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 986 values | visit_date timestamp[us] | revision_date timestamp[us] | committer_date timestamp[us] | github_id int64 3.89k 681M ⌀ | star_events_count int64 0 209k | fork_events_count int64 0 110k | gha_license_id stringclasses 23 values | gha_event_created_at timestamp[us] | gha_created_at timestamp[us] | gha_language stringclasses 145 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 122 values | content stringlengths 3 10.4M | authors listlengths 1 1 | author_id stringlengths 0 158 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
97b1ff339a1eb48f4f55d2efa03ee189bc2340db | 431c05db5dd38c69793dccf5988bbe3daa91b96f | /build tree form inorder & preorder.cpp | 5fade00de356ad0eabb9aff643ea3c30e550fee0 | [] | no_license | anuragpratap05/C_B_Binary_Trees | 8bf95369f1b18313cbb6a7fb2798eaaba3a5941d | c8e88d259a89c001cfe6e251e757a20094e6d7c2 | refs/heads/main | 2023-01-19T12:17:03.775721 | 2020-11-22T05:02:56 | 2020-11-22T05:02:56 | 314,506,067 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 5,147 | cpp | # C_B_Binary_Trees
#include<bits/stdc++.h>
using namespace std;
class node
{
public:
int data;
node* left;
node* right;
node(int d)
{
data = d;
left = NULL;
right = NULL;
}
};
node* buildtree()
{
int d;
cin >> d;
if (d == -1)
{
return NULL;
}
node* ans = new node(d);
ans->left = buildtree();
ans->right = buildtree();
return ans;
}
void print(node* rootnode)
{
if (rootnode == NULL)
{
return;
}
cout << rootnode->data << " ";
print(rootnode->left);
print(rootnode->right);
}
void printin(node* rootnode)
{
if (rootnode == NULL)
{
return;
}
printin(rootnode->left);
cout << rootnode->data << " ";
printin(rootnode->right);
}
void printpost(node* rootnode)
{
if (rootnode == NULL)
{
return;
}
printpost(rootnode->left);
printpost(rootnode->right);
cout << rootnode->data << " ";
}
int height(node* rootnode)
{
if (rootnode == NULL)
{
return 0;
}
int ls = height(rootnode->left);
int rs = height(rootnode->right);
return max(ls, rs) + 1;
}
void print_kth_level(node* rootnode, int k)
{
if (rootnode == NULL)
{
return;
}
if (k == 1)
{
cout << rootnode->data << " ";
return;
}
print_kth_level(rootnode->left, k - 1);
print_kth_level(rootnode->right, k - 1);
return;
}
void print_all_levels(node* rootnode)
{
int H = height(rootnode);
for (int i = 1; i <= H; i++)
{
print_kth_level(rootnode, i);
cout << endl;
}
return;
}
void bfs(node* rootnode)
{
queue<node*> q;
q.push(rootnode);
q.push(NULL);
while (!q.empty())
{
node* f = q.front();
if (f == NULL)
{
cout << endl;
q.pop();
if (!q.empty())
{
q.push(NULL);
}
}
else
{
cout << f->data << " " ;
q.pop();
if (f->left)
{
q.push(f->left);
}
if (f->right)
{
q.push(f->right);
}
}
}
}
int count(node* root)
{
if (root == NULL)
{
return 0;
}
int ans1 = count(root->left);
int ans2 = count(root->right);
return 1 + (ans1 + ans2);
}
int sum(node* root)
{
if (root == NULL)
{
return 0;
}
int ans1 = sum(root->left);
int ans2 = sum(root->right);
return root->data + (ans1 + ans2);
}
int diameter(node* root)
{
if (root == NULL)
{
return 0;
}
int h1 = height(root->left);
int h2 = height(root->right);
int op1 = h1 + h2;
int op2 = diameter(root->left);
int op3 = diameter(root->right);
return max(max(op1, op2), op3);
}
class Pair {
public:
int height;
int diameter;
};
Pair fastDiameter(node*root) {
Pair p;
if (root == NULL) {
p.diameter = p.height = 0;
return p;
}
//Otherwise
Pair left = fastDiameter(root->left);
Pair right = fastDiameter(root->right);
p.height = max(left.height, right.height) + 1;
p.diameter = max(left.height + right.height, max(left.diameter, right.diameter));
return p;
}
int replacesum(node* root)
{
if (root == NULL)
{
return 0;
}
if (root->left == NULL and root->right == NULL)
{
return root->data;
}
int leftsum = replacesum(root->left);
int rightsum = replacesum(root->right);
int temp = root->data;
root->data = leftsum + rightsum;
return temp + root->data;
}
class Hbpair
{
public:
int height;
bool balance;
};
Hbpair isbalnce(node* root)
{
Hbpair p;
if (root == NULL)
{
p.height = 0;
p.balance = true;
return p;
}
Hbpair left = isbalnce(root->left);
Hbpair right = isbalnce(root->right);
p.height = max(left.height , right.height) + 1;
if (abs(left.height - right.height) <= 1 and left.balance and right.balance)
{
p.balance = true;
}
else
{
p.balance = false;
}
return p;
}
node* build_from_array(int a[], int start, int end)
{
if (start > end)
{
return NULL;
}
int mid = (start + end) / 2;
node* n = new node(a[mid]);
n->left = build_from_array(a, start, mid - 1);
n->right = build_from_array(a, mid + 1, end);
return n;
}
node* createTreeFromTrav(int *in, int *pre, int s, int e) {
static int i = 0;
//Base Case
if (s > e) {
return NULL;
}
//Rec Case
node *root = new node(pre[i]);
int index = -1;
for (int j = s; s <= e; j++) {
if (in[j] == pre[i]) {
index = j;
break;
}
}
i++;
root->left = createTreeFromTrav(in, pre, s, index - 1);
root->right = createTreeFromTrav(in, pre, index + 1, e);
return root;
}
int main()
{
#ifndef ONLINE_jUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
//node* root = buildtree();
//print(root);
cout << endl;
//printin(root);
cout << endl;
//printpost(root);
//cout << height(root) << endl;
//print_kth_level(root, 3);
//print_all_levels(root);
//bfs(root);
//cout << count(root) << endl;
//cout << sum(root) << endl;
//cout << diameter(root) << endl;
//Pair p = fastDiameter(root);
//cout << p.height << endl;
//cout << p.diameter << endl;
//bfs(root);
//replacesum(root);
//cout << endl;
//bfs(root);
/*Hbpair ans = isbalnce(root);
cout << ans.height << endl;
if (ans.balance)
{
cout << "balanced" << endl;
//cout << ans.height << endl;
}
else
{
cout << "not balanced" << endl;
}*/
int in[] = {3, 2, 8, 4, 1, 6, 7, 5};
int pre[] = {1, 2, 3, 4, 8, 5, 6, 7};
int n = sizeof(in) / sizeof(int);
node*root = createTreeFromTrav(in, pre, 0, n - 1);
bfs(root);
}
| [
"noreply@github.com"
] | anuragpratap05.noreply@github.com |
884b83051053cf36c7a3ce5ba031c764d310c189 | b82b8cb14cb93ef1d5690d02371932792bcc6930 | /vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/WhiteSpace/SuperfluousWhitespaceUnitTest.5.inc | 90c8328644bbb24270a811d539d839d0a3fda3f0 | [
"MIT"
] | permissive | adityarifqyfauzan/wisata_indramayu | a4e80fa24815c53bb5ccd0aab99ffd3a3fa29b6d | b25fc68b446ce36274799c2d975af4ae7172e3b2 | refs/heads/main | 2023-02-03T10:53:11.521990 | 2020-12-21T23:30:33 | 2020-12-21T23:30:33 | 323,470,823 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 103 | inc | <?php
// This should throw an error - unicode space before open tag and after close tag.
?>
| [
"aditya.fauzan@indosystem.com"
] | aditya.fauzan@indosystem.com |
7210a1136403b60cb7d308c2671440312e8b964b | 84131823def8485ee9dbc94e14bb448522c6c260 | /so_5/rt/stats/impl/h/activity_tracking.hpp | 55fe5f623ff1312ed9a568254b62cebfe18406d3 | [
"BSD-3-Clause"
] | permissive | sigman78/sobjectizer | ea35f622b30fd42f13ab7c6ed2d21c326886c154 | d81c20a1264582e427a9a35d212361425fc34277 | refs/heads/master | 2021-04-13T01:44:37.343988 | 2017-06-19T08:18:32 | 2017-06-19T08:18:32 | 94,554,443 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 6,127 | hpp | /*
* SObjectizer-5
*/
/*!
* \file
* \since
* v.5.5.18
*
* \brief Details for implementation of activity tracking.
*/
#pragma once
#include <so_5/h/types.hpp>
#include <so_5/h/spinlocks.hpp>
#include <so_5/rt/stats/h/work_thread_activity.hpp>
namespace so_5
{
namespace stats
{
namespace activity_tracking_stuff {
/*!
* \since
* v.5.5.18
*
* \brief Various traits of activity tracking implementation.
*/
struct traits
{
//! Type of lock object to be used for synchronization of
//! activity tracking data.
using lock_t = default_spinlock_t;
};
/*!
* \brief An analog of std::lock_guard but without actual locking actions.
*
* This class is inteded to be used with different lock policies for
* stats_collector_t.
*
* \since
* v.5.5.18
*/
template< typename L >
struct no_actual_lock
{
no_actual_lock( L & ) { /* Do nothing. */ }
};
/*!
* \brief Default locking policy for stats_collector_t.
*
* Performs actual locking on start/stop and take_activity operations.
*
* \since
* v.5.5.18
*/
template< typename LOCK_HOLDER >
struct default_lock_policy
{
using start_stop_lock_t = std::lock_guard< LOCK_HOLDER >;
using take_stats_lock_t = std::lock_guard< LOCK_HOLDER >;
};
/*!
* \brief A custom locking policy for stats_collector_t.
*
* Performs actual locking only on take_activity operation.
*
* \since
* v.5.5.18
*/
template< typename LOCK_HOLDER >
struct no_lock_at_start_stop_policy
{
using start_stop_lock_t = no_actual_lock< LOCK_HOLDER >;
using take_stats_lock_t = std::lock_guard< LOCK_HOLDER >;
};
/*!
* \brief Base for the case of internal stats lock.
*
* \since
* v.5.5.18
*/
class internal_lock
{
traits::lock_t m_lock;
public :
using start_stop_lock_t = std::lock_guard< internal_lock >;
using take_stats_lock_t = std::lock_guard< internal_lock >;
internal_lock() {}
void lock() { m_lock.lock(); }
void unlock() { m_lock.unlock(); }
};
/*!
* \brief Base for the case of externals stats lock.
*
* \since
* v.5.5.18
*/
template<
typename LOCK_TYPE = traits::lock_t,
template<class> class LOCK_POLICY = default_lock_policy >
class external_lock
{
LOCK_TYPE & m_lock;
public :
using start_stop_lock_t =
typename LOCK_POLICY< external_lock >::start_stop_lock_t;
using take_stats_lock_t =
typename LOCK_POLICY< external_lock >::take_stats_lock_t;
external_lock( LOCK_TYPE & lock ) : m_lock( lock ) {}
void lock() { m_lock.lock(); }
void unlock() { m_lock.unlock(); }
};
/*!
* \brief A special class for cases where lock is not needed at all.
*
* Usage example:
* \code
class real_activity_tracker_t final
{
so_5::stats::activity_tracking_stuff::stats_collector_t<
so_5::stats::activity_tracking_stuff::null_lock >
m_waiting{};
so_5::stats::activity_tracking_stuff::stats_collector_t<
so_5::stats::activity_tracking_stuff::null_lock >
m_working{};
...
};
* \endcode
*
* \since
* v.5.5.19
*/
struct null_lock
{
public :
using start_stop_lock_t = no_actual_lock< null_lock >;
using take_stats_lock_t = no_actual_lock< null_lock >;
null_lock() {}
};
/*!
* \brief Helper for collecting activity stats.
*
* \since
* v.5.5.18
*/
template< typename LOCK_HOLDER >
class stats_collector_t : protected LOCK_HOLDER
{
LOCK_HOLDER &
lock_holder() { return *this; }
public :
template< typename... ARGS >
stats_collector_t( ARGS && ...args )
: LOCK_HOLDER( std::forward<ARGS>(args)... )
{}
void
start()
{
typename LOCK_HOLDER::start_stop_lock_t lock{ lock_holder() };
do_start();
}
/*!
* \brief A helper method for safe start if start method hasn't been
* called yet.
*
* \since
* v.5.5.19
*/
void
start_if_not_started()
{
typename LOCK_HOLDER::start_stop_lock_t lock{ lock_holder() };
if( !m_is_in_working )
do_start();
}
void
stop()
{
typename LOCK_HOLDER::start_stop_lock_t lock{ lock_holder() };
m_is_in_working = false;
so_5::stats::details::update_stats_from_current_time(
m_work_activity,
m_work_started_at );
}
so_5::stats::activity_stats_t
take_stats()
{
so_5::stats::activity_stats_t result;
bool is_in_working{ false };
so_5::stats::clock_type_t::time_point work_started_at;
{
typename LOCK_HOLDER::take_stats_lock_t lock{ lock_holder() };
result = m_work_activity;
if( true == (is_in_working = m_is_in_working) )
work_started_at = m_work_started_at;
}
if( is_in_working )
so_5::stats::details::update_stats_from_current_time(
result,
work_started_at );
return result;
}
private :
//! A flag for indicating work activity.
bool m_is_in_working{ false };
//! A time point when current activity started.
so_5::stats::clock_type_t::time_point m_work_started_at;
//! A statistics for work activity.
so_5::stats::activity_stats_t m_work_activity{};
void
do_start()
{
m_is_in_working = true;
m_work_started_at = so_5::stats::clock_type_t::now();
m_work_activity.m_count += 1;
}
};
/*!
* \brief Helper function for creation of dispatcher with respect
* to activity tracking flag in dispatcher params and in Environment's
* params.
*
* \since
* v.5.5.18
*/
template<
typename COMMON_DISP_IFACE_TYPE,
typename DISP_NO_TRACKING,
typename DISP_WITH_TRACKING,
typename ENV,
typename DISP_PARAMS,
typename... ARGS >
std::unique_ptr< COMMON_DISP_IFACE_TYPE >
create_appropriate_disp(
ENV & env,
const DISP_PARAMS & disp_params,
ARGS && ...args )
{
std::unique_ptr< COMMON_DISP_IFACE_TYPE > disp;
auto tracking = disp_params.work_thread_activity_tracking();
if( work_thread_activity_tracking_t::unspecified == tracking )
tracking = env.work_thread_activity_tracking();
if( work_thread_activity_tracking_t::on == tracking )
disp.reset(
new DISP_WITH_TRACKING{ std::forward<ARGS>(args)... } );
else
disp.reset(
new DISP_NO_TRACKING{ std::forward<ARGS>(args)... } );
return disp;
}
} /* namespace activity_tracking_stuff */
} /* namespace stats */
} /* namespace so_5 */
| [
"sigman78@gmail.com"
] | sigman78@gmail.com |
9bb3bb6aaa86b4eeaccf21f348e55e48d04504c4 | 47a668293f589b32e4191842fe8322dcb8b3ad2f | /app/src/main/jniLibs/arm64-v8a/include/nfiq2_fingerprintimagedata.hpp | 9098ba3e7114636c164cb1e1a6d8edf96a71e097 | [] | no_license | luongdv3vts/NFIQ2_ANdy | 6b722b2434546a437aa932a50a30a60ab931ae6a | e19d5058ccadb7ff0dfbba135e5205294219950a | refs/heads/main | 2023-07-09T02:41:43.132818 | 2021-08-06T22:35:39 | 2021-08-06T22:35:39 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,748 | hpp | /*
* This file is part of NIST Fingerprint Image Quality (NFIQ) 2. For more
* information on this project, refer to:
* - https://nist.gov/services-resources/software/nfiq2
* - https://github.com/usnistgov/NFIQ2
*
* This work is in the public domain. For complete licensing details, refer to:
* - https://github.com/usnistgov/NFIQ2/blob/master/LICENSE.md
*/
#ifndef NFIQ2_FINGERPRINTIMAGEDATA_HPP_
#define NFIQ2_FINGERPRINTIMAGEDATA_HPP_
#include "nfiq2_data.hpp"
namespace NFIQ2 {
/**
* Binary data representing a decompressed fingerprint image, canonically
* encoded as per ISO/IEC 19794-4:2005.
*/
class FingerprintImageData : public Data {
public:
/** 500 PPI resolution. */
static const uint16_t Resolution500PPI { 500 };
/** Default constructor. */
FingerprintImageData();
/**
* @brief
* Constructor that does not store image data.
*
* @param width
* Width of the image in pixels.
* @param height
* Height of the image in pixels.
* @param fingerCode
* Finger position of the fingerprint in the image.
* @param ppi
* Resolution of the image in pixels per inch.
*/
FingerprintImageData(
uint32_t width, uint32_t height, uint8_t fingerCode, uint16_t ppi);
/**
* @brief
* Constructor storing image data.
*
* @param pData
* Pointer to decompressed 8 bit-per-pixel grayscale image data,
* canonically encoded as per ISO/IEC 19794-4:2005.
* @param dataSize
* Size of the buffer pointed to by `pData`.
* @param width
* Width of the image in pixels.
* @param height
* Height of the image in pixels.
* @param fingerCode
* Finger position of the fingerprint in the image.
* @param ppi
* Resolution of the image in pixels per inch.
*/
FingerprintImageData(const uint8_t *pData, uint32_t dataSize,
uint32_t width, uint32_t height, uint8_t fingerCode, uint16_t ppi);
/** Copy constructor. */
FingerprintImageData(const FingerprintImageData &otherData);
/** Destructor. */
virtual ~FingerprintImageData();
/** Width of the fingerprint image in pixels. */
uint32_t width { 0 };
/** Height of the fingerprint image in pixels. */
uint32_t height { 0 };
/** ISO finger code of the fingerprint in the image. */
uint8_t fingerCode { 0 };
/** Pixels per inch of the fingerprint image. */
uint16_t ppi { Resolution500PPI };
/**
* @brief
* Obtain a copy of the image with near-white lines surrounding the
* fingerprint removed.
*
* @return
* Cropped fingerprint image.
*
* @throws NFIQ2::Exception
* Error performing the crop, or the image is too small to be processed
* after cropping.
*/
NFIQ2::FingerprintImageData copyRemovingNearWhiteFrame() const;
};
} // namespace NFIQ
#endif /* NFIQ2_FINGERPRINTIMAGEDATA_HPP_ */
| [
"akshatbajpai.biz@gmail.com"
] | akshatbajpai.biz@gmail.com |
e7fded952988667e4c74b2837f76be5e07799ec7 | 2cd6255a426d76f924c8c1f3c77a96c7c3be1794 | /src/repl/snapshot.hpp | 3c9326c8da4ffddaa1038973659be127f9016600 | [
"BSD-3-Clause"
] | permissive | masterve/test | 4019a0bf79a9e961f9034775d09380ccda86da6a | 87a06f974ddc0ca7baf0ca082d7ae8999d9a4196 | refs/heads/master | 2021-01-16T21:36:39.452527 | 2016-07-10T15:44:16 | 2016-07-10T15:44:16 | 63,005,966 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 9,239 | hpp | /*
*Copyright (c) 2013-2013, yinqiwen <yinqiwen@gmail.com>
*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 Redis nor the names of its contributors may be used
* to endorse or promote products derived from this software without
* specific prior written permission.
*
*THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
*AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
*IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
*ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
*BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
*CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
*SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
*INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
*CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
*ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
*THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef SNAPSHOT_HPP_
#define SNAPSHOT_HPP_
#include <string>
#include <deque>
#include "common.hpp"
#include "buffer/buffer_helper.hpp"
#include "context.hpp"
#include "db/codec.hpp"
#include "db/db_utils.hpp"
#include "thread/thread_mutex_lock.hpp"
namespace ardb
{
enum SnapshotType
{
REDIS_DUMP = 1, ARDB_DUMP, BACKUP_DUMP
};
enum SnapshotState
{
SNAPSHOT_INVALID = 0, DUMP_START = 1, DUMPING, DUMP_SUCCESS, DUMP_FAIL, LOAD_START = 10, LODING, LOAD_SUCCESS, LOAD_FAIL
};
class Snapshot;
typedef int SnapshotRoutine(SnapshotState state, Snapshot* snapshot, void* cb);
class ObjectIO
{
protected:
DBWriter* m_dbwriter;
virtual bool Read(void* buf, size_t buflen, bool cksm = true) = 0;
virtual int Write(const void* buf, size_t buflen) = 0;
int WriteType(uint8 type);
int WriteKeyType(KeyType type);
int WriteLen(uint32 len);
int WriteMillisecondTime(uint64 ts);
int WriteDouble(double v);
int WriteLongLongAsStringObject(long long value);
int WriteRawString(const std::string& str);
int WriteRawString(const char *s, size_t len);
int WriteLzfStringObject(const char *s, size_t len);
int WriteTime(time_t t);
int WriteStringObject(const Data& o);
int ReadType();
time_t ReadTime();
int64 ReadMillisecondTime();
uint32_t ReadLen(int *isencoded);
bool ReadInteger(int enctype, int64& v);
bool ReadLzfStringObject(std::string& str);
bool ReadString(std::string& str);
int ReadDoubleValue(double&val);
bool RedisLoadObject(Context& ctx, int type, const std::string& key, int64 expiretime);
void RedisLoadListZipList(Context& ctx, unsigned char* data, const std::string& key, ValueObject& meta_value);
void RedisLoadHashZipList(Context& ctx, unsigned char* data, const std::string& key, ValueObject& meta_value);
void RedisLoadZSetZipList(Context& ctx, unsigned char* data, const std::string& key, ValueObject& meta_value);
void RedisLoadSetIntSet(Context& ctx, unsigned char* data, const std::string& key, ValueObject& meta_value);
void RedisWriteMagicHeader();
int ArdbWriteMagicHeader();
int ArdbLoadChunk(Context& ctx, int type);
int ArdbLoadBuffer(Context& ctx, Buffer& buffer);
DBWriter& GetDBWriter();
public:
ObjectIO() :
m_dbwriter(NULL)
{
}
void SetDBWriter(DBWriter* writer)
{
m_dbwriter = writer;
}
int ArdbSaveRawKeyValue(const Slice& key, const Slice& value, Buffer& buffer, int64 ttl);
int ArdbFlushWriteBuffer(Buffer& buffer);
virtual ~ObjectIO()
{
}
};
class ObjectBuffer: public ObjectIO
{
private:
Buffer m_buffer;
bool Read(void* buf, size_t buflen, bool cksm);
int Write(const void* buf, size_t buflen);
public:
ObjectBuffer();
ObjectBuffer(const std::string& content);
bool RedisSave(Context& ctx, const std::string& key, std::string& content, uint64* ttl = NULL);
bool RedisLoad(Context& ctx, const std::string& key, int64 ttl);
bool CheckReadPayload();
Buffer& GetInternalBuffer()
{
return m_buffer;
}
bool ArdbLoad(Context& ctx);
void Reset()
{
m_buffer.Clear();
}
};
class SnapshotManager;
class Snapshot: public ObjectIO
{
protected:
FILE* m_read_fp;
FILE* m_write_fp;
std::string m_file_path;
uint64 m_cksm;
SnapshotRoutine* m_routine_cb;
void *m_routine_cbdata;
uint64 m_processed_bytes;
uint64 m_file_size;
SnapshotState m_state;
uint64 m_routinetime;
char* m_read_buf;
int64 m_expected_data_size;
int64 m_writed_data_size;
Buffer m_write_buffer;
uint64 m_cached_repl_offset;
uint64 m_cached_repl_cksm;
time_t m_save_time;
SnapshotType m_type;
void* m_snapshot_iter;
bool Read(void* buf, size_t buflen, bool cksm);
int RedisLoad();
int RedisSave();
int ArdbSave();
int ArdbLoad();
int BackupSave();
int BackupLoad();
int DoSave();
int PrepareSave(SnapshotType type, const std::string& file, SnapshotRoutine* cb, void *data);
void VerifyState();
friend class SnapshotManager;
public:
Snapshot();
SnapshotType GetType()
{
return m_type;
}
uint64 CachedReplOffset()
{
return m_cached_repl_offset;
}
uint64 CachedReplCksm()
{
return m_cached_repl_cksm;
}
const std::string& GetPath()
{
return m_file_path;
}
time_t SaveTime()
{
return m_save_time;
}
bool IsSaving();
bool IsReady();
void MarkDumpComplete();
void SetExpectedDataSize(int64 size);
int64 DumpLeftDataSize();
int64 ProcessLeftDataSize();
int Write(const void* buf, size_t buflen);
int OpenWriteFile(const std::string& file);
int OpenReadFile(const std::string& file);
int SetFilePath(const std::string& path);
int Load(const std::string& file, SnapshotRoutine* cb, void *data);
int Reload(SnapshotRoutine* cb, void *data);
int Save(SnapshotType type, const std::string& file, SnapshotRoutine* cb, void *data);
int BGSave(SnapshotType type, const std::string& file, SnapshotRoutine* cb = NULL, void *data = NULL);
void Flush();
void Remove();
int Rename(const std::string& default_file = "dump.rdb");
void Close();
void SetRoutineCallback(SnapshotRoutine* cb, void *data);
~Snapshot();
static SnapshotType GetSnapshotType(const std::string& file);
static SnapshotType GetSnapshotTypeByName(const std::string& name);
static std::string GetSyncSnapshotPath(SnapshotType type, uint64 offset, uint64 cksm);
};
class SnapshotManager
{
private:
typedef std::deque<Snapshot*> SnapshotArray;
ThreadMutexLock m_snapshots_lock;
SnapshotArray m_snapshots;
public:
SnapshotManager();
void Init();
void Routine();
Snapshot* GetSyncSnapshot(SnapshotType type, SnapshotRoutine* cb, void *data);
Snapshot* NewSnapshot(SnapshotType type, bool bgsave, SnapshotRoutine* cb, void *data);
void AddSnapshot(const std::string& path);
time_t LastSave();
int CurrentSaverNum();
time_t LastSaveCost();
int LastSaveErr();
time_t LastSaveStartUnixTime();
void PrintSnapshotInfo(std::string& str);
};
extern SnapshotManager* g_snapshot_manager;
}
#endif /* RDB_HPP_ */
| [
"igors@prana-bindu.com"
] | igors@prana-bindu.com |
2a87269d868f9f1f908c1ad8907945c517f8dcd7 | d0c44dd3da2ef8c0ff835982a437946cbf4d2940 | /cmake-build-debug/programs_tiling/function13955/function13955_schedule_5/function13955_schedule_5.cpp | 838ddac9f75f5af60524ded859a815c45754ded3 | [] | 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 | 913 | cpp | #include <tiramisu/tiramisu.h>
using namespace tiramisu;
int main(int argc, char **argv){
tiramisu::init("function13955_schedule_5");
constant c0("c0", 131072), c1("c1", 512);
var i0("i0", 0, c0), i1("i1", 0, c1), i100("i100", 1, c0 - 1), i101("i101", 1, c1 - 1), i01("i01"), i02("i02"), i03("i03"), i04("i04");
input input0("input0", {i0, i1}, p_int32);
computation comp0("comp0", {i100, i101}, (input0(i100, i101) + input0(i100 + 1, i101) + input0(i100 - 1, i101)));
comp0.tile(i100, i101, 64, 128, i01, i02, i03, i04);
comp0.parallelize(i01);
buffer buf00("buf00", {131072, 512}, p_int32, a_input);
buffer buf0("buf0", {131072, 512}, p_int32, a_output);
input0.store_in(&buf00);
comp0.store_in(&buf0);
tiramisu::codegen({&buf00, &buf0}, "../data/programs/function13955/function13955_schedule_5/function13955_schedule_5.o");
return 0;
} | [
"ei_mekki@esi.dz"
] | ei_mekki@esi.dz |
5c2679ebb3c361f9d82a3f6868ac7fd847a63cb8 | 0ac5b1acf32ddba4d3bbf866745b7e9903c227f0 | /inc/ISession_Point.h | c51b1df1dae278c09e5bdeda8a0dfe81875f54a8 | [] | no_license | zhucci/ASP_Project | cdda5c2c2419b1edf3385372828c952b19fe6e96 | c9b85a671df9cad0b8dc1fdf2ed6c4ce4db47d88 | refs/heads/master | 2016-09-12T01:11:24.022511 | 2016-05-27T10:42:36 | 2016-05-27T10:42:36 | 51,695,182 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,194 | h | // ISession_Point.h: interface for the ISession_Point class.
//
//////////////////////////////////////////////////////////////////////
#ifndef _ISESSION_POINT_
#define _ISESSION_POINT_
#include <Standard_Macro.hxx>
#include <Standard_DefineHandle.hxx>
#include "OCCT_Headers.h"
DEFINE_STANDARD_HANDLE(ISession_Point,AIS_InteractiveObject)
class ISession_Point : public AIS_InteractiveObject
{
public:
ISession_Point();
ISession_Point(Standard_Real X,Standard_Real Y ,Standard_Real Z);
ISession_Point(const gp_Pnt2d& aPoint,Standard_Real Elevation = 0);
ISession_Point(const gp_Pnt& aPoint);
virtual ~ISession_Point();
DEFINE_STANDARD_RTTI(ISession_Point)
private :
void Compute (const Handle(PrsMgr_PresentationManager3d)& aPresentationManager,
const Handle(Prs3d_Presentation)& aPresentation,
const Standard_Integer aMode);
void Compute (const Handle(Prs3d_Projector)& aProjector,
const Handle(Prs3d_Presentation)& aPresentation);
void ComputeSelection (const Handle(SelectMgr_Selection)& aSelection,
const Standard_Integer unMode);
gp_Pnt myPoint;
};
#endif // !defined(_ISESSION_POINT_)
| [
"zhuchkov612@gmail.com"
] | zhuchkov612@gmail.com |
fdfc0f4453f6bd8a8cf6492b3a61008561429381 | 040edc2bdbefe7c0d640a18d23f25a8761d62f40 | /25mt/src/psavefit.cpp | 75a894f70b1bd4148a1c64891a73215b29b5c9d1 | [
"BSD-2-Clause"
] | permissive | johnrsibert/tagest | 9d3be8352f6bb5603fbd0eb6140589bb852ff40b | 0194b1fbafe062396cc32a0f5a4bbe824341e725 | refs/heads/master | 2021-01-24T00:18:24.231639 | 2018-01-16T19:10:25 | 2018-01-16T19:10:25 | 30,438,830 | 3 | 3 | null | 2016-12-08T17:59:28 | 2015-02-07T00:05:30 | C++ | UTF-8 | C++ | false | false | 5,380 | cpp | //$Id: psavefit.cpp 2948 2012-02-11 01:30:26Z eunjung $
#include "par_t.h"
ostream& setfixed(ostream& _s);
const extern double min_nb_par;
const extern double max_nb_par;
extern ofstream clogf;
template <typename D3_ARRAY, typename MATRIX, typename VECTOR, typename DOUBLE>
void par_t<D3_ARRAY,MATRIX,VECTOR,DOUBLE>::savefit(ofstream& pf, const char* fullname)
{
if (!pf)
{
cerr << "Cannot open file " << fullname << endl;
exit(1);
}
pf << par_file_version
<< "\n# " << fullname
//<< "\n# " << executable
<< "\n#\n# M N deltax deltay sw_long sw_lat\n"
<< setw(5) << m << setw(5) << n
<< setw(7) << deltax << setw(7) << deltay << " " << sw_coord << endl;
pf << "# grid map\n";
pf << "# 1";
for (int i=2; i<=m; i++)
pf << setw(5) << i;
pf << "\n#\n";
for (int j=n; j>=1; j--)
{
for (int i=1; i<=m; i++)
{
pf << setw(5) << gridmap(i, j);
}
pf << endl;
}
pf << "#\n# boundary conditions:\n"
<< "# west_bndry east_bndry south_bndry north_bndry\n"
<< setw(8) << west_bndry
<< setw(14) << east_bndry
<< setw(14) << south_bndry
<< setw(14) << north_bndry
<< endl;
pf << m_ipar;
//Count releases > 0
int posrel = 0;
for (int k = 1; k <= nrelease; k++)
{
if (tr[k].cohort > 0)
posrel++;
}
pf << "\n# nmonth start_yr start_mo nrelease \n"
<< setw(8) << nmonth
<< setw(12) << start_date.get_year()
<< setw(12) << start_date.get_month_value()
<< setw(12) << posrel //Do not count zero cohorts
<< "\n# nfleet \n"
<< setw(8) << nfleet
<< "\n#" << endl;
pf << "# Model Parameters:\n"
<< "# natural\n"
<< "# mortality\n"
<< setw(25) << setprecision(17) << mort
<< "\n#" << endl;
if (m_ipar[19] > 0)
{
pf << "# special mortality\n";
pf << setw(25) << setprecision(17) << special_mort
<< "\n#" << endl;
}
pf << "#\n# fleet catchability reporting rate do fleet kludge\n";
for (int i=1; i <= nfleet; i++)
{
pf << setw(8) << (char*)fleet_names[i] << " "
<< setw(25) << setprecision(15) << q(i)
<< setw(25) << setprecision(15) << report_rates[i]
<< setw(5) << DomesticFleetKludgeFlag(i)
<< endl;
}
if (num_afm)
{
pf << "#\n# " << num_afm << " fishing mortality anomalies" << endl;
//year_month afm_date;
adstring afm_fleet;
for (int i = 1; i <= num_afm; i++)
{
//afm_date.set(afm_yr(i),afm_mo(i));
afm_fleet = fleet_names(afm_fl(i));
pf << afm_yr(i) << " " << afm_mo(i) << " " << afm_fleet << " " << afm_i(i)
<< " " << " " << afm_j(i)
<< setw(25) << setprecision(15) << afm(i) << endl;
}
}
pf << "#\n# tag releases:\n"
<< "# cohort year month i j number\n";
for (int k = 1; k <= nrelease; k++)
{
if (tr[k].cohort > 0)
{
pf << setfixed
// << setw(8) << get_tr_cohort(k) // cohort_index(k)
<< setw(8) << get_tr_release_cohort(k)
<< setw(8) << get_tr_date(k).get_year()
<< setw(8) << get_tr_date(k).get_month_value()
<< setw(8) << setprecision(2) << index_to_long(get_tr_i(k))
<< setw(8) << setprecision(2) << index_to_lat(get_tr_j(k))
<< setw(7) << int(get_tr_tags(k))
<< endl;
clogf << setfixed << setprecision(5);
}
}
pf << "#\n# parameter bounds\n"
<< "# minsig maxsig\n"
<< setprecision(8)
<< " " << minsig << " " << maxsig << endl
<< "# minmort maxmort\n"
<< " " << minmort << " " << maxmort << endl
<< "# minq maxq\n"
<< " " << minq << " " << maxq << endl
<< "# minr_rates maxr_rates\n"
<< " " << minr_rates << " " << maxr_rates << endl
<< "# minvel maxvel\n"
<< " " << minvel << " " << maxvel << endl;
if(m_ipar(83) ==1)
{
if(m_ipar(84) ==1)
{
pf<< "# minsus_spd maxsus_spd\n"
<< " " << minsus_spd << " " << maxsus_spd << endl;
}
if(m_ipar(85) == 1)
{
//pf << "# minMin_D maxMin_D\n"
// << " " << minMin_D << " " << maxMin_D << endl
pf << "# minslope maxslope\n"
<< " " << minslope << " " << maxslope << endl;
//<< "# mininflection maxinflection\n"
//<< " " << mininflection << " " << maxinflection << endl;
}
}
if ( (m_ipar[11] == 4) || (m_ipar[11] == 5) ||
(m_ipar[11] ==14) || (m_ipar[11] ==15) ||
(m_ipar[11] ==24) || (m_ipar[11] ==25) )
{
pf << "#" << endl;
pf << "# min_nb_par = " << min_nb_par << endl;
pf << "# max_nb_par = " << max_nb_par << endl;
pf << "# negative binomial parameters:" << endl;
if ( (m_ipar[11] ==24) || (m_ipar[11] ==25) )
{
for (int f = 1; f <= nfleet; f++)
{
pf << "# " << (char*)fleet_names[f] << endl;
pf << setw(23) << setprecision(16) << nb_par(f) << endl;
}
}
else
pf << setw(23) << setprecision(16) << nb_par << endl;
}
}
template void par_t<d3_array,dmatrix,dvector,double>::savefit(ofstream& pf, const char* fullname);
template void par_t<dvar3_array,dvar_matrix,dvar_vector,dvariable>::savefit(ofstream& pf, const char* fullname);
| [
"sibert@hawaii.edu"
] | sibert@hawaii.edu |
4c2340f59d48aa0d3ddb1d61494b4ae82a5df9dc | 63e13aa6d118b2c5d7eb94bc98d656e54cada19a | /src/main.cpp | e72a971ab8971678a4cfc1b6f89b89d5d2772676 | [
"MIT"
] | permissive | tsteinholz/Hangman | 21368dc27bcb706f264eab62f1cc05b46942cb74 | 87f8faec5b26438ca3f4b51bd8cafe679ddb5b35 | refs/heads/master | 2021-01-10T03:02:19.776928 | 2016-03-09T12:56:12 | 2016-03-09T12:56:12 | 50,922,690 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 5,629 | cpp | //-----------------------------------------------------------------------------
// The MIT License (MIT)
//
// Copyright (c) 2016 Thomas Steinholz
//
// 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 <allegro5/allegro.h>
#include "util/assetmanager.h"
#include "scenes/scene.h"
#include "scenes/mainmenu.h"
Scene *Scene::Current = nullptr;
int main() {
srand((unsigned int) time(NULL));
ALLEGRO_DISPLAY *display = NULL;
ALLEGRO_EVENT_QUEUE *queue;
ALLEGRO_TIMER *timer;
display = al_create_display(ASSET_MANAGER.SCREEN_W, ASSET_MANAGER.SCREEN_H);
if (!display) {
printf("al_create_display Failed!\n");
exit(-1);
}
queue = al_create_event_queue();
timer = al_create_timer(1.0 / 60);
al_register_event_source(queue, al_get_keyboard_event_source());
al_register_event_source(queue, al_get_mouse_event_source());
al_register_event_source(queue, al_get_display_event_source(display));
al_register_event_source(queue, al_get_timer_event_source(timer));
al_start_timer(timer);
// background gradient
ASSET_MANAGER.LoadImage("res/graphics/background.png", "background");
// data
ASSET_MANAGER.LoadDict("res/data/words.txt", "words");
// fonts
ASSET_MANAGER.LoadFont("res/fonts/cubic.ttf", 80, "cubic-header");
ASSET_MANAGER.LoadFont("res/fonts/league-gothic.ttf", 25, "cubic-credits");
ASSET_MANAGER.LoadFont("res/fonts/league-gothic.ttf", 45, "league");
ASSET_MANAGER.LoadFont("res/fonts/league-gothic.ttf", 125, "league-fancy");
ASSET_MANAGER.LoadFont("res/fonts/league-gothic.ttf", 25, "league-credits");
// animations
ASSET_MANAGER.LoadImage("res/animations/AddHead.png", "head");
ASSET_MANAGER.LoadImage("res/animations/AddTorso.png", "torso");
ASSET_MANAGER.LoadImage("res/animations/AddRArm.png", "right-arm");
ASSET_MANAGER.LoadImage("res/animations/AddLArm.png", "left-arm");
ASSET_MANAGER.LoadImage("res/animations/AddRLeg.png", "right-leg");
ASSET_MANAGER.LoadImage("res/animations/AddLLeg.png", "left-leg");
ASSET_MANAGER.LoadImage("res/animations/Death.png", "death");
// sounds
ASSET_MANAGER.LoadSound("res/sound/zipclick.ogg", "gui-click");
ASSET_MANAGER.LoadSound("res/sound/spring.ogg", "spring");
ASSET_MANAGER.LoadSound("res/sound/stab.ogg", "stab");
ASSET_MANAGER.LoadSound("res/sound/start_sound.ogg", "start sound");
bool render = true;
float bgx = ASSET_MANAGER.SCREEN_W / 2,
bgy = ASSET_MANAGER.SCREEN_H / 2,
bgvelx = rand() % 2 ? -.5f : .5f,
bgvely = rand() % 2 ? -.5f : .5f;
Scene::Current = new MainMenu();
while (Scene::GetExe()) {
ALLEGRO_EVENT event;
al_wait_for_event(queue, &event);
Scene::Current->Update(&event);
switch (event.type) {
case ALLEGRO_EVENT_DISPLAY_CLOSE:
Scene::SetExe(false);
break;
case ALLEGRO_EVENT_KEY_DOWN:
Scene::SetExe(event.keyboard.keycode != ALLEGRO_KEY_ESCAPE);
break;
case ALLEGRO_EVENT_TIMER:
if (bgx + ASSET_MANAGER.SCREEN_W >= al_get_bitmap_width(ASSET_MANAGER.GetImage("background")))
bgvelx = -bgvelx;
else if (bgx <= 5) bgvelx = -bgvelx;
if (bgy + ASSET_MANAGER.SCREEN_H >= al_get_bitmap_height(ASSET_MANAGER.GetImage("background")))
bgvely = -bgvely;
else if (bgy <= 5) bgvely = -bgvely;
bgx += bgvelx;
bgy += bgvely;
render = true;
break;
default:
break;
}
if (al_is_event_queue_empty(queue) && render) {
al_clear_to_color(al_map_rgb(0, 0, 0));
al_set_target_bitmap(al_get_backbuffer(display));
////////////////////////////////////////////////////////////////////
al_draw_scaled_bitmap(
ASSET_MANAGER.GetImage("background"),
bgx, bgy,
ASSET_MANAGER.SCREEN_W, ASSET_MANAGER.SCREEN_H,
0, 0,
ASSET_MANAGER.SCREEN_W, ASSET_MANAGER.SCREEN_H,
0);
Scene::Current->Render();
////////////////////////////////////////////////////////////////////
al_flip_display();
}
render = false;
}
al_destroy_display(display);
ASSET_MANAGER.DiscardAll();
return 0;
}
| [
"tsteinholz@yahoo.com"
] | tsteinholz@yahoo.com |
4521a5582bedec75d1bd0d203e775773e7100d7c | e30874b3aa20804833dd11788176f839fcd08690 | /cpp/include/cudf/strings/split/split_re.hpp | 14fcfaecdcdd3cbb20ebe0f2d0892cf47b2de698 | [
"Apache-2.0"
] | permissive | rapidsai/cudf | eaba8948cddde8161c3b02b1b972dab3df8d95b3 | c51633627ee7087542ad4c315c0e139dea58e408 | refs/heads/branch-23.10 | 2023-09-04T07:18:27.194295 | 2023-09-03T06:20:33 | 2023-09-03T06:20:33 | 90,506,918 | 5,386 | 751 | Apache-2.0 | 2023-09-14T00:27:03 | 2017-05-07T03:43:37 | C++ | UTF-8 | C++ | false | false | 9,792 | hpp | /*
* Copyright (c) 2022-2023, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#pragma once
#include <cudf/column/column.hpp>
#include <cudf/strings/strings_column_view.hpp>
#include <cudf/table/table.hpp>
#include <rmm/mr/device/per_device_resource.hpp>
namespace cudf {
namespace strings {
struct regex_program;
/**
* @addtogroup strings_split
* @{
* @file
*/
/**
* @brief Splits strings elements into a table of strings columns
* using a regex_program's pattern to delimit each string
*
* Each element generates a vector of strings that are stored in corresponding
* rows in the output table -- `table[col,row] = token[col] of strings[row]`
* where `token` is a substring between delimiters.
*
* The number of rows in the output table will be the same as the number of
* elements in the input column. The resulting number of columns will be the
* maximum number of tokens found in any input row.
*
* The `pattern` is used to identify the delimiters within a string
* and splitting stops when either `maxsplit` or the end of the string is reached.
*
* An empty input string will produce a corresponding empty string in the
* corresponding row of the first column.
* A null row will produce corresponding null rows in the output table.
*
* The regex_program's regex_flags are ignored.
*
* @code{.pseudo}
* s = ["a_bc def_g", "a__bc", "_ab cd", "ab_cd "]
* p1 = regex_program::create("[_ ]")
* s1 = split_re(s, p1)
* s1 is a table of strings columns:
* [ ["a", "a", "", "ab"],
* ["bc", "", "ab", "cd"],
* ["def", "bc", "cd", ""],
* ["g", null, null, null] ]
* p2 = regex_program::create("[ _]")
* s2 = split_re(s, p2, 1)
* s2 is a table of strings columns:
* [ ["a", "a", "", "ab"],
* ["bc def_g", "_bc", "ab cd", "cd "] ]
* @endcode
*
* @throw cudf::logic_error if `pattern` is empty.
*
* @param input A column of string elements to be split
* @param prog Regex program instance
* @param maxsplit Maximum number of splits to perform.
* Default of -1 indicates all possible splits on each string.
* @param mr Device memory resource used to allocate the returned result's device memory
* @return A table of columns of strings
*/
std::unique_ptr<table> split_re(
strings_column_view const& input,
regex_program const& prog,
size_type maxsplit = -1,
rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource());
/**
* @brief Splits strings elements into a table of strings columns using a
* regex_program's pattern to delimit each string starting from the end of the string
*
* Each element generates a vector of strings that are stored in corresponding
* rows in the output table -- `table[col,row] = token[col] of string[row]`
* where `token` is the substring between each delimiter.
*
* The number of rows in the output table will be the same as the number of
* elements in the input column. The resulting number of columns will be the
* maximum number of tokens found in any input row.
*
* Splitting occurs by traversing starting from the end of the input string.
* The `pattern` is used to identify the delimiters within a string
* and splitting stops when either `maxsplit` or the beginning of the string
* is reached.
*
* An empty input string will produce a corresponding empty string in the
* corresponding row of the first column.
* A null row will produce corresponding null rows in the output table.
*
* The regex_program's regex_flags are ignored.
*
* @code{.pseudo}
* s = ["a_bc def_g", "a__bc", "_ab cd", "ab_cd "]
* p1 = regex_program::create("[_ ]")
* s1 = rsplit_re(s, p1)
* s1 is a table of strings columns:
* [ ["a", "a", "", "ab"],
* ["bc", "", "ab", "cd"],
* ["def", "bc", "cd", ""],
* ["g", null, null, null] ]
* p2 = regex_program::create("[ _]")
* s2 = rsplit_re(s, p2, 1)
* s2 is a table of strings columns:
* [ ["a_bc def", "a_", "_ab", "ab"],
* ["g", "bc", "cd", "cd "] ]
* @endcode
*
* @throw cudf::logic_error if `pattern` is empty.
*
* @param input A column of string elements to be split.
* @param prog Regex program instance
* @param maxsplit Maximum number of splits to perform.
* Default of -1 indicates all possible splits on each string.
* @param mr Device memory resource used to allocate the returned result's device memory.
* @return A table of columns of strings.
*/
std::unique_ptr<table> rsplit_re(
strings_column_view const& input,
regex_program const& prog,
size_type maxsplit = -1,
rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource());
/**
* @brief Splits strings elements into a list column of strings
* using the given regex_program to delimit each string
*
* Each element generates an array of strings that are stored in an output
* lists column -- `list[row] = [token1, token2, ...] found in input[row]`
* where `token` is a substring between delimiters.
*
* The number of elements in the output column will be the same as the number of
* elements in the input column. Each individual list item will contain the
* new strings for that row. The resulting number of strings in each row can vary
* from 0 to `maxsplit + 1`.
*
* The `pattern` is used to identify the delimiters within a string
* and splitting stops when either `maxsplit` or the end of the string is reached.
*
* An empty input string will produce a corresponding empty list item output row.
* A null row will produce a corresponding null output row.
*
* The regex_program's regex_flags are ignored.
*
* @code{.pseudo}
* s = ["a_bc def_g", "a__bc", "_ab cd", "ab_cd "]
* p1 = regex_program::create("[_ ]")
* s1 = split_record_re(s, p1)
* s1 is a lists column of strings:
* [ ["a", "bc", "def", "g"],
* ["a", "", "bc"],
* ["", "ab", "cd"],
* ["ab", "cd", ""] ]
* p2 = regex_program::create("[ _]")
* s2 = split_record_re(s, p2, 1)
* s2 is a lists column of strings:
* [ ["a", "bc def_g"],
* ["a", "_bc"],
* ["", "ab cd"],
* ["ab", "cd "] ]
* @endcode
*
* @throw cudf::logic_error if `pattern` is empty.
*
* See the @ref md_regex "Regex Features" page for details on patterns supported by this API.
*
* @param input A column of string elements to be split
* @param prog Regex program instance
* @param maxsplit Maximum number of splits to perform.
* Default of -1 indicates all possible splits on each string.
* @param mr Device memory resource used to allocate the returned result's device memory
* @return Lists column of strings.
*/
std::unique_ptr<column> split_record_re(
strings_column_view const& input,
regex_program const& prog,
size_type maxsplit = -1,
rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource());
/**
* @brief Splits strings elements into a list column of strings using the given
* regex_program to delimit each string starting from the end of the string
*
* Each element generates a vector of strings that are stored in an output
* lists column -- `list[row] = [token1, token2, ...] found in input[row]`
* where `token` is a substring between delimiters.
*
* The number of elements in the output column will be the same as the number of
* elements in the input column. Each individual list item will contain the
* new strings for that row. The resulting number of strings in each row can vary
* from 0 to `maxsplit + 1`.
*
* Splitting occurs by traversing starting from the end of the input string.
* The `pattern` is used to identify the separation points within a string
* and splitting stops when either `maxsplit` or the beginning of the string
* is reached.
*
* An empty input string will produce a corresponding empty list item output row.
* A null row will produce a corresponding null output row.
*
* The regex_program's regex_flags are ignored.
*
* @code{.pseudo}
* s = ["a_bc def_g", "a__bc", "_ab cd", "ab_cd "]
* p1 = regex_program::create("[_ ]")
* s1 = rsplit_record_re(s, p1)
* s1 is a lists column of strings:
* [ ["a", "bc", "def", "g"],
* ["a", "", "bc"],
* ["", "ab", "cd"],
* ["ab", "cd", ""] ]
* p2 = regex_program::create("[ _]")
* s2 = rsplit_record_re(s, p2, 1)
* s2 is a lists column of strings:
* [ ["a_bc def", "g"],
* ["a_", "bc"],
* ["_ab", "cd"],
* ["ab_cd", ""] ]
* @endcode
*
* See the @ref md_regex "Regex Features" page for details on patterns supported by this API.
*
* @throw cudf::logic_error if `pattern` is empty.
*
* @param input A column of string elements to be split
* @param prog Regex program instance
* @param maxsplit Maximum number of splits to perform.
* Default of -1 indicates all possible splits on each string.
* @param mr Device memory resource used to allocate the returned result's device memory
* @return Lists column of strings
*/
std::unique_ptr<column> rsplit_record_re(
strings_column_view const& input,
regex_program const& prog,
size_type maxsplit = -1,
rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource());
/** @} */ // end of doxygen group
} // namespace strings
} // namespace cudf
| [
"noreply@github.com"
] | rapidsai.noreply@github.com |
34b261fb1198dc09bcd215e843e79ebc20f61184 | 631817a31f4ba5b071857d55400947369d3e1ee3 | /CD/CD/Graphics/Frame.hpp | ec516a2cb3b1176b98d3795f4449c3ab841e2d13 | [] | no_license | QW-C/CD | 4cff8e49cca0f11712d827e34d7f8b45ef22ba7a | e28a87b7dd9de03e2b126b237ef3ccaefcb9b0bf | refs/heads/master | 2023-03-26T18:17:02.113471 | 2021-03-27T17:11:32 | 2021-03-27T17:11:32 | 334,336,098 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,049 | hpp | #pragma once
#include <CD/Graphics/Common.hpp>
#include <CD/GPU/CommandBuffer.hpp>
#include <CD/GPU/Shader.hpp>
#include <vector>
#include <queue>
namespace CD {
struct BufferAllocation {
GPU::BufferHandle handle;
std::uint32_t offset;
};
class GPUBufferAllocator {
public:
GPUBufferAllocator(GPU::Device&);
~GPUBufferAllocator();
BufferAllocation create_buffer(std::uint32_t buffer_size, const void* data = nullptr, bool upload = true);
void lock(const GPU::Signal& frame_fence);
void reset(const GPU::Signal& completed_fence);
void update_data();
const GPU::Signal& flush();
const GPU::Signal& get_copy_fence() const;
private:
constexpr static std::uint64_t upload_buffer_size = 1 << 27;
constexpr static std::uint32_t buffer_alignment = 256;
GPU::Device& device;
GPU::CommandBuffer command_buffer;
GPU::BufferHandle gpu_buffer;
GPU::BufferHandle upload_buffer;
void* mapped_memory;
struct BufferFrameData {
std::uint32_t tail;
std::uint32_t head;
};
BufferFrameData frame;
GPU::Signal frame_fence;
GPU::Signal copy_fence;
std::vector<BufferFrameData> uploads;
std::queue<std::pair<GPU::Signal, BufferFrameData>> cache;
};
class CopyContext {
public:
CopyContext(GPU::Device&);
~CopyContext();
void upload_texture_slice(const Texture*, const GPU::TextureView&, const void* data, std::uint16_t width, std::uint16_t height, std::uint32_t row_pitch);
void upload_buffer(const GPU::BufferView&, const void* data);
void flush();
private:
constexpr static std::uint64_t texture_slice_alignment = 512;
constexpr static std::uint64_t texture_row_alignment = 256;
constexpr static std::uint64_t upload_buffer_size = 1 << 27;
GPU::Device& device;
GPU::CommandBuffer command_buffer;
GPU::BufferHandle upload_buffer_handle;
void* mapped_buffer;
std::uint32_t curr_offset;
GPU::Signal copy_fence;
GPU::Signal completed;
struct CopyBufferAllocation {
std::uint32_t offset;
std::uint32_t size;
GPU::Signal fence;
};
std::vector<CopyBufferAllocation> cache;
std::vector<CopyBufferAllocation> free_list;
CopyBufferAllocation reserve(std::uint64_t num_bytes, std::uint64_t alignment = texture_row_alignment);
};
using FrameResourceIndex = std::uint32_t;
struct FrameTextureViews {
GPU::PipelineHandle srv;
GPU::PipelineHandle uav;
};
struct FrameTexture {
Texture texture;
GPU::ResourceState state = GPU::ResourceState::Common;
FrameTextureViews* views;
};
class Frame {
public:
Frame(GPU::Device&, float width, float height);
~Frame();
FrameResourceIndex add_texture(GPU::TextureDesc&, bool create_views_flag = true);
FrameTexture& get_texture(FrameResourceIndex);
const RenderPass* create_render_pass(const GPU::RenderPassDesc&);
const GraphicsPipeline* create_pipeline(const GPU::GraphicsPipelineDesc&, const GPU::PipelineInputLayout&);
const ComputePipeline* create_pipeline(const GPU::ComputePipelineDesc&, const GPU::PipelineInputLayout&);
void bind_resources(const FrameResourceIndex* textures, std::size_t num_textures, GPU::ResourceState);
void begin();
void present();
void wait();
bool resize_buffers(float width, float height);
const GPU::Viewport& get_viewport() const;
GPU::ShaderCompiler& get_shader_compiler();
GPU::Device& get_device();
GPU::CommandBuffer& get_command_buffer();
GPUBufferAllocator& get_buffer_allocator();
CopyContext& get_copy_context();
private:
static constexpr std::uint32_t max_latency = 3;
GPU::Device& device;
GPU::CommandBuffer command_buffer;
GPU::Viewport viewport;
GPU::Signal present_fences[max_latency];
GPU::Signal completed_fence;
std::uint32_t present_index;
GPUBufferAllocator buffer_allocator;
CopyContext copy_context;
std::vector<std::unique_ptr<FrameTexture>> texture_pool;
std::vector<std::unique_ptr<FrameTextureViews>> views;
std::vector<std::unique_ptr<RenderPass>> render_passes;
std::vector<std::unique_ptr<ComputePipeline>> compute_pipelines;
std::vector<std::unique_ptr<GraphicsPipeline>> graphics_pipelines;
void create_views(FrameTexture&);
void destroy_textures();
};
} | [
"qwcollider@gmail.com"
] | qwcollider@gmail.com |
4d4432f270be3d1b2d96e744d055bd7f59ae0bfb | 0b1a12589f9b1995e88cf4214ed843fd0f204af6 | /src/api/dcps/isocpp2/code/org/opensplice/core/ObjectSet.cpp | a3cad3b89a5bc3315d857bd4d0015e5b8b16fdd9 | [
"Apache-2.0"
] | permissive | atolab/opensplice | 523199cd7464d86e73e5897c895afa4350ee5f07 | d606572ecc390b38dab5406a6008cf879e40595d | refs/heads/master | 2021-05-09T13:03:51.459850 | 2018-01-26T07:50:17 | 2018-01-26T07:50:17 | 119,022,146 | 1 | 0 | null | 2018-01-26T07:48:40 | 2018-01-26T07:48:40 | null | UTF-8 | C++ | false | false | 1,978 | cpp | /*
* OpenSplice DDS
*
* This software and documentation are Copyright 2006 to TO_YEAR PrismTech
* Limited, its affiliated companies and licensors. 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.
*
*/
/**
* @file
*/
#include <org/opensplice/core/ObjectSet.hpp>
#include <org/opensplice/core/ScopedLock.hpp>
void
org::opensplice::core::ObjectSet::insert(org::opensplice::core::ObjectDelegate& obj)
{
org::opensplice::core::ScopedMutexLock scopedLock(this->mutex);
this->objects.insert(obj.get_weak_ref());
}
void
org::opensplice::core::ObjectSet::erase(org::opensplice::core::ObjectDelegate& obj)
{
org::opensplice::core::ScopedMutexLock scopedLock(this->mutex);
this->objects.erase(obj.get_weak_ref());
}
void
org::opensplice::core::ObjectSet::all_close()
{
/* Copy the objects to use them outside the lock. */
vector vctr = this->copy();
/* Call close() of all Objects. */
for (vectorIterator it = vctr.begin(); it != vctr.end(); ++it) {
org::opensplice::core::ObjectDelegate::ref_type ref = it->lock();
if (ref) {
ref->close();
}
}
}
org::opensplice::core::ObjectSet::vector
org::opensplice::core::ObjectSet::copy()
{
org::opensplice::core::ScopedMutexLock scopedLock(this->mutex);
vector vctr(this->objects.size());
std::copy(this->objects.begin(), this->objects.end(), vctr.begin());
return vctr;
}
| [
"michiel.beemster@prismtech.com"
] | michiel.beemster@prismtech.com |
644886676c3e0c19235aaf4a7dd573236e9dce6e | 08dc75b6e9ab610cae686b28a132956d6a98bf3e | /Parent.h | 214525cd3572c8d8883a6ace12ddb6d9a879421b | [] | no_license | wjyu/CS343-A6 | d626a669003c4c863b5ff4e0bb3588c0e341ae4c | 44fff9fa02be29a2538504861791cf84e9643f2e | refs/heads/master | 2021-01-01T06:33:45.031253 | 2012-12-03T13:39:38 | 2012-12-03T13:39:38 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 452 | h | #ifndef Parent_H
#define Parent_H
#include <uC++.h>
class Printer;
class Bank;
_Task Parent
{
public:
Parent( Printer &prt, Bank &bank, unsigned int numStudents, unsigned int parentalDelay );
private:
Printer * printer; // reference to Printer
Bank * bank;//reference to Bank
unsigned int studentQuantity;// number of students
unsigned int delay;// delay for depositing gifts
void main();
};
#endif // Parent_H
| [
"jimmy.w.j.yu@gmail.com"
] | jimmy.w.j.yu@gmail.com |
3cb87447a1e8713bfaf2b8a47e14b5a217aa000f | 3a0321b0cc9567c6a97abaff4a3c20ce8708697e | /assignment_package/src/implement_me/kdtree.cpp | a22b26c8092d65e65ddd616cb36912abca393242 | [] | no_license | 0v0v0/HW8_KDTREE | be4901d9b8e8bd3c421acd5a9475d946aef6be09 | c6b1b20826ca11e0ffe43573f87e03a50bedec6e | refs/heads/master | 2020-03-11T11:48:03.909665 | 2018-04-18T00:30:18 | 2018-04-18T00:30:18 | 129,979,541 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 7,304 | cpp | #include "kdtree.h"
#include "iostream"
KDNode::KDNode()
: leftChild(nullptr), rightChild(nullptr), axis(0), minCorner(), maxCorner(), particles()
{}
KDNode::~KDNode()
{
delete leftChild;
delete rightChild;
}
KDTree::KDTree()
: root(nullptr)
{}
KDTree::~KDTree()
{
delete root;
}
// Comparator functions you can use with std::sort to sort vec3s along the cardinal axes
bool xSort(glm::vec3* a, glm::vec3* b) { return a->x < b->x; }
bool ySort(glm::vec3* a, glm::vec3* b) { return a->y < b->y; }
bool zSort(glm::vec3* a, glm::vec3* b) { return a->z < b->z; }
void KDTree::build(const std::vector<glm::vec3*> &points)
{
//TODO
//I think this time the points will be many so let's use uint instead of int?
//unsigned int does not work well in for loops, change back!
int size=points.size();
//Init
for( int i=0;i<size;i++)
{
xsorted.push_back(i);
ysorted.push_back(i);
zsorted.push_back(i);
}
//Insert Sort
//Checked from Wikipidia, which is the most efficient way I think?
//This sorts the points from big to small in xyz axis
int x_tmp;
int y_tmp;
int z_tmp;
/*
for (i = 1; i < n; i++)
{
key = arr[i];
j = i-1;
while (j >= 0 && arr[j] > key)
{
arr[j+1] = arr[j];
j = j-1;
}
arr[j+1] = key;
}*/
for(int i=0; i<size; i++)
{
x_tmp=xsorted.at(i);
int j=i-1;
while(j>=0 && xSort( points.at( xsorted.at(j) ) , points.at(x_tmp) ) )
{
xsorted.at(j+1)=xsorted.at(j);
j = j-1;
}
xsorted.at(j+1)=x_tmp;
}
for(int i=0; i<size; i++)
{
y_tmp=ysorted.at(i);
int j=i-1;
while(j>=0 && ySort( points.at( ysorted.at(j) ) , points.at(y_tmp) ) )
{
ysorted.at(j+1)=ysorted.at(j);
j = j-1;
}
ysorted.at(j+1)=y_tmp;
}
//Sort Z
for(int i=0; i<size; i++)
{
z_tmp=zsorted.at(i);
int j=i-1;
while(j>=0 && zSort( points.at( zsorted.at(j) ) , points.at(z_tmp) ) )
{
zsorted.at(j+1)=zsorted.at(j);
j = j-1;
}
zsorted.at(j+1)=z_tmp;
}
/*
qDebug() << "X axis sort: ";
for(int i=0;i<size;i++)
{
qDebug() << ( glm::to_string( *points.at(xsorted.at(i)) ) ).c_str();
}
qDebug() << "Y axis sort: ";
for(int i=0;i<size;i++)
{
qDebug() << ( glm::to_string( *points.at(ysorted.at(i)) ) ).c_str();
}
qDebug() << "Z axis sort: ";
for(int i=0;i<size;i++)
{
qDebug() << ( glm::to_string( *points.at(zsorted.at(i)) ) ).c_str();
}
*/
//build root
root=recursive(0,0,size-1,points);
int min=size-1;
int max=0;
glm::vec3 xmin=*points.at(xsorted.at(min));
glm::vec3 ymin=*points.at(ysorted.at(min));
glm::vec3 zmin=*points.at(zsorted.at(min));
minCorner=glm::vec3(xmin.x,ymin.y,zmin.z);
glm::vec3 xmax=*points.at(xsorted.at(max));
glm::vec3 ymax=*points.at(ysorted.at(max));
glm::vec3 zmax=*points.at(zsorted.at(max));
maxCorner=glm::vec3(xmax.x,ymax.y,zmax.z);
qDebug() << "build complete!";
}
//dir = direction
//max-min = how many particles in this segment
//node = the KD node we will build
KDNode* KDTree::recursive( int dir,
int min,
int max,
const std::vector<glm::vec3*> &points)
{
int size=max-min;
KDNode* node=new KDNode();
if(size>0)
{
int left,right;
if(size%2 == 0)
{
//odd num of elements
left=(size/2);
right=size-left;
left+=min;
right+=min;
if(size>1)
{
node->particles.push_back(points.at(left));
//qDebug() << "branch pushed " << left;
}
right++;
if(right>max)
{
right=max;
}
//qDebug() << "dir = " <<dir ;
//qDebug() << "left child is " <<min << " to " <<left;
//qDebug() << "right child is " <<right << " to " <<max;
//Spawn left child
node->leftChild=recursive(dir+1,min,left,points);
//Spawn right child
node->rightChild=recursive(dir+1,right,max,points);
}
else
{
//even num of elements
left=(size/2);
right=size-left;
left+=min;
right+=min;
if(size>1)
{
node->particles.push_back(points.at(left));
//qDebug() << "branch pushed " << left;
}
left--;
if(left<min)
{
left=min;
}
//qDebug() << "dir = " <<dir ;
//qDebug() << "left child is " <<min << " to " <<left;
//qDebug() << "right child is " <<right << " to " <<max;
//Spawn left child
node->leftChild=recursive(dir+1,min,left,points);
//Spawn right child
node->rightChild=recursive(dir+1,right,max,points);
}
}
else
{
node->particles.push_back(points.at(min));
node->leftChild=NULL;
node->rightChild=NULL;
//qDebug() << "leaf pushed" << min;
}
//Min-Max Corners
node->axis=dir%3;
glm::vec3 xmin=*points.at(xsorted.at(min));
glm::vec3 ymin=*points.at(ysorted.at(min));
glm::vec3 zmin=*points.at(zsorted.at(min));
node->minCorner=glm::vec3(xmin.x,ymin.y,zmin.z);
glm::vec3 xmax=*points.at(xsorted.at(max));
glm::vec3 ymax=*points.at(ysorted.at(max));
glm::vec3 zmax=*points.at(zsorted.at(max));
node->maxCorner=glm::vec3(xmax.x,ymax.y,zmax.z);
//test
glm::vec3 tmp=node->minCorner;
node->minCorner=node->maxCorner;
node->maxCorner=tmp;
return node;
}
std::vector<glm::vec3> KDTree::particlesInSphere(glm::vec3 c, float r)
{
//init
std::vector<glm::vec3> buffer;
buffer.clear();
KDNode* p;
p=root;
if(p->particles.size()>0)
{
glm::vec3 pos=*(p->particles.at(0));
float length=glm::dot(pos-c,pos-c);
if(length<r*r)
{
qDebug()<< "Find ! Len= " << length;
buffer.push_back(pos);
}
if(p->leftChild!=NULL)
{
scan(buffer,p->leftChild,c,r);
}
if(p->rightChild!=NULL)
{
scan(buffer,p->rightChild,c,r);
}
}
qDebug() << "Find Finished!";
return buffer;
}
void KDTree::scan(std::vector<glm::vec3> &buffer,KDNode* p, glm::vec3 c, float r)
{
if(p->particles.size()>0)
{
glm::vec3 pos=*(p->particles.at(0));
float length=glm::dot(pos-c,pos-c);
if(length<r*r)
{
qDebug()<< "Find ! Len= " << length;
buffer.push_back(pos);
}
if(p->leftChild!=NULL)
{
scan(buffer,p->leftChild,c,r);
}
if(p->rightChild!=NULL)
{
scan(buffer,p->rightChild,c,r);
}
}
}
void KDTree::clear()
{
delete root;
root = nullptr;
}
| [
"0v0v0@users.noreply.gitbhub.com"
] | 0v0v0@users.noreply.gitbhub.com |
f1c0e840610d96dc53285dbdcad7c343195ccf0c | 43d70c3eac5af55e68628c01b3d442c1bda6fb4c | /SDLManager.cpp | 1c0b7ecf33d5cbc3d49f40084df660187a838661 | [] | no_license | AlixDeMitchell/OOT3 | e5b3d7ed7be8ef07e569ea5b1211e15147967312 | 60434a17f54b233584af9c48466e16731b6978e4 | refs/heads/master | 2021-01-18T16:42:50.336514 | 2017-04-02T15:12:21 | 2017-04-02T15:12:21 | 86,758,306 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,004 | cpp | #include "SDLManager.h"
SDLManager::SDLManager()
{
//initialize SDL
InitSDL();
//init pointers to null
m_window = nullptr;
m_renderer = nullptr;
keyboard = SDL_GetKeyboardState( NULL );
//if SDL initializes, create window and renderer
if ( InitSDL() )
{
m_window = CreateWindow( "Particle Demo", 100, 100, SCREEN_W, SCREEN_H );
m_renderer = CreateRenderer( m_window );
}
}
bool SDLManager::InitSDL()
{
//initialize SDL
if ( SDL_Init( SDL_INIT_EVERYTHING ) != 0 )
{
std::cout << "SDL_Init Error: " << SDL_GetError() << std::endl;
return false;
}
return true;
}
SDL_Window* SDLManager::CreateWindow( char * _windowTitle, int _xPos, int _yPos, int _windowWidth, int _windowHeight )
{
// try to create the window, log error and return nullptr if fail
SDL_Window* window = SDL_CreateWindow( _windowTitle, _xPos, _yPos, _windowWidth, _windowHeight, SDL_WINDOW_SHOWN );
if ( window == nullptr )
{
std::cout << "SDL_CreateWindow Error: " << SDL_GetError() << std::endl;
return nullptr;
}
// return pointer to newly created window
return window;
}
SDL_Renderer* SDLManager::CreateRenderer( SDL_Window * _window )
{
// try to create renderer, log error and return NULL if fails
SDL_Renderer* renderer = SDL_CreateRenderer( _window, -1, SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC );
if ( renderer == nullptr )
{
std::cout << "SDL_CreateRenderer Error: " << SDL_GetError() << std::endl;
return nullptr;
}
// return pointer to new renderer
return renderer;
}
SDL_Renderer * SDLManager::GetRenderer()
{
return m_renderer;
}
const Uint8 * SDLManager::GetKeyboard()
{
return keyboard;
}
bool SDLManager::HandleEvents()
{
while ( SDL_PollEvent( &e ) )
{
/* If a quit event has been sent */
if ( e.type == SDL_QUIT )
{
/* Quit the application */
return true;
}
}
return false;
}
SDLManager::~SDLManager()
{
SDL_Quit();
}
| [
"noreply@github.com"
] | AlixDeMitchell.noreply@github.com |
a677208c7f37ad4b724d8eacc3c7cccc406cc0b6 | da84a58a036ab8fde955d4e4c4b335e078bccda3 | /build-aac_encode-Desktop_x86_darwin_generic_mach_o_64bit-Debug/moc_audiothread.cpp | b1ce80f353844c43c646c47f4c6dbec4740f6e04 | [] | no_license | forestfsl/audio | c9aea7efe1089e4f63355eaef634ed2c9faef0a6 | 5c615c22b7701780f12ce38a42635080892baa51 | refs/heads/master | 2023-07-13T01:28:01.934365 | 2021-08-21T06:26:14 | 2021-08-21T06:26:14 | 359,826,243 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,589 | cpp | /****************************************************************************
** Meta object code from reading C++ file 'audiothread.h'
**
** Created by: The Qt Meta Object Compiler version 68 (Qt 6.0.3)
**
** WARNING! All changes made in this file will be lost!
*****************************************************************************/
#include <memory>
#include "../aac_encode/audiothread.h"
#include <QtCore/qbytearray.h>
#include <QtCore/qmetatype.h>
#if !defined(Q_MOC_OUTPUT_REVISION)
#error "The header file 'audiothread.h' doesn't include <QObject>."
#elif Q_MOC_OUTPUT_REVISION != 68
#error "This file was generated using the moc from 6.0.3. It"
#error "cannot be used with the include files from this version of Qt."
#error "(The moc has changed too much.)"
#endif
QT_BEGIN_MOC_NAMESPACE
QT_WARNING_PUSH
QT_WARNING_DISABLE_DEPRECATED
struct qt_meta_stringdata_AudioThread_t {
const uint offsetsAndSize[2];
char stringdata0[12];
};
#define QT_MOC_LITERAL(ofs, len) \
uint(offsetof(qt_meta_stringdata_AudioThread_t, stringdata0) + ofs), len
static const qt_meta_stringdata_AudioThread_t qt_meta_stringdata_AudioThread = {
{
QT_MOC_LITERAL(0, 11) // "AudioThread"
},
"AudioThread"
};
#undef QT_MOC_LITERAL
static const uint qt_meta_data_AudioThread[] = {
// content:
9, // revision
0, // classname
0, 0, // classinfo
0, 0, // methods
0, 0, // properties
0, 0, // enums/sets
0, 0, // constructors
0, // flags
0, // signalCount
0 // eod
};
void AudioThread::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id, void **_a)
{
(void)_o;
(void)_id;
(void)_c;
(void)_a;
}
const QMetaObject AudioThread::staticMetaObject = { {
QMetaObject::SuperData::link<QThread::staticMetaObject>(),
qt_meta_stringdata_AudioThread.offsetsAndSize,
qt_meta_data_AudioThread,
qt_static_metacall,
nullptr,
nullptr,
nullptr
} };
const QMetaObject *AudioThread::metaObject() const
{
return QObject::d_ptr->metaObject ? QObject::d_ptr->dynamicMetaObject() : &staticMetaObject;
}
void *AudioThread::qt_metacast(const char *_clname)
{
if (!_clname) return nullptr;
if (!strcmp(_clname, qt_meta_stringdata_AudioThread.stringdata0))
return static_cast<void*>(this);
return QThread::qt_metacast(_clname);
}
int AudioThread::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
_id = QThread::qt_metacall(_c, _id, _a);
return _id;
}
QT_WARNING_POP
QT_END_MOC_NAMESPACE
| [
"fengsonglin@ad61v1.com"
] | fengsonglin@ad61v1.com |
498fd6be4473968b3fb94ca608572cd704950f62 | 0b216a3b1b3c261f7d314e9aaf1bfbdb91c1d520 | /engine/include/game/Camera.hpp | 77dfdb0c99bb8db1c3b54e7899f2eec73825661c | [] | no_license | ciaala/vulkan_engine_cpp | 2b24bdb07e55decb33bfcf4eaefa51a8cf52cf63 | c6de83c5082ecf19df1753c971b17d19673937a5 | refs/heads/master | 2021-06-03T09:24:43.147797 | 2017-07-25T05:09:44 | 2017-07-25T05:09:44 | 97,520,327 | 6 | 0 | null | 2017-07-24T22:41:53 | 2017-07-17T20:41:22 | C++ | UTF-8 | C++ | false | false | 769 | hpp | //
// Created by crypt on 19/07/17.
//
#ifndef VULKAN_ENGINE_CPP_CAMERA_HPP
#define VULKAN_ENGINE_CPP_CAMERA_HPP
#include <core/linmath.h>
namespace vlk {
class Camera {
protected:
mat4x4 projectionMatrix;
mat4x4 viewMatrix;
vec3 eye = {0.0f, 3.0f, 5.0f};
vec3 origin = {0, 0, 0};
vec3 up = {0.0f, 1.0f, 0.0};
public:
mat4x4 &getProjectionMatrix() {
return projectionMatrix;
}
mat4x4 &getViewMatrix() {
return viewMatrix;
}
vec3 &getEye() {
return eye;
}
vec3 &getOrigin() {
return origin;
}
vec3 &getUp() {
return up;
}
};
}
#endif //VULKAN_ENGINE_CPP_CAMERA_HPP
| [
"francesco.fiduccia@gmail.com"
] | francesco.fiduccia@gmail.com |
b16b8e6cfb8f9010f85a0e0371b266eef4859544 | abe1c82a1a6f9e3b64b94d54cb2b026f32c0e926 | /arcin/multifunc.cpp | 77b31ba694e357be40058e8910d19b62ab14b6e4 | [
"BSD-2-Clause",
"MIT"
] | permissive | dr-vipinkumarp/arcin-infinitas | ba06cb38ae52286d85618a58767d6bf3347489f5 | 425a22300c5d0b2ed7d04ec2f9aa2607539cdad9 | refs/heads/master | 2023-08-14T04:53:15.867186 | 2021-01-04T10:16:54 | 2021-01-04T10:16:54 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,104 | cpp | #include "timer.h"
#include "multifunc.h"
#include "inf_defines.h"
extern uint32_t debug_value;
// Window that begins on the first rising edge of E2
// i.e., any multi-taps must be done within this window in order to count
#define MULTITAP_DETECTION_WINDOW_MS 500
// assert button combination for this duration
#define EFFECTOR_COMBO_HOLD_DURATION_MS 100
typedef enum _MF_CURRENT_WINDOW {
MF_IDLE,
MF_CAPTURING_INPUT,
MF_ASSERTING_INPUT
} MF_CURRENT_WINDOW;
static MF_CURRENT_WINDOW current_window = MF_IDLE;
timer window_close_timer;
// how many times was E2 pressed during the capture window?
static uint8_t e2_rising_edge_count = 0;
static bool last_e2_status = false;
void capture_e2_presses(bool pressed) {
// rising edge (detect off-on sequence)
if (!last_e2_status && pressed) {
// if we were idle, start capturing input now.
if (current_window == MF_IDLE) {
e2_rising_edge_count = 0;
window_close_timer.arm(MULTITAP_DETECTION_WINDOW_MS);
current_window = MF_CAPTURING_INPUT;
}
// count every rising edge
e2_rising_edge_count += 1;
}
last_e2_status = pressed;
}
uint16_t get_multitap_output(uint8_t num_rising_edges) {
uint16_t button;
switch (num_rising_edges) {
case 0:
button = 0;
break;
case 1:
button = INFINITAS_BUTTON_E2;
break;
case 2:
button = INFINITAS_BUTTON_E3;
break;
case 3:
button = (INFINITAS_BUTTON_E2 | INFINITAS_BUTTON_E3);
break;
case 4:
default:
button = INFINITAS_BUTTON_E4;
break;
}
return button;
}
// used as a limiter
static uint32_t last_update_time = 0;
// button combination to assert
static uint16_t effector_buttons_being_asserted = 0;
uint16_t get_multi_function_keys(bool is_e2_pressed) {
uint32_t now = Time::time();
// Update at most once per 1ms. Otherwise, just return the last calculated
// result.
if (now == last_update_time) {
return effector_buttons_being_asserted;
}
last_update_time = now;
// capture button presses
if (current_window == MF_IDLE || current_window == MF_CAPTURING_INPUT) {
capture_e2_presses(is_e2_pressed);
}
// are we past capture window?
if (current_window == MF_CAPTURING_INPUT && window_close_timer.check_if_expired_reset()) {
// Start asserting button combo
current_window = MF_ASSERTING_INPUT;
window_close_timer.arm(EFFECTOR_COMBO_HOLD_DURATION_MS);
effector_buttons_being_asserted = get_multitap_output(e2_rising_edge_count);
}
// are we past assertion window?
if (current_window == MF_ASSERTING_INPUT && window_close_timer.check_if_expired_reset()) {
if (is_e2_pressed) {
// If the button is held down, extend the timer
window_close_timer.arm(EFFECTOR_COMBO_HOLD_DURATION_MS);
} else {
current_window = MF_IDLE;
effector_buttons_being_asserted = 0;
}
}
return effector_buttons_being_asserted;
} | [
"noreply@github.com"
] | dr-vipinkumarp.noreply@github.com |
e5e48c4536c75f41cbaa0041ad7078dc1233814e | 46a96d914fa4f802ad98ea07bdad5cfc9f5a9d92 | /Herencia/src/Estudiante.cpp | 3ed1c97e854fce89cea08b3c6b1c8583d3f2cdb3 | [] | no_license | kjtm03/clase1 | 521f9f9077d2b7d04e3066774c257343732251d3 | c3464de62fbbe1d63e3b9c45be767168d85575ec | refs/heads/master | 2021-01-23T00:20:33.815712 | 2017-06-27T15:01:29 | 2017-06-27T15:01:29 | 85,719,317 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 351 | cpp | #include "Estudiante.h"
#include <iostream>
#include "Persona.h"
using namespace std;
Estudiante::Estudiante(int ed4d, string n0mbre, string c4rne, float n0ta):Persona(ed4d,n0mbre)
{
carne = c4rne;
nota = n0ta;
}
void Estudiante::imprimirEstudiante()
{
imprimirDatos();
cout<<"Carne: "<<carne<<endl;
cout<<"Nota: "<<nota<<endl;
}
| [
"jktm01@gmail.com"
] | jktm01@gmail.com |
c396014e2f1f4bafd40ba6679eecf0d8bb00f937 | 0860688923249323224eb4d4f75e7c1de049caae | /lab2/playerdata.h | 0fcc3d0d9fba42963433bb2e6f5ae7c4ce1a140c | [] | no_license | youqing945/107-2_ProgramDesign_Lab | fce821f07fc918be1dcdcffd00448082a93acf0a | e43692daf442accae710c239d1902b2bf82aa821 | refs/heads/main | 2023-04-14T00:16:47.454296 | 2021-04-14T18:37:34 | 2021-04-14T18:37:34 | 357,837,251 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 321 | h | using namespace std;
class PlayerData{
public:
PlayerData(int, int, int);
void returnValue(float);
int getK();
void setK(int);
int getRa();
void setRa(int);
int getRb();
void setRb(int);
private:
int K;
int Ra;
int Rb;
};
| [
"youqing1211@gmail.com"
] | youqing1211@gmail.com |
4e14a52d0b816d5d3a1d60c1df6e8179e9b57ea6 | 2fdcf56c5e791dd9a4605a41ef7bc601e2fc9135 | /Info/string repair/main.cpp | 4447969f83a52c0c84504c4e713f51dddebff4eb | [] | no_license | DinuCr/CS | 42cc4a7920fb5a2ac5e1179930169e4d8d71592e | 8d381a622e70dd234d7a978501dcb7cf67e83adc | refs/heads/master | 2020-06-02T14:11:49.223214 | 2020-05-24T01:27:46 | 2020-05-24T01:27:46 | 191,174,654 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 360 | cpp | #include <iostream>
#include <fstream>
#include <cstring>
using namespace std;
ifstream fin("sr.in");
ofstream fout("sr.out");
char a[100100];
char b[100100];
int i;
int n;
int main()
{
fin>>a>>b;
n=strlen(a);
int j=0;
for(j=0; j<n; ++j)
{
if(a[j]==b[i])
{
fout<<j+1<<' ';
++i;
}
}
}
| [
"cristidinu1999@gmail.com"
] | cristidinu1999@gmail.com |
34db7a27691a0f4030b0834fd54ca84293bbbe34 | 3b6785102d5f29496ceca330648b56883b116fe7 | /source/XYO/DllInjectSample/Code/new_kernelbase__LoadLibraryA.cpp | 9d4c1a89d75aca0854877ee924ac14f7933aca13 | [
"MIT"
] | permissive | g-stefan/dll-inject-sample | aa3b7c021c651c3a5f249c66fec71f9196f34d7e | 746b7e0118a63ee2c963c6a1ab130de1b9353764 | refs/heads/main | 2023-07-27T12:17:00.517863 | 2023-06-08T12:23:11 | 2023-06-08T12:23:11 | 22,621,592 | 5 | 2 | null | null | null | null | UTF-8 | C++ | false | false | 263 | cpp | static HMODULE WINAPI _new_kernelbase__LoadLibraryA(const char *lpFileName) {
HMODULE retV;
retV = (*_original_kernelbase__LoadLibraryA)(lpFileName);
DWORD errCode = GetLastError();
thisHookInstance(retV);
SetLastError(errCode);
return retV;
};
| [
"g_stefan@yahoo.com"
] | g_stefan@yahoo.com |
972ab1679f17b70ca17c65330cb17651a608f62f | a4be4cc540ee0586f9ed7138302a71bc6976ac3e | /Vector3/Vector3/Vector3.cpp | c2cba9bf7f8101c049a9ca273b7f7b4a3ebd637b | [] | no_license | BorjaSasieta/ExercicisCppMaster | 30925cae3122818600672622b42eca946d1890a2 | 245c039a68b950d3477891a59616474a1eca298c | refs/heads/master | 2020-03-31T02:39:22.982465 | 2018-10-29T18:48:48 | 2018-10-29T18:48:48 | 151,834,087 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 991 | cpp | #include "Vector3.h"
#include <math.h>
Vector3::Vector3(){}
Vector3::Vector3(float x, float y, float z) : x(x), y(y), z(z) {}
Vector3::Vector3(const Vector3 &vec3) : x(vec3.x), y(vec3.y), z(vec3.z) {}
Vector3::~Vector3(){}
const float Vector3::getX() { return this->x; }
const float Vector3::getY() { return this->y; }
const float Vector3::getZ() { return this->z; }
void Vector3::setX(int x) { this->x = x; }
void Vector3::setY(int y) { this->y = y; }
void Vector3::setZ(int z) { this->z = z; }
Vector3 Vector3::plusVector(Vector3 a) { return Vector3((a.getX() + this->x), (a.getY() + this->y), (a.getZ() + this->z)); }
void Vector3::normalize() {
double operand = sqrt(this->x * this->x + this->y * this->y + this->z * this->z);
this->x /= operand;
this->y /= operand;
this->z /= operand;
}
float Vector3::distance(Vector3 const v) { return sqrt((v.x - this->x) * (v.x - this->x) +
(v.y - this->y) * (v.y - this->y) +
(v.z - this->z) * (v.z - this->z)); } | [
"borja.sasieta@gmail.com"
] | borja.sasieta@gmail.com |
18722212b11dc33abed69971de2f697bf0b01932 | 5971ce02ad593cc4c42a7473b0ed3c0de5e39822 | /transitive.cpp | dd52c157fe5cd4bd72824bd882cb222b1b0d8b96 | [] | no_license | vishalpathak24/MPIGraph | e1e22ffccae2e39589f47a26230a0209ccfb7a17 | 76e7aa1b1a924f72c616ebd2e5729dc1f1e453b4 | refs/heads/master | 2021-01-19T09:38:33.356719 | 2017-04-10T07:09:26 | 2017-04-10T07:09:26 | 87,777,991 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 136 | cpp | #include <iostream>
#include <vector>
using namespace std;
typedef struct TQuery{
int start;
int end;
vector <int> list;
}TQuery;
| [
"vishalpathak24@gmail.com"
] | vishalpathak24@gmail.com |
76f9c4a32d7dd2847fa3be0d1fb299bebe2d9b33 | 0a540cea0e3d8d1e6168be111148d899254b6822 | /SPS/ueg/JuliaMengen/cudaerror.h | 73830d5634e80e5d92dfb400f80a01251bfb262e | [] | no_license | theZnorf/esdexercises | 0b47ab103f61958c7dbf3676ace043597031d04c | dd3bf377191e28cbd6f945fa713a0db578a205cc | refs/heads/master | 2020-12-31T04:41:31.624351 | 2016-03-03T13:49:57 | 2016-03-03T13:49:57 | 43,483,834 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,066 | h | // $Id: snippet-1.h 26270 2014-10-23 08:25:40Z p20068 $
// $URL: https://svn01.fh-hagenberg.at/bin/cepheiden/vocational/teaching/ESD/SPS3/2015-WS/Ablauf/src/HelloWorld/src/snippet-1.h $
// $Revision: 26270 $
// $Date: 2014-10-23 10:25:40 +0200 (Do., 23 Okt 2014) $
// Creator: peter.kulczycki<AT>fh-hagenberg.at
// $Author: p20068 $
//
// Remarks: CUDA Error Handling
// Types: pfc::cuda_exception
// Functions: pfc::check
#ifndef CUDAERROR_H
#define CUDAERROR_H
#if defined __CUDACC__ /* NVIDIA CUDA compiler */
#define CUDA_ATTR_HOST_DEVICE __host__ __device__
#else
#define CUDA_ATTR_HOST_DEVICE
#endif
#include <cuda_runtime.h>
#include <stdexcept>
namespace pfc {
class cuda_exception : public std::runtime_error {
typedef std::runtime_error inherited;
public:
explicit cuda_exception (cudaError const error) : inherited (cudaGetErrorString (error)) {
}
};
inline void check(cudaError const error) {
if (error != cudaSuccess) {
throw pfc::cuda_exception (error);
}
}
} // namespace pfc
#endif | [
"franz.profelt@gmail.com"
] | franz.profelt@gmail.com |
7fa114652202c97598f28b4d79fdc3919eef2f3e | 79ffba00f7bb09d3c4f428ab0d449a8d1f71b538 | /Weapon.h | 49fe68cacf826167456458ef984bece24d4e6173 | [] | no_license | TMalicki/Alpacator-SFML | c933ceb3935aa9a315048520985f6f640640e56a | dbe72867727d1d797ea20031f6026f9e66aa9a7c | refs/heads/master | 2020-12-20T17:58:30.402723 | 2020-07-30T14:24:04 | 2020-07-30T14:24:04 | 236,162,535 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 555 | h | #ifndef WEAPON_H
#define WEAPON_H
#include <iostream>
#include "Items.h"
#include <SFML/Graphics.hpp>
using namespace std;
class Weapon : public Items
{
private:
string type;
public:
Weapon(string t = "Brak", int atk = 0, int def = 0, int agil = 0, int stam = 0, int hp = 0, int durab = 0) : type(t), Items(atk, def, agil, stam, hp, durab) {};
~Weapon() {};
virtual string getType() const { return type; };
virtual string getName() const = 0;
virtual void getLook() = 0;
virtual Weapon* copyItems() const = 0;
};
#endif | [
"noreply@github.com"
] | TMalicki.noreply@github.com |
bf376437336390a6c1e9dba5a8706a97221b6838 | 5ce88d26b1058da21ce211a12dee34ce59972a6c | /Lab2/Lab2/Source.cpp | 93e879bd34d2f1ac9eeedcbe6ce1986ededb6fa2 | [] | no_license | DonViktorash/cpp_lab_work | b5167ebe922d6894b190012bb0ea88e754888f68 | 1a7b38ccc7193db6aa3243bce05130acf6e70501 | refs/heads/master | 2021-05-21T00:27:17.689887 | 2020-04-15T11:56:55 | 2020-04-15T11:56:55 | 252,468,949 | 0 | 0 | null | null | null | null | WINDOWS-1251 | C++ | false | false | 1,139 | cpp | #include <iostream>
#include <vector>
//#include "stdafx.h"
using namespace std;
//главная функция
const int maxV = 1000;
int i, j, n;
int GR[maxV][maxV];
//алгоритм Флойда-Уоршелла
void FU(int D[][maxV], int V)
{
int k;
for (i = 0; i < V; i++) D[i][i] = 0;
for (k = 0; k < V; k++)
for (i = 0; i < V; i++)
for (j = 0; j < V; j++)
if (D[i][k] && D[k][j] && i != j)
if (D[i][k] + D[k][j] < D[i][j] || D[i][j] == 0)
D[i][j] = D[i][k] + D[k][j];
for (i = 0; i < V; i++)
{
for (j = 0; j < V; j++) cout << D[i][j] << "\t";
cout << endl;
}
}
void main()
{
setlocale(LC_ALL, "Rus");
cout << "Количество вершин в графе > "; cin >> n;
cout << "Введите матрицу весов ребер:\n";
for (i = 0; i < n; i++) {
for (j = 0; j < n; j++)
{
cout << "GR[" << i + 1 << "][" << j + 1 << "] > ";
cin >> GR[i][j];
}
}
for (i = 0; i < n; i++) {
for (j = 0; j < n; j++)
{
cout << GR[i][j] << " ";
}
cout << endl;
}
cout << "Матрица кратчайших путей:" << endl;
FU(GR, n);
system("pause>>void");
}
| [
"vik.markin2014@yandex.ru"
] | vik.markin2014@yandex.ru |
1f7907bb94937bed101a5900607f348d02ceda28 | 73ce639b6840cd58ff64a81cedce86ed96078fbd | /libredex/DexCallSite.cpp | dcc4aa40328873e8e7f963f0fb4012e29592ce65 | [
"MIT"
] | permissive | benjaminRomano/redex | 87dcac555a882ea3062438cf2a7c9b53a9b2fb8d | b2558edf3371a0f388dde370092148f4d7d4b852 | refs/heads/master | 2023-08-16T00:00:50.828350 | 2021-09-17T20:58:45 | 2021-09-17T21:23:33 | 408,568,868 | 0 | 0 | MIT | 2021-09-20T19:15:00 | 2021-09-20T19:07:20 | null | UTF-8 | C++ | false | false | 1,711 | cpp | /*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
#include "DexCallSite.h"
#include "DexAnnotation.h"
#include "DexClass.h"
#include "DexIdx.h"
#include "DexMethodHandle.h"
#include <sstream>
void DexCallSite::gather_strings(std::vector<DexString*>& lstring) const {
lstring.emplace_back(m_linker_method_name);
m_linker_method_type->gather_strings(lstring);
for (auto ev : m_linker_method_args) {
ev->gather_strings(lstring);
}
}
void DexCallSite::gather_methodhandles(
std::vector<DexMethodHandle*>& lmethodhandle) const {
lmethodhandle.push_back(m_linker_method_handle);
for (auto ev : m_linker_method_args) {
ev->gather_methodhandles(lmethodhandle);
}
}
void DexCallSite::gather_methods(std::vector<DexMethodRef*>& lmethod) const {
m_linker_method_handle->gather_methods(lmethod);
for (auto ev : m_linker_method_args) {
ev->gather_methods(lmethod);
}
}
void DexCallSite::gather_fields(std::vector<DexFieldRef*>& lfield) const {
m_linker_method_handle->gather_fields(lfield);
for (auto ev : m_linker_method_args) {
ev->gather_fields(lfield);
}
}
DexEncodedValueArray DexCallSite::as_encoded_value_array() const {
auto aev = std::make_unique<std::deque<DexEncodedValue*>>();
for (auto arg : m_linker_method_args) {
aev->push_back(arg);
}
aev->push_front(new DexEncodedValueMethodType(m_linker_method_type));
aev->push_front(new DexEncodedValueString(m_linker_method_name));
aev->push_front(new DexEncodedValueMethodHandle(m_linker_method_handle));
return DexEncodedValueArray(aev.release(), true);
}
| [
"facebook-github-bot@users.noreply.github.com"
] | facebook-github-bot@users.noreply.github.com |
00a2ba2ee92670858ae3726eedd32b9879f70733 | d514636c43099f00a264da7846fcee5842468429 | /Labs/Bigfoot/src/BF/3rdparty/strtk/strtk_serializer_example.cpp | f8ac3d22efbe72f4388aa8547e53ac4a710b86df | [
"MIT"
] | permissive | jadnohra/jad-pre-2015-dabblings | 92de27c6184a255dfdb4ed9ee2148d4bf71ced1e | 368cbd39c6371b3e48b0c67d9a83fc20eee41346 | refs/heads/master | 2021-07-22T20:07:18.651650 | 2017-11-03T11:31:18 | 2017-11-03T11:31:18 | 109,386,288 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 12,489 | cpp | /*
*****************************************************************
* String Toolkit Library *
* *
* Serializer Example *
* Author: Arash Partow (2002-2010) *
* URL: http://www.partow.net/programming/strtk/index.html *
* *
* Copyright notice: *
* Free use of the String Toolkit Library is permitted under the *
* guidelines and in accordance with the most current version of *
* the Common Public License. *
* http://www.opensource.org/licenses/cpl1.0.php *
* *
*****************************************************************
*/
#include <cstddef>
#include <iostream>
#include <fstream>
#include <algorithm>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include "strtk.hpp"
struct person
{
public:
std::string name;
unsigned int age;
double height;
float weight;
bool is_insane;
person()
{
clear();
}
bool operator==(const person& p)
{
return (p.name == name) &&
(p.age == age) &&
(p.weight == weight) &&
(p.height == height) &&
(p.is_insane == is_insane);
}
bool operator!=(const person& p)
{
return !operator==(p);
}
void clear()
{
name = "";
age = 0;
height = 0.0;
weight = 0.0f;
is_insane = false;
}
void read(strtk::serializer& s)
{
s >> name;
s >> age;
s >> height;
s >> weight;
s >> is_insane;
}
void write(strtk::serializer& s)
{
s << name;
s << age;
s << height;
s << weight;
s << is_insane;
}
};
bool test01(char* buffer, const unsigned int buffer_size)
{
strtk::serializer s(buffer,buffer_size);
s.clear();
person p1;
person p2;
p1.name = "Mr. Rumpelstilzchen";
p1.age = 637;
p1.height = 123.4567;
p1.weight = 765.345f;
p1.is_insane = true;
p1.write(s);
s.reset();
p2.read(s);
if (p1 != p2)
{
std::cout << "Test01 failed!" << std::endl;
return false;
}
return true;
}
bool test02(char* buffer, const unsigned int buffer_size)
{
strtk::serializer s(buffer,buffer_size);
s.clear();
person p1;
p1.name = "Mr. Rumpelstilzchen";
p1.age = 0;
p1.height = 123.4567;
p1.weight = 765.345f;
p1.is_insane = true;
const std::size_t rounds = 1000;
for (unsigned int i = 0; i < rounds; ++i)
{
p1.write(s);
p1.age++;
p1.height += 1.23;
p1.weight += 4.567f;
p1.is_insane = !p1.is_insane;
}
s.reset();
p1.name = "Mr. Rumpelstilzchen";
p1.age = 0;
p1.height = 123.4567;
p1.weight = 765.345f;
p1.is_insane = true;
person p2;
for (unsigned int i = 0; i < rounds; ++i)
{
p2.clear();
p2.read(s);
if (p1 != p2)
{
std::cout << "Test02 failed!" << std::endl;
return false;
}
p1.age++;
p1.height += 1.23;
p1.weight += 4.567f;
p1.is_insane = !p1.is_insane;
}
return true;
}
bool test03(char* buffer, const unsigned int buffer_size)
{
strtk::serializer s(buffer,buffer_size);
s.clear();
person p1;
p1.name = "Mr. Rumpelstilzchen";
p1.age = 0;
p1.height = 123.4567;
p1.weight = 765.345f;
p1.is_insane = true;
const std::size_t rounds = 1000;
for (unsigned int i = 0; i < rounds; ++i)
{
p1.write(s);
p1.age++;
p1.height += 1.23;
p1.weight += 4.567f;
p1.is_insane = !p1.is_insane;
}
std::ofstream o_stream("data.txt",std::ios::binary);
if (!o_stream)
{
std::cout << "Test03() ERROR - Could not open file!(1)" << std::endl;
return false;
}
s.write_to_stream(o_stream);
o_stream.close();
std::size_t length = s.length();
std::ifstream i_stream("data.txt",std::ios::binary);
if (!i_stream)
{
std::cout << "Test03() ERROR - Could not open file!(2)" << std::endl;
return false;
}
s.read_from_stream(i_stream,length);
s.reset();
p1.name = "Mr. Rumpelstilzchen";
p1.age = 0;
p1.height = 123.4567;
p1.weight = 765.345f;
p1.is_insane = true;
person p2;
for (unsigned int i = 0; i < rounds; ++i)
{
p2.clear();
p2.read(s);
if (p1 != p2)
{
std::cout << "Test03 failed!" << std::endl;
return false;
}
p1.age++;
p1.height += 1.23;
p1.weight += 4.567f;
p1.is_insane = !p1.is_insane;
}
return true;
}
bool test04(char* buffer, const unsigned int buffer_size)
{
{
// Read out then back in an array of unsigned ints.
strtk::serializer s(buffer,buffer_size);
s.clear();
std::deque<unsigned int> lst;
const unsigned int max_count = 1000;
for (unsigned int i = 0; i < max_count; lst.push_back(i++)) ;
s.write_from_external_sequence(lst);
lst.clear();
s.reset();
s.read_into_external_sequence(lst);
for (unsigned int i = 0; i < max_count; ++i)
{
if (lst[i] != i)
{
std::cout << "test04 - 'unsigned int' failure at index: " << i << std::endl;
return false;
}
}
}
{
// Read out then back in an array of floats.
strtk::serializer s(buffer,buffer_size);
s.clear();
std::vector<float> lst;
const unsigned int max_count = 1000;
const std::size_t magic_count = 6;
const float magic[magic_count] = { 111.111f, 333.333f, 555.555f,
777.777f, 135.531f, 357.753f };
for (unsigned int i = 0; i < max_count; ++i)
{
lst.push_back(magic[i % magic_count] * i);
}
s.write_from_external_sequence(lst);
lst.clear();
s.reset();
s.read_into_external_sequence(lst);
for (unsigned int i = 0; i < max_count; ++i)
{
const float d = magic[i % magic_count] * i;
if (lst[i] != d)
{
std::cout << "test04 - 'float' failure at index: " << i
<< " expected value: " << d << std::endl;
return false;
}
}
}
{
// Read out then back in an array of doubles.
strtk::serializer s(buffer,buffer_size);
s.clear();
std::list<double> lst;
const unsigned int max_count = 1000;
const std::size_t magic_count = 6;
const double magic[magic_count] = { 111.111, 333.333, 555.555,
777.777, 135.531, 357.753 };
for (unsigned int i = 0; i < max_count; ++i)
{
lst.push_back(magic[i % magic_count] * i);
}
s.write_from_external_sequence(lst);
lst.clear();
s.reset();
s.read_into_external_sequence(lst);
std::list<double>::iterator itr = lst.begin();
for (unsigned int i = 0; i < max_count; ++i, ++itr)
{
const double d = magic[i % magic_count] * i;
if (*itr != d)
{
std::cout << "test04 - 'double' failure at index: " << i
<< " expected value: " << d << std::endl;
return false;
}
}
}
return true;
}
bool test05(char* buffer)
{
char in_char = -17;
unsigned char in_uchar = 200;
short in_short = -20000;
unsigned short in_ushort = 55555;
int in_int = -1111111;
unsigned int in_uint = 79797979;
long in_long = -43294761;
unsigned long in_ulong = 78292365;
float in_float = 1234.5678f;
double in_double = 9876.54321;
long double in_ldouble = 456789.123456;
char out_char = 0;
unsigned char out_uchar = 0;
short out_short = 0;
unsigned short out_ushort = 0;
int out_int = 0;
unsigned int out_uint = 0;
long out_long = 0;
unsigned long out_ulong = 0;
float out_float = 0.0f;
double out_double = 0.0;
long double out_ldouble = 0.0;
unsigned char* ptr = reinterpret_cast<unsigned char*>(buffer);
strtk::write_pod(ptr,
in_char,
in_uchar,
in_short,
in_ushort,
in_int,
in_uint,
in_long,
in_ulong,
in_float,
in_double,
in_ldouble);
strtk::read_pod(ptr,
out_char,
out_uchar,
out_short,
out_ushort,
out_int,
out_uint,
out_long,
out_ulong,
out_float,
out_double,
out_ldouble);
if (in_char != out_char) { std::cout << "test05 - Failed char" << std::endl; return false; }
if (in_uchar != out_uchar) { std::cout << "test05 - Failed uchar" << std::endl; return false; }
if (in_short != out_short) { std::cout << "test05 - Failed short" << std::endl; return false; }
if (in_ushort != out_ushort) { std::cout << "test05 - Failed ushort" << std::endl; return false; }
if (in_int != out_int) { std::cout << "test05 - Failed int" << std::endl; return false; }
if (in_uint != out_uint) { std::cout << "test05 - Failed uint" << std::endl; return false; }
if (in_long != out_long) { std::cout << "test05 - Failed long" << std::endl; return false; }
if (in_ulong != out_ulong) { std::cout << "test05 - Failed ulong" << std::endl; return false; }
if (in_float != out_float) { std::cout << "test05 - Failed float" << std::endl; return false; }
if (in_double != out_double) { std::cout << "test05 - Failed double" << std::endl; return false; }
if (in_ldouble != out_ldouble) { std::cout << "test05 - Failed ldouble" << std::endl; return false; }
return true;
}
bool test06(char* buffer)
{
const size_t size = 10;
const int intlst[size] = { -1, 2, -3, 4, -5, 6, -7, 8, -9, 10 };
const unsigned int uintlst[size] = {
734594, 1375762, 5432543, 3454, 32132,
65463, 976765, 2355754, 74239542, 32523
};
const float fltlst[size] = { 1.1f, 2.2f, 3.3f, 4.4f, 5.5f, 6.6f, 7.7f, 8.8f, 9.9f, 10.10f };
const double dbllst[size] = { 1.1, 2.2, 3.3, 4.4, 5.5, 6.6, 7.7, 8.8, 9.9, 10.10 };
int r_intlst[size] = { 0 };
unsigned int r_uintlst[size] = { 0 };
float r_fltlst[size] = { 0.0f };
double r_dbllst[size] = { 0.0 };
unsigned char* ptr = reinterpret_cast<unsigned char*>(buffer);
ptr = strtk::write_pod(ptr,intlst);
ptr = strtk::write_pod(ptr,uintlst);
ptr = strtk::write_pod(ptr,fltlst);
ptr = strtk::write_pod(ptr,dbllst);
ptr = reinterpret_cast<unsigned char*>(buffer);
ptr = strtk::read_pod(ptr,r_intlst);
ptr = strtk::read_pod(ptr,r_uintlst);
ptr = strtk::read_pod(ptr,r_fltlst);
ptr = strtk::read_pod(ptr,r_dbllst);
if (!std::equal(intlst, intlst + size, r_intlst))
{
std::cout << "test06 - failed int list compare." << std::endl;
return false;
}
if (!std::equal(uintlst, uintlst + size, r_uintlst))
{
std::cout << "test06 - failed unsigned int list compare." << std::endl;
return false;
}
if (!std::equal(fltlst, fltlst + size, r_fltlst))
{
std::cout << "test06 - failed float list compare." << std::endl;
return false;
}
if (!std::equal(dbllst, dbllst + size, r_dbllst))
{
std::cout << "test06 - failed double list compare." << std::endl;
return false;
}
return true;
}
int main()
{
static const std::size_t max_buffer_size = 64 * strtk::one_kilobyte; // 64KB
char* buffer = new char[max_buffer_size];
test01(buffer,max_buffer_size);
test02(buffer,max_buffer_size);
test03(buffer,max_buffer_size);
test04(buffer,max_buffer_size);
test05(buffer);
test06(buffer);
delete[] buffer;
return 0;
}
| [
"pinkfish@e0e46c49-be69-4f5a-ad62-21024a331aea"
] | pinkfish@e0e46c49-be69-4f5a-ad62-21024a331aea |
1a4623e87d7943aeefa7476d9e75245e69d3569d | c09b256a1cb2dafb33a6149b840a96ac7bb5ea92 | /ATourOfCPP11/Functions_12/ConstexprFunctions_5/constVsConstexpr_0.cpp | 438f202d658f2c4a1c3285e982b9705c7b9a2307 | [] | no_license | Masoudas/SampleCPlusPlusCodes | 2e7f4b3019cbfe5438f9a2490306ec4752515467 | 3945e0703f5d49fb4e86fffd3133d5076605c10e | refs/heads/master | 2021-07-08T13:09:35.512300 | 2020-10-07T15:34:23 | 2020-10-07T15:34:23 | 196,350,870 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,644 | cpp | /**
* See https://docs.microsoft.com/en-us/cpp/cpp/constexpr-cpp?view=vs-2019#:~:text=The%20primary%20difference%20between%20const,All%20constexpr%20variables%20are%20const%20.
* What's the difference between a const and a consexpr?
*
* The primary difference is that initialization of const can be deferred until run-time, whereas
* for constexpr it has to be done at compile time.
*
* When we mean run-time, we literally mean object initialization inside constructor, which is why the following
* initialization works, that allow us to have a constant class member.
*/
#include <iostream>
class A{
public:
const int x;
A(int x) : x(x){}
};
int main(){
A a{10};
std::cout << a.x;
}
/**
* As we already said in _6, a constexpr can only hold literal types, hence it cannot hold pointers.
* The only exception to pointers is the array of void or array of value types.
*/
/**
* A variable can be declared with constexpr, when it has a literal type and is initialized.
* If the initialization is performed by a constructor, the constructor must be declared as constexpr.
* A reference may be declared as constexpr when both these conditions are met:
* The referenced object is initialized by a constant expression, and any implicit conversions invoked
* during initialization are also constant expressions. (Why would someone need to define a reference constexpr?)
*
* So we can assign to a const using constexpr and vice-versa.
* const int x = 10;
* constexpr int y = x;
*
* However, when it comes to assignment with function, we could only assign using constexpr to constant expression.
*
*/
| [
"Masoudas@hotmail.com"
] | Masoudas@hotmail.com |
b30e658df6812559716b4b16cc57715c4482accc | df8b0b089e2bf863ce2d1e471db8d34f12ada531 | /sawyer_interface/sawyer_woz/include/sawyer_woz/sawyer_woz.hpp | 968db059c20aab47879b56b1586e39506476d52e | [] | no_license | ICRA-2019/TCG | aba1af1c607626819c6900eb488b711d4e4890be | e917dada693d912c7dc6d46d379ad696c7e6a632 | refs/heads/master | 2022-02-13T07:30:28.827489 | 2018-09-04T15:49:44 | 2018-09-04T15:49:44 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,738 | hpp | #ifndef SAWYER_WOZINTERFACE_H
#define SAWYER_WOZINTERFACE_H
#include <QWidget>
#include <QImage>
#include <QPainter>
#include <QPaintDevice>
#include <QtGui>
#include <QLCDNumber>
#include <ros/ros.h>
#include <ros/callback_queue.h>
#include <std_msgs/String.h>
#include <std_msgs/Int8.h>
#include <std_msgs/Bool.h>
#include <std_srvs/Empty.h>
#include <iostream>
#include <ctime>
#include <fstream>
#include <string>
#include <stdlib.h>
#include <time.h>
#include <tf/transform_listener.h>
namespace Ui {
class SawyerWoZInterface;
}
class SawyerWoZInterface : public QWidget {
Q_OBJECT
public:
explicit SawyerWoZInterface(QWidget *parent = 0);
~SawyerWoZInterface();
void controlCallback(const std_msgs::Int8 &msg);
void humanCallback(const std_msgs::Int8 &msg);
void actionCallback(const std_msgs::Int8 &msg);
void UpdateImage();
private
Q_SLOTS:
void on_pickItem_clicked();
void on_placeDQA_clicked();
void on_placeSQA_clicked();
void on_placeBox_clicked();
void on_startRecording_clicked();
void on_stopRecording_clicked();
void on_moveToStart_clicked();
void on_run_clicked();
void on_countDown_overflow();
protected:
void timerEvent(QTimerEvent *event);
private:
Ui::SawyerWoZInterface *ui;
QBasicTimer Mytimer;
QTimer *timer;
QTimer *cdtimer;
ros::NodeHandle n;
ros::Publisher pub_sawyer_woz_msgs, pub_run;
ros::ServiceClient client_record_start, client_record_stop;
ros::Subscriber sub_sawyer_msgs, sub_action_msgs, sub_human_msgs;
int count;
int longTimeout;
int shortTimeout;
int itemLimit;
bool humanReady;
bool recording;
tf::TransformListener listener;
};
#endif
| [
"eccarpio@hotmail.com"
] | eccarpio@hotmail.com |
c33dec4ee32e5ddbec1a70d1873d9846b6cdd527 | 38b7c79c386f46f53be75df5f4003ba4b2b8f1f8 | /DSA/Sorting/SelectionSortAlgo.cpp | 14cf4d5640943f5137d2cca4ade97b2972cf1b02 | [] | no_license | inioluwaa/Problem-Solving | 28c5c6e644583fc83847c597654004145688c080 | 77482ac0b0224af626bcd329a4f091058f635e73 | refs/heads/master | 2020-04-09T08:09:18.675605 | 2019-07-05T06:20:35 | 2019-07-05T06:20:35 | 158,824,806 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 556 | cpp | #include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main() {
}
void SelectionSort(vector<int> &array) {
int minIndex, minValue;
for (int start = 0; start < (array.size() - 1); start++) {
minIndex = start;
minValue = array[start];
for (int index = start + 1; index < array.size(); index++) {
if (array[index] < minValue) {
minValue = array[index];
minIndex = index;
}
}
swap(array[minIndex], array[start]);
}
}
| [
"inioluwaakinleye@gmail.com"
] | inioluwaakinleye@gmail.com |
b35147dbec02958dd6de8ef8d8da4c857a681474 | 65ac72799ea978a9c73bcbb1cb04095637576f98 | /cpp/include/cudf/utilities/span.hpp | 7e25ea4ce2ddda3d32b2e6469b942ed94d224e90 | [
"Apache-2.0"
] | permissive | trxcllnt/cudf | fd3251d47aa9de21cf4156189326e128ce346b1d | 507299d2e75fd58a5ff1fe8d187184d287bbf23f | refs/heads/branch-0.16 | 2023-08-23T10:39:43.507170 | 2020-10-13T06:24:35 | 2020-10-13T06:24:35 | 177,693,334 | 0 | 0 | Apache-2.0 | 2020-09-04T12:57:22 | 2019-03-26T01:35:55 | C++ | UTF-8 | C++ | false | false | 5,926 | hpp | /*
* Copyright (c) 2020, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#pragma once
#include <rmm/thrust_rmm_allocator.h>
#include <rmm/device_buffer.hpp>
#include <rmm/device_uvector.hpp>
#include <thrust/detail/raw_pointer_cast.h>
#include <thrust/device_vector.h>
#include <cstddef>
#include <limits>
#include <type_traits>
namespace cudf {
namespace detail {
constexpr std::size_t dynamic_extent = std::numeric_limits<std::size_t>::max();
/**
* @brief C++20 std::span with reduced feature set.
*/
template <typename T, std::size_t Extent, typename Derived>
class span_base {
static_assert(Extent == dynamic_extent, "Only dynamic extent is supported");
public:
using element_type = T;
using value_type = std::remove_cv<T>;
using size_type = std::size_t;
using difference_type = std::ptrdiff_t;
using pointer = T*;
using iterator = T*;
using const_pointer = T const*;
using reference = T&;
using const_reference = T const&;
static constexpr std::size_t extent = Extent;
constexpr span_base() noexcept : _data(nullptr), _size(0) {}
constexpr span_base(pointer data, size_type size) : _data(data), _size(size) {}
// constexpr span_base(pointer begin, pointer end) : _data(begin), _size(end - begin) {}
constexpr span_base(span_base const& other) noexcept = default;
constexpr span_base& operator=(span_base const& other) noexcept = default;
// not noexcept due to undefined behavior when size = 0
constexpr reference front() const { return _data[0]; }
// not noexcept due to undefined behavior when size = 0
constexpr reference back() const { return _data[_size - 1]; }
// not noexcept due to undefined behavior when idx < 0 || idx >= size
constexpr reference operator[](size_type idx) const { return _data[idx]; }
constexpr iterator begin() const noexcept { return _data; }
constexpr iterator end() const noexcept { return _data + _size; }
constexpr pointer data() const noexcept { return _data; }
constexpr size_type size() const noexcept { return _size; }
constexpr size_type size_bytes() const noexcept { return sizeof(T) * _size; }
constexpr bool empty() const noexcept { return _size == 0; }
/**
* @brief Obtains a subspan consisting of the first N elements of the sequence
*
* @param count Number of elements from the beginning of this span to put in the subspan.
*/
constexpr Derived first(size_type count) const noexcept { return Derived(_data, count); }
/**
* @brief Obtains a subspan consisting of the last N elements of the sequence
*
* @param count Number of elements from the end of this span to put in the subspan
*/
constexpr Derived last(size_type count) const noexcept
{
return Derived(_data + _size - count, count);
}
constexpr Derived subspan(size_type offset, size_type count) const noexcept
{
return Derived(_data + offset, count);
}
private:
pointer _data;
size_type _size;
};
// ===== host_span =================================================================================
template <typename T>
struct is_host_span_supported_container : std::false_type {
};
template <typename T, typename Alloc>
struct is_host_span_supported_container< //
std::vector<T, Alloc>> : std::true_type {
};
template <typename T, typename Alloc>
struct is_host_span_supported_container< //
thrust::host_vector<T, Alloc>> : std::true_type {
};
template <typename T, std::size_t Extent = dynamic_extent>
struct host_span : public span_base<T, Extent, host_span<T, Extent>> {
using base = cudf::detail::span_base<T, Extent, host_span<T, Extent>>;
using base::base;
constexpr host_span() noexcept : base() {} // required to compile on centos
template <typename C, std::enable_if_t<is_host_span_supported_container<C>::value>* = nullptr>
constexpr host_span(C& in) : base(in.data(), in.size())
{
}
template <typename C, std::enable_if_t<is_host_span_supported_container<C>::value>* = nullptr>
constexpr host_span(C const& in) : base(in.data(), in.size())
{
}
};
// ===== device_span ===============================================================================
template <typename T>
struct is_device_span_supported_container : std::false_type {
};
template <typename T, typename Alloc>
struct is_device_span_supported_container< //
thrust::device_vector<T, Alloc>> : std::true_type {
};
template <typename T>
struct is_device_span_supported_container< //
rmm::device_vector<T>> : std::true_type {
};
template <typename T>
struct is_device_span_supported_container< //
rmm::device_uvector<T>> : std::true_type {
};
template <typename T, std::size_t Extent = dynamic_extent>
struct device_span : public span_base<T, Extent, device_span<T, Extent>> {
using base = cudf::detail::span_base<T, Extent, device_span<T, Extent>>;
using base::base;
constexpr device_span() noexcept : base() {} // required to compile on centos
template <typename C, std::enable_if_t<is_device_span_supported_container<C>::value>* = nullptr>
constexpr device_span(C& in) : base(thrust::raw_pointer_cast(in.data()), in.size())
{
}
template <typename C, std::enable_if_t<is_device_span_supported_container<C>::value>* = nullptr>
constexpr device_span(C const& in) : base(thrust::raw_pointer_cast(in.data()), in.size())
{
}
};
} // namespace detail
} // namespace cudf
| [
"noreply@github.com"
] | trxcllnt.noreply@github.com |
3b55d6c72cee68db3356bc76076484747cf5f9ef | 112e119bc9baf584550045b249b283b02901e0b1 | /U/Source/Overlord/NpcSystem/Character/CSPlayer.h | e97e551528104c12674a64b9e17d4ac05a87c8fe | [] | no_license | Iliketoshootunity/UE4 | 17a42513004606d1338cb902c881eee3a43ddad1 | dee869b5594002d621ca86131c961db4a2e0d084 | refs/heads/master | 2020-12-13T15:24:17.615337 | 2020-01-17T09:50:07 | 2020-01-17T09:50:07 | 234,457,306 | 1 | 0 | null | null | null | null | GB18030 | C++ | false | false | 853 | h | // Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "Protoc/fight.pb.h"
#include "Protoc/move.pb.h"
#include "CSCharacter.h"
#include "CSPlayer.generated.h"
/**
*
*/
UCLASS()
class OVERLORD_API ACSPlayer : public ACSCharacter
{
GENERATED_BODY()
public:
ACSPlayer();
public:
//////////////////////////////////////////////////////////////////////////
// 输入操作相关
UFUNCTION(BlueprintCallable, Category = Input) void OnRotateToTagrget(float RotateTime);
void CoverOperation(float NewRockerX, float NewRockerY, float NewMaxRotate, float NewSourceYaw, float NewControllerYaw, float NewTargetYaw); //*覆盖操作信息*/
float CacheMaxRotate;
float CacheSourceYaw;
float CacheTargetYaw;
float CacheRockerX;
float CacheRockerY;
float CacheControllerYaw;
};
| [
"34265768+Iliketoshootunity@users.noreply.github.com"
] | 34265768+Iliketoshootunity@users.noreply.github.com |
cd501f73ea695a4cb81e28860c5d6d20f7c957c1 | 3aa583042109255f69ddbb7259b14b2e3ae95f29 | /main.cpp | 1292d2aa69e0a83e386160a2f3bc8ad6b3e1c930 | [] | no_license | Simmiyo/2_tema15 | 6694bc5f89786584fd33f77b3b6744abc52f877b | f4435a5d845ad4b08934c5471cc6557178ccbce1 | refs/heads/master | 2020-05-06T13:45:48.090556 | 2019-04-08T18:49:28 | 2019-04-08T18:49:28 | 180,154,662 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,275 | cpp | #include <iostream>
#include <fstream>
#include "Clasa_Vector.h"
#include "Clasa_Nr_natural.h"
#include "Clasa_Nr_intreg.h"
using namespace std;
template <class clasa> void Swap(clasa &a,clasa &b)
{
clasa aux;
aux = a;
a = b;
b = aux;
}
template <class clasa> void Sort(clasa *v,int n)
{
int i,j = 0,minpoz;
clasa Min;
for(j=0;j<n-1;j++)
{
Min = v[j];
minpoz = j;
for(i=j;i<n;i++)
{
if(Min >= v[i])
{
Min = v[i];
minpoz = i;
}
}
Swap(v[j],v[minpoz]);
}
}
int main()
{
ifstream f("numere.in");
Nr_natural *vec[10];
int i,n,t;
f>>n;
for(i=0;i<n;i++)
{
f>>t;
if(!t)
vec[i] = new Nr_intreg;
else
vec[i] = new Nr_natural;
}
for(i=0;i<n;i++)
{
f>>(*vec[i]);
cout<<*vec[i]<<" ";
}
cout<<endl;
Nr_intreg x,y,v[10];
cin>>x>>y;
cout<<x*y<<endl;
cout<<x-y<<endl;
cout<<x+y<<endl;
Swap(x,y);
cout<<x<<" "<<y<<endl;
Nr_natural v1[10];
for(i=0;i<n;i++)
{
f>>v1[i];
}
Sort(v1,n);
for(i=0;i<n;i++)
{
cout<<v1[i]<<" ";
}
f.close();
return 0;
}
| [
"noreply@github.com"
] | Simmiyo.noreply@github.com |
1041fe449b57da8c9cf24cc150a66ffab7a3c4ff | 6b2a8dd202fdce77c971c412717e305e1caaac51 | /solutions_5644738749267968_0/C++/Luizim/deceitfulWar.cpp | c5c7537d65adbffb29f5419d7e8ca788e6d37b21 | [] | no_license | alexandraback/datacollection | 0bc67a9ace00abbc843f4912562f3a064992e0e9 | 076a7bc7693f3abf07bfdbdac838cb4ef65ccfcf | refs/heads/master | 2021-01-24T18:27:24.417992 | 2017-05-23T09:23:38 | 2017-05-23T09:23:38 | 84,313,442 | 2 | 4 | null | null | null | null | UTF-8 | C++ | false | false | 711 | cpp | #include <iostream>
#include <set>
using namespace std;
int main(){
int t;
cin>>t;
for(int i=0;i<t;i++){
int n, n1=0, n2=0;
cin>>n;
set<double> set1, set2;
for(int j=0;j<n;j++){
double aux;
cin>>aux;
set1.insert(aux);
}
for(int j=0;j<n;j++){
double aux;
cin>>aux;
set2.insert(aux);
}
set<double>::iterator it1 = set1.begin(), it2 = set2.begin();
for(int i=0;i<n;i++){
if(*it1>*it2){
n1++;
it2++;
}
it1++;
}
set<double>::reverse_iterator rit1, rit2;
rit1 = set1.rbegin();
rit2 = set2.rbegin();
for(int i=0;i<n;i++){
if(*rit1>*rit2)
n2++;
else
rit2++;
rit1++;
}
cout<<"Case #"<<i+1<<": "<<n1<<' '<<n2<<endl;
}
} | [
"eewestman@gmail.com"
] | eewestman@gmail.com |
6c4abe83bfcd2fc3121a808f5a44913d559f1c63 | 242b897609ebb0d23cfbcaa22a1177f47d359fab | /src/datatypes/graph.cpp | 5638f40222aa33bc888659d2b5fcd1c7546049e5 | [] | no_license | JoOkuma/segm | 868e7e2ae7a647d3f2902949d67a017d23efee1e | 6d3ea82c4ee6dcc94c26db8e9d03392397646449 | refs/heads/master | 2020-04-16T05:03:04.813817 | 2019-08-30T14:48:11 | 2019-08-30T14:48:11 | 165,291,286 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 42 | cpp |
#include "graph.h"
using namespace segm; | [
"jordao.bragantini@gmail.com"
] | jordao.bragantini@gmail.com |
91cd12d72e82267442f1ac75b2e9077ed4c93ffa | 3c1abab292ef3ae73604621e299b5def07e7b403 | /PiscineCPP/day00/ex00/megaphone.cpp | 89e9e3eec7daf4d14694b9c989f126f8b9bd31f0 | [] | no_license | hdelanoe/42born2code | 672dc0c63e00902582f9ffa1be11cfb01b98fef4 | 2ecb5ceb7131900b3ca15379ec1c16a508c63e2c | refs/heads/master | 2021-01-20T12:28:02.109625 | 2019-05-08T13:28:55 | 2019-05-08T13:28:55 | 89,773,613 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,237 | cpp | /* ************************************************************************** */
/* */
/* ::: :::::::: */
/* megaphone.cpp :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: hdelanoe <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2018/04/08 20:57:33 by hdelanoe #+# #+# */
/* Updated: 2018/04/08 21:14:34 by hdelanoe ### ########.fr */
/* */
/* ************************************************************************** */
#include <iostream>
#include <cctype>
int main(int argc, char **argv)
{
int i;
int j;
char *str;
i = 0;
while (argv[++i])
{
str = argv[i];
j = -1;
while (str[++j])
std::cout << char(toupper(int(str[j])));
}
if (argc == 1)
std::cout << "* LOUD AND UNBEARABLE FEEDBACK NOISE *";
std::cout << std::endl;
return (0);
}
| [
"delanoe.hugo@gmail.com"
] | delanoe.hugo@gmail.com |
878f8106872a5f664026cd5589fe1f0687535996 | 3e45eb6d621659714b79192568c54e53be9ef290 | /admin/thirdparty/bbclone/ip2ext/74.inc | 4841de37b5a73989205b803ca82eb04fb2d165e8 | [] | no_license | Rafaj-Design/WebGuru | 233317c39bafced10c1ee728d2f0a05031c7d15a | f6bf85f149d14630deda57a06d361fd6758817eb | refs/heads/master | 2021-05-26T16:54:20.748036 | 2013-04-26T12:20:13 | 2013-04-26T12:20:13 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,203 | inc | us|1241513984|131072
us|1241776128|4096
us|1241907200|98304
us|1242038272|65536
ca|1242300416|262144
us|1242562560|1703936
ca|1244659712|65536
us|1244790784|4096
us|1244798976|4096
us|1244807168|4096
us|1244815360|4096
us|1244823552|4096
ca|1244831744|4096
us|1244839936|4096
ca|1244848128|4096
us|1244856320|4096
ca|1244864512|4096
us|1244872704|4096
us|1244880896|4096
us|1244889088|4096
us|1244897280|4096
us|1244905472|4096
us|1244913664|4096
us|1244921856|65536
ca|1245184000|131072
us|1245446144|32768
us|1245577216|73728
us|1245708288|671744
us|1246756864|262144
ca|1247281152|262144
us|1247543296|131072
ca|1247805440|1744896
us|1249681408|4096
us|1249689600|8192
us|1249705984|16384
us|1249771520|4096
us|1249779712|4096
us|1249787904|4096
ca|1249796096|4096
us|1249804288|4096
us|1249812480|4096
us|1249820672|4096
us|1249828864|4096
us|1249837056|8192
us|1249853440|8192
us|1249869824|4096
ca|1249886208|12288
us|1249902592|1376256
us|1251999744|1048576
us|1254096896|262144
ca|1254621184|8192
us|1254637568|8192
us|1254653952|24576
us|1254686720|12288
us|1254752256|65536
us|1254883328|16384
us|1254916096|8192
us|1254932480|20480
us|1254981632|4096
ca|1254989824|8192
us|1254998016|4096
us|1255006208|4096
us|1255014400|8192
us|1255030784|8192
ca|1255047168|8192
pr|1255063552|8192
us|1255079936|8192
us|1255096320|36864
us|1255145472|20480
us|1255211008|16384
ca|1255276544|12288
ca|1255309312|24576
us|1255342080|24576
us|1255374848|16384
us|1255407616|8192
us|1255424000|8192
us|1255440384|4096
us|1255456768|8192
us|1255473152|8192
pr|1255489536|8192
us|1255505920|8192
us|1255522304|4096
us|1255538688|4096
us|1255546880|4096
us|1255555072|16384
ca|1255571456|4096
us|1255579648|4096
us|1255587840|4096
us|1255596032|4096
us|1255604224|32768
ca|1255669760|65536
us|1255800832|53248
us|1255931904|4096
us|1255940096|4096
us|1255948288|4096
us|1255956480|4096
us|1255964672|4096
ca|1255972864|4096
us|1255981056|4096
us|1255989248|4096
us|1255997440|4096
us|1256005632|4096
us|1256013824|4096
us|1256022016|12288
us|1256038400|4096
us|1256046592|4096
us|1256054784|4096
us|1256062976|4096
us|1256087552|4096
us|1256095744|8192
us|1256112128|8192
us|1256128512|32768
us|1256194048|2097152 | [
"ondrej.rafaj@fuerteint.com"
] | ondrej.rafaj@fuerteint.com |
f7b1b5fd5aabfcc450335cfce9586e0b913b912b | 508fff84ee929a68daac4ff900d36912f0d6b6ed | /WSEExternal/include/Common/Serialize/Util/hkChainedClassNameRegistry.h | 7c16cc88ca16b87c23d029c645bc168a9f78010f | [
"WTFPL"
] | permissive | blockspacer/wse | f2e05755ba1263c645d0b021548a73e5a5a33ba6 | 3ad901f1a463139b320c30ea08bdc343358ea6b6 | refs/heads/master | 2023-03-16T13:15:04.153026 | 2014-02-13T08:10:03 | 2014-02-13T08:10:03 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,884 | h | /*
*
* Confidential Information of Telekinesys Research Limited (t/a Havok). Not for disclosure or distribution without Havok's
* prior written consent. This software contains code, techniques and know-how which is confidential and proprietary to Havok.
* Level 2 and Level 3 source code contains trade secrets of Havok. Havok Software (C) Copyright 1999-2009 Telekinesys Research Limited t/a Havok. All Rights Reserved. Use of this software is subject to the terms of an end user license agreement.
*
*/
#ifndef HK_SERIALIZE_CHAINED_CLASS_NAME_REGISTRY_H
#define HK_SERIALIZE_CHAINED_CLASS_NAME_REGISTRY_H
#include <Common/Base/Reflection/Registry/hkDynamicClassNameRegistry.h>
/// Partially populated registry which forwards requests for unknown classes.
class hkChainedClassNameRegistry : public hkDynamicClassNameRegistry
{
public:
hkChainedClassNameRegistry( const hkClassNameRegistry* nextReg );
~hkChainedClassNameRegistry();
virtual const hkClass* getClassByName( const char* className ) const;
void setNextRegistry(const hkClassNameRegistry* nextRegistry);
protected:
const hkClassNameRegistry* m_nextRegistry;
};
#endif // HK_SERIALIZE_CHAINED_CLASS_NAME_REGISTRY_H
/*
* Havok SDK - NO SOURCE PC DOWNLOAD, BUILD(#20090704)
*
* Confidential Information of Havok. (C) Copyright 1999-2009
* Telekinesys Research Limited t/a Havok. All Rights Reserved. The Havok
* Logo, and the Havok buzzsaw logo are trademarks of Havok. Title, ownership
* rights, and intellectual property rights in the Havok software remain in
* Havok and/or its suppliers.
*
* Use of this software for evaluation purposes is subject to and indicates
* acceptance of the End User licence Agreement for this product. A copy of
* the license is included with this software and is also available at www.havok.com/tryhavok.
*
*/
| [
"690187+Swyter@users.noreply.github.com"
] | 690187+Swyter@users.noreply.github.com |
09f6c2a04595dcb50f408d8466530f0e171d35c2 | 6fa16a9321d8d968c8524eaf29e08602cbd50f33 | /examples/01-REQ-REP/clientREQ.cpp | 1962497b2b32d52c0f665539a105bfe7809d35ba | [
"MIT"
] | permissive | skyformat99/zmqHelper | cb975fd502f926c83ccbbf19ea6e1ab19c789396 | badb1b1f4589866f9de1fe1cbb0be170a63b14f5 | refs/heads/master | 2020-12-28T19:23:45.085523 | 2014-12-29T12:59:34 | 2014-12-29T12:59:34 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,016 | cpp |
// -----------------------------------------------------------------
// clientREQ.cpp
// -----------------------------------------------------------------
#include <zmq.hpp>
#include <string>
#include <iostream>
#include "../../zmqHelper.h"
// -----------------------------------------------------------------
// -----------------------------------------------------------------
int main ()
{
using namespace zmqHelper;
SocketAdaptor< ZMQ_REQ > sa;
std::cerr << "Connecting to hello world server..." << std::endl;
sa.connect ("tcp://localhost:5555");
// Do 10 requests, waiting each time for a response
for (int i = 1; i <= 10; i++) {
// Send the request
std::vector<std::string> multi = { "Hallo Hallo", "Hello Hello" };
sa.sendText ( multi );
// Get the reply.
auto lines = sa.receiveText ();
std::cout << " received -------- \n";
for ( auto s : lines ) {
std::cout << s << "\n";
}
std::cout << " ----------------- \n";
} // for
sa.close ();
return 0;
} // main ()
| [
"cibercitizen1@gmail.com"
] | cibercitizen1@gmail.com |
fa6855ff814e79117b6c9fcd5731d06b84130a04 | eac31c4934320fd87e6a181c00a390aca0f51455 | /project/win32/third_party/fox/include/FXDirDialog.h | 999e92692c6f973d97ee4453d995405187d5e8f5 | [] | no_license | zhanglehs/rtc21 | 0ab5a213479d4d98c2e8087013c4f189887c4a8e | 54f9c1fb8d634e2e27b45b48bb6a2e8978191df0 | refs/heads/master | 2021-09-07T20:56:49.582627 | 2018-03-01T01:40:52 | 2018-03-01T01:40:52 | 98,876,600 | 0 | 2 | null | null | null | null | UTF-8 | C++ | false | false | 4,018 | h | /********************************************************************************
* *
* D i r e c t o r y S e l e c t i o n D i a l o g *
* *
*********************************************************************************
* Copyright (C) 2000,2016 by Jeroen van der Zijp. All Rights Reserved. *
*********************************************************************************
* This library is free software; you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License as published by *
* the Free Software Foundation; either version 3 of the License, or *
* (at your option) any later version. *
* *
* This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Lesser General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/> *
********************************************************************************/
#ifndef FXDIRDIALOG_H
#define FXDIRDIALOG_H
#ifndef FXDIALOGBOX_H
#include "FXDialogBox.h"
#endif
namespace FX {
class FXFileAssociations;
class FXDirSelector;
/**
* A Directory Dialog provides a way to select a directory. In function,
* the directory selection dialog is very similar to the file dialog, except that
* the Directory Dialog displays a tree-structured view of the file system, and
* thereby makes up and down navigation through the file system significantly easier.
*/
class FXAPI FXDirDialog : public FXDialogBox {
FXDECLARE(FXDirDialog)
protected:
FXDirSelector *dirbox; // Directory selection widget
protected:
FXDirDialog(){}
void initdialog();
private:
FXDirDialog(const FXDirDialog&);
FXDirDialog &operator=(const FXDirDialog&);
public:
/// Construct Directory Dialog box
FXDirDialog(FXWindow* owner,const FXString& name,FXuint opts=0,FXint x=0,FXint y=0,FXint w=400,FXint h=300);
/// Construct free-floating Directory Dialog box
FXDirDialog(FXApp* a,const FXString& name,FXuint opts=0,FXint x=0,FXint y=0,FXint w=400,FXint h=300);
/// Hide this window
virtual void hide();
/// Change directory
void setDirectory(const FXString& path);
/// Return directory
FXString getDirectory() const;
/// Return true if showing files as well as directories
FXbool showFiles() const;
/// Show or hide normal files
void showFiles(FXbool showing);
/// Return true if showing hidden files
FXbool showHiddenFiles() const;
/// Show or hide hidden files
void showHiddenFiles(FXbool showing);
/// Return wildcard matching mode
FXuint getMatchMode() const;
/// Change wildcard matching mode (see FXPath)
void setMatchMode(FXuint mode);
/// Change directory list style
void setDirBoxStyle(FXuint style);
/// Return directory list style
FXuint getDirBoxStyle() const;
/// Change file associations; delete old ones if owned
void setAssociations(FXFileAssociations* assoc,FXbool owned=false);
/// Return file associations
FXFileAssociations* getAssociations() const;
/// Open directory name
static FXString getOpenDirectory(FXWindow* owner,const FXString& caption,const FXString& path);
/// Save to stream
virtual void save(FXStream& store) const;
/// Load from stream
virtual void load(FXStream& store);
/// Destructor
virtual ~FXDirDialog();
};
}
#endif
| [
"zl124548@youku.com"
] | zl124548@youku.com |
2143a21dd25822be2350977687b36f1ab01b25df | 4b7bbca74248ac244eec794b7181a8196c5e6b34 | /archive/LeetCode/leetcode-medium-654-Maximum Binary Tree.cpp | 68800badda240d59fefb11efac7f11eb59f85bbb | [] | no_license | macans/algorithm-problems | 6bba1b42019dcea76044c3398ce534332a997d40 | c976610773f08fd059dd7b5ac11c4b5a2f475543 | refs/heads/master | 2022-09-14T05:42:41.538584 | 2022-08-15T02:29:59 | 2022-08-15T02:29:59 | 128,619,483 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,786 | cpp | /**
* @authors: https://github.com/macans
* @date: 2020-05-29 21:19:15
*/
#include <vector>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <iostream>
using namespace std;
struct TreeNode {
int val;
TreeNode *left;
TreeNode *right;
TreeNode() : val(0), left(nullptr), right(nullptr) {}
TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}
TreeNode(int x, TreeNode *left, TreeNode *right) : val(x), left(left), right(right) {}
};
class Solution1 {
public:
TreeNode* constructMaximumBinaryTree(vector<int>& nums) {
map<int, TreeNode*> s;
for(int i = 0; i < nums.size(); i++){
auto it = s.insert(make_pair(nums[i], new TreeNode(nums[i]))).first;
if(it != s.begin()){
it->second->left = next(it, -1)->second;
s.erase(s.begin(), it);
}
if(next(it, 1) != s.end()) {
next(it, 1)->second->right = it->second;
}
}
return s.rbegin()->second;
}
};
class Solution2 {
public:
TreeNode* constructMaximumBinaryTree(vector<int>& nums) {
vector<pair<int, TreeNode*> > s;
s.push_back(make_pair(nums[0], new TreeNode(nums[0])));
for(int i = 1; i < nums.size(); i++){
TreeNode* cur = new TreeNode(nums[i]);
pair<int, TreeNode*> p = make_pair(nums[i], cur);
auto it = lower_bound(s.rbegin(), s.rend(), p);
if(it != s.rend()){
it->second->right = cur;
}
if(it != s.rbegin()){
cur->left = next(it, -1)->second;
}
s.resize(distance(it, s.rend()));
s.push_back(p);
}
return s.front().second;
}
};
int main(){
}
| [
"jzhaa@amazon.com"
] | jzhaa@amazon.com |
3225ca177b48f83f9061897325d56189b330cc82 | 17c2db030b06e193ed96ae4f6a21860e22a6661d | /libjulia/usr/include/llvm/Config/AsmPrinters.def | 7cb52aaf15ea6ac5c0366a2cb38da2f7bb35b137 | [
"MIT",
"BSD-3-Clause"
] | permissive | tshort/jl2js-dock | ef19fc34e988a020d9bc45b4e8befe9dc1b8162f | cc1e7f3512d20e3870848d34fd1773bbbf87eac6 | refs/heads/master | 2021-06-29T05:10:52.583507 | 2017-09-24T13:19:00 | 2017-09-24T13:19:00 | 104,154,517 | 3 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 1,869 | def | /*===- llvm/Config/AsmPrinters.def - LLVM Assembly Printers -----*- C++ -*-===*\
|* *|
|* The LLVM Compiler Infrastructure *|
|* *|
|* This file is distributed under the University of Illinois Open Source *|
|* License. See LICENSE.TXT for details. *|
|* *|
|*===----------------------------------------------------------------------===*|
|* *|
|* This file enumerates all of the assembly-language printers *|
|* supported by this build of LLVM. Clients of this file should define *|
|* the LLVM_ASM_PRINTER macro to be a function-like macro with a *|
|* single parameter (the name of the target whose assembly can be *|
|* generated); including this file will then enumerate all of the *|
|* targets with assembly printers. *|
|* *|
|* The set of targets supported by LLVM is generated at configuration *|
|* time, at which point this header is generated. Do not modify this *|
|* header directly. *|
|* *|
\*===----------------------------------------------------------------------===*/
#ifndef LLVM_ASM_PRINTER
# error Please define the macro LLVM_ASM_PRINTER(TargetName)
#endif
LLVM_ASM_PRINTER(NVPTX)
LLVM_ASM_PRINTER(X86)
#undef LLVM_ASM_PRINTER
| [
"tshort.rlists@gmail.com"
] | tshort.rlists@gmail.com |
f42d77aa1e1eb833c342ea7f882f6883057cc3e6 | 0444cfef309d88c36885041ea9b5c151729c0a1b | /dlv/dlv_channelpage.h | 0465aafca7b3f172a77c75938a795ba1573845dd | [] | no_license | matthklo/dill | 7c976f7aabbd9e0f2eab449b74678fd53723b585 | e22a4fac70c952bff46bbb5e658ce7b6798d3fe6 | refs/heads/master | 2020-04-25T12:46:45.131420 | 2013-05-27T15:08:25 | 2013-05-27T15:08:25 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,898 | h | /*
* Copyright (c) 2013, hklo.tw@gmail.com
* 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 <organization> 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 <COPYRIGHT HOLDER> 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.
*
*/
#pragma once
#include "dlv.h"
#include <wx/listctrl.h>
#include <wx/statline.h>
#include <vector>
#include <map>
class DlvChannelPage : public wxPanel
{
public:
DlvChannelPage(wxWindow *parent, DLVCHTYPE type = CHTYPE_LIVE);
~DlvChannelPage();
void OnAppenLog(DlvEvtDataLog *logdata);
void OnUpdateRegister(DlvEvtDataRegister *regdata);
void OnShowRegViewButtonClicked(wxCommandEvent& ev);
void OnLogClear(wxCommandEvent& ev);
void OnPriorityFilterChanged(wxCommandEvent& ev);
void OnRecordButtonClicked(wxCommandEvent& ev);
DLVCHTYPE getType() const;
private:
DECLARE_EVENT_TABLE()
void renderLog(DlvEvtDataLog *logdata);
void resetContent();
void resetLogContent(bool deleteRaw = true);
void resetRegisterContent();
unsigned char getCurrentPriorityFilterLevel();
DLVCHTYPE mChannelType;
bool mRecording;
wxBoxSizer* mMainVBoxSizer;
wxBoxSizer* mButtonHBoxSizer;
wxBoxSizer* mPriorityFilterHBoxSizer;
wxBoxSizer* mContentHBoxSizer;
wxBoxSizer* mLogVBoxSizer;
wxBoxSizer* mFilterHBoxSizer;
wxListCtrl* mLogListCtrl;
wxListCtrl* mRegListCtrl;
wxBitmapButton* mShowRegViewButton;
wxBitmapButton* mFilterAddButton;
wxBitmapButton* mFilterEditButton;
wxBitmapButton* mFilterDeleteButton;
wxBitmapButton* mClearLogButton;
wxBitmapButton* mRecordButton;
wxComboBox* mPriorityComboBox;
wxTextCtrl* mFilterTextCtrl;
wxImage* mFilterAddImage;
wxImage* mFilterEditImage;
wxImage* mFilterDeleteImage;
wxImage* mClearLogImage;
wxImage* mShowRegViewImage;
wxImage* mHideRegViewImage;
wxImage* mStartRecordingImage;
wxImage* mStopRecordingImage;
typedef std::vector<DlvEvtDataLog*> LogDataVector;
std::vector<DlvEvtDataLog*> mLogData;
struct StringLess : std::binary_function<wxString, wxString, bool>
{
bool operator() (const wxString& a, const wxString& b) const
{
return (a.compare(b) < 0);
}
};
typedef std::map<wxString, long, StringLess> RegisterMap;
std::map<wxString, long, StringLess> mRegisterData;
};
| [
"hklo.tw@gmail.com"
] | hklo.tw@gmail.com |
89e22a255c6c158e9a5d88db011d2532ce4ebfd4 | 3be3e4e5280b0803ae3a6a06467854b41afa0501 | /mainwindow.cpp | 2098761590eaa0f99c4c7b5f3a4ca476be2b67f0 | [] | no_license | AlexBeem/POV-Globe-1 | 01805a718313cd52473426a0459665585169f9e1 | 5de18f9e5e45e71916fc1fe977d98a167cd8d3c7 | refs/heads/master | 2021-09-23T17:39:18.363228 | 2018-09-25T20:41:31 | 2018-09-25T20:41:31 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,256 | cpp | #include "mainwindow.h"
#include "ui_mainwindow.h"
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
ui->stackedWidget->addWidget(&hPage);
setWindowTitle("POV Globe - login");
setupLayout();
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::on_startButton_clicked() //simple login function
{
QString pw = ui->lineEdit->text();
QString IP = ui->IPLineEdit->text();
QString IPGlobe = ui->ipGlobeLineEdit->text();
int x = ui->lineEditX->text().toInt();
int y = ui->lineEditY->text().toInt();
if(pw == "1234"){
ui->stackedWidget->setCurrentWidget(&hPage);
setWindowTitle("POV Globe - configurator");
} else {
ui->lineEdit->setText("wrong... try again");
}
hPage.setupUDP(IP);
hPage.setupLedUDP(IPGlobe);
hPage.setResolution(x,y);
}
void MainWindow::setupLayout()
{
QPixmap pixmap(":/icons/icons/staff-login.jpg");
QIcon myIcon(pixmap);
ui->startButton->setIcon(myIcon);
ui->startButton->setIconSize(QSize(200,45));
ui->startButton->setStyleSheet("border-radius: 11px; background-color: #00cc00; ");
ui->startButton->setText("");
}
| [
"stefangroenendijk1998@hotmail.com"
] | stefangroenendijk1998@hotmail.com |
0cfcc9a7621dda6ad8884c568497bde7edcc1bd1 | ffd6e7f0f3dc76e41c7784bebdd28973191900f2 | /USACO/lifeguards.cpp | c72c0b04fedd047f391ec66e60b038e819db5331 | [] | no_license | theopan8/competitive-programming | e12a1b2f8a00748d7170ec8c130c0bfdb605baa8 | c507102b204e09ccd037dd37e6e3677dae1bb89c | refs/heads/main | 2023-07-22T20:56:39.956584 | 2021-08-31T20:57:11 | 2021-08-31T20:57:11 | 387,005,395 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,404 | cpp | #include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <cstdio>
#include <utility>
#include <queue>
#include <math.h>
#include <set>
#include <bitset>
#include <cmath>
#include <bitset>
#include <cstring>
#include <limits>
using namespace std;
#define maxn 100010
#define maxk 110
#define pii pair<int,int>
//#define int long long
vector<pii> temp;
vector<pii> guards;
int dp[maxk][maxn];
int jump[maxn];
int n, k;
int main() {
freopen("lifeguards.in", "r", stdin);
freopen("lifeguards.out", "w", stdout);
ios_base::sync_with_stdio(0);
cin >> n >> k;
for(int i = 0; i < n; i++) {
int s, e; cin >> s >> e;
temp.push_back(pii(s,e));
}
sort(temp.begin(), temp.end());
int maxend = 0;
guards.push_back(pii(0, 0));
for(int i = 0; i < temp.size(); i++) {
if (temp[i].second > maxend) {
maxend = temp[i].second;
guards.push_back(temp[i]);
continue;
}
k--;
continue;
}
if (k <= 0) {
int last = 0;
int tot = 0;
for(pii i : guards) {
if (i.first >= last) tot += i.second - i.first;
else tot += i.second - last;
last = i.second;
}
cout << tot << endl;
return 0;
}
int idx = 0;
for(int i = 1; i < guards.size(); i++) {
while (idx + 1 < guards.size()) {
if (guards[idx + 1].second <= guards[i].first) idx++;
else break;
}
jump[i] = idx;
}
for(int i = 1; i <= k; i++) {
dp[i][0] = -1000000000;
}
for(int j = 1; j < guards.size(); j++) {
for(int i = 0; i <= min(j, k); i++) {
dp[i][j] = max(0, dp[max(0, i - 1)][j - 1]);
dp[i][j] = max(dp[i][j], dp[max(0, i - (j - jump[j] - 1))][jump[j]] + guards[j].second - guards[j].first);
if (jump[i] < j - 1) {
dp[i][j] = max(dp[i][j], dp[max(0, i - (j - jump[j] - 2))][jump[j] + 1] + guards[j].second - guards[jump[j] + 1].second);
}
}
for(int i = min(j - 1, k) + 1; i <= k; i++) {
dp[i][j] = -1000000000;
}
}
/*for(int i = 0; i < guards.size(); i++) {
for(int j = 0; j <= k; j++) {
cout << dp[j][i] << " ";
}
cout << endl;
}*/
cout << dp[k][guards.size() - 1] << endl;
} | [
"noreply@github.com"
] | theopan8.noreply@github.com |
3c99a729a848ecf09a93c026978c8babe583d80a | 384c999fc76e0bbeb2b2f01f0a800d3e357b2e2f | /src/talon_state_controller/include/talon_state_controller/talon_config_controller.h | 1919917f41fba7da12f58690a1c0b6862b639f51 | [] | no_license | MatthewWalstra/Swerve_ws | ba9129ea7458b3e2d38b2ad263ca34ebff87f8d4 | 26a50455fcdfbe1592e67fda357e6464fca9218d | refs/heads/master | 2022-12-09T21:29:00.438377 | 2020-06-28T20:47:42 | 2020-06-28T20:47:42 | 275,479,820 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,884 | h | ///////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2012, hiDOF INC.
//
// 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 hiDOF, 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.
//////////////////////////////////////////////////////////////////////////////
/*
* Original joint_state_controller Author: Wim Meeussen
*/
#pragma once
#include <controller_interface/controller.h>
#include <realtime_tools/realtime_publisher.h>
#include <talon_interface/talon_state_interface.h>
#include <talon_state_msgs/TalonConfig.h>
#include <ros/ros.h>
namespace talon_config_controller
{
/**
* \brief Controller that publishes the config of all talons in a robot.
*
* This controller publishes the config of all resources registered to a \c hardware_interface::TalonStateInterface to a
* topic of type \c sensor_msgs/TalonConfig. The following is a basic configuration of the controller.
*
* \code
* talon_config_controller:
* type: talon_config_controller/TalonConfigController
* publish_rate: 50
* \endcode
*
*/
class TalonConfigController: public controller_interface::Controller<hardware_interface::TalonStateInterface>
{
public:
TalonConfigController() : publish_rate_(0.0) {}
virtual bool init(hardware_interface::TalonStateInterface *hw,
ros::NodeHandle &root_nh,
ros::NodeHandle &controller_nh) override;
virtual void starting(const ros::Time &time) override;
virtual void update(const ros::Time &time, const ros::Duration & /*period*/) override;
virtual void stopping(const ros::Time & /*time*/) override;
private:
std::vector<hardware_interface::TalonStateHandle> talon_state_;
std::shared_ptr<realtime_tools::RealtimePublisher<talon_state_msgs::TalonConfig> > realtime_pub_;
ros::Time last_publish_time_;
double publish_rate_;
size_t num_hw_joints_; ///< Number of joints present in the TalonInterface
std::string limitSwitchSourceToString(const hardware_interface::LimitSwitchSource source) const;
std::string remoteLimitSwitchSourceToString(const hardware_interface::RemoteLimitSwitchSource source) const;
std::string limitSwitchNormalToString(const hardware_interface::LimitSwitchNormal normal) const;
std::string feedbackDeviceToString(const hardware_interface::FeedbackDevice feedback_device) const;
std::string remoteSensorSourceToString(const hardware_interface::RemoteSensorSource remote_sensor_source) const;
};
}
| [
"you@example.com"
] | you@example.com |
dbc33451f825635085b0b29aab845179593cc849 | 2e29f4158e2941eb2ddf128743545793b92581c5 | /33/using_frnd_func_add_two_complex_by_overloading_plus_operator/main.cpp | 0f301e80b85c9ffd7b8a7360a0664d3982c726c8 | [] | no_license | adamug/100_days_of_C_and_CPP_coding | de9ddb837f27e0a66d50d4a043be520e6439c90e | f824584a099f817dfe2f090979dc6f0deee57bcd | refs/heads/master | 2023-01-11T01:02:26.517577 | 2020-11-07T08:15:10 | 2020-11-07T08:15:10 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 676 | cpp | #include <iostream>
using namespace std;
class complex{
float real,imag;
public:
complex(){}
complex(float x,float y){
real=x;imag=y;
}
void display(void){
cout<<real<<" + j "<<imag<<"\n";
}
friend complex operator+(complex,complex);
};
complex operator+(complex c,complex c2){
complex temp;
temp.real=c2.real+c.real;
temp.imag=c2.imag+c.imag;
return temp;
}
int main()
{
complex c1,c2,c3;
c1 = complex(2.5,3.5);
c2 = complex(1.6,2.7);
c3 = c1 + c2;
cout<<"c1 = ";c1.display();
cout<<"c2 = ";c2.display();
cout<<"c3 = ";c3.display();
//cout << "Hello world!" << endl;
return 0;
}
| [
"aman.arju427742@gmail.com"
] | aman.arju427742@gmail.com |
c57cf08baae42a1fdc0a7d77276027001a5fbc0c | 265668bdec1f5f37c7f4345ef867ac0fe2eab921 | /c++ code/析构函数.cpp | 693557ead4a6e7babb3eb3efaa2991580d4f99e7 | [] | no_license | kongchenglc/C-and-C-code | 338751cda76721acc81c77b529386d92ad7de708 | 3b3774a2ed5a0ab3f849165e7be54bc2b6354cd1 | refs/heads/master | 2020-06-26T00:29:22.248690 | 2018-01-24T05:26:03 | 2018-01-24T05:26:03 | 96,998,094 | 1 | 0 | null | null | null | null | GB18030 | C++ | false | false | 713 | cpp | #include <iostream>
using namespace std;
class A {
public :int n;
A(int _n=10):n(_n) {
cout<<"A("<<n<<")构造\t";
}
~A(){
cout<<"A("<<n<<")析构\t";
}
};
class B {
public :int m;
B(int _n=20):m(_n),a(_n) {
cout<<"B("<<m<<")构造\t";
}
~B(){
cout<<"B("<<m<<")析构\t";
}
A a;
};
B *gp,gb(30);
void fun4()
{
static B b41(41);
B b42(42);
gp=new B(43);
}
void fun5()
{
static B b51(51);
B b52(52);
}
B fun6(B b61)
{
delete gp;
return b61;
}
int main(){
cout<<"\n------main start--------"<<endl;
fun4();cout<<"\n-------fun4 end-----"<<endl;
fun5();cout<<"\n-------fun5 end-----"<<endl;
B b71(71),b72(72);
b72=fun6(b71);
cout<<"\n-------main end----------"<<endl;
return 0;
}
| [
"kongchenglc@gmail.com"
] | kongchenglc@gmail.com |
259d37d09d42c5c7ed9701d8e67e72af429e4d21 | 54e053623f4c8ca9c483ee601fa2d6f9a5c503d2 | /bind/interface/ILuaApiT.h | 36d519b05bdc39e904ed95f2e1ed6db13bc2af8b | [
"MIT"
] | permissive | murisly/luaband | be95fafb6a4d509214a304735aaf78ee0a5d3a0a | 07a620b622916c272b1f61005b3d1d7c4c489242 | refs/heads/master | 2021-01-22T02:17:47.708786 | 2017-02-16T06:38:42 | 2017-02-16T06:38:42 | 81,042,553 | 6 | 0 | null | null | null | null | GB18030 | C++ | false | false | 4,326 | h | #pragma once
#include "ILuaApi.h"
#include "enginehelp/LuaVarint.h"
#include "memory/ref_counted.h"
template <class T>
struct _APIDISP_MAP_ENTRY
{
PCSTR pszName;
long (T::*pfn)(const binding::lua::DISP_PARAMS&, binding::lua::CLuaVariant&);
PCSTR pszArgFlags;
};
#define BEGIN_APIDISP_MAP(_class)\
static const _APIDISP_MAP_ENTRY<_class>* GetApiDispMap(SIZE_T& nCount)\
{\
static const _APIDISP_MAP_ENTRY<_class> dispmap[] = { { "", &DispDefault, NULL },
#define END_APIDISP_MAP() }; nCount = _countof(dispmap); return dispmap; };
#define APIDISP_ENTRY_EX(name, func, flags) { name, func, flags },
#define APIDISP_ENTRY_F(name, flags) APIDISP_ENTRY_EX(#name, &name, flags)
#define APIDISP_ENTRY(name) APIDISP_ENTRY_EX(#name, &name, NULL)
#define DECLARE_LUAFUNC(name) long name(const DISP_PARAMS& rDispParams,CLuaVariant& rVarResult);
// i - 整数,u - unsigned整数, s - 字符串, d - double, U - ILuaElementCollection, * - 任意
#define API_PARAM_NULL ""
#define API_PARAM_INT "i"
#define API_PARAM_UINT "u"
#define API_PARAM_BOOL "i"
#define API_PARAM_STRING "s"
#define API_PARAM_DOUBLE "d"
#define API_PARAM_ILUAELEMENTCOLLECTION "U"
#define API_PARAM_ANY "*"
//////////////////////////////////////////////////////////////////////////
// CApiDispTraits
class CApiDispTraits
{
public:
// 参数检查函数
// i - 整数,u - unsigned整数, s - 字符串, d - double, U - ILuaElementCollection, b - 二进制数组,* - 任意
static BOOL CheckDispParams(
const binding::lua::DISP_PARAMS& rDispParams,
PCSTR pszFlags)
{
if(pszFlags == NULL)
return TRUE;
PSTR p = (PSTR)pszFlags;
for(size_t i = 0; i < rDispParams.size(); ++i, ++p)
{
switch(*p)
{
case '*':
break;
case 'i':
case 'u':
break;
case 'd':
if(rDispParams[i].getType() != binding::lua::CLuaVariant::VAR_DOUBLE)
return FALSE;
break;
case 's':
if( rDispParams[i].getType() != binding::lua::CLuaVariant::VAR_WSTRING )
{
return FALSE;
}
break;
case 'U': // ILuaElementCollection
if( rDispParams[i].getType() != binding::lua::CLuaVariant::VAR_ILUAEC ||
rDispParams[i].getValue<binding::lua::ILuaElementCollection*>() == NULL )
{
return FALSE;
}
break;
case 'b':
if( rDispParams[i].getType() != binding::lua::CLuaVariant::VAR_BINARY )
{
return FALSE;
}
break;
default:
assert(FALSE && "CheckDispParams: 无效的参数标识");
case '\0':
return FALSE;
}
}
//如果最后面是"*"则通过验证,但是这种情况只有最后是"*"才可以
BOOL bOk = TRUE;
while(*p != '\0')
{
if (*p != '*')
{
bOk = FALSE;
break;
}
p++;
}
return bOk;
}
};
//////////////////////////////////////////////////////////////////////////
// CApiDispImplRootT
template <class T>
class __declspec(novtable) CApiDispImplRootT
:public binding::lua::ILuaApi
,public CApiDispTraits
,public binding::RefCountedImpl<T>
{
public:
static binding::lua::ILuaApi* GetInstance()
{
T* pImpl = new T;
pImpl->AddRef();
return pImpl;
}
virtual ~CApiDispImplRootT()
{
}
static const _APIDISP_MAP_ENTRY< CApiDispImplRootT<T> >* GetApiDispMap(SIZE_T& nCount)
{
nCount = 0;
return NULL;
}
long DispDefault(const binding::lua::DISP_PARAMS&, binding::lua::CLuaVariant&)
{
return E_FAIL;
}
public:
// ILuaApi
virtual void AddRef()
{
InternalAddRef();
}
virtual void Release()
{
InternalRelease();
}
virtual long Invoke(binding::lua::DISP_ID dispIdMember,const binding::lua::DISP_PARAMS& rDispParams,binding::lua::CLuaVariant& rVarResult)
{
SIZE_T nCount = 0;
const _APIDISP_MAP_ENTRY<T>* pApiMap = T::GetApiDispMap(nCount);
if(dispIdMember < 0 || dispIdMember >= (binding::lua::DISP_ID)nCount)
{
return DISP_E_MEMBERNOTFOUND;
}
if(!CheckDispParams(rDispParams, pApiMap[dispIdMember].pszArgFlags))
{
return DISP_E_TYPEMISMATCH;
}
T* pThis = (T*)this;
return (pThis->*pApiMap[dispIdMember].pfn)(
rDispParams,
rVarResult);
}
virtual long GetDispTable(DispTable& table)
{
SIZE_T nCount = 0;
const _APIDISP_MAP_ENTRY<T>* pApiMap = T::GetApiDispMap(nCount);
for(SIZE_T index = 1 ; index < nCount ; index++)
{
table.insert(DispTable::value_type(index,pApiMap[index].pszName));
}
return 0;
}
}; | [
"murisly2015@gmail.com"
] | murisly2015@gmail.com |
d55ea2fd70832927306169fcbf4912e1052fd893 | 22cebbf3ddc30ca86c6b54014ff6344432ca608a | /include/3dim/graph/osg/CModelDragger3D.h | f0d529080958d7205476aa171ae056a227c06cef | [
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | nneerr123/3dimviewer | fd35b79f619f657fd52fe1d18a78c08d9841fb27 | e23a3147edc35034ef4b75eae9ccdcbc7192b1a1 | refs/heads/master | 2022-04-08T22:41:10.162793 | 2020-03-03T08:32:14 | 2020-03-03T08:32:14 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 11,555 | h | ///////////////////////////////////////////////////////////////////////////////
// $Id$
//
// 3DimViewer
// Lightweight 3D DICOM viewer.
//
// Copyright 2008-2016 3Dim Laboratory s.r.o.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
///////////////////////////////////////////////////////////////////////////////
#ifndef CMODELDRAGGER3D_H
#define CMODELDRAGGER3D_H
#include <data/CModel.h>
#include <osg/CSceneOSG.h>
#include <osg/CActiveObjectBase.h>
#include <osgGA/GUIEventHandler>
#include <osg/Node>
#include <osgUtil/LineSegmentIntersector>
#include <osg/CSprite.h>
#include <osg/CRotate2DDragger.h>
#include <osg/CTranslate1DDragger.h>
#include <osg/CTranslate2DDragger.h>
#include <osg/CGeometryGenerator.h>
#include <osg/CCylinderDragger.h>
#include <osg/CIntersectionProspector.h>
namespace osg
{
class CFreeModelVisualizer;
}
///////////////////////////////////////////////////////////////////////////////
namespace osgManipulator
{
///////////////////////////////////////////////////////////////////////////////
// CModel3DRotationDragger - rotation
class CModel3DRotationDragger : public CompositeDragger
{
public:
//! Constructor
CModel3DRotationDragger();
/** Setup default geometry for dragger. */
void setupDefaultGeometry();
//! Set ring radius
void setRadius(float r1, float r2);
//! Update
virtual void updateGeometry();
//! Get x axis dragger node reference
CCylinderDragger & getXDragger() { return *m_rxDragger; }
//! Get x axis dragger node reference
CCylinderDragger & getYDragger() { return *m_ryDragger; }
//! Get x axis dragger node reference
CCylinderDragger & getZDragger() { return *m_rzDragger; }
protected:
//! Destructor
// Rotation draggers
osg::ref_ptr<CCylinderDragger> m_rxDragger;
osg::ref_ptr<CCylinderDragger> m_ryDragger;
osg::ref_ptr<CCylinderDragger> m_rzDragger;
//! Geometry
osg::ref_ptr< osg::CDonutGeometry > m_ring;
osg::ref_ptr< osg::CDonutGeometry > m_invisibleRing;
}; // CModel3DRotationDragger
///////////////////////////////////////////////////////////////////////////////
// CModel3DTranslationDragger - movement along axis
class CModel3DTranslationDragger : public osgManipulator::CTranslate1DDragger
{
public:
//! Constructor.
CModel3DTranslationDragger();
//! Set translation line constructor
CModel3DTranslationDragger(const osg::Vec3& s, const osg::Vec3& e);
//! Setup default geometry for dragger.
virtual void setupDefaultGeometry();
//! Set sizes
virtual void setOffset(float offset_head, float offset_tail);
//! Set scale
virtual void setScale(float scale);
//! Update changed geometry.
virtual void updateGeometry();
protected:
//! Arrows
osg::ref_ptr<osg::CArrow3DGeometry> m_arrow;
//! Shifting transforms
osg::ref_ptr<osg::MatrixTransform> m_shiftHead, m_shiftTail;
//! Scaling transforms
osg::ref_ptr<osg::MatrixTransform> m_scaleHead, m_scaleTail;
};
///////////////////////////////////////////////////////////////////////////////
// CModel3DViewPlaneDragger - movement along plane
class CModel3DViewPlaneDragger : public osgManipulator::CTranslate2DDragger, public osgManipulator::IHoverDragger
{
public:
//! Constructor
CModel3DViewPlaneDragger(geometry::CMesh* pMesh, osg::Matrix modelPos);
//! Setup default geometry for dragger.
virtual void setupDefaultGeometry();
//! Update geometry
virtual void updateGeometry();
virtual void accept(osg::NodeVisitor& nv);
void updateModelMatrix(const osg::Matrix &modelPos);
//! Update
void updateModel(int storageID);
//! Set sphere radius
void setRadius(float radius);
void onMouseEnter() override;
void onMouseLeave() override;
protected:
//! Revert plane rotation given by matrix transformations
virtual void revertTransformsOnPlane();
protected:
//! geometry
osg::CFreeModelVisualizer* m_pVisualizer;
//! pointer to moved object mesh (so the object itself can be draggable)
geometry::CMesh* m_pMesh;
//! Shifting transforms
osg::ref_ptr<osg::MatrixTransform> m_shift;
//! Nodepath matrix
osg::Matrix m_nodepath_matrix;
//! View matrix
osg::Matrix m_view_matrix;
//! Sphere geometry
osg::ref_ptr<osg::CSphereGeometry> m_sphere;
};
} // namespace osgManipulator
///////////////////////////////////////////////////////////////////////////////
// Model manipulator
namespace osg
{
////////////////////////////////////////////////////////////////////////////////////////////////////
//!\brief 3D pivot dragger holder.
////////////////////////////////////////////////////////////////////////////////////////////////////
class CPivotDraggerHolder : public osgManipulator::CompositeDragger, data::CGeneralObjectObserver<CPivotDraggerHolder>, public CActiveObjectBase
{
private:
osg::ref_ptr<osgManipulator::CModel3DTranslationDragger> m_translationXDragger;
osg::ref_ptr<osgManipulator::CModel3DTranslationDragger> m_translationYDragger;
osg::ref_ptr<osgManipulator::CModel3DTranslationDragger> m_translationZDragger;
public:
CPivotDraggerHolder();
~CPivotDraggerHolder();
//! Handle dragger move
virtual bool handle(const osgManipulator::PointerInfo &pi, const osgGA::GUIEventAdapter &ea, osgGA::GUIActionAdapter &aa);
void onMouseEnter(const osgGA::GUIEventAdapter& ea, bool command_mode) override;
void onMouseExit(const osgGA::GUIEventAdapter& ea, bool command_mode) override;
//! Sets sizes of translation draggers
void setOffset(float offset);
void setScale(float scale);
//! Prepare materials
void prepareMaterials();
//!
virtual void objectChanged(data::CStorageEntry *pEntry, const data::CChangedEntries &changes);
//! Pivot observer method
void sigPivotChanged(data::CStorageEntry *pEntry, const data::CChangedEntries &changes);
};
////////////////////////////////////////////////////////////////////////////////////////////////////
//!\brief Base class for model dragger holders.
////////////////////////////////////////////////////////////////////////////////////////////////////
class CModelDraggerHolder : public osgManipulator::CompositeDragger, public data::CGeneralObjectObserver<CModelDraggerHolder>
{
public:
//! Constructor
CModelDraggerHolder(int idModel, bool signalDraggerMove, bool signalDraggerMoveSetMatrix);
//! Destructor
~CModelDraggerHolder();
//! For extern update of model matrix
virtual void updateModelMatrix(const osg::Matrix &modelPos) { }
//! Set ID of current handled model
void setModelID(int id, bool setPivot);
//! Get ID of current handled model
int getModelID() const { return m_idModel; }
//! Handle dragger move
virtual bool handle(const osgManipulator::PointerInfo &pi, const osgGA::GUIEventAdapter &ea, osgGA::GUIActionAdapter &aa);
protected:
//! Prepare materials
virtual void prepareMaterials() { }
//! Model observer method
virtual void objectChanged(data::CStorageEntry *pEntry, const data::CChangedEntries &changes);
void sigModelChanged(data::CStorageEntry *pEntry, const data::CChangedEntries &changes);
void sigPivotChanged(data::CStorageEntry *pEntry, const data::CChangedEntries &changes);
virtual void internalModelChanged(data::CStorageEntry *pEntry, const data::CChangedEntries &changes);
virtual void internalPivotChanged(data::CStorageEntry *pEntry, const data::CChangedEntries &changes);
protected:
//! Flag if pivot should be set to model's position
bool m_bSetPivot;
//! Flags for signalling DraggerMove
bool m_bSignalDraggerMove;
bool m_bSignalDraggerMoveSetMatrix;
//! Associated model ID
int m_idModel;
};
////////////////////////////////////////////////////////////////////////////////////////////////////
//!\brief 3D model dragger holder.
////////////////////////////////////////////////////////////////////////////////////////////////////
class C3DModelDraggerHolder : public CModelDraggerHolder, public CActiveObjectBase
{
public:
//! Constructor for use in scan appliance alignment dialog
C3DModelDraggerHolder(CFreeModelVisualizer* pVisualizer, const osg::Matrix &modelPos, const osg::Vec3& sceneSize, bool signalDraggerMove, bool signalDraggerMoveSetMatrix);
//! Constructor for use in main 3D window
C3DModelDraggerHolder(int modelID, const osg::Matrix &modelPos, const osg::Vec3& sceneSize, bool signalDraggerMove, bool signalDraggerMoveSetMatrix);
//! Destructor
~C3DModelDraggerHolder();
//! For extern update of model matrix
virtual void updateModelMatrix(const osg::Matrix &modelPos);
//! Sets pivot dragger
void setPivotDragger(CPivotDraggerHolder *pivotDragger);
void updatePivotDraggerMatrix();
//! Handle dragger move
virtual bool handle(const osgManipulator::PointerInfo &pi, const osgGA::GUIEventAdapter &ea, osgGA::GUIActionAdapter &aa);
void onMouseEnter(const osgGA::GUIEventAdapter& ea, bool command_mode) override;
void onMouseExit(const osgGA::GUIEventAdapter& ea, bool command_mode) override;
protected:
//! Prepare materials
virtual void prepareMaterials();
//! Model observer method
virtual void internalModelChanged(data::CStorageEntry *pEntry, const data::CChangedEntries &changes);
virtual void internalPivotChanged(data::CStorageEntry *pEntry, const data::CChangedEntries &changes);
protected:
//! Pivot dragger
osg::ref_ptr<osg::CPivotDraggerHolder> m_pivot_dragger;
double m_pivot_dragger_offset;
double m_pivot_dragger_scale;
geometry::CMesh::Point m_bbMin, m_bbMax;
//! Trackball dragger
osg::ref_ptr<osgManipulator::CModel3DRotationDragger> m_rotation_dragger;
//! Translation draggers
osg::ref_ptr<osgManipulator::CModel3DTranslationDragger> m_x_translate_dragger;
osg::ref_ptr<osgManipulator::CModel3DTranslationDragger> m_y_translate_dragger;
osg::ref_ptr<osgManipulator::CModel3DTranslationDragger> m_z_translate_dragger;
//! Translation draggers
osg::ref_ptr<osgManipulator::CModel3DViewPlaneDragger> m_translate_dragger;
};
} // namespace osg
#endif // CMODELDRAGGER3D_H | [
"stanek@3dim-laboratory.cz"
] | stanek@3dim-laboratory.cz |
cc4898a958b7f742f14b10856dd132eb858237c3 | 29588978cf19800f7dd7e4acdcb24e04e37adfba | /tests/test_get.cpp | d8ce18c190bc5c0d20474048e0ae61689d77666d | [
"MIT"
] | permissive | kurtsansom/toml11 | 4550efa48e8ef8d5b23b49c4e89a61caa4577bba | aa6fd03ce7588cffb4abd222f9946d32e3235910 | refs/heads/master | 2020-08-15T15:17:48.077930 | 2019-11-08T15:24:54 | 2019-11-08T15:24:54 | 215,362,438 | 0 | 1 | MIT | 2019-11-08T15:24:56 | 2019-10-15T17:53:49 | null | UTF-8 | C++ | false | false | 17,842 | cpp | #define BOOST_TEST_MODULE "test_get"
#ifdef UNITTEST_FRAMEWORK_LIBRARY_EXIST
#include <boost/test/unit_test.hpp>
#else
#define BOOST_TEST_NO_LIB
#include <boost/test/included/unit_test.hpp>
#endif
#include <toml.hpp>
#include <map>
#include <unordered_map>
#include <list>
#include <deque>
#include <array>
#include <tuple>
#if __cplusplus >= 201703L
#include <string_view>
#endif
using test_value_types = std::tuple<
toml::value,
toml::basic_value<toml::preserve_comments>,
toml::basic_value<toml::discard_comments, std::map, std::deque>,
toml::basic_value<toml::preserve_comments, std::map, std::deque>
>;
BOOST_AUTO_TEST_CASE_TEMPLATE(test_get_exact, value_type, test_value_types)
{
{
value_type v(true);
BOOST_TEST(true == toml::get<toml::boolean>(v));
toml::get<toml::boolean>(v) = false;
BOOST_TEST(false == toml::get<toml::boolean>(v));
toml::boolean x = toml::get<toml::boolean>(std::move(v));
BOOST_TEST(false == x);
}
{
value_type v(42);
BOOST_TEST(toml::integer(42) == toml::get<toml::integer>(v));
toml::get<toml::integer>(v) = 54;
BOOST_TEST(toml::integer(54) == toml::get<toml::integer>(v));
toml::integer x = toml::get<toml::integer>(std::move(v));
BOOST_TEST(toml::integer(54) == x);
}
{
value_type v(3.14);
BOOST_TEST(toml::floating(3.14) == toml::get<toml::floating>(v));
toml::get<toml::floating>(v) = 2.71;
BOOST_TEST(toml::floating(2.71) == toml::get<toml::floating>(v));
toml::floating x = toml::get<toml::floating>(std::move(v));
BOOST_TEST(toml::floating(2.71) == x);
}
{
value_type v("foo");
BOOST_TEST(toml::string("foo", toml::string_t::basic) ==
toml::get<toml::string>(v));
toml::get<toml::string>(v).str += "bar";
BOOST_TEST(toml::string("foobar", toml::string_t::basic) ==
toml::get<toml::string>(v));
toml::string x = toml::get<toml::string>(std::move(v));
BOOST_TEST(toml::string("foobar") == x);
}
{
value_type v("foo", toml::string_t::literal);
BOOST_TEST(toml::string("foo", toml::string_t::literal) ==
toml::get<toml::string>(v));
toml::get<toml::string>(v).str += "bar";
BOOST_TEST(toml::string("foobar", toml::string_t::literal) ==
toml::get<toml::string>(v));
toml::string x = toml::get<toml::string>(std::move(v));
BOOST_TEST(toml::string("foobar", toml::string_t::literal) == x);
}
{
toml::local_date d(2018, toml::month_t::Apr, 22);
value_type v(d);
BOOST_TEST(d == toml::get<toml::local_date>(v));
toml::get<toml::local_date>(v).year = 2017;
d.year = 2017;
BOOST_TEST(d == toml::get<toml::local_date>(v));
toml::local_date x = toml::get<toml::local_date>(std::move(v));
BOOST_TEST(d == x);
}
{
toml::local_time t(12, 30, 45);
value_type v(t);
BOOST_TEST(t == toml::get<toml::local_time>(v));
toml::get<toml::local_time>(v).hour = 9;
t.hour = 9;
BOOST_TEST(t == toml::get<toml::local_time>(v));
toml::local_time x = toml::get<toml::local_time>(std::move(v));
BOOST_TEST(t == x);
}
{
toml::local_datetime dt(toml::local_date(2018, toml::month_t::Apr, 22),
toml::local_time(12, 30, 45));
value_type v(dt);
BOOST_TEST(dt == toml::get<toml::local_datetime>(v));
toml::get<toml::local_datetime>(v).date.year = 2017;
dt.date.year = 2017;
BOOST_TEST(dt == toml::get<toml::local_datetime>(v));
toml::local_datetime x = toml::get<toml::local_datetime>(std::move(v));
BOOST_TEST(dt == x);
}
{
toml::offset_datetime dt(toml::local_datetime(
toml::local_date(2018, toml::month_t::Apr, 22),
toml::local_time(12, 30, 45)), toml::time_offset(9, 0));
value_type v(dt);
BOOST_TEST(dt == toml::get<toml::offset_datetime>(v));
toml::get<toml::offset_datetime>(v).date.year = 2017;
dt.date.year = 2017;
BOOST_TEST(dt == toml::get<toml::offset_datetime>(v));
toml::offset_datetime x = toml::get<toml::offset_datetime>(std::move(v));
BOOST_TEST(dt == x);
}
{
using array_type = typename value_type::array_type;
array_type vec;
vec.push_back(value_type(42));
vec.push_back(value_type(54));
value_type v(vec);
BOOST_TEST(vec == toml::get<array_type>(v));
toml::get<array_type>(v).push_back(value_type(123));
vec.push_back(value_type(123));
BOOST_TEST(vec == toml::get<array_type>(v));
array_type x = toml::get<array_type>(std::move(v));
BOOST_TEST(vec == x);
}
{
using table_type = typename value_type::table_type;
table_type tab;
tab["key1"] = value_type(42);
tab["key2"] = value_type(3.14);
value_type v(tab);
BOOST_TEST(tab == toml::get<table_type>(v));
toml::get<table_type>(v)["key3"] = value_type(123);
tab["key3"] = value_type(123);
BOOST_TEST(tab == toml::get<table_type>(v));
table_type x = toml::get<table_type>(std::move(v));
BOOST_TEST(tab == x);
}
{
value_type v1(42);
BOOST_TEST(v1 == toml::get<value_type>(v1));
value_type v2(54);
toml::get<value_type>(v1) = v2;
BOOST_TEST(v2 == toml::get<value_type>(v1));
value_type x = toml::get<value_type>(std::move(v1));
BOOST_TEST(v2 == x);
}
}
BOOST_AUTO_TEST_CASE_TEMPLATE(test_get_integer_type, value_type, test_value_types)
{
{
value_type v(42);
BOOST_TEST(int(42) == toml::get<int >(v));
BOOST_TEST(short(42) == toml::get<short >(v));
BOOST_TEST(char(42) == toml::get<char >(v));
BOOST_TEST(unsigned(42) == toml::get<unsigned >(v));
BOOST_TEST(long(42) == toml::get<long >(v));
BOOST_TEST(std::int64_t(42) == toml::get<std::int64_t >(v));
BOOST_TEST(std::uint64_t(42) == toml::get<std::uint64_t>(v));
BOOST_TEST(std::int16_t(42) == toml::get<std::int16_t >(v));
BOOST_TEST(std::uint16_t(42) == toml::get<std::uint16_t>(v));
BOOST_TEST(std::uint16_t(42) == toml::get<std::uint16_t>(std::move(v)));
}
}
BOOST_AUTO_TEST_CASE_TEMPLATE(test_get_floating_type, value_type, test_value_types)
{
{
value_type v(3.14);
BOOST_TEST(static_cast<float >(3.14) == toml::get<float >(v));
BOOST_TEST(static_cast<double >(3.14) == toml::get<double >(v));
BOOST_TEST(static_cast<long double>(3.14) == toml::get<long double>(v));
BOOST_TEST(3.14f == toml::get<float>(std::move(v)));
}
}
BOOST_AUTO_TEST_CASE_TEMPLATE(test_get_string_type, value_type, test_value_types)
{
{
value_type v("foo", toml::string_t::basic);
BOOST_TEST("foo" == toml::get<std::string>(v));
toml::get<std::string>(v) += "bar";
BOOST_TEST("foobar" == toml::get<std::string>(v));
const auto x = toml::get<std::string>(std::move(v));
BOOST_TEST("foobar" == x);
}
{
value_type v("foo", toml::string_t::literal);
BOOST_TEST("foo" == toml::get<std::string>(v));
toml::get<std::string>(v) += "bar";
BOOST_TEST("foobar" == toml::get<std::string>(v));
const auto x = toml::get<std::string>(std::move(v));
BOOST_TEST("foobar" == x);
}
#if __cplusplus >= 201703L
{
value_type v("foo", toml::string_t::basic);
BOOST_TEST("foo" == toml::get<std::string_view>(v));
}
{
value_type v("foo", toml::string_t::literal);
BOOST_TEST("foo" == toml::get<std::string_view>(v));
}
#endif
}
BOOST_AUTO_TEST_CASE_TEMPLATE(test_get_toml_array, value_type, test_value_types)
{
{
const value_type v{42, 54, 69, 72};
const std::vector<int> vec = toml::get<std::vector<int>>(v);
const std::list<short> lst = toml::get<std::list<short>>(v);
const std::deque<std::int64_t> deq = toml::get<std::deque<std::int64_t>>(v);
BOOST_TEST(42 == vec.at(0));
BOOST_TEST(54 == vec.at(1));
BOOST_TEST(69 == vec.at(2));
BOOST_TEST(72 == vec.at(3));
std::list<short>::const_iterator iter = lst.begin();
BOOST_TEST(static_cast<short>(42) == *(iter++));
BOOST_TEST(static_cast<short>(54) == *(iter++));
BOOST_TEST(static_cast<short>(69) == *(iter++));
BOOST_TEST(static_cast<short>(72) == *(iter++));
BOOST_TEST(static_cast<std::int64_t>(42) == deq.at(0));
BOOST_TEST(static_cast<std::int64_t>(54) == deq.at(1));
BOOST_TEST(static_cast<std::int64_t>(69) == deq.at(2));
BOOST_TEST(static_cast<std::int64_t>(72) == deq.at(3));
std::array<int, 4> ary = toml::get<std::array<int, 4>>(v);
BOOST_TEST(static_cast<int>(42) == ary.at(0));
BOOST_TEST(static_cast<int>(54) == ary.at(1));
BOOST_TEST(static_cast<int>(69) == ary.at(2));
BOOST_TEST(static_cast<int>(72) == ary.at(3));
std::tuple<int, short, unsigned, long> tpl =
toml::get<std::tuple<int, short, unsigned, long>>(v);
BOOST_TEST(static_cast<int >(42) == std::get<0>(tpl));
BOOST_TEST(static_cast<short >(54) == std::get<1>(tpl));
BOOST_TEST(static_cast<unsigned>(69) == std::get<2>(tpl));
BOOST_TEST(static_cast<long >(72) == std::get<3>(tpl));
const value_type p{3.14, 2.71};
std::pair<double, double> pr = toml::get<std::pair<double, double> >(p);
BOOST_TEST(3.14 == pr.first);
BOOST_TEST(2.71 == pr.second);
}
{
value_type v{42, 54, 69, 72};
const std::vector<int> vec = toml::get<std::vector<int>>(std::move(v));
BOOST_TEST(42 == vec.at(0));
BOOST_TEST(54 == vec.at(1));
BOOST_TEST(69 == vec.at(2));
BOOST_TEST(72 == vec.at(3));
}
{
value_type v{42, 54, 69, 72};
const std::deque<int> deq = toml::get<std::deque<int>>(std::move(v));
BOOST_TEST(42 == deq.at(0));
BOOST_TEST(54 == deq.at(1));
BOOST_TEST(69 == deq.at(2));
BOOST_TEST(72 == deq.at(3));
}
{
value_type v{42, 54, 69, 72};
const std::list<int> lst = toml::get<std::list<int>>(std::move(v));
std::list<int>::const_iterator iter = lst.begin();
BOOST_TEST(42 == *(iter++));
BOOST_TEST(54 == *(iter++));
BOOST_TEST(69 == *(iter++));
BOOST_TEST(72 == *(iter++));
}
{
value_type v{42, 54, 69, 72};
std::array<int, 4> ary = toml::get<std::array<int, 4>>(std::move(v));
BOOST_TEST(static_cast<int>(42) == ary.at(0));
BOOST_TEST(static_cast<int>(54) == ary.at(1));
BOOST_TEST(static_cast<int>(69) == ary.at(2));
BOOST_TEST(static_cast<int>(72) == ary.at(3));
}
{
value_type v{42, 54, 69, 72};
std::tuple<int, short, unsigned, long> tpl =
toml::get<std::tuple<int, short, unsigned, long>>(std::move(v));
BOOST_TEST(static_cast<int >(42) == std::get<0>(tpl));
BOOST_TEST(static_cast<short >(54) == std::get<1>(tpl));
BOOST_TEST(static_cast<unsigned>(69) == std::get<2>(tpl));
BOOST_TEST(static_cast<long >(72) == std::get<3>(tpl));
}
}
BOOST_AUTO_TEST_CASE_TEMPLATE(test_get_toml_array_of_array, value_type, test_value_types)
{
{
const value_type v1{42, 54, 69, 72};
const value_type v2{"foo", "bar", "baz"};
const value_type v{v1, v2};
std::pair<std::vector<int>, std::vector<std::string>> p =
toml::get<std::pair<std::vector<int>, std::vector<std::string>>>(v);
BOOST_TEST(p.first.size() == 4u);
BOOST_TEST(p.first.at(0) == 42);
BOOST_TEST(p.first.at(1) == 54);
BOOST_TEST(p.first.at(2) == 69);
BOOST_TEST(p.first.at(3) == 72);
BOOST_TEST(p.second.size() == 3u);
BOOST_TEST(p.second.at(0) == "foo");
BOOST_TEST(p.second.at(1) == "bar");
BOOST_TEST(p.second.at(2) == "baz");
std::tuple<std::vector<int>, std::vector<std::string>> t =
toml::get<std::tuple<std::vector<int>, std::vector<std::string>>>(v);
BOOST_TEST(std::get<0>(t).at(0) == 42);
BOOST_TEST(std::get<0>(t).at(1) == 54);
BOOST_TEST(std::get<0>(t).at(2) == 69);
BOOST_TEST(std::get<0>(t).at(3) == 72);
BOOST_TEST(std::get<1>(t).at(0) == "foo");
BOOST_TEST(std::get<1>(t).at(1) == "bar");
BOOST_TEST(std::get<1>(t).at(2) == "baz");
}
{
const value_type v1{42, 54, 69, 72};
const value_type v2{"foo", "bar", "baz"};
value_type v{v1, v2};
std::pair<std::vector<int>, std::vector<std::string>> p =
toml::get<std::pair<std::vector<int>, std::vector<std::string>>>(std::move(v));
BOOST_TEST(p.first.size() == 4u);
BOOST_TEST(p.first.at(0) == 42);
BOOST_TEST(p.first.at(1) == 54);
BOOST_TEST(p.first.at(2) == 69);
BOOST_TEST(p.first.at(3) == 72);
BOOST_TEST(p.second.size() == 3u);
BOOST_TEST(p.second.at(0) == "foo");
BOOST_TEST(p.second.at(1) == "bar");
BOOST_TEST(p.second.at(2) == "baz");
}
}
BOOST_AUTO_TEST_CASE_TEMPLATE(test_get_toml_table, value_type, test_value_types)
{
{
const value_type v1{
{"key1", 1},
{"key2", 2},
{"key3", 3},
{"key4", 4}
};
const auto v = toml::get<std::map<std::string, int>>(v1);
BOOST_TEST(v.at("key1") == 1);
BOOST_TEST(v.at("key2") == 2);
BOOST_TEST(v.at("key3") == 3);
BOOST_TEST(v.at("key4") == 4);
}
{
value_type v1{
{"key1", 1},
{"key2", 2},
{"key3", 3},
{"key4", 4}
};
const auto v = toml::get<std::map<std::string, int>>(std::move(v1));
BOOST_TEST(v.at("key1") == 1);
BOOST_TEST(v.at("key2") == 2);
BOOST_TEST(v.at("key3") == 3);
BOOST_TEST(v.at("key4") == 4);
}
}
BOOST_AUTO_TEST_CASE_TEMPLATE(test_get_toml_local_date, value_type, test_value_types)
{
value_type v1(toml::local_date{2018, toml::month_t::Apr, 1});
const auto date = std::chrono::system_clock::to_time_t(
toml::get<std::chrono::system_clock::time_point>(v1));
std::tm t;
t.tm_year = 2018 - 1900;
t.tm_mon = 4 - 1;
t.tm_mday = 1;
t.tm_hour = 0;
t.tm_min = 0;
t.tm_sec = 0;
t.tm_isdst = -1;
const auto c = std::mktime(&t);
BOOST_TEST(c == date);
}
BOOST_AUTO_TEST_CASE_TEMPLATE(test_get_toml_local_time, value_type, test_value_types)
{
value_type v1(toml::local_time{12, 30, 45});
const auto time = toml::get<std::chrono::seconds>(v1);
const bool result = time == std::chrono::hours(12) +
std::chrono::minutes(30) +
std::chrono::seconds(45);
BOOST_TEST(result);
}
BOOST_AUTO_TEST_CASE_TEMPLATE(test_get_toml_local_datetime, value_type, test_value_types)
{
value_type v1(toml::local_datetime(
toml::local_date{2018, toml::month_t::Apr, 1},
toml::local_time{12, 30, 45}));
const auto date = std::chrono::system_clock::to_time_t(
toml::get<std::chrono::system_clock::time_point>(v1));
std::tm t;
t.tm_year = 2018 - 1900;
t.tm_mon = 4 - 1;
t.tm_mday = 1;
t.tm_hour = 12;
t.tm_min = 30;
t.tm_sec = 45;
t.tm_isdst = -1;
const auto c = std::mktime(&t);
BOOST_TEST(c == date);
}
BOOST_AUTO_TEST_CASE_TEMPLATE(test_get_toml_offset_datetime, value_type, test_value_types)
{
{
value_type v1(toml::offset_datetime(
toml::local_date{2018, toml::month_t::Apr, 1},
toml::local_time{12, 30, 0},
toml::time_offset{9, 0}));
// 2018-04-01T12:30:00+09:00
// == 2018-04-01T03:30:00Z
const auto date = toml::get<std::chrono::system_clock::time_point>(v1);
const auto timet = std::chrono::system_clock::to_time_t(date);
// get time_t as gmtime (2018-04-01T03:30:00Z)
const auto tmp = std::gmtime(std::addressof(timet)); // XXX not threadsafe!
BOOST_TEST(tmp);
const auto tm = *tmp;
BOOST_TEST(tm.tm_year + 1900 == 2018);
BOOST_TEST(tm.tm_mon + 1 == 4);
BOOST_TEST(tm.tm_mday == 1);
BOOST_TEST(tm.tm_hour == 3);
BOOST_TEST(tm.tm_min == 30);
BOOST_TEST(tm.tm_sec == 0);
}
{
value_type v1(toml::offset_datetime(
toml::local_date{2018, toml::month_t::Apr, 1},
toml::local_time{12, 30, 0},
toml::time_offset{-8, 0}));
// 2018-04-01T12:30:00-08:00
// == 2018-04-01T20:30:00Z
const auto date = toml::get<std::chrono::system_clock::time_point>(v1);
const auto timet = std::chrono::system_clock::to_time_t(date);
// get time_t as gmtime (2018-04-01T03:30:00Z)
const auto tmp = std::gmtime(std::addressof(timet)); // XXX not threadsafe!
BOOST_TEST(tmp);
const auto tm = *tmp;
BOOST_TEST(tm.tm_year + 1900 == 2018);
BOOST_TEST(tm.tm_mon + 1 == 4);
BOOST_TEST(tm.tm_mday == 1);
BOOST_TEST(tm.tm_hour == 20);
BOOST_TEST(tm.tm_min == 30);
BOOST_TEST(tm.tm_sec == 0);
}
}
| [
"niina.toru.68u@gmail.com"
] | niina.toru.68u@gmail.com |
e94d746a91983ab48754664de1dead904909b88c | d771c4e4c4d2b4a4925afe235aac8cb7efdd12b4 | /main.cpp | 819a3e9b1d35e77ece016ddfb56b9e7d6ff8a967 | [] | no_license | objektowe123/cw-2 | 77eb164656e46a55a2f31d5ddf80a540bba612e6 | fda9a47a2b0d5c979099c1727c762bdbb7902a31 | refs/heads/master | 2021-07-08T12:23:44.809212 | 2017-10-03T19:23:41 | 2017-10-03T19:23:41 | 105,558,047 | 0 | 0 | null | null | null | null | WINDOWS-1250 | C++ | false | false | 955 | cpp | #include <iostream>
#include <cstdlib>
#include <windows.h>
using namespace std;
void gotoxy( int column, int line )
{
COORD coord;
coord.X = column;
coord.Y = line;
SetConsoleCursorPosition(
GetStdHandle( STD_OUTPUT_HANDLE ),
coord
);
}
int main()
{
int wiersz=1;
int x= 40;
int y =1;
int wiersze=10;
cout<<"Podaj liczbe wierszy: ";
cin>>wiersze;
cout<<endl;
if(wiersze<10)
{
gotoxy(3,3);
cout<<"Mala choinka"<<endl;
}
if(wiersze>10)
{
gotoxy(3,3);
cout<<"Duza choinka"<<endl;
}
wiersze=wiersze-1;
gotoxy(x,y);
for( int i = 0; i < wiersz; ++i )
{
cout<<"*";
}
for(int i=0;i<wiersze;i++)
{
wiersz=wiersz+1; // zmniejszyłem wartość zwiekszania się ilości znaków w każdym wierszu
x=x-1;
y=y+1;
gotoxy(x,y);
for( int i = 0; i < wiersz; ++i )
{
cout<<"* "; // dodałem drukowanie spacji po kazdej gwiazdce
}
}
}
| [
"przemek19961996@o2.pl"
] | przemek19961996@o2.pl |
c80b8f15aa396b756caf8e18f7d8d2d6fbf2bbfd | 840877399be53611e086f898c37d6b2179b8248f | /proj7/tester.cpp | d6153f2498f4449523f14c32306a9bae895d9f7a | [] | no_license | BryceAllen613/112 | e1fdb9e7943b177aea9a35f0f5c5196116d1acb0 | ecb04b3482a6dc88221910395c0de27840bd29d9 | refs/heads/master | 2020-08-16T23:44:12.518871 | 2019-10-16T14:51:05 | 2019-10-16T14:51:05 | 215,572,940 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 694 | cpp | /* tester.cpp is a "driver" to run the tests in the StackTester class.
* Joel Adams, for CS 112 at Calvin College.
*/
#include "StackTester.h"
#include "ReversePoemTester.h"
#include "ReversePoem.h"
#include <iostream>
using namespace std;
int main() {
StackTester st;
st.runTests();
ReversePoemTester rpt;
rpt.runTests();
//while (in != q)
cout << "enter the name of a poem:" <<endl;
string in;
cin>> in;
ReversePoem rp(in);
cout << "\n" << endl;
cout << rp.getTitle() << endl;
cout << rp.getAuthor() << endl;
cout << "\n*** Top-To-Bottom ***\n" << endl;
cout << rp.getBody() << endl;
cout << "\n*** Bottom-To-Top ***\n" << endl;
cout << rp.getBodyReversed() << endl;
}
| [
"bryceallen@dhcp93-151.calvin.edu"
] | bryceallen@dhcp93-151.calvin.edu |
0012b78df1803a348abcdff1354c521d707c73ac | 8ead33955285de594502c56b0c5699be31be3946 | /Plugins/AirSim/Source/AirLib/include/physics/PhysicsBody.hpp | 822e2751f40e22176e7280d44f64c7824b6f9c15 | [] | no_license | ece496-Telecopter/PointFollow | e936d13adc51fc72b4b446fac24fb829658172f1 | f39da461528f2ff91d38c2a882b7ad420e9d2d53 | refs/heads/master | 2023-01-18T21:07:43.304981 | 2020-11-25T19:42:34 | 2020-11-25T19:42:34 | 316,028,953 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 129 | hpp | version https://git-lfs.github.com/spec/v1
oid sha256:33f5d955c146528f0d2b884c4037dbe75db8468bc2aec76d84c9536b129cd798
size 6523
| [
"me@sarhad.me"
] | me@sarhad.me |
fef72a53f16a7c0e5ec04f68acaf89ed9cac9ecd | 406e622740fcec70f6f6de40e3d92b7569507dce | /src/examples/raytracinginoneweekend/main.cpp | 28a1c1f74be44f4ae837d5a1b4b310b6cac71f96 | [
"MIT"
] | permissive | MZSATC/visionaray | 9ac96c53a3ded8cbfb225ac124083d1677a69058 | f90c809cefa33002dc51903bbd5ffadc96b6b90e | refs/heads/master | 2020-06-27T16:53:50.688609 | 2019-07-29T22:05:52 | 2019-07-29T22:05:52 | 200,001,802 | 0 | 1 | null | 2019-08-01T07:37:54 | 2019-08-01T07:37:54 | null | UTF-8 | C++ | false | false | 8,901 | cpp | // This file is distributed under the MIT license.
// See the LICENSE file for details.
//-------------------------------------------------------------------------------------------------
// This file is based on Peter Shirley's book "Ray Tracing in One Weekend"
//
#include <cstdlib>
#include <iostream>
#include <ostream>
#include <memory>
#include <GL/glew.h>
#include <visionaray/detail/platform.h>
#include <visionaray/aligned_vector.h>
#include <visionaray/bvh.h>
#include <visionaray/cpu_buffer_rt.h>
#include <visionaray/generic_material.h>
#include <visionaray/kernels.h>
#include <visionaray/material.h>
#include <visionaray/point_light.h>
#include <visionaray/scheduler.h>
#include <visionaray/thin_lens_camera.h>
#include <common/manip/arcball_manipulator.h>
#include <common/manip/pan_manipulator.h>
#include <common/manip/zoom_manipulator.h>
#include <common/viewer_glut.h>
using namespace visionaray;
using viewer_type = viewer_glut;
//-------------------------------------------------------------------------------------------------
//
//
struct renderer : viewer_type
{
using host_ray_type = basic_ray<simd::float4>;
renderer()
: viewer_type(512, 512, "Visionaray \"Ray Tracing in One Weekend by Peter Shirley\" Example")
, bbox({ -3.0f, -3.0f, -3.0f }, { 3.0f, 3.0f, 3.0f })
, host_sched(8)
{
random_scene();
set_background_color(vec3(0.5f, 0.7f, 1.0f));
}
aabb bbox;
thin_lens_camera cam;
cpu_buffer_rt<PF_RGBA32F, PF_UNSPECIFIED> host_rt;
tiled_sched<host_ray_type> host_sched;
unsigned frame_num = 0;
// rendering data
index_bvh<basic_sphere<float>> sphere_bvh;
aligned_vector<basic_sphere<float>> list;
aligned_vector<generic_material<
glass<float>,
matte<float>,
mirror<float>
>> materials;
basic_sphere<float> make_sphere(vec3 center, float radius)
{
static int sphere_id = 0;
basic_sphere<float> sphere(center, radius);
sphere.prim_id = sphere_id;
sphere.geom_id = sphere_id;
++sphere_id;
return sphere;
}
glass<float> make_dielectric(float ior)
{
glass<float> mat;
mat.ct() = from_rgb(1.0f, 1.0f, 1.0f);
mat.kt() = 1.0f;
mat.cr() = from_rgb(1.0f, 1.0f, 1.0f);
mat.kr() = 1.0f;
mat.ior() = spectrum<float>(ior);
return mat;
}
matte<float> make_lambertian(vec3 cd)
{
matte<float> mat;
mat.ca() = from_rgb(0.0f, 0.0f, 0.0f);
mat.ka() = 0.0f;
mat.cd() = from_rgb(cd);
mat.kd() = 1.0f;
return mat;
}
mirror<float> make_metal(vec3 cr)
{
mirror<float> mat;
mat.cr() = from_rgb(cr);
mat.kr() = 1.0f;
mat.ior() = spectrum<float>(0.0);
mat.absorption() = spectrum<float>(0.0);
return mat;
}
void random_scene()
{
int n = 500;
list.resize(n + 1);
materials.resize(n + 1);
list[0] = make_sphere(vec3(0, -1000, 0), 1000);
materials[0] = make_lambertian(vec3(0.5f, 0.5f, 0.5f));
int i = 1;
for (int a = -11; a < 11; ++a)
{
for (int b = -11; b < 11; ++b)
{
float choose_mat = drand48();
vec3 center(a + 0.9 * drand48(), 0.2, b + 0.9 * drand48());
if (length(center - vec3(4, 0.2, 0)) > 0.9)
{
list[i] = make_sphere(center, 0.2);
if (choose_mat < 0.8) // diffuse
{
materials[i] = make_lambertian(vec3(
static_cast<float>(drand48() * drand48()),
static_cast<float>(drand48() * drand48()),
static_cast<float>(drand48() * drand48())
));
}
else if (choose_mat < 0.95) // metal
{
materials[i] = make_metal(vec3(
0.5f * (1.0f + static_cast<float>(drand48())),
0.5f * (1.0f + static_cast<float>(drand48())),
0.5f * (1.0f + static_cast<float>(drand48()))
));
}
else
{
materials[i] = make_dielectric(1.5f);
}
++i;
}
}
}
list[i] = make_sphere(vec3(0, 1, 0), 1.0);
materials[i] = make_dielectric(1.5f);
++i;
list[i] = make_sphere(vec3(-4, 1, 0), 1.0);
materials[i] = make_lambertian(vec3(0.4f, 0.2f, 0.1f));
++i;
list[i] = make_sphere(vec3(4, 1, 0), 1.0);
materials[i] = make_metal(vec3(0.7f, 0.6f, 0.5f));
++i;
binned_sah_builder builder;
builder.enable_spatial_splits(true);
sphere_bvh = builder.build(index_bvh<basic_sphere<float>>{}, list.data(), i);
}
protected:
void on_display();
void on_mouse_move(visionaray::mouse_event const& event);
void on_space_mouse_move(visionaray::space_mouse_event const& event);
void on_resize(int w, int h);
};
//-------------------------------------------------------------------------------------------------
// Display function, contains the rendering kernel
//
void renderer::on_display()
{
// some setup
pixel_sampler::basic_jittered_blend_type<float> blend_params;
float alpha = 1.0f / ++frame_num;
blend_params.sfactor = alpha;
blend_params.dfactor = 1.0f - alpha;
auto sparams = make_sched_params(
blend_params,
cam,
host_rt
);
aligned_vector<index_bvh<basic_sphere<float>>::bvh_ref> primitives;
primitives.push_back(sphere_bvh.ref());
auto kparams = make_kernel_params(
primitives.data(),
primitives.data() + primitives.size(),
materials.data(),
50,
1E-3f,
vec4(background_color(), 1.0f),
vec4(0.5f, 0.7f, 1.0f, 1.0f)
);
pathtracing::kernel<decltype(kparams)> kern;
kern.params = kparams;
host_sched.frame(kern, sparams);
// display the rendered image
auto bgcolor = background_color();
glClearColor(bgcolor.x, bgcolor.y, bgcolor.z, 1.0);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glEnable(GL_FRAMEBUFFER_SRGB);
host_rt.display_color_buffer();
}
//-------------------------------------------------------------------------------------------------
// resize event
//
void renderer::on_resize(int w, int h)
{
cam.set_viewport(0, 0, w, h);
float aspect = w / static_cast<float>(h);
cam.perspective(45.0f * constants::degrees_to_radians<float>(), aspect, 0.001f, 1000.0f);
host_rt.resize(w, h);
host_rt.clear_color_buffer();
frame_num = 0;
viewer_type::on_resize(w, h);
}
//-------------------------------------------------------------------------------------------------
// mouse move event
//
void renderer::on_mouse_move(visionaray::mouse_event const& event)
{
if (event.buttons() != mouse::NoButton)
{
frame_num = 0;
host_rt.clear_color_buffer();
}
viewer_type::on_mouse_move(event);
}
void renderer::on_space_mouse_move(visionaray::space_mouse_event const& event)
{
frame_num = 0;
host_rt.clear_color_buffer();
viewer_type::on_space_mouse_move(event);
}
//-------------------------------------------------------------------------------------------------
// Main function, performs initialization
//
int main(int argc, char** argv)
{
renderer rend;
try
{
rend.init(argc, argv);
}
catch (std::exception& e)
{
std::cerr << e.what() << '\n';
return EXIT_FAILURE;
}
float aspect = rend.width() / static_cast<float>(rend.height());
rend.cam.perspective(45.0f * constants::degrees_to_radians<float>(), aspect, 0.001f, 1000.0f);
rend.cam.view_all( rend.bbox );
float aperture = 0.1f;
rend.cam.set_lens_radius(aperture / 2.0f);
rend.cam.set_focal_distance(10.0f);
rend.add_manipulator( std::make_shared<arcball_manipulator>(rend.cam, mouse::Left) );
rend.add_manipulator( std::make_shared<pan_manipulator>(rend.cam, mouse::Middle) );
// Additional "Alt + LMB" pan manipulator for setups w/o middle mouse button
rend.add_manipulator( std::make_shared<pan_manipulator>(rend.cam, mouse::Left, keyboard::Alt) );
rend.add_manipulator( std::make_shared<zoom_manipulator>(rend.cam, mouse::Right) );
rend.event_loop();
}
| [
"info@szellmann.de"
] | info@szellmann.de |
360115cd96aea3638fb8db1654da204743f71be0 | 5c271235bfa0db6b5731baa88d942a4047e90279 | /pgcityways/pgcityways-test/PgCityWaysTest.cpp | 38eb3b9949c59338ac087b6fb47e82cfd69ef33c | [] | no_license | rshafeev/busweb-conf | 0aac1a3f350be805289af1a30bf188fbc58424a9 | 16983138a1b80526ce2ffacdce4f1d82a2c98ced | refs/heads/master | 2020-06-14T02:48:41.287269 | 2015-01-16T09:40:02 | 2015-01-16T09:40:02 | 194,872,908 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 707 | cpp | #ifndef PGCITYWAYSTEST_H
#define PGCITYWAYSTEST_H
#include <QtTest>
#include "core/graphdata.h"
class PgCityWaysTest : public QObject
{
Q_OBJECT
public:
std::shared_ptr<GraphData> graphData;
private Q_SLOTS:
void initTestCase()
{
TestGraphDataLoader loader;
graphData = loader.loadEuclidGraphData("../test-data/graph1.dat");
for(int i=0;i < graphData->edgesCount; i++){
edge_t e = graphData->edges[i];
std::cout << "edge: " << e.source << " " << e.target << " " << e.cost << "\n";
}
}
void cleanupTestCase()
{
}
void testBoostDijkstra()
{
}
};
#include "moc/PgCityWaysTest.moc"
#endif
| [
"rs@premiumgis.com"
] | rs@premiumgis.com |
3cd865faba2aa6b557ef7e38561e6d12afa81670 | 7e3f0030e8afca8b420c390a8851b26a65c93272 | /Sound Reactive and Normal Patterns/waterfall.ino | e832b9e16662555097f05cb31b807b49ab3bb8e7 | [] | no_license | ShreyT-hash/DIY-LED-Visualizer | 935550503c33b61d1d09c610411da731967b3a3c | b0e7d965e0f074a11dbc6b0944929ffbc11ba6ec | refs/heads/master | 2021-06-29T14:17:35.756611 | 2021-05-20T06:14:40 | 2021-05-20T06:14:40 | 232,185,380 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,165 | ino | #include <FastLED.h>
// How many leds in your strip?
#define NUM_LEDS 20
#define MicSamples (1024*2)
#define SCROLL_SPEED 20
int audio = A0;
unsigned long rr;
#define DATA_PIN 6
CRGB leds[NUM_LEDS];
void setup() {
delay( 3000 ); // power-up safety delay
FastLED.addLeds<NEOPIXEL, DATA_PIN>(leds, NUM_LEDS);
FastLED.setBrightness(60);
for (int i = 0; i < NUM_LEDS; i++)
leds[i] = CRGB(0, 0, 0);
FastLED.show();
Serial.begin(9600);
}
void loop() {
pulsating();
}
void pulsating(){
rr = millis();
leds[0]=CRGB::Red;
for (int i = NUM_LEDS; i>0; i--)
leds[i] = CRGB::Red;
if (millis() - rr > SCROLL_SPEED) {
rr += SCROLL_SPEED;
for (int i = NUM_LEDS - 1; i > 0; i--)
leds[i] = leds[i - 1];
FastLED.show();
delay(200);
}
}
int processAudio(){
long signalAvg = 0, signalMax = 0, signalMin = 1024, t0 = millis();
for (int i = 0; i < MicSamples; i++)
{
int ai = analogRead(audio);
signalMin = min(signalMin, ai);
signalMax = max(signalMax, ai);
signalAvg += ai;
}
signalAvg /= (MicSamples * 1.4);
return signalAvg;
}
| [
"tshrey@students.cs.ubc.ca"
] | tshrey@students.cs.ubc.ca |
beb6be29a2f878375603c3d5489fd4d1e9542947 | bced6a50319e23cb642e770e3f7a0a7b17d5fc46 | /runtime/cpp/test/CountPeersTest.cpp | 0b4fb87b7470a05482b51394c16a21d389bb0dc8 | [
"Apache-2.0"
] | permissive | yliu120/K3 | d17e5c21799c28f76dd41568ca2c6071536c45a3 | dc744e80da0583bdd6a97e733918dd7d3bc0839c | refs/heads/master | 2021-01-21T01:21:07.090214 | 2015-06-16T19:37:19 | 2015-06-16T19:37:19 | 42,563,431 | 0 | 0 | null | 2015-09-16T03:55:25 | 2015-09-16T03:55:25 | null | UTF-8 | C++ | false | false | 5,307 | cpp | #include <Common.hpp>
#include <Engine.hpp>
#include <Dispatch.hpp>
#include <MessageProcessor.hpp>
#include <test/TestUtils.hpp>
#include <functional>
#include <iostream>
#include <sstream>
#include <boost/regex.hpp>
#include <boost/thread/thread.hpp>
#include <xUnit++/xUnit++.h>
FACT("Simulation mode CountPeers with 3 peers should count 3") {
K3::nodeCounter = 0;
K3::peer1 = K3::make_address(K3::localhost, 3000);
K3::peer2 = K3::make_address(K3::localhost, 3001);
K3::peer3 = K3::make_address(K3::localhost, 3002);
K3::rendezvous = K3::peer1;
std::list<K3::Address> peers = std::list<K3::Address>();
peers.push_back(K3::peer1);
peers.push_back(K3::peer2);
peers.push_back(K3::peer3);
K3::SystemEnvironment s_env = K3::defaultEnvironment(peers);
auto engine = K3::buildEngine(true, s_env);
auto table = countPeersTable(engine);
auto mp = K3::buildMP(engine,table);
K3::Message m1 = K3::Message(K3::peer1, "join", "()");
K3::Message m2 = K3::Message(K3::peer2, "join", "()");
K3::Message m3 = K3::Message(K3::peer3, "join", "()");
engine->send(m1);
engine->send(m2);
engine->send(m3);
// Run Engine
engine->runEngine(mp);
// Check the result
Assert.Equal(3, K3::nodeCounter);
}
FACT("Network mode CountPeers with 3 peers should count 3") {
K3::nodeCounter = 0;
using std::shared_ptr;
using boost::thread;
using boost::thread_group;
// Create peers
K3::peer1 = K3::make_address(K3::localhost, 3000);
K3::peer2 = K3::make_address(K3::localhost, 3005);
K3::peer3 = K3::make_address(K3::localhost, 3002);
K3::rendezvous = K3::peer1;
// Create engines
auto engine1 = K3::buildEngine(false, K3::defaultEnvironment(K3::peer1));
auto engine2 = K3::buildEngine(false, K3::defaultEnvironment(K3::peer2));
auto engine3 = K3::buildEngine(false, K3::defaultEnvironment(K3::peer3));
// Create MPs
auto mp1 = K3::buildMP(engine1,countPeersTable(engine1));
auto mp2 = K3::buildMP(engine2,countPeersTable(engine2));
auto mp3 = K3::buildMP(engine3,countPeersTable(engine3));
// Create initial messages (source)
K3::Message m1 = K3::Message(K3::peer1, "join", "()");
K3::Message m2 = K3::Message(K3::peer2, "join", "()");
K3::Message m3 = K3::Message(K3::peer3, "join", "()");
engine1->send(m1);
engine2->send(m2);
engine3->send(m3);
// Fork a thread for each engine
auto service_threads = std::shared_ptr<thread_group>(new thread_group());
shared_ptr<thread> t1 = engine1->forkEngine(mp1);
shared_ptr<thread> t2 = engine2->forkEngine(mp2);
shared_ptr<thread> t3 = engine3->forkEngine(mp3);
service_threads->add_thread(t1.get());
service_threads->add_thread(t2.get());
service_threads->add_thread(t3.get());
int timeout = 3;
int i = 0;
int desired = 3;
while ((K3::nodeCounter < desired) && i < timeout) {
boost::this_thread::sleep_for( boost::chrono::seconds(1) );
i++;
}
engine1->forceTerminateEngine();
engine2->forceTerminateEngine();
engine3->forceTerminateEngine();
service_threads->join_all();
service_threads->remove_thread(t1.get());
service_threads->remove_thread(t2.get());
service_threads->remove_thread(t3.get());
// Check the result
Assert.Equal(desired, K3::nodeCounter);
}
FACT("Network mode CountPeers with 100k messages per 3 peers should count 300k") {
K3::nodeCounter = 0;
using boost::thread;
using boost::thread_group;
using std::shared_ptr;
// Create peers
K3::peer1 = K3::make_address(K3::localhost, 3000);
K3::peer2 = K3::make_address(K3::localhost, 3005);
K3::peer3 = K3::make_address(K3::localhost, 3002);
K3::rendezvous = K3::peer1;
// Create engines
auto engine1 = K3::buildEngine(false, K3::defaultEnvironment(K3::peer1));
auto engine2 = K3::buildEngine(false, K3::defaultEnvironment(K3::peer2));
auto engine3 = K3::buildEngine(false, K3::defaultEnvironment(K3::peer3));
// Create MPs
auto mp1 = K3::buildMP(engine1, countPeersTable(engine1));
auto mp2 = K3::buildMP(engine2, countPeersTable(engine2));
auto mp3 = K3::buildMP(engine3, countPeersTable(engine3));
// Create initial messages (source)
K3::Message m1 = K3::Message(K3::peer1, "join", "()");
K3::Message m2 = K3::Message(K3::peer2, "join", "()");
K3::Message m3 = K3::Message(K3::peer3, "join", "()");
for (int i = 0; i < 100000; i++) {
engine1->send(m1);
engine2->send(m2);
engine3->send(m3);
}
// Fork a thread for each engine
auto service_threads = std::shared_ptr<thread_group>(new thread_group());
int timeout = 600;
int i =0;
int desired = 300000;
shared_ptr<thread> t1 = engine1->forkEngine(mp1);
shared_ptr<thread> t2 = engine2->forkEngine(mp2);
shared_ptr<thread> t3 = engine3->forkEngine(mp3);
service_threads->add_thread(t1.get());
service_threads->add_thread(t2.get());
service_threads->add_thread(t3.get());
while ((K3::nodeCounter < desired) && i < timeout) {
boost::this_thread::sleep_for( boost::chrono::seconds(1) );
i++;
}
engine1->forceTerminateEngine();
engine2->forceTerminateEngine();
engine3->forceTerminateEngine();
service_threads->join_all();
service_threads->remove_thread(t1.get());
service_threads->remove_thread(t2.get());
service_threads->remove_thread(t3.get());
// Check the result
Assert.Equal(desired, K3::nodeCounter);
}
| [
"joshdub223@gmail.com"
] | joshdub223@gmail.com |
56ecf0facd13e276cd20decac832dbda1b6248e7 | dec4ef167e1ce49062645cbf036be324ea677b5e | /SDK/PUBG_WeapSickle_parameters.hpp | 0212abb36764b4727901b910bd97e4c17d68a9c3 | [] | no_license | qrluc/pubg-sdk-3.7.19.5 | 519746887fa2204f27f5c16354049a8527367bfb | 583559ee1fb428e8ba76398486c281099e92e011 | refs/heads/master | 2021-04-15T06:40:38.144620 | 2018-03-26T00:55:36 | 2018-03-26T00:55:36 | 126,754,368 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 383 | hpp | #pragma once
// PlayerUnknown's Battlegrounds (3.5.7.7) SDK
#ifdef _MSC_VER
#pragma pack(push, 0x8)
#endif
#include "PUBG_WeapSickle_classes.hpp"
namespace PUBG
{
//---------------------------------------------------------------------------
//Parameters
//---------------------------------------------------------------------------
}
#ifdef _MSC_VER
#pragma pack(pop)
#endif
| [
"qrl@uc.com"
] | qrl@uc.com |
d0ebb4d817121df1c8e9faff85baf8e166f70c68 | 16e3d9643c7a628b56756e26db0f9bb7311e7379 | /main.cpp | bed1c28eedffa0fffeb6422d4f7a528c33bb6dba | [] | no_license | someilay/Yandex_Internship_2021_Task_C | 95a6d463a5f65d83063364e3b2255d98a11b9dc5 | a1bbc8a85577ea8f1b4942355306c9e376044c98 | refs/heads/main | 2023-04-03T06:25:45.333745 | 2021-04-08T06:56:40 | 2021-04-08T06:56:40 | 354,888,603 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 6,266 | cpp | #include <iostream>
#include <ctime>
#define TEST 0
struct pair {
int value;
int index;
};
typedef struct pair Pair;
Pair *createPair(int v, int i) {
Pair *out = new Pair();
out->index = i;
out->value = v;
return out;
}
void mergeSort(Pair **arr, int size) {
if (size > 1) {
mergeSort(arr, size / 2);
mergeSort(arr + size / 2, size - size / 2);
int i = 0, j = size / 2, z = 0;
Pair **buf = new Pair *[size];
while (i < size / 2 && j < size) {
if (arr[i]->value <= arr[j]->value) {
buf[z] = arr[i];
i++;
} else {
buf[z] = arr[j];
j++;
}
z++;
}
if (i >= size / 2) {
std::copy(arr + j, arr + size, buf + z);
}
if (j >= size) {
std::copy(arr + i, arr + size / 2, buf + z);
}
std::copy(buf, buf + size, arr);
delete[] buf;
}
}
int D(int j, int l, int k, const int* A, const int* S){
return S[k + l] + S[l == 0 ? 0 : l - 1] - 2 * l * A[j] + (2 * j - k) * A[j] - S[j] - S[j == 0 ? 0 : j - 1];
}
int findMin(int j, int k, int left, int right, const int* A, const int* S){
if (left == right){
return D(j, left, k, A, S);
}
if (right - left == 1){
int lSum = D(j, left, k, A, S);
int rSum = D(j, right, k, A, S);
return lSum < rSum ? lSum : rSum;
}
int medium = (left + right) / 2;
int mSum = D(j, medium, k, A, S);
int mrSum = D(j, medium + 1, k, A, S);
int mlSum = D(j, medium - 1, k, A, S);
if (mrSum < mSum && mSum <= mlSum){
return findMin(j, k, medium + 1, right, A, S);
} else if (mlSum < mSum && mSum <= mrSum){
return findMin(j, k, left, medium - 1, A, S);
} else if (mlSum > mSum && mSum < mrSum){
return mSum;
} else {
int lSum = findMin(j, k, left, medium - 1, A, S);
int rSum = findMin(j, k, medium + 1, right, A, S);
return std::min(std::min(lSum, rSum), mSum);
}
}
int* alg2(int* input, int n, int k){
Pair **arr = new Pair *[n];
for (int i = 0; i < n; i++) {
arr[i] = createPair(input[i], i);
}
mergeSort(arr, n);
int *results = new int[n];
int *A = new int[n];
int *S = new int[n];
for (int i = 0; i < n; i++) {
A[i] = arr[i]->value - arr[0]->value;
}
S[0] = 0;
for (int i = 1; i < n; i++) {
S[i] = S[i - 1] + A[i];
}
for (int i = 0; i < n; i++) {
int left = i - k >= 0 ? i - k : 0;
int right = i + k < n ? i : n - 1 - k;
results[arr[i]->index] = findMin(i, k, left, right, A, S);
}
free(A);
free(S);
for (int i = 0; i < n; i++) {
free(arr[i]);
}
return results;
}
#if TEST == 0
int main() {
int n, k;
std::cin >> n;
std::cin >> k;
int* arr = new int[n];
for (int i = 0; i < n; i++) {
std::cin >> arr[i];
}
int* answer = alg2(arr, n, k);
for (int i = 0; i < n; i++) {
printf("%d ", answer[i]);
}
}
#else
int* alg1(int* input, int n, int k){
Pair** arr = new Pair*[n];
for (int i = 0; i < n; i++) {
arr[i] = createPair(input[i], i);
}
mergeSort(arr, n);
int* results = new int[n];
for (int i = 0; i < n; i++) {
int l = i - 1, r = i + 1;
int res = 0;
for (int j = 0; j < k; j++) {
int new_l_res = 0;
int new_r_res = 0;
if (l > -1){
new_l_res += std::abs(arr[l]->value - arr[i]->value);
} else{
new_l_res = INT32_MAX;
}
if (r < n){
new_r_res += std::abs(arr[r]->value - arr[i]->value);
} else{
new_r_res = INT32_MAX;
}
if (new_l_res < new_r_res){
l--;
res += new_l_res;
} else{
r++;
res += new_r_res;
}
}
results[arr[i]->index] = res;
}
for (int i = 0; i < n; i++) {
free(arr[i]);
}
return results;
}
int* randArray(int n, int min_, int max_){
int* out = new int[n];
for (int i = 0; i < n; i++) {
out[i] = rand() % (max_ - min_ + 1) + min_;
}
return out;
}
int main() {
srand(time(nullptr));
const int NUMBER_OF_TEST = 100;
const int MAX_SIZE = 5000;
const int MIN_SIZE = 5;
const int MAX_VALUE = 1000000;
const int MIN_VALUE = 1;
for (int i = 0; i < NUMBER_OF_TEST; i++) {
int size = rand() % (MAX_SIZE - MIN_SIZE + 1) + MIN_SIZE;
int k = rand() % (size - 1) + 1;
int* input = randArray(size, MIN_VALUE, MAX_VALUE);
int* ans1 = alg1(input, size, k);
int* ans2 = alg2(input, size, k);
bool success = true;
for (int j = 0; j < size; j++) {
if (ans1[j] != ans2[j]){
printf("Error! Iteration = %d, Size = %d, K = %d\n", i, size, k);
for (int l = 0; l < size; l++) {
printf("%d ", input[l]);
}
printf("\n");
for (int l = 0; l < size; l++) {
printf("%d ", ans1[l]);
}
printf("\n");
for (int l = 0; l < size; l++) {
printf("%d ", ans2[l]);
}
printf("\n");
success = false;
break;
}
}
if (success){
printf("Success! Iteration = %d\n", i);
}
free(input);
free(ans1);
free(ans2);
}
const int ABSOLUTE_MAX_SIZE = 300000;
const int ABSOLUTE_MAX_K = 299999;
const int ABSOLUTE_MAX_VALUE = 100000000;
int* input = randArray(ABSOLUTE_MAX_SIZE, 0, ABSOLUTE_MAX_VALUE);
clock_t tStart = clock();
alg2(input, ABSOLUTE_MAX_SIZE, ABSOLUTE_MAX_K);
printf("Algorithm 2 taken: %.2fs\n", (double)(clock() - tStart)/CLOCKS_PER_SEC);
tStart = clock();
alg1(input, ABSOLUTE_MAX_SIZE, ABSOLUTE_MAX_K);
printf("Algorithm 1 taken: %.2fs\n", (double)(clock() - tStart)/CLOCKS_PER_SEC);
return 0;
}
#endif | [
"noreply@github.com"
] | someilay.noreply@github.com |
333fe09f3c0f4776c8821190e60906af657b4923 | cf710c6ff4ed0d68147400545d411c21ace18806 | /thrift/compiler/test/fixtures/mcpp2-compare/gen-cpp2/enums_types.h | 04a43f84dbe2651f24eb5d6d628b232389896425 | [
"Apache-2.0"
] | permissive | dendisuhubdy/fbthrift | fdb1f9edda96b00a3c088773fea4fe8da0d7eef2 | e91d5cbe21246bfabc2f0af353c7a7b7da382983 | refs/heads/master | 2020-05-23T16:01:32.960752 | 2019-05-15T02:59:45 | 2019-05-15T03:08:17 | 186,839,215 | 0 | 0 | Apache-2.0 | 2019-12-09T07:14:46 | 2019-05-15T14:05:48 | C++ | UTF-8 | C++ | false | false | 8,484 | h | /**
* Autogenerated by Thrift
*
* DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
* @generated
*/
#pragma once
#include <thrift/lib/cpp2/GeneratedHeaderHelper.h>
#include <thrift/lib/cpp2/Thrift.h>
#include <thrift/lib/cpp2/gen/module_types_h.h>
#include <thrift/lib/cpp2/protocol/Protocol.h>
// BEGIN declare_enums
namespace facebook { namespace ns { namespace qwerty {
enum class AnEnumA {
FIELDA = 0
};
using _AnEnumA_EnumMapFactory = apache::thrift::detail::TEnumMapFactory<AnEnumA>;
extern const _AnEnumA_EnumMapFactory::ValuesToNamesMapType _AnEnumA_VALUES_TO_NAMES;
extern const _AnEnumA_EnumMapFactory::NamesToValuesMapType _AnEnumA_NAMES_TO_VALUES;
enum class AnEnumB {
FIELDA = 0,
FIELDB = 2
};
using _AnEnumB_EnumMapFactory = apache::thrift::detail::TEnumMapFactory<AnEnumB>;
extern const _AnEnumB_EnumMapFactory::ValuesToNamesMapType _AnEnumB_VALUES_TO_NAMES;
extern const _AnEnumB_EnumMapFactory::NamesToValuesMapType _AnEnumB_NAMES_TO_VALUES;
enum class AnEnumC {
FIELDC = 0
};
using _AnEnumC_EnumMapFactory = apache::thrift::detail::TEnumMapFactory<AnEnumC>;
extern const _AnEnumC_EnumMapFactory::ValuesToNamesMapType _AnEnumC_VALUES_TO_NAMES;
extern const _AnEnumC_EnumMapFactory::NamesToValuesMapType _AnEnumC_NAMES_TO_VALUES;
enum class AnEnumD {
FIELDD = 0
};
using _AnEnumD_EnumMapFactory = apache::thrift::detail::TEnumMapFactory<AnEnumD>;
extern const _AnEnumD_EnumMapFactory::ValuesToNamesMapType _AnEnumD_VALUES_TO_NAMES;
extern const _AnEnumD_EnumMapFactory::NamesToValuesMapType _AnEnumD_NAMES_TO_VALUES;
enum class AnEnumE {
FIELDA = 0
};
using _AnEnumE_EnumMapFactory = apache::thrift::detail::TEnumMapFactory<AnEnumE>;
extern const _AnEnumE_EnumMapFactory::ValuesToNamesMapType _AnEnumE_VALUES_TO_NAMES;
extern const _AnEnumE_EnumMapFactory::NamesToValuesMapType _AnEnumE_NAMES_TO_VALUES;
}}} // facebook::ns::qwerty
namespace std {
template<> struct hash<typename ::facebook::ns::qwerty::AnEnumA> : public apache::thrift::detail::enum_hash<typename ::facebook::ns::qwerty::AnEnumA> {};
template<> struct equal_to<typename ::facebook::ns::qwerty::AnEnumA> : public apache::thrift::detail::enum_equal_to<typename ::facebook::ns::qwerty::AnEnumA> {};
template<> struct hash<typename ::facebook::ns::qwerty::AnEnumB> : public apache::thrift::detail::enum_hash<typename ::facebook::ns::qwerty::AnEnumB> {};
template<> struct equal_to<typename ::facebook::ns::qwerty::AnEnumB> : public apache::thrift::detail::enum_equal_to<typename ::facebook::ns::qwerty::AnEnumB> {};
template<> struct hash<typename ::facebook::ns::qwerty::AnEnumC> : public apache::thrift::detail::enum_hash<typename ::facebook::ns::qwerty::AnEnumC> {};
template<> struct equal_to<typename ::facebook::ns::qwerty::AnEnumC> : public apache::thrift::detail::enum_equal_to<typename ::facebook::ns::qwerty::AnEnumC> {};
template<> struct hash<typename ::facebook::ns::qwerty::AnEnumD> : public apache::thrift::detail::enum_hash<typename ::facebook::ns::qwerty::AnEnumD> {};
template<> struct equal_to<typename ::facebook::ns::qwerty::AnEnumD> : public apache::thrift::detail::enum_equal_to<typename ::facebook::ns::qwerty::AnEnumD> {};
template<> struct hash<typename ::facebook::ns::qwerty::AnEnumE> : public apache::thrift::detail::enum_hash<typename ::facebook::ns::qwerty::AnEnumE> {};
template<> struct equal_to<typename ::facebook::ns::qwerty::AnEnumE> : public apache::thrift::detail::enum_equal_to<typename ::facebook::ns::qwerty::AnEnumE> {};
} // std
namespace apache { namespace thrift {
template <> struct TEnumDataStorage<::facebook::ns::qwerty::AnEnumA>;
template <> struct TEnumTraits<::facebook::ns::qwerty::AnEnumA> {
using type = ::facebook::ns::qwerty::AnEnumA;
static constexpr std::size_t const size = 1;
static folly::Range<type const*> const values;
static folly::Range<folly::StringPiece const*> const names;
static char const* findName(type value);
static bool findValue(char const* name, type* out);
static constexpr type min() { return type::FIELDA; }
static constexpr type max() { return type::FIELDA; }
};
template <> struct TEnumDataStorage<::facebook::ns::qwerty::AnEnumB>;
template <> struct TEnumTraits<::facebook::ns::qwerty::AnEnumB> {
using type = ::facebook::ns::qwerty::AnEnumB;
static constexpr std::size_t const size = 2;
static folly::Range<type const*> const values;
static folly::Range<folly::StringPiece const*> const names;
static char const* findName(type value);
static bool findValue(char const* name, type* out);
static constexpr type min() { return type::FIELDA; }
static constexpr type max() { return type::FIELDB; }
};
template <> struct TEnumDataStorage<::facebook::ns::qwerty::AnEnumC>;
template <> struct TEnumTraits<::facebook::ns::qwerty::AnEnumC> {
using type = ::facebook::ns::qwerty::AnEnumC;
static constexpr std::size_t const size = 1;
static folly::Range<type const*> const values;
static folly::Range<folly::StringPiece const*> const names;
static char const* findName(type value);
static bool findValue(char const* name, type* out);
static constexpr type min() { return type::FIELDC; }
static constexpr type max() { return type::FIELDC; }
};
template <> struct TEnumDataStorage<::facebook::ns::qwerty::AnEnumD>;
template <> struct TEnumTraits<::facebook::ns::qwerty::AnEnumD> {
using type = ::facebook::ns::qwerty::AnEnumD;
static constexpr std::size_t const size = 1;
static folly::Range<type const*> const values;
static folly::Range<folly::StringPiece const*> const names;
static char const* findName(type value);
static bool findValue(char const* name, type* out);
static constexpr type min() { return type::FIELDD; }
static constexpr type max() { return type::FIELDD; }
};
template <> struct TEnumDataStorage<::facebook::ns::qwerty::AnEnumE>;
template <> struct TEnumTraits<::facebook::ns::qwerty::AnEnumE> {
using type = ::facebook::ns::qwerty::AnEnumE;
static constexpr std::size_t const size = 1;
static folly::Range<type const*> const values;
static folly::Range<folly::StringPiece const*> const names;
static char const* findName(type value);
static bool findValue(char const* name, type* out);
static constexpr type min() { return type::FIELDA; }
static constexpr type max() { return type::FIELDA; }
};
}} // apache::thrift
// END declare_enums
// BEGIN struct_indirection
// END struct_indirection
// BEGIN forward_declare
namespace facebook { namespace ns { namespace qwerty {
class SomeStruct;
}}} // facebook::ns::qwerty
// END forward_declare
// BEGIN typedefs
// END typedefs
// BEGIN hash_and_equal_to
// END hash_and_equal_to
namespace facebook { namespace ns { namespace qwerty {
class SomeStruct final : private apache::thrift::detail::st::ComparisonOperators<SomeStruct> {
public:
SomeStruct() :
fieldA(0) {}
// FragileConstructor for use in initialization lists only.
[[deprecated("This constructor is deprecated")]]
SomeStruct(apache::thrift::FragileConstructor, int32_t fieldA__arg);
template <typename _T>
void __set_field(::apache::thrift::detail::argument_wrapper<1, _T> arg) {
fieldA = arg.extract();
__isset.fieldA = true;
}
SomeStruct(SomeStruct&&) = default;
SomeStruct(const SomeStruct&) = default;
SomeStruct& operator=(SomeStruct&&) = default;
SomeStruct& operator=(const SomeStruct&) = default;
void __clear();
int32_t fieldA;
struct __isset {
bool fieldA;
} __isset = {};
bool operator==(const SomeStruct& rhs) const;
bool operator<(const SomeStruct& rhs) const;
int32_t get_fieldA() const {
return fieldA;
}
int32_t& set_fieldA(int32_t fieldA_) {
fieldA = fieldA_;
__isset.fieldA = true;
return fieldA;
}
template <class Protocol_>
uint32_t read(Protocol_* iprot);
template <class Protocol_>
uint32_t serializedSize(Protocol_ const* prot_) const;
template <class Protocol_>
uint32_t serializedSizeZC(Protocol_ const* prot_) const;
template <class Protocol_>
uint32_t write(Protocol_* prot_) const;
private:
template <class Protocol_>
void readNoXfer(Protocol_* iprot);
friend class ::apache::thrift::Cpp2Ops< SomeStruct >;
};
void swap(SomeStruct& a, SomeStruct& b);
template <class Protocol_>
uint32_t SomeStruct::read(Protocol_* iprot) {
auto _xferStart = iprot->getCursorPosition();
readNoXfer(iprot);
return iprot->getCursorPosition() - _xferStart;
}
}}} // facebook::ns::qwerty
| [
"facebook-github-bot@users.noreply.github.com"
] | facebook-github-bot@users.noreply.github.com |
25b241f17818205b7ee87a45aa9e08f185f5a7e0 | d6b40d09f08a30ece3d4f29d46158ddbabc609e4 | /Bamboo/src/Bamboo/Timing.h | d5f709830c5d85db40d367f1244f707ff8641f8d | [] | no_license | Buddy99/Bamboo | 1f4b48baf0995148c2b44153ddffe1742b7d29a6 | f912ebd368e3e98f99adcb1fd3c2b1d2fd2171af | refs/heads/main | 2023-04-21T22:39:53.473854 | 2021-05-01T20:08:20 | 2021-05-01T20:08:20 | 344,511,350 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 617 | h | #pragma once
#include "Core.h"
#include <chrono>
namespace Bamboo
{
class BAMBOO_API Timing
{
public:
static void Init();
static double GetTimeSinceStartup();
static void SetFixedFrameTime(double frameTime);
static double GetFixedFrameTime();
static void SetRenderFrameTime(double frameTime);
static double GetRenderFrameTime();
static void SetDeltaTime(double deltaTime);
static double GetDeltaTime();
private:
inline static std::chrono::system_clock::time_point start;
inline static double FixedFrameTime;
inline static double RenderFrameTime;
inline static double DeltaTime;
};
} | [
"anjahandl22@gmail.com"
] | anjahandl22@gmail.com |
81380591131be299d1f0e943923ba7755916745f | 0bee11d8cbf3290d1facde59e15924efe0eca705 | /MID.cpp | 2b07a31fcd35f1e1d273596c5c51b985fb1de998 | [] | no_license | verontanos/OOP | 5382c4d0a1b542b9fe640effbb98b70a69c5688b | 4e09ca48556482d3496cb6fa140210459c331f3a | refs/heads/main | 2023-04-28T00:18:24.000885 | 2021-05-15T14:59:47 | 2021-05-15T14:59:47 | 338,974,961 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,048 | cpp | #include<iostream>
using namespace std;
class mahasiswa{
public:
int assigment;
int quiz;
int attendance;
int mid_test;
int final_test;
void Student(){
int grade[3];
int N;
cout<<"Grading system ver1.0\n";
cout<<"=======================\n";
cout<<"Enter number of students:";
cin>>N;
for(int A=1; A<=N; A++){
cout<<"masukan nilai dari mahasiswa: "<<endl;
cout<<"Attendance :"; cin>>assigment;
cout<<"Quiz :"; cin>>quiz;
cout<<"Assignment :"; cin>>attendance;
cout<<"Mid Exam :"; cin>>mid_test;
cout<<"Final Exam :"; cin>>final_test;
int AT = (attendance * 10/100);
int Q = (quiz * 10) /100;
int AS = (assigment * 20) /100;
int MT = (mid_test * 30) /100;
int FT = (final_test * 30) /100;
grade[A]= AT+Q+AS+MT+FT;
}
attendance = attendance*10/100;
quiz = quiz*10/100;
assigment = assigment*20/100;
mid_test = mid_test*30/100;
final_test = final_test*30/100;
cout<<"--------------------------------";
cout<<"\nStudent Grade";
cout<<"\n--------------------------------";
cout<<"\nStudent\t \t GRADE";
cout<<"\n--------------------------------";
for (int A=1; A<=N; A++){
cout<<"\n"<<A;
cout<<"\t \t "<< grade[A];
if(grade[A]<=100 && grade[A]>=91){
cout<<"(A)";
}else if(grade[A]<=90 && grade[A]>=85){
cout<<"(A-)";
}else if(grade[A]<=84 && grade[A]>=82){
cout<<"(B+)";
}else if(grade[A]<=81 && grade[A]>=78){
cout<<"(B)";
}else if(grade[A]<=77 && grade[A]>=75){
cout<<"(B-)";
}else if(grade[A]<=74 && grade[A]>=70){
cout<<"(C+)";
}else if(grade[A]<=69 && grade[A]>=67){
cout<<"(C)";
}else if(grade[A]<=66 && grade[A]>=60){
cout<<"(C-)";
}else if(grade[A]<=59 && grade[A]>=40){
cout<<"(D)";
}else if(grade[A]<=39 && grade[A]>=0){
cout<<"(F)";
}else{
cout<<"\nsalah menginputkan nilai!!";
}
}
}
};
int main(){
mahasiswa pelajar;
pelajar.Student();
return 0;
}
| [
"noreply@github.com"
] | verontanos.noreply@github.com |
2fae3013f48a23c3461491c8455bab705a880eed | d55d52747adfb7e8944abac10076a99553ad5f8b | /connected_component.h | b1174c1e8b47cfcad9c60012658d2a34f31a7b6f | [] | no_license | akevli/FlightPaths | 1fd181dd24fbaa0594d95c05870d2b99e4337889 | 8cef2a8e832fcdf37f923c7da944727e24255caf | refs/heads/master | 2023-02-12T19:19:33.204465 | 2021-01-10T20:39:50 | 2021-01-10T20:39:50 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 906 | h | #pragma once
#include <queue>
#include <fstream>
#include <iostream>
#include "edge.h"
#include "graph.h"
using namespace std;
class ConnectedComponents {
private:
vector<int> elems;
public:
/**
* @param num - Number of elements to add to the disjoint set
*/
void addelements(int num);
/**
* @param elem - Element for which to find the representative element
* @return - Index of the representative element of the set
*/
int find(int elem);
/**
* @param a - First element set to union
* @param b - Second element set to union
*/
void setunion(int a, int b);
/**
* @param map - Map with airport ids as the key and pointers to airports as the values
*/
void calculateConnectedComponents(unordered_map<int, Airport*>& map);
}; | [
"akli2@illinois.edu"
] | akli2@illinois.edu |
81e256bdb19e8379e2bae28e8df69007c9190495 | 630a68871d4cdcc9dbc1f8ac8b44f579ff994ecf | /myodd/boost/libs/hana/example/functional/lockstep.cpp | 3ad2f44763681ed095f916ec8e8c7a311b7d63f4 | [
"MIT",
"BSL-1.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | FFMG/myoddweb.piger | b56b3529346d9a1ed23034098356ea420c04929d | 6f5a183940661bd7457e6a497fd39509e186cbf5 | refs/heads/master | 2023-01-09T12:45:27.156140 | 2022-12-31T12:40:31 | 2022-12-31T12:40:31 | 52,210,495 | 19 | 2 | MIT | 2022-12-31T12:40:32 | 2016-02-21T14:31:50 | C++ | UTF-8 | C++ | false | false | 514 | cpp | // Copyright Louis Dionne 2013-2016
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)
#include <boost/hana/functional/lockstep.hpp>
#include <boost/hana/plus.hpp>
namespace hana = boost::hana;
constexpr int to_int(char c) {
return static_cast<int>(c) - 48;
}
constexpr int increment(int i) {
return i + 1;
}
static_assert(hana::lockstep(hana::plus)(to_int, increment)('3', 4) == 3 + 5, "");
int main() { }
| [
"github@myoddweb.com"
] | github@myoddweb.com |
6c12e092a6ed5e53ccd5e776767b7865f0533405 | 21492f2b68460b11981a13c7c8487ef2ba71c43d | /Assignments/Assignment 1/Yuvraj/AS4.cpp | 5349c50ce7243fd451aa3be9f1788bb4083677a8 | [] | no_license | sukhsagar/Coditude1.0 | 8f666dc9a7caf6f2706b74505916119bed917fc6 | 2ecbce98cc9496750af0b914ba7962135e26d1d3 | refs/heads/master | 2020-06-02T10:59:17.904617 | 2019-06-12T20:23:09 | 2019-06-12T20:23:09 | 191,133,653 | 1 | 0 | null | 2019-06-12T20:23:10 | 2019-06-10T09:04:36 | C++ | UTF-8 | C++ | false | false | 277 | cpp | #include<iostream>
#include<conio.h>
using namespace std;
int main()
{
int i,j,start,end;
cout<<"enter the staring and end point of series";
cin>>start>>end;
cout<<"series is :";
i=start-1;
while(i<=end)
{
cout<<start<<"\t"<<i<<"\t";
start++;
i++;
}
return 0;
}
| [
"sukhsagar.batra@gmail.com"
] | sukhsagar.batra@gmail.com |
f3c235501ff1d50404d337e63e3491010400bdab | 31f04b398eec5065a907643b31396ada0a7a500b | /GutlandLiberatus/Weapon.h | abf2f9744074413d4e5ed2751e7bbd4039dda49c | [] | no_license | Dequilla/Gutland-Liberatus | a0b6aaa4a8761ea0ec037ec7ca67048efc728c8c | f8bee8cf9aae73d253dbd4bedff0af753c981803 | refs/heads/master | 2020-12-18T12:34:40.765098 | 2016-05-30T09:30:15 | 2016-05-30T09:30:15 | 235,381,818 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 409 | h | #pragma once
#include <vector>
struct Weapon {
enum class Type {
Melee = 0,
Range
};
Weapon::Weapon(){};
Weapon::~Weapon(){};
unsigned int rangeModifier = 0;
unsigned int meleeModifier = 0;
unsigned int evasionModifier = 0;
unsigned int maxDamage = 0;
unsigned int minimumDamage = 0;
unsigned int critChance = 0;
std::string name;
Type weaponType;
std::string attacks[4];
}; | [
"edwin.wallin@dequilla.com"
] | edwin.wallin@dequilla.com |
76ec11513d8bd60395feede068397176ec9b1e5e | 7c63ba18dede49d24518cd8fb7d7bfa317e180a5 | /src/qrtelescope.cpp | e7cbfa29ec17398bdc4c192c2642b85cacd18960 | [] | no_license | RTS2/rts2-qt | 3211895b9db8cb736f8009b923301f5fe10e612c | e549313397067b0be0c8e5056429f4c813e53111 | refs/heads/master | 2020-04-05T11:21:55.287695 | 2017-09-08T23:42:15 | 2017-09-08T23:42:15 | 81,386,553 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,494 | cpp | #include "qrtelescope.h"
#include "qrapp.h"
#include <libnova/libnova.h>
#include <QApplication>
#include <QJsonDocument>
#include <QJsonObject>
#include <QJsonArray>
#include <QStyle>
QRTelescope::QRTelescope(const QString &_telescope, QWidget *parent) :
QWidget(parent),
telescope(_telescope)
{
mainLayout = new QVBoxLayout(this);
raDec = new QLCDNumber();
mainLayout->addWidget(raDec);
raDec->setDigitCount(24);
raDec->display("00:00:00.000 +00'00:00.00");
gridLayout = new QGridLayout(this);
QToolButton *b = new QToolButton();
b->setArrowType(Qt::UpArrow);
b->setFixedSize(50, 50);
b->setIconSize(QSize(50, 50));
gridLayout->addWidget(b, 0, 1);
connect(b, SIGNAL(clicked()), this, SLOT(buttonUpClicked()));
b = new QToolButton();
b->setArrowType(Qt::LeftArrow);
b->setFixedSize(50, 50);
b->setIconSize(QSize(50, 50));
gridLayout->addWidget(b, 1, 0);
connect(b, SIGNAL(clicked()), this, SLOT(buttonLeftClicked()));
b = new QToolButton();
b->setArrowType(Qt::RightArrow);
b->setFixedSize(50, 50);
b->setIconSize(QSize(50, 50));
gridLayout->addWidget(b, 1, 2);
connect(b, SIGNAL(clicked()), this, SLOT(buttonRightClicked()));
b = new QToolButton();
b->setArrowType(Qt::DownArrow);
b->setFixedSize(50, 50);
b->setIconSize(QSize(50, 50));
gridLayout->addWidget(b, 2, 1);
connect(b, SIGNAL(clicked()), this, SLOT(buttonDownClicked()));
b = new QToolButton();
b->setIcon(QApplication::style()->standardIcon(QStyle::SP_BrowserStop));
b->setFixedSize(50, 50);
b->setIconSize(QSize(50, 50));
gridLayout->addWidget(b, 1, 1);
connect(b, SIGNAL(clicked()), this, SLOT(buttonStopClicked()));
mainLayout->addLayout(gridLayout);
setLayout(mainLayout);
connect(&QRApp::getInstance(), &QRApp::rts2Updated, this, &QRTelescope::rts2Updated);
}
QRTelescope::~QRTelescope()
{
delete gridLayout;
delete mainLayout;
}
void
QRTelescope::buttonUpClicked()
{
QRApp::getInstance().rts2IncValue(telescope, "OFFS", +1/60.0, 0);
}
void
QRTelescope::buttonDownClicked()
{
QRApp::getInstance().rts2IncValue(telescope, "OFFS", -1/60.0, 0);
}
void
QRTelescope::buttonLeftClicked()
{
QRApp::getInstance().rts2IncValue(telescope, "OFFS", 0, -1/60.0);
}
void
QRTelescope::buttonStopClicked()
{
QRApp::getInstance().rts2Command(telescope, "stop");
}
void
QRTelescope::buttonRightClicked()
{
QRApp::getInstance().rts2IncValue(telescope, "OFFS", 0, +1/60.0);
}
void
QRTelescope::rts2Updated(QJsonDocument &doc)
{
QJsonObject docObject = doc.object();
QJsonObject devArray = docObject[telescope].toObject();
qDebug() << "tel " << devArray.toVariantMap();
QJsonObject dArray = devArray["d"].toObject();
struct ln_equ_posn telPos;
telPos.ra = dArray["TEL"].toArray()[1].toObject()["ra"].toVariant().toDouble();
telPos.dec = dArray["TEL"].toArray()[1].toObject()["dec"].toVariant().toDouble();
struct lnh_equ_posn rdv;
ln_equ_to_hequ(&telPos, &rdv);
raDec->display(QString("%1:%2:%3 %4'%5:%6")
.arg((short int) rdv.ra.hours, 2, 10, QLatin1Char('0'))
.arg((short int) rdv.ra.minutes, 2, 10, QLatin1Char('0'))
.arg(rdv.ra.seconds, 2, 'g', 3, QLatin1Char('0'))
.arg((short int) rdv.dec.degrees, 2, 10, QLatin1Char('0'))
.arg((short int) rdv.dec.minutes, 2, 10, QLatin1Char('0'))
.arg(rdv.dec.seconds, 2, 'g', 2, QLatin1Char('0'))
);
}
| [
"petr@kubanek.net"
] | petr@kubanek.net |
fe33d05b4e1129e605c406127527e28838888764 | eec6fc365c7415835b4a69eaceb23a224f2abc47 | /BaekJoon/2020/2xn 타일링 2 (11727번).cpp | 378c1158bb9884204f74768238b9762e95e50600 | [] | no_license | chosh95/STUDY | 3e2381c632cebecc9a91e791a4a27a89ea6491ea | 0c88a1dd55d1826e72ebebd5626d6d83665c8431 | refs/heads/master | 2022-04-30T23:58:56.228240 | 2022-04-18T13:08:01 | 2022-04-18T13:08:01 | 166,837,216 | 3 | 1 | null | 2019-06-20T10:51:49 | 2019-01-21T15:32:03 | C++ | UTF-8 | C++ | false | false | 220 | cpp | #include <iostream>
using namespace std;
int N;
int dp[1001];
int main()
{
cin >> N;
dp[0] = 0;
dp[1] = 1;
dp[2] = 3;
for (int i = 3; i <= N; i++)
dp[i] = (dp[i - 2] * 2 + dp[i - 1]) % 10007;
cout << dp[N];
} | [
"chosh-95@hanmail.net"
] | chosh-95@hanmail.net |
6c6497623ed613719493522b9461f8c100ee53af | 1663ff6118362ab70b2dd35ce113678b4225491c | /DalitzAnalysis/src/SealModule.cc | 12bfc640c16963111e275ac4c638339daa1ed5f5 | [] | no_license | deguio/usercode | f9fd35a9ed695e751cfa413d307a9639118380f1 | 30c2072054f078a913b286dc74ab83c44df1739f | refs/heads/master | 2021-01-18T23:09:04.273206 | 2013-03-28T16:26:48 | 2013-03-28T16:26:48 | 10,270,047 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 235 | cc | #include "FWCore/Framework/interface/InputSourceMacros.h"
#include "FWCore/Framework/interface/MakerMacros.h"
#include "Dalitz/DalitzAnalysis/interface/QCDAnalyzer.h"
DEFINE_SEAL_MODULE();
DEFINE_ANOTHER_FWK_MODULE(QCDAnalyzer);
| [
""
] | |
28a6e93ba9dd7791b841290056c3a301cc8675f8 | 7a6b6a4b30f86f4a9dba1cb21ff48d185ca46c07 | /source/headers/player.h | 24d25ca52c65d4e30eee749e05cdff3caee79136 | [] | no_license | Kbman99/remaking-cavestory | 94f7cac523024e6689849644ca254ed159725a45 | 3440df6d8b2c90f45ef418f71fd76b4939b959f3 | refs/heads/master | 2020-12-21T21:47:36.437579 | 2016-08-12T05:19:02 | 2016-08-12T05:19:02 | 58,980,583 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,641 | h | #ifndef PLAYER_H
#define PLAYER_H
#include "globals.h"
#include "animatedsprite.h"
#include "slope.h"
#include "level.h"
class Graphics;
class Player : public AnimatedSprite {
public:
Player();
Player(Graphics &graphics, Vector2 spawnPoint);
void draw(Graphics &graphics);
void update(float elapsedTime);
/* void moveLeft
Moves the player left by -dx
*/
void moveLeft();
/* void moveRight
Moves the player right by dx
*/
void moveRight();
/* void stopMoving
Stops moving the player
*/
void stopMoving();
/* void lookUp
The player looks up
*/
void lookUp();
/* void stopLookingUp
The player stops looking up
*/
void stopLookingUp();
/* void lookDown
The player looks down OR interacts (turns around)
*/
void lookDown();
/* void stopLookingDown
The player stops looking down or interacting
*/
void stopLookingDown();
/* void jump
Starts jumping
*/
void jump();
virtual void animationDone(std::string currentAnimation);
virtual void setupAnimations();
void handleTileCollisions(std::vector<Rectangle> &others);
void handleSlopeCollisions(std::vector<Slope> &others);
void handleDoorCollision(std::vector<Door> &others, Level &level, Graphics &graphics);
const float getX() const;
const float getY() const;
const inline int getMaxHealth() const { return this->_maxHealth; }
const inline int getCurrentHealth() const { return this->_currentHealth; }
private:
float _dx, _dy;
Direction _facing;
bool _grounded;
bool _lookingUp;
bool _lookingDown;
int _maxHealth;
int _currentHealth;
};
#endif | [
"Kylebowman99@gmail.com"
] | Kylebowman99@gmail.com |
2d707eb5c101d86780cc87059885390e5808b493 | 7888d2af010aeed43a52c9e983f1e08586e8e227 | /QSS_SourceCode/QSS/Source/GUI/SpectrumPlotComponent.h | 43827e2c56a85daf2b103e3d1e461ea79ae7268f | [] | no_license | CreativeCodingLab/QuasarSonify | f5d4b55e3936234a8107e0ae14641d0a4c360716 | 2bab1445288074766a727cd77cb126c90450e201 | refs/heads/master | 2021-03-15T18:59:49.541446 | 2020-12-16T23:55:56 | 2020-12-16T23:55:56 | 246,873,374 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,598 | h | /*
==============================================================================
This file was auto-generated!
==============================================================================
*/
#pragma once
#include "../../JuceLibraryCode/JuceHeader.h"
#include "../AudioGraph/AudioGraph.h"
#include "../GlobalDefines.h"
#include "../Data/DataHandler.h"
struct spectralPoint
{
float wavelength{0};
float flux{0};
float curX{0};
float curY{0};
};
class SpectrumPlotComponent : public Component
{
public:
SpectrumPlotComponent();
~SpectrumPlotComponent(){}
void paint(Graphics &g) override;
void resized() override;
void formatPlotAndRepaint();
void setSpectralPlotData(std::vector<RawData> &rawData)
{
spectralPlot.clear();
for(int i = 0; i < rawData.size(); i++)
{
spectralPoint sp;
sp.wavelength = rawData[i].wavelength;
sp.flux = rawData[i].flux;
spectralPlot.push_back(sp);
}
formatPlotAndRepaint();
}
void plotCenterAndWidth(int center1, int center2, int center3, int width)
{
xCenter1 = center1;
xCenter2 = center2;
xCenter3 = center3;
xWidth = width;
repaint();
}
private:
std::vector<spectralPoint> spectralPlot;
int xCenter1{0};
int xCenter2{0};
int xCenter3{0};
int xWidth{0};
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (SpectrumPlotComponent)
};
| [
"brian.hansen78@gmail.com"
] | brian.hansen78@gmail.com |
8008a00fd6638872d247796c7e8b4b2b5a034d58 | 016d77fd7e9b3587cd83fb11b805d748a11d2531 | /docs/cppprimer/part02/chapter08/src/0801.cpp | 5bb4c125d8fcd7e6e8e09c03dc1178b5dc438871 | [] | no_license | kadoyatsukasa/kadoyatsukasa.github.io | 3c88459438499abdbfd2106adc8887aca45d9404 | b765581d12962dcc2286eda994e5590907ee2dc9 | refs/heads/master | 2021-07-16T22:33:16.401357 | 2020-05-25T07:25:03 | 2020-05-25T07:25:03 | 165,992,723 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 489 | cpp | #include<iostream>
#include<string>
using std::istream;
using std::ostream;
using std::string;
using std::cout;
using std::cin;
using std::endl;
istream& get_stream(istream& stream){
string output;
while(!stream.eof())
std::getline(stream,output);
cout<<output;
stream.clear();
return stream;
}
int main(int argc, char const *argv[])
{
get_stream(cin);
// string output;
// std::getline(input,output);
// cout<<output;
return 0;
}
| [
"amaduesmozart@outlook.com"
] | amaduesmozart@outlook.com |
35dc56c8a3e85045ff6f241fda04126d1df5b9a0 | 39a1d46fdf2acb22759774a027a09aa9d10103ba | /inference-engine/tests/functional/plugin/cpu/single_layer_tests/pad.cpp | fb9cf3df0bb9f9a2b30a84f8afd783f88edcf44d | [
"Apache-2.0"
] | permissive | mashoujiang/openvino | 32c9c325ffe44f93a15e87305affd6099d40f3bc | bc3642538190a622265560be6d88096a18d8a842 | refs/heads/master | 2023-07-28T19:39:36.803623 | 2021-07-16T15:55:05 | 2021-07-16T15:55:05 | 355,786,209 | 1 | 3 | Apache-2.0 | 2021-06-30T01:32:47 | 2021-04-08T06:22:16 | C++ | UTF-8 | C++ | false | false | 12,033 | cpp | // Copyright (C) 2018-2021 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
//
#include <shared_test_classes/single_layer/pad.hpp>
#include "test_utils/cpu_test_utils.hpp"
using namespace InferenceEngine;
using namespace CPUTestUtils;
namespace CPULayerTestsDefinitions {
typedef std::tuple<
LayerTestsDefinitions::padLayerTestParamsSet,
CPUSpecificParams
> padLayerCPUTestParamsSet;
class PadLayerCPUTest : public testing::WithParamInterface<padLayerCPUTestParamsSet>,
public LayerTestsUtils::LayerTestsCommon, public CPUTestsBase {
public:
static std::string getTestCaseName(testing::TestParamInfo<padLayerCPUTestParamsSet> obj) {
LayerTestsDefinitions::padLayerTestParamsSet basicParamsSet;
CPUSpecificParams cpuParams;
std::tie(basicParamsSet, cpuParams) = obj.param;
std::ostringstream result;
result << LayerTestsDefinitions::PadLayerTest::getTestCaseName(testing::TestParamInfo<LayerTestsDefinitions::padLayerTestParamsSet>(
basicParamsSet, 0));
result << CPUTestsBase::getTestCaseName(cpuParams);
return result.str();
}
protected:
void SetUp() override {
LayerTestsDefinitions::padLayerTestParamsSet basicParamsSet;
CPUSpecificParams cpuParams;
std::tie(basicParamsSet, cpuParams) = this->GetParam();
std::tie(inFmts, outFmts, priority, selectedType) = cpuParams;
InferenceEngine::SizeVector inputShape;
std::vector<int64_t> padsBegin, padsEnd;
float argPadValue;
ngraph::helpers::PadMode padMode;
InferenceEngine::Precision netPrecision;
std::tie(padsBegin, padsEnd, argPadValue, padMode, netPrecision, inPrc, outPrc, inLayout, inputShape, targetDevice) =
basicParamsSet;
inPrc = outPrc = netPrecision;
selectedType = std::string("ref_") + netPrecision.name();
auto ngPrc = FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(netPrecision);
auto params = ngraph::builder::makeParams(ngPrc, {inputShape});
auto paramOuts = ngraph::helpers::convert2OutputVector(
ngraph::helpers::castOps2Nodes<ngraph::opset3::Parameter>(params));
auto pad = ngraph::builder::makePad(paramOuts[0], padsBegin, padsEnd, argPadValue, padMode);
pad->get_rt_info() = getCPUInfo();
ngraph::ResultVector results{std::make_shared<ngraph::opset3::Result>(pad)};
function = std::make_shared<ngraph::Function>(results, params, "pad");
}
};
TEST_P(PadLayerCPUTest, CompareWithRefs) {
SKIP_IF_CURRENT_TEST_IS_DISABLED()
Run();
CheckPluginRelatedResults(executableNetwork, "Pad");
}
namespace {
const auto cpuParams_nChw16c = CPUSpecificParams {{nChw16c}, {nChw16c}, {}, {}};
const auto cpuParams_nCdhw16c = CPUSpecificParams {{nCdhw16c}, {nCdhw16c}, {}, {}};
const auto cpuParams_nChw8c = CPUSpecificParams {{nChw8c}, {nChw8c}, {}, {}};
const auto cpuParams_nCdhw8c = CPUSpecificParams {{nCdhw8c}, {nCdhw8c}, {}, {}};
const auto cpuParams_nhwc = CPUSpecificParams {{nhwc}, {nhwc}, {}, {}};
const auto cpuParams_ndhwc = CPUSpecificParams {{ndhwc}, {ndhwc}, {}, {}};
const std::vector<InferenceEngine::Precision> inputPrecisions = {
InferenceEngine::Precision::FP32,
InferenceEngine::Precision::BF16,
InferenceEngine::Precision::I8
};
const std::vector<float> argPadValue = {0.f, 1.f, 2.5f, -1.f};
const std::vector<ngraph::helpers::PadMode> padMode = {
ngraph::helpers::PadMode::EDGE,
ngraph::helpers::PadMode::REFLECT,
ngraph::helpers::PadMode::SYMMETRIC
};
const std::vector<std::vector<int64_t>> padsBegin4DConstBlocked = {{0, 0, 0, 0}, {0, 0, 1, 3}, {2, 16, 1, 0}, {0, 0, 2, 0}};
const std::vector<std::vector<int64_t>> padsEnd4DConstBlocked = {{0, 0, 0, 0}, {0, 0, 2, 1}, {2, 0, 0, 1}, {1, 32, 2, 0}};
const std::vector<std::vector<int64_t>> padsBegin4DBlocked = {{0, 0, 0, 0}, {0, 0, 1, 3}, {2, 0, 1, 0}, {0, 0, 2, 0}};
const std::vector<std::vector<int64_t>> padsEnd4DBlocked = {{0, 0, 0, 0}, {0, 0, 2, 1}, {2, 0, 0, 1}, {1, 0, 2, 0}};
const std::vector<std::vector<int64_t>> padsBegin4D = {{0, 0, 0, 0}, {0, 1, 1, 1}, {0, 2, 1, 0}, {0, 0, 0, 1}};
const std::vector<std::vector<int64_t>> padsEnd4D = {{0, 0, 0, 0}, {0, 2, 1, 1}, {0, 0, 2, 0}, {1, 1, 0, 0}};
const std::vector<CPUSpecificParams> CPUParams4DBlocked = {
cpuParams_nChw16c,
cpuParams_nChw8c,
};
const auto pad4DConstParamsBlocked = testing::Combine(
testing::ValuesIn(padsBegin4DConstBlocked),
testing::ValuesIn(padsEnd4DConstBlocked),
testing::ValuesIn(argPadValue),
testing::Values(ngraph::helpers::PadMode::CONSTANT),
testing::ValuesIn(inputPrecisions),
testing::Values(InferenceEngine::Precision::UNSPECIFIED),
testing::Values(InferenceEngine::Precision::UNSPECIFIED),
testing::Values(InferenceEngine::Layout::ANY),
testing::Values(std::vector<size_t>{3, 16, 5, 5}),
testing::Values(CommonTestUtils::DEVICE_CPU)
);
INSTANTIATE_TEST_SUITE_P(
smoke_CPUPad4DConstBlocked,
PadLayerCPUTest,
::testing::Combine(
pad4DConstParamsBlocked,
::testing::ValuesIn(CPUParams4DBlocked)),
PadLayerCPUTest::getTestCaseName
);
const auto pad4DConstParams = testing::Combine(
testing::ValuesIn(padsBegin4D),
testing::ValuesIn(padsEnd4D),
testing::ValuesIn(argPadValue),
testing::Values(ngraph::helpers::PadMode::CONSTANT),
testing::ValuesIn(inputPrecisions),
testing::Values(InferenceEngine::Precision::UNSPECIFIED),
testing::Values(InferenceEngine::Precision::UNSPECIFIED),
testing::Values(InferenceEngine::Layout::ANY),
testing::Values(std::vector<size_t>{3, 16, 5, 5}),
testing::Values(CommonTestUtils::DEVICE_CPU)
);
INSTANTIATE_TEST_SUITE_P(
smoke_CPUPad4DConst,
PadLayerCPUTest,
::testing::Combine(
pad4DConstParams,
::testing::Values(cpuParams_nhwc)),
PadLayerCPUTest::getTestCaseName
);
const auto pad4DParamsBlocked = testing::Combine(
testing::ValuesIn(padsBegin4DBlocked),
testing::ValuesIn(padsEnd4DBlocked),
testing::Values(0),
testing::ValuesIn(padMode),
testing::ValuesIn(inputPrecisions),
testing::Values(InferenceEngine::Precision::UNSPECIFIED),
testing::Values(InferenceEngine::Precision::UNSPECIFIED),
testing::Values(InferenceEngine::Layout::ANY),
testing::Values(std::vector<size_t>{3, 16, 10, 5}),
testing::Values(CommonTestUtils::DEVICE_CPU)
);
INSTANTIATE_TEST_SUITE_P(
smoke_CPUPad4DBlocked,
PadLayerCPUTest,
::testing::Combine(
pad4DParamsBlocked,
::testing::ValuesIn(CPUParams4DBlocked)),
PadLayerCPUTest::getTestCaseName
);
const auto pad4DParams = testing::Combine(
testing::ValuesIn(padsBegin4D),
testing::ValuesIn(padsEnd4D),
testing::Values(0),
testing::ValuesIn(padMode),
testing::ValuesIn(inputPrecisions),
testing::Values(InferenceEngine::Precision::UNSPECIFIED),
testing::Values(InferenceEngine::Precision::UNSPECIFIED),
testing::Values(InferenceEngine::Layout::ANY),
testing::Values(std::vector<size_t>{3, 16, 10, 5}),
testing::Values(CommonTestUtils::DEVICE_CPU)
);
INSTANTIATE_TEST_SUITE_P(
smoke_CPUPad4D,
PadLayerCPUTest,
::testing::Combine(
pad4DParams,
::testing::Values(cpuParams_nhwc)),
PadLayerCPUTest::getTestCaseName
);
const std::vector<std::vector<int64_t>> padsBegin5DConstBlocked = {{0, 0, 0, 0, 0}, {0, 0, 1, 1, 0}, {2, 32, 1, 1, 0}, {0, 0, 1, 3, 1}, {0, 0, 0, 1, 0}};
const std::vector<std::vector<int64_t>> padsEnd5DConstBlocked = {{0, 0, 0, 0, 0}, {1, 16, 1, 1, 0}, {0, 0, 0, 1, 0}, {0, 0, 0, 1, 1}, {0, 0, 1, 0, 1}};
const std::vector<std::vector<int64_t>> padsBegin5DBlocked = {{0, 0, 0, 0, 0}, {0, 0, 1, 1, 0}, {2, 0, 1, 1, 0}, {0, 0, 1, 3, 1}, {0, 0, 0, 1, 0}};
const std::vector<std::vector<int64_t>> padsEnd5DBlocked = {{0, 0, 0, 0, 0}, {1, 0, 1, 1, 0}, {0, 0, 0, 1, 0}, {0, 0, 0, 1, 1}, {0, 0, 1, 0, 1}};
const std::vector<std::vector<int64_t>> padsBegin5D = {{0, 0, 0, 0, 0}, {0, 0, 2, 0, 0}, {1, 1, 1, 1, 0}, {2, 0, 1, 0, 1}, {0, 2, 1, 3, 1}};
const std::vector<std::vector<int64_t>> padsEnd5D = {{0, 0, 0, 0, 0}, {0, 0, 1, 0, 0}, {1, 0, 1, 1, 2}, {2, 2, 0, 1, 0}, {1, 1, 2, 0, 1}};
const std::vector<CPUSpecificParams> CPUParams5DBlocked = {
cpuParams_nCdhw16c,
cpuParams_nCdhw8c,
};
const auto pad5DConstParamsBlocked = testing::Combine(
testing::ValuesIn(padsBegin5DConstBlocked),
testing::ValuesIn(padsEnd5DConstBlocked),
testing::ValuesIn(argPadValue),
testing::Values(ngraph::helpers::PadMode::CONSTANT),
testing::ValuesIn(inputPrecisions),
testing::Values(InferenceEngine::Precision::UNSPECIFIED),
testing::Values(InferenceEngine::Precision::UNSPECIFIED),
testing::Values(InferenceEngine::Layout::ANY),
testing::Values(std::vector<size_t>{3, 16, 5, 5, 5}),
testing::Values(CommonTestUtils::DEVICE_CPU)
);
INSTANTIATE_TEST_SUITE_P(
smoke_CPUPad5DConstBlocked,
PadLayerCPUTest,
::testing::Combine(
pad5DConstParamsBlocked,
::testing::ValuesIn(CPUParams5DBlocked)),
PadLayerCPUTest::getTestCaseName
);
const auto pad5DConstParams = testing::Combine(
testing::ValuesIn(padsBegin5D),
testing::ValuesIn(padsEnd5D),
testing::ValuesIn(argPadValue),
testing::Values(ngraph::helpers::PadMode::CONSTANT),
testing::ValuesIn(inputPrecisions),
testing::Values(InferenceEngine::Precision::UNSPECIFIED),
testing::Values(InferenceEngine::Precision::UNSPECIFIED),
testing::Values(InferenceEngine::Layout::ANY),
testing::Values(std::vector<size_t>{3, 16, 10, 5, 5}),
testing::Values(CommonTestUtils::DEVICE_CPU)
);
INSTANTIATE_TEST_SUITE_P(
smoke_CPUPad5DConst,
PadLayerCPUTest,
::testing::Combine(
pad5DConstParams,
::testing::Values(cpuParams_ndhwc)),
PadLayerCPUTest::getTestCaseName
);
const auto pad5DParamsBlocked = testing::Combine(
testing::ValuesIn(padsBegin5DBlocked),
testing::ValuesIn(padsEnd5DBlocked),
testing::Values(0),
testing::ValuesIn(padMode),
testing::ValuesIn(inputPrecisions),
testing::Values(InferenceEngine::Precision::UNSPECIFIED),
testing::Values(InferenceEngine::Precision::UNSPECIFIED),
testing::Values(InferenceEngine::Layout::ANY),
testing::Values(std::vector<size_t>{3, 16, 5, 5, 5}),
testing::Values(CommonTestUtils::DEVICE_CPU)
);
INSTANTIATE_TEST_SUITE_P(
smoke_CPUPad5DBlocked,
PadLayerCPUTest,
::testing::Combine(
pad5DParamsBlocked,
::testing::ValuesIn(CPUParams5DBlocked)),
PadLayerCPUTest::getTestCaseName
);
const auto pad5DParams = testing::Combine(
testing::ValuesIn(padsBegin5D),
testing::ValuesIn(padsEnd5D),
testing::Values(0),
testing::ValuesIn(padMode),
testing::ValuesIn(inputPrecisions),
testing::Values(InferenceEngine::Precision::UNSPECIFIED),
testing::Values(InferenceEngine::Precision::UNSPECIFIED),
testing::Values(InferenceEngine::Layout::ANY),
testing::Values(std::vector<size_t>{3, 16, 5, 5, 5}),
testing::Values(CommonTestUtils::DEVICE_CPU)
);
INSTANTIATE_TEST_SUITE_P(
smoke_CPUPad5D,
PadLayerCPUTest,
::testing::Combine(
pad5DParams,
::testing::Values(cpuParams_ndhwc)),
PadLayerCPUTest::getTestCaseName
);
} // namespace
} // namespace CPULayerTestsDefinitions
| [
"noreply@github.com"
] | mashoujiang.noreply@github.com |
b042abe6936a4a5abf3a9d0d7ce16f3177d1a356 | fdc60d1bb095629fc48487f09e235fa743150561 | /extensions/browser/guest_view/mime_handler_view/mime_handler_view_guest.h | a448bc2c2da52c6a364cd64bb93c19cfc641c1dd | [
"BSD-3-Clause"
] | permissive | Litt1er/chromium | befd054e926c74bbb34fea6244bb694ac20f7e7b | a76fca647bd07d649d6c896974ef1a11b62f307a | refs/heads/master | 2023-03-14T19:50:05.889711 | 2019-02-20T05:22:19 | 2019-02-20T05:22:19 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 6,950 | h | // Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef EXTENSIONS_BROWSER_GUEST_VIEW_MIME_HANDLER_VIEW_MIME_HANDLER_VIEW_GUEST_H_
#define EXTENSIONS_BROWSER_GUEST_VIEW_MIME_HANDLER_VIEW_MIME_HANDLER_VIEW_GUEST_H_
#include <memory>
#include <string>
#include "base/macros.h"
#include "base/memory/weak_ptr.h"
#include "components/guest_view/browser/guest_view.h"
#include "content/public/common/transferrable_url_loader.mojom.h"
#include "extensions/common/api/mime_handler.mojom.h"
#include "services/service_manager/public/cpp/binder_registry.h"
namespace content {
class WebContents;
struct ContextMenuParams;
struct StreamInfo;
} // namespace content
namespace extensions {
class MimeHandlerViewGuestDelegate;
// A container for a StreamHandle and any other information necessary for a
// MimeHandler to handle a resource stream.
class StreamContainer {
public:
StreamContainer(
std::unique_ptr<content::StreamInfo> stream,
int tab_id,
bool embedded,
const GURL& handler_url,
const std::string& extension_id,
content::mojom::TransferrableURLLoaderPtr transferrable_loader,
const GURL& original_url);
~StreamContainer();
// Aborts the stream.
void Abort(const base::Closure& callback);
base::WeakPtr<StreamContainer> GetWeakPtr();
content::mojom::TransferrableURLLoaderPtr TakeTransferrableURLLoader();
bool embedded() const { return embedded_; }
int tab_id() const { return tab_id_; }
GURL handler_url() const { return handler_url_; }
std::string extension_id() const { return extension_id_; }
const std::string& mime_type() const { return mime_type_; }
const GURL& original_url() const { return original_url_; }
const GURL& stream_url() const { return stream_url_; }
net::HttpResponseHeaders* response_headers() const {
return response_headers_.get();
}
private:
const std::unique_ptr<content::StreamInfo> stream_;
const bool embedded_;
const int tab_id_;
const GURL handler_url_;
const std::string extension_id_;
content::mojom::TransferrableURLLoaderPtr transferrable_loader_;
std::string mime_type_;
GURL original_url_;
GURL stream_url_;
scoped_refptr<net::HttpResponseHeaders> response_headers_;
base::WeakPtrFactory<StreamContainer> weak_factory_;
DISALLOW_COPY_AND_ASSIGN(StreamContainer);
};
class MimeHandlerViewGuest
: public guest_view::GuestView<MimeHandlerViewGuest> {
public:
static guest_view::GuestViewBase* Create(
content::WebContents* owner_web_contents);
static const char Type[];
// BrowserPluginGuestDelegate overrides.
bool CanUseCrossProcessFrames() override;
bool CanBeEmbeddedInsideCrossProcessFrames() override;
content::RenderWidgetHost* GetOwnerRenderWidgetHost() override;
content::SiteInstance* GetOwnerSiteInstance() override;
void SetEmbedderFrame(int process_id, int routing_id);
void SetBeforeUnloadController(
mime_handler::BeforeUnloadControlPtrInfo pending_before_unload_control);
void SetPluginCanSave(bool can_save) { plugin_can_save_ = can_save; }
// Asks the plugin to do save.
bool PluginDoSave();
content::RenderFrameHost* GetEmbedderFrame() const;
protected:
explicit MimeHandlerViewGuest(content::WebContents* owner_web_contents);
~MimeHandlerViewGuest() override;
private:
friend class TestMimeHandlerViewGuest;
// GuestViewBase implementation.
const char* GetAPINamespace() const final;
int GetTaskPrefix() const final;
void CreateWebContents(const base::DictionaryValue& create_params,
WebContentsCreatedCallback callback) override;
void DidAttachToEmbedder() override;
void DidInitialize(const base::DictionaryValue& create_params) final;
void EmbedderFullscreenToggled(bool entered_fullscreen) final;
bool ZoomPropagatesFromEmbedderToGuest() const final;
bool ShouldDestroyOnDetach() const final;
// WebContentsDelegate implementation.
content::WebContents* OpenURLFromTab(
content::WebContents* source,
const content::OpenURLParams& params) final;
void NavigationStateChanged(content::WebContents* source,
content::InvalidateTypes changed_flags) final;
bool HandleContextMenu(const content::ContextMenuParams& params) final;
bool PreHandleGestureEvent(content::WebContents* source,
const blink::WebGestureEvent& event) final;
content::JavaScriptDialogManager* GetJavaScriptDialogManager(
content::WebContents* source) final;
bool GuestSaveFrame(content::WebContents* guest_web_contents) final;
bool SaveFrame(const GURL& url, const content::Referrer& referrer) final;
void OnRenderFrameHostDeleted(int process_id, int routing_id) final;
void EnterFullscreenModeForTab(
content::WebContents* web_contents,
const GURL& origin,
const blink::WebFullscreenOptions& options) override;
void ExitFullscreenModeForTab(content::WebContents*) override;
bool IsFullscreenForTabOrPending(
const content::WebContents* web_contents) const override;
bool ShouldCreateWebContents(
content::WebContents* web_contents,
content::RenderFrameHost* opener,
content::SiteInstance* source_site_instance,
int32_t route_id,
int32_t main_frame_route_id,
int32_t main_frame_widget_route_id,
content::mojom::WindowContainerType window_container_type,
const GURL& opener_url,
const std::string& frame_name,
const GURL& target_url,
const std::string& partition_id,
content::SessionStorageNamespace* session_storage_namespace) override;
// Updates the fullscreen state for the guest. Returns whether the change
// needs to be propagated to the embedder.
bool SetFullscreenState(bool is_fullscreen);
// content::WebContentsObserver implementation.
void DocumentOnLoadCompletedInMainFrame() final;
void OnInterfaceRequestFromFrame(
content::RenderFrameHost* render_frame_host,
const std::string& interface_name,
mojo::ScopedMessagePipeHandle* interface_pipe) final;
void ReadyToCommitNavigation(
content::NavigationHandle* navigation_handle) final;
void FuseBeforeUnloadControl(
mime_handler::BeforeUnloadControlRequest request);
std::unique_ptr<MimeHandlerViewGuestDelegate> delegate_;
std::unique_ptr<StreamContainer> stream_;
int embedder_frame_process_id_;
int embedder_frame_routing_id_;
int embedder_widget_routing_id_;
service_manager::BinderRegistry registry_;
bool is_guest_fullscreen_ = false;
bool is_embedder_fullscreen_ = false;
bool plugin_can_save_ = false;
mime_handler::BeforeUnloadControlPtrInfo pending_before_unload_control_;
DISALLOW_COPY_AND_ASSIGN(MimeHandlerViewGuest);
};
} // namespace extensions
#endif // EXTENSIONS_BROWSER_GUEST_VIEW_MIME_HANDLER_VIEW_MIME_HANDLER_VIEW_GUEST_H_
| [
"commit-bot@chromium.org"
] | commit-bot@chromium.org |
70483ffb8f73f62f172c9d33bb4b909ff4e93659 | 3b445422416dfab14bca047a4ecc1a98ddfdc19d | /caffe-layers/interchange_layer.cpp | b05d0e3aab89b8c7d4b32f12d22f2e2636ecae38 | [] | no_license | Jensen-Su/memos | 77f2ec882894a6c4c85fb808944bf12fb4793603 | e9d9725a2317221dbcafee92bdb3dfbc724009d4 | refs/heads/master | 2021-01-18T19:11:55.394203 | 2017-09-04T00:08:59 | 2017-09-04T00:08:59 | 86,891,036 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,028 | cpp | #include <vector>
#include "caffe/layers/interchange_layer.hpp"
namespace caffe{
template <typename Dtype>
void InterchangeLayer<Dtype>::LayerSetUp(const vector<Blob<Dtype>*> &bottom,
const vector<Blob<Dtype>*> &top){
CHECK_NE(bottom[0], top[0]) << this->type() << " Layer does not allow in-place computation.";
CHECK_EQ(bottom[0]->num_axes(), 4) << "Number of axes of bottom blob must be 4.";
}
template <typename Dtype>
void InterchangeLayer<Dtype>::Reshape(const vector<Blob<Dtype>*> &bottom,
const vector <Blob<Dtype>*> &top){
const int num = bottom[0]->shape()[0];
const int channels = bottom[0]->shape()[1];
const int dim = bottom[0]->shape()[2] * bottom[0]->shape()[3];
vector<int> top_shape(4);
top_shape[0] = num;
top_shape[1] = dim;
int height = this->layer_param_.interchange_param().height();
int width = this->layer_param_.interchange_param().width();
CHECK_NE((width <= 0) && (height<= 0), true) << "height or width, at least one must be set "
<< "for Layer " << this->type();
if (height <= 0) height = channels / width;
else if(width <= 0) width = channels / height;
CHECK_EQ(width * height, channels) << "height * width != channels in Layer "
<< this->type();
top_shape[2] = height;
top_shape[3] = width;
top[0]->Reshape(top_shape);
}
template <typename Dtype>
void InterchangeLayer<Dtype>::Forward_cpu(const vector<Blob<Dtype>*> &bottom,
const vector<Blob<Dtype>*> &top){
const Dtype* bottom_data = bottom[0]->cpu_data();
Dtype* top_data = top[0]->mutable_cpu_data();
int num = bottom[0]->shape()[0];
int channels = bottom[0]->shape(1);
int dim = bottom[0]->shape(2) * bottom[0]->shape(3);
for(int n = 0; n < num; ++n){
for(int c = 0; c < channels; ++c){
for(int d = 0; d < dim; ++d){
top_data[d * channels + c] = bottom_data[c * dim + d];
}
top_data += dim * channels;
bottom_data += dim * channels;
}
}
}
template <typename Dtype>
void InterchangeLayer<Dtype>::Backward_cpu(const vector<Blob<Dtype>*> &top,
const vector<bool> &propagate_down, const vector<Blob<Dtype>*> &bottom){
const Dtype* top_diff = top[0]->cpu_diff();
Dtype* bottom_diff = bottom[0]->mutable_cpu_diff();
int num = bottom[0]->shape()[0];
int channels = bottom[0]->shape(1);
int dim = bottom[0]->shape(2) * bottom[0]->shape(3);
if(this->param_propagate_down_[0]){
for(int n = 0; n < num; ++n){
for(int c = 0; c < channels; ++c){
for(int d = 0; d < dim; ++d){
bottom_diff[c * dim + d] = top_diff[d * channels + c];
}
bottom_diff += dim * channels;
top_diff += dim * channels;
}
}
}
}
#ifdef CPU_ONLY
STUB_GPU(InterchangeLayer);
#endif
INSTANTIATE_CLASS(InterchangeLayer);
REGISTER_LAYER_CLASS(Interchange);
} //namespace caffe
| [
"jcsu14@fudan.edu.cn"
] | jcsu14@fudan.edu.cn |
c6446fb257df195598a3c92aea4fd310efdc841b | 28a61a4e042e03ff6edf6b323534dc0e3eeaeceb | /tinyxml/BookListXml.h | 05382557c583595f36d10ccaf2d650da0dd250cc | [] | no_license | no7dw/btpd | 964cdedd68dc85088dd42c4f2f507cf125c5de78 | 49998e41dc6293139e59b04beaa3bef913a37426 | refs/heads/master | 2020-04-14T09:05:17.731295 | 2014-03-24T16:47:13 | 2014-03-24T16:47:13 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 740 | h | #ifndef __BOOK_LIST_XML_H
#define __BOOK_LIST_XML_H
#include "XXml.h"
//#include "../deq/deq.h"
#include "../client.h"
#include <deque>
typedef deque<CourseInfo> DQCI;
//same BookList 3 obj
//no static
class BookListXml : public XXml
{
public:
BookListXml();
//BookListXml();
~BookListXml();
private:
DQCI QCI;
int BookListSize;
private:
int InitBookList();
/*TiXmlDocument *myDocument;
char m_XmlFilePath[100];
TiXmlElement *pFirstBookElem, *pLastBookElem, *pRootElement;*/
public:
int LoadXml(const char *XmlFilePath);
DQCI* GetBookListQueue();
CourseInfo *GetCourseInfo(const string &CourseID);
int AddItem(const CourseInfo &CI);
int RemoveItem(const string &CourseID);
int GetListSize();
};
#endif | [
"no7david@gmail.com"
] | no7david@gmail.com |
43ff44158934beee52ab116fc0b7495c7a361183 | 5e695328e0f896c76620ac04260dbafc59abaa5e | /main.cpp | 60b31cdef87864bc36ab1be7b7a6e576f3a30ef6 | [] | no_license | OneStopProgramming/C-Tutorial-9 | c8d84296077cd54305a9218859b74688d02b227c | e8dac28e03657a5925426697a60ce0bef5ac00be | refs/heads/master | 2021-01-13T01:50:57.716734 | 2014-08-11T21:06:06 | 2014-08-11T21:06:06 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 961 | cpp | #include <cstdlib>
#include <iostream>
#include <string>
using namespace std;
void whileLoop();
void doWhileLoop();
void forLoop();
int main(int argc, char *argv[])
{
char x[] = "Hello world!";
for(int index =0; index < sizeof(x); index++)
{
cout << x[index];
}
char z;
cin >> z;
return 0;
}
void whileLoop()
{
int x = 10;
int i = 0;
while(x > 0)
{
if(x%2 == 0) //If x is divisible by 2 (ie no remainder)
{
i+=2; //i <= i + 2
}
else
{
i*=2; //i <= i * 2
}
cout << i << endl; //Print i
x--; //Decrease x by 1
}
}
void doWhileLoop()
{
int x = 0;
do{
x--;
cout << x << endl;
}while(x > 0);
}
void forLoop()
{
for(int x=10, i=0; x > 0; x--, i++)
{
cout << i << endl;
}
}
| [
"git@kevinjdolan.com"
] | git@kevinjdolan.com |
d8db3e7e9deb3e70030a1093c804a5d9bba11600 | 88e9d9a13b16aefca34d590a9c5eaeb28b16cb33 | /ccms/catkin_ws/devel/include/rosapi/GetActionServersRequest.h | 94fd1b8acc4aaa11fc26b6a40502c0cf19ecb5c6 | [] | no_license | hdb1301040027/ccms | f4d97ae0b80984297c646516a07ab543ca2009e9 | f105265a2d2dd8b0f74d54535055a4bf13883258 | refs/heads/master | 2022-12-12T07:09:48.660486 | 2019-08-02T13:23:30 | 2019-08-02T13:23:30 | 200,236,199 | 1 | 0 | null | 2022-12-04T05:46:42 | 2019-08-02T13:06:23 | JavaScript | UTF-8 | C++ | false | false | 4,841 | h | // Generated by gencpp from file rosapi/GetActionServersRequest.msg
// DO NOT EDIT!
#ifndef ROSAPI_MESSAGE_GETACTIONSERVERSREQUEST_H
#define ROSAPI_MESSAGE_GETACTIONSERVERSREQUEST_H
#include <string>
#include <vector>
#include <map>
#include <ros/types.h>
#include <ros/serialization.h>
#include <ros/builtin_message_traits.h>
#include <ros/message_operations.h>
namespace rosapi
{
template <class ContainerAllocator>
struct GetActionServersRequest_
{
typedef GetActionServersRequest_<ContainerAllocator> Type;
GetActionServersRequest_()
{
}
GetActionServersRequest_(const ContainerAllocator& _alloc)
{
(void)_alloc;
}
typedef boost::shared_ptr< ::rosapi::GetActionServersRequest_<ContainerAllocator> > Ptr;
typedef boost::shared_ptr< ::rosapi::GetActionServersRequest_<ContainerAllocator> const> ConstPtr;
}; // struct GetActionServersRequest_
typedef ::rosapi::GetActionServersRequest_<std::allocator<void> > GetActionServersRequest;
typedef boost::shared_ptr< ::rosapi::GetActionServersRequest > GetActionServersRequestPtr;
typedef boost::shared_ptr< ::rosapi::GetActionServersRequest const> GetActionServersRequestConstPtr;
// constants requiring out of line definition
template<typename ContainerAllocator>
std::ostream& operator<<(std::ostream& s, const ::rosapi::GetActionServersRequest_<ContainerAllocator> & v)
{
ros::message_operations::Printer< ::rosapi::GetActionServersRequest_<ContainerAllocator> >::stream(s, "", v);
return s;
}
} // namespace rosapi
namespace ros
{
namespace message_traits
{
// BOOLTRAITS {'IsFixedSize': True, 'IsMessage': True, 'HasHeader': False}
// {'rosapi': ['/home/ubuntu/ccms/catkin_ws/src/rosbridge_suite/rosapi/msg']}
// !!!!!!!!!!! ['__class__', '__delattr__', '__dict__', '__doc__', '__eq__', '__format__', '__getattribute__', '__hash__', '__init__', '__module__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__', '_parsed_fields', 'constants', 'fields', 'full_name', 'has_header', 'header_present', 'names', 'package', 'parsed_fields', 'short_name', 'text', 'types']
template <class ContainerAllocator>
struct IsFixedSize< ::rosapi::GetActionServersRequest_<ContainerAllocator> >
: TrueType
{ };
template <class ContainerAllocator>
struct IsFixedSize< ::rosapi::GetActionServersRequest_<ContainerAllocator> const>
: TrueType
{ };
template <class ContainerAllocator>
struct IsMessage< ::rosapi::GetActionServersRequest_<ContainerAllocator> >
: TrueType
{ };
template <class ContainerAllocator>
struct IsMessage< ::rosapi::GetActionServersRequest_<ContainerAllocator> const>
: TrueType
{ };
template <class ContainerAllocator>
struct HasHeader< ::rosapi::GetActionServersRequest_<ContainerAllocator> >
: FalseType
{ };
template <class ContainerAllocator>
struct HasHeader< ::rosapi::GetActionServersRequest_<ContainerAllocator> const>
: FalseType
{ };
template<class ContainerAllocator>
struct MD5Sum< ::rosapi::GetActionServersRequest_<ContainerAllocator> >
{
static const char* value()
{
return "d41d8cd98f00b204e9800998ecf8427e";
}
static const char* value(const ::rosapi::GetActionServersRequest_<ContainerAllocator>&) { return value(); }
static const uint64_t static_value1 = 0xd41d8cd98f00b204ULL;
static const uint64_t static_value2 = 0xe9800998ecf8427eULL;
};
template<class ContainerAllocator>
struct DataType< ::rosapi::GetActionServersRequest_<ContainerAllocator> >
{
static const char* value()
{
return "rosapi/GetActionServersRequest";
}
static const char* value(const ::rosapi::GetActionServersRequest_<ContainerAllocator>&) { return value(); }
};
template<class ContainerAllocator>
struct Definition< ::rosapi::GetActionServersRequest_<ContainerAllocator> >
{
static const char* value()
{
return "\n\
";
}
static const char* value(const ::rosapi::GetActionServersRequest_<ContainerAllocator>&) { return value(); }
};
} // namespace message_traits
} // namespace ros
namespace ros
{
namespace serialization
{
template<class ContainerAllocator> struct Serializer< ::rosapi::GetActionServersRequest_<ContainerAllocator> >
{
template<typename Stream, typename T> inline static void allInOne(Stream&, T)
{}
ROS_DECLARE_ALLINONE_SERIALIZER
}; // struct GetActionServersRequest_
} // namespace serialization
} // namespace ros
namespace ros
{
namespace message_operations
{
template<class ContainerAllocator>
struct Printer< ::rosapi::GetActionServersRequest_<ContainerAllocator> >
{
template<typename Stream> static void stream(Stream&, const std::string&, const ::rosapi::GetActionServersRequest_<ContainerAllocator>&)
{}
};
} // namespace message_operations
} // namespace ros
#endif // ROSAPI_MESSAGE_GETACTIONSERVERSREQUEST_H
| [
"1771913824@qq.com"
] | 1771913824@qq.com |
19c524d556ddd4bc1b35ae2f010574fb00d871b3 | ddcc472c56ba2c151ab8425abc9733ab05c8438b | /Tarea de Logica/Ejercicio 3 en C++.cpp | ee29deda11637be2787cac503bfb44a188f6f4dc | [] | no_license | Kevinoob-design/Old-Progaming-Learning | 5ee80c42cec48b8189d66523209be074f6dad361 | 01730fdcfa12bf85c85bfa7c05ddb2dc264458a1 | refs/heads/master | 2022-03-20T21:27:38.381191 | 2019-12-12T18:38:38 | 2019-12-12T18:38:38 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 11,626 | cpp | //Realizar un programa que dado 8 valores capturados determine la variable que tenga el numero menor, evaluando con If anidados compuestos.
#include<iostream>
#include <stdlib.h>
using namespace std;
int main(){
cout << "Introduzca 8 numeros. El programa comparara todos y escogera el mayor\n" << endl;
int a, b, c, d, e, f, g, h;
cout << "ingrese el valor de A: "; cin >> a;
cout << "ingrese el valor de B: "; cin >> b;
cout << "ingrese el valor de C: "; cin >> c;
cout << "ingrese el valor de D: "; cin >> d;
cout << "ingrese el valor de E: "; cin >> e;
cout << "ingrese el valor de F: "; cin >> f;
cout << "ingrese el valor de G: "; cin >> g;
cout << "ingrese el valor de H: "; cin >> h;
cout << "\n" << endl;
if (a>b) {
if (a>c) {
if (a>d) {
if (a>e) {
if (a>f) {
if (a>g) {
if (a>h) {
cout << "El mayor es " << a << endl;
} else {
cout << "El mayor es " << h << endl;
}
} else {
if (g>h) {
cout << "El mayor es " << g << endl;
} else {
cout << "El mayor es " << h << endl;
}
}
} else {
if (f>g) {
if (f>h) {
cout << "El mayor es " << f << endl;
} else {
cout << "El mayor es " << h << endl;
}
} else {
if (g>h) {
cout << "El mayor es " << g << endl;
} else {
cout << "El mayor es " << h << endl;
}
}
}
} else {
if (e>f) {
if (e>g) {
if (e>h) {
cout << "El mayor es " << e << endl;
} else {
cout << "El mayor es " << h << endl;
}
} else {
if (g>h) {
cout << "El mayor es " << g << endl;
} else {
cout << "El mayor es " << h << endl;
}
}
} else {
if (f>g) {
if (f>h) {
cout << "El mayor es " << f << endl;
} else {
cout << "El mayor es " << h << endl;
}
} else {
if (g>h) {
cout << "El mayor es " << g << endl;
} else {
cout << "El mayor es " << h << endl;
}
}
}
}
} else {
if (d>e) {
if (d>f) {
if (d>g) {
if (d>h) {
cout << "El mayor es " << d << endl;
} else {
cout << "El mayor es " << h << endl;
}
} else {
if (g>h) {
cout << "El mayor " << g << endl;
} else {
cout << "El mayor es " << h << endl;
}
}
} else {
if (f>g) {
if (f>h) {
cout << "El mayor es " << f << endl;
} else {
cout << "El mayor es " << h << endl;
}
} else {
if (g>h) {
cout << "El mayor es " << g << endl;
} else {
cout << "El mayor es " << h << endl;
}
}
}
} else {
if (e>f) {
if (e>g) {
if (e>h) {
cout << "El mayor es " << e << endl;
} else {
cout << "El mayor es " << h << endl;
}
} else {
if (g>h) {
cout << "El mayor es " << g << endl;
} else {
cout << "El mayor es " << h << endl;
}
}
} else {
if (f>g) {
if (f>h) {
cout << "El mayor es " << f << endl;
} else {
cout << "El mayor es " << h << endl;
}
} else {
if (g>h) {
cout << "El mayor " << g << endl;
} else {
cout << "El mayor es " << h << endl;
}
}
}
}
}
} else {
if (c>d) {
if (c>e) {
if (c>f) {
if (c>g) {
if (c>h) {
cout << "El mayor es " << c << endl;
} else {
cout << "El mayor es " << h << endl;
}
} else {
if (g>h) {
cout << "El mayor es " << g << endl;
} else {
cout << "El mayor es " << h << endl;
}
}
} else {
if (f>g) {
if (f>h) {
cout << "El mayor es " << f << endl;
} else {
cout << "El mayor es " << h << endl;
}
} else {
if (g>h) {
cout << "El mayor es " << g << endl;
} else {
cout << "El mayor es " << h << endl;
}
}
}
} else {
if (e>f) {
if (e>g) {
if (e>h) {
cout << "El mayor es " << e << endl;
} else {
cout << "El mayor es " << h << endl;
}
} else {
if (g>h) {
cout << "El mayor es " << g << endl;
} else {
cout << "El mayor es " << h << endl;
}
}
} else {
if (f>g) {
if (f>h) {
cout << "El mayor es " << f << endl;
} else {
cout << "El mayor es " << h << endl;
}
} else {
if (g>h) {
cout << "El mayor es " << g << endl;
} else {
cout << "El mayor es " << h << endl;
}
}
}
}
} else {
if (d>e) {
if (d>f) {
if (d>g) {
if (d>h) {
cout << "El mayor es " << d << endl;
} else {
cout << "El mayor es " << h << endl;
}
} else {
if (g>h) {
cout << "El mayor es " << g << endl;
} else {
cout << "El mayor es " << h << endl;
}
}
} else {
if (f>g) {
if (f>h) {
cout << "El mayor es " << f << endl;
} else {
cout << "El mayor es " << h << endl;
}
} else {
if (g>h) {
cout << "El mayor es " << g << endl;
} else {
cout << "El mayor es " << h << endl;
}
}
}
} else {
if (e>f) {
if (e>g) {
if (e>h) {
cout << "El mayor es " << e << endl;
} else {
cout << "El mayor es " << h << endl;
}
} else {
if (g>h) {
cout << "El mayor es " << g << endl;
} else {
cout << "El mayor es " << h << endl;
}
}
} else {
if (f>g) {
if (f>h) {
cout << "El mayor es " << f << endl;
} else {
cout << "El mayor es " << h << endl;
}
} else {
if (g>h) {
cout << "El mayor es " << g << endl;
} else {
cout << "El mayor es " << h << endl;
}
}
}
}
}
}
} else {
if (b>c) {
if (b>d) {
if (b>e) {
if (b>f) {
if (b>g) {
if (b>h) {
cout << "El mayor es " << b << endl;
} else {
cout << "El mayor es " << h << endl;
}
} else {
if (g>h) {
cout << "El mayor es " << g << endl;
} else {
cout << "El mayor es " << h << endl;
}
}
} else {
if (f>g) {
if (f>h) {
cout << "El mayor es " << f << endl;
} else {
cout << "El mayor es " << h << endl;
}
} else {
if (g>h) {
cout << "El mayor es " << g << endl;
} else {
cout << "El mayor es " << h << endl;
}
}
}
} else {
if (e>f) {
if (e>g) {
if (e>h) {
cout << "El mayor es " << e << endl;
} else {
cout << "El mayor es " << h << endl;
}
} else {
if (g>h) {
cout << "El mayor es " << g << endl;
} else {
cout << "El mayor es " << h << endl;
}
}
} else {
if (f>g) {
if (f>h) {
cout << "El mayor es " << f << endl;
} else {
cout << "El mayor es " << h << endl;
}
} else {
if (g>h) {
cout << "El mayor es " << g << endl;
} else {
cout << "El mayor es " << h << endl;
}
}
}
}
} else {
if (d>e) {
if (d>f) {
if (d>g) {
if (d>h) {
cout << "El mayor es " << d << endl;
} else {
cout << "El mayor es " << h << endl;
}
} else {
if (g>h) {
cout << "El mayor es " << d << endl;
} else {
cout << "El mayor es " << h << endl;
}
}
} else {
if (f>g) {
if (f>h) {
cout << "El mayor es " << f << endl;
} else {
cout << "El mayor es " << h << endl;
}
} else {
if (g>h) {
cout << "El mayor es " << g << endl;
} else {
cout << "El mayor es " << h << endl;
}
}
}
} else {
if (e>f) {
if (e>g) {
if (e>h) {
cout << "El mayor es " << g << endl;
} else {
cout << "El mayor es " << h << endl;
}
} else {
if (g>h) {
cout << "El mayor es " << g << endl;
} else {
cout << "El mayor es " << h << endl;
}
}
} else {
if (f>g) {
if (f>h) {
cout << "El mayor es " << f << endl;
} else {
cout << "El mayor es " << h << endl;
}
} else {
if (g>h) {
cout << "El mayor es " << g << endl;
} else {
cout << "El mayor es " << h << endl;
}
}
}
}
}
} else {
if (c>d) {
if (c>e) {
if (c>f) {
if (c>g) {
if (c>h) {
cout << "El mayor es " << c << endl;
} else {
cout << "El mayor es " << h << endl;
}
} else {
if (g>h) {
cout << "El mayor es " << g << endl;
} else {
cout << "El mayor es " << h << endl;
}
}
} else {
if (f>g) {
if (f>h) {
cout << "El mayor es " << f << endl;
} else {
cout << "El mayor es " << h << endl;
}
} else {
if (g>h) {
cout << "El mayor es " << g << endl;
} else {
cout << "El mayor es " << h << endl;
}
}
}
} else {
if (e>f) {
if (e>g) {
if (e>h) {
cout << "El mayor es " << e << endl;
} else {
cout << "El mayor es " << h << endl;
}
} else {
if (g>h) {
cout << "El mayor es " << g << endl;
} else {
cout << "El mayor es " << h << endl;
}
}
} else {
if (f>g) {
if (f>h) {
cout << "El mayor es " << f << endl;
} else {
cout << "El mayor es " << h << endl;
}
} else {
if (g>h) {
cout << "El mayor es " << g << endl;
} else {
cout << "El mayor es " << h << endl;
}
}
}
}
} else {
if (c>e) {
if (c>f) {
if (c>g) {
if (c>h) {
cout << "El mayor es " << c << endl;
} else {
cout << "El mayor es " << h << endl;
}
} else {
if (g>h) {
cout << "El mayor es " << g << endl;
} else {
cout << "El mayor es " << h << endl;
}
}
} else {
if (f>g) {
if (f>h) {
cout << "El mayor es " << f << endl;
} else {
cout << "El mayor es " << h << endl;
}
} else {
if (g>h) {
cout << "El mayor es " << g << endl;
} else {
cout << "El mayor es " << h << endl;
}
}
}
} else {
if (e>f) {
if (e>g) {
if (e>h) {
cout << "El mayor es " << e << endl;
} else {
cout << "El mayor es " << h << endl;
}
} else {
if (g>h) {
cout << "El mayor es " << g << endl;
} else {
cout << "El mayor es " << h << endl;
}
}
} else {
if (f>g) {
if (f>h) {
cout << "El mayor es " << f << endl;
} else {
cout << "El mayor es " << h << endl;
}
} else {
if (g>h) {
cout << "El mayor es " << g << endl;
} else {
cout << "EL mayor es " << h << endl;
}
}
}
}
}
}
}
system("pause");
return 0;
}
| [
"52089890+Kevinoob-design@users.noreply.github.com"
] | 52089890+Kevinoob-design@users.noreply.github.com |
fe008c65e8c9c981af66233a228797082a704c25 | 187cec85c2a2984be61e7534ea77199015e03810 | /RpcServer/Server/Service.cpp | ef8fe6bc23bab070a25315d2138b2d2049c90cb3 | [] | no_license | yueqianlongma/RpcLearning | 268f95195f59ffd184b902274e9ecc10bfe9e4ee | b44f0f7a04ea02ebb495d89dbc9bde379bffeb75 | refs/heads/master | 2023-03-12T02:54:15.538785 | 2021-03-03T09:40:48 | 2021-03-03T09:40:48 | 344,073,213 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 941 | cpp |
#include"Service.h"
#include<RpcServer/common.h>
#include<RpcServer/Exception.h>
#include<RpcServer/RpcError.h>
using namespace rpc;
void Service::callProcedureReturn(const std::string& methodName,
json::Value& request,
const RpcDoneCallback& done)
{
auto it = procedureReturn_.find(methodName);
if (it == procedureReturn_.end()) {
throw RequestException(RPC_METHOD_NOT_FOUND,
request["id"],
"method not found");
}
it->second->invoke(request, done);
};
void Service::callProcedureNotify(const std::string& methodName, json::Value& request)
{
auto it = procedureNotfiy_.find(methodName);
if (it == procedureNotfiy_.end()) {
throw NotifyException(RPC_METHOD_NOT_FOUND,
"method not found");
}
it->second->invoke(request);
}; | [
"yydw.mjl@foxmail.com"
] | yydw.mjl@foxmail.com |
d1b07b26c0630b91b08fd0ccfdaa688bbb03e355 | 7c8a5f62a335d5108fd95c62f3c6aaf15cae0b7b | /mathematical/modDivide.cpp | ec9dfa484d561e2c5b284da1f28e7b553fad2714 | [] | no_license | pratiksaha/practice | a6809006fedeee982e823b3660c7673f2c77379a | 3b3705d7738dbeddc20c0482a6bce07028ddbafe | refs/heads/master | 2021-01-13T17:25:39.678405 | 2017-03-15T21:40:16 | 2017-03-15T21:40:16 | 24,746,662 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 780 | cpp | //modular division
#include<bits/stdc++.h>
using namespace std;
int gcdExtended(int a, int b, int *x, int *y) {
if (a == 0) {
*x = 0, *y = 1;
return b;
}
int x1, y1;
int gcd = gcdExtended(b%a, a, &x1, &y1);
*x = y1 - (b/a) * x1;
*y = x1;
return gcd;
}
int modInverse(int b, int m) {
int x, y;
int g = gcdExtended(b, m, &x, &y);
if (g != 1)
return -1;
return (x%m + m) % m;
}
void modDivide(int a, int b, int m) {
cout<<"Value of c such that ("<<b<<"*c)%"<<m<<" = "<<a<<"%"<<m<<" is ";
a = a % m;
int inv = modInverse(b, m);
if (inv == -1)
cout<<"Not Defined\n";
else
cout<<(inv*a)%m<<endl;
}
int main() {
int a = 8, b = 3, m = 5;
modDivide(a, b, m);
return 0;
}
| [
"pratiksaha89@gmail.com"
] | pratiksaha89@gmail.com |
102a548c91f9850b4b8d3f48d288d912427be63a | 2003f5c7f68df79e273624a380e15920bb66eb3e | /binary trees/bottom_view.cpp | a53f5b56070f79a8cc3769180f02df94a5b9e639 | [] | no_license | tmittal98/CPP-codes | 0dfbc25d12fba8ba558e862e0725d74578effcd3 | 3a53a684f27dcb366b1a2d7383abf6310f19ef28 | refs/heads/main | 2023-08-30T06:00:05.949617 | 2021-10-29T20:12:27 | 2021-10-29T20:12:27 | 422,682,553 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,130 | cpp |
void findMinHDMaxHD(Node* root,int hd,int &maxHD,int &minHD){
if(root){
if(hd < minHD){
minHD = hd;
}
if(hd > maxHD){
maxHD = hd;
}
findMinHDMaxHD(root->left,hd-1,maxHD,minHD);
findMinHDMaxHD(root->right,hd+1,maxHD,minHD);
}
return;
}
//Function to return a list containing the bottom view of the given tree.
vector <int> bottomView(Node *root)
{
int maxHD = 0;
int minHD = 0;
int hd = 0;
findMinHDMaxHD(root,hd,maxHD,minHD);
int n = abs(maxHD) + abs(minHD) + 1;
int a[n] = {0};
//current hd of root
hd = abs(minHD);
queue<pair<Node*,int>> q;
q.push({root,hd});
while(!q.empty()){
int hd = q.front().second;
Node* node = q.front().first;
//update in array
a[hd] = node->data;
if(node->left){
q.push({node->left,hd-1});
}
if(node->right){
q.push({node->right,hd+1});
}
q.pop();
}
vector<int> v(a,a+n);
return v;
} | [
"tusharmittal429@gmail.com"
] | tusharmittal429@gmail.com |
180a91b707309c5ba3e3dd07ac75a16acb2dda92 | b3f6619f036c2e265aa4b3c7d30790b5435c5398 | /QPubNubPublisher.h | eb64cb56b0bc51e2eb2bdb52a7a3e59d92b33292 | [] | no_license | pke/PubNub4Qt | 1d600acf913d8e5800c779434c9598f7d3b006b5 | 282f984f854b8eca77b8c9b5c09ffed58e09fabd | refs/heads/master | 2020-12-25T09:57:12.933479 | 2013-08-14T12:09:51 | 2013-08-14T12:09:51 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 998 | h | #pragma once
#include <QNetworkReply>
#include "QPubNubBase.h"
class QPubNubPublisher : public QPubNubBase {
Q_OBJECT
signals:
void published(const QString& timeToken);
public:
QPubNubPublisher(
QNetworkAccessManager* networkAccessManager,
const QString& publishKey,
const QString& subscribeKey,
const QString& channel,
QObject* parent= nullptr);
#ifdef Q_PUBNUB_CRYPT
void encryptMessages(const QByteArray& cipherKey);
#endif
void signMessages(const QByteArray& secretKey);
public slots:
void publish(const QJsonValue& value);
private:
QByteArray toByteArray(const QJsonValue& value);
QByteArray signature(const QByteArray& message);
QString url(const QByteArray& message);
private slots:
void onError(QNetworkReply::NetworkError code);
void readyRead();
private:
const QString m_publishKey;
const QString m_subscribeKey;
const QString m_channel;
QByteArray m_secretKey;
#ifdef Q_PUBNUB_CRYPT
QByteArray m_cipherKey;
#endif
};
| [
"phil.kursawe@gmail.com"
] | phil.kursawe@gmail.com |
ab8b9c592b62ef70f71644cdf7e90071ade57ce5 | 609a6e31a72c79a0d719b22ecb2f27ae3ed3d8df | /src/asio-udt/service.hh | 52dd47e475e9d59f14ff92c7413e2e02d0cb2002 | [] | no_license | infinitio/asio-udt | b72f5c6bc81b412839bb6bf582ab8b672218a8b4 | 4b94f035ead4cc1fc6770b8df722a6b9500e03e4 | refs/heads/master | 2020-12-02T16:17:52.847460 | 2017-07-07T11:41:47 | 2017-07-07T11:41:47 | 96,531,511 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,984 | hh | #ifndef ASIO_UDT_SERVICE_HH
# define ASIO_UDT_SERVICE_HH
# include <functional>
# include <unordered_map>
# include <boost/asio.hpp>
# include <boost/thread.hpp>
# include <udt/udt.h>
# include <asio-udt/fwd.hh>
namespace boost
{
namespace asio
{
namespace ip
{
namespace udt
{
class service: public io_service::service
{
public:
service(io_service& io_service);
~service();
static io_service::id id;
virtual
void
shutdown_service();
void
register_read(socket* sock,
std::function<void ()> const& action,
std::function<void ()> const& cancel);
void
cancel_read(socket* sock);
void
register_write(socket* sock,
std::function<void ()> const& action,
std::function<void ()> const& cancel);
void
cancel_write(socket* sock);
private:
std::set<UDTSOCKET> _wait_read;
std::set<UDTSOCKET> _wait_write;
void
_wait_refresh(UDTSOCKET sock);
private:
int _epoll;
std::unique_ptr<boost::thread> _thread;
void
_run();
class work
{
public:
work(io_service& service,
std::function<void ()> const& action,
std::function<void ()> const& cancel);
std::function<void ()> action;
std::function<void ()> cancel;
private:
io_service::work _work;
};
typedef std::unordered_map<int, work> Map;
Map _read_map;
Map _write_map;
boost::mutex _lock;
boost::condition_variable _barrier;
bool _stop;
};
}
}
}
}
#endif
| [
"mefyl@gruntech.org"
] | mefyl@gruntech.org |
12cd808cedfb498d7303548068d618beacb7e19d | 506e4e438e4f1525743664ba31fda9a5dace53f7 | /ultraball/commonball.h | 6b4c95dc2be1c8eb0da9a6b06e4d3b4e39dc9233 | [] | no_license | ekuri/UltraBall | d3e907c8abb386f80ab1dfafecb0b8cf48f0b7e0 | 4dbd8a070a74689a7da4cf0378a0fedb1e28b189 | refs/heads/master | 2016-08-03T14:48:01.851843 | 2015-09-07T07:11:34 | 2015-09-07T07:11:34 | 34,326,471 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 513 | h | #ifndef COMMONBALL_H
#define COMMONBALL_H
#include "abstractball.h"
#include "abstractwall.h"
#include <QPainter>
class CommonBall : public AbstractBall
{
public:
CommonBall(const QPointF &initialPosition, const QPointF &initialVelocity, qreal initialRadius);
list<Item*> getProcessItem();
void processItem(list<Item*> targetItems);
void moveNext();
void crashToWallThenBounce(const QPointF &crashPoint);
void handleAnimation();
protected:
int actCount;
};
#endif // COMMONBALL_H
| [
"960956136@qq.com"
] | 960956136@qq.com |
eee6d04fa8ec08ef12913e080befbca27ce06b5d | d0596d36470c08f6e1ef26e4e4d8702752d8899b | /prototype/photonADAnalyzerUpg.cc | f9920cd9a6efb8185d8e4f25237ae93a120f5671 | [] | no_license | NuDot/machine_learning | a5482bd1ce1cd89dbfbac8cbde990278459a8bc0 | 2acdb45b22ed1bb7617b7d0622ecad12f2b69a50 | refs/heads/master | 2021-04-28T07:37:04.506402 | 2019-11-02T04:39:19 | 2019-11-02T04:39:19 | 122,227,075 | 1 | 1 | null | 2019-05-10T19:17:53 | 2018-02-20T16:53:28 | Python | UTF-8 | C++ | false | false | 2,755 | cc | #include "TSystem.h"
#include "TChain.h"
#include "TFile.h"
#include "TClonesArray.h"
#include "TTree.h"
#include "TH1.h"
#include "TH2.h"
#include "TCanvas.h"
#include "TVector3.h"
#include "TImage.h"
#include <algorithm>
using namespace std;
using namespace CLHEP;
using namespace TMath;
//this file is a root script reading in the root tree generated by geant4 simulation,
//then implementing an analysis to plot the angular distribution between two selected
//photons. It will automatically select the photon which has input energy closest to the
//input photon energy and also within epsilon.
void photonADAnalyzerUpg (double firstPhotonEnergy_MeV, double secondPhotonEnergy_MeV, TString fileName, double epsilon = 0.1) {
gDirectory->pwd();
TFile *treeFile = new TFile(fileName);
TTree *tr = (TTree*)treeFile->Get("tree");
Long64_t numberofEntries = tr->GetEntries();
vector<double>* E = NULL;
vector<double>* x = NULL;
vector<double>* y = NULL;
vector<double>* z = NULL;
tr->SetBranchAddress("E", &E);
tr->SetBranchAddress("x", &x);
tr->SetBranchAddress("y", &y);
tr->SetBranchAddress("z", &z);
ostringstream title;
title<< "Angular Distribution Between" << firstPhotonEnergy_MeV << "MeV and " << secondPhotonEnergy_MeV << "MeV Photon";
TString histTitle = title.str();
title<<".root";
TString fileTitle = title.str();
TH1F * photonAD = new TH1F(histTitle,histTitle, 100, -1, 1);
for(Int_t entry = 0;entry < numberofEntries; ++entry) {
tr->GetEntry(entry);
int iPhoton1 = -1, iPhoton2 = -1;
double dPhoton1 = 1000.0, dPhoton2 = 1000.0;
//select the photon where the energy difference between its energy and
//input photon energy is minimum.
for(size_t iE = 0; iE < E->size(); ++iE) {
if (Abs(E->at(iE) - firstPhotonEnergy_MeV) <= dPhoton1) {
dPhoton1 = Abs(E->at(iE) - firstPhotonEnergy_MeV);
iPhoton1 = iE;
}
if (Abs(E->at(iE) - secondPhotonEnergy_MeV) <= dPhoton2) {
dPhoton2 = Abs(E->at(iE) - secondPhotonEnergy_MeV);
iPhoton2 = iE;
}
}
//make sure the energy difference between given photon and Geant4 generated photon is
//within acceptable epsilon range.
bool isAcceptableEpsilon = (dPhoton1/firstPhotonEnergy_MeV <= epsilon) && (dPhoton2/secondPhotonEnergy_MeV <= epsilon);
if (iPhoton1 != -1 && iPhoton2 != -1 && iPhoton1 != iPhoton2 && isAcceptableEpsilon) {
TVector3 photon1(x->at(iPhoton1),y->at(iPhoton1), z->at(iPhoton1));
TVector3 photon2(x->at(iPhoton2),y->at(iPhoton2), z->at(iPhoton2));
double cosAngle = photon1.Dot(photon2)/(photon1.Mag()*photon2.Mag());
photonAD->Fill(cosAngle);
}
}
TFile f(fileTitle, "RECREATE");
photonAD->Write();
f.Close();
}
| [
"liaobo77@bu.edu"
] | liaobo77@bu.edu |
5ffe3199320bf070e1ab987e8a023f697bfca7cc | 72b426d1a96a5dbe628f9d287b6c3636ea49b929 | /questions/Algorithms/0067. Add Binary/cpp.cc | be340092e9e75436f8c11e805a4748d4c17a33ca | [
"MIT"
] | permissive | 6leetcode/6leetcode | bc041ccccf0904e869a5aafa2c9634b37283c72b | 0c0973c634c881bd874bad5a0526b91a2d83f1a0 | refs/heads/main | 2023-04-10T01:03:34.741255 | 2022-11-13T14:45:56 | 2022-11-13T15:03:19 | 196,491,457 | 13 | 1 | MIT | 2023-03-15T08:10:40 | 2019-07-12T02:02:53 | C | UTF-8 | C++ | false | false | 1,246 | cc | #include <iostream>
using namespace std;
// ------------------------------- solution begin -------------------------------
class Solution {
public:
string addBinary(string a, string b) {
int len_a = a.size();
int len_b = b.size();
int len = len_a > len_b ? len_a : len_b;
string res = "";
int upper = 0;
while (len_a > 0 || len_b > 0) {
int an = len_a > 0 ? a[--len_a] - '0' : 0;
int bn = len_b > 0 ? b[--len_b] - '0' : 0;
if (an + bn + upper == 3) {
res = "1" + res;
upper = 1;
} else if (an + bn + upper == 2) {
res = "0" + res;
upper = 1;
} else if (an + bn + upper == 1) {
res = "1" + res;
upper = 0;
} else if (an + bn + upper == 0) {
res = "0" + res;
upper = 0;
}
len--;
}
if (upper == 1) {
res = "1" + res;
}
return res;
}
};
// ------------------------------- solution end ---------------------------------
int main(int argc, char const *argv[]) {
string input1 = "1011";
string input2 = "111";
cout << "Input: " << input1 << " " << input2 << endl;
Solution solution;
cout << "Output: " << solution.addBinary(input1, input2) << endl;
return EXIT_SUCCESS;
}
| [
"i@tosone.cn"
] | i@tosone.cn |
1bf45c4d68331277d71efd8113077dfb3a0cc148 | c60377fe680d96535fe9e9c3e4710d2a6418892c | /PonG.cpp | a9b7386ed8deef5a37f5739f45090edfdc7b4407 | [] | no_license | Dhurai1995/pongPong | 5f803279dc06c8914efe7069ed289307788feec7 | 8fc662d50c1bd779489283b62fbf9010e061a489 | refs/heads/master | 2022-12-26T05:19:12.434752 | 2020-10-10T09:55:19 | 2020-10-10T09:55:19 | 281,588,179 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,419 | cpp | // The main file of the pong game
#include<iostream>
#include<sstream>
#include "Bat.h"
#include<cstdlib>
#include<SFML\Graphics.hpp>
#include "Ball.h"
int main()
{
sf::VideoMode vm(1920, 1080);
sf::RenderWindow window(vm, "Pong", sf::Style::Fullscreen);
int score = 0;
int lives = 3;
Bat bat(1920 / 2, 1080 - 20);
Ball ball(1920 / 2, 0);
sf::Text hud;
sf::Font font;
font.loadFromFile("fonts/ka1.ttf");
hud.setFont(font);
hud.setCharacterSize(75);
hud.setFillColor(sf::Color::White);
hud.setPosition(20, 20);
sf::Clock clock;
while (window.isOpen())
{
/*
Handle the players input
*/
sf::Event event;
while (window.pollEvent(event))
{
if (event.type == sf::Event::Closed)
window.close();
}
if (sf::Keyboard::isKeyPressed(sf::Keyboard::Escape))
window.close();
if (sf::Keyboard::isKeyPressed(sf::Keyboard::Left))
bat.moveLeft();
else
bat.stopLeft();
if (sf::Keyboard::isKeyPressed(sf::Keyboard::Right))
bat.moveRight();
else
bat.stopRight();
/*
Update the bat, the ball and the HUD
*/
sf::Time dt = clock.restart();
bat.update(dt);
ball.update(dt);
std::stringstream ss;
ss << "Score: " << score << "Lives:" << lives;
hud.setString(ss.str());
/*
draw the bat, ball and the hud
*/
window.clear();
window.draw(hud);
window.draw(bat.getShape());
window.draw(ball.getShape());
window.display();
}
return 0;
} | [
"dhuraiip@gmail.com"
] | dhuraiip@gmail.com |
bea09b612ff88c606d9aecc4f8a7903fa3f612ed | b154b5de040cef45edf6fec351243a3a73d833bc | /15.go/16.cpp | dc6c2c04013376847b4578401893834de8b0d28d | [] | no_license | yangxiaox/code | a6f2d652b847a746ed303c8dffeaf7fb758d9ecd | d8f93eddedc153d02903c8eb8f7641b096d80aaa | refs/heads/master | 2021-09-10T14:04:18.857186 | 2018-03-27T13:34:09 | 2018-03-27T13:34:09 | 116,806,676 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 296 | cpp | /*************************************************************************
> File Name: 16.cpp
> Author:
> Mail:
> Created Time: 2017年11月23日 星期四 18时46分59秒
************************************************************************/
#include<iostream>
using namespace std;
| [
"823567085@qq.com"
] | 823567085@qq.com |
806f450881720b5d59c3158ddac457a627a836e2 | 801b121ef12cc6ad82becbdc5236a52e8cd6f764 | /PunctuationOccurrence.h | 0e898217f03bde7dba4b9c9bb10cf8848e698716 | [] | no_license | MikeWarren2014/CodeBreaker | d1f7f5f91ee2ea5c364a5ecf360b98bb368d3084 | 1ddaca5b2d2a9a675fac39cd73a7c98a3627f8e1 | refs/heads/master | 2021-01-21T18:00:22.087707 | 2016-09-18T06:35:18 | 2016-09-18T06:35:18 | 68,443,806 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 504 | h | #ifndef PUNCTUATIONOCCURRENCE_H
#define PUNCTUATIONOCCURRENCE_H
#include <iostream>
class PunctuationOccurrence
{
public:
PunctuationOccurrence();
PunctuationOccurrence(int, char);
int getLocation() const;
char getPunctuation() const;
friend std::ostream& operator<<(std::ostream& o, const PunctuationOccurrence& p)
{
return (o <<
"{\n\tcharacter: " << p.punctuation <<
"\n\tlocation: " << p.spot << "}" << std::endl);
}
private:
int spot;
char punctuation;
};
#endif
| [
"noreply@github.com"
] | MikeWarren2014.noreply@github.com |
234f075047da9a2b2517d38e0f3a6707228c2845 | 4b332d0026d4717ca77e416e3d95a11500863820 | /audit/matchers/prefix_matcher.h | bb96d36d7859af038826b432fc897fb1d6df34db | [
"Apache-2.0",
"LicenseRef-scancode-generic-cla"
] | permissive | qause/plusfish | 836bdf627573f628df04ebe834dda52a6240c934 | a56ac07ca132613ecda7f252a69312ada66bbbca | refs/heads/main | 2023-03-20T19:40:34.589876 | 2021-03-19T17:26:40 | 2021-03-19T17:26:40 | 446,000,581 | 1 | 0 | Apache-2.0 | 2022-01-09T05:18:16 | 2022-01-09T05:18:15 | null | UTF-8 | C++ | false | false | 1,927 | h | // Copyright 2020 Google LLC. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef OPS_SECURITY_PENTESTING_SCANNING_PLUSFISH_AUDIT_MATCHERS_PREFIX_MATCHER_H_
#define OPS_SECURITY_PENTESTING_SCANNING_PLUSFISH_AUDIT_MATCHERS_PREFIX_MATCHER_H_
#include "opensource/deps/base/macros.h"
#include "audit/matchers/matcher.h"
#include "proto/matching.pb.h"
#include "request.h"
namespace plusfish {
// Can be used to check if a content string starts with a specified prefix.
class PrefixMatcher : public MatcherInterface {
public:
explicit PrefixMatcher(const MatchRule_Match& match);
~PrefixMatcher() override {}
// If negative matching is expected.
bool negative() const override { return match_.negative_match(); }
bool Prepare() override;
// Returns true if any of the contained values are a prefix of the content
// parameter.
bool MatchAny(const Request* request,
const std::string* content) const override;
private:
// Helper method to match a single string against the content and it's origin
// Request. Returns true on success and false on failure.
bool MatchSingle(const std::string& search_string,
const std::string* content) const;
const MatchRule_Match match_;
DISALLOW_COPY_AND_ASSIGN(PrefixMatcher);
};
} // namespace plusfish
#endif // OPS_SECURITY_PENTESTING_SCANNING_PLUSFISH_AUDIT_MATCHERS_PREFIX_MATCHER_H_
| [
"heinenn@google.com"
] | heinenn@google.com |
78d4c78068f2eec0415b969f0f01ba3348930075 | c6a29c01ab6bc520d2778f8760a2eb28a011b727 | /libraries/MicroLCD/MicroLCD.h | 8503a659327c1a380eec1eeecd9bf7a8fd5efc16 | [] | no_license | sepolab/DYI_Smart_Home | fc845f538dd07987c925845e561fe31b1e1a3534 | d634e50a1bdc34a133c4b5099d322f89e251eb8d | refs/heads/master | 2020-04-23T12:05:28.273110 | 2017-08-18T14:55:19 | 2017-08-18T14:55:19 | 98,498,904 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,431 | h | /*************************************************************************
* Arduino Text & Bitmap Display Library for multiple models of monochrome LCD display
* Distributed under GPL v2.0
* Copyright (c) 2013-2014 Stanley Huang <stanleyhuangyc@gmail.com>
* All rights reserved.
* For more information, please visit http://arduinodev.com
*************************************************************************/
#include <Arduino.h>
//#define MEMORY_SAVING
typedef enum {
FONT_SIZE_SMALL = 0,
FONT_SIZE_MEDIUM,
FONT_SIZE_LARGE,
FONT_SIZE_XLARGE
} FONT_SIZE;
#define FLAG_PAD_ZERO 1
#define FLAG_PIXEL_DOUBLE_H 2
#define FLAG_PIXEL_DOUBLE_V 4
#define FLAG_PIXEL_DOUBLE (FLAG_PIXEL_DOUBLE_H | FLAG_PIXEL_DOUBLE_V)
extern const PROGMEM unsigned char font5x8[][5];
extern const PROGMEM unsigned char digits8x8[][8] ;
extern const PROGMEM unsigned char digits16x16[][32];
extern const PROGMEM unsigned char digits16x24[][48];
extern const PROGMEM unsigned char font8x16_doslike[][16];
extern const PROGMEM unsigned char font8x16_terminal[][16];
class LCD_Common
{
public:
LCD_Common():m_font(FONT_SIZE_SMALL),m_flags(0) {}
void setFontSize(FONT_SIZE size) { m_font = size; }
void setFlags(byte flags) { m_flags = flags; }
virtual void backlight(bool on) {}
virtual void draw(const PROGMEM byte* buffer, byte width, byte height) {}
void printInt(uint16_t value, int8_t padding = -1);
void printLong(uint32_t value, int8_t padding = -1);
protected:
virtual void writeDigit(byte n) {}
byte m_font;
byte m_flags;
};
class LCD_Null : public LCD_Common, public Print
{
public:
byte getLines() { return 0; }
byte getCols() { return 0; }
void clearLine(byte line) {}
void clear() {}
void begin() {}
void setCursor(byte column, byte line) {}
size_t write(uint8_t c) { return 0; }
};
#include "SSD1306.h"
class LCD_SSD1306 : public LCD_Common, public SSD1306, public Print
{
public:
void setCursor(byte column, byte line);
void setContrast(byte Contrast);
void draw(const PROGMEM byte* buffer, byte width, byte height);
size_t write(uint8_t c);
void clear(byte x = 0, byte y = 0, byte width = 128, byte height = 64);
void clearLine(byte line);
byte getLines() { return 21; }
byte getCols() { return 8; }
private:
void writeDigit(byte n);
byte m_col;
byte m_row;
};
class LCD_SH1106 : public LCD_Common, public Print
{
public:
void begin();
void setCursor(byte column, byte line);
void draw(const PROGMEM byte* buffer, byte width, byte height);
size_t write(uint8_t c);
void clear(byte x = 0, byte y = 0, byte width = 132, byte height = 64);
void clearLine(byte line);
byte getLines() { return 21; }
byte getCols() { return 8; }
private:
void WriteCommand(unsigned char ins);
void WriteData(unsigned char dat);
void writeDigit(byte n);
byte m_col;
byte m_row;
};
#include "PCD8544.h"
class LCD_PCD8544 : public LCD_Common, public PCD8544
{
public:
byte getLines() { return 6; }
byte getCols() { return 14; }
void backlight(bool on)
{
pinMode(7, OUTPUT);
digitalWrite(7, on ? HIGH : LOW);
}
void clearLine(byte line)
{
setCursor(0, line);
for (byte i = 14; i > 0; i--) write(' ');
}
void draw(const PROGMEM byte* buffer, byte width, byte height);
private:
void writeDigit(byte n);
};
| [
"tringuyen1506@gmail.com"
] | tringuyen1506@gmail.com |
231de984dc9a04acf5ae6cab68c8422c6e91fc99 | 5499e8b91353ef910d2514c8a57a80565ba6f05b | /garnet/bin/ui/gltf_export/main.cc | 953fb43c6786246d617d5c66b041831aaa4afc70 | [
"BSD-3-Clause"
] | permissive | winksaville/fuchsia | 410f451b8dfc671f6372cb3de6ff0165a2ef30ec | a0ec86f1d51ae8d2538ff3404dad46eb302f9b4f | refs/heads/master | 2022-11-01T11:57:38.343655 | 2019-11-01T17:06:19 | 2019-11-01T17:06:19 | 223,695,500 | 3 | 2 | BSD-3-Clause | 2022-10-13T13:47:02 | 2019-11-24T05:08:59 | C++ | UTF-8 | C++ | false | false | 18,846 | cc | // Copyright 2018 The Fuchsia Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include <fuchsia/ui/scenic/cpp/fidl.h>
#include <fuchsia/ui/scenic/internal/cpp/fidl.h>
#include <lib/async-loop/cpp/loop.h>
#include <lib/async-loop/default.h>
#include <lib/sys/cpp/component_context.h>
#include <png.h>
#include <cstdlib>
#include <iostream>
#include <memory>
#include <trace-provider/provider.h>
#include "rapidjson/document.h"
#include "rapidjson/prettywriter.h"
#include "rapidjson/stringbuffer.h"
#include "src/lib/fsl/vmo/vector.h"
#include "src/lib/fxl/command_line.h"
#include "src/lib/fxl/log_settings_command_line.h"
#include "src/lib/fxl/logging.h"
#include "src/ui/scenic/lib/gfx/snapshot/snapshot_generated.h"
#include "src/ui/scenic/lib/gfx/snapshot/version.h"
#include "third_party/cobalt/src/lib/crypto_util/base64.h"
using cobalt::crypto::Base64Encode;
using namespace rapidjson;
using namespace scenic_impl::gfx;
const char *EMPTY_GLTF_DOC = R"glTF({
"scenes": [{
"nodes": []
}],
"scene": 0,
"nodes": [],
"meshes": [],
"buffers": [],
"bufferViews": [],
"accessors": [],
"materials": [],
"textures": [],
"images": [],
"samplers": [{}],
"asset": {
"version": "2.0"
}
})glTF";
const char *EMPTY_TEXTURE_MATERIAL = R"glTF({
"pbrMetallicRoughness" : {
"baseColorTexture" : {
},
"metallicFactor" : 0.0,
"roughnessFactor" : 1.0
}
})glTF";
const char *EMPTY_COLOR_MATERIAL = R"glTF({
"pbrMetallicRoughness" : {
"baseColorFactor" : [1.0, 1.0, 1.0, 1.0],
"metallicFactor" : 0.0,
"roughnessFactor" : 1.0
}
})glTF";
// Converts uncompressed raw image to PNG.
bool RawToPNG(size_t width, size_t height, const uint8_t *data, std::vector<uint8_t> &out);
// Dumps rapidjson Value to ostream.
std::ostream &operator<<(std::ostream &os, const Value &v) {
StringBuffer buffer;
PrettyWriter<StringBuffer> writer(buffer);
v.Accept(writer);
return os << buffer.GetString();
}
// Defines a class to take a snapshot of the current scenic composition.
class SnapshotTaker {
public:
explicit SnapshotTaker(async::Loop *loop)
: loop_(loop), context_(sys::ComponentContext::Create()) {
// Connect to the Scenic service.
scenic_ = context_->svc()->Connect<fuchsia::ui::scenic::Scenic>();
scenic_.set_error_handler([this](zx_status_t status) {
FXL_LOG(ERROR) << "Lost connection to Scenic service.";
encountered_error_ = true;
loop_->Quit();
});
// Connect to the internal snapshot service.
snapshotter_ = context_->svc()->Connect<fuchsia::ui::scenic::internal::Snapshot>();
snapshotter_.set_error_handler([this](zx_status_t status) {
FXL_LOG(ERROR) << "Lost connection to Snapshot service.";
encountered_error_ = true;
loop_->Quit();
});
}
bool encountered_error() const { return encountered_error_; }
// Takes a snapshot of the current scenic composition and dumps it to
// std::out in glTF format.
void TakeSnapshot() {
// If we wait for a call back from GetDisplayInfo, we are guaranteed that
// the GFX system is initialized, which is a prerequisite for taking a
// screenshot. TODO(SCN-678): Remove call to GetDisplayInfo once bug done.
scenic_->GetDisplayInfo([this](fuchsia::ui::gfx::DisplayInfo /*unused*/) {
snapshotter_->TakeSnapshot(
[this](std::vector<fuchsia::ui::scenic::internal::SnapshotResult> results) {
if (results.size() == 0) {
FXL_LOG(INFO) << "No compositors found.";
loop_->Quit();
}
// Although multiple results can be returned, one for each compositor, the glTF exporter
// currently only makes use of the first compositor that is found.
if (results.size() > 1) {
FXL_LOG(WARNING) << "Multiple snapshot buffers were returned, but glTF exporter is "
"only using the first one.";
}
const auto &result = results[0];
if (!result.success) {
FXL_LOG(ERROR) << "Snapshot was not successful.";
encountered_error_ = true;
loop_->Quit();
}
const auto &buffer = result.buffer;
std::vector<uint8_t> data;
if (!fsl::VectorFromVmo(buffer, &data)) {
FXL_LOG(ERROR) << "TakeSnapshot failed";
encountered_error_ = true;
loop_->Quit();
return;
}
// We currently support flatbuffer.v1_0 format.
auto snapshot = (const SnapshotData *)data.data();
if (snapshot->type != SnapshotData::SnapshotType::kFlatBuffer ||
snapshot->version != SnapshotData::SnapshotVersion::v1_0) {
FXL_LOG(ERROR) << "Invalid snapshot format encountered. Aborting.";
encountered_error_ = true;
loop_->Quit();
return;
}
// De-serialize the snapshot from flatbuffer.
auto node = flatbuffers::GetRoot<snapshot::Node>(snapshot->data);
// Start with an empty glTF document.
document_.Parse(EMPTY_GLTF_DOC);
// Export root node of the scene graph. This recursively exports all
// descendant nodes.
int index = glTF_export_node(node, true);
auto &gltf_nodes = document_["scenes"][0]["nodes"];
gltf_nodes.PushBack(index, document_.GetAllocator());
// Dump the result json document in glTF format to stdout.
std::cout << document_;
loop_->Quit();
});
});
}
private:
int glTF_export_node(const snapshot::Node *node, bool flip_yaxis = false) {
// The allocator used through out.
auto &allocator = document_.GetAllocator();
auto gltf_node = Value(kObjectType);
if (node->name()) {
gltf_node.AddMember("name", node->name()->str(), allocator);
}
if (node->transform()) {
auto translation = node->transform()->translation();
if (translation->x() != 0.0 || translation->y() != 0.0 || translation->z() != 0.0) {
auto gltf_translation = Value(kArrayType);
gltf_translation.PushBack(translation->x(), allocator);
gltf_translation.PushBack(translation->y(), allocator);
gltf_translation.PushBack(translation->z(), allocator);
gltf_node.AddMember("translation", gltf_translation, allocator);
}
auto rotation = node->transform()->rotation();
if (rotation->x() != 0.0 || rotation->y() != 0.0 || rotation->z() != 0.0 ||
rotation->w() != 1.0) {
auto gltf_rotation = Value(kArrayType);
gltf_rotation.PushBack(rotation->x(), allocator);
gltf_rotation.PushBack(rotation->y(), allocator);
gltf_rotation.PushBack(rotation->z(), allocator);
gltf_rotation.PushBack(rotation->w(), allocator);
gltf_node.AddMember("rotation", gltf_rotation, allocator);
}
auto scale = node->transform()->scale();
if (scale->x() != 1.0 || scale->y() != 1.0 || scale->z() != 1.0) {
auto gltf_scale = Value(kArrayType);
gltf_scale.PushBack(scale->x(), allocator);
if (flip_yaxis) {
gltf_scale.PushBack(scale->y() * -1, allocator);
} else {
gltf_scale.PushBack(scale->y(), allocator);
}
gltf_scale.PushBack(scale->z(), allocator);
gltf_node.AddMember("scale", gltf_scale, allocator);
}
}
if (node->mesh()) {
int index = glTF_export_mesh(node);
gltf_node.AddMember("mesh", index, allocator);
}
auto &gltf_nodes = document_["nodes"];
auto index = gltf_nodes.Size();
gltf_nodes.PushBack(gltf_node, allocator);
if (node->children()) {
auto child_nodes = Value(kArrayType);
for (auto child : *node->children()) {
int index = glTF_export_node(child);
child_nodes.PushBack(index, allocator);
}
auto &gltf_node = document_["nodes"][index];
gltf_node.AddMember("children", child_nodes, allocator);
}
return index;
}
int glTF_export_mesh(const snapshot::Node *node) {
// The allocator used through out.
auto &allocator = document_.GetAllocator();
auto gltf_primitive = Value(kObjectType);
gltf_primitive.AddMember("material", glTF_export_material(node), allocator);
gltf_primitive.AddMember("attributes", glTF_export_buffer(node->mesh(), true), allocator);
gltf_primitive.AddMember("indices", glTF_export_buffer(node->mesh(), false), allocator);
auto gltf_primitives = Value(kArrayType);
gltf_primitives.PushBack(gltf_primitive, allocator);
auto gltf_mesh = Value(kObjectType);
gltf_mesh.AddMember("primitives", gltf_primitives, allocator);
auto &gltf_meshes = document_["meshes"];
auto index = gltf_meshes.Size();
gltf_meshes.PushBack(gltf_mesh, allocator);
return index;
}
Value glTF_export_buffer(const snapshot::Geometry *mesh, bool is_vertex_buffer) {
auto &allocator = document_.GetAllocator();
const uint8_t *bytes = is_vertex_buffer ? mesh->attributes()->Get(0)->buffer()->Data()
: mesh->indices()->buffer()->Data();
size_t size = is_vertex_buffer ? mesh->attributes()->Get(0)->buffer()->Length()
: mesh->indices()->buffer()->Length();
int count = is_vertex_buffer ? mesh->attributes()->Get(0)->vertex_count()
: mesh->indices()->index_count();
// Create a glTF buffer.
std::string base64_bytes;
Base64Encode(bytes, size, &base64_bytes);
std::ostringstream data;
data << "data:application/octet-stream;base64," << base64_bytes;
auto data_str = data.str();
Value data_uri(kStringType);
data_uri.SetString(data_str.c_str(), data_str.length(), allocator);
Value gltf_buffer(kObjectType);
gltf_buffer.AddMember("uri", data_uri, allocator);
gltf_buffer.AddMember("byteLength", size, allocator);
auto &gltf_buffers = document_["buffers"];
int buffer_index = gltf_buffers.Size();
gltf_buffers.PushBack(gltf_buffer, allocator);
// Create a glTF bufferView.
Value gltf_bufferView(kObjectType);
gltf_bufferView.AddMember("buffer", Value(buffer_index), allocator);
gltf_bufferView.AddMember("byteOffset", Value(0), allocator);
gltf_bufferView.AddMember("byteLength", size, allocator);
gltf_bufferView.AddMember("target", is_vertex_buffer ? Value(34962) : Value(34963), allocator);
if (is_vertex_buffer) {
gltf_bufferView.AddMember("byteStride", mesh->attributes()->Get(0)->stride(), allocator);
}
auto &gltf_bufferViews = document_["bufferViews"];
int buffer_view_index = gltf_bufferViews.Size();
gltf_bufferViews.PushBack(gltf_bufferView, allocator);
// Create a glTF accessor.
Value gltf_accessor(kObjectType);
gltf_accessor.AddMember("bufferView", Value(buffer_view_index), allocator);
gltf_accessor.AddMember("byteOffset", Value(0), allocator);
gltf_accessor.AddMember("componentType", is_vertex_buffer ? Value(5126) : Value(5125),
allocator);
gltf_accessor.AddMember("count", count, allocator);
gltf_accessor.AddMember("type", is_vertex_buffer ? Value("VEC3") : Value("SCALAR"), allocator);
if (is_vertex_buffer) {
Value gltf_max(kArrayType);
gltf_max.PushBack(mesh->bbox_max()->x(), allocator);
gltf_max.PushBack(mesh->bbox_max()->y(), allocator);
gltf_max.PushBack(mesh->bbox_max()->z(), allocator);
Value gltf_min(kArrayType);
gltf_min.PushBack(mesh->bbox_min()->x(), allocator);
gltf_min.PushBack(mesh->bbox_min()->y(), allocator);
gltf_min.PushBack(mesh->bbox_min()->z(), allocator);
gltf_accessor.AddMember("max", gltf_max, allocator);
gltf_accessor.AddMember("min", gltf_min, allocator);
}
auto &gltf_accessors = document_["accessors"];
int accessor_index = gltf_accessors.Size();
gltf_accessors.PushBack(gltf_accessor, allocator);
int texture_accessor_index = gltf_accessors.Size();
// Add texture accessor for vertex buffer.
if (is_vertex_buffer) {
Value gltf_accessor(kObjectType);
gltf_accessor.AddMember("bufferView", Value(buffer_view_index), allocator);
gltf_accessor.AddMember("byteOffset", Value(8), allocator);
gltf_accessor.AddMember("componentType", Value(5126), allocator);
gltf_accessor.AddMember("count", count, allocator);
gltf_accessor.AddMember("type", Value("VEC2"), allocator);
Value gltf_max(kArrayType);
gltf_max.PushBack(1.0, allocator);
gltf_max.PushBack(1.0, allocator);
Value gltf_min(kArrayType);
gltf_min.PushBack(0.0, allocator);
gltf_min.PushBack(0.0, allocator);
gltf_accessor.AddMember("max", gltf_max, allocator);
gltf_accessor.AddMember("min", gltf_min, allocator);
gltf_accessors.PushBack(gltf_accessor, allocator);
}
// Add the accessor index to the glTF primitive.
if (is_vertex_buffer) {
auto gltf_attributes = Value(kObjectType);
gltf_attributes.AddMember("POSITION", accessor_index, allocator);
gltf_attributes.AddMember("TEXCOORD_0", texture_accessor_index, allocator);
return gltf_attributes;
} else {
return Value(accessor_index);
}
}
int glTF_export_material(const snapshot::Node *node) {
auto &allocator = document_.GetAllocator();
if (node->material_type() == snapshot::Material_Color) {
auto color = static_cast<const snapshot::Color *>(node->material());
Document gltf_material(kObjectType, &allocator);
gltf_material.Parse(EMPTY_COLOR_MATERIAL);
auto &gltf_color = gltf_material["pbrMetallicRoughness"]["baseColorFactor"];
gltf_color.Clear();
gltf_color.PushBack(color->red(), allocator);
gltf_color.PushBack(color->green(), allocator);
gltf_color.PushBack(color->blue(), allocator);
gltf_color.PushBack(color->alpha(), allocator);
auto &gltf_materials = document_["materials"];
int materials_index = gltf_materials.Size();
gltf_materials.PushBack(gltf_material, allocator);
return materials_index;
} else {
auto image = static_cast<const snapshot::Image *>(node->material());
// Convert raw image to png.
const uint8_t *bytes = image->data()->Data();
std::vector<uint8_t> out;
if (!RawToPNG(image->width(), image->height(), bytes, out)) {
FXL_LOG(FATAL) << "Unable to convert to PNG";
return -1;
}
// Encode to base64.
std::string base64_bytes;
Base64Encode(out.data(), out.size(), &base64_bytes);
std::ostringstream data;
data << "data:image/png;base64," << base64_bytes;
auto data_str = data.str();
Value data_uri(kStringType);
data_uri.SetString(data_str.c_str(), data_str.length(), allocator);
Value gltf_image(kObjectType);
gltf_image.AddMember("mimeType", "image/png", allocator);
gltf_image.AddMember("width", image->width(), allocator);
gltf_image.AddMember("height", image->height(), allocator);
gltf_image.AddMember("format", image->format(), allocator);
gltf_image.AddMember("size", out.size(), allocator);
gltf_image.AddMember("uri", data_uri, allocator);
auto &gltf_images = document_["images"];
int image_index = gltf_images.Size();
gltf_images.PushBack(gltf_image, allocator);
Value gltf_texture(kObjectType);
gltf_texture.AddMember("sampler", 0, allocator);
gltf_texture.AddMember("source", image_index, allocator);
auto &gltf_textures = document_["textures"];
int texture_index = gltf_textures.Size();
gltf_textures.PushBack(gltf_texture, allocator);
Document gltf_material(kObjectType, &allocator);
gltf_material.Parse(EMPTY_TEXTURE_MATERIAL);
auto &gltf_baseColorTexture = gltf_material["pbrMetallicRoughness"]["baseColorTexture"];
gltf_baseColorTexture.AddMember("index", texture_index, allocator);
auto &gltf_materials = document_["materials"];
int materials_index = gltf_materials.Size();
gltf_materials.PushBack(gltf_material, allocator);
return materials_index;
}
}
private:
async::Loop *loop_;
std::unique_ptr<sys::ComponentContext> context_;
bool encountered_error_ = false;
fuchsia::ui::scenic::ScenicPtr scenic_;
fuchsia::ui::scenic::internal::SnapshotPtr snapshotter_;
Document document_;
};
int main(int argc, const char **argv) {
auto command_line = fxl::CommandLineFromArgcArgv(argc, argv);
if (!fxl::SetLogSettingsFromCommandLine(command_line))
return 1;
const auto &positional_args = command_line.positional_args();
if (positional_args.size() != 0) {
FXL_LOG(ERROR) << "Usage: gltf_export\n"
<< "Takes a snapshot in glTF format and writes it to stdout.\n"
<< "To write to a file, redirect stdout, e.g.: "
<< "gltf_export > \"${DST}\"";
return 1;
}
async::Loop loop(&kAsyncLoopConfigAttachToCurrentThread);
trace::TraceProviderWithFdio trace_provider(loop.dispatcher());
SnapshotTaker taker(&loop);
taker.TakeSnapshot();
loop.Run();
return taker.encountered_error() ? EXIT_FAILURE : EXIT_SUCCESS;
}
////////////////////////////////////////////////////////////////////////////////
// PNG encode.
bool RawToPNG(size_t width, size_t height, const uint8_t *data, std::vector<uint8_t> &out) {
out.clear();
png_structp png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
png_infop info_ptr = png_create_info_struct(png_ptr);
if (setjmp(png_jmpbuf(png_ptr))) {
png_destroy_write_struct(&png_ptr, NULL);
FXL_LOG(ERROR) << "Unable to create write struct";
return false;
}
png_set_IHDR(png_ptr, info_ptr, width, height, 8, PNG_COLOR_TYPE_RGBA, PNG_INTERLACE_NONE,
PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT);
std::vector<uint8_t *> rows(height);
for (size_t y = 0; y < height; ++y) {
rows[y] = (uint8_t *)data + y * width * 4;
}
png_set_rows(png_ptr, info_ptr, &rows[0]);
png_set_write_fn(
png_ptr, &out,
[](png_structp png_ptr, png_bytep data, png_size_t length) {
std::vector<uint8_t> *p = (std::vector<uint8_t> *)png_get_io_ptr(png_ptr);
p->insert(p->end(), data, data + length);
},
NULL);
png_write_png(png_ptr, info_ptr, PNG_TRANSFORM_BGR, NULL);
if (setjmp(png_jmpbuf(png_ptr))) {
png_destroy_write_struct(&png_ptr, NULL);
FXL_LOG(ERROR) << "Unable to create write png";
return false;
}
png_destroy_write_struct(&png_ptr, NULL);
return true;
}
| [
"commit-bot@chromium.org"
] | commit-bot@chromium.org |
2fabd718c9f0ebe468601d9fe271f7322cf225f2 | d85b1f3ce9a3c24ba158ca4a51ea902d152ef7b9 | /testcases/CWE762_Mismatched_Memory_Management_Routines/s05/CWE762_Mismatched_Memory_Management_Routines__new_array_free_int64_t_21.cpp | 2edc11783adbc6f8759a677ef74120d7d1f15ca5 | [] | no_license | arichardson/juliet-test-suite-c | cb71a729716c6aa8f4b987752272b66b1916fdaa | e2e8cf80cd7d52f824e9a938bbb3aa658d23d6c9 | refs/heads/master | 2022-12-10T12:05:51.179384 | 2022-11-17T15:41:30 | 2022-12-01T15:25:16 | 179,281,349 | 34 | 34 | null | 2022-12-01T15:25:18 | 2019-04-03T12:03:21 | null | UTF-8 | C++ | false | false | 4,537 | cpp | /* TEMPLATE GENERATED TESTCASE FILE
Filename: CWE762_Mismatched_Memory_Management_Routines__new_array_free_int64_t_21.cpp
Label Definition File: CWE762_Mismatched_Memory_Management_Routines__new_array_free.label.xml
Template File: sources-sinks-21.tmpl.cpp
*/
/*
* @description
* CWE: 762 Mismatched Memory Management Routines
* BadSource: Allocate data using new []
* GoodSource: Allocate data using malloc()
* Sinks:
* GoodSink: Deallocate data using delete []
* BadSink : Deallocate data using free()
* Flow Variant: 21 Control flow: Flow controlled by value of a static global variable. All functions contained in one file.
*
* */
#include "std_testcase.h"
namespace CWE762_Mismatched_Memory_Management_Routines__new_array_free_int64_t_21
{
#ifndef OMITBAD
/* The static variable below is used to drive control flow in the sink function */
static int badStatic = 0;
static void badSink(int64_t * data)
{
if(badStatic)
{
/* POTENTIAL FLAW: Deallocate memory using free() - the source memory allocation function may
* require a call to delete [] to deallocate the memory */
free(data);
}
}
void bad()
{
int64_t * data;
/* Initialize data*/
data = NULL;
/* POTENTIAL FLAW: Allocate memory with a function that requires delete [] to free the memory */
data = new int64_t[100];
badStatic = 1; /* true */
badSink(data);
}
#endif /* OMITBAD */
#ifndef OMITGOOD
/* The static variables below are used to drive control flow in the sink functions. */
static int goodB2G1Static = 0;
static int goodB2G2Static = 0;
static int goodG2bStatic = 0;
/* goodB2G1() - use badsource and goodsink by setting the static variable to false instead of true */
static void goodB2G1Sink(int64_t * data)
{
if(goodB2G1Static)
{
/* INCIDENTAL: CWE 561 Dead Code, the code below will never run */
printLine("Benign, fixed string");
}
else
{
/* FIX: Deallocate the memory using delete [] */
delete [] data;
}
}
static void goodB2G1()
{
int64_t * data;
/* Initialize data*/
data = NULL;
/* POTENTIAL FLAW: Allocate memory with a function that requires delete [] to free the memory */
data = new int64_t[100];
goodB2G1Static = 0; /* false */
goodB2G1Sink(data);
}
/* goodB2G2() - use badsource and goodsink by reversing the blocks in the if in the sink function */
static void goodB2G2Sink(int64_t * data)
{
if(goodB2G2Static)
{
/* FIX: Deallocate the memory using delete [] */
delete [] data;
}
}
static void goodB2G2()
{
int64_t * data;
/* Initialize data*/
data = NULL;
/* POTENTIAL FLAW: Allocate memory with a function that requires delete [] to free the memory */
data = new int64_t[100];
goodB2G2Static = 1; /* true */
goodB2G2Sink(data);
}
/* goodG2B() - use goodsource and badsink */
static void goodG2BSink(int64_t * data)
{
if(goodG2bStatic)
{
/* POTENTIAL FLAW: Deallocate memory using free() - the source memory allocation function may
* require a call to delete [] to deallocate the memory */
free(data);
}
}
static void goodG2B()
{
int64_t * data;
/* Initialize data*/
data = NULL;
/* FIX: Allocate memory from the heap using malloc() */
data = (int64_t *)malloc(100*sizeof(int64_t));
if (data == NULL) {exit(-1);}
goodG2bStatic = 1; /* true */
goodG2BSink(data);
}
void good()
{
goodB2G1();
goodB2G2();
goodG2B();
}
#endif /* OMITGOOD */
} /* close namespace */
/* Below is the main(). It is only used when building this testcase on
its own for testing or for building a binary to use in testing binary
analysis tools. It is not used when compiling all the testcases as one
application, which is how source code analysis tools are tested. */
#ifdef INCLUDEMAIN
using namespace CWE762_Mismatched_Memory_Management_Routines__new_array_free_int64_t_21; /* so that we can use good and bad easily */
int main(int argc, char * argv[])
{
/* seed randomness */
srand( (unsigned)time(NULL) );
#ifndef OMITGOOD
printLine("Calling good()...");
good();
printLine("Finished good()");
#endif /* OMITGOOD */
#ifndef OMITBAD
printLine("Calling bad()...");
bad();
printLine("Finished bad()");
#endif /* OMITBAD */
return 0;
}
#endif
| [
"Alexander.Richardson@cl.cam.ac.uk"
] | Alexander.Richardson@cl.cam.ac.uk |
9bb4e05498eaf3bb216573654759684a1aae3f1d | b6e7062a85f6fb8007f1d4f31b13b54da2cda3a6 | /680_验证回文字符串 Ⅱ.cpp | 9c986dc1c19d45f8d445dd45afdcfda243f42f63 | [] | no_license | maxiupili/DataStructure | c25fe52cf132ebf3896ed9fcf85d3ed983f0bb69 | c6daa91b8eedbb450b02f25ec804b98dda8bca13 | refs/heads/master | 2020-12-06T22:31:35.877732 | 2020-06-16T11:12:15 | 2020-06-16T11:12:15 | 232,569,275 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,175 | cpp | /*
给定一个非空字符串 s,最多删除一个字符。判断是否能成为回文字符串。
示例 1:
输入: "aba"
输出: True
示例 2:
输入: "abca"
输出: True
解释: 你可以删除c字符。
注意:
字符串只包含从 a-z 的小写字母。字符串的最大长度是50000。
*/
class Solution {
public:
bool validPalindrome(string s) {
int n = s.size() - 1;
bool res = true;
for (int i = 0; i < n; ++i, --n) {
if (s[i] != s[n]) {
res = fun(s, i + 1, n) || fun(s, i, n - 1);
break;
}
}
return res;
}
bool fun(string s, int start, int end) {
bool res = true;
//cout<<start<<" "<<end<<endl;
// if (start >= end) {
// return true;
// }
// if (s[start] != s[end]) {
// return false;
// } else {
// return fun(s, start + 1, end -1);
// }
while (start < end) {
if (s[start] != s[end]) {
res = false;
break;
}
start++;
end--;
}
return res;
}
}; | [
"2567444258@qq.com"
] | 2567444258@qq.com |
bc2a3ac91a1d23d06dcc5ea80d127566f1101e44 | dc4de7137e7f8b502790c8279391b22a3018633a | /Bomberman/src/G20_AA2-2/Player.cpp | 1fdb9b5bc7021aa85eaf6a42f8bd637b1ad212ca | [] | no_license | pacitto/G20_AA2_2 | 864ea15a82ab1037f54756dfb6f3bae1116a46a9 | ad4c634f12a84e7431f985ea6a55ceddef2121e5 | refs/heads/main | 2023-02-14T05:08:37.370672 | 2021-01-08T20:02:34 | 2021-01-08T20:02:34 | 327,974,796 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,589 | cpp | #include "Player.h"
Player::Player()
{
}
Player::Player(int _id)
{
id = _id;
SetUpPlayer();
}
void Player::SetUpPlayer()
{
if(id == 1)
{
left = InputKey::K_A;
right = InputKey::K_D;
up = InputKey::K_W;
down = InputKey::K_S;
bomb = InputKey::K_SPACE;
spriteId.assign(PLAYER1_SPRITESHEET::ID);
}
else if (id == 2)
{
left = InputKey::K_LEFT;
right = InputKey::K_RIGHT;
up = InputKey::K_UP;
down = InputKey::K_DOWN;
bomb = InputKey::K_CTRL;
spriteId.assign(PLAYER2_SPRITESHEET::ID);
}
animationFrame = { PLAYER_SIZE, 0, PLAYER_SIZE, PLAYER_SIZE };
SetInitialPos({ 0,0 });
}
void Player::SetLives(int _lives)
{
lives = _lives;
}
int Player::GetLives()
{
return lives;
}
void Player::SetInitialPos(VEC2 _pos)
{
initialPos = _pos;
currentPos = initialPos;
}
VEC2 Player::GetInitialPos()
{
return initialPos;
}
void Player::Update(bool* _inputs)
{
if (_inputs[(int)left])
{
std::cout << "PLAYER " << id << ": LEFT" << std::endl;
}
else if (_inputs[(int)right])
{
std::cout << "PLAYER " << id << ": RIGHT" << std::endl;
}
else if (_inputs[(int)up])
{
std::cout << "PLAYER " << id << ": UP" << std::endl;
}
else if (_inputs[(int)down])
{
std::cout << "PLAYER " << id << ": DOWN" << std::endl;
}
else if (_inputs[(int)bomb])
{
std::cout << "PLAYER " << id << ": BOMB" << std::endl;
}
}
void Player::Draw()
{
Renderer::Instance()->PushSprite(spriteId, animationFrame, RECT{currentPos.x * PLAYER_SIZE + OFFSET_X, currentPos.y * PLAYER_SIZE + OFFSET_Y, PLAYER_SIZE, PLAYER_SIZE });
}
Player::~Player()
{
}
| [
"pacitto3@gmail.com"
] | pacitto3@gmail.com |
979ae13a699f1ebc85014cc37088a7573ed7d97a | abd81df6cf4fcd121b1748ce75ad70db312aca0d | /include/MTL/board/mbedLPC1768/MTL/Pins.h | 5a6d378fb6365d82867b0f3e9aefeb0becd9799b | [
"MIT"
] | permissive | sandsmark/Platform | 0701822034e370eb36ac65ffac975a6f0f3a5083 | 067ce90b3600ad2ab19e216b90c1618605c43ae9 | refs/heads/master | 2020-07-20T11:07:26.063173 | 2019-09-05T18:35:33 | 2019-09-05T18:35:33 | 206,630,178 | 0 | 0 | MIT | 2019-09-05T18:22:44 | 2019-09-05T18:22:43 | null | UTF-8 | C++ | false | false | 2,829 | h | //------------------------------------------------------------------------------
// Copyright (c) 2013 John D. Haughton
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
//------------------------------------------------------------------------------
//! \file Pins.h
//! \brief mbed LP1768 module pins
#ifndef MBED_LPC1768_PINS_H
#define MBED_LPC1768_PINS_H
#include "MTL/chip/LPC1768/Pins.h"
namespace MTL {
static const unsigned PIN_DIP5 = PIN_0_9;
static const unsigned PIN_DIP6 = PIN_0_8;
static const unsigned PIN_DIP7 = PIN_0_7;
static const unsigned PIN_DIP8 = PIN_0_6;
static const unsigned PIN_DIP9 = PIN_0_0;
static const unsigned PIN_DIP10 = PIN_0_1;
static const unsigned PIN_DIP11 = PIN_0_18;
static const unsigned PIN_DIP12 = PIN_0_17;
static const unsigned PIN_DIP13 = PIN_0_15;
static const unsigned PIN_DIP14 = PIN_0_16;
static const unsigned PIN_DIP15 = PIN_0_23;
static const unsigned PIN_DIP16 = PIN_0_24;
static const unsigned PIN_DIP17 = PIN_0_25;
static const unsigned PIN_DIP18 = PIN_0_26;
static const unsigned PIN_DIP19 = PIN_1_30;
static const unsigned PIN_DIP20 = PIN_1_31;
static const unsigned PIN_DIP21 = PIN_2_5;
static const unsigned PIN_DIP22 = PIN_2_4;
static const unsigned PIN_DIP23 = PIN_2_3;
static const unsigned PIN_DIP24 = PIN_2_2;
static const unsigned PIN_DIP25 = PIN_2_1;
static const unsigned PIN_DIP26 = PIN_2_0;
static const unsigned PIN_DIP27 = PIN_0_11;
static const unsigned PIN_DIP28 = PIN_0_10;
static const unsigned PIN_DIP29 = PIN_0_5;
static const unsigned PIN_DIP30 = PIN_0_4;
static const unsigned PIN_LED1 = PIN_1_18;
static const unsigned PIN_LED2 = PIN_1_20;
static const unsigned PIN_LED3 = PIN_1_21;
static const unsigned PIN_LED4 = PIN_1_23;
} // namespace MTL
#endif // MBED_LPC1768_PINS_H
| [
"anotherjohnh@gmail.com"
] | anotherjohnh@gmail.com |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.