blob_id
stringlengths 40
40
| directory_id
stringlengths 40
40
| path
stringlengths 2
247
| content_id
stringlengths 40
40
| detected_licenses
listlengths 0
57
| license_type
stringclasses 2
values | repo_name
stringlengths 4
111
| snapshot_id
stringlengths 40
40
| revision_id
stringlengths 40
40
| branch_name
stringlengths 4
58
| visit_date
timestamp[ns]date 2015-07-25 18:16:41
2023-09-06 10:45:08
| revision_date
timestamp[ns]date 1970-01-14 14:03:36
2023-09-06 06:22:19
| committer_date
timestamp[ns]date 1970-01-14 14:03:36
2023-09-06 06:22:19
| github_id
int64 3.89k
689M
โ | star_events_count
int64 0
209k
| fork_events_count
int64 0
110k
| gha_license_id
stringclasses 25
values | gha_event_created_at
timestamp[ns]date 2012-06-07 00:51:45
2023-09-14 21:58:52
โ | gha_created_at
timestamp[ns]date 2008-03-27 23:40:48
2023-08-24 19:49:39
โ | gha_language
stringclasses 159
values | src_encoding
stringclasses 34
values | language
stringclasses 1
value | is_vendor
bool 1
class | is_generated
bool 2
classes | length_bytes
int64 7
10.5M
| extension
stringclasses 111
values | filename
stringlengths 1
195
| text
stringlengths 7
10.5M
|
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
f7d9e7f2ff8a263ea2eff8fb57c4539f3b084600
|
be2372d829a46cb29b450eb95ec19cd92e0bbe1b
|
/moStepperlibA.cpp
|
9c254a33a33a60fe05a37c2700f98e07b5d2ff30
|
[] |
no_license
|
amckeeota/moStepperlibA
|
d069c34f30061aab2aecb708cd4aee53a5b1e344
|
0e6f72bee3e7075b98edece3b0ee6e1d289faf08
|
refs/heads/master
| 2016-08-12T05:51:22.197438
| 2015-12-17T08:08:24
| 2015-12-17T08:08:24
| 48,160,720
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,245
|
cpp
|
moStepperlibA.cpp
|
#include "Arduino.h"
#include "moStepperlib.h"
#include "String.h"
moStepper::moStepper(char assA,char assA_bar,char assB,char assB_bar){
A=assA;
A_bar = assA_bar;
B = assB;
B_bar = assB_bar;
pinMode(A,OUTPUT);
pinMode(B,OUTPUT);
pinMode(A_bar,OUTPUT);
pinMode(B_bar,OUTPUT);
a = amp;
b_bar = amp + division;
a_bar = amp + division*2;
b = amp + division*3;
}
void moStepper::stepForward(){
curStep++;
a++;
b++;
a_bar++;
b_bar++;
switch(curStep){
case division:
b = amp;
break;
case (division*2):
a_bar = amp;
break;
case (division*3):
b_bar = amp;
break;
case (division*4):
a= amp;
curStep=0;
break;
default:
break;
}
setMotor();
}
void moStepper::stepBack(){
curStep--;
a--;
b--;
a_bar--;
b_bar--;
switch(curStep){
case (-1):
a = &[(int)(numSteps-1)];
curStep=numSteps-1;
break;
case (3*division-1):
b_bar = &[(int)(numSteps-1)];
break;
case (2*division-1):
a_bar = &[(int)(numSteps-1)];
break;
case (division-1):
b = &[(int)(numSteps-1)];
break;
default:
break;
}
setMotor();
}
void moStepper::setMotor(){
digitalWrite(A,*a);
digitalWrite(B,*b);
digitalWrite(A_bar,*a_bar);
digitalWrite(B_bar,*b_bar);
}
|
d07a5009b7956674f4b05c82fea82fbd5a690025
|
818d205ced79f21481280f886de234f58e5f49cf
|
/SpiralMatrix/spiral_matrix_test.cpp
|
9a3839c1b0b5e7246c8d22c2296f9ede231b024a
|
[] |
no_license
|
babypuma/leetcode
|
6cafe2495b1b77701589be7d44e2c42e467cba18
|
0ac08c56623d5990d7fde45d0cc962f5926c6b64
|
refs/heads/master
| 2022-06-15T17:03:53.515967
| 2022-05-31T16:24:30
| 2022-05-31T16:24:30
| 25,457,134
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 3,146
|
cpp
|
spiral_matrix_test.cpp
|
/*
* Author : Jeremy Zhao
* Email : jqzhao@live.com
* Date : 2014/11/16
*
* Source : https://oj.leetcode.com/problems/spiral-matrix/
* Problem: Spiral Matrix
*
*/
#include <gtest/gtest.h>
#include <set>
#include "spiral_matrix.h"
class SolutionTest : public ::testing::Test {
protected:
virtual void SetUp() {
}
virtual void TearDown() {
}
Solution solution_;
};
TEST_F(SolutionTest, case1) {
vector<vector<int> > vec2d;
int a[][2] = {{1, 2}, {3, 4}};
for (size_t i = 0; i < sizeof(a)/sizeof(int[2]); i++) {
vector<int> vec(a[i], a[i] + sizeof(a[i])/sizeof(int));
vec2d.push_back(vec);
}
vector<int> v = solution_.spiralOrder(vec2d);
int b[] = {1, 2, 4, 3};
ASSERT_EQ(sizeof(b)/sizeof(int), v.size());
for (size_t i = 0; i < v.size(); i++) {
EXPECT_EQ(b[i], v[i]);
}
}
TEST_F(SolutionTest, case2) {
vector<vector<int> > vec2d;
int a[][3] = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}};
for (size_t i = 0; i < sizeof(a)/sizeof(int[3]); i++) {
vector<int> vec(a[i], a[i] + sizeof(a[i])/sizeof(int));
vec2d.push_back(vec);
}
vector<int> v = solution_.spiralOrder(vec2d);
int b[] = {1, 2, 3, 6, 9, 8, 7, 4, 5};
ASSERT_EQ(sizeof(b)/sizeof(int), v.size());
for (size_t i = 0; i < v.size(); i++) {
EXPECT_EQ(b[i], v[i]);
}
}
TEST_F(SolutionTest, case3) {
vector<vector<int> > vec2d;
int a[][4] = {{1, 2, 3, 4}, {5, 6, 7, 8}, {9, 10, 11, 12}, {13, 14, 15, 16}};
for (size_t i = 0; i < sizeof(a)/sizeof(int[4]); i++) {
vector<int> vec(a[i], a[i] + sizeof(a[i])/sizeof(int));
vec2d.push_back(vec);
}
vector<int> v = solution_.spiralOrder(vec2d);
int b[] = {1, 2, 3, 4, 8, 12, 16, 15, 14, 13, 9, 5, 6, 7, 11, 10};
ASSERT_EQ(sizeof(b)/sizeof(int), v.size());
for (size_t i = 0; i < v.size(); i++) {
EXPECT_EQ(b[i], v[i]);
}
}
TEST_F(SolutionTest, case4) {
vector<vector<int> > vec2d;
int a[][3] = {{2, 5, 8}, {4, 0, -1}};
for (size_t i = 0; i < sizeof(a)/sizeof(int[3]); i++) {
vector<int> vec(a[i], a[i] + sizeof(a[i])/sizeof(int));
vec2d.push_back(vec);
}
vector<int> v = solution_.spiralOrder(vec2d);
int b[] = {2, 5, 8, -1, 0, 4};
ASSERT_EQ(sizeof(b)/sizeof(int), v.size());
for (size_t i = 0; i < v.size(); i++) {
EXPECT_EQ(b[i], v[i]);
}
}
TEST_F(SolutionTest, case5) {
vector<vector<int> > vec2d;
vector<int> vec(1, 1);
vec2d.push_back(vec);
vector<int> v = solution_.spiralOrder(vec2d);
ASSERT_EQ(1, (int)v.size());
EXPECT_EQ(1, v[0]);
}
TEST_F(SolutionTest, case6) {
vector<vector<int> > vec2d;
vector<int> vec(1, 1);
vec2d.push_back(vec);
vector<int> v = solution_.spiralOrder(vec2d);
ASSERT_EQ(1, (int)v.size());
EXPECT_EQ(1, v[0]);
}
TEST_F(SolutionTest, case7) {
vector<vector<int> > vec2d;
int a[][3] = {{2, 3, 4}, {5, 6, 7}, {8, 9, 10}, {11, 12, 13}};
for (size_t i = 0; i < sizeof(a)/sizeof(int[3]); i++) {
vector<int> vec(a[i], a[i] + sizeof(a[i])/sizeof(int));
vec2d.push_back(vec);
}
vector<int> v = solution_.spiralOrder(vec2d);
int b[] = {2, 3, 4, 7, 10, 13, 12, 11, 8, 5, 6, 9};
ASSERT_EQ(sizeof(b)/sizeof(int), v.size());
for (size_t i = 0; i < v.size(); i++) {
EXPECT_EQ(b[i], v[i]);
}
}
|
cc406beef879bb6f16d67e64d0e0a75787b0d77a
|
21416342a748cfcb926a0f299b1a7354626a8a29
|
/src/lib/net/ClientSocket.cpp
|
92dcaf44f6e0e4e8125bb4ca82ae6752881bf40f
|
[
"MIT"
] |
permissive
|
Cheney0712/SysMonitor
|
0d23eaa5434c3c28b0603e1e85f4a25682fe5917
|
fdaac5eacf28b62739c4e050e27abd1fdbfd18c4
|
refs/heads/master
| 2022-04-09T07:03:20.290918
| 2020-04-07T14:12:00
| 2020-04-07T14:12:00
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,357
|
cpp
|
ClientSocket.cpp
|
#include "ClientSocket.h"
#ifdef __WINDOWS__
#include<winsock2.h>
#else //__LINUX__
#include <unistd.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#endif
ClientSocket::ClientSocket()
{
m_sock = socket(AF_INET, SOCK_STREAM, 0);
}
ClientSocket::~ClientSocket() {}
int ClientSocket::Connect(const SocketAddress &remote)
{
m_remote = remote;
// server ip address
sockaddr_in serverAddr;
serverAddr.sin_addr.s_addr = inet_addr(remote.IP().Str().c_str());
serverAddr.sin_family = AF_INET;
serverAddr.sin_port = htons(remote.Port());
int rc = connect(m_sock, (sockaddr*)&serverAddr, sizeof(sockaddr));
if (0 == rc)
{
// remote ip address
sockaddr_in remoteAddr;
socklen_t len = sizeof(sockaddr_in);
int rc2 = getpeername(m_sock, (sockaddr*)&remoteAddr, &len);
if (0 == rc2)
{
m_remote.SetIP(inet_ntoa(remoteAddr.sin_addr));
m_remote.SetPort(ntohs(remoteAddr.sin_port));
}
// local ip address
sockaddr_in localAddr;
len = sizeof(sockaddr_in);
rc2 = getsockname(m_sock, (sockaddr*)&localAddr, &len);
if (0 == rc2)
{
m_local.SetIP(inet_ntoa(localAddr.sin_addr));
m_local.SetPort(ntohs(localAddr.sin_port));
}
}
return rc;
}
|
637170e929051604e7eb5f1ecd2afddf2a5f146a
|
dd50d1a5a3c7e96e83e75f68c7a940f91275f206
|
/source/tnn/device/opencl/acc/opencl_upsample_layer_acc.cc
|
ddd55d0f61d9d015aca04f8104c31a5f32812979
|
[
"BSD-3-Clause"
] |
permissive
|
bluaxe/TNN
|
2bfdecc85ac4684e82032a86703eacaed5419ad6
|
cafdb8792dc779236ec06dbeb65710073d27ebcd
|
refs/heads/master
| 2023-03-19T02:55:39.007321
| 2021-03-04T02:59:18
| 2021-03-04T02:59:18
| 272,395,487
| 3
| 0
|
NOASSERTION
| 2020-12-30T08:10:31
| 2020-06-15T09:23:31
|
C++
|
UTF-8
|
C++
| false
| false
| 6,045
|
cc
|
opencl_upsample_layer_acc.cc
|
// Tencent is pleased to support the open source community by making TNN available.
//
// Copyright (C) 2020 THL A29 Limited, a Tencent company. All rights reserved.
//
// Licensed under the BSD 3-Clause License (the "License"); you may not use this file except
// in compliance with the License. You may obtain a copy of the License at
//
// https://opensource.org/licenses/BSD-3-Clause
//
// Unless required by applicable law or agreed to in writing, software distributed
// under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
// CONDITIONS OF ANY KIND, either express or implied. See the License for the
// specific language governing permissions and limitations under the License.
#include "tnn/device/opencl/acc/opencl_layer_acc.h"
#include "tnn/device/opencl/imagebuffer_convertor.h"
namespace TNN_NS {
DECLARE_OPENCL_ACC(Upsample);
static std::vector<uint32_t> UpsampleLocalWS3D(std::vector<uint32_t> &gws, const uint32_t max_workgroup_size) {
uint32_t compute_units = OpenCLRuntime::GetInstance()->DeviceComputeUnits();
GpuType gpu_type = OpenCLRuntime::GetInstance()->GetGpuInfo().type;
std::vector<uint32_t> lws(3, 0);
if (gpu_type == GpuType::ADRENO) {
lws[0] = 4;
lws[1] = gcd(gcd(max_workgroup_size / 16, compute_units * 4), gws[1]);
lws[2] = 4;
} else {
lws[0] = 4;
lws[1] = max_workgroup_size / 16;
lws[2] = 4;
}
return lws;
}
Status OpenCLUpsampleLayerAcc::Init(Context *context, LayerParam *param, LayerResource *resource,
const std::vector<Blob *> &inputs, const std::vector<Blob *> &outputs) {
LOGD("Init Upsample Acc\n");
Status ret = OpenCLLayerAcc::Init(context, param, resource, inputs, outputs);
CHECK_TNN_OK(ret)
op_name_ = "Upsample";
UpsampleLayerParam *upsample_param = dynamic_cast<UpsampleLayerParam *>(param);
if (!upsample_param) {
LOGE("Error: layer param is null\n");
return Status(TNNERR_MODEL_ERR, "Error: layer param is null");
}
// create kernel
std::string kernel_name;
if (upsample_param->mode == 1) { // nearst
LOGD("build nearest\n");
kernel_name = "Nearest";
} else if (upsample_param->mode == 2) { // bilinear
if (upsample_param->align_corners) {
LOGD("build bilinear with aligned corners\n");
kernel_name = "BilinearAlignCorners";
} else {
LOGD("build bilinear\n");
kernel_name = "Bilinear";
}
} else if (upsample_param->mode == 3) { // cubic
if (upsample_param->align_corners) {
LOGD("build cubic with aligned corners\n");
kernel_name = "CubicAlignCorners";
} else {
LOGD("build cubic\n");
kernel_name = "Cubic";
}
} else {
LOGE("Not support Upsample type: %d\n", upsample_param->mode);
return Status(TNNERR_OPENCL_ACC_INIT_ERROR, "invalid upsample mode");
}
if (run_3d_ndrange_) {
kernel_name += "GS3D";
}
ret = CreateExecuteUnit(execute_units_[0], "upsample", kernel_name);
if (ret != TNN_OK) {
LOGE("create execute unit failed!\n");
return ret;
}
return TNN_OK;
}
Status OpenCLUpsampleLayerAcc::Reshape(const std::vector<Blob *> &inputs, const std::vector<Blob *> &outputs) {
LOGD("Upsample Acc Reshape\n");
UpsampleLayerParam *upsample_param = dynamic_cast<UpsampleLayerParam *>(param_);
if (!upsample_param) {
LOGE("Error: layer param is null\n");
return Status(TNNERR_MODEL_ERR, "Error: layer param is null");
}
auto input = inputs[0];
auto output = outputs[0];
auto input_dims = input->GetBlobDesc().dims;
auto output_dims = output->GetBlobDesc().dims;
const int batch = input_dims[0];
const int channels = input_dims[1];
const int input_height = input_dims[2];
const int input_width = input_dims[3];
const int output_height = output_dims[2];
const int output_width = output_dims[3];
const int channel_blocks = UP_DIV(channels, 4);
float height_scale;
float width_scale;
if ((upsample_param->mode == 2 || upsample_param->mode == 3) && upsample_param->align_corners) {
height_scale = (float)(input_height - 1) / (float)(output_height - 1);
width_scale = (float)(input_width - 1) / (float)(output_width - 1);
} else {
height_scale = (float)input_height / (float)output_height;
width_scale = (float)input_width / (float)output_width;
}
uint32_t idx = 0;
if (run_3d_ndrange_) {
execute_units_[0].global_work_size = {static_cast<uint32_t>(output_width),
static_cast<uint32_t>(channel_blocks),
static_cast<uint32_t>(batch * output_height)};
execute_units_[0].local_work_size =
UpsampleLocalWS3D(execute_units_[0].global_work_size, execute_units_[0].workgroupsize_max);
for (auto gws : execute_units_[0].global_work_size) {
execute_units_[0].ocl_kernel.setArg(idx++, gws);
}
} else {
idx = SetExecuteUnit2DSizeInfoDefault(execute_units_[0], output_dims);
}
execute_units_[0].ocl_kernel.setArg(idx++, *((cl::Image *)input->GetHandle().base));
execute_units_[0].ocl_kernel.setArg(idx++, *((cl::Image *)output->GetHandle().base));
execute_units_[0].ocl_kernel.setArg(idx++, height_scale);
execute_units_[0].ocl_kernel.setArg(idx++, width_scale);
execute_units_[0].ocl_kernel.setArg(idx++, static_cast<int32_t>(input_height));
execute_units_[0].ocl_kernel.setArg(idx++, static_cast<int32_t>(input_width));
execute_units_[0].ocl_kernel.setArg(idx++, static_cast<int32_t>(output_height));
if (!run_3d_ndrange_) {
execute_units_[0].ocl_kernel.setArg(idx++, static_cast<int32_t>(output_width));
}
return TNN_OK;
}
REGISTER_OPENCL_ACC(Upsample, LAYER_UPSAMPLE)
} // namespace TNN_NS
|
5b43b1d15069ea00647e8a9f1632499d64c7cca7
|
2b0ff7f7529350a00a34de9050d3404be6d588a0
|
/026_ๅๅฒ่ฆ็ช_Bar/03_OpenGL ็ฐกๅฎๆฉๅจๆ่ๅ ไธBar/OpenGL ็ฐกๅฎๆฉๅจๆ่ๅ ไธBar2/ๅ
ญๆกฟ/Bar.cpp
|
0c5a61d7d7c6b8402c5583b56d2013ced24a364a
|
[] |
no_license
|
isliulin/jashliao_VC
|
6b234b427469fb191884df2def0b47c4948b3187
|
5310f52b1276379b267acab4b609a9467f43d8cb
|
refs/heads/master
| 2023-05-13T09:28:49.756293
| 2021-06-08T13:40:23
| 2021-06-08T13:40:23
| null | 0
| 0
| null | null | null | null |
BIG5
|
C++
| false
| false
| 2,814
|
cpp
|
Bar.cpp
|
// Bar.cpp : implementation file
//
#include "stdafx.h"
#include "GLbase.h"
#include "Bar.h"
#include "MainFrm.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
CMainFrame *CMainFrame1;
/////////////////////////////////////////////////////////////////////////////
// CBar dialog
CBar::CBar(CWnd* pParent /*=NULL*/)
: CDialogBar()
{
//{{AFX_DATA_INIT(CBar)
m_str1 = _T("็ฌฌไธๆ่ฝ่ปธ");
m_str2 = _T("็ฌฌไบๆ่ฝ่ปธ");
m_str3 = _T("็ฌฌไธๆ่ฝ่ปธ");
m_str4 = _T("็ฌฌๅๆ่ฝ่ปธ");
m_str5 = _T("็ฌฌไบๆ่ฝ่ปธ");
m_str6 = _T("็ฌฌไธไผธ้ท้");
m_v1 = 0.0f;
m_v2 = 0.0f;
m_v3 = 0.0f;
m_v4 = 0.0f;
m_v5 = 0.0f;
m_v6 = 0.0f;
//}}AFX_DATA_INIT
}
void CBar::DoDataExchange(CDataExchange* pDX)
{
CDialogBar::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CBar)
DDX_Text(pDX, IDC_EDIT7, m_str1);
DDX_Text(pDX, IDC_EDIT8, m_str2);
DDX_Text(pDX, IDC_EDIT9, m_str3);
DDX_Text(pDX, IDC_EDIT10, m_str4);
DDX_Text(pDX, IDC_EDIT11, m_str5);
DDX_Text(pDX, IDC_EDIT12, m_str6);
DDX_Text(pDX, IDC_EDIT1, m_v1);
DDX_Text(pDX, IDC_EDIT2, m_v2);
DDX_Text(pDX, IDC_EDIT3, m_v3);
DDX_Text(pDX, IDC_EDIT4, m_v4);
DDX_Text(pDX, IDC_EDIT5, m_v5);
DDX_Text(pDX, IDC_EDIT6, m_v6);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CBar, CDialogBar)
//{{AFX_MSG_MAP(CBar)
// NOTE: the ClassWizard will add message map macros here
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CBar message handlers
void CBar::GetData(float *data)
{
UpdateData(true);
*(data+0)=m_v1;
*(data+1)=m_v2;
*(data+2)=m_v3;
*(data+3)=m_v4;
*(data+4)=m_v5;
*(data+5)=m_v6;
UpdateData(false);
}
void CBar::SentData(int index,float data)
{
UpdateData(true);
switch(index)
{
case 0:
m_v1+=data;
m_v2+=0;
m_v3+=0;
m_v4+=0;
m_v5+=0;
m_v6+=0;
break;
case 1:
m_v1+=0;
m_v2+=data;
m_v3+=0;
m_v4+=0;
m_v5+=0;
m_v6+=0;
break;
case 2:
m_v1+=0;
m_v2+=0;
m_v3+=data;
m_v4+=0;
m_v5+=0;
m_v6+=0;
break;
case 3:
m_v1+=0;
m_v2+=0;
m_v3+=0;
m_v4+=data;
m_v5+=0;
m_v6+=0;
break;
case 4:
m_v1+=0;
m_v2+=0;
m_v3+=0;
m_v4+=0;
m_v5+=data;
m_v6+=0;
break;
case 5:
m_v1+=0;
m_v2+=0;
m_v3+=0;
m_v4+=0;
m_v5+=0;
m_v6+=data;
break;
}
UpdateData(false);
}
void CBar::show(void)
{
CMainFrame1=(CMainFrame*)AfxGetMainWnd();
if(!IsWindow(m_hWnd))
{
if(Create(CMainFrame1,IDD_DIALOGBAR,CBRS_LEFT,AFX_IDW_CONTROLBAR_FIRST+32))
{
UpdateData(false);
EnableDocking(CBRS_ALIGN_LEFT);
CMainFrame1->DockControlBar(this,AFX_IDW_DOCKBAR_LEFT);
UpdateData(false);
//p=fopen("test.txt","w");
}
}
else
{
CMainFrame1->ShowControlBar(this,!IsWindowVisible(),false);
//fclose(p);
}
}
|
64432777dcefa3475b4cc0798e3c7706cffee35c
|
0e453b30c164a7b6f528afcde8d00df3a5805020
|
/InputManager.h
|
53e00bb2a2c81690f802fc9f89edc6e51602adea
|
[] |
no_license
|
ethragur/CG_2015
|
6064f732217ccc28a0525e4ba2ab743a11303f2b
|
176608720e74031034dd8f459fd6b57cc0533d50
|
refs/heads/master
| 2021-01-15T15:32:29.592404
| 2016-08-21T18:01:07
| 2016-08-21T18:01:07
| 33,717,225
| 1
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 536
|
h
|
InputManager.h
|
#ifndef INPUTMANAGER_H
#define INPUTMANAGER_H
class InputManager
{
private:
//vars
static bool FORWARD;
static bool BACK;
static bool RIGHT;
static bool LEFT;
static bool MODE1;
public:
//func
static void keyboard(unsigned char key, int x, int y);
static void keyboardUp(unsigned char key, int x, int y);
static void mouse(int button, int state, int x, int y);
static void mouseMovement(int x, int y);
static void acMouseMovement(int x, int y);
static void onIdle();
};
#endif //INPUTMANAGER_H
|
b3514a95ec67623dfcc1101d7b24d40edb88b2fe
|
0b55957db9f5b13c526a82a310bc3b94bf746db9
|
/src/unit_tests/InterfaceDialogTest/InterfaceDialogTest.cpp
|
257c993814683528c214798d25166c4f94772fa1
|
[] |
no_license
|
fwbuilder/fwbuilder
|
ba8cdb6f2b68ca733a7e7a0b2f1c3720ee32019d
|
8013c00e1f29350d96926768290e8c7f91cda424
|
refs/heads/master
| 2023-08-06T06:07:30.933612
| 2023-07-22T22:56:24
| 2023-07-22T22:56:24
| 22,487,992
| 263
| 96
| null | 2023-05-20T12:20:59
| 2014-07-31T22:52:40
|
C++
|
UTF-8
|
C++
| false
| false
| 6,806
|
cpp
|
InterfaceDialogTest.cpp
|
/*
Firewall Builder
Copyright (C) 2010 NetCitadel, LLC
Author: Roman Bovsunivskiy a2k0001@gmail.com
$Id: InterfaceDialogTestTest.cpp 2723 2010-03-16 17:32:18Z a2k $
This program is free software which we release under the GNU General Public
License. You may redistribute and/or modify this program under the terms
of that license as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
To get a copy of the GNU General Public License, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "InterfaceDialogTest.h"
//#include "../../global.h"
#include <QApplication>
#include <QFile>
#include <QTextStream>
#include <QTest>
#include <iostream>
#include <QProcess>
#include <QDebug>
#include <QToolButton>
#include <QMessageBox>
#include <QWidget>
#include <QLineEdit>
#include "FWWindow.h"
#include "ProjectPanel.h"
#include "ObjectTreeView.h"
#include "ObjectTreeViewItem.h"
#include "ObjectEditor.h"
#include "FWObjectClipboard.h"
#include "TextEditWidget.h"
#include "fwbuilder/Address.h"
#include "fwbuilder/IPv4.h"
#include "fwbuilder/IPv6.h"
#include "FWBTree.h"
#include "fwbuilder/Library.h"
#include "fwbuilder/FWObjectDatabase.h"
#include "InterfaceDialog.h"
#include "StartTipDialog.h"
#include "fwbuilder/FWObjectDatabase.h"
#include "fwbuilder/Interface.h"
#include "InterfaceDialogTest.h"
#include "fwbuilder/IPService.h"
using namespace std;
using namespace libfwbuilder;
void InterfaceDialogTest::initTestCase()
{
new FWObjectClipboard();
mw = new FWWindow();
mw->show();
mw->startupLoad();
// mw->resize(1200, 600);
StartTipDialog *d = mw->findChild<StartTipDialog*>();
if (d!=nullptr) d->close();
om = dynamic_cast<ObjectManipulator*>(mw->getCurrentObjectTree()->parent()->parent());
QTest::qWait(1000);
firewall = Firewall::cast(om->createObject(FWBTree().getStandardSlotForObject(findUserLibrary(), Firewall::TYPENAME), Firewall::TYPENAME, "TestFirewall"));
firewall->setStr("platform", "pix"); // using pix platforms as it supports all dialog options
interface = Interface::cast(om->createObject(firewall, Interface::TYPENAME, "TestInterface"));
QVERIFY(interface!=nullptr);
}
Library* InterfaceDialogTest::findUserLibrary()
{
Library *lib = nullptr;
foreach (FWObject *obj, mw->db()->getByType(Library::TYPENAME))
{
if (obj->getName() == "User")
{
lib = Library::cast(obj);
break;
}
}
return lib;
}
void InterfaceDialogTest::testDialog()
{
om->editObject(interface);
InterfaceDialog *dialog = mw->findChild<InterfaceDialog*>("w_InterfaceDialog");
QVERIFY(dialog != nullptr);
QLineEdit *obj_name = dialog->findChild<QLineEdit*>("obj_name");
QLineEdit *label = dialog->findChild<QLineEdit*>("label");
TextEditWidget *comment = dialog->findChild<TextEditWidget*>("comment");
//options:
QSpinBox *seclevel = dialog->findChild<QSpinBox*>("seclevel");
QComboBox *netzone = dialog->findChild<QComboBox*>("netzone");
QCheckBox *management = dialog->findChild<QCheckBox*>("management");
QCheckBox *unprotected = dialog->findChild<QCheckBox*>("unprotected");
QCheckBox *dedicated_failover = dialog->findChild<QCheckBox*>("dedicated_failover");
QRadioButton *regular = dialog->findChild<QRadioButton*>("regular");
QRadioButton *dynamic = dialog->findChild<QRadioButton*>("dynamic");
QRadioButton *unnumbered = dialog->findChild<QRadioButton*>("unnumbered");
// setting object name
obj_name->clear();
QTest::keyClicks(obj_name, "TestInterfaceName");
QTest::keyClick(obj_name, Qt::Key_Enter);
QVERIFY(interface->getName() == "TestInterfaceName");
// setting label
label->clear();
QTest::keyClicks(label, "TestInterfaceLabel");
QTest::keyClick(label, Qt::Key_Enter);
QVERIFY(interface->getLabel() == "TestInterfaceLabel");
// setting comment
comment->clear();
QTest::mouseClick(comment, Qt::LeftButton);
QTest::keyClicks(comment, "Test comment");
QTest::mouseClick(comment, Qt::LeftButton);
QTest::keyClick(comment, Qt::Key_Tab);
QTest::qWait(100);
QVERIFY (interface->getComment() == "Test comment");
// setting security level
QTest::mouseClick(seclevel, Qt::LeftButton);
QTest::keyClick(seclevel, Qt::Key_Up);
QTest::keyClick(seclevel, Qt::Key_Up);
QTest::keyClick(seclevel, Qt::Key_Enter);
QVERIFY(interface->getSecurityLevel() == 2);
// testing management
QVERIFY(interface->isManagement() == false);
QTest::mouseClick(management, Qt::LeftButton);
QVERIFY(interface->isManagement() == true);
QTest::mouseClick(management, Qt::LeftButton);
QVERIFY(interface->isManagement() == false);
// testing unprotected
QVERIFY(interface->isUnprotected() == false);
QTest::mouseClick(unprotected, Qt::LeftButton);
QVERIFY(interface->isUnprotected() == true);
QTest::mouseClick(unprotected, Qt::LeftButton);
QVERIFY(interface->isUnprotected() == false);
// testing dedicated failover
QVERIFY(interface->isDedicatedFailover() == false);
QTest::mouseClick(dedicated_failover, Qt::LeftButton);
QVERIFY(interface->isDedicatedFailover() == true);
QTest::mouseClick(dedicated_failover, Qt::LeftButton);
QVERIFY(interface->isDedicatedFailover() == false);
// testing regular/dynamic/unnumbered switch
QTest::mouseClick(regular, Qt::LeftButton, Qt::NoModifier, QPoint(5, 5));
QVERIFY(interface->isRegular() == true);
QVERIFY(interface->isDyn() == false);
QVERIFY(interface->isUnnumbered() == false);
QTest::mouseClick(dynamic, Qt::LeftButton);
QVERIFY(interface->isRegular() == false);
QVERIFY(interface->isDyn() == true);
QVERIFY(interface->isUnnumbered() == false);
QTest::mouseClick(unnumbered, Qt::LeftButton);
QVERIFY(interface->isRegular() == false);
QVERIFY(interface->isDyn() == false);
QVERIFY(interface->isUnnumbered() == true);
// testing that changing netzone combo value changed interface's property
string zone = interface->getStr("network_zone");
bool changed = false;
for(int i=0; i<netzone->count(); i++)
{
netzone->setCurrentIndex(i);
dialog->changed();
if (interface->getStr("network_zone") != zone)
{
changed = true;
break;
}
}
QVERIFY(changed);
}
|
3c31d48cc4e65796040c47052ee2c4d0a215df47
|
f7310e96ab2cdbd4f8f98581db7d707e5304a320
|
/src/httpd/page_handler.hpp
|
3494edc74730e7319a2f044d6ea05af70c9faec0
|
[] |
no_license
|
qtplatz/acqiris-httpd
|
72a014a118cc7f3a958942334bbddd3543983fa8
|
2d22db449628c48198db26f2339c5f1af41edc49
|
refs/heads/master
| 2020-03-24T22:39:07.417931
| 2018-08-08T01:53:23
| 2018-08-08T01:53:23
| 143,096,162
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 2,653
|
hpp
|
page_handler.hpp
|
// -*- C++ -*-
/**************************************************************************
** Copyright (C) 2010-2018 Toshinobu Hondo, Ph.D.
** Copyright (C) 2013-2018 MS-Cheminformatics LLC
*
** Contact: toshi.hondo@scienceliaison.com
**
** Commercial Usage
**
** Licensees holding valid ScienceLiaison commercial licenses may use this
** file in accordance with the ScienceLiaison Commercial License Agreement
** provided with the Software or, alternatively, in accordance with the terms
** contained in a written agreement between you and ScienceLiaison.
**
** GNU Lesser General Public License Usage
**
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.TXT included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
**************************************************************************/
#pragma once
#include <boost/signals2.hpp>
#include <boost/asio.hpp>
#include <array>
#include <atomic>
#include <memory>
#include <mutex>
#include <utility>
#include <vector>
#include <functional>
namespace acqrscontrols { namespace aqdrv4 { class waveform; } }
namespace acqiris {
class task;
class page_handler {
std::mutex mutex_;
page_handler();
public:
~page_handler();
constexpr static const char * prefix{ "/api$" };
constexpr static const size_t prefix_size = sizeof( "/api$" ) - 1;
static page_handler * instance();
enum { nitem = 32 };
size_t size() const;
void commit();
// bool http_request( const std::string& method, const std::string& request_path, std::string& );
bool http_request( const std::string& method, const std::string& request_path, const std::string& body, std::string& reply );
void handle_tick();
void handle_temperature( double );
void handle_waveform( std::shared_ptr< const acqrscontrols::aqdrv4::waveform > );
typedef boost::signals2::signal< void( const std::string&, const std::string&, const std::string& ) > sse_handler_t;
boost::signals2::connection register_sse_handler( const sse_handler_t::slot_type& );
void setTask( std::shared_ptr< task > );
private:
sse_handler_t sse_handler_;
uint32_t event_id_;
std::atomic_flag spin_flag_;
std::shared_ptr< task > task_;
};
}
|
68f0a1d4e88202f218fd55af9e08122dfce3a531
|
607161f98685a5f164aee88d9f11085dbcc9d041
|
/Integer2English/gtestcase.cpp
|
b7b366688ae0518e601616f214f1e6106e275a5a
|
[] |
no_license
|
juehan/Integer2English
|
88a8ff9ea1fd62ff30b310e20bbed63de93b3a89
|
c1bb42a112943b3a215590e4d42d2ef276fcd1b8
|
refs/heads/master
| 2021-01-10T22:05:42.395133
| 2013-01-07T02:45:44
| 2013-01-07T02:45:44
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 4,291
|
cpp
|
gtestcase.cpp
|
/*****************************************************************************
* gtestcase.cpp: gtest unittest
* Copyright (C) 2013 John (Juhan) Lee
* Authors: John (Juhan) Lee<to.johnny.lee@gmail.com>
* Description: googletest unittest of Int2Eng Class
* Date: 05. Jan. 2013
*****************************************************************************/
#include "gtest/gtest.h"
#include "Int2Eng.h"
TEST(InputTest, twoDigit)
{
Int2Eng in1("45");
in1.parse();
EXPECT_TRUE(in1.digit() == 2);
Int2Eng in2("-93");
in2.parse();
EXPECT_TRUE(in2.digit() == 2);
}
TEST(InputTest, threeDigit)
{
Int2Eng in1("456");
in1.parse();
EXPECT_TRUE(in1.digit() == 3);
Int2Eng in2("-631");
EXPECT_TRUE(in1.digit() == 3);
}
TEST(InputTest, fourDigit)
{
Int2Eng in1("4567");
in1.parse();
EXPECT_TRUE(in1.digit() == 4);
Int2Eng in2("-6315");
in2.parse();
EXPECT_TRUE(in2.digit() == 4);
}
TEST(InputTest, fiveDigit)
{
Int2Eng in1("12345");
in1.parse();
EXPECT_TRUE(in1.digit() == 5);
Int2Eng in2("-63186");
in2.parse();
EXPECT_TRUE(in2.digit() == 5);
}
TEST(InputTest, sixDigit)
{
Int2Eng in1("453223");
in1.parse();
EXPECT_TRUE(in1.digit() == 6);
Int2Eng in2("-631863");
in2.parse();
EXPECT_TRUE(in2.digit() == 6);
}
TEST(ValidityTest, isNumber)
{
Int2Eng in1("34dasd");
in1.parse();
EXPECT_FALSE(in1.parse());
Int2Eng in2("a4xjdhe");
in2.parse();
EXPECT_FALSE(in2.parse());
Int2Eng in3("??92");
in3.parse();
EXPECT_FALSE(in3.parse());
Int2Eng in4("12345678901234567890123456789012");//32bit
in4.parse();
EXPECT_TRUE(in4.parse());
}
TEST(ValidityTest, isNegative)
{
Int2Eng in6("-34123");
in6.parse();
EXPECT_TRUE(in6.parse());
Int2Eng in7("-3-4123");
in7.parse();
EXPECT_FALSE(in7.parse());
}
TEST(Analyse, t0)
{
//10 -> ten
Int2Eng in0("10");
EXPECT_TRUE(in0.parse());
ASSERT_STRCASEEQ("ten", in0.buildStr().c_str());
Int2Eng in1("11");
EXPECT_TRUE(in1.parse());
ASSERT_STRCASEEQ("eleven", in1.buildStr().c_str());
Int2Eng in2("12");
EXPECT_TRUE(in2.parse());
ASSERT_STRCASEEQ("twelve", in2.buildStr().c_str());
Int2Eng in3("15");
EXPECT_TRUE(in3.parse());
ASSERT_STRCASEEQ("fifteen", in3.buildStr().c_str());
Int2Eng in4("19");
EXPECT_TRUE(in4.parse());
ASSERT_STRCASEEQ("nineteen", in4.buildStr().c_str());
Int2Eng in5("0");
EXPECT_TRUE(in5.parse());
ASSERT_STRCASEEQ("zero", in5.buildStr().c_str());
Int2Eng in6("9");
EXPECT_TRUE(in6.parse());
ASSERT_STRCASEEQ("nine", in6.buildStr().c_str());
}
TEST(Analyse, t1)
{
Int2Eng in1("64");
EXPECT_TRUE(in1.parse());
ASSERT_STRCASEEQ("sixty four", in1.buildStr().c_str());
Int2Eng in2("99");
EXPECT_TRUE(in2.parse());
ASSERT_STRCASEEQ("ninety nine", in2.buildStr().c_str());
Int2Eng in3("21");
EXPECT_TRUE(in3.parse());
ASSERT_STRCASEEQ("twenty one", in3.buildStr().c_str());
}
TEST(Analyse, t2)
{
Int2Eng in1("264");
EXPECT_TRUE(in1.parse());
ASSERT_STRCASEEQ("two hundred sixty four", in1.buildStr().c_str());
Int2Eng in2("-189");
EXPECT_TRUE(in2.parse());
ASSERT_STRCASEEQ("minus one hundred eighty nine", in2.buildStr().c_str());
Int2Eng in3("-766");
EXPECT_TRUE(in3.parse());
ASSERT_STRCASEEQ("minus seven hundred sixty six", in3.buildStr().c_str());
//121 -> one hundred twenty one
Int2Eng in4("121");
EXPECT_TRUE(in4.parse());
ASSERT_STRCASEEQ("one hundred twenty one", in4.buildStr().c_str());
}
TEST(Analyse, t3)
{
Int2Eng in1("6423");
EXPECT_TRUE(in1.parse());
ASSERT_STRCASEEQ("six thousand four hundred twenty three", in1.buildStr().c_str());
Int2Eng in2("6419");
EXPECT_TRUE(in2.parse());
ASSERT_STRCASEEQ("six thousand four hundred nineteen", in2.buildStr().c_str());
//1032 -> one thousand thirty two
Int2Eng in3("1032");
EXPECT_TRUE(in3.parse());
ASSERT_STRCASEEQ("one thousand thirty two", in3.buildStr().c_str());
}
TEST(Analyse, t4)
{
Int2Eng in1("46423");
EXPECT_TRUE(in1.parse());
ASSERT_STRCASEEQ("fourty six thousand four hundred twenty three", in1.buildStr().c_str());
Int2Eng in2("46412");
EXPECT_TRUE(in2.parse());
ASSERT_STRCASEEQ("fourty six thousand four hundred twelve", in2.buildStr().c_str());
//11043 -> eleven thousand forty three
Int2Eng in3("11043");
EXPECT_TRUE(in3.parse());
ASSERT_STRCASEEQ("eleven thousand fourty three", in3.buildStr().c_str());
}
|
f36d518c4ba3201f56ab4fd1921f34c10659f7f4
|
1a390314e2dc92575dbf2541e2990bf1269b06e6
|
/Baekjoon/3986.cpp
|
8cd2beb5b8f15541e768f24ccb3fa0153a145374
|
[
"MIT"
] |
permissive
|
Twinparadox/AlgorithmProblem
|
c27ca6b48cdaf256ef25bc7b2fd6c233b2da4df1
|
0190d17555306600cfd439ad5d02a77e663c9a4e
|
refs/heads/master
| 2021-01-11T06:33:47.760303
| 2020-11-08T00:43:24
| 2020-11-08T00:43:24
| 69,226,206
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 467
|
cpp
|
3986.cpp
|
#include <iostream>
#include <stack>
#include <string>
using namespace std;
int main(void)
{
int N, ans = 0;
cin >> N;
while (N--)
{
string str;
stack<char> st;
cin >> str;
int len = str.length();
for (int i = 0; i < len; i++)
{
char c = str[i];
if (st.size() > (len - i))
break;
if (st.size() == 0)
st.push(c);
else if (st.top() == c)
st.pop();
else
st.push(c);
}
if (st.size() == 0)
ans++;
}
cout << ans;
}
|
ee72f8d04e831bd526566d3cccd0bdac65900d32
|
aa01d4bf21833cc30ce93304cd0a843d61e1bd3d
|
/main.cpp
|
2685a0450659b1a69301a637ab4e5596def5db4f
|
[] |
no_license
|
bakwc/ImageRobot
|
126e1ebf763a7796b24ec9171daa7a4ff4c68b62
|
31c09830ba377836522865e94605f9d4c1077bd8
|
refs/heads/master
| 2021-01-13T02:07:13.760748
| 2012-12-07T06:35:00
| 2012-12-07T06:35:00
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 351
|
cpp
|
main.cpp
|
#include <iostream>
#include "application.h"
void myMsgHandler(QtMsgType messageType, const char *msg) {
if (messageType == QtDebugMsg) {
std::cout << msg << "\n";
}
}
int main(int argc, char *argv[])
{
qInstallMsgHandler(myMsgHandler);
TApplication app(argc, argv);
app.Init();
app.Start();
return app.exec();
}
|
ae56305defbfa14ee74660b8f0866af8820b394a
|
a7764174fb0351ea666faa9f3b5dfe304390a011
|
/drv/Hatch/Hatch_SequenceNodeOfSequenceOfLine_0.cxx
|
598e24ab40155b703576434c4ab9a3dd0f0bc05f
|
[] |
no_license
|
uel-dataexchange/Opencascade_uel
|
f7123943e9d8124f4fa67579e3cd3f85cfe52d91
|
06ec93d238d3e3ea2881ff44ba8c21cf870435cd
|
refs/heads/master
| 2022-11-16T07:40:30.837854
| 2020-07-08T01:56:37
| 2020-07-08T01:56:37
| 276,290,778
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,518
|
cxx
|
Hatch_SequenceNodeOfSequenceOfLine_0.cxx
|
// This file is generated by WOK (CPPExt).
// Please do not edit this file; modify original file instead.
// The copyright and license terms as defined for the original file apply to
// this header file considered to be the "object code" form of the original source.
#include <Hatch_SequenceNodeOfSequenceOfLine.hxx>
#ifndef _Standard_Type_HeaderFile
#include <Standard_Type.hxx>
#endif
#ifndef _Hatch_Line_HeaderFile
#include <Hatch_Line.hxx>
#endif
#ifndef _Hatch_SequenceOfLine_HeaderFile
#include <Hatch_SequenceOfLine.hxx>
#endif
IMPLEMENT_STANDARD_TYPE(Hatch_SequenceNodeOfSequenceOfLine)
IMPLEMENT_STANDARD_SUPERTYPE_ARRAY()
STANDARD_TYPE(TCollection_SeqNode),
STANDARD_TYPE(MMgt_TShared),
STANDARD_TYPE(Standard_Transient),
IMPLEMENT_STANDARD_SUPERTYPE_ARRAY_END()
IMPLEMENT_STANDARD_TYPE_END(Hatch_SequenceNodeOfSequenceOfLine)
IMPLEMENT_DOWNCAST(Hatch_SequenceNodeOfSequenceOfLine,Standard_Transient)
IMPLEMENT_STANDARD_RTTI(Hatch_SequenceNodeOfSequenceOfLine)
#define SeqItem Hatch_Line
#define SeqItem_hxx <Hatch_Line.hxx>
#define TCollection_SequenceNode Hatch_SequenceNodeOfSequenceOfLine
#define TCollection_SequenceNode_hxx <Hatch_SequenceNodeOfSequenceOfLine.hxx>
#define Handle_TCollection_SequenceNode Handle_Hatch_SequenceNodeOfSequenceOfLine
#define TCollection_SequenceNode_Type_() Hatch_SequenceNodeOfSequenceOfLine_Type_()
#define TCollection_Sequence Hatch_SequenceOfLine
#define TCollection_Sequence_hxx <Hatch_SequenceOfLine.hxx>
#include <TCollection_SequenceNode.gxx>
|
9aad3f053942af9f3cd68c1c37b785d3dc2e23f4
|
32fcc41cc1b59a46932158e5062c8c37f88cd989
|
/third_party/rapidyaml/rapidyaml/examples/add_subdirectory/main.cpp
|
bcaf6cb688933d1439bf9c89fc1fafdf7aa6ee5b
|
[
"Apache-2.0",
"MIT"
] |
permissive
|
google/jsonnet
|
4cb224b7836e215df4bac809ad1ffed628a4d3d7
|
e605e4673294d2bf43eb8351fb8f5d9ba26d5e68
|
refs/heads/master
| 2023-08-28T16:27:58.576444
| 2023-08-14T12:02:45
| 2023-08-14T12:02:45
| 22,527,161
| 6,616
| 546
|
Apache-2.0
| 2023-08-14T12:02:46
| 2014-08-01T20:29:12
|
Jsonnet
|
UTF-8
|
C++
| false
| false
| 648
|
cpp
|
main.cpp
|
#include <ryml_std.hpp>
#include <ryml.hpp>
#include <c4/format.hpp>
#include <stdexcept>
#if C4_CPP < 17
#error "must be C++17"
#endif
template <class... Args>
void err(c4::csubstr fmt, Args const& ...args)
{
throw std::runtime_error(c4::formatrs<std::string>(fmt, args...));
}
void check(ryml::Tree const& t, c4::csubstr key, c4::csubstr expected)
{
c4::csubstr actual = t[key].val();
if(actual != expected)
{
err("expected t[{}]='{}', got '{}'", key, expected, actual);
}
}
int main()
{
auto tree = ryml::parse("{foo: 0, bar: 1}");
check(tree, "foo", "0");
check(tree, "bar", "1");
return 0;
}
|
95598b893e0c97708f82b09fe8bb1a97544020cc
|
fb135356aa27d9728ed5829860eecea4b5033910
|
/example/ugly/line_num.cc
|
64c0bc590df3fd6a04cb897a19d9482d8a2fc7a3
|
[
"BSL-1.0"
] |
permissive
|
sabel83/metatest
|
c0394ee40c5bb1330405ff70612da6b964d235d0
|
6bcb54ca77538b8b691fef9c67971609d01b70ee
|
refs/heads/master
| 2021-01-19T06:18:17.301607
| 2015-05-12T14:43:00
| 2015-05-12T14:43:00
| 8,935,277
| 13
| 1
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,269
|
cc
|
line_num.cc
|
// Copyright Endre Tamas SAJO (baja@inf.elte.hu) 2011.
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_2_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
#include <boost/mpl/vector.hpp>
#include <boost/mpl/size.hpp>
#include <boost/mpl/equal.hpp>
#include <boost/mpl/aux_/test.hpp>
// MPL_TEST_CASE and various asserts use preprocessor line number information
// to guarantee unique names
#line 1
MPL_TEST_CASE()
{
using namespace boost::mpl;
typedef vector2<char,short> v2;
#line 1
MPL_ASSERT(( equal<v2, v2::type > ));
#line 1
MPL_ASSERT(( equal<v2, v2::type > ));
}
#line 1
MPL_TEST_CASE()
{
using namespace boost::mpl;
typedef vector3<char,short,int> v3;
MPL_ASSERT(( equal<v3, v3::type > ));
}
// $ g++ -c line_num.cpp
// line_num.cpp: In function โvoid test1()โ:
// line_num.cpp:1: error: conflicting declaration โmpl_assertion_in_line_1โ
// line_num.cpp:1: error: โmpl_assertion_in_line_1โ has a previous declaration as
// โtest1()::<anonymous enum> mpl_assertion_in_line_1โ
// line_num.cpp: In function โvoid test1()โ:
// line_num.cpp:1: error: redefinition of โvoid test1()โ
// line_num.cpp:1: error: โvoid test1()โ previously defined here
|
84dae46f7cfe5e96db879103c319ab5b9513e470
|
679849fa6b4f7bbf657f9c6f7783c8fe78d359cd
|
/2010.7.15_poker/Poker.h
|
ece00deaa33af7216a9f12f91b872f44cd9d6a21
|
[] |
no_license
|
peter517/MFCGames
|
7132506de59129f1aa3516b9ac2976ad66fff901
|
e55f34fa95e6839446684d20e094aac6552e66d4
|
refs/heads/master
| 2016-09-10T19:04:05.852942
| 2013-05-18T02:33:12
| 2013-05-18T02:33:12
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 280
|
h
|
Poker.h
|
//Poker.h
#ifndef _POKER_H_
#define _POKER_H_
#include <iostream>
#include "time.h"
using namespace std;
struct Card{
int a[5];
int num;
};
class Poker
{
public:
Poker::Poker();
void Deal();
void Play();
private:
int m_oringal[10];
Card A;
Card B;
};
#endif
|
0ed624df13d98bfe2b430a0589d56572b363d38a
|
b1cac9f6480d99c01d2a6dfff482122f0569dff8
|
/src/rendering/shader/ShadowDepthShader.cpp
|
aa396a693bfb45321158b20a7c12ec459f4108a5
|
[] |
no_license
|
drumber-1/3DEngine
|
186cd90d6e6c0087f3aaf5dc0609fae5ac6076d1
|
b0f8e0ea42e8a4e3be0fa7965a4850c7a8284627
|
refs/heads/master
| 2020-05-20T05:55:27.840188
| 2016-07-18T18:23:16
| 2016-07-18T18:23:16
| 50,782,214
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 546
|
cpp
|
ShadowDepthShader.cpp
|
#include "ShadowDepthShader.hpp"
ShadowDepthShader::ShadowDepthShader() : Shader("shadow_depth_vert.glsl", "shadow_depth_frag.glsl") {
addUniform("worldToProjectionMatrix");
addUniform("modelToWorldMatrix");
}
void ShadowDepthShader::setCamera(const BaseCameraComponent& camera) {
setUniform("worldToProjectionMatrix", camera.getWorldToProjectionMatrix());
}
void ShadowDepthShader::draw(const RenderComponent& renderComponent) {
setUniform("modelToWorldMatrix", renderComponent.getTransformationMatrix());
renderComponent.mesh->draw();
}
|
f8c3bcb29130f382a5bc700164cedd60fbf3050a
|
5cd24f65c050a99a02e3ca4936236cfee6c310ca
|
/lib/periodic_time_tag_cc_impl.cc
|
3fa8671f88e7334065a532579517256395bef57f
|
[] |
no_license
|
ant-uni-bremen/gr-tacmac
|
509297f12833269513883b54ba5335eb3e4251b2
|
ff2a08e8184dfaf4893f3e485a26da97c27ba3be
|
refs/heads/main
| 2023-06-21T19:32:45.633012
| 2023-01-11T11:31:01
| 2023-01-11T11:31:01
| 250,314,414
| 0
| 0
| null | 2023-06-13T09:23:08
| 2020-03-26T16:38:43
|
C++
|
UTF-8
|
C++
| false
| false
| 4,432
|
cc
|
periodic_time_tag_cc_impl.cc
|
/* -*- c++ -*- */
/*
* Copyright 2020 Johannes Demel.
*
* SPDX-License-Identifier: GPL-3.0-or-later
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "periodic_time_tag_cc_impl.h"
#include <gnuradio/io_signature.h>
#include <fmt/core.h>
namespace gr {
namespace tacmac {
periodic_time_tag_cc::sptr periodic_time_tag_cc::make(double samp_rate,
uint32_t tag_interval)
{
return gnuradio::get_initial_sptr(
new periodic_time_tag_cc_impl(samp_rate, tag_interval));
}
/*
* The private constructor
*/
periodic_time_tag_cc_impl::periodic_time_tag_cc_impl(double samp_rate,
uint32_t tag_interval)
: gr::sync_block("periodic_time_tag_cc",
gr::io_signature::make(1, 1, sizeof(gr_complex)),
gr::io_signature::make(0, 1, sizeof(gr_complex))),
d_samp_rate(samp_rate),
d_tag_interval(tag_interval),
d_full_secs(0),
d_frac_secs(0.0),
d_tag_offset(0),
d_next_tag_offset(tag_interval),
d_slot_counter(0)
{
message_port_register_out(MSG_OUT_PORT);
}
/*
* Our virtual destructor.
*/
periodic_time_tag_cc_impl::~periodic_time_tag_cc_impl() {}
void periodic_time_tag_cc_impl::log_status_summary()
{
if (d_next_status_summary > d_tag_offset) {
return;
}
GR_LOG_DEBUG(
d_logger,
fmt::format("STATUS: {}, counter={}",
get_formatted_tag_string(d_tag_offset, d_full_secs, d_frac_secs),
d_slot_counter));
d_next_status_summary += uint64_t(2 * d_samp_rate);
}
int periodic_time_tag_cc_impl::work(int noutput_items,
gr_vector_const_void_star& input_items,
gr_vector_void_star& output_items)
{
const gr_complex* in = (const gr_complex*)input_items[0];
if (output_items.size() > 0) {
gr_complex* out = (gr_complex*)output_items[0];
memcpy(out, in, sizeof(gr_complex) * noutput_items);
}
std::vector<tag_t> tags;
get_tags_in_range(
tags, 0, nitems_read(0), (nitems_read(0) + noutput_items), RATE_KEY);
for (auto t : tags) {
double tag_rate = pmt::to_double(t.value);
if (std::fabs(tag_rate - d_samp_rate) > 1.0e-1) {
std::string err_msg = fmt::format(
"Runtime rate change not supported! configured={}MSps, received={}MSps",
d_samp_rate / 1.0e6,
tag_rate / 1.0e6);
GR_LOG_ERROR(this->d_logger, err_msg);
throw std::runtime_error(err_msg);
}
}
get_tags_in_range(
tags, 0, nitems_read(0), (nitems_read(0) + noutput_items), TIME_KEY);
for (auto t : tags) {
d_tag_offset = t.offset;
d_full_secs = pmt::to_uint64(pmt::tuple_ref(t.value, 0));
d_frac_secs = pmt::to_double(pmt::tuple_ref(t.value, 1));
d_next_tag_offset = t.offset; // + d_tag_interval;
GR_LOG_DEBUG(this->d_logger,
"Received new tag @offset=" + get_formatted_tag_string(d_tag_offset,
d_full_secs,
d_frac_secs));
}
uint64_t total_items = nitems_read(0) + noutput_items;
while (total_items > d_next_tag_offset) {
d_frac_secs += (d_next_tag_offset - d_tag_offset) / d_samp_rate;
if (d_frac_secs >= 1.0) {
d_full_secs += 1;
d_frac_secs -= 1.0;
}
pmt::pmt_t info = pmt::make_tuple(pmt::from_uint64(d_full_secs),
pmt::from_double(d_frac_secs),
pmt::from_uint64(d_next_tag_offset),
pmt::from_double(d_samp_rate),
pmt::from_uint64(d_slot_counter));
d_slot_counter++;
if (output_items.size() > 0) {
add_item_tag(0, d_next_tag_offset, TIME_KEY, info);
}
message_port_pub(MSG_OUT_PORT, info);
d_tag_offset = d_next_tag_offset;
d_next_tag_offset += d_tag_interval;
}
log_status_summary();
// Tell runtime system how many output items we produced.
return noutput_items;
}
} /* namespace tacmac */
} /* namespace gr */
|
6bdfcd3aec47921571fabb1e2c1b80dd3817341a
|
39099d7ae2047ad2b8ea5b038b8f812fca7b29d9
|
/144/HW14_6/UniqueList/myoutofrangeexception.cpp
|
70c81314ef6f12127008173efd78c18cc10f8666
|
[] |
no_license
|
danilaml/DZ
|
58c8b6392895ff09fa3bf43324974d86f313a745
|
961a4273ef80565d96ccf846f9c8c975157f0fd7
|
refs/heads/master
| 2021-01-01T17:21:04.748663
| 2015-05-07T19:02:03
| 2015-05-07T19:02:03
| 17,184,352
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 121
|
cpp
|
myoutofrangeexception.cpp
|
#include "myoutofrangeexception.h"
MyOutOfRangeException::MyOutOfRangeException(const char *msg) : MyException(msg)
{
}
|
919d7abf54f3263e25b37421062faba4040b242b
|
71baf84f88c01fae99df3f0b2b8022ea49034cf5
|
/socket_pcap.cpp
|
609d313cba376a5e54841f967905850052711af4
|
[] |
no_license
|
qq431169079/utrack
|
7526ec9822b3f0744969f371adf59455bbf4275b
|
2ba95d9ab1b153454edce726f804c00e196e658d
|
refs/heads/master
| 2020-04-01T17:28:04.886991
| 2014-08-18T16:32:07
| 2014-08-18T16:32:07
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 15,537
|
cpp
|
socket_pcap.cpp
|
/*
utrack is a very small an efficient BitTorrent tracker
Copyright (C) 2013-2014 Arvid Norberg
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "socket.hpp"
#include "config.hpp"
#include "utils.hpp"
#include "stack.hpp"
#include <stdio.h> // for stderr
#include <errno.h> // for errno
#include <string.h> // for strerror
#include <stdlib.h> // for exit
#include <assert.h>
#ifdef _WIN32
#include <winsock2.h>
#include <iphlpapi.h>
#define snprintf _snprintf
#else
#include <unistd.h> // for close
#include <poll.h> // for poll
#include <fcntl.h> // for F_GETFL and F_SETFL
#include <sys/socket.h> // for iovec
#include <netinet/in.h> // for sockaddr
#include <net/if.h> // for ifreq
#include <sys/ioctl.h>
#include <arpa/inet.h> // for inet_ntop
#endif
#include <atomic>
#include <mutex>
#include <chrono>
#include <thread>
#include <string>
#ifndef MSG_NOSIGNAL
#define MSG_NOSIGNAL 0
#endif
extern std::atomic<uint32_t> bytes_out;
extern std::atomic<uint32_t> dropped_bytes_out;
packet_socket::packet_socket(char const* device)
: m_pcap(nullptr)
, m_closed(ATOMIC_VAR_INIT(0))
#ifndef USE_WINPCAP
, m_send_cursor(0)
#endif
{
#ifdef USE_WINPCAP
m_send_buffer.reserve(21);
#else
m_send_buffer.resize(send_buffer_size);
#endif
std::error_code ec;
std::vector<device_info> devices = interfaces(ec);
if (ec)
{
fprintf(stderr, "failed to list network interfaces: \"%s\"\n"
, ec.message().c_str());
exit(2);
}
// resolve source IP and network mask from device
bool found = false;
for (auto const& dev : devices)
{
printf("device: %s\n", dev.name);
printf(" hw: %s\n", to_string(dev.hardware_addr).c_str());
if (strcmp(dev.name, device) != 0) continue;
// just pick the first IPv4 address
auto i = std::find_if(dev.addresses.begin(), dev.addresses.end()
, [=](network const& a) { return a.ip.sa_family == AF_INET; });
if (i == dev.addresses.end())
{
fprintf(stderr, "could not find an IPv4 address on device: \"%s\"\n"
, device);
exit(2);
}
found = true;
m_eth_addr = dev.hardware_addr;
m_mask = (sockaddr_in&)i->mask;
m_our_addr = (sockaddr_in&)i->ip;
}
if (!found)
{
fprintf(stderr, "could not find device: \"%s\"\n", device);
exit(2);
}
init(device);
}
packet_socket::packet_socket(sockaddr const* bind_addr)
: m_pcap(nullptr)
, m_closed(ATOMIC_VAR_INIT(0))
#ifndef USE_WINPCAP
, m_send_cursor(0)
#endif
{
#ifdef USE_WINPCAP
m_send_buffer.reserve(21);
#else
m_send_buffer.resize(send_buffer_size);
#endif
if (bind_addr->sa_family != AF_INET)
{
fprintf(stderr, "only IPv4 supported\n");
exit(2);
return;
}
m_our_addr = *(sockaddr_in*)bind_addr;
std::error_code ec;
std::vector<device_info> devices = interfaces(ec);
if (ec)
{
fprintf(stderr, "failed to list network interfaces: \"%s\"\n"
, ec.message().c_str());
exit(2);
}
// resolve device and network mask from bind_addr
char device[IFNAMSIZ];
bool found = false;
for (auto const& dev : devices)
{
printf("device: %s\n", dev.name);
printf(" hw: %s\n", to_string(dev.hardware_addr).c_str());
auto i = std::find_if(dev.addresses.begin(), dev.addresses.end()
, [=](network const& a) { return sockaddr_eq(&a.ip, (sockaddr const*)&m_our_addr); });
if (i == dev.addresses.end()) continue;
found = true;
m_eth_addr = dev.hardware_addr;
m_mask = (sockaddr_in&)i->mask;
strncpy(device, dev.name, IFNAMSIZ);
}
if (!found)
{
fprintf(stderr, "failed to bind: no device found with that address\n");
exit(2);
}
init(device);
}
void packet_socket::init(char const* device)
{
char error_msg[PCAP_ERRBUF_SIZE];
m_pcap = pcap_create(device, error_msg);
if (m_pcap == nullptr)
{
fprintf(stderr, "failed to create packet capture handle: %s"
, error_msg);
exit(2);
return;
}
// capture whole packets
pcap_set_snaplen(m_pcap, 1500);
int r = pcap_setnonblock(m_pcap, 0, error_msg);
if (r == -1)
{
fprintf(stderr, "failed to set blocking mode: %s\n", error_msg);
return;
}
r = pcap_setdirection(m_pcap, PCAP_D_IN);
if (r == -1)
fprintf(stderr, "pcap_setdirection() = %d \"%s\"\n", r, pcap_geterr(m_pcap));
r = pcap_set_buffer_size(m_pcap, socket_buffer_size);
if (r == -1)
fprintf(stderr, "pcap_set_buffer_size() = %d \"%s\"\n", r, pcap_geterr(m_pcap));
r = pcap_set_timeout(m_pcap, 1);
if (r == -1)
fprintf(stderr, "pcap_set_timeout() = %d \"%s\"\n", r, pcap_geterr(m_pcap));
r = pcap_setdirection(m_pcap, PCAP_D_IN);
if (r == -1)
fprintf(stderr, "pcap_setdirection() = %d \"%s\"\n", r, pcap_geterr(m_pcap));
uint32_t ip = ntohl(m_our_addr.sin_addr.s_addr);
uint32_t mask = ntohl(m_mask.sin_addr.s_addr);
printf("bound to %d.%d.%d.%d\n"
, (ip >> 24) & 0xff
, (ip >> 16) & 0xff
, (ip >> 8) & 0xff
, ip & 0xff);
printf("mask %d.%d.%d.%d\n"
, (mask >> 24) & 0xff
, (mask >> 16) & 0xff
, (mask >> 8) & 0xff
, mask & 0xff);
printf("hw: %s\n", to_string(m_eth_addr).c_str());
r = pcap_activate(m_pcap);
if (r != 0)
{
fprintf(stderr, "pcap_activate() = %d \"%s\"\n", r, pcap_geterr(m_pcap));
exit(-1);
}
m_link_layer = pcap_datalink(m_pcap);
if (m_link_layer < 0)
{
fprintf(stderr, "pcap_datalink() = %d \"%s\"\n", r, pcap_geterr(m_pcap));
exit(-1);
}
printf("link layer: ");
switch (m_link_layer)
{
case DLT_NULL: printf("loopback\n"); break;
case DLT_EN10MB: printf("ethernet\n"); break;
default: printf("unknown\n"); break;
}
std::string program_text = "udp";
if (m_our_addr.sin_port != 0)
{
program_text += " dst port ";
program_text += std::to_string(ntohs(m_our_addr.sin_port));
char buf[100];
program_text += " and dst host ";
program_text += inet_ntop(AF_INET, &m_our_addr.sin_addr.s_addr
, buf, sizeof(buf));
}
fprintf(stderr, "capture filter: \"%s\"\n", program_text.c_str());
bpf_program p;
r = pcap_compile(m_pcap, &p, program_text.c_str(), 1, 0xffffffff);
if (r == -1)
fprintf(stderr, "pcap_compile() = %d \"%s\"\n", r, pcap_geterr(m_pcap));
r = pcap_setfilter(m_pcap, &p);
if (r == -1)
fprintf(stderr, "pcap_setfilter() = %d \"%s\"\n", r, pcap_geterr(m_pcap));
for (int i = 0; i < 3; ++i)
m_send_threads.emplace_back(&packet_socket::send_thread, this);
}
packet_socket::~packet_socket()
{
close();
for (auto& t : m_send_threads) t.join();
#ifdef USE_WINPCAP
for (auto i : m_free_list)
pcap_sendqueue_destroy(i);
for (auto i : m_send_buffer)
pcap_sendqueue_destroy(i);
#endif
if (m_pcap) pcap_close(m_pcap);
}
void packet_socket::close()
{
m_closed = 1;
if (m_pcap)
pcap_breakloop(m_pcap);
}
bool packet_socket::send(packet_buffer& packets)
{
#ifdef USE_WINPCAP
assert(packets.m_queue != 0);
std::unique_lock<std::mutex> l(m_mutex);
if (m_send_buffer.size() > 20)
{
l.unlock();
// if the send queue is too large, just send
// it synchronously
int r = pcap_sendqueue_transmit(m_pcap, packets.m_queue, 0);
if (r < 0)
fprintf(stderr, "pcap_setfilter() = %d \"%s\"\n", r, pcap_geterr(m_pcap));
return true;
}
assert(packets.m_queue != NULL);
m_send_buffer.push_back(packets.m_queue);
if (!m_free_list.empty())
{
packets.m_queue = m_free_list.back();
m_free_list.erase(m_free_list.end()-1);
}
else
{
l.unlock();
packets.m_queue = pcap_sendqueue_alloc(0x100000);
if (packets.m_queue == NULL)
{
fprintf(stderr, "failed to allocate send queue\n");
exit(1);
}
}
return true;
#else
std::lock_guard<std::mutex> l(m_mutex);
if (packets.m_send_cursor == 0) return true;
if (m_send_cursor + packets.m_send_cursor > m_send_buffer.size())
{
dropped_bytes_out.fetch_add(packets.m_send_cursor, std::memory_order_relaxed);
packets.m_send_cursor = 0;
return false;
}
bytes_out.fetch_add(packets.m_send_cursor, std::memory_order_relaxed);
memcpy(&m_send_buffer[m_send_cursor]
, packets.m_buf.data(), packets.m_send_cursor);
m_send_cursor += packets.m_send_cursor;
packets.m_send_cursor = 0;
#endif
return true;
}
packet_buffer::packet_buffer(packet_socket& s)
: m_link_layer(s.m_link_layer)
#ifndef USE_WINPCAP
, m_send_cursor(0)
#endif
, m_from(s.m_our_addr)
, m_mask(s.m_mask)
, m_eth_from(s.m_eth_addr)
, m_arp(s)
#ifdef USE_WINPCAP
, m_queue(pcap_sendqueue_alloc(0x100000))
, m_pcap(s.m_pcap)
#else
, m_buf(0x100000)
#endif
{
#ifdef USE_WINPCAP
if (m_queue == NULL)
{
fprintf(stderr, "failed to allocate send queue\n");
exit(1);
}
#endif
}
packet_buffer::~packet_buffer()
{
#ifdef USE_WINPCAP
pcap_sendqueue_destroy(m_queue);
#endif
}
bool packet_buffer::append(iovec const* v, int num
, sockaddr_in const* to)
{
return append_impl(v, num, to, &m_from);
}
bool packet_buffer::append_impl(iovec const* v, int num
, sockaddr_in const* to, sockaddr_in const* from)
{
int buf_size = 0;
for (int i = 0; i < num; ++i) buf_size += v[i].iov_len;
if (buf_size > 1500 - 28 - 30)
{
fprintf(stderr, "append: packet too large\n");
return false;
}
#ifdef USE_WINPCAP
std::uint8_t buffer[1500];
std::uint8_t* ptr = buffer;
int len = 0;
#else
if (m_send_cursor + buf_size + 28 + 30 > m_buf.size())
{
dropped_bytes_out.fetch_add(buf_size, std::memory_order_relaxed);
return false;
}
std::uint8_t* ptr = &m_buf[m_send_cursor];
std::uint8_t* prefix = ptr;
ptr += 2;
#endif
#ifdef USE_SYSTEM_SEND_SOCKET
int len = 0;
memcpy(ptr, to, sizeof(sockaddr_in));
ptr += sizeof(sockaddr_in);
len += sizeof(sockaddr_in);
for (int i = 0; i < num; ++i)
{
memcpy(ptr, v[i].iov_base, v[i].iov_len);
ptr += v[i].iov_len;
len += v[i].iov_len;
}
m_send_cursor += len + 2;
#else
if (to->sin_family != AF_INET)
{
fprintf(stderr, "unsupported network protocol (only IPv4 is supported)\n");
return false;
}
int len = 0;
int r;
switch (m_link_layer)
{
case DLT_NULL:
{
std::uint32_t proto = 2;
memcpy(ptr, &proto, 4);
ptr += 4;
len += 4;
break;
}
case DLT_EN10MB:
{
r = render_eth_frame(ptr, 1500 - len, to, from, &m_mask
, m_eth_from, m_arp);
if (r < 0) return false;
ptr += len;
len += r;
break;
}
default:
// unsupported link layer
fprintf(stderr, "unsupported data link layer (%d)\n", m_link_layer);
return false;
}
r = render_ip_frame(ptr, 1500 - len, v, num, to, from);
if (r < 0) return false;
len += r;
#ifdef USE_WINPCAP
pcap_pkthdr hdr;
hdr.caplen = len;
hdr.len = len;
memset(&hdr.ts, 0, sizeof(hdr.ts));
int r = pcap_sendqueue_queue(m_queue, &hdr, buffer);
#else
prefix[0] = (len >> 8) & 0xff;
prefix[1] = len & 0xff;
m_send_cursor += len + 2;
#endif
#endif // USE_SYSTEM_SEND_SOCKET
return true;
}
#ifdef USE_WINPCAP
void packet_socket::send_thread()
{
std::vector<pcap_send_queue*> local_buffer;
// exponential back-off. The more read operations that return
// no packets, the longer we wait until we read again. This
// balances CPU usage when idle with wasting less time when busy
const static int sleep_timers[] = {0, 1, 5, 10, 50, 100, 500};
int sleep = 0;
while (!m_closed)
{
if (sleep > 0)
{
// we did not see any packets in the buffer last cycle
// through. sleep for a while to see if there are any in
// a little bit
// printf("sleep %d ms\n", sleep_timers[sleep-1]);
std::this_thread::sleep_for(
std::chrono::milliseconds(sleep_timers[sleep-1]));
}
{
std::lock_guard<std::mutex> l(m_mutex);
if (m_send_buffer.empty())
{
if (sleep < sizeof(sleep_timers)/sizeof(sleep_timers[0]))
++sleep;
continue;
}
local_buffer.swap(m_send_buffer);
}
sleep = 0;
for (auto i : local_buffer)
{
int r = pcap_sendqueue_transmit(m_pcap, i, 0);
if (r < 0)
fprintf(stderr, "pcap_setfilter() = %d \"%s\"\n", r, pcap_geterr(m_pcap));
std::lock_guard<std::mutex> l(m_mutex);
m_free_list.push_back(i);
}
local_buffer.clear();
}
}
#else
void packet_socket::send_thread()
{
std::vector<uint8_t> local_buffer;
local_buffer.resize(send_buffer_size);
int end;
#ifdef USE_SYSTEM_SEND_SOCKET
// socket used for sending
int sock = socket(PF_INET, SOCK_DGRAM, 0);
if (sock < 0)
{
fprintf(stderr, "failed to open send socket (%d): %s\n"
, errno, strerror(errno));
exit(1);
}
int one = 1;
if (setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, &one, sizeof(one)) < 0)
{
fprintf(stderr, "failed to set SO_REUSEADDR on send socket (%d): %s\n"
, errno, strerror(errno));
}
#ifdef SO_REUSEPORT
if (setsockopt(sock, SOL_SOCKET, SO_REUSEPORT, &one, sizeof(one)) < 0)
{
fprintf(stderr, "failed to set SO_REUSEPORT on send socket (%d): %s\n"
, errno, strerror(errno));
}
#endif
sockaddr_in bind_addr;
memset(&bind_addr, 0, sizeof(bind_addr));
bind_addr.sin_family = AF_INET;
bind_addr.sin_addr.s_addr = INADDR_ANY;
bind_addr.sin_port = m_our_addr.sin_port;
int r = bind(sock, (sockaddr*)&bind_addr, sizeof(bind_addr));
if (r < 0)
{
fprintf(stderr, "failed to bind send socket to port %d (%d): %s\n"
, ntohs(m_our_addr.sin_port), errno, strerror(errno));
exit(1);
}
int opt = socket_buffer_size;
r = setsockopt(sock, SOL_SOCKET, SO_SNDBUF, &opt, sizeof(opt));
if (r == -1)
{
fprintf(stderr, "failed to set send socket buffer size (%d): %s\n"
, errno, strerror(errno));
}
#endif
// exponential back-off. The more read operations that return
// no packets, the longer we wait until we read again. This
// balances CPU usage when idle with wasting less time when busy
const static int sleep_timers[] = {0, 1, 5, 10, 50, 100, 500};
int sleep = 0;
while (!m_closed)
{
if (sleep > 0)
{
// we did not see any packets in the buffer last cycle
// through. sleep for a while to see if there are any in
// a little bit
// printf("sleep %d ms\n", sleep_timers[sleep-1]);
std::this_thread::sleep_for(
std::chrono::milliseconds(sleep_timers[sleep-1]));
}
{
std::lock_guard<std::mutex> l(m_mutex);
if (m_send_cursor == 0)
{
if (sleep < sizeof(sleep_timers)/sizeof(sleep_timers[0]))
++sleep;
continue;
}
local_buffer.swap(m_send_buffer);
end = m_send_cursor;
m_send_cursor = 0;
}
sleep = 0;
for (int i = 0; i < end;)
{
int len = (local_buffer[i] << 8) | local_buffer[i+1];
assert(len <= 1500);
assert(len > 0);
i += 2;
assert(local_buffer.size() - i >= len);
#ifdef USE_SYSTEM_SEND_SOCKET
assert(len >= sizeof(sockaddr_in));
sockaddr_in* to = (sockaddr_in*)(local_buffer.data() + i);
int r = sendto(sock
, local_buffer.data() + i + sizeof(sockaddr_in)
, len - sizeof(sockaddr_in), 0, (sockaddr*)to, sizeof(sockaddr_in));
if (r == -1)
fprintf(stderr, "sendto() = %d \"%s\"\n", r
, strerror(errno));
#else
int r = pcap_sendpacket(m_pcap, local_buffer.data() + i
, len);
if (r == -1)
fprintf(stderr, "pcap_sendpacket() = %d \"%s\"\n", r
, pcap_geterr(m_pcap));
#endif
i += len;
}
}
#ifdef USE_SYSTEM_SEND_SOCKET
::close(sock);
#endif
}
#endif // !USE_WINPCAP
void packet_socket::local_endpoint(sockaddr_in* addr)
{
*addr = m_our_addr;
}
|
6968274b7e4a97eff927cdb94212fc3a3c6077a1
|
38f12635aea1716c7bc8fc32b412011762447254
|
/lib_cpp/TestClass.h
|
898933e9e5093bc1ebc971635cc919590f8ab93a
|
[] |
no_license
|
9cvele3/Interoperability
|
290c6fac24950a0d33833b2faceb3234f911e9fb
|
95b359cedfd164f7e4289babeefafb3dd9bfa7d6
|
refs/heads/master
| 2020-03-07T07:09:24.491656
| 2018-04-12T20:12:47
| 2018-04-12T20:12:47
| 127,341,316
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 276
|
h
|
TestClass.h
|
#pragma once
#ifdef LIB_CPP_EXPORTS
#define LIB_CPP_API __declspec(dllexport)
#else
#define LIB_CPP_API __declspec(dllimport)
#endif
class TestClass
{
public:
LIB_CPP_API TestClass();
LIB_CPP_API ~TestClass();
LIB_CPP_API int getNumPublic();
private:
int getNum();
};
|
6d4056566dc5b51466af7503d4a1894ad70edf2f
|
1d6237b288645be23bc1c6eafe8a99e0b128953e
|
/src/GManager.cpp
|
490ef9551b2a41ae8e02c73c5e3ea65f14bca210
|
[] |
no_license
|
CaterTsai/C_12Giraffe
|
1c64114e819f043342bc41e1245a8468c368fd3c
|
87592f855f8c8c50d215b44da1b878f9f5aaf8b8
|
refs/heads/master
| 2021-01-10T18:14:19.608560
| 2016-01-30T06:55:29
| 2016-01-30T06:55:29
| 49,572,286
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 312
|
cpp
|
GManager.cpp
|
#include "GManager.h"
//--------------------------------------------------------------
void GManager::setup()
{
}
//--------------------------------------------------------------
void GManager::update(float fDelta)
{
}
//--------------------------------------------------------------
void GManager::draw()
{
}
|
89b0ca3f7cb103fcf9b336ecaa92492219e659f4
|
7ddcc11b7d1ae4ee2d91c4498b3da51627a71151
|
/c++/05_containers_and_strings/iterators.cpp
|
154f705570ee1c0bd2b0b202cd06c7cf784fe9bd
|
[] |
no_license
|
MarkMckessock/ICS4U-Misc
|
edcf7b41eb018062234de20ce8cce4afbada4054
|
f5189942abc3e2a4db106a94e959d3b244639efb
|
refs/heads/master
| 2021-09-07T20:53:35.833343
| 2018-03-01T00:21:48
| 2018-03-01T00:21:48
| 119,929,091
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,022
|
cpp
|
iterators.cpp
|
#include <vector>
#include <iostream>
#include <string>
int main(){
struct test {
std::string name;
};
std::vector<int> list;
std::vector<test> list_2;
list.push_back(4);
list.push_back(5);
list.push_back(6);
test mark = {"Tom"};
test jack = {"Randy"};
test greg = {"paul"};
list_2.push_back(mark);
list_2.push_back(jack);
list_2.push_back(greg);
for(int i=0; i<list.size();i++){
std::cout << list[i] << std::endl;
}
for(int i=0; i<list_2.size();i++){
std::cout << list_2[i].name << std::endl;
}
//The same effect can be acheived more efficiently using an iterator.
//The const_iterator type is used because its value will not be modified.
for(std::vector<int>::const_iterator iter = list.begin(); iter < list.end(); iter++){
std::cout << (*iter) << std::endl;
}
for(std::vector<test>::const_iterator iter = list_2.begin(); iter < list_2.end(); iter++){
std::cout << iter->name << std::endl;
//The '->' operator is a shortcut for (*iter).name
}
}
|
a79bb862ddf78f22c296d70a30044745cb837bf2
|
9f03dc94e947cbc05f4468b6a4aa1d7150962542
|
/player.h
|
02f88882ec919f7491c52ee415b3b629e5b9a9c9
|
[] |
no_license
|
JuliaNortman/Project
|
0f1196b4214b5af2d3e51cbeb74a55e9e768ca08
|
3908344045fd6b3214096d4f4079ae9b2f08c0f8
|
refs/heads/master
| 2020-04-05T16:16:33.325960
| 2019-05-27T06:37:08
| 2019-05-27T06:37:08
| 157,004,972
| 1
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,091
|
h
|
player.h
|
#pragma once
#include "board.h"
#include <QWidget>
#include <QApplication>
#include <QTime>
class Board;
struct Move
{
int from;
int to;
};
class Player :public QObject
{
Q_OBJECT
protected:
Board *board;
Color color;
bool canMove = true;/*information about whether it is Player`s turn to move or not*/
public:
Player(Color c);
virtual ~Player() = default;
virtual void move() = 0;
bool getCanMove(){return canMove;}
void setCanMove(bool canMove){this->canMove = canMove;}
Color getColor(){return color;}
void setBoard(Board* pBoard){board = pBoard;}
virtual bool isBot() = 0;
};
class Person : public Player
{
public:
Person(Color c);
void move() override;
void setBoardActive();
bool isBot()override {return false;}
};
class Bot : public Player
{
public:
Bot( Color c);
void move() override;
void setBoardActive();
void setBoardUnactive();
Move easythink();/*AI*/
Move hardThink();
int minimax(Board* board, int depth, bool maximizer);
bool isBot()override {return true;}
};
|
03b3224431d51533cc8b2a7030cdceded8b57108
|
cfe409a4843c1a1acc0a78fac69e5b3d5901c46c
|
/lib/test_so.cpp
|
efa7f2e18a03a00d7d4e5540b2bf7b5d282b7d20
|
[] |
no_license
|
yanggh/Radar
|
fc7b8c6a32d59cd83e357e408ed7ce5138b10258
|
b5afe7c1da0191445dbb1fff3deecb7b7a21d5d1
|
refs/heads/master
| 2020-03-29T08:20:55.053292
| 2018-10-17T08:20:22
| 2018-10-17T08:20:22
| 149,705,795
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 539
|
cpp
|
test_so.cpp
|
#include <stdio.h>
#include "test_so.h"
using namespace std;
int add(int* out1_len, void* out1, int in1_len, void* in1, int in2_len, void* in2, int in3_len, void* in3, int in4_len, void* in4, int in5_len, void* in5)
{
printf("asdfasdfasdfasdfasdfsadadd add\n");
return in1_len +in2_len;
}
int sub(int* out1_len, void* out1, int in1_len, void* in1, int in2_len, void* in2, int in3_len, void* in3, int in4_len, void* in4, int in5_len, void* in5)
{
printf("asdfasdfasdfasdfasdfsadadd sub\n");
return in1_len - in2_len;
}
|
4ef458b5ab7ffa16f16bb706fa56247bde3fc784
|
91d4a4a04e504277f1951b9d698a870419075ee5
|
/src/clientSM.h
|
7f4d301d0dc2c709f725f98a6939f6ddca2496f7
|
[
"Apache-2.0"
] |
permissive
|
WinterChen/MyFramework
|
f7df280ef14f2759fdb04d98675cb25706150fad
|
de2e9c5892fd824901261c5adc084a2e3a0cf880
|
refs/heads/master
| 2021-01-11T16:05:05.007538
| 2019-01-23T10:01:22
| 2019-01-23T10:01:22
| 80,001,150
| 1
| 3
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 721
|
h
|
clientSM.h
|
#ifndef CLIENTSM_H
#define CLIENTSM_H
//#include "request.h"
#include "callbackObj.h"
#include "netConnection.h"
//#include "myframework.pb.h"
//#include "myframework.pb.helper.h"
//using namespace google::protobuf;//::Message
class ClientSM : public CallbackObj {
public:
ClientSM(NetConnection *conn);
~ClientSM();
int HandleEvent(int code, void *data){return HandleRequest(code, data);}
int HandleRequest(int code,void * data);
//int HandleTerminate(int code, void *data);
private:
/// A handle to a network connection
NetConnection *mNetConnection;
/// log out client ip addr. for debugging purposes
std::string mClientIP;
//google::protobuf::Message *mRequest;
};
#endif
|
1429f5474afc576e62e1e8295d4c70a148a1382e
|
07306d96ba61d744cb54293d75ed2e9a09228916
|
/External/NaturalMotion/common/XMD/src/XMD/IkChain.cpp
|
d80b1e3b91efe67bde47d1a1c388f7109e4c02c8
|
[] |
no_license
|
D34Dspy/warz-client
|
e57783a7c8adab1654f347f389c1dace35b81158
|
5262ea65e0baaf3f37ffaede5f41c9b7eafee7c1
|
refs/heads/master
| 2023-03-17T00:56:46.602407
| 2015-12-20T16:43:00
| 2015-12-20T16:43:00
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 14,681
|
cpp
|
IkChain.cpp
|
//----------------------------------------------------------------------------------------------------------------------
/// \file RenderLayer.cpp
/// \note (C) Copyright 2003-2005 Robert Bateman. All rights reserved.
//----------------------------------------------------------------------------------------------------------------------
#include "XMD/Model.h"
#include "XMD/IkChain.h"
#include "XMD/FileIO.h"
#include "nmtl/algorithm.h"
namespace XMD
{
//----------------------------------------------------------------------------------------------------------------------
XIkChain::XIkChain(XModel* pModel)
: XBase(pModel),m_Handle(0),m_Priority(1),m_MaxIterations(2147483647),
m_Weight(1.0f),m_PoWeight(1.0f),m_Tolerance(static_cast<XReal>(1e-05)),m_Stickiness(0),m_PoleVector(),
m_PoleConstraint(0),m_IkChain()
{
}
//----------------------------------------------------------------------------------------------------------------------
XIkChain::~XIkChain()
{
}
//----------------------------------------------------------------------------------------------------------------------
XFn::Type XIkChain::GetApiType() const
{
return XFn::IkChain;
}
//----------------------------------------------------------------------------------------------------------------------
XU32 XIkChain::GetDataSize() const
{
XU32 sz = XBase::GetDataSize();
sz += sizeof(XId)*2;
sz += sizeof(XS32);
sz += sizeof(XU32)*2;
sz += sizeof(XReal)*4;
sz += 3*sizeof(XReal);
sz += sizeof(XId)*static_cast<XU32>(m_IkChain.size());
return sz;
}
//----------------------------------------------------------------------------------------------------------------------
XU32 XIkChain::GetNumBonesInChain() const
{
return static_cast<XU32>(m_IkChain.size());
}
//----------------------------------------------------------------------------------------------------------------------
XBone* XIkChain::GetBoneInChain(const XU32 idx) const
{
if(idx< GetNumBonesInChain() )
{
XBase* ptr = m_pModel->FindNode(m_IkChain[idx]);
if(ptr)
{
XBone* pBone = ptr->HasFn<XBone>();
return pBone;
}
}
return 0;
}
//----------------------------------------------------------------------------------------------------------------------
bool XIkChain::AddBoneToChain(const XBone* bone)
{
// asserted because ptr is null or not from this XModel
XMD_ASSERT( (bone) && IsValidObj(bone) );
if(!bone)
return false;
// make sure not already part of the IK chain.
if (m_IkChain.end() != nmtl::find(m_IkChain.begin(),m_IkChain.end(),bone->GetID()))
{
return false;
}
m_IkChain.push_back(bone->GetID());
return true;
}
//----------------------------------------------------------------------------------------------------------------------
bool XIkChain::RemoveBone(const XBone* bone)
{
if (bone && IsValidObj(bone))
{
XIndexList::iterator it = nmtl::find(m_IkChain.begin(),m_IkChain.end(),bone->GetID());
if(it!=m_IkChain.end())
{
m_IkChain.erase(it);
return true;
}
}
return false;
}
//----------------------------------------------------------------------------------------------------------------------
XBone* XIkChain::GetHandle() const
{
XBase* ptr = m_pModel->FindNode(m_Handle);
if(ptr)
{
XBone* pBone = ptr->HasFn<XBone>();
return pBone;
}
return 0;
}
//----------------------------------------------------------------------------------------------------------------------
const XVector3& XIkChain::GetPoleVector() const
{
return m_PoleVector;
}
//----------------------------------------------------------------------------------------------------------------------
XBone* XIkChain::GetPoleConstraint() const
{
XBase* base = m_pModel->FindNode(m_PoleConstraint);
if (base)
{
return base->HasFn<XBone>();
}
return 0;
}
//----------------------------------------------------------------------------------------------------------------------
XS32 XIkChain::GetPriority() const
{
return m_Priority;
}
//----------------------------------------------------------------------------------------------------------------------
XU32 XIkChain::GetMaxIterations() const
{
return m_MaxIterations;
}
//----------------------------------------------------------------------------------------------------------------------
XReal XIkChain::GetWeight() const
{
return m_Weight;
}
//----------------------------------------------------------------------------------------------------------------------
XReal XIkChain::GetPoWeight() const
{
return m_PoWeight;
}
//----------------------------------------------------------------------------------------------------------------------
XReal XIkChain::GetTolerance() const
{
return m_Tolerance;
}
//----------------------------------------------------------------------------------------------------------------------
XReal XIkChain::GetStickiness() const
{
return m_Stickiness;
}
//----------------------------------------------------------------------------------------------------------------------
XBase* XIkChain::GetFn(XFn::Type type)
{
if (XFn::IkChain == type)
{
return (XIkChain*)this;
}
return XBase::GetFn(type);
}
//----------------------------------------------------------------------------------------------------------------------
const XBase* XIkChain::GetFn(XFn::Type type) const
{
if(XFn::IkChain==type)
return (const XIkChain*)this;
return XBase::GetFn(type);
}
//----------------------------------------------------------------------------------------------------------------------
bool XIkChain::NodeDeath(XId id)
{
XIndexList::iterator it = m_IkChain.begin();
for( ; it != m_IkChain.end(); ++it )
{
if (*it == id)
{
m_IkChain.erase(it);
break;
}
}
if(m_PoleConstraint == id)
m_PoleConstraint = 0;
if(m_Handle == id)
m_Handle=0;
return XBase::NodeDeath(id);
}
//----------------------------------------------------------------------------------------------------------------------
void XIkChain::PreDelete(XIdSet& extra_nodes)
{
XBase::PreDelete(extra_nodes);
}
//----------------------------------------------------------------------------------------------------------------------
bool XIkChain::ReadChunk(std::istream& ifs)
{
READ_CHECK("handle",ifs);
ifs >> m_Handle;
READ_CHECK("priority",ifs);
ifs >> m_Priority;
READ_CHECK("max_iterations",ifs);
ifs >> m_MaxIterations;
READ_CHECK("weight",ifs);
ifs >> m_Weight;
READ_CHECK("poweight",ifs);
ifs >> m_PoWeight;
READ_CHECK("tolerance",ifs);
ifs >> m_Tolerance;
READ_CHECK("stickiness",ifs);
ifs >> m_Stickiness;
READ_CHECK("pole_vector",ifs);
ifs >> m_PoleVector;
READ_CHECK("pole_constraint",ifs);
ifs >> m_PoleConstraint;
READ_CHECK("chain",ifs);
XU32 num;
ifs >> num;
m_IkChain.resize(num);
XIndexList::iterator it = m_IkChain.begin();
for( ; it != m_IkChain.end(); ++it )
{
ifs >> *it;
}
return ifs.good();
}
//----------------------------------------------------------------------------------------------------------------------
bool XIkChain::WriteChunk(std::ostream& ofs)
{
ofs << "\thandle " << m_Handle << "\n"
<< "\tpriority " << m_Priority << "\n"
<< "\tmax_iterations " << m_MaxIterations << "\n"
<< "\tweight " << m_Weight
<< "\tpoweight " << m_PoWeight
<< "\ttolerance " << m_Tolerance
<< "\tstickiness " << m_Stickiness
<< "\tpole_vector " << m_PoleVector.x << " " << m_PoleVector.y << " " << m_PoleVector.z << "\n"
<< "\tpole_constraint " << m_PoleConstraint
<< "\tchain " << GetNumBonesInChain() << "\n\t\t";
XIndexList::iterator it = m_IkChain.begin();
for( ; it != m_IkChain.end(); ++it )
{
ofs << *it << " ";
}
ofs << "\n";
return ofs.good();
}
//----------------------------------------------------------------------------------------------------------------------
bool XIkChain::DoData(XFileIO& io)
{
DUMPER(XIkChain);
IO_CHECK( XBase::DoData(io) );
IO_CHECK( io.DoData(&m_Handle) );
DPARAM( m_Handle );
IO_CHECK( io.DoData(&m_Priority) );
DPARAM( m_Priority );
IO_CHECK( io.DoData(&m_MaxIterations) );
DPARAM( m_MaxIterations );
IO_CHECK( io.DoData(&m_Weight) );
DPARAM( m_Weight );
IO_CHECK( io.DoData(&m_PoWeight) );
DPARAM( m_PoWeight );
IO_CHECK( io.DoData(&m_Tolerance) );
DPARAM( m_Tolerance );
IO_CHECK( io.DoData(&m_Stickiness) );
DPARAM( m_Stickiness );
IO_CHECK( io.DoData(&m_PoleVector) );
DPARAM( m_PoleVector );
IO_CHECK( io.DoData(&m_PoleConstraint) );
DPARAM( m_PoleConstraint );
IO_CHECK( io.DoDataVector(m_IkChain) );
DAPARAM( m_IkChain );
return true;
}
//----------------------------------------------------------------------------------------------------------------------
void XIkChain::DoCopy(const XBase* rhs)
{
const XIkChain* cb = rhs->HasFn<XIkChain>();
XMD_ASSERT(cb);
m_Handle = cb->m_Handle;
m_Priority = cb->m_Priority;
m_MaxIterations = cb->m_MaxIterations;
m_Weight = cb->m_Weight;
m_PoWeight = cb->m_PoWeight;
m_Tolerance = cb->m_Tolerance;
m_Stickiness = cb->m_Stickiness;
m_PoleVector = cb->m_PoleVector;
m_PoleConstraint = cb->m_PoleConstraint;
m_IkChain = cb->m_IkChain;
XBase::DoCopy(cb);
}
//----------------------------------------------------------------------------------------------------------------------
bool XIkChain::SetBonesInChain(const XBoneList& bones)
{
// run a check. The bones should form a continuous chain where the next
// bone in the chain is the child of the one before. To make this test
// easier (and to avoid a recursive function), start at the end of the
// chain and make sure that the element before it is actually the parent
// of that bone
//
{
XBoneList::const_iterator it = bones.end()-1;
XBoneList::const_iterator it2 = bones.end()-2;
for (;it2 >= bones.begin(); --it,--it2 )
{
//
// if you assert here, the node in the chain does not belong to this
// model.
//
XMD_ASSERT( IsValidObj(*it) );
// make sure the node is valid
if(!IsValidObj(*it))
return false;
// make sure the bones are continuous
if ((*it)->GetParent() != *it2)
{
return false;
}
}
}
// OK, the list is a valid chain, lets set it
m_IkChain.clear();
XBoneList::const_iterator it = bones.begin();
for (;it != bones.end(); ++it)
{
m_IkChain.push_back( (*it)->GetID() );
}
return true;
}
//----------------------------------------------------------------------------------------------------------------------
bool XIkChain::SetBonesInChain(const XBone* ik_root,const XBone* ik_effector)
{
if( !ik_root || !ik_effector )
return false;
bool root_valid = IsValidObj(ik_root);
// if you assert here, the ik root is not a node from the same XModel
// as this IK chain.
XMD_ASSERT(root_valid);
bool effector_valid = IsValidObj(ik_effector);
// if you assert here, the ik effector is not a node from the same XModel
// as this IK chain.
XMD_ASSERT(effector_valid);
if(!root_valid || !effector_valid) return false;
// construct a list of bones by working from the effector to the
// ik root.
XIndexList chain;
const XBone* ptr = ik_effector;
bool found_root = false;
while(ptr && !found_root)
{
chain.insert(chain.begin(),ptr->GetID());
if (ptr->GetID() == ik_root->GetID())
{
found_root=true;
}
ptr = ptr->GetParent();
}
if (!found_root)
{
XGlobal::GetLogger()->Log(XBasicLogger::kError,"could not determine a valid chain between the root and effector");
return false;
}
m_IkChain = chain;
return true;
}
//----------------------------------------------------------------------------------------------------------------------
void XIkChain::GetBonesInChain(XBoneList& bones) const
{
bones.clear();
XIndexList::const_iterator it = m_IkChain.begin();
for (;it != m_IkChain.end(); ++it)
{
bones.push_back( m_pModel->FindNode( *it )->HasFn<XBone>() );
}
}
//----------------------------------------------------------------------------------------------------------------------
void XIkChain::SetPoleVector(const XVector3& pole_vector)
{
m_PoleVector = pole_vector;
}
//----------------------------------------------------------------------------------------------------------------------
bool XIkChain::SetPoleConstraint(const XBase* transform)
{
if(!transform)
{
m_PoleConstraint = 0;
return true;
}
bool is_valid = IsValidObj(transform);
// if you assert here, the pole constraint provided is not from the same
// XModel as this ik chain...
XMD_ASSERT(is_valid);
if(!is_valid)
return false;
if (transform->HasFn<XBone>())
{
m_PoleConstraint = transform->GetID();
return true;
}
return false;
}
//----------------------------------------------------------------------------------------------------------------------
bool XIkChain::SetHandle(const XBase* transform)
{
if(!transform)
{
m_Handle = 0;
return true;
}
bool is_valid = IsValidObj(transform);
// if you assert here, the pole constraint provided is not from the same
// XModel as this ik chain...
XMD_ASSERT(is_valid);
if(!is_valid)
return false;
if (transform->HasFn<XBone>())
{
m_Handle = transform->GetID();
return true;
}
return false;
}
//----------------------------------------------------------------------------------------------------------------------
void XIkChain::SetPriority(const XS32 priority)
{
m_Priority = priority;
}
//----------------------------------------------------------------------------------------------------------------------
void XIkChain::SetMaxIterations(const XU32 num_iterations)
{
m_MaxIterations = num_iterations;
}
//----------------------------------------------------------------------------------------------------------------------
void XIkChain::SetWeight(const XReal weight)
{
m_Weight = weight;
}
//----------------------------------------------------------------------------------------------------------------------
void XIkChain::SetPoWeight(const XReal po_weight)
{
m_PoWeight = po_weight;
}
//----------------------------------------------------------------------------------------------------------------------
void XIkChain::SetTolerance(const XReal tolerance)
{
m_Tolerance = tolerance;
}
//----------------------------------------------------------------------------------------------------------------------
void XIkChain::SetStickiness(const XReal stickiness)
{
m_Stickiness = stickiness;
}
}
|
2b1f836b5b26741ccd758c2836e2fba5c75962d5
|
8bd1f2f63b7858c5006316a479b27b30eea903b9
|
/BattleTanks/Source/BattleTanks/Public/TankTrack.h
|
a3b9272fa96c2a12ec884e14d3ce60d35ff88867
|
[] |
no_license
|
SagaXXI/BattleTank
|
9c44f1ef966921569a35c07f9c147d9a98be3f5e
|
b4aadfdd4839caf562a797e18905f2775040b525
|
refs/heads/main
| 2023-08-17T03:39:25.177347
| 2021-07-30T05:26:25
| 2021-07-30T05:26:25
| 363,938,690
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 749
|
h
|
TankTrack.h
|
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "Components/StaticMeshComponent.h"
#include "TankTrack.generated.h"
/**
*
*/
UCLASS(meta=(BlueprintSpawnableComponent))
class BATTLETANKS_API UTankTrack : public UStaticMeshComponent
{
GENERATED_BODY()
//Max force to apply for tracks to move (in Newtons (mass * acceleration))
UPROPERTY(EditDefaultsOnly, Category = "Movement")
float TankMaxDrivingForce = 400000.f;
void DriveTrack(float CurrentThrottle);
//Getter for SprungWheels on Tank
TArray <class ASprungWheel*> GetWheels() const;
public:
UFUNCTION(BlueprintCallable, Category = "Input")
void SetThrottle(float Throttle);
UTankTrack();
};
|
71b8df78b9b9b616180240cb0b0ae8afe9141267
|
ab0a8234e443a6aa152b9f7b135a1e2560e9db33
|
/Server/CGSF/LogicLayer/MOGame/chat-server/chathandler.h
|
62970ff57dccdb5b6040368a9ef7fd540a7c892e
|
[] |
no_license
|
zetarus/Americano
|
71c358d8d12b144c8858983c23d9236f7d0e941b
|
b62466329cf6f515661ef9fb9b9d2ae90a032a60
|
refs/heads/master
| 2023-04-08T04:26:29.043048
| 2018-04-19T11:21:14
| 2018-04-19T11:21:14
| 104,159,178
| 9
| 2
| null | 2023-03-23T12:10:51
| 2017-09-20T03:11:44
|
C++
|
UTF-8
|
C++
| false
| false
| 8,728
|
h
|
chathandler.h
|
/*
* The Mana Server
* Copyright (C) 2004-2010 The Mana World Development Team
*
* This file is part of The Mana Server.
*
* The Mana Server is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* any later version.
*
* The Mana Server is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with The Mana Server. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef CHATHANDLER_H
#define CHATHANDLER_H
#include <deque>
#include <map>
#include <string>
#include "chat-server/guild.h"
#include "net/connectionhandler.h"
#include "utils/tokencollector.h"
class ChatChannel;
class ChatClient;
/**
* Manages chat related things like private messaging, chat channel handling
* as well as guild chat. The only form of chat not handled by this server is
* local chat, which is handled by the game server.
*
* @todo <b>b_lindeijer:</b> Extend this class with handling of team chat once
* teams are implemented.
*/
class ChatHandler : public ConnectionHandler
{
private:
/**
* Data needed for initializing a ChatClient.
*/
struct Pending
{
std::string character;
unsigned char level;
};
struct PartyInvite
{
PartyInvite(std::string inviterName, std::string inviteeName)
: mInviter(inviterName)
, mInvitee(inviteeName)
{
const int validTimeframe = 60;
mExpireTime = time(nullptr) + validTimeframe;
}
std::string mInviter;
std::string mInvitee;
time_t mExpireTime;
};
std::map<std::string, ChatClient*> mPlayerMap;
std::deque<PartyInvite> mInvitations;
std::map<std::string, int> mNumInvites;
public:
ChatHandler();
/**
* Start the handler.
*/
bool startListen(enet_uint16 port, const std::string &host);
/**
* Tell a list of users about an event in a chatchannel.
*
* @param channel the channel to send the message in, must not be nullptr
* @param info information pertaining to the event
*/
void warnUsersAboutPlayerEventInChat(ChatChannel *channel,
const std::string &info,
char eventId);
/**
* Called by TokenCollector when a client wrongly connected.
*/
void deletePendingClient(ChatClient *);
/**
* Called by TokenCollector when a client failed to connect.
*/
void deletePendingConnect(Pending *);
/**
* Called by TokenCollector when a client succesfully connected.
*/
void tokenMatched(ChatClient *, Pending *);
/**
* Send information about a change in the guild list to guild members.
*/
void sendGuildListUpdate(Guild *guild,
const std::string &characterName,
char eventId);
void handlePartyInvite(MessageIn &msg);
/**
* Sends an announce to all connected clients.
*/
void handleAnnounce(const std::string &message, int senderId,
const std::string &senderName);
/**
* Returns ChatClient from the Player Map
* @param The name of the character
* @return The Chat Client
*/
ChatClient *getClient(const std::string &name) const;
protected:
/**
* Process chat related messages.
*/
void processMessage(NetComputer *computer, MessageIn &message);
/**
* Returns a ChatClient instance.
*/
NetComputer *computerConnected(ENetPeer *);
/**
* Cleans up after the disconnected client.
*/
void computerDisconnected(NetComputer *);
/**
* Send messages for each guild the character belongs to.
*/
void sendGuildRejoin(ChatClient &computer);
/**
* Send chat and guild info to chat client, so that they can join the
* correct channels.
*/
void sendGuildEnterChannel(const MessageOut &msg,
const std::string &name);
void sendGuildInvite(const std::string &invitedName,
const std::string &inviterName,
const std::string &guildName);
private:
// TODO: Unused
void handleCommand(ChatClient &client, const std::string &command);
void handleChatMessage(ChatClient &client, MessageIn &msg);
void handlePrivMsgMessage(ChatClient &client, MessageIn &msg);
void handleWhoMessage(ChatClient &client);
void handleEnterChannelMessage(ChatClient &client, MessageIn &msg);
void handleModeChangeMessage(ChatClient &client, MessageIn &msg);
void handleKickUserMessage(ChatClient &client, MessageIn &msg);
void handleQuitChannelMessage(ChatClient &client, MessageIn &msg);
void handleListChannelsMessage(ChatClient &client, MessageIn &msg);
void handleListChannelUsersMessage(ChatClient &client, MessageIn &msg);
void handleTopicChange(ChatClient &client, MessageIn &msg);
void handleDisconnectMessage(ChatClient &client, MessageIn &msg);
void handleGuildCreate(ChatClient &client, MessageIn &msg);
void handleGuildInvite(ChatClient &client, MessageIn &msg);
void handleGuildAcceptInvite(ChatClient &client, MessageIn &msg);
void handleGuildGetMembers(ChatClient &client, MessageIn &msg);
void handleGuildMemberLevelChange(ChatClient &client, MessageIn &msg);
void removeCharacterFormGuild(ChatClient &client, Guild *guild);
void handleGuildKickMember(ChatClient &client, MessageIn &msg);
void handleGuildQuit(ChatClient &client, MessageIn &msg);
void handlePartyInviteAnswer(ChatClient &client, MessageIn &msg);
void handlePartyQuit(ChatClient &client);
void removeExpiredPartyInvites();
void removeUserFromParty(ChatClient &client);
/**
* Tell all the party members a member has left
*/
void informPartyMemberQuit(ChatClient &client);
/**
* Tell the player to be more polite.
*/
void warnPlayerAboutBadWords(ChatClient &computer);
/**
* Say something private to a player.
*/
void sayToPlayer(ChatClient &computer, const std::string &playerName,
const std::string &text);
/**
* Finds out the name of a character by its id. Either searches it
* in the list of online characters or otherwise gets it from the db.
*/
unsigned getIdOfChar(const std::string &name);
/**
* Sends a message to every client in a registered channel.
*
* @param channel the channel to send the message in, must not be nullptr
* @param msg the message to be sent
*/
void sendInChannel(ChatChannel *channel, MessageOut &msg);
/**
* Retrieves the guild channel or creates one automatically
* Automatically makes client join it
* @param The name of the guild (and therefore the channel)
* @param The client to join the channel
* @return Returns the channel joined
*/
ChatChannel *joinGuildChannel(const std::string &name,
ChatClient &client);
/**
* Set the topic of a guild channel
*/
void guildChannelTopicChange(ChatChannel *channel, int playerId,
const std::string &topic);
/**
* Container for pending clients and pending connections.
*/
TokenCollector<ChatHandler, ChatClient *, Pending *> mTokenCollector;
friend void registerChatClient(const std::string &, const std::string &, int);
};
/**
* Register future client attempt. Temporary until physical server split.
*/
void registerChatClient(const std::string &, const std::string &, int);
extern ChatHandler *chatHandler;
#endif
|
ad82a78694b226a3f3340b60a768f7765872a6be
|
8b76d8f5949e7d1a2a2b2d84cbeab08d3d2e0b62
|
/inc/i_agent.hpp
|
f6e753f48ca3bfe5aa3bc319eef21a0c903045da
|
[] |
no_license
|
RoyMattar/smart-home
|
a5690d1de4c22a94f55960d9fe8d19f199bac17d
|
5a27facdd225df252a6f3d9e1d1edbcc10514dd4
|
refs/heads/master
| 2022-07-03T10:55:42.119093
| 2020-05-18T08:58:11
| 2020-05-18T08:58:11
| 264,874,482
| 2
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 413
|
hpp
|
i_agent.hpp
|
#ifndef I_AGENT_HPP
#define I_AGENT_HPP
#include "common_utils.hpp"
#include "i_push_event_bus.hpp"
#include "i_consumer_registrar.hpp"
namespace smart_home
{
class IAgent
{
public:
virtual void Connect (SharedPtr<IPushEventBus> const& a_pushBus,
SharedPtr<IConsumerRegistrar> const& a_registrar) = 0;
virtual void Disconnect () = 0;
};
} // smart_home
#endif // I_AGENT_HPP
|
6c1906f4b65cc0479015064750da0fe09fef17ec
|
e6322c3d387929757ce579c5776606fddd0b26b2
|
/Common/Pool/SimplePool.h
|
3f98a605322856d51933b7634cf9a5636bb2ee22
|
[] |
no_license
|
liaohq/server
|
aa8527a53006945b84605cc2f3b974d88a9b1cca
|
41dc54bde846ca95461170b131ace9d87c322098
|
refs/heads/master
| 2020-04-27T20:24:46.591047
| 2019-03-31T09:31:42
| 2019-03-31T09:31:42
| 174,656,201
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 718
|
h
|
SimplePool.h
|
/*
* author: lhq
* data : 2017.4.7
* bref : simple memory pool
*/
#include<set>
typedef unsigned char BYTE;
template<typename DATA_T,const int MAX_SIZE>
class SimplePool
{
public:
SimplePool()
{
m_Pool = NULL;
m_Active = NULL;
m_Index = 0;
m_IdleList.clear();
}
~SimplePool()
{
if(NULL == m_Pool)
{
return;
}
delete [] m_Pool;
delete [] m_Active;
}
public:
void Init(int init_size = MAX_SIZE )
{
if(init_size>MAX_SIZE)
{
init_size = MAX_SIZE;
}
m_Pool = new DATA_T[MAX_SIZE];
m_Active = new BYTE[MAX_SIZE];
for(int i=0;i<init_size;i++)
{
m_Active[i] = false;
}
}
private:
DATA_T* m_Pool;
BYTE* m_Active;
int m_Index;
set<int> m_IdleList;
};
|
a1a18a39281b9e03497528d0d09dcd83f65d72c1
|
e411c7bef1cc26542f483913ca423c51f6216dbc
|
/src/Driver/Spi_Driver.cpp
|
928d213f426bce270d7a9dd2f46975e1d24d0ebb
|
[] |
no_license
|
MeowSoft/SpiDriver
|
4f5d78fa9c42ae96962620d5d7226b74cb75fb02
|
ea9e775134b7f34b6448bb32fe9aa6c48c51aa8f
|
refs/heads/master
| 2023-08-22T18:18:14.449359
| 2021-10-22T13:15:34
| 2021-10-22T13:15:34
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 3,106
|
cpp
|
Spi_Driver.cpp
|
/**
* This file contains the 'validatePins' and 'init'
* method definitions for the selected platform.
*/
#include "../Spi_Driver.h"
USE_NAMESPACE_SPI
// ====================================
// ARM (Due):
// ====================================
#if defined(__SAM3X8E__)
bool SPI_Driver::validatePins(
const uint8_t csPin,
const uint8_t dcPin,
LogMethod_t logger
) {
return true;
}
void SPI_Driver::init(
const uint8_t csPin,
const uint8_t dcPin
) {
Spi_ = Spi_ARM();
Spi_.init(csPin, dcPin);
}
// ====================================
// AVR (Duemilanove):
// ====================================
#elif defined(__AVR__)
bool SPI_Driver::validatePins(
const uint8_t csPin,
const uint8_t dcPin,
LogMethod_t logger
) {
return true;
}
void SPI_Driver::init(
const uint8_t csPin,
const uint8_t dcPin
) {
Spi_ = Spi_AVR();
Spi_.init(csPin, dcPin);
}
// ====================================
// ESP8266:
// ====================================
#elif defined(ESP8266)
bool SPI_Driver::validatePins(
const uint8_t csPin,
const uint8_t dcPin,
LogMethod_t logger
) {
return true;
}
void SPI_Driver::init(
const uint8_t csPin,
const uint8_t dcPin
) {
Spi_ = Spi_ESP8266();
Spi_.init(csPin, dcPin);
}
// ====================================
// Teensy LC:
// ====================================
#elif defined(__MKL26Z64__)
bool SPI_Driver::validatePins(
const uint8_t sdoPin,
const uint8_t sckPin,
const uint8_t csPin,
const uint8_t dcPin,
LogMethod_t logger
) {
const char* error;
if (!(Spi_.validatePins(sdoPin, sckPin, csPin, dcPin, error))) {
logger(error);
return false;
}
return true;
}
void SPI_Driver::init(
const uint8_t sdoPin,
const uint8_t sckPin,
const uint8_t csPin,
const uint8_t dcPin
) {
Spi_ = Spi_Teensy_LC();
Spi_.init(sdoPin, sckPin, csPin, dcPin);
}
// ====================================
// Teensy 3.x:
// ====================================
#elif defined(__MK20DX128__) || defined(__MK20DX256__) || defined(__MK64FX512__) || defined(__MK66FX1M0__)
bool SPI_Driver::validatePins(
const uint8_t sdoPin,
const uint8_t sckPin,
const uint8_t csPin,
const uint8_t dcPin,
LogMethod_t logger
) {
const char* error = NULL;
if (!Spi_.validatePins(sdoPin, sckPin, csPin, dcPin, error)) {
logger(error);
return false;
}
return true;
}
void SPI_Driver::init(
const uint8_t sdoPin,
const uint8_t sckPin,
const uint8_t csPin,
const uint8_t dcPin,
uint8_t nopCmd
) {
Spi_ = Spi_Teensy_3x();
Spi_.init(sdoPin, sckPin, csPin, dcPin, nopCmd);
}
// ====================================
// All other platforms:
// ====================================
#else
bool SPI_Driver::validatePins(
const uint8_t csPin,
const uint8_t dcPin,
LogMethod_t logger
) {
return true;
}
void SPI_Driver::init(
const uint8_t csPin,
const uint8_t dcPin
) {
Spi_ = Spi_Legacy();
Spi_.init(csPin, dcPin);
}
#endif
|
26e1e1309033b5a1001d6402033cd808bb675585
|
385c04f0202883e614e1a4860fc2f52682b9c1b3
|
/zen/picking/lib/vsLogLib.cpp
|
830b1ef3a1e9292f724cbb50947f6dcc4680dd6b
|
[] |
no_license
|
JanosSarkoezi/cmake
|
7e1a990e2e91c50a56f6924af1f4b9e77523bcd5
|
0d85ac3a2b7e64d7772f66ab354734d66452e9cd
|
refs/heads/master
| 2021-07-23T02:24:13.765470
| 2021-03-07T19:34:02
| 2021-03-07T19:34:02
| 244,494,088
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,688
|
cpp
|
vsLogLib.cpp
|
/** ----------------------------------------------------------
* \class VSLogLib
*
* Lighthouse3D
*
* VSLogLib - Very Simple Log Library
*
* \version 0.1.0
* Initial Release
*
* This class provides a basic logging mechanism
*
* Full documentation at
* http://www.lighthouse3d.com/very-simple-libs
*
---------------------------------------------------------------*/
#include "vsLogLib.h"
VSLogLib::VSLogLib(): pStreamEnabled(false) {
}
// cleans up
VSLogLib::~VSLogLib() {
pLogVector.clear();
}
// clears the log
void
VSLogLib::clear() {
pLogVector.clear();
}
// adds a message, printf style
void
VSLogLib::addMessage(std::string s, ...) {
va_list args;
va_start(args,s);
vsnprintf( pAux, 256, s.c_str(), args );
//vsprintf(pAux,s.c_str(), args);
va_end(args);
if (pStreamEnabled)
*pOuts << pAux << "\n";
else
pLogVector.push_back(pAux);
}
// dumps the log contents to a file
void
VSLogLib::dumpToFile(std::string filename) {
std::ofstream file;
file.open(filename.c_str());
for (unsigned int i = 0; i < pLogVector.size(); ++i) {
file << pLogVector[i] << "\n";
}
file.close();
}
// dumps the log contents to a string
std::string
VSLogLib::dumpToString() {
pRes = "";
for (unsigned int i = 0; i < pLogVector.size(); ++i) {
pRes += pLogVector[i] + "\n";
}
return pRes;
}
void
VSLogLib::disableStream() {
pStreamEnabled = false;
}
void
VSLogLib::enableStream(std::ostream *outStream) {
// set the output stream
if (!outStream)
pOuts = (std::iostream *)&std::cout;
else
pOuts = outStream;
pStreamEnabled = true;
}
|
23952882993dbdf7d09a236e0cca1630cf37cb9b
|
c565137e9564118f38444eaca744a6588b90d053
|
/DirectX113DTutorialGameEditor/Editor/Gizmo3D.cpp
|
ae3c993c97d4ed8b55654c582db5477b4a94827a
|
[] |
no_license
|
principal6/DirectX113DTutorial
|
f670971c5cfe09f4744b50324a8795e455c4a317
|
12bc6eb92c73e53eb588d55386a4dbca3e9c9300
|
refs/heads/master
| 2020-08-02T22:59:27.634000
| 2020-01-31T09:41:49
| 2020-01-31T09:41:49
| 211,528,785
| 5
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 17,247
|
cpp
|
Gizmo3D.cpp
|
#include "Gizmo3D.h"
#include "../Core/ConstantBuffer.h"
#include "../Core/PrimitiveGenerator.h"
#include "../Core/Shader.h"
#include "../Model/Object3D.h"
using std::make_unique;
CGizmo3D::CGizmo3D(ID3D11Device* const PtrDevice, ID3D11DeviceContext* const PtrDeviceContext) :
m_PtrDevice{ PtrDevice }, m_PtrDeviceContext{ PtrDeviceContext }
{
assert(m_PtrDevice);
assert(m_PtrDeviceContext);
}
CGizmo3D::~CGizmo3D()
{
}
void CGizmo3D::Create()
{
bool bShouldCompileShaders{ false };
m_CBGizmoSpace = make_unique<CConstantBuffer>(m_PtrDevice, m_PtrDeviceContext, &m_CBGizmoSpaceData, sizeof(m_CBGizmoSpaceData));
m_CBGizmoSpace->Create();
m_CBGizmoColorFactor = make_unique<CConstantBuffer>(m_PtrDevice, m_PtrDeviceContext, &m_CBGizmoColorFactorData, sizeof(m_CBGizmoColorFactorData));
m_CBGizmoColorFactor->Create();
m_VSGizmo = make_unique<CShader>(m_PtrDevice, m_PtrDeviceContext);
m_VSGizmo->Create(EShaderType::VertexShader, CShader::EVersion::_4_0, bShouldCompileShaders, L"Shader\\VSGizmo.hlsl", "main",
CObject3D::KInputElementDescs, ARRAYSIZE(CObject3D::KInputElementDescs));
m_VSGizmo->ReserveConstantBufferSlots(KVSSharedCBCount);
m_VSGizmo->AttachConstantBuffer(m_CBGizmoSpace.get());
m_PSGizmo = make_unique<CShader>(m_PtrDevice, m_PtrDeviceContext);
m_PSGizmo->Create(EShaderType::PixelShader, CShader::EVersion::_4_0, bShouldCompileShaders, L"Shader\\PSGizmo.hlsl", "main");
m_PSGizmo->ReserveConstantBufferSlots(KPSSharedCBCount);
m_PSGizmo->AttachConstantBuffer(m_CBGizmoColorFactor.get());
if (!m_RotationX)
{
m_RotationX = make_unique<CObject3D>("Gizmo", m_PtrDevice, m_PtrDeviceContext);
SMesh MeshRing{ GenerateTorus(K3DGizmoRadius, 16, KRotationGizmoRingSegmentCount, KColorX) };
SMesh MeshAxis{ GenerateCylinder(K3DGizmoRadius, 1.0f, 16, KColorX) };
TranslateMesh(MeshAxis, XMVectorSet(0, 0.5f, 0, 0));
m_RotationX->Create(MergeStaticMeshes(MeshRing, MeshAxis));
m_RotationX->RotateRollTo(-XM_PIDIV2);
}
if (!m_RotationY)
{
m_RotationY = make_unique<CObject3D>("Gizmo", m_PtrDevice, m_PtrDeviceContext);
SMesh MeshRing{ GenerateTorus(K3DGizmoRadius, 16, KRotationGizmoRingSegmentCount, KColorY) };
SMesh MeshAxis{ GenerateCylinder(K3DGizmoRadius, 1.0f, 16, KColorY) };
TranslateMesh(MeshAxis, XMVectorSet(0, 0.5f, 0, 0));
m_RotationY->Create(MergeStaticMeshes(MeshRing, MeshAxis));
}
if (!m_RotationZ)
{
m_RotationZ = make_unique<CObject3D>("Gizmo", m_PtrDevice, m_PtrDeviceContext);
SMesh MeshRing{ GenerateTorus(K3DGizmoRadius, 16, KRotationGizmoRingSegmentCount, KColorZ) };
SMesh MeshAxis{ GenerateCylinder(K3DGizmoRadius, 1.0f, 16, KColorZ) };
TranslateMesh(MeshAxis, XMVectorSet(0, 0.5f, 0, 0));
m_RotationZ->Create(MergeStaticMeshes(MeshRing, MeshAxis));
m_RotationZ->RotatePitchTo(XM_PIDIV2);
}
if (!m_TranslationX)
{
m_TranslationX = make_unique<CObject3D>("Gizmo", m_PtrDevice, m_PtrDeviceContext);
SMesh MeshAxis{ GenerateCylinder(K3DGizmoRadius, 1.0f, 16, KColorX) };
SMesh MeshCone{ GenerateCone(0, 0.1f, 0.5f, 16, KColorX) };
TranslateMesh(MeshCone, XMVectorSet(0, 0.5f, 0, 0));
MeshAxis = MergeStaticMeshes(MeshAxis, MeshCone);
TranslateMesh(MeshAxis, XMVectorSet(0, 0.5f, 0, 0));
m_TranslationX->Create(MeshAxis);
m_TranslationX->RotateRollTo(-XM_PIDIV2);
}
if (!m_TranslationY)
{
m_TranslationY = make_unique<CObject3D>("Gizmo", m_PtrDevice, m_PtrDeviceContext);
SMesh MeshAxis{ GenerateCylinder(K3DGizmoRadius, 1.0f, 16, KColorY) };
SMesh MeshCone{ GenerateCone(0, 0.1f, 0.5f, 16, KColorY) };
TranslateMesh(MeshCone, XMVectorSet(0, 0.5f, 0, 0));
MeshAxis = MergeStaticMeshes(MeshAxis, MeshCone);
TranslateMesh(MeshAxis, XMVectorSet(0, 0.5f, 0, 0));
m_TranslationY->Create(MeshAxis);
}
if (!m_TranslationZ)
{
m_TranslationZ = make_unique<CObject3D>("Gizmo", m_PtrDevice, m_PtrDeviceContext);
SMesh MeshAxis{ GenerateCylinder(K3DGizmoRadius, 1.0f, 16, KColorZ) };
SMesh MeshCone{ GenerateCone(0, 0.1f, 0.5f, 16, KColorZ) };
TranslateMesh(MeshCone, XMVectorSet(0, 0.5f, 0, 0));
MeshAxis = MergeStaticMeshes(MeshAxis, MeshCone);
TranslateMesh(MeshAxis, XMVectorSet(0, 0.5f, 0, 0));
m_TranslationZ->Create(MeshAxis);
m_TranslationZ->RotatePitchTo(XM_PIDIV2);
}
if (!m_ScalingX)
{
m_ScalingX = make_unique<CObject3D>("Gizmo", m_PtrDevice, m_PtrDeviceContext);
SMesh MeshAxis{ GenerateCylinder(K3DGizmoRadius, 1.0f, 16, KColorX) };
SMesh MeshCube{ GenerateCube(KColorX) };
ScaleMesh(MeshCube, XMVectorSet(0.2f, 0.2f, 0.2f, 0));
TranslateMesh(MeshCube, XMVectorSet(0, 0.5f, 0, 0));
MeshAxis = MergeStaticMeshes(MeshAxis, MeshCube);
TranslateMesh(MeshAxis, XMVectorSet(0, 0.5f, 0, 0));
m_ScalingX->Create(MeshAxis);
m_ScalingX->RotateRollTo(-XM_PIDIV2);
}
if (!m_ScalingY)
{
m_ScalingY = make_unique<CObject3D>("Gizmo", m_PtrDevice, m_PtrDeviceContext);
SMesh MeshAxis{ GenerateCylinder(K3DGizmoRadius, 1.0f, 16, KColorY) };
SMesh MeshCube{ GenerateCube(KColorY) };
ScaleMesh(MeshCube, XMVectorSet(0.2f, 0.2f, 0.2f, 0));
TranslateMesh(MeshCube, XMVectorSet(0, 0.5f, 0, 0));
MeshAxis = MergeStaticMeshes(MeshAxis, MeshCube);
TranslateMesh(MeshAxis, XMVectorSet(0, 0.5f, 0, 0));
m_ScalingY->Create(MeshAxis);
}
if (!m_ScalingZ)
{
m_ScalingZ = make_unique<CObject3D>("Gizmo", m_PtrDevice, m_PtrDeviceContext);
SMesh MeshAxis{ GenerateCylinder(K3DGizmoRadius, 1.0f, 16, KColorZ) };
SMesh MeshCube{ GenerateCube(KColorZ) };
ScaleMesh(MeshCube, XMVectorSet(0.2f, 0.2f, 0.2f, 0));
TranslateMesh(MeshCube, XMVectorSet(0, 0.5f, 0, 0));
MeshAxis = MergeStaticMeshes(MeshAxis, MeshCube);
TranslateMesh(MeshAxis, XMVectorSet(0, 0.5f, 0, 0));
m_ScalingZ->Create(MeshAxis);
m_ScalingZ->RotatePitchTo(XM_PIDIV2);
}
}
void CGizmo3D::CaptureTranslation(const XMVECTOR& Translation)
{
m_GizmoTranslation = Translation / XMVectorGetW(Translation);
}
void CGizmo3D::UpdateTranslation(const XMVECTOR& CameraPosition)
{
// @important
// Translate gizmos
m_TranslationX->TranslateTo(m_GizmoTranslation);
m_TranslationY->TranslateTo(m_GizmoTranslation);
m_TranslationZ->TranslateTo(m_GizmoTranslation);
m_RotationX->TranslateTo(m_GizmoTranslation);
m_RotationY->TranslateTo(m_GizmoTranslation);
m_RotationZ->TranslateTo(m_GizmoTranslation);
m_ScalingX->TranslateTo(m_GizmoTranslation);
m_ScalingY->TranslateTo(m_GizmoTranslation);
m_ScalingZ->TranslateTo(m_GizmoTranslation);
// @important
// Calculate scalar IAW the distance from the camera
m_GizmoDistanceScalar = XMVectorGetX(XMVector3Length(CameraPosition - m_GizmoTranslation)) * 0.1f;
m_GizmoDistanceScalar = pow(m_GizmoDistanceScalar, 0.7f);
}
void CGizmo3D::SetMode(EMode eMode)
{
m_eCurrentMode = eMode;
}
bool CGizmo3D::Interact(const XMVECTOR& PickingRayOrigin, const XMVECTOR& PickingRayDirection,
const XMVECTOR& CameraPosition, const XMVECTOR& CameraForward, int MouseX, int MouseY, bool bMouseLeftDown)
{
bool bResult{ false };
if (IsInAction())
{
float DotXAxisForward{ XMVectorGetX(XMVector3Dot(XMVectorSet(1, 0, 0, 0), CameraForward)) };
float DotZAxisForward{ XMVectorGetX(XMVector3Dot(XMVectorSet(0, 0, 1, 0), CameraForward)) };
int DeltaX{ MouseX - m_CapturedMouseX };
int DeltaY{ MouseY - m_CapturedMouseY };
int Delta{};
if (m_eCurrentMode == EMode::Rotation)
{
Delta = (m_eSelectedAxis == EAxis::AxisY) ? -DeltaX : -DeltaY;
}
else // Translation & Scaling
{
switch (m_eSelectedAxis)
{
default:
case EAxis::None:
break;
case EAxis::AxisX:
if (DotZAxisForward < 0.0f) DeltaX = -DeltaX;
Delta = DeltaX;
break;
case EAxis::AxisY:
Delta = -DeltaY;
break;
case EAxis::AxisZ:
if (DotXAxisForward >= 0.0f) DeltaX = -DeltaX;
Delta = DeltaX;
break;
}
}
int DeltaSign{};
if (Delta != 0)
{
if (Delta > +1) DeltaSign = +1;
if (Delta < -1) DeltaSign = -1;
}
if (DeltaSign != 0)
{
float DistanceObejctCamera{ XMVectorGetX(XMVector3Length(m_GizmoTranslation - CameraPosition)) };
float DeltaFactor{ KMovementFactorBase };
if (DistanceObejctCamera > K3DGizmoCameraDistanceThreshold4) DeltaFactor *= 32.0f; // 2.0f
else if (DistanceObejctCamera > K3DGizmoCameraDistanceThreshold3) DeltaFactor *= 16.0f; // 1.0f
else if (DistanceObejctCamera > K3DGizmoCameraDistanceThreshold2) DeltaFactor *= 8.0f; // 0.5f
else if (DistanceObejctCamera > K3DGizmoCameraDistanceThreshold1) DeltaFactor *= 4.0f; // 0.25f
else if (DistanceObejctCamera > K3DGizmoCameraDistanceThreshold0) DeltaFactor *= 2.0f; // 0.125f
float DeltaTranslationScalar{ DeltaSign * DeltaFactor };
float DeltaRotationScalar{ DeltaSign * KRotation360To2PI * KRotationDelta };
float DeltaScalingScalar{ DeltaSign * DeltaFactor };
switch (m_eCurrentMode)
{
case EMode::Translation:
DeltaRotationScalar = 0;
DeltaScalingScalar = 0;
break;
case EMode::Rotation:
DeltaTranslationScalar = 0;
DeltaScalingScalar = 0;
break;
case EMode::Scaling:
DeltaTranslationScalar = 0;
DeltaRotationScalar = 0;
break;
default:
break;
}
m_DeltaTranslation = XMVectorSet(
(m_eSelectedAxis == EAxis::AxisX) ? DeltaTranslationScalar : 0,
(m_eSelectedAxis == EAxis::AxisY) ? DeltaTranslationScalar : 0,
(m_eSelectedAxis == EAxis::AxisZ) ? DeltaTranslationScalar : 0, 0);
m_DeltaPitch = (m_eSelectedAxis == EAxis::AxisX) ? DeltaRotationScalar : 0;
m_DeltaYaw = (m_eSelectedAxis == EAxis::AxisY) ? DeltaRotationScalar : 0;
m_DeltaRoll = (m_eSelectedAxis == EAxis::AxisZ) ? DeltaRotationScalar : 0;
m_DeltaScaling = XMVectorSet(
(m_eSelectedAxis == EAxis::AxisX) ? DeltaScalingScalar : 0,
(m_eSelectedAxis == EAxis::AxisY) ? DeltaScalingScalar : 0,
(m_eSelectedAxis == EAxis::AxisZ) ? DeltaScalingScalar : 0, 0);
m_CapturedMouseX = MouseX;
m_CapturedMouseY = MouseY;
m_GizmoTranslation += m_DeltaTranslation;
bResult = true;
}
}
else
{
m_CapturedMouseX = MouseX;
m_CapturedMouseY = MouseY;
m_PickingRayOrigin = PickingRayOrigin;
m_PickingRayDirection = PickingRayDirection;
switch (m_eCurrentMode)
{
case EMode::Translation:
m_bIsHovered = true;
if (IsInteractingTS(EAxis::AxisX))
{
m_eSelectedAxis = EAxis::AxisX;
}
else if (IsInteractingTS(EAxis::AxisY))
{
m_eSelectedAxis = EAxis::AxisY;
}
else if (IsInteractingTS(EAxis::AxisZ))
{
m_eSelectedAxis = EAxis::AxisZ;
}
else
{
m_bIsHovered = false;
}
break;
case EMode::Rotation:
{
XMVECTOR T{ KVectorGreatest };
m_bIsHovered = false;
if (IsInteractingR(EAxis::AxisX, &T))
{
m_eSelectedAxis = EAxis::AxisX;
m_bIsHovered = true;
}
if (IsInteractingR(EAxis::AxisY, &T))
{
m_eSelectedAxis = EAxis::AxisY;
m_bIsHovered = true;
}
if (IsInteractingR(EAxis::AxisZ, &T))
{
m_eSelectedAxis = EAxis::AxisZ;
m_bIsHovered = true;
}
break;
}
case EMode::Scaling:
m_bIsHovered = true;
if (IsInteractingTS(EAxis::AxisX))
{
m_eSelectedAxis = EAxis::AxisX;
}
else if (IsInteractingTS(EAxis::AxisY))
{
m_eSelectedAxis = EAxis::AxisY;
}
else if (IsInteractingTS(EAxis::AxisZ))
{
m_eSelectedAxis = EAxis::AxisZ;
}
else
{
m_bIsHovered = false;
}
break;
default:
break;
}
if (m_bIsHovered && bMouseLeftDown)
{
m_bIsInAction = true;
}
else if (!m_bIsHovered)
{
m_eSelectedAxis = EAxis::None;
}
}
UpdateTranslation(CameraPosition);
return bResult;
}
void CGizmo3D::QuitAction()
{
m_bIsInAction = false;
}
bool CGizmo3D::IsInteractingTS(EAxis eAxis)
{
static constexpr float KGizmoLengthFactor{ 1.1875f };
static constexpr float KGizmoRaidus{ 0.05859375f };
XMVECTOR CylinderSpaceRayOrigin{ m_PickingRayOrigin - m_GizmoTranslation };
XMVECTOR CylinderSpaceRayDirection{ m_PickingRayDirection };
switch (eAxis)
{
case EAxis::None:
return false;
break;
case EAxis::AxisX:
{
XMMATRIX RotationMatrix{ XMMatrixRotationZ(XM_PIDIV2) };
CylinderSpaceRayOrigin = XMVector3TransformCoord(CylinderSpaceRayOrigin, RotationMatrix);
CylinderSpaceRayDirection = XMVector3TransformNormal(CylinderSpaceRayDirection, RotationMatrix);
if (IntersectRayCylinder(CylinderSpaceRayOrigin, CylinderSpaceRayDirection,
KGizmoLengthFactor * m_GizmoDistanceScalar, KGizmoRaidus * m_GizmoDistanceScalar)) return true;
}
break;
case EAxis::AxisY:
if (IntersectRayCylinder(CylinderSpaceRayOrigin, CylinderSpaceRayDirection,
KGizmoLengthFactor * m_GizmoDistanceScalar, KGizmoRaidus * m_GizmoDistanceScalar)) return true;
break;
case EAxis::AxisZ:
{
XMMATRIX RotationMatrix{ XMMatrixRotationX(-XM_PIDIV2) };
CylinderSpaceRayOrigin = XMVector3TransformCoord(CylinderSpaceRayOrigin, RotationMatrix);
CylinderSpaceRayDirection = XMVector3TransformNormal(CylinderSpaceRayDirection, RotationMatrix);
if (IntersectRayCylinder(CylinderSpaceRayOrigin, CylinderSpaceRayDirection,
KGizmoLengthFactor * m_GizmoDistanceScalar, KGizmoRaidus * m_GizmoDistanceScalar)) return true;
}
break;
default:
break;
}
return false;
}
bool CGizmo3D::IsInteractingR(EAxis eAxis, XMVECTOR* const OutPtrT)
{
static constexpr float KHollowCylinderInnerRaidus{ 0.9375f };
static constexpr float KHollowCylinderOuterRaidus{ 1.0625f };
static constexpr float KHollowCylinderHeight{ 0.125f };
XMVECTOR CylinderSpaceRayOrigin{ m_PickingRayOrigin - m_GizmoTranslation };
XMVECTOR CylinderSpaceRayDirection{ m_PickingRayDirection };
XMVECTOR NewT{ KVectorGreatest };
switch (eAxis)
{
case EAxis::None:
{
return false;
}
case EAxis::AxisX:
{
XMMATRIX RotationMatrix{ XMMatrixRotationZ(XM_PIDIV2) };
CylinderSpaceRayOrigin = XMVector3TransformCoord(CylinderSpaceRayOrigin, RotationMatrix);
CylinderSpaceRayDirection = XMVector3TransformNormal(CylinderSpaceRayDirection, RotationMatrix);
if (IntersectRayHollowCylinderCentered(CylinderSpaceRayOrigin, CylinderSpaceRayDirection, KHollowCylinderHeight,
KHollowCylinderInnerRaidus * m_GizmoDistanceScalar, KHollowCylinderOuterRaidus * m_GizmoDistanceScalar, &NewT))
{
if (XMVector3Less(NewT, *OutPtrT))
{
*OutPtrT = NewT;
return true;
}
}
break;
}
case EAxis::AxisY:
{
if (IntersectRayHollowCylinderCentered(CylinderSpaceRayOrigin, CylinderSpaceRayDirection, KHollowCylinderHeight,
KHollowCylinderInnerRaidus * m_GizmoDistanceScalar, KHollowCylinderOuterRaidus * m_GizmoDistanceScalar, &NewT))
{
if (XMVector3Less(NewT, *OutPtrT))
{
*OutPtrT = NewT;
return true;
}
}
break;
}
case EAxis::AxisZ:
{
XMMATRIX RotationMatrix{ XMMatrixRotationX(XM_PIDIV2) };
CylinderSpaceRayOrigin = XMVector3TransformCoord(CylinderSpaceRayOrigin, RotationMatrix);
CylinderSpaceRayDirection = XMVector3TransformNormal(CylinderSpaceRayDirection, RotationMatrix);
if (IntersectRayHollowCylinderCentered(CylinderSpaceRayOrigin, CylinderSpaceRayDirection, KHollowCylinderHeight,
KHollowCylinderInnerRaidus * m_GizmoDistanceScalar, KHollowCylinderOuterRaidus * m_GizmoDistanceScalar, &NewT))
{
if (XMVector3Less(NewT, *OutPtrT))
{
*OutPtrT = NewT;
return true;
}
}
break;
}
default:
break;
}
return false;
}
void CGizmo3D::Draw(const XMMATRIX& ViewProjection)
{
m_VSGizmo->Use();
m_PSGizmo->Use();
bool bShouldHighlightX{ m_eSelectedAxis == EAxis::AxisX };
bool bShouldHighlightY{ m_eSelectedAxis == EAxis::AxisY };
bool bShouldHighlightZ{ m_eSelectedAxis == EAxis::AxisZ };
switch (m_eCurrentMode)
{
case CGizmo3D::EMode::Translation:
DrawGizmo(m_TranslationX.get(), ViewProjection, bShouldHighlightX);
DrawGizmo(m_TranslationY.get(), ViewProjection, bShouldHighlightY);
DrawGizmo(m_TranslationZ.get(), ViewProjection, bShouldHighlightZ);
break;
case CGizmo3D::EMode::Rotation:
DrawGizmo(m_RotationX.get(), ViewProjection, bShouldHighlightX);
DrawGizmo(m_RotationY.get(), ViewProjection, bShouldHighlightY);
DrawGizmo(m_RotationZ.get(), ViewProjection, bShouldHighlightZ);
break;
case CGizmo3D::EMode::Scaling:
DrawGizmo(m_ScalingX.get(), ViewProjection, bShouldHighlightX);
DrawGizmo(m_ScalingY.get(), ViewProjection, bShouldHighlightY);
DrawGizmo(m_ScalingZ.get(), ViewProjection, bShouldHighlightZ);
break;
default:
break;
}
}
void CGizmo3D::DrawGizmo(CObject3D* const Gizmo, const XMMATRIX& ViewProjection, bool bShouldHighlight)
{
Gizmo->ScaleTo(XMVectorSet(m_GizmoDistanceScalar, m_GizmoDistanceScalar, m_GizmoDistanceScalar, 0.0f));
Gizmo->UpdateWorldMatrix();
m_CBGizmoSpaceData.WVP = XMMatrixTranspose(Gizmo->GetWorldMatrix() * ViewProjection);
m_CBGizmoSpace->Update();
// @important: alpha 0 means color overriding in PS
m_CBGizmoColorFactorData.ColorFactor = (bShouldHighlight) ? XMVectorSet(1.0f, 1.0f, 0.0f, 0.0f) : XMVectorSet(1.0f, 1.0f, 1.0f, 1.0f);
m_CBGizmoColorFactor->Update();
Gizmo->Draw();
}
const XMVECTOR& CGizmo3D::GetDeltaTranslation() const
{
return m_DeltaTranslation;
}
float CGizmo3D::GetDeltaPitch() const
{
return m_DeltaPitch;
}
float CGizmo3D::GetDeltaYaw() const
{
return m_DeltaYaw;
}
float CGizmo3D::GetDeltaRoll() const
{
return m_DeltaRoll;
}
const XMVECTOR& CGizmo3D::GetDeltaScaling() const
{
return m_DeltaScaling;
}
bool CGizmo3D::IsInAction() const
{
return m_bIsInAction;
}
|
789f23d403a14974fd7ed1336b020c767c4617cc
|
03a18d364f245ab2c901ea33b310f67147014cfa
|
/Temps5/Temps5.ino
|
458f280a0ae3a53106705b1b90c5f2384b81b4b3
|
[
"Unlicense"
] |
permissive
|
davidb24v/pyTemps
|
9240468aee962add32c4f88e3474b2e1ce410f62
|
abf34a8237adb189cad12326ec1ad95620f5ed11
|
refs/heads/master
| 2021-03-12T22:27:28.567922
| 2014-01-21T06:40:04
| 2014-01-21T06:40:04
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,566
|
ino
|
Temps5.ino
|
#include <OneWire.h>
#include <DallasTemperature.h>
// One wire bus connected to pin 3
#define ONE_WIRE_BUS 3
// Use 9 bit temperature
#define TEMPERATURE_PRECISION 9
// Setup a oneWire instance to communicate with any OneWire devices
OneWire oneWire(ONE_WIRE_BUS);
// Pass our oneWire reference to Dallas Temperature.
DallasTemperature sensors(&oneWire);
// Device addresses (see numbers on cables)
uint8_t sensor[5][8] = {
{ 0x28, 0xB1, 0xD1, 0x23, 0x05, 0x00, 0x00, 0x70 },
{ 0x28, 0x20, 0x07, 0x24, 0x05, 0x00, 0x00, 0xB2 },
{ 0x28, 0xF6, 0x25, 0xEF, 0x04, 0x00, 0x00, 0xB9 },
{ 0x28, 0x91, 0x43, 0x23, 0x05, 0x00, 0x00, 0xF2 },
{ 0x28, 0x91, 0x3F, 0x23, 0x05, 0x00, 0x00, 0xBE }
};
void setup(void) {
// start serial port
Serial.begin(115200);
// Start up the library
sensors.begin();
// Set precision to 9 bits
for (int i=0; i<5; i++) {
sensors.setResolution(sensor[i], TEMPERATURE_PRECISION);
}
// On-board LED
pinMode(13, OUTPUT);
digitalWrite(13, LOW);
}
void loop(void) {
float tempC;
// call sensors.requestTemperatures() to issue a global temperature
// request to all devices on the bus
sensors.requestTemperatures();
delay(10);
// Turn on LED
digitalWrite(13, HIGH);
// Print timestamp in seconds
Serial.print(millis()/1000L);
Serial.print(" ");
// Print temperatures
for (int i=0; i<5; i++) {
tempC = sensors.getTempC(sensor[i]);
Serial.print(tempC);
Serial.print(" ");
}
Serial.println("");
// Turn off LED
digitalWrite(13, LOW);
delay(60000L);
}
|
73bac07c606dfc260633463660db3a062d7aa952
|
c165141f2d8389668a51b3f704e30c18671ef7a0
|
/articles/postscript.re
|
220cfd425df6fe5650bb8da83bc0de29cb77ed5d
|
[] |
no_license
|
onestop-techbook/setting_goals
|
0571ebbed9dc5edb00e314aec65f8c23f71662bf
|
7020bf1eb759448afc195929121c2cc7c187a11b
|
refs/heads/master
| 2021-07-17T20:29:13.576547
| 2021-07-13T11:19:47
| 2021-07-13T11:19:47
| 167,572,269
| 5
| 17
| null | 2019-09-07T22:12:37
| 2019-01-25T15:51:33
|
C++
|
UTF-8
|
C++
| false
| false
| 3,963
|
re
|
postscript.re
|
= ใใจใใ
ใใฎๆฌใๆใซใจใฃใฆใใใ ใใใใใจใใใใใพใใ
็ฎๆจ่จญๅฎใฎๆ่กใจใใใฟใคใใซใฎๆฌๆธใงใใใ้่ฆใชๆ่กใงใใใใฎใฎใใฉใใใๅฝขใซใพใจใพใใไธๅฎใใชใใฃใใใใงใฏใใใพใใใๅไบบใฎไฝ้จใซไพๅญใใใใใใใใณใใคใณใใใใใใใใใใฏใใฟใ้ใพใใชใใฎใงใฏใชใใ๏ผ็ตๆใจใใฆใฏๅ
จใใฎๆๆใ ใฃใใใใงใใใๆนๆณ่ซใจใใฆๆฎ้ๅใปไธ่ฌๅใใใๆ่กใๅฎไฝ้จใ็ซฏ็ทใซๅฎ่ทต็ใซใพใจใพใฃใๆ่กใ้ใพใใพใใใ
ไปๅใใใใใใฎๅท็ญ่
ใฎ็ใใใซใๅๅใใใ ใใพใใใใใใใจใใใใใพใใใใใใใซ็ฐใชใฃใ่ฆ็นใ็ฐใชใฃใใทใใฅใจใผใทใงใณใซๅฏพใใไธใคใฎ่งฃใไพใจใใฆๅ่ใซใชใ่จไบใฐใใใงใใใใใใใ่ชญใฟๅฟใใใใใๆ กๆญฃใใชใใใใชใใปใฉใชใใปใฉใใจใใชใใใทใผใณใๅคใใๆฅฝใใ็ทจ้ใงใใพใใใ
็ฎๆจ่จญๅฎใใฟใคใ ใใใธใกใณใใชใฉใไธใฎไธญใซใใใใใใฎๆฌใๅญๅจใใพใใใWebใใปใใใผใชใฉใใใพใใพใชๅชไฝใงๅใไธใใใใใใจใๅคใใงใใใใๆงใ
ใชๆนๆณใใใใ ใใซใใใใใ้ท็ญใใใงใใใใใๆนๆณใจใใฆ่ชๅใซๅใๅใใชใใฏใใใจๆใใพใใใใใใๆๅณใงใใชใ ใใใน็ใซใฏใชใใพใใ่่
ใใใใใฎๅฎไฝ้จใซๅบใฅใใฆๅฎ่กใใฆใใๆนๆณใใจใใใใใใจใงใๅฐใ่บซ่ฟใซๆใใใใใฎใงใฏใชใใงใใใใ๏ผ
ๆงใ
ใชๆนๆณใใทใใฅใจใผใทใงใณใใจใฎๆนๆณใใใใพใใใชใซใใฒใจใคใงใใใใใใๆนๆณใใใใ่ชญใใงใใฃใฆใฟใฆใใใฃใใใจๆใฃใฆใใใ ใใใฐๅนธใใงใใ
ใใฆใ่กจ็ดใฏไปๅใๆนๅทใใ@llminatollใใใซใ้กใใใพใใใๆฌๆธใซๅ
็ซใคไฝ้จ็ใซใใใฆใฏใใใใใจใใฎใคใฉในใใไฝฟใฃใ่กจ็ดใงใใใใใฏใณในใใใใกใใใซใใ็ด ๆตใช่กจ็ดใซ็ใพใๅคใใใพใใใ่่
็ดนไปใซใๆธใใฆใใใ ใใฆใใพใใใ่ฃ่กจ็ดๅดใซๅฑฑใใใไธใคไฝใใใใใซใๆใ็ซใฆใฆใใดใผใซใฏไธใคใใใชใใใใจใใๅฝขใงไปไธใใฆใใใ ใใพใใใ
ใใฎๆฌใฏใๆ็ต็ใซใ36็ซ ใ160ใใผใธใฎๅใๆฌใซใชใใพใใใ่่
ใฏ26ไบบใๆฐใใๅๅ่ชใจใใฆใใ้ๅปๆ้ซใฎไบบๆฐใงใใญใๆนใใฆใๅๅ ใใใ ใใพใใ่่
ใฎ็ๆงใใใใใจใใใใใพใใใไปๅใๅๅท็ญใจใใๆนใใใใฃใใใใพใใ่่
ใจใใฆใฎใฏใใใฎไธๆญฉใฎๅ ดใไฝใใใจใใงใใใใจใใใใใๆใฃใฆใใพใใ
่่
ใจใใฆไธๆญฉใ่ธใฟๅบใใใจใฏใๆฑบใใฆ้ฃใใใใจใงใฏใใใพใใใใใ ๆธใใใใจๆใ็ซใฆใฐใใใฎใงใใๆธใใใฟใฏไฝใงใใใใงใใใใ ่ชๅใฎไฝ้จใๆธใใ ใใงใๅๅใงใใใใใใใฏใ่่
ใๅฎ้ใซไฝ้จใใใใจใงใใใใๅคๅ้ใใใใใใชใใ้ญ้ใใๅฏ่ฝๆงใใใๅ
ๅฎนใงใใ
่ฆชๆนProjectใงใฏใใใพใใพใชใใผใใซใคใใฆใฎๅๅ่ชใไผ็ปใๅท็ญใ็บ่กใใฆใใพใใใใฎๆฌใ่ชญใใงใๆฌใๆธใใฆใฟใใใจๆใฃใใใใฎใใชใใใใฒๆฌใๆธใใฆใฟใพใใใใใใใชใๅ่ใใตใผใฏใซไธปใฏใใผใใซ้ซใใใใจใ่ใใงใใใใๅๅ่ชใธใฎๅฏ็จฟใใๅงใใฆใฟใพใใใ๏ผ1็ซ ใซๅ่ใจใใฆใใฎๅๅ่ชใฎๅท็ญ่ฆ้ ใ่จ่ผใใฆใใพใใไปใฎ็ดฐใใ/ๅคงๅคใชใจใใใฏใใกใใงใใใพใใฎใงใๆฌๆใๆธใใ ใใง่่
ใจใใฆใฎไธๆญฉใ่ธใฟๅบใใพใใใใชใใฎๅๅ ใใๅพ
ใกใใฆใใใพใใ
ใใใงใฏใใพใๆฌกใฎๅๅ่ชใๆฌกใฎใคใใณใใงใไผใใใพใใใใ
//flushright{
2019ๅนด9ๆ
็ทจ้้ทใ่ฆชๆน๏ผ ่ฆชๆนProjectใๆ
//}
|
0f87dcf125d2798d90ad91205852e917122cf271
|
531e989a056f70f17a5d20164c5d998926aa2fee
|
/tests/testPendule.cc
|
c0d424441b4d72745cd4850e102d419f8a25341f
|
[] |
no_license
|
domzhaomathematics/pendulum
|
a1c68694c50d3f595c2df5737a9395f979c9d727
|
634056a159aea65fb1d0c8f2936718d2a7b18b6f
|
refs/heads/master
| 2020-09-14T05:52:47.456633
| 2019-11-20T23:15:36
| 2019-11-20T23:15:36
| 223,039,661
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 823
|
cc
|
testPendule.cc
|
#include <iostream>
#include <cmath>
#include "Vecteur.h"
#include "Oscillateur.h"
#include "Integrateur.h"
#include "Pendule.h"
#include "IntegrateurEuler.h"
#include "IntegrateurRK.h"
#include "Newmark.h"
using namespace std;
//puisque nous n'avons defini aucun support a dessin dans ces tests (on n'avait pas encore vu cela), ils ne compilent plus
int main()
{
Pendule P1(0.33, 0.25, 0.15, Vecteur(0, 1, 0), Vecteur(0, 0, 0));
P1.Vitesse(0);
P1.Parametre(Vecteur(0,P1.L(),0));
cout << P1 << endl;
IntegrateurEulerCromer in(0.01);
double t = 0;
while (t < 0.04) {
in.evolue(P1, t); // un object oscillateur , et le temps
t += 0.01;
cout << P1 << endl;
cout << (P1.Parametre()) << endl;
cout << (P1.Vitesse()) << endl;
cout << endl;
}
return 0;
}
|
0040c6152179fb29bf9889b112c8be6a8ead798b
|
e00047d43784e64cf31d15b0c3a6dd65ba771cb7
|
/CTCI/2-Concepts-and-Algorithms/8-Recursion-and-Dynamic-Programming/Gunjan/8-9-Parens.cpp
|
b5f24afa2d0f5e05a525ed2c55ed57512b10c921
|
[] |
no_license
|
swayamxd/noobmaster69
|
e49510f7c02c5323c0ac78d76bad2f31124f3b72
|
f549c365c4623e2ea17ca120d72c8488bfcfd8de
|
refs/heads/master
| 2022-01-16T13:04:14.666901
| 2022-01-12T11:55:06
| 2022-01-12T11:55:06
| 199,595,424
| 3
| 2
| null | 2020-12-01T04:18:11
| 2019-07-30T07:07:52
|
C++
|
UTF-8
|
C++
| false
| false
| 2,054
|
cpp
|
8-9-Parens.cpp
|
#include<iostream>
#include<vector>
#include<unordered_set>
using namespace std;
void display(vector<string> parenthesis){
for(auto x:parenthesis){
cout << x << endl;
}
cout << "Size: " << parenthesis.size() << endl;
}
void display(unordered_set<string> parenthesis){
for(auto x:parenthesis){
cout << x << endl;
}
cout << "Size: " << parenthesis.size() << endl;
}
void generateString (int index, int leftParenCount, int rightParenCount,
vector<string>& permutations, string validString) {
// when either leftParenCount<0 or rightParenCount<leftParenCount
// that means it's invalid state, return
if(leftParenCount<0 || rightParenCount<leftParenCount) return;
// when all parenthesis are used, push back the string to list and return
if(leftParenCount==0 && rightParenCount==0){
permutations.push_back(validString);
return;
} else {
// left recurse
validString[index] = '(';
generateString(index+1,leftParenCount-1,rightParenCount,permutations,validString);
// right recurse
validString[index] = ')';
generateString(index+1,leftParenCount,rightParenCount-1,permutations,validString);
}
}
vector<string> generateString(int pairCount){
vector<string> permutations;
string validString;
validString.resize(pairCount*2);
generateString(0,pairCount,pairCount,permutations,validString);
return permutations;
}
/*
// lots of duplicate calls are made
unordered_set<string> generateString(int pairCount){
unordered_set<string> parenthesis;
if(pairCount == 1){
parenthesis.insert("()");
return parenthesis;
}
unordered_set<string> intermediate = generateString(pairCount-1);
for(string x:intermediate){
for (int i=0;i<pairCount;i++){
parenthesis.insert(x.substr(0,i)+"()"+x.substr(i,x.length()));
}
}
return parenthesis;
}
*/
int main(){
int pairCount = 3;
display(generateString(pairCount));
return 0;
}
|
a20f2193b17c5333b82d834f692d262b33ab2a97
|
6b91ea73a53de75224cd775e7e902c9dbbd2bac2
|
/BOJ/NO.1012/bfs.cpp
|
d741da16ce0462b3dcb32ad760a6d68b58f12930
|
[] |
no_license
|
vvega-a/algorithm_study
|
d823fb05e3fd59c060a85a7ce29e436b5cafcae8
|
4f0cc828bb33e55a8250b67fee7ece9d84cc46b3
|
refs/heads/master
| 2023-02-23T23:51:43.228244
| 2019-11-27T10:35:04
| 2019-11-27T10:35:04
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,220
|
cpp
|
bfs.cpp
|
//https://www.acmicpc.net/problem/1012
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
using namespace std;
int n, m, k;
int res = 0;
int map[52][52];
bool visit[52][52];
int dx[4] = { 0,0,1,-1 };
int dy[4] = { 1,-1,0,0 };
typedef struct point
{
int x, y;
}p;
void bfs(p start)
{
queue<p> q;
q.push(start);
visit[start.x][start.y] = true;
map[start.x][start.y] = 0;
while (!q.empty())
{
p start = q.front();
q.pop();
for (int i = 0; i < 4; i++)
{
p next = { start.x + dx[i],start.y + dy[i] };
if (visit[next.x][next.y] == false && map[next.x][next.y] == 1)
{
q.push(next);
map[next.x][next.y] = 0;
visit[next.x][next.y] = true;
}
}
}
res++;
}
void ans()
{
for (int i = 1; i <= n; i++)
{
for (int j = 1; j <= m; j++)
{
if (map[i][j] == 1)
bfs({ i,j });
}
}
cout << res << endl;
}
int main()
{
int t;
cin >> t;
while (t--)
{
//์ด๊ธฐํ
for (int i = 0; i <52; i++)
{
for (int j = 0; j <52; j++)
{
map[i][j] = 0;
visit[i][j] = false;
}
}
res = 0;
//์
๋ ฅ
cin >> m >> n >> k;
while (k--)
{
int x, y;
cin >> x>> y;
map[y+1][x+1] = 1;
}
//ํด๊ฒฐ
ans();
}
return 0;
}
|
c87ea275e94f6ababb846f41ba361a07ca95976f
|
ef448a74eb1aeee002fb58b31061d074f7cd0ec3
|
/is mirror Inverse.cpp
|
0145e19f177faaa135cfb790b97767a8ae90cd85
|
[] |
no_license
|
RushilKhantwal/Algo-Codes
|
68c2c275a4b1de1d7307b73bab91ee606b681497
|
d2b93c02573426f5d6a7515920b3340817d1cdbc
|
refs/heads/master
| 2022-11-20T19:43:56.439640
| 2020-07-19T21:45:28
| 2020-07-19T21:45:28
| 264,461,881
| 3
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 532
|
cpp
|
is mirror Inverse.cpp
|
#include<bits/stdc++.h>
using namespace std;
long long inverse( long long n)
{
int j=0;
int i=0;
long long inv=0;
while(n != 0)
{
++j;
i=(n%10) - 1;
inv += ((pow(10,i))*j);
n /= 10;
}
return inv;
}
int main()
{
long long n;
cin>>n;
long long res = inverse(n);
if( res == n)
cout<<"true";
else
cout<<"false";
return 0;
}
|
38726b5df6cdcccaf364cb210fb2448765ca1826
|
e0bbca1766ffe1279bbf00a300769c9a41fe9e9c
|
/Codeforces451/B.cpp
|
88a8ee34691efffe5540c5f18191fc3706830de8
|
[] |
no_license
|
srijan-srivastav/Competitive-programming-contests
|
a86d83132d142e4c6b903b747dffda23a77eb509
|
0ffb16e037c352fa3c8c0048d67dd52017180133
|
refs/heads/master
| 2020-03-19T14:40:53.278591
| 2018-06-09T03:35:11
| 2018-06-09T03:35:11
| 136,635,044
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,048
|
cpp
|
B.cpp
|
#include <bits/stdc++.h>
using namespace std;
int main()
{
int money;
int a;
int b;
cin>>money>>a>>b;
int min=0;
int max=0;
if(a>b)
{
min=b;
max=a;
}
else
{
min=a;
max=b;
}
int countm=0;
int countl=0;
while(1)
{
money=money-min;
countm++;
if(money<0)
{
money=money+min;
countm--;
break;
}
}
if(money==0)
{
if(min==a)
{
cout<<"YES"<<endl;
cout<<countm<<" "<<countl<<endl;
}
else
{
cout<<"YES"<<endl;
cout<<countl<<" "<<countm<<endl;
}
}
else
{
int flag=0;
while(countm!=0)
{
money=money+min;
countm--;
if(money>=max)
{
money=money-max;
countl++;
if(money==0)
{
flag=1;
if(min==a)
{
cout<<"YES"<<endl;
cout<<countm<<" "<<countl<<endl;
}
else
{
cout<<"YES"<<endl;
cout<<countl<<" "<<countm<<endl;
}
break;
}
}
}
if(flag==0)
cout<<"NO"<<endl;
}
}
|
677394db3361bdcfae14a8aa29ee45305e19c296
|
813bb036c810b7b7e85d36d7827f3b09acccd627
|
/properties.h
|
80004cb4d3956cdaaa57da4671e3df1b98f00a7b
|
[] |
no_license
|
tort-dla-psa/qml-ui
|
28fe310228b2f431e28f222e6e9d1fd9e2e6f0e3
|
7f6858a45ccd386c7d984e3dd2e6dfc2f1a7c943
|
refs/heads/master
| 2022-07-24T03:12:24.587325
| 2020-05-26T01:36:29
| 2020-05-26T01:36:29
| 266,860,429
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 989
|
h
|
properties.h
|
#ifndef PROPERTIES_H
#define PROPERTIES_H
#include <QObject>
#include <QString>
#include <QVector>
struct Property{
QString text;
QString value;
friend bool operator == (const Property &lhs, const Property &rhs){
return lhs.text == rhs.text &&
lhs.value == rhs.value;
}
friend bool operator != (const Property &lhs, const Property &rhs){
return !(lhs == rhs);
}
};
class Properties : public QObject {
Q_OBJECT
QVector<Property> props;
public:
explicit Properties(QObject *parent = nullptr);
~Properties();
const decltype(props)& items()const;
bool addItem(unsigned index, const Property &prop);
size_t size()const;
signals:
void prop_changed(Property);
void pre_append();
void post_append();
void pre_remove(unsigned);
void post_remove();
public slots:
void addItem(const Property &prop);
void addItem();
void remove(const Property &prop);
};
#endif // PROPERTIES_H
|
edda49df86856fa82a4004155c3d7ef0b18dec0e
|
5eaa7f7ad83ae6c2e6167c87fa093a0668058d23
|
/QVtdEditor/qscrollareaex.h
|
38d07786708bf1d92ac809315876a235e5ac3e11
|
[] |
no_license
|
cadencii/vConnect
|
5597e5a23edddb0ef0a3ce22a042942dd3e8c296
|
dfe260623bae88fcfd90a25def2bfd1ffb2dbd18
|
refs/heads/master
| 2021-01-20T11:30:17.124806
| 2013-10-02T14:20:26
| 2013-10-02T14:20:26
| 12,994,261
| 7
| 1
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 872
|
h
|
qscrollareaex.h
|
/**
* qscrollareaex.h
* Copyright (C) 2010 kbinani
*
* This file is part of QVtdEditor.
*
* QVtdEditor is free software; you can redistribute it and/or
* modify it under the terms of the GNU GPL License.
*
* QVtdEditor 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.
*/
#ifndef QSCROLLAREAEX_H
#define QSCROLLAREAEX_H
#include <QScrollArea>
/**
* ใตใคใบๅคๆดๆใซใทใฐใใซใ้ใใใจใฎๅบๆฅใQScrollArea
*/
class QScrollAreaEx : public QScrollArea{
Q_OBJECT
public:
explicit QScrollAreaEx(QWidget *parent = 0);
protected:
void resizeEvent( QResizeEvent *e );
signals:
/**
* ใตใคใบใๅคๆดใใใใจใใซ็บ็ใใใทใฐใใซ
*/
void onResize();
};
#endif // QSCROLLAREAEX_H
|
a5463bf93047bedc655417f32064728192387dc6
|
4e8a440699ad4dfca23ea7bc4f8727c91e506220
|
/Bitmap/Bitmap/main.cpp
|
7209da4ad91b8b4b8a467cfc920601b11af4eee0
|
[] |
no_license
|
Wolfgangwgb/Code
|
3f3910e3298fcea8d768197c53d2c52337bb007f
|
352b4c3f39ac44ed163262cf047836714ac0aa93
|
refs/heads/master
| 2021-01-22T10:46:04.262041
| 2017-09-13T13:23:57
| 2017-09-13T13:23:57
| 92,653,587
| 1
| 1
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,286
|
cpp
|
main.cpp
|
#include<iostream>
using namespace std;
#include<string>
#include"bitmap.h"
#include"bloom_filter.h"
void Test()
{
Bitmap b(2048);
size_t arr[] = { 31, 32, 6, 34, 76, 954, 23, 42, 57, 12 };
for (size_t i = 0; i < sizeof(arr) / sizeof(arr[0]); ++i)
{
b.Set(arr[i]);
}
if (b.Exist(34))
std::cout << "YES" << std::endl;
else
std::cout << "NO" << std::endl;
b.Reset(34);
if (b.Exist(34))
std::cout << "YES" << std::endl;
else
std::cout << "NO" << std::endl;
if (b.Exist(0))
std::cout << "YES" << std::endl;
else
std::cout << "NO" << std::endl;
}
//void Ring_right_shift(char p[], int k,int n)
//{
// if (0 == k || n == 0)
// return;
// while (k--)
// {
// char ret = p[n-1];
// for (int i = n - 1; i >= 0; --i)
// {
// p[i+1] = p[i];
// }
// p[0] = ret;
// }
//}
void Test_Bloom()
{
string str("hello");
string str1("ello");
Bloom_Filter<string> bf(1024);
bf.Set(str);
if (bf.Exist_bloom(str))
cout << "Yes" << endl;
else
cout << "No" << endl;
if (bf.Exist_bloom(str1))
cout << "Yes" << endl;
else
cout << "No" << endl;
}
int main()
{
//char p[] = { 'a', 'b', 'c', 'd', 'e','f','g','h','i'};
//Ring_right_shift(p,3,sizeof(p)/sizeof(p[0]));
//Ring_right_shift(p, 6, sizeof(p) / sizeof(p[0]));
//Test();
Test_Bloom();
return 0;
}
|
0c9d824e9c3b2a4d17c97ba6ef95693bf76ac1ab
|
aea7799cdf8ecb7b9304c8898767e91949f71d4b
|
/round1/reverse-linked-list-2.cpp
|
48c8b70a0a7b495e2c13d8a11fb39734b3b0ab8d
|
[] |
no_license
|
elsucai/LC
|
e2baab13168761519ae537176e42fa04607de88a
|
d5915a4efb6e16e2cea5f8d448ca72c2f8edcc9b
|
refs/heads/master
| 2016-09-08T02:05:30.401990
| 2014-04-01T22:50:23
| 2014-04-01T22:50:23
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 778
|
cpp
|
reverse-linked-list-2.cpp
|
/**
* Definition for singly-linked list.
* struct ListNode {
* int val;
* ListNode *next;
* ListNode(int x) : val(x), next(NULL) {}
* };
*/
class Solution {
public:
ListNode *reverseBetween(ListNode *head, int m, int n) {
// Start typing your C/C++ solution below
// DO NOT write int main() function
if(!head)
return NULL;
ListNode *next, *newtail, *pre, *s, *tmp;
pre = NULL;
tmp = NULL;
s = head;
int i;
for(i = 1; i <= m-1; i++){
tmp = s;
s = s->next;
}
newtail = s;
for(i = 1; i <= n-m+1; i++){
next = s->next;
s->next = pre;
pre = s;
s = next;
}
// s is the beginning of the rest list
if(!tmp)
head = pre;
else
tmp->next = pre;
newtail->next = s;
return head;
}
};
|
9f401977b8b373c4b8e383c315adb7d022cdf628
|
d81bf03ac0da3e356d464059cb6d71021e8583ef
|
/StringOperator.h
|
905ad026e3cdafd292d00472f86253aa047fac8a
|
[] |
no_license
|
Karl0007/TASK2-mysql
|
f968ad7217ad05847f8138350eaf4f34eea82577
|
f5b49213f6bd22eb1991bba7ca1701b3399595a9
|
refs/heads/master
| 2020-05-09T13:54:52.050658
| 2019-04-13T12:48:08
| 2019-04-13T12:48:08
| 181,173,492
| 3
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 689
|
h
|
StringOperator.h
|
#pragma once
#include <bits/stdc++.h>
using std::string;
using std::vector;
namespace My
{
extern vector<string> Split(const string &, const char &, const string &bef = "");
extern int StrToUInt(string const &);
extern string UIntToStr(int);
extern vector<string> CutBetween(const string &str, const char left, const char right);
extern string Replace(const string &str, const char a, const string &b);
extern string MergeVec(const vector<string> &strs, const string &split = "\t", const string &end = "\n");
template <class T>
extern int posInVec(const vector<T> &vec, T x)
{
int pos = 0;
for (auto i : vec)
{
if (i == x)
{
return pos;
}
pos++;
}
}
} // namespace My
|
3eee50ba2b0b7d11d2db5305c0006552dcf30a12
|
914a4d60f79b0b96a4440979e1fd6ded5f7bc668
|
/2DPatternSearch/PatternSearch.cpp
|
d95e839054bbd5216b583e0ccb55bf0d7b006549
|
[] |
no_license
|
marcinwasowicz/Text-Algorithms
|
9772fddb924685772dceb5b87dab7b9ee1754ce8
|
66ade82efec434c78e09464236af2ec4d33202d2
|
refs/heads/master
| 2021-05-19T07:03:06.107565
| 2020-09-27T16:09:18
| 2020-09-27T16:09:18
| 251,577,146
| 1
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 2,143
|
cpp
|
PatternSearch.cpp
|
#include "PatternSearch.h"
#include <algorithm>
using namespace std;
PatternSearch::PatternSearch(vector<string>& pattern, string &alphabet) {
this->automaton = new Automaton(pattern, alphabet);
}
vector<int> PatternSearch::parseLine(vector<int> &line) {
// pass line of states thorugh final states automaton, and store every index at which we got into accepting state
vector<int> result;
vector<int> finalStates = this->automaton->getFinalStates();
unordered_map<int, vector<int>> machine = this->automaton->getFinalStatesAutomaton();
int numOfStates = finalStates.size();
int state = 0;
for(int i = 0; i<line.size(); i++){
if(machine.find(line[i]) == machine.end()){
state = 0;
continue;
}
state = machine[line[i]][state];
if(state == numOfStates){
result.push_back(i);
}
}
return result;
}
vector<pair<int, vector<int>>> PatternSearch::findPattern(vector<string> &text) {
// pass each column of text through automaton, and store automaton state after reading each letter
vector<pair<int,vector<int>>> result;
int len = 0;
vector<vector<int>> automatonOutput;
for(auto word : text){
len = max(len, (int)word.length());
automatonOutput.push_back({});
}
for(int i = 0; i<len; i++){
for(int j = 0; j<text.size(); j++){
if(i<text[j].length()){
automatonOutput[j].push_back(this->automaton->readChar(text[j][i]));
}
}
this->automaton->rollBack();
}
// apply final state automaton for each line of aho corasick automaton output,
// and for each line store indexes at which final state automaton got into final state
// ( we will not store information about lines whose parseLine method output is empty)
for(int i = 0; i<automatonOutput.size(); i++){
vector<int> temp = this->parseLine(automatonOutput[i]);
if(temp.size()!=0){
result.push_back(make_pair(i, temp));
}
}
return result;
}
PatternSearch::~PatternSearch() {
delete this->automaton;
}
|
9d2c0f5dc242eaec7058b0b5c78df48cdc281cdf
|
890eb8e28dab8463138d6ae80359c80c4cf03ddd
|
/SMPF/Protocol/Channel/HAL/MODEM/CmdHdlr/NR/RF_BLOCK/ch_HalRfExtCmdsNr.cpp
|
e730d4e1b3bd5080910d5a9bcbc1f4866ec542c8
|
[] |
no_license
|
grant-h/shannon_S5123
|
d8c8dd1a2b49a9fe08268487b0af70ec3a19a5b2
|
8f7acbfdcf198779ed2734635990b36974657b7b
|
refs/heads/master
| 2022-06-17T05:43:03.224087
| 2020-05-06T15:39:39
| 2020-05-06T15:39:39
| 261,804,799
| 7
| 1
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 88
|
cpp
|
ch_HalRfExtCmdsNr.cpp
|
Line 62: FreqSetCmd: Wrong RAT Type(%d)!!
Line 207: [AS] AsEnableCmd(%d) resultEn(%d)!!
|
114d316e2fe70cb5f0c6f36197760f689c22fbe8
|
9b6c8262a81d94bdf4e386c5790b6cabbc544d3a
|
/Single tries/1A.cpp
|
e2d9716cc0927c4561612997d8d30332d1471d08
|
[] |
no_license
|
SeefatHimel/CodeForces
|
e5ce762a12b13fb45dd665697cd634e26151c87f
|
e0a5a25b5125595de92a1ec4549242728ef50337
|
refs/heads/main
| 2023-05-15T16:30:39.607778
| 2021-06-13T21:04:36
| 2021-06-13T21:04:36
| 372,318,996
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 186
|
cpp
|
1A.cpp
|
#include<iostream>
using namespace std;
main()
{
long long int a,b,m,c,d,s;
cin>>a>>b>>m;
c=a/m;
d=b/m;
if(a%m!=0)c++;
if(b%m!=0)d++;
s=c*d;
cout<<s;
}
|
be21b25e32f1898df1a7ab7b878c8d025511ae71
|
7ec4ce13fe476404a1769d9958dc41bef48661bc
|
/2019็งๆITๅ
ฌๅธ้ข่ฏ้ข/็พๅข/01.cpp
|
308f424615655a5fcf0a6c3d50cf0376909caa25
|
[] |
no_license
|
meihao1203/learning
|
45679e1b0912b62f7a6ef1999fb2a374733f5926
|
dbef1a1b6ccb704c53b2439661d062eb69060a0d
|
refs/heads/master
| 2021-07-19T23:36:50.602595
| 2018-12-09T02:03:06
| 2018-12-09T02:03:06
| 113,955,622
| 11
| 4
| null | null | null | null |
GB18030
|
C++
| false
| false
| 967
|
cpp
|
01.cpp
|
#include<iostream>
#include<set>
using namespace std;
static int total = 0;
static set<int> everyNode;
void travesal(int** arr,bool* visited,int nodes,int visit);
int main()
{
int nodes;
cin>>nodes;
//ๅผ่พๆฐ็ป็ฉบ้ด
int** arr = new int*[nodes];
for(int idx=0;idx!=nodes;++idx)
{
arr[idx] = new int[nodes];
}
//่ฏปๅ
ฅๆฐๆฎ
for(int idx=0;idx<nodes-1;++idx)
{
int first,second;
cin>>first>>second;
arr[first-1][second-1] = 1;
}
bool* visited = new bool[nodes];
for(int idx=0;idx!=nodes;++idx)
{
visited[idx] = false;
}
travesal(arr,visited,nodes,0);
cout<<total+1<<endl;
system("pause");
}
void travesal(int** arr,bool* visited,int nodes,int visit)
{
if(everyNode.size()==nodes)
return ;
visited[visit] = true;
for(int idx=1;idx<nodes;++idx)
{
if(visited[idx]==false &&
arr[visit][idx]==1)
{
everyNode.insert(idx);
travesal(arr,visited,nodes,idx);
++total;
}
}
}
|
1ec75cfd57107f6526116a544285bff0dcd0e782
|
25a107f9cab4ddedf457c355299f0078697506ad
|
/AppData/Local/Autodesk/webdeploy/production/1f559bb8ae333199306b5c4f1fe680c6eb7ab9e0/CPP/include/Fusion/Fusion/SMTExportOptions.h
|
5b0947884129280713e508fc2ae041b3f16105f8
|
[] |
no_license
|
Park-Minjoo/HCI_TeamProject_GroupNo2
|
1b6cc7887173f717ba76068472174cc3a9109124
|
5ace0f0a9d81b39d6782300a14847b223d7ed90a
|
refs/heads/master
| 2023-01-27T11:59:36.791453
| 2023-01-13T04:26:18
| 2023-01-13T04:26:18
| 273,715,196
| 1
| 0
| null | 2023-01-13T04:26:26
| 2020-06-20T13:39:33
| null |
UTF-8
|
C++
| false
| false
| 2,218
|
h
|
SMTExportOptions.h
|
//////////////////////////////////////////////////////////////////////////////
//
// Copyright 2016 Autodesk, Inc. All rights reserved.
//
// Use of this software is subject to the terms of the Autodesk license
// agreement provided at the time of installation or download, or which
// otherwise accompanies this software.
//
//////////////////////////////////////////////////////////////////////////////
#pragma once
#include "ExportOptions.h"
// THIS CLASS WILL BE VISIBLE TO AN API CLIENT.
// THIS HEADER FILE WILL BE GENERATED FROM NIDL.
#include "../../Core/OSMacros.h"
#ifdef FUSIONXINTERFACE_EXPORTS
# ifdef __COMPILING_ADSK_FUSION_SMTEXPORTOPTIONS_CPP__
# define ADSK_FUSION_SMTEXPORTOPTIONS_API XI_EXPORT
# else
# define ADSK_FUSION_SMTEXPORTOPTIONS_API
# endif
#else
# define ADSK_FUSION_SMTEXPORTOPTIONS_API XI_IMPORT
#endif
namespace adsk { namespace fusion {
/// Defines that an SMT export is to be done and specifies the various options.
class SMTExportOptions : public ExportOptions {
public:
/// Gets and set the version of the SMT format to write to. The default
/// is to use the current version of the Autodesk Shape Manager kernel
/// that Fusion 360 is using. Specifying an invalid version will result
/// in an assert.
/// Valid versions are 218 up to the current version, which is what this
/// property returns by default when a new SMTExportOptions object is
/// created.
int version() const;
bool version(int value);
ADSK_FUSION_SMTEXPORTOPTIONS_API static const char* classType();
ADSK_FUSION_SMTEXPORTOPTIONS_API const char* objectType() const override;
ADSK_FUSION_SMTEXPORTOPTIONS_API void* queryInterface(const char* id) const override;
ADSK_FUSION_SMTEXPORTOPTIONS_API static const char* interfaceId() { return classType(); }
private:
// Raw interface
virtual int version_raw() const = 0;
virtual bool version_raw(int value) = 0;
};
// Inline wrappers
inline int SMTExportOptions::version() const
{
int res = version_raw();
return res;
}
inline bool SMTExportOptions::version(int value)
{
return version_raw(value);
}
}// namespace fusion
}// namespace adsk
#undef ADSK_FUSION_SMTEXPORTOPTIONS_API
|
acf3827b8aef674a664993955eb6d2a1b2bb8755
|
71cd5b6943b3b4a7107cced43e68cd79ec3f7c4d
|
/SampleFramework/DirectGame/WindowsProject1/TilesetInfo.h
|
9a33fc27361b54c871a36277dba9e81f58a2e808
|
[] |
no_license
|
nlebachnlb/mario-directx
|
57fd8dacb7999c5caea68ac8a3c9afb8aea74fdf
|
abc84b676d02c136d77cd88398f9680abb79c328
|
refs/heads/main
| 2023-02-24T19:40:26.863310
| 2021-01-22T16:58:54
| 2021-01-22T16:58:54
| 307,131,400
| 10
| 1
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 402
|
h
|
TilesetInfo.h
|
#pragma once
#include <string>
#include "tinyxml.h"
class TilesetInfo
{
public:
TilesetInfo();
TilesetInfo(int id, int tileCount, std::string source);
static TilesetInfo* FromXMLData(TiXmlElement* data);
std::string GetSource();
int GetID();
int GetTileCount();
int GetImageWidth();
int GetImageHeight();
private:
int id;
std::string source;
int tileCount;
int imgWidth, imgHeight;
};
|
db8cf3f44920e93c53d56a20510d984423c826ba
|
2394a717ba6dd2ab9a7822d2eb8093d0a5194f6b
|
/01. Dynamic Arrays & String/5 [codeforces] A. Vitaly and Strings_explain.cpp
|
09fc642959028e8f1618e5fd74e49443fc1956b5
|
[] |
no_license
|
ngtranminhtuan/Algorithm-Immediately
|
8ce292141c206631ac649ff1b396569cd8226e9c
|
f174a7de1448683d4f70ebde3dfe6f667ca863af
|
refs/heads/master
| 2021-12-12T13:39:02.363221
| 2021-11-19T04:33:03
| 2021-11-19T04:33:03
| 200,312,777
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,353
|
cpp
|
5 [codeforces] A. Vitaly and Strings_explain.cpp
|
/*
- Chแบกy ngฦฐแปฃc chuแปi S tแปซ kรฝ tแปฑ cuแปi vแป kรฝ tแปฑ ฤแบงu, xรฉt hai trฦฐแปng hแปฃp sau:
+ Nแบฟu gแบทp kรฝ tแปฑ โzโ thรฌ biแบฟn kรฝ tแปฑ nร y thร nh kรฝ tแปฑ โaโ.
+ Nแบฟu gแบทp kรฝ tแปฑ khรกc โzโ thรฌ tฤng kรฝ tแปฑ nร y lรชn mแปt bแบญc,
nghฤฉa lร nแบฟu gแบทp kรฝ tแปฑ โbโ thรฌ biแบฟn thร nh โcโ,
kรฝ tแปฑ lร โgโ thรฌ biแบฟn thร nh โhโ. Ngay sau tฤng kรฝ tแปฑ lรชn mแปt bแบญc
thรฌ dแปซng vรฒng lแบทp.
- Sau khi biแบฟn ฤแปi xong hรฃy so sรกnh giแปฏa chuแปi kแบฟt quแบฃ vร T,
nแบฟu chuแปi kแบฟt quแบฃ khรกc chuแปi T (nghฤฉa lร chuแปi nhแป hฦกn T) thรฌ in ra chuแปi
kแบฟt quแบฃ, ngฦฐแปฃc lแบกi in โNo such stringโ.
ฤแป phแปฉc tแบกp: O(N) vแปi N lร ฤแป dร i cแปงa 2 chuแปi.
*/
#include <iostream>
#include <string>
using namespace std;
int main() {
string s, t;
cin >> s >> t;
for (int i = s.size() - 1; i >= 0; i--) {
if (s[i] == 'z') {
s[i] = 'a';
}
else {
s[i]++;
break;
}
}
cout << (s == t ? "No such string" : s);
return 0;
}
// Python
s = list(input())
t = list(input())
for i in range(len(s) - 1, -1, -1):
if s[i] == 'z':
s[i] = 'a'
else:
s[i] = chr(ord(s[i]) + 1)
break
print(''.join(s) if s != t else "No such string")
|
798a1d0e34022cf5e2850e62abc08d153d7b46da
|
6df461fa311c892a968c2d3d9e15fd2225ce5e46
|
/database.h
|
a0fb298b3dd439d79c34eef98217ee73a60a1c27
|
[] |
no_license
|
kamilmaestro/Communicator_GUI
|
8347f85cba1a710e11cfc53eb2fa312de22e5f71
|
514100636f49d575ea2c031202862cf5a0049cbb
|
refs/heads/master
| 2020-05-19T08:57:46.943611
| 2019-06-14T19:26:02
| 2019-06-14T19:26:02
| 184,935,315
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 289
|
h
|
database.h
|
#ifndef DATABASE_H
#define DATABASE_H
#include <QSqlDatabase>
#include <QSqlQuery>
#include <QSqlError>
namespace database {
QSqlDatabase &connect();
QSqlQuery &getMessages(int id1, int id2);
int getId(QString login);
int getId(QString login, QString password);
}
#endif // DATABASE_H
|
e95c5d289c5d8b539e3460b9cf20e1bf3219f68a
|
64a41423f567fe8973f57e26910cf1bb2f41b540
|
/uva/uva10298_Power_Strings/cpp/main.cpp
|
8b2d560ee5b0e26af360a5c6bd915db5dcafaa74
|
[] |
no_license
|
lfmunoz/competitive_programming
|
1d16b64d4b90214a0745da1460420361a7771f52
|
cf6a90c780b422f4b4c0bdcaa7e9a1bcb4f50ad5
|
refs/heads/master
| 2023-01-24T18:15:01.234165
| 2020-11-23T02:43:19
| 2020-11-23T02:43:19
| 283,283,319
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 2,344
|
cpp
|
main.cpp
|
/*
https://www.udebug.com/UVa/10298
It was very tempting to be clever with this problem, meaing that
I wanted to find a way to detect when a pattern repeated, something
similar to what kmpPreprocess does. Forget that just
check each possibility starting from 1.
*/
// ________________________________________________________________________________
// INCLUDE
// ________________________________________________________________________________
#include <bits/stdc++.h>
typedef unsigned int uint;
using namespace std;
// ________________________________________________________________________________
// GLOBAL
// ________________________________________________________________________________
// ________________________________________________________________________________
// HELPER METHODS
// ________________________________________________________________________________
void initialize()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
#ifdef DEFAULT
// freopen("input.txt", "r", stdin);
// freopen("default.txt", "r", stdin);
#endif
std::cout << std::fixed;
std::cout << std::setprecision(2);
}
// ________________________________________________________________________________
// SOLUTION
// ________________________________________________________________________________
bool isValid(const string &line, int size) {
string match = line.substr(0, size);
for (int i = 0; i < line.size(); i += size) {
string compare = line.substr(i, size);
if (compare != match) {
return false;
}
}
return true;
}
// ________________________________________________________________________________
// MAIN
// ________________________________________________________________________________
string START_END = ".";
#if !defined(IS_TEST)
int main() {
initialize();
string line;
while (true) {
getline(cin, line);
if (line.compare(START_END) == 0) break;
int size = 1;
while (true) {
if (line.size() % size != 0) {
size += 1;
continue;
}
if(isValid(line, size)) {
cout << line.size() / size << "\n";
break;
}
size +=1;
}
}
return 0;
}
#endif
|
6c22b03d86bb828bd263681e617a848e5f8f04c8
|
2f6a9ff787b9eb2ababc9bb39e15f1349fefa3d2
|
/inet/src/inet/physicallayer/ieee80211/mode/Ieee80211ErpOfdmMode.cc
|
3375092b514056fca887e79effecc79d9b01349f
|
[
"BSD-3-Clause",
"MPL-2.0",
"LicenseRef-scancode-free-unknown"
] |
permissive
|
ntanetani/quisp
|
97f9c2d0a8d3affbc709452e98c02c568f5fe8fd
|
47501a9e9adbd6adfb05a1c98624870b004799ea
|
refs/heads/master
| 2023-03-10T08:05:30.044698
| 2022-06-14T17:29:28
| 2022-06-14T17:29:28
| 247,196,429
| 0
| 1
|
BSD-3-Clause
| 2023-02-27T03:27:22
| 2020-03-14T02:16:19
|
C++
|
UTF-8
|
C++
| false
| false
| 5,711
|
cc
|
Ieee80211ErpOfdmMode.cc
|
//
// Copyright (C) 2015 OpenSim Ltd.
//
// This program 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 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU 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/>.
//
#include "inet/physicallayer/ieee80211/mode/Ieee80211ErpOfdmMode.h"
namespace inet {
namespace physicallayer {
Ieee80211ErpOfdmMode::Ieee80211ErpOfdmMode(const char *name, bool isErpOnly, const Ieee80211OfdmPreambleMode *preambleMode, const Ieee80211OfdmSignalMode *signalMode, const Ieee80211OfdmDataMode *dataMode) :
Ieee80211OfdmMode(name, preambleMode, signalMode, dataMode, MHz(20), MHz(20)), // review the channel spacing
isErpOnly(isErpOnly)
{
}
const Ieee80211ErpOfdmMode Ieee80211ErpOfdmCompliantModes::erpOfdmMode6Mbps("erpOfdmMode6Mbps", false, &Ieee80211OfdmCompliantModes::ofdmPreambleModeCS20MHz, &Ieee80211OfdmCompliantModes::ofdmHeaderMode6MbpsRate13, &Ieee80211OfdmCompliantModes::ofdmDataMode6MbpsCS20MHz);
const Ieee80211ErpOfdmMode Ieee80211ErpOfdmCompliantModes::erpOfdmMode9Mbps("erpOfdmMode9Mbps", false, &Ieee80211OfdmCompliantModes::ofdmPreambleModeCS20MHz, &Ieee80211OfdmCompliantModes::ofdmHeaderMode6MbpsRate15, &Ieee80211OfdmCompliantModes::ofdmDataMode9MbpsCS20MHz);
const Ieee80211ErpOfdmMode Ieee80211ErpOfdmCompliantModes::erpOfdmMode12Mbps("erpOfdmMode12Mbps", false, &Ieee80211OfdmCompliantModes::ofdmPreambleModeCS20MHz, &Ieee80211OfdmCompliantModes::ofdmHeaderMode6MbpsRate5, &Ieee80211OfdmCompliantModes::ofdmDataMode12MbpsCS20MHz);
const Ieee80211ErpOfdmMode Ieee80211ErpOfdmCompliantModes::erpOfdmMode18Mbps("erpOfdmMode18Mbps", false, &Ieee80211OfdmCompliantModes::ofdmPreambleModeCS20MHz, &Ieee80211OfdmCompliantModes::ofdmHeaderMode6MbpsRate7, &Ieee80211OfdmCompliantModes::ofdmDataMode18MbpsCS20MHz);
const Ieee80211ErpOfdmMode Ieee80211ErpOfdmCompliantModes::erpOfdmMode24Mbps("erpOfdmMode24Mbps", false, &Ieee80211OfdmCompliantModes::ofdmPreambleModeCS20MHz, &Ieee80211OfdmCompliantModes::ofdmHeaderMode6MbpsRate9, &Ieee80211OfdmCompliantModes::ofdmDataMode24MbpsCS20MHz);
const Ieee80211ErpOfdmMode Ieee80211ErpOfdmCompliantModes::erpOfdmMode36Mbps("erpOfdmMode36Mbps", false, &Ieee80211OfdmCompliantModes::ofdmPreambleModeCS20MHz, &Ieee80211OfdmCompliantModes::ofdmHeaderMode6MbpsRate11, &Ieee80211OfdmCompliantModes::ofdmDataMode36Mbps);
const Ieee80211ErpOfdmMode Ieee80211ErpOfdmCompliantModes::erpOfdmMode48Mbps("erpOfdmMode48Mbps", false, &Ieee80211OfdmCompliantModes::ofdmPreambleModeCS20MHz, &Ieee80211OfdmCompliantModes::ofdmHeaderMode6MbpsRate1, &Ieee80211OfdmCompliantModes::ofdmDataMode48Mbps);
const Ieee80211ErpOfdmMode Ieee80211ErpOfdmCompliantModes::erpOfdmMode54Mbps("erpOfdmMode54Mbps", false, &Ieee80211OfdmCompliantModes::ofdmPreambleModeCS20MHz, &Ieee80211OfdmCompliantModes::ofdmHeaderMode6MbpsRate3, &Ieee80211OfdmCompliantModes::ofdmDataMode54Mbps);
const Ieee80211ErpOfdmMode Ieee80211ErpOfdmCompliantModes::erpOnlyOfdmMode6Mbps("erpOnlyOfdmMode6Mbps", true, &Ieee80211OfdmCompliantModes::ofdmPreambleModeCS20MHz, &Ieee80211OfdmCompliantModes::ofdmHeaderMode6MbpsRate13, &Ieee80211OfdmCompliantModes::ofdmDataMode6MbpsCS20MHz);
const Ieee80211ErpOfdmMode Ieee80211ErpOfdmCompliantModes::erpOnlyOfdmMode9Mbps("erpOnlyOfdmMode9Mbps", true, &Ieee80211OfdmCompliantModes::ofdmPreambleModeCS20MHz, &Ieee80211OfdmCompliantModes::ofdmHeaderMode6MbpsRate15, &Ieee80211OfdmCompliantModes::ofdmDataMode9MbpsCS20MHz);
const Ieee80211ErpOfdmMode Ieee80211ErpOfdmCompliantModes::erpOnlyOfdmMode12Mbps("erpOnlyOfdmMode12Mbps", true, &Ieee80211OfdmCompliantModes::ofdmPreambleModeCS20MHz, &Ieee80211OfdmCompliantModes::ofdmHeaderMode6MbpsRate5, &Ieee80211OfdmCompliantModes::ofdmDataMode12MbpsCS20MHz);
const Ieee80211ErpOfdmMode Ieee80211ErpOfdmCompliantModes::erpOnlyOfdmMode18Mbps("erpOnlyOfdmMode18Mbps", true, &Ieee80211OfdmCompliantModes::ofdmPreambleModeCS20MHz, &Ieee80211OfdmCompliantModes::ofdmHeaderMode6MbpsRate7, &Ieee80211OfdmCompliantModes::ofdmDataMode18MbpsCS20MHz);
const Ieee80211ErpOfdmMode Ieee80211ErpOfdmCompliantModes::erpOnlyOfdmMode24Mbps("erpOnlyOfdmMode24Mbps", true, &Ieee80211OfdmCompliantModes::ofdmPreambleModeCS20MHz, &Ieee80211OfdmCompliantModes::ofdmHeaderMode6MbpsRate9, &Ieee80211OfdmCompliantModes::ofdmDataMode24MbpsCS20MHz);
const Ieee80211ErpOfdmMode Ieee80211ErpOfdmCompliantModes::erpOnlyOfdmMode36Mbps("erpOnlyOfdmMode36Mbps", true, &Ieee80211OfdmCompliantModes::ofdmPreambleModeCS20MHz, &Ieee80211OfdmCompliantModes::ofdmHeaderMode6MbpsRate11, &Ieee80211OfdmCompliantModes::ofdmDataMode36Mbps);
const Ieee80211ErpOfdmMode Ieee80211ErpOfdmCompliantModes::erpOnlyOfdmMode48Mbps("erpOnlyOfdmMode48Mbps", true, &Ieee80211OfdmCompliantModes::ofdmPreambleModeCS20MHz, &Ieee80211OfdmCompliantModes::ofdmHeaderMode6MbpsRate1, &Ieee80211OfdmCompliantModes::ofdmDataMode48Mbps);
const Ieee80211ErpOfdmMode Ieee80211ErpOfdmCompliantModes::erpOnlyOfdmMode54Mbps("erpOnlyOfdmMode54Mbps", true, &Ieee80211OfdmCompliantModes::ofdmPreambleModeCS20MHz, &Ieee80211OfdmCompliantModes::ofdmHeaderMode6MbpsRate3, &Ieee80211OfdmCompliantModes::ofdmDataMode54Mbps);
const simtime_t Ieee80211ErpOfdmMode::getRifsTime() const
{
return -1;
}
} /* namespace physicallayer */
} /* namespace inet */
|
7f359fb93271bcd7c4af7ee2c81a02e5985c6fc2
|
33999e40cb8b078543335c0849ce0556de2bf82a
|
/Projects/HybridH1/InputTreatment.cpp
|
0b3cec336217baab532eff892070b66fa4005386
|
[] |
no_license
|
labmec/ErrorEstimation
|
1821222cac24e919b6663846078f6cef4717e972
|
6ca13c3d6cd59dc3d33fde23a48d1fec48818d4c
|
refs/heads/main
| 2023-08-20T23:08:45.333448
| 2021-03-29T14:22:38
| 2021-03-29T14:22:38
| 130,746,925
| 2
| 1
| null | 2023-06-23T18:44:44
| 2018-04-23T19:33:29
|
C++
|
UTF-8
|
C++
| false
| false
| 7,552
|
cpp
|
InputTreatment.cpp
|
//
// Created by victor on 16/03/2021.
//
#include "InputTreatment.h"
#include "DataStructure.h"
#include "MeshInit.h"
#include "Tools.h"
void Configure(ProblemConfig &config,int ndiv,PreConfig &pConfig,char *argv[]){
ReadEntry(config, pConfig);
config.ndivisions = ndiv;
config.dimension = pConfig.dim;
config.prefine = false;
config.exact.operator*().fSignConvention = 1;
config.exact->fDimension = config.dimension;
bool isOriginCentered = 0; /// Wheater the domain = [0,1]x^n or [-1,1]^n
if(pConfig.type == 2) isOriginCentered = 1;
TPZGeoMesh *gmesh;
TPZManVector<int, 4> bcids(4, -1);
gmesh = Tools::CreateGeoMesh(1, bcids, config.dimension,isOriginCentered,pConfig.topologyMode);
Tools::UniformRefinement(config.ndivisions, gmesh);
config.gmesh = gmesh;
config.materialids.insert(1);
config.bcmaterialids.insert(-1);
if (pConfig.type == 2) {
config.materialids.insert(2);
config.materialids.insert(3);
config.bcmaterialids.insert(-5);
config.bcmaterialids.insert(-6);
config.bcmaterialids.insert(-8);
config.bcmaterialids.insert(-9);
SetMultiPermeMaterials(config.gmesh);
}
if(pConfig.argc != 1) {
config.k = atoi(argv[3]);
config.n = atoi(argv[4]);
}
if(pConfig.debugger == true && ndiv != 0){
Tools::DrawGeoMesh(config,pConfig);
}
}
void ConfigureNFconvergence(ProblemConfig &config,PreConfig &pConfig){
ReadEntry(config, pConfig);
config.dimension = pConfig.dim;
config.prefine = false;
config.exact.operator*().fSignConvention = 1;
config.exact->fDimension = config.dimension;
TPZGeoMesh *gmesh;
TPZManVector<int, 4> bcids(4, -1);
bcids[3] = -2;
gmesh = Tools::CreateGeoMesh(1, bcids, config.dimension,0,pConfig.topologyMode);
config.gmesh = gmesh;
config.materialids.insert(1);
config.bcmaterialids.insert(-1);
config.bcmaterialids.insert(-2);
if(pConfig.debugger == true){
Tools::DrawGeoMesh(config,pConfig);
}
}
void EvaluateEntry(int argc, char *argv[],PreConfig &pConfig){
if(argc != 1 && argc != 5){
std::cout << "Invalid entry";
DebugStop();
}
if(argc == 5){
pConfig.argc = argc;
for(int i = 3; i < 5 ; i++)
IsInteger(argv[i]);
if(std::strcmp(argv[2], "H1") == 0)
pConfig.mode = 0;
else if(std::strcmp(argv[2], "Hybrid") == 0) {
pConfig.mode = 1;
if(pConfig.n < 1 ){
std::cout << "Unstable method\n";
DebugStop();
}
}
else if(std::strcmp(argv[2], "Mixed") == 0) {
pConfig.mode = 2;
if(pConfig.n < 0) DebugStop();
}
else DebugStop();
if(std::strcmp(argv[1], "ESinSin") == 0) {
pConfig.type = 0;
pConfig.problem = "ESinSin";
}
else if(std::strcmp(argv[1], "EArcTan") == 0) {
pConfig.type = 1;
if(pConfig.n < 1 ){
std::cout << "Unstable method\n";
DebugStop();
}
pConfig.problem = "EArcTan";
}
else if(std::strcmp(argv[1], "ESteklovNonConst") == 0) {
pConfig.type = 2;
if(pConfig.n < 0) DebugStop();
pConfig.problem = "ESteklovNonConst";
}
else DebugStop();
}
else{
if (pConfig.approx == "H1") pConfig.mode = 0;
else if (pConfig.approx == "Hybrid") pConfig.mode = 1;
else if (pConfig.approx == "Mixed") pConfig.mode = 2;
else DebugStop();
if (pConfig.problem== "ESinSin") pConfig.type= 0;
else if (pConfig.problem=="EArcTan") pConfig.type = 1;
else if (pConfig.problem == "ESteklovNonConst") pConfig.type = 2;
else DebugStop();
}
if (pConfig.topologyMode != -1) DebugStop();
if (pConfig.topology == "Triangular") pConfig.topologyMode = 1;
else if (pConfig.topology == "Quadrilateral") pConfig.topologyMode = 2;
else if (pConfig.topology == "Tetrahedral") pConfig.topologyMode = 3;
else if (pConfig.topology == "Hexahedral") pConfig.topologyMode = 4;
else if (pConfig.topology == "Prism") pConfig.topologyMode = 5;
if (pConfig.topologyMode == -1) DebugStop();
if(pConfig.topologyMode < 3) pConfig.dim = 2;
else pConfig.dim = 3;
}
void InitializeOutstream(PreConfig &pConfig, char *argv[]){
//Error buffer
if( remove( "Erro.txt" ) != 0) perror( "Error deleting file" );
else puts( "Error log successfully deleted" );
pConfig.Erro.open("Erro.txt",std::ofstream::app);
pConfig.Erro << "----------COMPUTED ERRORS----------\n";
pConfig.Log = new TPZVec<REAL>(pConfig.numErrors, -1);
pConfig.rate = new TPZVec<REAL>(pConfig.numErrors, -1);
ProblemConfig config;
Configure(config,0,pConfig,argv);
std::stringstream out;
switch (pConfig.topologyMode) {
case 1:
pConfig.topologyFileName = "2D-Tri";
break;
case 2:
pConfig.topologyFileName = "2D-Qua";
break;
case 3:
pConfig.topologyFileName = "3D-Tetra";
break;
case 4:
pConfig.topologyFileName = "3D-Hex";
break;
case 5:
pConfig.topologyFileName = "3D-Prism";
break;
default:
DebugStop();
break;
}
switch(pConfig.mode) {
case 0: //H1
out << "H1_" << pConfig.topologyFileName << "_" << config.problemname << "_k-"
<< config.k;
pConfig.plotfile = out.str();
break;
case 1: //Hybrid
out << "Hybrid_" << pConfig.topologyFileName << "_" << config.problemname << "_k-"
<< config.k << "_n-" << config.n;
pConfig.plotfile = out.str();
break;
case 2: // Mixed
out << "Mixed_" << pConfig.topologyFileName << "_" << config.problemname << "_k-"
<< config.k << "_n-" << config.n;
pConfig.plotfile = out.str();
break;
default:
std::cout << "Invalid mode number";
DebugStop();
break;
}
std::string command = "mkdir " + pConfig.plotfile;
system(command.c_str());
std::string timer_name = pConfig.plotfile + "/timer.txt";
if( remove(timer_name.c_str()) != 0)
perror( "Error deleting file" );
else
puts( "Error log successfully deleted" );
pConfig.timer.open(timer_name, std::ofstream::app);
}
void IsInteger(char *argv){
std::istringstream ss(argv);
int x;
if (!(ss >> x)) {
std::cerr << "Invalid number: " << argv << '\n';
} else if (!ss.eof()) {
std::cerr << "Trailing characters after number: " << argv << '\n';
}
}
void ReadEntry(ProblemConfig &config, PreConfig &preConfig){
config.exact = new TLaplaceExample1;
switch(preConfig.type){
case 0:
config.exact.operator*().fExact = TLaplaceExample1::ESinSin;
break;
case 1:
config.exact.operator*().fExact = TLaplaceExample1::EArcTan;
break;
case 2:
config.exact.operator*().fExact = TLaplaceExample1::ESteklovNonConst;
preConfig.h*=2;
break;
default:
DebugStop();
break;
}
config.k = preConfig.k;
config.n = preConfig.n;
config.problemname = preConfig.problem;
}
|
746d276ff66016115a618ada02e72f9e44c9c223
|
d6a1da196bc61ceecce316b91607c9df1c62d12d
|
/Eto/A/lib/lib_objectcontainer.cpp
|
de3538305e71c96a72c69517cba9f3f7ed6503de
|
[] |
no_license
|
DanielMaydana/FJALA-mod2
|
75aefa40b0e962e9fa946a822b22533682ba1b6e
|
6296d4098ac309389143161e973d2f1021f785f0
|
refs/heads/master
| 2021-06-13T08:30:01.789114
| 2019-08-15T15:13:08
| 2019-08-15T15:13:08
| 172,765,900
| 0
| 0
| null | 2021-05-10T04:36:10
| 2019-02-26T18:23:31
|
C++
|
UTF-8
|
C++
| false
| false
| 261
|
cpp
|
lib_objectcontainer.cpp
|
#include "lib_objectcontainer.h"
#include "lib_object.h"
lib_objectcontainer::lib_objectcontainer
(lib_object* obj)
: obj { obj }
{
}
lib_objectcontainer::~lib_objectcontainer()
{
delete obj;
}
lib_object& lib_objectcontainer::get()
{
return *obj;
}
|
0ec7f57dbd6e2ce2f2197270425bb686d625690c
|
3bb279b544d208187ad24cde358ee385c2cbb1df
|
/Sorting/Painter.cpp
|
e3372704adeb8b93e17d50f2c2f13ced0611baf2
|
[] |
no_license
|
rakshityadav07/C-
|
4a08419426ac2ab5358327bb4e5116e82a943fe3
|
07a277395b8523c67b5891f159f8e889aeb19a90
|
refs/heads/master
| 2020-09-28T06:32:30.774746
| 2020-03-20T01:10:25
| 2020-03-20T01:10:25
| 226,713,186
| 1
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 293
|
cpp
|
Painter.cpp
|
#include <iostream>
#define ll long long int
using namespace std;
int main(){
ll n,k,t,li;
cin >> n >> k >> t >> li;
int s = 0 ;
int e= n-1
int mid;
while(s<=e){
mid = (s+e)/2;
if(getmax(a,n,k,mid)){
finalans = ans;
s = mid+1;
}
else{
e = mid -1;
}
}
}
|
744126cde0dc8cbde391d804cf06b5052abb5a85
|
43409b014f08c3d053596a7e0a6ab50d3f95ec51
|
/bin/mBed/mainG.cpp
|
5cbc54ceb9c89426e3593b423b32e27ccf70f3b7
|
[] |
no_license
|
edgano/mBed-nf
|
f92f9f2c421a5e5a5087873f6e3fe2c6548c2bb4
|
c770be65da5d88c9205675e2747b13afe657861e
|
refs/heads/master
| 2021-04-28T05:41:31.873339
| 2018-03-01T15:21:26
| 2018-03-01T15:21:26
| 122,183,373
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 24,952
|
cpp
|
mainG.cpp
|
/**
* Author: Gordon Blackshields
*
* for comments contact fabian.sievers@ucd.ie (FS)
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <iostream>
#include <ctime>
#include "alignment/Alignment.h"
#include "alignment/Sequence.h"
#include "general/clustalw.h"
#include "general/UserParameters.h"
#include "substitutionMatrix/SubMatrix.h"
#include "general/Utility.h"
#include "fileInput/FileReader.h"
#include "interface/InteractiveMenu.h"
#include "interface/CommandLineParser.h"
#include "general/DebugLog.h"
#include "general/ClustalWResources.h"
#include "general/Stats.h"
#include "SparseMap.h" /* G */
#include "SmartKMeans.h" /* G */
namespace clustalw
{
UserParameters* userParameters; /* C & G */
Utility* utilityObject; /* C */
SubMatrix *subMatrix; /* C & G */
DebugLog* logObject; /* C */
Stats* statsObject; /* C */
}
using namespace std;
using namespace clustalw;
void help(char *argv0) /* included argc0, FS, 2009-08-06 */
// Help message for helpless users
{
cout << "\n\ntypical usage: " << argv0 << " [-infile pathToInputFile] ";
//cout << "[-seedfile pathToSeedFile] ";
cout << "[-speed speed] ";
cout << "[-clustering clusteringType] ";
cout << "[-method methodType] ";
cout << "[-numInputSeeds number] ";
cout << "[-numOutputDims number] ";
cout << "[-useSeedsOnly true] ";
cout << "[-findOutliers true] ";
cout << "[-seedPosition vector] ";
cout << "[-seedSelection method] ";
cout << "[-seedTreatment method] ";
cout << "[-evaluate False]";
cout << "[-evaluate2 False]";
cout << " \n\nwhere:\n";
cout << " [-speed] can be either fast or slow (default = fast)\n";
cout << " [-clustering] can be either upgma, kmeans, hybrid or none (default = upgma).\n";
cout << " [-method] can be either SparseMap or SeedMap or FullMatrix\n (default = FullMatrix).\n";
cout << " [-numInputSeeds] is the number of initial seed sequences to use to start the pre-processing (SeedMap).\n";
cout << " [-numOutputDims] is the final number of output dimensions (SeedMap, SparseMap).\n";
cout << " It embeds the sequences with respect to the first k reference groups. \n";
cout << " [-useSeedsOnly] is 'true' by default; forces the program to embed all sequences using just the seeds.\n";
cout << " [-findOutliers] is 'true' by default; setting it as 'false' will gain speed (but may lose accuracy.)\n";
cout << " [-seedfile] allows the user to supply a set of sequences (in a FASTA format file) to use as seeds.\n";
cout << " [-seedSelection] may be 'naive','single', 'medoids' or 'multi'. This defines how the seeds are chosen.\n";
cout << " [-seedSelection] may be 'naive','bySeqLen','bySeqDist' or 'bySeqFeats'. This defines how the seeds are treated.\n";
cout << " [-evaluate] allows you to test the resultant vectors by correlation with the orginal distances\n";
cout << " \n\nIf you do not specify any options, then the program will create a full distance matrix and upgma tree by default\n";
exit(1);
}
int main(int argc, char *argv[]){
userParameters = new UserParameters(false); /* C & G */
utilityObject = new Utility(); /* C */
subMatrix = new SubMatrix(); /* C */
statsObject = new Stats(); /* C */
ClustalWResources *resources = ClustalWResources::Instance(); /* C */
resources->setPathToExecutable(string(argv[0])); /* C */
userParameters->setDisplayInfo(true); /* C */
vector<string> args; /* FS, 2009-04-21 */
/* G --> */
string inputFile;
string seedFile;
string speed = "fast";
string clustering = "upgma";
string method = "FullMatrix";
string seedSelectionMethod = "uniform";
string seedTreatmentMethod = "uniform";
int numInputSeeds = -1;
int numOutputDims = -1;
double distMaskCutoff = 0.0;
bool fast = true;
bool sparse = false;
bool hybrid = false;
bool upgma = true;
bool kmeans = false;
bool doClustering = true;
bool useSeedsOnly = true;
bool findOutliers = true;
bool useSeedFile = false;
bool evaluate = false;
bool evaluate2 = false;
/* <-- G */
//userParameters->setDebug(5);
#if DEBUGFULL
if(DEBUGLOG) {
cout << "debugging is on\n\n\n";
logObject = new DebugLog("logfile.txt");
logObject->logMsg("Loggin is on!");
}
#endif
cout << endl;
cout << "+-----------------------------------------+" << endl;
cout << "| mBed -- fast clustering / tree building |" << endl;
cout << "+-----------------------------------------+" << endl;
cout << "Author: Gordon Blackshields, UCD\n" << endl;
cout << "for help type " << argv[0] << " -help\n" << endl;
if (1 == argc){
exit(1);
}
for (int i = 1; i < argc; ++i) {
if (strcmp(argv[i], "-help") == 0) {
help(argv[0]);
exit(1);
} /* help */
else if(strcmp(argv[i], "-infile") == 0)
{
inputFile = string(argv[i+1]);
i++; /* FS, 2009-04-21 */
bool flag = false;
ifstream fin;
fin.open(inputFile.c_str(), ifstream::in);
if( fin.is_open() ){
flag=true;
}
fin.close();
if (flag == true)
{
cout << "using input file " << inputFile <<"\n";
}
else if (flag == false)
{
cout << "error: input file does not exist: "<<inputFile <<"\n";
exit(1);
}
} /* file name */
else if (strcmp(argv[i], "-seedfile") == 0)
{
seedFile = string(argv[i+1]);
bool flag = false;
i++; /* FS, 2009-04-21 */
ifstream fin;
fin.open(seedFile.c_str(), ifstream::in);
if( fin.is_open() )
{
flag=true;
}
fin.close();
if (flag == true)
{
cout << "using seed file " << seedFile <<"\n";
useSeedFile = true;
}
else if (flag == false)
{
cout << "error: seed file does not exist: "<<seedFile <<"\n";
exit(1);
}
} /* seedfile */
//**************************************************//
//**************************************************//
//seedPosition
//**************************************************//
//**************************************************//
else if (strcmp(argv[i], "-method") == 0)
{
method = argv[i+1];
cout << "Method:\t" << method <<"\n";
i++; /* FS, 2009-04-21 */
if(method == "SparseMap")
{
sparse = true;
}
else if(method == "SeedMap")
{
sparse = true;
}
else if(method == "FullMatrix")
{
sparse = false;
}
else if ( (method != "SparseMap") &&
(method != "SeedMap") &&
(method != "FullMatrix") )
{
cout << "\nInvalid argument for " << argv[i] <<" command: " << method <<".\n";
cout << "Please specify one of 'SparseMap','SeedMap','FullMatrix'\n";
help(argv[0]);
exit(1);
}
//cout << method+"\n";
} /* method */
else if(strcmp(argv[i], "-speed") == 0)
{
speed = argv[i+1];
i++; /* FS, 2009-04-21 */
cout << "Speed:\t" << speed <<"\n";
if(speed == "fast")
{
fast = true;
}
else if(speed == "slow")
{
fast = false;
}
else if ( (speed != "fast") &&
(speed != "slow") )
{
cout << "\nInvalid argument for " << argv[i] <<":\t"<<speed<<".\n";
cout << "Please specify 'fast' or 'slow'\n";
help(argv[0]);
exit(1); // multiple exit points in parsing algorithm
}
} /* speed */
else if(strcmp(argv[i], "-clustering") == 0)
{
clustering = argv[i+1];
cout << "Clustering:\t" << clustering <<"\n";
i++; /* FS, 2009-04-21 */
if(clustering == "upgma")
{
upgma = true;
hybrid = false;
kmeans = false;
doClustering = true;
}
else if(clustering == "kmeans")
{
upgma = false;
kmeans = true;
hybrid = false;
doClustering = true;
}
else if(clustering == "hybrid")
{
upgma = false;
kmeans = true;
hybrid = true;
doClustering = true;
}
else if(clustering == "none")
{
upgma = false;
kmeans = false;
hybrid = false;
doClustering = false;
}
else if ( (clustering != "upgma") &&
(clustering != "kmeans") &&
(clustering != "hybrid") &&
(clustering != "none") )
{
cout << "\nInvalid argument for " << argv[i] << ":\t" << clustering <<".\n";
cout << "Please specify one of 'upgma','hybrid','kmeans','none'\n";
help(argv[0]);
exit(1);
}
} /* clustering */
else if(strcmp(argv[i], "-numInputSeeds") == 0)
{
numInputSeeds = atoi(argv[i+1]);
i++; /* FS, 2009-04-21 */
cout << "numInputSeeds:\t" << numInputSeeds << "\n";
if(numInputSeeds < 1)
{
cout << "Error: please specify a positive integer for number of input seeds\n";
help(argv[0]);
exit(1);
}
} /* number of seeds */
else if(strcmp(argv[i], "-distMask") == 0)
{
distMaskCutoff = atof(argv[i+1]);
i++; /* FS, 2009-04-21 */
cout << "using distance masking cutoff of:\t" << distMaskCutoff << "\n";
if(distMaskCutoff > 1.0 )
{
cout << "Error: please specify a distance mask cutoff of between 0 and 1.\n";
help(argv[0]);
exit(1);
}
} /* distance mask cutoff value */
else if(strcmp(argv[i], "-numOutputDims") == 0)
{
numOutputDims = atoi(argv[i+1]);
cout << "numOutputDims:\t" << numOutputDims << "\n";
i++; /* FS, 2009-04-21 */
if(numOutputDims < 1)
{
cout << "Error: please specify a positive integer for number of output dimensions\n";
help(argv[0]);
exit(1);
}
} /* dimensions */
else if(strcmp(argv[i], "-useSeedsOnly") == 0)
{
string option = argv[i+1];
cout << "Using input seeds as single-element reference groups:\t" << option << "\n";
i++; /* FS, 2009-04-21 */
if(option == "true")
{
useSeedsOnly = true;
}
else if(option == "false")
{
useSeedsOnly = false;
}
else if(option != "true" && option !="false")
{
cout << "\nInvalid argument for " << argv[i] <<":\t " << option <<".\n";
cout << "Please specify 'true' or 'false'\n";
help(argv[0]);
exit(1);
}
} /* seed only */
else if (strcmp(argv[i], "-findOutliers") == 0)
{
string option = argv[i+1];
i++; /* FS, 2009-04-21 */
if(option == "true")
{
findOutliers = true;
}
else if(option == "false")
{
findOutliers = false;
}
else if(option != "true" && option !="false")
{
cout << "\nInvalid argument for " << argv[i] <<":\t " << option <<".\n";
cout << "Please specify 'true' or 'false'\n";
help(argv[0]);
exit(1);
}
} /* outliers */
else if(strcmp(argv[i], "-seedSelection") == 0)
{
seedSelectionMethod = argv[i+1];
cout << "seed Selection Method:\t" << seedSelectionMethod <<"\n";
i++; /* FS, 2009-04-21 */
if(
(seedSelectionMethod != "minimal") &&
(seedSelectionMethod != "uniform") &&
(seedSelectionMethod != "length") &&
(seedSelectionMethod != "random") &&
(seedSelectionMethod != "medoid")
)
{
cout << "unrecognised option for " << argv[i] << " command: " << seedSelectionMethod << "\n";
cout << "Please choose one of the following; minimal, uniform, length, medoid or random.\n";
help(argv[0]);
exit(1);
}
} /* seed selection */
else if(strcmp(argv[i], "-seedTreatment") == 0)
{
seedTreatmentMethod = argv[i+1];
i++; /* FS, 2009-04-21 */
cout << "seed Treatment Method:\t" << seedTreatmentMethod <<"\n";
if( (seedTreatmentMethod != "naive") &&
(seedTreatmentMethod != "none") &&
(seedTreatmentMethod != "usePivotObjects") &&
(seedTreatmentMethod != "usePivotGroups") &&
(seedTreatmentMethod != "usePivotObjectsAndConverge") &&
(seedTreatmentMethod != "usePivotGroupsAndConverge") &&
(seedTreatmentMethod != "useSeqFeatures") )
{
cout << "unrecognised option for " << argv[i] << " command: " << seedTreatmentMethod << "\n";
cout << "Please choose one of the following; naive, usePivotObjects,usePivotGroups, usePivotObjectsAndConverge, usePivotGroupsAndConverge, useSeqFeatures\n";
help(argv[0]);
exit(1);
}
} /* seed treatment */
else if(strcmp(argv[i], "-evaluate") == 0)
{
string option = argv[i+1];
cout << "you have chosen to evaluate the embedding (correlation, stress)\n";
i++; /* FS, 2009-04-21 */
if(option == "true")
{
evaluate = true;
}
else if(option == "false")
{
evaluate = false;
}
else if(option != "true" && option !="false")
{
cout << "\nInvalid argument for " << argv[i] <<":\t " << option <<".\n";
cout << "Please specify 'true' or 'false'\n";
help(argv[0]);
exit(1);
}
}
else if(strcmp(argv[i], "-evaluate2") == 0)
{
string option = argv[i+1];
cout << "you have chosen to evaluate the embedding (correlation, stress)\n";
cout << "across increasingly big values of k \n";
i++; /* FS, 2009-04-21 */
if(option == "true")
{
evaluate2 = true;
}
else if(option == "false")
{
evaluate2 = false;
}
else if(option != "true" && option !="false")
{
cout << "\nInvalid argument for " << argv[i] <<":\t " << option <<".\n";
cout << "Please specify 'true' or 'false'\n";
help(argv[0]);
exit(1);
}
}
else { /* FS, 2009-04-21
arguments that are not recognised by Gordon's `logic`
are copied into the args vector to be processed by Clustal */
args.push_back(argv[i]);
} /* not seed map but clustal flag */
} /* i <= 1 < argc */
/* FS, 2009-04-21
Gordon's `logic` has already identified the infile
let Clustal know about it */
string zcAux;
zcAux = string("-infile=");
zcAux.append(inputFile);
args.push_back(zcAux);
/*string zcAux2; it will be used to add ref as file -> need to parse in the command line
zcAux2 = string("-seedfile=");
zcAux2.append(seedFile);
args.push_back(zcAux2);*/
cout << "Other Flags:" << endl;
for (int i = 0; i < args.size(); i++){
cout << i << ": " << args[i] << endl;
}
CommandLineParser cmdLineParser(&args, false);
/*
TIMER FUNCTIONS
The first set are CPU timers - more accurate than wall times,
but only go to a certain limit and then count backwards
(and go into negative numbers...)
these timers are suffixed by "Start" or "Stop".
The second set are the equivalent WALL timers.
They are useful for long execution times, but only give integer values
These timers are suffixed by "Begin" or "End"
*/
clock_t readStart, readStop; // clock to read in sequence data
clock_t embeddingStart, embeddingStop; // clock for vector calculation
clock_t matrixStart, matrixStop; // clock for matrix calculation
clock_t clusterStart, clusterStop; // clock for cluster calculation.
time_t readBegin, readEnd;
time_t embeddingBegin, embeddingEnd;
time_t matrixBegin, matrixEnd;
time_t clusterBegin, clusterEnd;
double cpuReadTime; int wallReadTime;
double cpuEmbedTime; int wallEmbedTime;
double cpuMatrixTime; int wallMatrixTime;
double cpuClusterTime; int wallClusterTime;
/* Timer 1: Time taken to read sequence file */
readStart = clock(); readBegin = time(NULL);
Alignment alignObj; /* G */
DistMatrix fullDistMat; /* G */
FileReader myFileReader; /* F */
myFileReader.seqInput(&alignObj, false); /* F */
/*FileReader mySeedReader; will be the seeds file
mySeedReader.seqInput(&alignObj, false);*/
int numSeqs = alignObj.getNumSeqs();
readStop = clock(); readEnd = time(NULL);
cpuReadTime = (double)(readStop - readStart)/CLOCKS_PER_SEC;
wallReadTime = readEnd - readBegin;
cout << "\nfileReadTime (s) [Wall / CPU]: " << wallReadTime << " " << cpuReadTime << "\n";
/* G --> */
SparseMap myMap(&alignObj, fast);
auto_ptr<DistMatrix> distMat;
DistMatrix* ptrToMat;
int nseqs = myMap.getNumSeqs();
if(sparse == true) {
vector<int> seeds;
if(useSeedFile == true){
/*
if the seed file is supplied, then we need to open it and
extract the sequences. Right now it's very simple and naive:
I'm not using the sequences from this seed file, but I'm
searching through the alignment object from the original
sequences, and recording the indices of these seeeds. This is
just a temporary measure, as it was easier to code
up. However, it also means that the seed sequences are needed
to be present in the input file. To move away from this, I
need to change the code to be able to use any sequences as
seeds, regardless if they're in the sequence file or not.
*/
/* <<CONTINUE HERE>> */
//*************************************************//
// Generating the seed position vector //
//*************************************************//
for (int i=0; i<numInputSeeds;i++){
seeds.push_back(i);
}
//*************************************************//
//*************************************************//
} /* (useSeedFile == true) */
/*Timer 2: Time taken to do the embedding */
embeddingStart = clock(); embeddingBegin = time(NULL);
myMap.doEmbedding(method, numInputSeeds, numOutputDims, useSeedsOnly,
findOutliers, seeds, seedSelectionMethod,
seedTreatmentMethod, distMaskCutoff);
embeddingStop = clock(); embeddingEnd = time(NULL);
cpuEmbedTime = (double)(embeddingStop - embeddingStart)/CLOCKS_PER_SEC;
wallEmbedTime = embeddingEnd - embeddingBegin;
cout << "\nEmbedding Time (s) [Wall / CPU]: " << wallEmbedTime << " " << cpuEmbedTime << "\n";
//cout << "Embedding Time (s) [Wall / CPU]: " << embeddingEnd - embeddingBegin << " " <<(double)(embeddingStop-embeddingStart)/CLOCKS_PER_SEC << "\n";
if (evaluate == true)
{
myMap.evaluateEmbedding();
}
if (evaluate2 == true)
{
myMap.evaluateEmbedding2();
}
myMap.printCoordinatesToFile();
if (doClustering == true)
{
if (upgma == true)
{
/*The actual clustering is done later - this loop is only for the distance matrix creation*/
/*Timer 3: Time taken to create a distance matrix (only valid for UPGMA clustering */
matrixStart = clock(); matrixBegin = time(NULL);
myMap.calculateDistanceMatrix();
matrixStop = clock(); matrixEnd = time(NULL);
cpuMatrixTime = (double)(matrixStop - matrixStart)/CLOCKS_PER_SEC;
wallMatrixTime = matrixEnd - matrixBegin;
cout << "\nMatrix Time (s) [Wall / CPU]: " << wallMatrixTime << " " << cpuMatrixTime << "\n";
//cout << "Matrix Time (s) [Wall / CPU]: " << matrixEnd - matrixBegin << " " << (double)(matrixStop-matrixStart)/CLOCKS_PER_SEC << "\n";
myMap.printDistanceMatrixToFile();
distMat = myMap.getDistMat();
ptrToMat = distMat.get();
} /* (upgma == true) */
else if ((kmeans == true) || (hybrid == true))
{
/*
Cluster the data with kmeans.
numIterations is the max number of iterations k-means will
have to find the optimal clustering (may terminate early).
numCenters is the number of clusters k-means will find
*/
int numCenters = 300; //nseqs / 50; /* <<DANGER>> */
if (numCenters <= 4) {
numCenters = 4;
}
int numIterations = (int)(log2(numCenters));
auto_ptr<vector<Point> > data = myMap.getData();
auto_ptr<vector<Point> > thisClustering;
/*Timer 4: time taken to cluster the objects (through whatever route */
clusterStart = clock(); clusterBegin = time(NULL);
SmartKMeans kmeans;
thisClustering = kmeans.initClustering(data.get(), numCenters);
auto_ptr<KMeansResult> results;
results = kmeans.doClustering(data.get(), thisClustering.get(), numIterations);
clusterStop = clock(); clusterEnd = time(NULL);
if (hybrid == false)
{
/*
That's it. Kmeans clustering only. UPGMA clustering will not
be performed on the kmeans output
*/
cpuClusterTime = (double)(clusterStop - clusterStart)/CLOCKS_PER_SEC;
wallClusterTime = clusterEnd - clusterBegin;
cout << "\nClustering Time (s) [Wall / CPU]: " << wallClusterTime << " " << cpuClusterTime << "\n";
vector<vector<int> > clusters;
clusters.resize(numCenters);
vector<int>* Assign = results->clusterAssignment.get();
ofstream outfile("kmeans.out", ofstream::trunc);
for(int i = 0; i < nseqs; i++){
int ClusterAssignment = (*Assign)[i];
outfile << (*Assign)[i] << " ";
}
// this next part is unnecessary - it's purely for printing to the screen!!
/*
for(int i = 0; i < clusters.size(); i++) {
cout << "CLUSTER " << i << ": ";
for(int j = 0; j < Assign->size(); j++) {
if((*Assign)[j] == i) {
cout << alignObj.getName(j + 1) << " ";
clusters[i].push_back(j);
}
}
cout << "\n";
}
*/
clusters.clear();
} /* (hybrid == false) */
else
{
// "hybrid" means to take the kmeans output and cluster with UPGMA
cout << "\nKMEANS Time (s) [Wall / CPU]: " << wallClusterTime << " " << cpuClusterTime << "\n";
TreeInterface tree;
tree.doKMeansTree(&alignObj, data, results);
cpuClusterTime = (double)(clusterStop - clusterStart)/CLOCKS_PER_SEC;
wallClusterTime = clusterEnd - clusterBegin;
cout << "\nClustering Time (s) [Wall / CPU]: " << wallClusterTime << " " << cpuClusterTime << "\n";
} /* !(hybrid == false) */
} /* ((kmeans == true) || (hybrid == true)) */
} /* (doClustering == true) */
} /* (sparse == true) */
if (sparse == false)
{
matrixStart = clock(); matrixBegin = time(NULL);
fullDistMat.ResizeRect(nseqs + 1);
double dist;
if (fast == true)
{
clustalw::FastPairwiseAlign fastAlign;
for(int i = 0; i < nseqs; i++)
{
cout << "computing matrix row ("<< i + 1 << "/" << nseqs << ")\n";
for(int j = 0; j <= i; j++)
{
if(i == j)
{
fullDistMat(i + 1, j + 1) = 0.0;
}
else
{
fastAlign.pairwiseAlign(&alignObj, &dist, i+1, j+1);
fullDistMat(i + 1, j + 1) = dist;
}
}
}
} /* (fast == true) */
else
{
// use the slow Needleman-Wunsch distance measure
clustalw::FullPairwiseAlign fullAlign;
for(int i = 0; i < nseqs; i++)
{
cout << "computing matrix row ("<< i + 1 << "/" << nseqs << ")\n";
for(int j = 0; j <= i; j++)
{
if(i == j)
{
fullDistMat(i + 1, j + 1) = 0.0;
}
else
{
fullAlign.pairwiseAlign(&alignObj, &dist, i+1, j+1);
fullDistMat(i + 1, j + 1) = dist;
}
}
}
} /* !(fast == true) */
/*
* Get a pointer to the distance matrix to be used for clustering
*/
ptrToMat = &fullDistMat;
matrixStop = clock(); matrixEnd = time(NULL);
cpuMatrixTime = (double)(matrixStop - matrixStart)/CLOCKS_PER_SEC;
wallMatrixTime = matrixEnd - matrixBegin;
cout << "\nMatrix Time (s) [Wall / CPU]: " << wallMatrixTime << " " << cpuMatrixTime << "\n";
long unsigned int totalPossible = (((nseqs * nseqs) - nseqs) / 2);
cout << "\nFullMatrix DistCalls: " << totalPossible << "\n";
ofstream outfile("distMat.out", ofstream::trunc);
for(int i = 0; i < nseqs; i++)
{
outfile << alignObj.getName(i + 1) << " ";
for(int j = 0; j <= i; j++)
{
outfile << setprecision(10) << fullDistMat(i + 1, j + 1) << " ";
}
outfile << "\n";
}
} /* (sparse == false) */
if (upgma == true)
{
// now that we have a distance matrix, apply UPGMA to cluster
clusterStart = clock(); clusterBegin = time(NULL);
cout << "we're at the cluster start point \n";
TreeInterface tree;
bool success = false;
//string treeName = "temptree";
string treeName = inputFile + ".dnd";
//cout << "initialised the tree object \n";
tree.doTreeOnly(ptrToMat, &alignObj, 1, nseqs, &treeName, &success);
//cout << "and completed the tree object \n";
clusterStop = clock(); clusterEnd = time(NULL);
cpuClusterTime = (double)(clusterStop - clusterStart)/CLOCKS_PER_SEC;
wallClusterTime = clusterEnd - clusterBegin;
cout << "\nClustering Time (s) [Wall / CPU]: " << wallClusterTime << " " << cpuClusterTime << "\n";
} /* (upgma == true) */
delete userParameters;
delete utilityObject;
delete subMatrix;
if(logObject)
{
delete logObject;
}
cout << "\n"
"+---------------------------+\n"
"| Program ran to completion |\n"
"+---------------------------+\n" << endl;
return 0;
}
|
7561447f984948e757257dd8a2f279d42833c2ae
|
19f8a512cd2c17dd72c04f2847f58d268deb8623
|
/char.cpp
|
f7238f45f70c8a88be3d4b7d0e315216944a1b2c
|
[] |
no_license
|
ggreco/lpcgame
|
9aec307636322a099141ac7d58d4f91671c42f9d
|
6559afff90526019c81f7a7d33a008324e36292f
|
refs/heads/master
| 2016-09-06T10:02:05.310532
| 2013-10-18T10:50:56
| 2013-10-18T10:50:56
| 4,595,398
| 2
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 109
|
cpp
|
char.cpp
|
#include "char.h"
#include "SDL_image.h"
Character::
Character(const std::string &xml) : AnimObj(xml)
{
}
|
3a9c6220bcb852558d0ea07b2fbe118fe447c909
|
0494c9caa519b27f3ed6390046fde03a313d2868
|
/src/chrome/browser/ui/views/autofill/autofill_credit_card_bubble_views.cc
|
fb2f2388085eae5a57c3167d40080381485a96a0
|
[
"BSD-3-Clause"
] |
permissive
|
mhcchang/chromium30
|
9e9649bec6fb19fe0dc2c8b94c27c9d1fa69da2c
|
516718f9b7b95c4280257b2d319638d4728a90e1
|
refs/heads/master
| 2023-03-17T00:33:40.437560
| 2017-08-01T01:13:12
| 2017-08-01T01:13:12
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 3,606
|
cc
|
autofill_credit_card_bubble_views.cc
|
// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/ui/views/autofill/autofill_credit_card_bubble_views.h"
#include "chrome/browser/ui/autofill/autofill_credit_card_bubble_controller.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_finder.h"
#include "chrome/browser/ui/views/frame/browser_view.h"
#include "chrome/browser/ui/views/location_bar/location_bar_view.h"
#include "ui/gfx/font.h"
#include "ui/gfx/insets.h"
#include "ui/gfx/size.h"
#include "ui/views/bubble/bubble_frame_view.h"
#include "ui/views/controls/link.h"
#include "ui/views/controls/styled_label.h"
#include "ui/views/layout/box_layout.h"
#include "ui/views/layout/layout_constants.h"
#include "ui/views/view.h"
#include "ui/views/widget/widget.h"
namespace autofill {
AutofillCreditCardBubbleViews::~AutofillCreditCardBubbleViews() {}
void AutofillCreditCardBubbleViews::Show() {
// TODO(dbeam): investigate why this steals focus from the web contents.
views::BubbleDelegateView::CreateBubble(this);
GetWidget()->Show();
SizeToContents();
}
void AutofillCreditCardBubbleViews::Hide() {
GetWidget()->Close();
}
bool AutofillCreditCardBubbleViews::IsHiding() const {
return GetWidget() && GetWidget()->IsClosed();
}
string16 AutofillCreditCardBubbleViews::GetWindowTitle() const {
return controller_->BubbleTitle();
}
void AutofillCreditCardBubbleViews::Init() {
SetLayoutManager(new views::BoxLayout(views::BoxLayout::kVertical, 0, 0,
views::kRelatedControlVerticalSpacing));
views::StyledLabel::RangeStyleInfo bold;
bold.font_style = gfx::Font::BOLD;
const std::vector<ui::Range>& ranges = controller_->BubbleTextRanges();
views::StyledLabel* contents =
new views::StyledLabel(controller_->BubbleText(), NULL);
for (size_t i = 0; i < ranges.size(); ++i) {
contents->AddStyleRange(ranges[i], bold);
}
AddChildView(contents);
views::Link* link = new views::Link();
link->SetHorizontalAlignment(gfx::ALIGN_LEFT);
link->SetText(controller_->LinkText());
link->set_listener(this);
AddChildView(link);
}
gfx::Size AutofillCreditCardBubbleViews::GetPreferredSize() {
return gfx::Size(
AutofillCreditCardBubbleViews::kContentWidth,
GetHeightForWidth(AutofillCreditCardBubble::kContentWidth));
}
void AutofillCreditCardBubbleViews::LinkClicked(views::Link* source,
int event_flags) {
if (controller_)
controller_->OnLinkClicked();
}
// static
base::WeakPtr<AutofillCreditCardBubble> AutofillCreditCardBubble::Create(
const base::WeakPtr<AutofillCreditCardBubbleController>& controller) {
AutofillCreditCardBubbleViews* bubble =
new AutofillCreditCardBubbleViews(controller);
return bubble->weak_ptr_factory_.GetWeakPtr();
}
AutofillCreditCardBubbleViews::AutofillCreditCardBubbleViews(
const base::WeakPtr<AutofillCreditCardBubbleController>& controller)
: BubbleDelegateView(BrowserView::GetBrowserViewForBrowser(
chrome::FindBrowserWithWebContents(controller->web_contents()))->
GetLocationBarView()->autofill_credit_card_view(),
views::BubbleBorder::TOP_RIGHT),
controller_(controller),
weak_ptr_factory_(this) {
// Match bookmarks bubble view's anchor view insets and margins.
set_anchor_view_insets(gfx::Insets(7, 0, 7, 0));
set_margins(gfx::Insets(0, 19, 18, 18));
set_move_with_anchor(true);
}
} // namespace autofill
|
1603889bdeb240ecd475189280dc589f7355180d
|
62ddc693f482c5061f41f070a34b9aa9e02a3565
|
/src/flow/action.hpp
|
f38c9b2cc5b572145952bfd959f336c8abc9f8ee
|
[] |
no_license
|
sebastocorp/lets-chaproxy
|
9baf8d17eee5638f13a77d2a6a7d2f64ddc46735
|
76662f8f23be3a13a12b0a3e75ccb77fbd423e4a
|
refs/heads/master
| 2023-07-09T17:14:45.490476
| 2021-08-22T00:40:43
| 2021-08-22T00:40:43
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 538
|
hpp
|
action.hpp
|
#pragma once
namespace FLOW
{
struct Action{
// METHODs
static void createCerts();
static void renewCerts();
static void watchLogs();
// Maybe not needed
static void logSucces();
static void logError();
};
}
#ifdef ACTION_IMPLEMENTATION
namespace FLOW
{
void Action::createCerts(){}
void Action::renewCerts(){}
void Action::watchLogs(){}
// Maybe not needed
void Action::logSucces(){}
void Action::logError(){}
}
#endif // ACTION_IMPLEMENTATION
|
5e0de83afda056cb93db80e762e3c17092d1c79c
|
97e169f89aacdfc34c1f3bce2e9588f4fd277cfe
|
/LaboReseauxBinome/Evaluation1/Librairies/Exceptions/ErrnoException.h
|
9ceca3c6cbc1816431b2e6bc41a1a6b3ea2af651
|
[] |
no_license
|
OceStasse/Reseaux
|
59d6949926263b517b1c4c53ace9883b8d0eb285
|
437c03361193c24881bc13fdb5ddb9886235bdf4
|
refs/heads/master
| 2020-03-22T14:18:21.237944
| 2018-09-08T07:43:37
| 2018-09-08T07:43:37
| 140,168,416
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 480
|
h
|
ErrnoException.h
|
#ifndef EXCEPTIONS_ERRNOEXCEPTION_H
#define EXCEPTIONS_ERRNOEXCEPTION_H
#include <cerrno>
#include <cstring>
class ErrnoException : public std::exception {
protected:
std::string message;
int errnoCode;
public:
ErrnoException(int errorCode, std::string msg);
ErrnoException(int errorCode, const char *msg);
ErrnoException(const ErrnoException& orig);
virtual ~ErrnoException() throw();
virtual const char* what() const throw();
};
#endif //EXCEPTIONS_ERRNOEXCEPTION_H
|
d053d869f5ecdbdd64622359d29a3a9c033d28ff
|
6552d3e62b55a90b798d483d186cbb330757bd17
|
/Old_map/old/old_node.cpp
|
ff4fcfceee47243bb87a22808882d95c62f17fd5
|
[] |
no_license
|
Tako-San/ILab
|
87cf0e8183162129ab761ebb698d6ccdf90e89d2
|
101cb42025dbba4fb5c686767365035b8f42f716
|
refs/heads/master
| 2021-07-11T10:22:05.627856
| 2020-11-24T17:58:13
| 2020-11-24T17:58:13
| 218,972,144
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 2,283
|
cpp
|
old_node.cpp
|
#include "old_node.h"
Node::Node() : key(0),
val{0},
parent(nullptr),
left(nullptr),
right(nullptr)
{
}
Node::Node(size_t new_key) : key(new_key),
val{0},
parent(nullptr),
left(nullptr),
right(nullptr)
{
}
Node::Node(size_t new_key, Data new_val) : key(new_key),
val(new_val),
parent(nullptr),
left(nullptr),
right(nullptr)
{
}
Node * Node::add(size_t new_key, Data new_val)
{
#define DIRTY_JOB(side) \
if(side != nullptr) \
return side->add(new_key, new_val); \
else \
{ \
side = new Node; \
side->set(new_key, new_val, this); \
printf("\n%p %p\n", left, right); \
return side; \
} \
if(new_key < key)
{
printf("%ld < %ld\n", new_key, key);
DIRTY_JOB(left)
}
else if(new_key > key)
{
DIRTY_JOB(right)
}
return nullptr;
}
void Node::set_key(size_t new_key)
{
key = new_key;
}
void Node::set_val(Data new_val)
{
val = new_val;
}
/*void Node::set_left(Node * new_left)
{
left = new_left;
}
void Node::set_right(Node * new_right)
{
right = new_right;
}*/
void Node::set_parent(Node * new_parent)
{
parent = new_parent;
}
void Node::set(size_t new_key, Data new_val, Node * new_parent)
{
set_key(new_key);
set_val(new_val);
set_parent(new_parent);
}
void Node::print()
{
if(left != nullptr)
left->print();
std::cout<<key<<": "<<val<<'\n';
if(right != nullptr)
right->print();
}
Node* Node::find(size_t fkey)
{
if(fkey == key)
return this;
else if(fkey < key && left != nullptr)
return left->find(fkey);
else if(fkey > key && right != nullptr)
return right->find(fkey);
return nullptr;
}
|
d3ca124c7d6b32e2bf1509d902a5be0a179f1b00
|
37d433dd8d5d0968fcd7866e98e85d25290f90fc
|
/test/bdev/bdevc++/common/GlobalMemoryAlloc.h
|
9374ab17d522075f61eb5187a11d3eec3e31205f
|
[
"BSD-3-Clause"
] |
permissive
|
janlt/spdk
|
454294b7e17526922902d8d83c99c99563e67a8a
|
263a281579bd956acf596cd3587872c209050816
|
refs/heads/master
| 2021-05-18T20:06:26.695445
| 2020-09-24T08:17:51
| 2020-09-24T08:17:51
| 251,393,718
| 1
| 0
|
NOASSERTION
| 2020-03-30T18:29:01
| 2020-03-30T18:29:00
| null |
UTF-8
|
C++
| false
| false
| 2,241
|
h
|
GlobalMemoryAlloc.h
|
/**
* Copyright (c) 2019 Intel 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 <cstddef>
#include <iostream>
#include <typeinfo>
using namespace std;
#include <stdlib.h>
namespace BdevCpp {
template <class Y> class GlobalMemoryAlloc {
public:
virtual ~GlobalMemoryAlloc();
static void *New(unsigned int padd_);
static void Delete(void *obj_);
static unsigned int objectSize();
static const char *getName();
protected:
GlobalMemoryAlloc(const GlobalMemoryAlloc<Y> &right);
GlobalMemoryAlloc<Y> &operator=(const GlobalMemoryAlloc<Y> &right);
};
template <class Y> inline GlobalMemoryAlloc<Y>::~GlobalMemoryAlloc() {}
template <class Y> inline void *GlobalMemoryAlloc<Y>::New(unsigned int padd_) {
#ifdef _MM_DEBUG_
#ifndef _MM_GMP_ON_
cout << " GlobalMemoryAlloc<Y>::New, padd_: " << padd_
<< " sizeof(Y): " << sizeof(Y) << endl
<< flush;
#else
fprintf(stderr, " GlobalMemoryAlloc<Y>::New, padd_: %d sizeof(Y): %d\n",
padd_, sizeof(Y));
fflush(stderr);
#endif
#endif
#ifndef _MM_GMP_ON_
return ::new char[padd_ + sizeof(Y)];
#else
return (char *)::malloc(padd_ + sizeof(Y)) + padd_;
#endif
}
template <class Y> inline void GlobalMemoryAlloc<Y>::Delete(void *obj_) {}
template <class Y> inline unsigned int GlobalMemoryAlloc<Y>::objectSize() {
return (unsigned int)sizeof(Y);
}
template <class Y> inline const char *GlobalMemoryAlloc<Y>::getName() {
static const type_info &ti = typeid(Y);
#ifdef _MM_DEBUG_
#ifndef _MM_GMP_ON_
cout << "NAME: " << ti.name() << endl << flush;
#else
fprintf(stderr, "NAME: %s\n", ti.name());
#endif
#endif
return ti.name();
}
} // namespace BdevCpp
|
4ad88e9e864ec3b9cfa5765fd87ae2d63da666cd
|
3d693499bcc8040426da0446285d74c3ec3bd734
|
/src/Entity.cpp
|
83306fb44a3e6379609cadb57c0df90e90686ae6
|
[] |
no_license
|
miguelsantoss/AVT1516
|
a86aec6c8319e1bc01e852f1aec7c007abd3f052
|
3746a579ac9ead80122c1da9ffb0db1cba537e72
|
refs/heads/master
| 2021-01-10T06:31:19.594637
| 2015-11-18T17:51:22
| 2015-11-18T17:51:22
| 44,014,595
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 286
|
cpp
|
Entity.cpp
|
#include "Entity.h"
#include <iostream>
Entity::Entity() {}
Entity::~Entity() {}
void Entity::setPosition(float x, float y, float z) {
_position.set(x, y, z);
}
void Entity::setPosition(const Vector3& position) {
_position.set(position.getX(), position.getY(), position.getZ());
}
|
29d0527a7bec186e8cbcd80a44134d8e0a6b5de3
|
33206dc0ad17813afc29113cef3a062ad32808b9
|
/ndmanager-plugins/src/process_nlxconvert/ncsfilecollection.h
|
a4a16eac577e2a33d8e4034b0ef5dbc514b13fc9
|
[] |
no_license
|
brendonw1/preprocessing
|
4abf385aaa481e6cf8cb8cab3944085396aa6569
|
7202e0ee3d0d50fd1072568c6748ee5a6b31a93f
|
refs/heads/master
| 2020-03-07T11:49:55.873212
| 2018-03-30T17:02:37
| 2018-03-30T17:02:37
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 4,162
|
h
|
ncsfilecollection.h
|
/***************************************************************************
* Copyright (C) 2004-2011 by Michael Zugaro *
* michael.zugaro@college-de-france.fr *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 3 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
* *
***************************************************************************/
#ifndef NCS_FILE_COLLECTION
#define NCS_FILE_COLLECTION
#include "customtypes.h"
#include "nlxerror.h"
#include "ncsfile.h"
#include <fstream>
using namespace std;
/**
@author Michael Zugaro
*/
class NCSFileCollection
{
public:
/**
Constructor
*/
NCSFileCollection(bool reverse = false) : n(0),reverse(reverse),recordDuration(-1),t(-1),minGap(-1) { files = new NCSFile[NCS_MAX_N_CHANNELS]; };
/**
Destructor
*/
virtual ~NCSFileCollection() { delete[] files; };
/**
Setter
@param reverse true if signals should be reversed
*/
virtual void set(bool reverse) { this->reverse = reverse; };
/**
Add an input file to the collection
@param filename name of the file to add
*/
virtual void add(string filename);
/**
Open files
@return false if one of the files could not be opened
*/
virtual void open() throw(NLXError);
/**
Close files
*/
virtual void close();
/**
Read frequency and record duration, and determine number of records
*/
virtual void init() throw(NLXError);
/**
Count the number of records in the files
@return number of records
*/
virtual long getNRecords();
/**
Read next data record
@return false if the record could not be read (end of file)
*/
virtual bool readRecord();
/**
Skip missing records
*/
virtual void skipMissingRecords();
/**
Fill missing records
*/
virtual void fillMissingRecords(ofstream &output);
/**
Write record data to output file
*/
virtual void writeRecord(ofstream &output);
/**
Show file headers
*/
virtual void showFileHeaders();
/**
Get current timestamp
@return current timestamp
*/
virtual Time getTimestamp() { return t; };
/**
Get record duration
@return current record duration ยตs
*/
virtual Time getRecordDuration() { return recordDuration; };
/**
Get current gap
@return current gap in ยตs
*/
virtual Time getGap() { return minGap; };
/**
Get (common) sampling frequency
@return frequency
*/
virtual Frequency getFrequency() { if ( n == 0 ) return 0; else return files[0].frequency; };
private:
/**
List of ncs file objects
*/
NCSFile *files;
/**
Total number of ncs files
*/
int n;
/**
Reverse signals?
*/
bool reverse;
/**
Record duration
*/
Time recordDuration;
/**
Previous timestamp
*/
Time t0;
/**
Current timestamp = earliest timestamp across ncs files
*/
Time t;
/**
In each ncs file, there is a (possibly non-zero) gap between current timestamp and the *end* of the previous record
This is the minimum value across ncs files
*/
Time minGap;
/**
Current record contents
*/
Data buffer[NCS_N_SAMPLES_PER_RECORD*NCS_MAX_N_CHANNELS];
};
#endif
|
797c64721868764c866ffd1139a5a75db3be9039
|
c576da974f64149c75ddbd0f5e12dd7044e554d6
|
/src/common/data_objects/Container.h
|
2d32f97421a0868c7b968768fd40690300a06d44
|
[] |
no_license
|
yahavx/ship-stowage-model
|
20d6773d6ec195e118909882f6dd0beb4ea079d9
|
5f80d321cfe5b9b8f2cdeb1f33086eb2fd5b029a
|
refs/heads/master
| 2021-05-23T09:24:58.708894
| 2020-06-17T17:55:51
| 2020-06-17T17:55:51
| 253,218,795
| 1
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,189
|
h
|
Container.h
|
//
// Created by yahav on 05/04/2020.
//
#ifndef SHIP_STOWAGE_MODEL_CONTAINER_H
#define SHIP_STOWAGE_MODEL_CONTAINER_H
#include <string>
#include <iostream>
#include <stdio.h>
#include <vector>
#include "PortId.h"
#include "PackingOperation.h"
#include "../utils/Errors.h"
class Container {
std::string id;
int weight;
PortId destPort;
public:
// region Constructors
Container(const std::string &id, int weight, const PortId &destPort);
// endregion
// region Getters and setters
int getWeight() const;
void setWeight(int weight);
const PortId &getDestPort() const;
void setDestPort(const PortId &destPort);
const std::string &getId() const;
void setId(const std::string &id);
// endregion
// region Operators
bool operator==(const Container &rhs) const;
bool operator!=(const Container &rhs) const;
// endregion
// region Functions
bool isIdInIsoFormat() const;
Error isContainerLegal() const;
// endregion
// region Printer
friend std::ostream &operator<<(std::ostream &os, const Container &container);
// endregion
};
#endif //SHIP_STOWAGE_MODEL_CONTAINER_H
|
bb5da04efa99d5d2e961491e12fce95b5e3fba6c
|
ece2091476cadacff957f889ae029c53584b7edf
|
/leetcodec++/leetcode105.cpp
|
01b680dec0a1ce146d79d55294ce9808bd36108a
|
[] |
no_license
|
mhhuang95/LeetCode
|
719091a5cde281f5d3b9388ee6696033d5475c1d
|
e9e74a81a7f10888c2c342c70b1ba32b09a16ab2
|
refs/heads/master
| 2021-06-12T08:18:21.836748
| 2019-09-24T13:27:16
| 2019-09-24T13:27:16
| 142,246,450
| 2
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 924
|
cpp
|
leetcode105.cpp
|
//
// Created by ้ปๆ่พ on 2019-08-01.
//
/**
* Definition for a binary tree node.
* struct TreeNode {
* int val;
* TreeNode *left;
* TreeNode *right;
* TreeNode(int x) : val(x), left(NULL), right(NULL) {}
* };
*/
class Solution {
public:
TreeNode* buildTree(vector<int>& preorder, vector<int>& inorder) {
return helper(preorder, 0, preorder.size(), inorder, 0, inorder.size());
}
TreeNode* helper(vector<int>& preorder, int i, int j, vector<int>& inorder, int k, int l){
if (i >= j ||k >= l)
return NULL;
auto f = find(inorder.begin() + k, inorder.begin() + l, preorder[i]);
int dis = f - inorder.begin() - k;
TreeNode* root = new TreeNode(preorder[i]);
root->left = helper(preorder, i+1, i+1+dis, inorder, k, k+dis);
root->right = helper(preorder, i+1+dis,j, inorder ,k+dis+1, l);
return root;
}
};
|
03ffccbc6a8a77e1416cf4ea75d6b8335545693b
|
1346cda90de949fcf9bceb0a8de241a6194e7088
|
/RayTracer/RayTracer/Union.h
|
62badea68a39450d0fd37ea2bd34f8b74a1c16a8
|
[] |
no_license
|
xuyunhan/Ray-Chaser
|
4e22a8e4e75b36ae5cd77d03ced545f7e5a1ef2f
|
f5e1c066d549e731e3df175d4197bff7cded2198
|
refs/heads/master
| 2021-01-10T01:20:59.705349
| 2016-03-11T09:28:52
| 2016-03-11T09:28:52
| 53,182,436
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 236
|
h
|
Union.h
|
#pragma once
#include "Geometry.h"
#include <vector>
class Union :
public Geometry
{
public:
Union();
~Union();
IntersectResult Intersect(Ray3 ray);
std::vector<Geometry*> geometries;
void AddGeometry(Geometry* newGeometry);
};
|
1fc8fb66d715278b03fffdce8ba821bb4590fc5e
|
52ca17dca8c628bbabb0f04504332c8fdac8e7ea
|
/boost/fusion/include/container.hpp
|
15a6c203193fd44c8e484156b4399a4d98b173f7
|
[] |
no_license
|
qinzuoyan/thirdparty
|
f610d43fe57133c832579e65ca46e71f1454f5c4
|
bba9e68347ad0dbffb6fa350948672babc0fcb50
|
refs/heads/master
| 2021-01-16T17:47:57.121882
| 2015-04-21T06:59:19
| 2015-04-21T06:59:19
| 33,612,579
| 0
| 0
| null | 2015-04-08T14:39:51
| 2015-04-08T14:39:51
| null |
UTF-8
|
C++
| false
| false
| 70
|
hpp
|
container.hpp
|
#include "thirdparty/boost_1_58_0/boost/fusion/include/container.hpp"
|
ae088a8e3402959b366328cf9930fa5c19599387
|
ee4d9243c725b2ffc689dcfe0506df2e8e3606bc
|
/SP3_Base_Team05/Base/Source/MeshManager.cpp
|
96c712f5b7b642ea1e4b4c4efb72dbc9b761f1b3
|
[] |
no_license
|
zhiternn/SP3_Team05
|
a5e2280b76b80ae5aa9ab96855df918608953fe1
|
73552ee440e5fe7be487b926758501f2e78bb06f
|
refs/heads/master
| 2021-01-15T15:31:13.876022
| 2016-09-01T09:55:50
| 2016-09-01T09:55:50
| 65,693,677
| 0
| 1
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 11,061
|
cpp
|
MeshManager.cpp
|
#include "MeshManager.h"
#include "MeshBuilder.h"
#include "LoadTGA.h"
MS MeshManager::_modelStack;
Mesh* MeshManager::_meshList[GEO_DEFAULT_END];
MeshManager::MeshManager()
{
}
MeshManager::~MeshManager()
{
for (int i = 0; i < GEO_DEFAULT_END; ++i)
{
if (meshList[i])
delete meshList[i];
}
}
void MeshManager::Init()
{
for (int i = 0; i < GEO_DEFAULT_END; ++i)
{
if (meshList[i])
delete meshList[i];
meshList[i] = NULL;
}
meshList[GEO_AXES] = MeshBuilder::GenerateAxes("reference");
meshList[GEO_CROSSHAIR] = MeshBuilder::GenerateQuad("crosshair", Color(0, 0, 0), 1.f);
meshList[GEO_CROSSHAIR]->textureArray[0] = LoadTGA("Image//target.tga");
meshList[GEO_QUAD] = MeshBuilder::GenerateQuad("quad", Color(1, 1, 1), 1.f);
meshList[GEO_CUBE] = MeshBuilder::GenerateCube("cube", Color(1, 1, 1));
meshList[GEO_TEXT] = MeshBuilder::GenerateText("text", 16, 16);
meshList[GEO_TEXT]->textureID = LoadTGA("Image//font.tga");
meshList[GEO_TEXT]->material.kAmbient.Set(1, 0, 0);
meshList[GEO_RING] = MeshBuilder::GenerateRing("ring", Color(1, 0, 1), 36, 1, 0.5f);
meshList[GEO_LIGHTBALL] = MeshBuilder::GenerateSphere("lightball", Color(1, 1, 1), 18, 36, 1.f);
meshList[GEO_SPHERE] = MeshBuilder::GenerateSphere("sphere", Color(1, 1, 1), 9, 18, 1.f);
meshList[GEO_CONE] = MeshBuilder::GenerateCone("cone", Color(0.5f, 1, 0.3f), 36, 10.f, 1.f);
//meshList[GEO_LIGHT_DEPTH_QUAD] = MeshBuilder::GenerateQuad("LIGHT_DEPTH_TEXTURE", Color(1, 1, 1), 1.f);
//meshList[GEO_LIGHT_DEPTH_QUAD]->textureArray[0] = m_lightDepthFBO.GetTexture();
meshList[GEO_BULLET] = MeshBuilder::GenerateSphere("sphere", Color(1, 1, 1), 9, 18, 1.f);
meshList[GEO_BULLET]->material.kAmbient.Set(0.5f, 0.1f, 0.1f);
meshList[GEO_BULLET]->material.kDiffuse.Set(0.2f, 0.2f, 0.2f);
meshList[GEO_BULLET]->material.kSpecular.Set(0.1f, 0.1f, 0.1f);
meshList[GEO_BULLET]->enableLight = true;
meshList[GEO_GRENADE];
meshList[GEO_SHIELD];
meshList[GEO_ROPE] = MeshBuilder::GenerateQuad("rope", Color(1, 1, 1), 1);
meshList[GEO_ROPE]->textureArray[0] = LoadTGA("Image//rope.tga");
//PARTICLES
meshList[GEO_PARTICLE_SMOKE] = MeshBuilder::GenerateQuad("p_smoke", Color(1, 1, 1), 1);
meshList[GEO_PARTICLE_SMOKE]->textureArray[0] = LoadTGA("Image//particle_smoke.tga");
meshList[GEO_PARTICLE_HIT] = MeshBuilder::GenerateQuad("p_hit", Color(1, 1, 1), 1);
meshList[GEO_PARTICLE_HIT]->textureArray[0] = LoadTGA("Image//particle_hit.tga");
meshList[GEO_PARTICLE_SIGNAL] = MeshBuilder::GenerateQuad("p_signal", Color(1, 1, 1), 1);
meshList[GEO_PARTICLE_SIGNAL]->textureArray[0] = LoadTGA("Image//particle_signal.tga");
meshList[GEO_PARTICLE_SKID] = MeshBuilder::GenerateQuad("p_skid", Color(1, 1, 1), 1);
meshList[GEO_PARTICLE_SKID]->textureArray[0] = LoadTGA("Image//particle_skid.tga");
meshList[GEO_PARTICLE_ATTACK] = MeshBuilder::GenerateQuad("p_atck", Color(1, 1, 1), 1);
meshList[GEO_PARTICLE_ATTACK]->textureArray[0] = LoadTGA("Image//particle_attack.tga");
meshList[GEO_PARTICLE_TELEPORT] = MeshBuilder::GenerateQuad("p_teleport", Color(1, 1, 1), 1);
meshList[GEO_PARTICLE_TELEPORT]->textureArray[0] = LoadTGA("Image//Detlaff_TGA//teleport.tga");
meshList[GEO_TRAP] = MeshBuilder::GenerateOBJ("trap", "Obj//sphereobj.obj");
meshList[GEO_TRAP]->textureArray[0] = LoadTGA("Image//trap.tga");
meshList[GEO_TRAP]->material.kAmbient.Set(0.1f, 0.1f, 0.1f);
meshList[GEO_TRAP]->material.kDiffuse.Set(0.1f, 0.1f, 0.1f);
meshList[GEO_TRAP]->material.kSpecular.Set(0.5f, 0.5f, 0.5f);
meshList[GEO_PLAYER_TOP] = MeshBuilder::GenerateOBJ("player_top", "Obj//player_top.obj");
meshList[GEO_PLAYER_TOP]->enableLight = true;
meshList[GEO_PLAYER_TOP]->textureArray[0] = LoadTGA("Image//player.tga");
//meshList[GEO_PLAYER_TOP]->textureArray[1] = LoadTGA("Image//player2.tga");
//meshList[GEO_PLAYER_TOP]->textureArray[2] = LoadTGA("Image//player3.tga");
meshList[GEO_PLAYER_BOTTOM] = MeshBuilder::GenerateOBJ("player_top", "Obj//player_bottom.obj");
meshList[GEO_PLAYER_BOTTOM]->enableLight = true;
meshList[GEO_PLAYER_BOTTOM]->textureArray[0] = LoadTGA("Image//player.tga");
//meshList[GEO_PLAYER_BOTTOM]->textureArray[1] = LoadTGA("Image//player2.tga");
//meshList[GEO_PLAYER_BOTTOM]->textureArray[2] = LoadTGA("Image//player3.tga");
meshList[GEO_FLOOR] = MeshBuilder::GenerateQuad("floor", Color(0.4f, 0.4f, 0.4f), 1.f, 4.0f);
meshList[GEO_FLOOR]->textureArray[0] = LoadTGA("Image//hex_floor_default.tga");
meshList[GEO_FLOOR]->textureArray[1] = LoadTGA("Image//hex_floor_emissive.tga");
meshList[GEO_BACKGROUND1] = MeshBuilder::GenerateQuad("bg1", Color(0.4f, 0.4f, 0.4f), 1.f);
meshList[GEO_BACKGROUND1]->textureArray[0] = LoadTGA("Image//bg1.tga");
meshList[GEO_BACKGROUND2] = MeshBuilder::GenerateQuad("bg2", Color(0.4f, 0.4f, 0.4f), 1.f);
meshList[GEO_BACKGROUND2]->textureArray[0] = LoadTGA("Image//bg2.tga");
meshList[GEO_BACKGROUND3] = MeshBuilder::GenerateQuad("bg3", Color(0.4f, 0.4f, 0.4f), 1.f);
meshList[GEO_BACKGROUND3]->textureArray[0] = LoadTGA("Image//bg3.tga");
meshList[GEO_FLOOR_HEX] = MeshBuilder::GenerateQuad("floor", Color(0.4f, 0.4f, 0.4f), 1.f, 3.0f);
meshList[GEO_FLOOR_HEX]->enableLight = true;
meshList[GEO_FLOOR_HEX]->textureArray[0] = LoadTGA("Image//hex_floor_default.tga");
meshList[GEO_FLOOR_HEX]->textureArray[1] = LoadTGA("Image//hex_floor_emissive.tga");
meshList[GEO_MINIMAP] = MeshBuilder::GenerateCircle("minimap_background", Color(0.4f, 0.4f, 0.4f));
meshList[GEO_MINIMAP]->textureArray[0] = LoadTGA("Image//minimap_background.tga");
meshList[GEO_MINIMAP_BORDER] = MeshBuilder::GenerateCircleOutline("minimap_background_outline", Color(0.4f, 0.4f, 0.4f));
meshList[GEO_MINIMAP_PLAYER_ICON] = MeshBuilder::GenerateCircle("player", Color(0.1f, 0.9f, 0.1f), 2);
meshList[GEO_MINIMAP_BOSS_MAIN_ICON] = MeshBuilder::GenerateCircle("minimap_background", Color(1.0f, 0.0f, 0.0f), 2);
meshList[GEO_MINIMAP_BOSS_BODY_ICON] = MeshBuilder::GenerateCircle("minimap_background", Color(0.5f, 0.1f, 0.1f), 2);
meshList[GEO_MINIMAP_BOSS_BODY_DEAD_ICON] = MeshBuilder::GenerateCircle("minimap_background", Color(0.3f, 0.3f, 0.3f), 2);
meshList[GEO_BORDER] = MeshBuilder::GenerateQuad("border", Color(1, 1, 1), 1.f);
meshList[GEO_HEALTH] = MeshBuilder::GenerateQuad("health", Color(0, 1, 0), 1.f);
meshList[GEO_DASH] = MeshBuilder::GenerateQuad("dash", Color(0, 0.3f, 0.7f), 1.f);
meshList[GEO_CAPTURE] = MeshBuilder::GenerateQuad("capture", Color(1.0f, 1.0f, 0.0f), 1.f);
meshList[GEO_WEAPON_MACHINEGUN] = MeshBuilder::GenerateQuad("machinegun", Color(0, 0, 0), 1.f);
meshList[GEO_WEAPON_MACHINEGUN]->textureArray[0] = LoadTGA("Image//machinegun.tga");
meshList[GEO_WEAPON_SHOTGUN] = MeshBuilder::GenerateQuad("shotgun", Color(0, 0, 0), 1.f);
meshList[GEO_WEAPON_SHOTGUN]->textureArray[0] = LoadTGA("Image//shotgun.tga");
meshList[GEO_WEAPON_SPLITGUN] = MeshBuilder::GenerateQuad("splitgun", Color(0, 0, 0), 1.f);
meshList[GEO_WEAPON_SPLITGUN]->textureArray[0] = LoadTGA("Image//splitgun.tga");
meshList[GEO_PROJECTILE_BULLET] = MeshBuilder::GenerateQuad("bullet", Color(0, 0, 0), 1.f);
meshList[GEO_PROJECTILE_BULLET]->textureArray[0] = LoadTGA("Image//bullet_icon.tga");
meshList[GEO_PROJECTILE_HOOK] = MeshBuilder::GenerateQuad("hook", Color(0, 0, 0), 1.f);
meshList[GEO_PROJECTILE_HOOK]->textureArray[0] = LoadTGA("Image//hook_icon.tga");
meshList[GEO_PROJECTILE_TRAP] = MeshBuilder::GenerateQuad("trap", Color(0, 0, 0), 1.f);
meshList[GEO_PROJECTILE_TRAP]->textureArray[0] = LoadTGA("Image//trap_icon.tga");
meshList[GEO_UI_BACKGROUND] = MeshBuilder::GenerateQuad("UI_background", Color(0, 0, 0), 1.f);
meshList[GEO_UI_BACKGROUND]->textureArray[0] = LoadTGA("Image//UI_background.tga");
InitSceneSnake();
InitSceneDetlaff();
InitSceneSummoner();
InitSceneGolem();
InitMainMenu();
}
void MeshManager::InitSceneDetlaff()
{
meshList[GEO_DETLAFF_1] = MeshBuilder::GenerateOBJ("DETLAFF", "obj\\snake_body.obj");
meshList[GEO_DETLAFF_1]->enableLight = true;
meshList[GEO_DETLAFF_1]->material.kAmbient.Set(0.4f, 0.4f, 0.4f);
meshList[GEO_DETLAFF_1]->material.kDiffuse.Set(0.4f, 0.4f, 0.4f);
meshList[GEO_DETLAFF_1]->material.kSpecular.Set(0.4f, 0.4f, 0.4f);
meshList[GEO_DETLAFF_1]->textureArray[0] = LoadTGA("Image//Detlaff_TGA//deathstar.tga");
}
void MeshManager::InitSceneSnake()
{
meshList[GEO_SCENESNAKE_WALLS] = MeshBuilder::GenerateCube("SceneSnake_walls", Color(0.4f, 0.4f, 0.4f));
meshList[GEO_SCENESNAKE_WALLS]->enableLight = true;
meshList[GEO_SCENESNAKE_WALLS]->material.kAmbient.Set(0.4f, 0.4f, 0.4f);
meshList[GEO_SCENESNAKE_WALLS]->material.kDiffuse.Set(0.4f, 0.4f, 0.4f);
meshList[GEO_SCENESNAKE_WALLS]->material.kSpecular.Set(0.4f, 0.4f, 0.4f);
meshList[GEO_SNAKE_HEAD] = MeshBuilder::GenerateOBJ("snake_head", "Obj\\snake_head.obj");
meshList[GEO_SNAKE_HEAD]->enableLight = true;
meshList[GEO_SNAKE_HEAD]->textureArray[0] = LoadTGA("Image//snake_head.tga");
meshList[GEO_SNAKE_BODY] = MeshBuilder::GenerateOBJ("snake_body", "Obj\\snake_body.obj");
meshList[GEO_SNAKE_BODY]->enableLight = true;
meshList[GEO_SNAKE_BODY]->textureArray[0] = LoadTGA("Image//snake_body.tga");
}
void MeshManager::InitSceneSummoner()
{
meshList[GEO_SUMMONER] = MeshBuilder::GenerateOBJ("summoner", "Obj\\summoner.obj");
meshList[GEO_SUMMONER]->enableLight = true;
meshList[GEO_SUMMONER]->textureArray[0] = LoadTGA("Image//summoner.tga");
meshList[GEO_SUMMONS] = MeshBuilder::GenerateOBJ("summoner", "Obj\\summons.obj");
meshList[GEO_SUMMONS]->enableLight = true;
}
void MeshManager::InitSceneGolem()
{
meshList[GEO_GOLEMHEAD] = MeshBuilder::GenerateOBJ("GEO_GOLEMHEAD", "Obj//golemheadhand.obj");
meshList[GEO_GOLEMHEAD]->textureArray[0] = LoadTGA("Image//outUV.tga");
meshList[GEO_GOLEMHAND] = MeshBuilder::GenerateOBJ("GEO_GOLEMHAND", "Obj//golemheadhand.obj");
meshList[GEO_GOLEMHAND]->textureArray[0] = LoadTGA("Image//outUV2.tga");
}
void MeshManager::InitMainMenu()
{
//menu
meshList[GEO_MENU_CURSOR] = MeshBuilder::GenerateQuad("GEO_MENU_CURSOR", Color(0, 0, 0), 1.f);
meshList[GEO_MENU_CURSOR]->textureArray[0] = LoadTGA("Image//menucursor.tga");
meshList[GEO_MENU_BACKGROUND] = MeshBuilder::GenerateQuad("GEO_MENU_BACKGROUND", Color(0, 0, 0), 1.f);
meshList[GEO_MENU_BACKGROUND]->textureArray[0] = LoadTGA("Image//background1.tga");
meshList[GEO_MENU_CHOICEBOX] = MeshBuilder::GenerateQuad("GEO_MENU_CHOICEBOX", Color(0, 0, 0), 1.f);
meshList[GEO_MENU_CHOICEBOX]->textureArray[0] = LoadTGA("Image//choicebox.tga");
meshList[GEO_MENU_SELECTION] = MeshBuilder::GenerateQuad("GEO_MENU_SELECTION", Color(0, 0, 0), 1.f);
meshList[GEO_MENU_SELECTION]->textureArray[0] = LoadTGA("Image//selected.tga");
meshList[GEO_MENU_FRAME] = MeshBuilder::GenerateQuad("GEO_MENU_FRAME", Color(0, 0, 0), 1.f);
meshList[GEO_MENU_FRAME]->textureArray[0] = LoadTGA("Image//framemetal.tga");
meshList[GEO_MENU_LVLSELECT] = MeshBuilder::GenerateQuad("GEO_MENU_LVLSELECT", Color(0, 0, 0), 1.f);
meshList[GEO_MENU_LVLSELECT]->textureArray[0] = LoadTGA("Image//levelselectbg.tga");
}
|
7de0ada6c8d4d5d81910664510adabe69db5baff
|
90a79e8e00a315b7ae5b578e0761d1be32d9d0e3
|
/FloatingText.cpp
|
8b2b90799e23a8d462b1cef1c1f57fc880a0b764
|
[
"MIT"
] |
permissive
|
matthias-christen/CdCoverCreator
|
bbe3043cdcedd87181ec14d8c532562af672c67a
|
edb223c2cf33ab3fb72d84ce2a9bce8500408c2a
|
refs/heads/master
| 2021-01-10T07:25:38.485319
| 2016-02-13T11:56:36
| 2016-02-13T11:56:36
| 51,643,109
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,826
|
cpp
|
FloatingText.cpp
|
#include "StdAfx.h"
#include "floatingtext.h"
#include "MainFrm.h"
IMPLEMENT_DYNCREATE(CFloatingText, CFloatingGraphicsObject)
CFloatingText::CFloatingText(void)
{
// create the RTF
m_pFormattedText = new CFormattedTextDraw ();
m_pFormattedText->Create ();
m_nContextMenuID = IDR_MENU_FLOATINGTEXT;
}
CFloatingText::~CFloatingText(void)
{
delete m_pFormattedText;
}
void CFloatingText::Render (CRenderDC rdc, RenderType rt, CRect rectRender, bool bIsPrinting)
{
m_pFormattedText->put_Height (m_dHeight * 1000);
m_pFormattedText->Draw (rdc.m_pDC->GetSafeHdc (), &rectRender);
}
bool CFloatingText::Edit (CAutoRichEditCtrl* pEditCtrl)
{
pEditCtrl->MoveWindow (&m_tracker.m_rect);
pEditCtrl->ShowWindow (SW_SHOW);
BSTR bstrRTF;
m_pFormattedText->get_RTFText (&bstrRTF);
CString strRTF (bstrRTF);
pEditCtrl->SetRTF (strRTF);
pEditCtrl->SetFocus ();
// attach the control to the RTF toolbar
((CMainFrame*) AfxGetMainWnd ())->m_wndRTFToolbar.SetRTFControl (pEditCtrl);
return true;
}
void CFloatingText::EndEdit (CAutoRichEditCtrl* pEditCtrl)
{
pEditCtrl->ShowWindow (SW_HIDE);
BSTR bstrText = pEditCtrl->GetRTF ().AllocSysString ();
m_pFormattedText->put_RTFText (bstrText);
::SysFreeString (bstrText);
// detach the control from the RTF toolbar
((CMainFrame*) AfxGetMainWnd ())->m_wndRTFToolbar.SetRTFControl (NULL);
}
void CFloatingText::Serialize (CArchive& ar)
{
CFloatingGraphicsObject::Serialize (ar);
if (ar.IsStoring ())
{
BSTR bstrText;
m_pFormattedText->get_RTFText (&bstrText);
CString strText (bstrText);
ar << strText;
}
else
{
CString strText;
ar >> strText;
BSTR bstrText = strText.AllocSysString ();
m_pFormattedText->put_RTFText (bstrText);
::SysFreeString (bstrText);
}
}
|
19a8c8fe45c8b125572272b6dfee095dca862b3a
|
0b8237f747576dce33a7641bb145da55a3018cb2
|
/lab4_question4.cpp
|
51234d8bbac5042df9d89d790a004193b2e5c6ad
|
[] |
no_license
|
solarstorm123/Assignment-4
|
1add0cb19ed695ec5f67b4d4a20e31bf00de0f87
|
7801ac925865a9f933440dc0d972627472828503
|
refs/heads/master
| 2021-06-28T03:46:52.274006
| 2017-09-15T18:14:20
| 2017-09-15T18:14:20
| 103,686,945
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 372
|
cpp
|
lab4_question4.cpp
|
#include <iostream>
using namespace std;
void even(int x)
{
if (x>=0)
{
if(x%2==0)
cout<<"the number is even.";
else {cout<<"the number is odd.";}
}
else{cout<<"entered number is invalid."; }
}
int main()
{
int x;
cout<<"enter a positive integer."<<endl;
cin>>x;
even(x);
return 0;
}
|
00b49179ac0be62c3919c8d5b6b9d7f19e170165
|
d8e7a11322f6d1b514c85b0c713bacca8f743ff5
|
/7.6.00.37/V76_00_37/MaxDB_ORG/sys/src/SAPDB/DBM/Srv/SharedMemory/DBMSrvShM_BaseUnlocker.cpp
|
f3da1e2c7bd6e1eb9dcf85a0fa1e0726fee91a43
|
[] |
no_license
|
zhaonaiy/MaxDB_GPL_Releases
|
a224f86c0edf76e935d8951d1dd32f5376c04153
|
15821507c20bd1cd251cf4e7c60610ac9cabc06d
|
refs/heads/master
| 2022-11-08T21:14:22.774394
| 2020-07-07T00:52:44
| 2020-07-07T00:52:44
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 2,256
|
cpp
|
DBMSrvShM_BaseUnlocker.cpp
|
/*!
@file DBMSrvShM_BaseUnlocker.cpp
@author MarcW
@brief Base class for shared memory - for unlocking
========== licence begin GPL
Copyright (c) 2003-2005 SAP AG
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
========== licence end
*/
#include "SAPDB/DBM/Srv/SharedMemory/DBMSrvShM_BaseUnlocker.hpp"
DBMSrvShM_BaseUnlocker* DBMSrvShM_BaseUnlocker::getInstance(const char* infoFile, const char* dataFile, DBMSrvMsg_Error& errOut) {
DBMSrvShM_BaseUnlocker* newInstance(NULL);
newInstance = new DBMSrvShM_BaseUnlocker();
if( newInstance == NULL )
errOut.Overrule(DBMSrvMsg_Error(SDBMSG_DBMSRV_MEM));
else
newInstance->deferredConstructor(infoFile, dataFile, errOut);
return newInstance;
}
DBMSrvShM_BaseUnlocker::DBMSrvShM_BaseUnlocker()
: DBMSrvShM_Base() {
}
bool DBMSrvShM_BaseUnlocker::deferredConstructor( const char* infoFile, const char* dataFile, DBMSrvMsg_Error &errOut ) {
if( !minimalInit(dataFile, errOut) )
return false;
calculateInfoSize();
m_pInfoShm = openSharedMemory(infoFile, m_SizeInfoShm, errOut);
if( m_pInfoShm == NULL ) {
errOut.Overrule(DBMSrvMsg_Error(SDBMSG_DBMSRV_SHMNOUNLOCKER));
}
else {
setPointersIntoInfo();
m_IsValid = true;
}
return m_IsValid;
}
DBMSrvShM_BaseUnlocker::~DBMSrvShM_BaseUnlocker() {
m_IsValid = false;
}
bool DBMSrvShM_BaseUnlocker::forceUnlock(DBMSrvMsg_Error& errOut) {
m_pSpinlock->Unlock();
m_pBackinglock->Unlock();
return true;
}
|
6084834df994f58f09ec7c7fd672387140601e96
|
6351ecaa77af56efefd72c7bd2250801dabb6679
|
/quadrat_avatar/Zwischenstand/zeichenfeld.h
|
977c11acacdbf2cece69d49afae3cf6e372432ad
|
[] |
no_license
|
SoerenPoeschel/Qt-exam_game
|
43b601e6ec5d6e681e0543a0dcad7b0e00745051
|
1f4b8b5dbd8042f597886d1f0eff1d71708a4e8b
|
refs/heads/master
| 2020-03-30T23:27:23.827973
| 2018-10-10T16:36:09
| 2018-10-10T16:36:09
| 151,700,750
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 383
|
h
|
zeichenfeld.h
|
#include <vector>
using namespace std;
#include <QWidget>
class zeichenFeld : public QWidget
{
// Q_OBJECT
public:
zeichenFeld(QWidget *parent = 0);
~zeichenFeld();
private:
//vector<QRect *> rects; unnรถรถtig, weil dumm
vector<QPoint *> points;
int playerX;
protected:
void paintEvent(QPaintEvent *event);
void keyPressEvent(QKeyEvent *event);
};
|
b0c70bc7c38bc506e4f542122ae80b910b0fe719
|
665cb80fdede0487e0a4635e0585d7eb9d2d8fb5
|
/programa9.cc
|
d08f004be97e1d0617128e22e63148ede09e4bc0
|
[] |
no_license
|
FisicaComputacionalI/20171031-clase-anyyanel
|
74a5e955212ce87b33857c6ccee734149ac5bfc8
|
fede863de360e3723e5c29a9c6c15d8b79745f38
|
refs/heads/master
| 2021-05-07T21:39:06.631722
| 2017-10-31T19:56:43
| 2017-10-31T19:56:43
| 109,043,075
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 593
|
cc
|
programa9.cc
|
//Any Yanel Morales Guevara
//Calculando la edad promedio en que se graduara el grupo
#include <vector>
#include <iostream>
using namespace std;
int main(){
size_t talla=16;
vector<int> edad(talla);
int sum=0;
for(int i=0; i<talla; i++){
cout <<"Que edad tienes?"<<endl;
cin>> edad[i];
}
for (int j=0;j<talla; j++)
sum+=(edad[j]+3);
for (int j=0; j<talla; j++)
cout<<edad[j]<<",";
cout<<endl;
cout<<"El promedio de edad a la que se graduara este grupo es"<<sum/16<<endl;
return 0;
}
|
3576f007d15194ea18137d05262da947b35b6352
|
1f3ec3476070503417a626ed1fe9fb2d9bacfd21
|
/ignoredfilesdialog.cpp
|
00ab431b7ca17a49349b50c28d9516bb78f31192
|
[
"MIT"
] |
permissive
|
geotavros/VpkCompare
|
273dc0ce973b10f549468f226ec8a267131c6bfd
|
c988efb8f3f5e4bf506e0061645f2feb44cb946d
|
refs/heads/master
| 2021-01-17T08:00:41.013621
| 2016-07-04T16:04:46
| 2016-07-04T16:04:46
| 25,733,681
| 9
| 2
| null | 2016-07-04T16:04:47
| 2014-10-25T14:14:58
|
C++
|
UTF-8
|
C++
| false
| false
| 1,493
|
cpp
|
ignoredfilesdialog.cpp
|
#include "ignoredfilesdialog.h"
#include "ui_ignoredfilesdialog.h"
#include "addignoredfiledialog.h"
IgnoredFilesDialog::IgnoredFilesDialog(QWidget *parent, QStringList ignore_list) :
QDialog(parent),
ui(new Ui::IgnoredFilesDialog)
{
ui->setupUi(this);
for (int i = 0; i < ignore_list.size(); ++i)
{
QListWidgetItem *item = new QListWidgetItem(ignore_list[i]);
item->setFlags(item->flags() | Qt::ItemIsEditable);
ui->ignore_list->addItem(item);
}
//ui->ignore_list->insertItems(0, ignore_list);
}
IgnoredFilesDialog::~IgnoredFilesDialog()
{
delete ui;
}
QStringList IgnoredFilesDialog::ignoreList() const
{
QStringList result;
for (int i = 0; i < ui->ignore_list->count(); ++i)
{
result.append(ui->ignore_list->item(i)->text());
}
return result;
}
void IgnoredFilesDialog::on_add_clicked()
{
AddIgnoredFileDialog dialog(this);
//connect(dialog_, SIGNAL(accepted()), this, SLOT(on_addignoredfiledialog_accepted()));
if (QDialog::Accepted == dialog.exec())
{
if (!dialog.filename().isEmpty())
{
QListWidgetItem *item = new QListWidgetItem(dialog.filename());
item->setFlags(item->flags() | Qt::ItemIsEditable);
ui->ignore_list->addItem(item);
//ui->ignore_list->addItem(dialog.filename());
}
}
}
void IgnoredFilesDialog::on_remove_clicked()
{
delete ui->ignore_list->takeItem(ui->ignore_list->currentRow());
}
|
8f9c2482454015dbd2aabfaf32b9841d33181660
|
6276ee99caf2a4bfd5adeefa4e815a30b220075e
|
/algospot/์ง๋ฐ๋ธ์จ.cpp
|
1fea2ed6ca2a40e0cccfc0ddd2a93ae69bd72670
|
[] |
no_license
|
RokwonK/Problem_solving
|
ba95b71aac0567e1d321484d2ffd9809c8b6654e
|
92bf77b93fcbe9102a18fc30a9d539276b06ffc5
|
refs/heads/master
| 2022-12-05T00:10:21.709831
| 2020-08-13T05:44:17
| 2020-08-13T05:44:17
| 210,171,514
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,979
|
cpp
|
์ง๋ฐ๋ธ์จ.cpp
|
#include<iostream>
#include<cstring>
#include<string>
#include<vector>
#include<map>
#include<algorithm>
using namespace std;
const int MOD = 1000*1000*1000+7;
long long e;
string str_e, sort_e;
int m, n;
int dp[1 << 15][20][2];
// less๊ฐ 0์ด๋ฉด ์์ง ๊ธฐ์กด e๋ณด๋ค ํฐ์ง ์์์ง ๋ชจ๋ฅธ๋ค๋ ๊ฑฐ
int solve(int index, int taken, int mod, int less) {
if (index == n)
return (less && mod == 0) ? 1 : 0;
//๊ฐ ์๋ฆฌ์๋ฅผ ์ฌ์ฉํ๋์ง, ๋๋จธ์ง๊ฐ ๋ช์ธ์ง, ๋ณธ๋ ๊ฐ๋ณด๋ค ํฐ์ง์์์ง,
int &value = dp[taken][mod][less];
if (value != -1) return value;
value = 0;
for (int i = 0; i < n; i++) {
// ์์ง ์ฌ์ฉํ์ง ์์ ๊ฒ๋ง
if ( (taken & (1 << i)) == 0) {
// ๋ณธ๋ ๊ฐ๋ณด๋ค ์๋ค๊ณ ํ๋ช
๋์ง ์์ ๊ณณ์์ ํ ๊ฐ์ด ๋ ํฌ๋ค๋ฉด
if (less == 0 && str_e[index] < sort_e[i]) continue;
// ๊ฐ์ ์๊ฐ ์๋ค๋ฉด ์ ์๊บผ๋ถํฐ ์ฌ์ฉํ๊ฒ ํ๊ธฐ ์ํ ๊ฒ(๊ทธ๋์ผ ๊ฐ์์๊ฐ ์์ด๋ ๊ฒ์ ๋ฐฉ์งํจ)
if (i > 0 && sort_e[i-1] == sort_e[i] && (taken & (1 << (i-1)))==0 ) continue;
// ์ด๋ฒ ๊ฐ์ ์ฌ์ฉํ ๊ฒ์ด๋ ์ฌ์ฉํ๋ค๊ณ ํ๊ธฐ
int nexttaken = taken | (1 << i);
// ๋๋จธ์ง ๊ฐ์ ์ต์ ํ
int nextmod = (mod*10 + (sort_e[i]-'0')) % m;
// ์ด์ ๋ค์ ๋ณธ๋๊ฐ๋ณด๋ค ํฐ์ง ์ํฐ์ง ํ์ธ
int nextless = less || str_e[index] > sort_e[i];
value = ( value + solve(index+1, nexttaken, nextmod, nextless) ) % MOD;
}
}
return value;
}
int main(void) {
ios_base::sync_with_stdio(0);
cin.tie(0);
int T;
cin >> T;
while(T--) {
memset(dp,-1,sizeof(dp));
cin >> e >> m;
str_e = to_string(e);
sort_e = to_string(e);
n = str_e.size();
sort(sort_e.begin(), sort_e.end());
cout << solve(0, 0, 0, 0) <<'\n';
}
return 0;
}
|
253e352a934b57a7b2b3c24b225a24e54b42aeed
|
cf49d925f90fbfd894478ecfd57cc49e1c90bc1c
|
/src/graphing_strategy.cpp
|
86d4e481c2bcdf6b8c4c2a65ad9ada2ca7fac262
|
[] |
no_license
|
P-Dhruv20/Graphing-Calculator
|
e941c1574971d81628b0f66e534aa50a1252a568
|
7687983192cccfb295c7dd5dc92db273d11e85a9
|
refs/heads/master
| 2023-04-24T11:13:47.205050
| 2021-04-16T06:38:38
| 2021-04-16T06:38:38
| 356,142,199
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 3,510
|
cpp
|
graphing_strategy.cpp
|
#include "../header/graphing_strategy.hpp"
#include <iostream>
#include <string>
#include <vector>
using namespace std;
void GraphingStrategy::execute() {
this->getUserInput();
while (this->inputIsValid(this->user_expression) == 0) {
cout << "INVALID INPUT" << endl;
this->getUserInput();
}
this->graph();
}
void GraphingStrategy::getUserInput() {
cout << "Enter your function (with variable x): ";
cin >> this->user_expression;
}
int GraphingStrategy::inputIsValid(string str) {
int variable_flag = 0;
for(int i = 0; i < str.size(); i++) {
str.at(i) = toupper(str.at(i));
}
vector<char> brackets;
int operand_count = 0;
int operator_count = 0;
for (unsigned int i = 0; i < str.size(); i++) {
char c = str.at(i);
if (!isspace(c)) {
if (isdigit(c)) {
operand_count++;
while((i+1) != str.size() && isdigit(str.at(i+1))) {
i++;
}
}
else if(c == '+' || c == '-' || c == '*'|| c == '/' || c == '^') {
operator_count++;
}
else if(c == '(' || c == '{' || c == '[') {
brackets.push_back(c);
}
else if(c == ')' || c == '}' || c == ']') {
char prev = brackets.back();
if ((c == ')' && prev == '(') ||
(c == '}' && prev == '{') ||
(c == ']' && prev == '[')) {
brackets.pop_back();
}
}
else if (c == '!') {
if((i-1) != 0) {
char prev = str.at(i - 1);
if(!isdigit(prev) &&
!(prev == ')' || prev == ']' || prev == '}')) {
return 0;
}
}
else {
return 0;
}
}
else if(!isalpha(c)) {
return 0;
}
else {
if(c == 'X') {
operand_count++;
variable_flag++;
}
else if ((c != 'C') && (c != 'T') && (c != 'S')) {
return 0;
}
else if(c == 'C' && str.find("COS") == string::npos) {
return 0;
}
else if (c == 'T' && str.find("TAN") == string::npos) {
return 0;
}
else if (c == 'S' && str.find("SIN") == string::npos) {
return 0;
}
else {
i+=2;
if (i < str.size()) {
if(c == 'C' && str.at(i) != 'S') {
return 0;
}
else if (c == 'T' && str.at(i) != 'N') {
return 0;
}
else if (c == 'S' && str.at(i) != 'N') {
return 0;
}
}
else {
return 0;
}
}
}
}
}
if (operand_count != (operator_count+1)) {
return 0;
}
else if (brackets.size() != 0) {
return 0;
}
else if (variable_flag != 1) {
return 0;
}
return 1;
}
void GraphingStrategy::graph() {
cout << "TODO: GRAPHING STRATEGY graph()";
}
|
3ec99e1af73a4c65b0d6a5edb20af475ab5f8fc2
|
a33106f47736d22b737b342d7cbd5acc06fd9e8d
|
/src/textrender_frag.cpp
|
15e8ace445fc95a1a6a424bdedad2e60e8c154b3
|
[
"MIT"
] |
permissive
|
0xABAD/glTools
|
0921f2c4b9c0398b33d7efe7013a5e71907f7771
|
e16a3fc18abb0b40cd40419fb081cf9a465674db
|
refs/heads/master
| 2021-05-29T17:26:12.271943
| 2015-08-23T22:34:15
| 2015-08-23T22:35:04
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,807
|
cpp
|
textrender_frag.cpp
|
// This file was generated by codegen.py
// --null set -- 0x00 is appended at the end of the array
#include <glt/textrender_frag.hpp>
std::array<char, 285> glt::textrender_frag = {
0x23,0x76,0x65,0x72, 0x73,0x69,0x6f,0x6e, 0x20,0x34,0x35,0x30, 0x0d,0x0a,0x0d,0x0a,
0x69,0x6e,0x20,0x76, 0x65,0x63,0x32,0x20, 0x54,0x65,0x78,0x43, 0x6f,0x6f,0x72,0x64,
0x3b,0x0d,0x0a,0x0d, 0x0a,0x6c,0x61,0x79, 0x6f,0x75,0x74,0x20, 0x28,0x6c,0x6f,0x63,
0x61,0x74,0x69,0x6f, 0x6e,0x20,0x3d,0x20, 0x30,0x29,0x20,0x6f, 0x75,0x74,0x20,0x76,
0x65,0x63,0x34,0x20, 0x46,0x72,0x61,0x67, 0x43,0x6f,0x6c,0x6f, 0x72,0x3b,0x0d,0x0a,
0x0d,0x0a,0x6c,0x61, 0x79,0x6f,0x75,0x74, 0x20,0x28,0x62,0x69, 0x6e,0x64,0x69,0x6e,
0x67,0x20,0x3d,0x20, 0x30,0x29,0x20,0x75, 0x6e,0x69,0x66,0x6f, 0x72,0x6d,0x20,0x73,
0x61,0x6d,0x70,0x6c, 0x65,0x72,0x32,0x44, 0x20,0x42,0x69,0x74, 0x6d,0x61,0x70,0x3b,
0x0d,0x0a,0x0d,0x0a, 0x75,0x6e,0x69,0x66, 0x6f,0x72,0x6d,0x20, 0x76,0x65,0x63,0x34,
0x20,0x54,0x65,0x78, 0x74,0x43,0x6f,0x6c, 0x6f,0x72,0x3b,0x0d, 0x0a,0x0d,0x0a,0x76,
0x6f,0x69,0x64,0x20, 0x6d,0x61,0x69,0x6e, 0x28,0x29,0x0d,0x0a, 0x7b,0x0d,0x0a,0x09,
0x76,0x65,0x63,0x34, 0x20,0x74,0x65,0x78, 0x65,0x6c,0x20,0x3d, 0x20,0x74,0x65,0x78,
0x74,0x75,0x72,0x65, 0x28,0x42,0x69,0x74, 0x6d,0x61,0x70,0x2c, 0x20,0x54,0x65,0x78,
0x43,0x6f,0x6f,0x72, 0x64,0x29,0x3b,0x0d, 0x0a,0x0d,0x0a,0x09, 0x69,0x66,0x20,0x28,
0x74,0x65,0x78,0x65, 0x6c,0x2e,0x72,0x20, 0x3d,0x3d,0x20,0x30, 0x2e,0x30,0x66,0x29,
0x0d,0x0a,0x09,0x09, 0x64,0x69,0x73,0x63, 0x61,0x72,0x64,0x3b, 0x0d,0x0a,0x0d,0x0a,
0x09,0x46,0x72,0x61, 0x67,0x43,0x6f,0x6c, 0x6f,0x72,0x20,0x3d, 0x20,0x54,0x65,0x78,
0x74,0x43,0x6f,0x6c, 0x6f,0x72,0x3b,0x0d, 0x0a,0x7d,0x0d,0x0a,0x00
};
|
e291f3a68adb81970e0b35cabfcdafd94b0d4817
|
abb3b337d6dfe090d46860e72107356cb16fa128
|
/HRobotPressureSensorPrivateBase.h
|
2474a012955e7610830829950adf5ba5d1cdb43b
|
[] |
no_license
|
a2824256/URtest
|
6bb5a976ef4e4ad10f731e3bb3c685fae79465ce
|
126991886e415e0a4702a36e85207f37c408ffd1
|
refs/heads/master
| 2023-03-21T00:34:58.543229
| 2021-03-02T07:44:11
| 2021-03-02T07:44:11
| 343,687,406
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 706
|
h
|
HRobotPressureSensorPrivateBase.h
|
#ifndef HROBOTPRESSURESENSORPRIVATEBASE_H
#define HROBOTPRESSURESENSORPRIVATEBASE_H
#include <QObject>
typedef struct HPressureInfoStruct {
double ForceX;
double ForceY;
double ForceZ;
double TorqueX;
double TorqueY;
double TorqueZ;
} HPressureInfo;
class HRobotPressureSensorPrivateBase : public QObject
{
Q_OBJECT
public:
HRobotPressureSensorPrivateBase();
virtual ~HRobotPressureSensorPrivateBase();
// virtual HPressureInfo GetPressureSensorInfo() = 0;
virtual void SetNeedToCalibration(bool bCalibration) = 0;
// virtual void Check() = 0 ;
signals:
void SigPressureInfo(double x,double y,double z);
};
#endif // HROBOTPRESSURESENSORPRIVATEBASE_H
|
e6161e8c2b1e2a8e7b7454a578b5844cb1fcd222
|
d2af2477ac51fca468ea1e311a768dd6eaa30c3a
|
/super-knowledge-platform/skpServer/trunk/src/core/skpEventObject_p.h
|
fca87bf8d287da8ce5620d9c4cdc448b348d6c5b
|
[
"MIT"
] |
permissive
|
yefy/skp
|
35f43fe8312a4418ae19e5eb4df08509753f6c5d
|
a9fafa09eacd6a0a802ea6550efd30ace79e4a4f
|
refs/heads/master
| 2021-01-10T01:06:11.511514
| 2016-04-07T08:15:06
| 2016-04-07T08:15:06
| 54,396,970
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 571
|
h
|
skpEventObject_p.h
|
#ifndef SKPEVENTOBJECT_P_H
#define SKPEVENTOBJECT_P_H
#include "skpObject_p.h"
#include "skpEventObject.h"
enum EventType
{
EventTypeInit = 0,
EventTypeStart,
EventTypeStop,
EventTypeFree,
};
class SkpEventObjectPrivate : public SkpObjectPrivate
{
public:
SkpEventObjectPrivate();
virtual ~SkpEventObjectPrivate();
private:
SKP_DECLARE_PUBLIC(SkpEventObject);
private:
SkpMutex m_mutex;
std::vector<int> m_in;
std::vector<int> m_out;
protected:
int m_currType;
void *m_data;
int64 m_time;
};
#endif // SKPEVENTOBJECT_P_H
|
714a859bf277f7808aef38746eda53cc291fe443
|
87b516fa18600233bee4a0afee7f6db62c133aff
|
/Practicaa1.10.cpp
|
496c96d4a9e0853d67dd4c80be96a2468d74b560
|
[] |
no_license
|
NachoCesa/UTN-C-
|
1999207bb82a83ab08f9a81f48fee27b922f3196
|
a17221c3d35c3b5d7787db3cf8b3ba464328ace5
|
refs/heads/master
| 2022-11-23T16:48:18.206851
| 2020-07-05T11:53:08
| 2020-07-05T11:53:08
| null | 0
| 0
| null | null | null | null |
WINDOWS-1250
|
C++
| false
| false
| 1,860
|
cpp
|
Practicaa1.10.cpp
|
//============================================================================
// Name : 10.cpp
// Author :
// Version :
// Copyright : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================
#include <iostream>
#include <stdlib.h>
#include <string>
using namespace std;
int main() {
cout << "Ingresar todas las fechas solicitadas en el siguiente formato: aaaammdd" << endl;
cout << "Ingresar la fecha de hoy: " << endl;
int fechahoy;
fechahoy = 0;
cin >> fechahoy;
cout << "Ingresar la primera fecha deseada: " << endl;
int fecha1;
fecha1 = 0;
cin >> fecha1;
cout << "Ingresar la segunda fecha deseada: " << endl;
int fecha2;
fecha2 = 0;
cin >> fecha2;
int d1;
d1= ((fechahoy/10000)*365)+(((fechahoy%10000)-(fechahoy%100))/100)+(fechahoy%100);
if((fechahoy/10000)%4==0){
if((fechahoy/10000)%100==0 and (fechahoy/10000)%400!=0 ){
}else{
d1=d1+1;
}
}else{
}
int d2;
d2= ((fecha1/10000)*365)+(((fecha1%10000)-(fecha1%100))/100)+(fecha1%100);
if((fecha1/10000)%4==0){
if((fecha1/10000)%100==0 and (fecha1/10000)%400!=0 ){
}else{
d2=d2+1;
}
}else{
}
int a;
a=fechahoy-fecha1;
int a1;
a1= abs(a);
int d3;
d3= ((fecha2/10000)*365)+(((fecha2%10000)-(fecha2%100))/100)+(fecha2%100);
if((fecha2/10000)%4==0){
if((fecha2/10000)%100==0 and (fecha2/10000)%400!=0 ){
}else{
d3=d3+1;
}
}else{
}
int b;
b=fechahoy-fecha2;
int b1;
b1=abs(b);
if(a1>b1){
cout << "La segunda fecha es la mรกs cercana a hoy." << endl;
}
else{
cout << "La primera fecha es la mรกs cercana a hoy." << endl;
}
return 0;
}
|
94687125c64e0f96c291a23650566bd464020d00
|
45eb0e938381864209dbab8df0564a5c2677821b
|
/sqlexec/sqlexec/sqlitedb.h
|
c5bbcf1dd900c266e8210721853fa64dd0cadb8c
|
[
"Apache-2.0"
] |
permissive
|
vocky/NDSPoi
|
3a79d5ea0683e4d0188af79487f4bb7e4cbbd54a
|
7f1ea50d6fe8e8d4874cfa080881fd6bdb66fa9e
|
refs/heads/master
| 2021-08-30T04:40:11.706417
| 2017-12-16T02:45:38
| 2017-12-16T02:45:38
| 114,427,033
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,515
|
h
|
sqlitedb.h
|
#ifndef SQLITE_DATA_BASE_H
#define SQLITE_DATA_BASE_H
#include "sqlite3.h"
#include <string>
#include "cursor.h"
#include <vector>
#include <stdint.h>
namespace search {
class SqliteDB {
public:
SqliteDB();
SqliteDB(const SqliteDB& db);
SqliteDB& operator=(const SqliteDB& db);
~SqliteDB();
public:
/**
* @brief open database connect
* path: database file
*/
bool Open(const char* path);
/**
* @brief create database
* path: database file
*/
bool CreateDB(const std::string& path);
/**
* @brief exec sql, not use for query
**/
bool ExecSql(const std::string& sql);
/**
* @brief query action.
**/
bool Query(const char* sql, Cursor* cursor);
bool Query(const std::string& sql, const std::vector<std::string>& params, Cursor* cursor);
/**
*@brief insert sql
*/
bool insert(const std::string& sql);
bool insert(const std::string& sql, const std::vector<std::string>& params);
sqlite3_stmt * prepare(const std::string& sql);
void bind_int(sqlite3_stmt* stmt, int index, int value){
sqlite3_bind_int(stmt, index, value);
}
void bind_int64(sqlite3_stmt* stmt, int index, int64_t value){
sqlite3_bind_int64(stmt, index, value);
}
void bind_blob(sqlite3_stmt* stmt, int index, char* value,int length){
sqlite3_bind_blob(stmt, index, value, length, NULL);
}
void bind_text(sqlite3_stmt* stmt, int index, char* value){
sqlite3_bind_text(stmt, index, value, -1, NULL);
}
bool Finalize(sqlite3_stmt *);
private:
sqlite3* db;
};
} //namespace search
#endif
|
d26bf13ed1aa0b19413906b317f4153d99d5b80b
|
6f224b734744e38062a100c42d737b433292fb47
|
/libc/test/src/string/memmove_test.cpp
|
57ab0d40d33eaafc8f4bb81b4dca082258e27ad9
|
[
"NCSA",
"LLVM-exception",
"Apache-2.0"
] |
permissive
|
smeenai/llvm-project
|
1af036024dcc175c29c9bd2901358ad9b0e6610e
|
764287f1ad69469cc264bb094e8fcdcfdd0fcdfb
|
refs/heads/main
| 2023-09-01T04:26:38.516584
| 2023-08-29T21:11:41
| 2023-08-31T22:16:12
| 216,062,316
| 0
| 0
|
Apache-2.0
| 2019-10-18T16:12:03
| 2019-10-18T16:12:03
| null |
UTF-8
|
C++
| false
| false
| 3,490
|
cpp
|
memmove_test.cpp
|
//===-- Unittests for memmove ---------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#include "src/string/memmove.h"
#include "memory_utils/memory_check_utils.h"
#include "src/__support/CPP/span.h"
#include "test/UnitTest/MemoryMatcher.h"
#include "test/UnitTest/Test.h"
using __llvm_libc::cpp::array;
using __llvm_libc::cpp::span;
namespace __llvm_libc {
TEST(LlvmLibcMemmoveTest, MoveZeroByte) {
char Buffer[] = {'a', 'b', 'y', 'z'};
const char Expected[] = {'a', 'b', 'y', 'z'};
void *const Dst = Buffer;
void *const Ret = __llvm_libc::memmove(Dst, Buffer + 2, 0);
EXPECT_EQ(Ret, Dst);
ASSERT_MEM_EQ(Buffer, testing::MemoryView(Expected));
}
TEST(LlvmLibcMemmoveTest, DstAndSrcPointToSameAddress) {
char Buffer[] = {'a', 'b'};
const char Expected[] = {'a', 'b'};
void *const Dst = Buffer;
void *const Ret = __llvm_libc::memmove(Dst, Buffer, 1);
EXPECT_EQ(Ret, Dst);
ASSERT_MEM_EQ(Buffer, testing::MemoryView(Expected));
}
TEST(LlvmLibcMemmoveTest, DstStartsBeforeSrc) {
// Set boundary at beginning and end for not overstepping when
// copy forward or backward.
char Buffer[] = {'z', 'a', 'b', 'c', 'z'};
const char Expected[] = {'z', 'b', 'c', 'c', 'z'};
void *const Dst = Buffer + 1;
void *const Ret = __llvm_libc::memmove(Dst, Buffer + 2, 2);
EXPECT_EQ(Ret, Dst);
ASSERT_MEM_EQ(Buffer, testing::MemoryView(Expected));
}
TEST(LlvmLibcMemmoveTest, DstStartsAfterSrc) {
char Buffer[] = {'z', 'a', 'b', 'c', 'z'};
const char Expected[] = {'z', 'a', 'a', 'b', 'z'};
void *const Dst = Buffer + 2;
void *const Ret = __llvm_libc::memmove(Dst, Buffer + 1, 2);
EXPECT_EQ(Ret, Dst);
ASSERT_MEM_EQ(Buffer, testing::MemoryView(Expected));
}
// e.g. `Dst` follow `src`.
// str: [abcdefghij]
// [__src_____]
// [_____Dst__]
TEST(LlvmLibcMemmoveTest, SrcFollowDst) {
char Buffer[] = {'z', 'a', 'b', 'z'};
const char Expected[] = {'z', 'b', 'b', 'z'};
void *const Dst = Buffer + 1;
void *const Ret = __llvm_libc::memmove(Dst, Buffer + 2, 1);
EXPECT_EQ(Ret, Dst);
ASSERT_MEM_EQ(Buffer, testing::MemoryView(Expected));
}
TEST(LlvmLibcMemmoveTest, DstFollowSrc) {
char Buffer[] = {'z', 'a', 'b', 'z'};
const char Expected[] = {'z', 'a', 'a', 'z'};
void *const Dst = Buffer + 2;
void *const Ret = __llvm_libc::memmove(Dst, Buffer + 1, 1);
EXPECT_EQ(Ret, Dst);
ASSERT_MEM_EQ(Buffer, testing::MemoryView(Expected));
}
// Adapt CheckMemmove signature to op implementation signatures.
static inline void Adaptor(cpp::span<char> dst, cpp::span<char> src,
size_t size) {
__llvm_libc::memmove(dst.begin(), src.begin(), size);
}
TEST(LlvmLibcMemmoveTest, SizeSweep) {
static constexpr int kMaxSize = 400;
static constexpr int kDenseOverlap = 15;
using LargeBuffer = array<char, 2 * kMaxSize + 1>;
LargeBuffer Buffer;
Randomize(Buffer);
for (int Size = 0; Size < kMaxSize; ++Size)
for (int Overlap = -1; Overlap < Size;) {
ASSERT_TRUE(CheckMemmove<Adaptor>(Buffer, Size, Overlap));
// Prevent quadratic behavior by skipping offset above kDenseOverlap.
if (Overlap > kDenseOverlap)
Overlap *= 2;
else
++Overlap;
}
}
} // namespace __llvm_libc
|
8014aeb8e0cfb5e039d2e7efce2fc09ffb93309d
|
ae8f225a8eec24ab59fab966833b1ec1a0dac070
|
/include/control_systems/Elevator.h
|
29f740c2f9abdcfedf11a06b8b0ed1fbc006d2cc
|
[] |
no_license
|
Team5712/DeepSpace_2019
|
434c2dcb6c9f2f99ed60a7a6823de962447a6db2
|
43efbe004a272c57fe3003cb7d29ee1fe0a569a9
|
refs/heads/master
| 2020-04-15T02:59:13.628234
| 2019-04-17T20:14:36
| 2019-04-17T20:14:36
| 164,331,482
| 1
| 1
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,159
|
h
|
Elevator.h
|
#ifndef SRC_CONTROL_SYSTEMS_ELEVATOR_H_
#define SRC_CONTROL_SYSTEMS_ELEVATOR_H_
#include <cmath>
#include <iostream>
#include "frc/WPILib.h"
#include "ctre/Phoenix.h"
#include "rev/CANSparkMax.h"
#include "AHRS.h"
using namespace std;
/**
* this class will implement many of the basic functionalities of our drive system
* into one convenient class with drive and turning options
*
*/
class Elevator
{
rev::CANSparkMax *elevator_master;
rev::CANSparkMax *elevator_slave;
AnalogPotentiometer *pot;
float max_height = 78;
public:
Elevator();
float getPosition();
void setPosition(float);
void setPower(float);
struct ElevatorPositions {
const float bottom = 5;
const float middle = 42;
const float top = 74;
const float cargo_offset = -5;
} positions;
struct elevator_pid {
float prev_error = 0;
float Kminoutput = -0.205;
float Kmaxoutput = 0.65;
float i_state = 0;
float Kp = 0.065;
float Ki = 0.0;
float Kd = 0.0;
float Kf = 0.0;
float i_zone = 0.0;
} pid;
};
#endif /* SRC_CONTROL_SYSTEMS_ELEVATOR_H_ */
|
1793e3d8bce5034d263893ce5263b8b1e2aaef75
|
f4fecbb45ef912e7f761fb95300e74d0a4598828
|
/pushlibrary/src/main/cpp/jni_bridge.cpp
|
7755bd255cd3289a13819ab609c4186f02d867d5
|
[] |
no_license
|
kmdai/Librtmp
|
08d302b3ce6e6588742782217f9373bd6ae9190a
|
79a15f50ddaf0106abcb1945b67c8a3aa5b38b2f
|
refs/heads/dev
| 2021-05-09T22:10:06.759366
| 2019-07-31T09:13:10
| 2019-07-31T09:13:10
| 118,743,680
| 4
| 2
| null | 2019-03-15T07:05:24
| 2018-01-24T09:35:06
|
C
|
UTF-8
|
C++
| false
| false
| 5,866
|
cpp
|
jni_bridge.cpp
|
//
// Created by kmdai on 18-4-19.
//
#include "push_rtmp.h"
#include "AudioRecordEngine.h"
#include "push_rtmp.h"
#include <functional>
#include <string>
extern "C" {
AudioRecordEnginePtr audioRecordEnginePtr;
#define SRS_ARRAY_ELEMS(a) (sizeof(a) / sizeof(a[0]))
#define JNI_CLS_MANAGER "com/kmdai/rtmppush/LibrtmpManager"
static JavaVM *javaVM;
media_config media_config_{0};
long frames{0};
static jboolean native_setUrl(JNIEnv *env, jobject instance, jstring url) {
const char *rtmp_url = env->GetStringUTFChars(url, JNI_FALSE);
int result = init_srs(rtmp_url);
if (!result) {
return JNI_FALSE;
}
set_framerate(media_config_.frame_rate);
set_VideoBitrate(media_config_.video_bit_rate);
set_Width(media_config_.width);
set_Height(media_config_.height);
set_AudioBitrate(media_config_.audio_bit_rate);
set_Channel(media_config_.channel_count);
set_Samplerate(media_config_.audio_sample_rate);
audioRecordEnginePtr->openRecordingStream();
rtmp_start(javaVM);
env->ReleaseStringUTFChars(url, rtmp_url);
return JNI_TRUE;
}
static void
native_addFrame(JNIEnv *env, jobject instance, jbyteArray data, jint size, jint type, jint flag,
jint time) {
jbyte *chunk = (jbyte *) malloc(size);
env->GetByteArrayRegion(data, 0, size, chunk);
auto n_type = NODE_TYPE_VIDEO;
if (type == 1) {
n_type = NODE_TYPE_AUDIO;
}
q_node_p node = create_node((char *) chunk, size, n_type, flag, time);
in_queue(node);
free(chunk);
}
static void native_init(JNIEnv *env, jobject instance, jstring name) {
const char *name_ = env->GetStringUTFChars(name, JNI_FALSE);
std::string name_s{name_};
audioRecordEnginePtr = createAudioRecordEnginePtr();
audioRecordEnginePtr->initCodec(media_config_.audio_sample_rate,
media_config_.channel_count,
media_config_.audio_bit_rate,
name_s,
[](uint8_t *data, uint32_t size, uint64_t time, int flag) {
q_node_p node = create_node((char *) data, size,
NODE_TYPE_AUDIO, flag, time);
LOGI("flag----:%d,time:%ld,size:%d", flag, time, size);
in_queue(node);
}
);
env->ReleaseStringUTFChars(name, name_);
}
static void native_release(JNIEnv *env, jobject instance) {
rtmp_destroy();
audioRecordEnginePtr->closeRecording();
}
static void native_setFrameRate(JNIEnv *env, jobject instance, jint framerate) {
media_config_.frame_rate = static_cast<uint32_t >(framerate);
}
static void native_setVideoBitRate(JNIEnv *env, jobject instance, jint videodatarate) {
media_config_.video_bit_rate = static_cast<uint32_t >(videodatarate);
}
static void native_setWidth(JNIEnv *env, jobject instance, jint width) {
media_config_.width = static_cast<uint32_t >(width);
}
static void native_setHeight(JNIEnv *env, jobject instance, jint height) {
media_config_.height = static_cast<uint32_t >(height);
}
static void native_setAudioBitrate(JNIEnv *env, jobject instance, jint audioBitrate) {
media_config_.audio_bit_rate = static_cast<uint32_t >(audioBitrate);
}
static void native_setChannelCount(JNIEnv *env, jobject instance, jint channel) {
media_config_.channel_count = static_cast<uint32_t >(channel);
}
static void native_setAudioSampleRate(JNIEnv *env, jobject instance, jint audiosamplerate) {
media_config_.audio_sample_rate = static_cast<uint32_t >(audiosamplerate);
}
/**
* ๆฌๅฐๅฝๆฐ
*/
const JNINativeMethod srs_methods[] = {
{"setUrl", "(Ljava/lang/String;)Z", (void *) native_setUrl},
{"release", "()V", (void *) native_release},
{"addFrame", "([BIIII)V", (void *) native_addFrame},
{"setFrameRate", "(I)V", (void *) native_setFrameRate},
{"setVideoBitRate", "(I)V", (void *) native_setVideoBitRate},
{"setChannelCount", "(I)V", (void *) native_setChannelCount},
{"setWidth", "(I)V", (void *) native_setWidth},
{"setHeight", "(I)V", (void *) native_setHeight},
{"setAudioBitrate", "(I)V", (void *) native_setAudioBitrate},
{"setAudioSampleRate", "(I)V", (void *) native_setAudioSampleRate},
{"init", "(Ljava/lang/String;)V", (void *) native_init}
};
/**
* ๅจๆๆณจๅๆฌๅฐๅฝๆฐ
* @param vm
* @param reserved
* @return
*/
JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void *reserved) {
javaVM = vm;
JNIEnv *jenv;
if (vm->GetEnv((void **) &jenv, JNI_VERSION_1_6) != JNI_OK) {
SRS_LOGE("Env not got");
return JNI_ERR;
}
jclass clz = jenv->FindClass(JNI_CLS_MANAGER);
if (clz == NULL) {
SRS_LOGE("JNI_OnLoad:Class %s not found", JNI_CLS_MANAGER);
return JNI_ERR;
}
if (jenv->RegisterNatives(clz, srs_methods, SRS_ARRAY_ELEMS(srs_methods))) {
SRS_LOGE("methods not registered");
return JNI_ERR;
}
return JNI_VERSION_1_6;
}
/**
* ๅๆถๆณจๅ
* @param vm
* @param reserved
*/
JNIEXPORT void JNI_OnUnload(JavaVM *vm, void *reserved) {
JNIEnv *jenv;
if (vm->GetEnv((void **) &jenv, JNI_VERSION_1_6) != JNI_OK) {
SRS_LOGE("Env not got");
return;
}
jclass clz = jenv->FindClass(JNI_CLS_MANAGER);
if (clz == NULL) {
SRS_LOGE("JNI_OnUnload:Class %s not found", JNI_CLS_MANAGER);
return;
}
jenv->UnregisterNatives(clz);
}
}
|
2b8b1d60b02871b44eddc98630809b1dd7298de3
|
6b2a8dd202fdce77c971c412717e305e1caaac51
|
/solutions_5751500831719424_1/C++/psalios/repeater.cpp
|
04d18eb6ed1ffd128748cc9d329d136678903cfb
|
[] |
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
| 2,261
|
cpp
|
repeater.cpp
|
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<map>
using namespace std;
int N;
string w[110];
int pos[110];
map<int,int> Q;
int main(){
freopen( "repeater.in", "r", stdin );
freopen( "repeater.out", "w", stdout );
int T; cin>>T;
for(int t=1;t<=T;t++){
cin>>N;
for(int i=0;i<N;i++){
cin>>w[i];
pos[i] = 0;
}
bool ok = true;
for(int i=1;i<N;i++)
if( w[i][0] != w[0][0] )
ok = false;
int c = 0;
while( ok ){
int counter = 0;
for(int i=0;i<N;i++)
if( pos[i] == w[i].size() )
counter++;
if( counter== N )
break;
else if( counter > 0 ){
ok = false;
break;
}
Q.clear();
char target = w[0][pos[0]];
for(int i=0;i<N;i++){
int t = pos[i];
while( (t<w[i].size()) && (w[i][t] == target) ){
t++;
Q[t-pos[i]]++;
}
if( t == pos[i] ){
ok = false;
break;
}
pos[i] = t;
}
map<int,int>::iterator it;
for( it = Q.begin(); it != Q.end(); ++it ){
int posa = it->second;
if( posa > N/2 )
c += N - posa;
else
c += posa;
}
}
cout<<"Case #"<<t<<": ";
if( ok )
cout<<c<<'\n';
else
cout<<"Fegla Won\n";
}
return 0;
}
|
85e40aa01fc5ec572acb79ba54a224f6a854b7a4
|
5b22bf742e018a4fd35d5cf6affbd9aadd5df805
|
/ezNet/Network/Public/SocketFactory.h
|
fd0c638d64c4722c4d6b9d1f438169aa497169a8
|
[] |
no_license
|
moritzrinow/ezNet
|
8bbc1428f13cdbc2780013780986f5240cfaefad
|
ec9fb79f68eb887081149b108b7548e737e1dd62
|
refs/heads/master
| 2020-03-25T19:06:03.386954
| 2018-08-17T09:32:50
| 2018-08-17T09:32:50
| 144,064,618
| 1
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 632
|
h
|
SocketFactory.h
|
// Copyright (c) 2018 - 2018, Moritz Rinow. All rights reserved.
#pragma once
#include "ISocket.h"
EZNET_BEGIN
class SocketFactory;
/*
* Simple factory for creating and destroying ISocket objects.
*/
class SocketFactory {
public:
/*
* Creates a blocking socket.
*/
static ISocket* CreateSocket();
/*
* Creates a socket, which blocking mode depends on the input parameter.
*/
static ISocket* CreateSocket(bool blocking);
/*
* Simply calls delete on the ISocket object.
* Only call this on an ISocket object, that was created on the heap.
*/
static void DestroySocket(ISocket* socket);
};
EZNET_END
|
32d306c977c9efe30ca215dd93bbdba913b1961e
|
42499f23a86279d122710b1e6e5ef883766636b5
|
/src/landIce/evaluators/LandIce_AnalyticIceGeometry_Def.hpp
|
dac8df5b977dea478aa74d3329f5b1ac9821aaec
|
[
"BSD-2-Clause"
] |
permissive
|
gahansen/Albany
|
4cd4de9ecd0ac0beed5857fa5150b61b5c73b5ba
|
4af7004bc1aaa8102dbdd1d116f30f581cbb0b82
|
refs/heads/master
| 2023-05-27T01:55:24.548529
| 2023-05-17T16:12:27
| 2023-05-17T16:12:27
| 168,227,296
| 7
| 4
|
NOASSERTION
| 2019-01-29T20:56:28
| 2019-01-29T20:56:27
| null |
UTF-8
|
C++
| false
| false
| 2,513
|
hpp
|
LandIce_AnalyticIceGeometry_Def.hpp
|
//*****************************************************************//
// Albany 3.0: Copyright 2016 Sandia Corporation //
// This Software is released under the BSD license detailed //
// in the file "license.txt" in the top-level Albany directory //
//*****************************************************************//
#include "Phalanx_DataLayout.hpp"
#include "Phalanx_Print.hpp"
namespace LandIce {
//**********************************************************************
template<typename EvalT, typename Traits>
AnalyticIceGeometry<EvalT, Traits>::AnalyticIceGeometry (const Teuchos::ParameterList& p,
const Teuchos::RCP<Albany::Layouts>& dl) :
coordVec (p.get<std::string> ("Coordinate QP Vector Name"), dl->qp_gradient ),
H (p.get<std::string> ("Ice Thickness QP Variable Name"), dl->qp_scalar),
z_s (p.get<std::string> ("Surface Height QP Variable Name"), dl->qp_scalar)
{
this->addDependentField(coordVec);
this->addEvaluatedField(z_s);
this->addEvaluatedField(H);
std::vector<PHX::DataLayout::size_type> dims;
dl->qp_gradient->dimensions(dims);
numQp = dims[1];
numDim = dims[2];
rho = p.get<Teuchos::ParameterList*>("Physical Parameters")->get<double>("Ice Density");
g = p.get<Teuchos::ParameterList*>("Physical Parameters")->get<double>("Gravity Acceleration");
L = p.get<Teuchos::ParameterList*>("Hydrology Parameters")->get<double>("Domain Length",1.0);
dx = p.get<Teuchos::ParameterList*>("Hydrology Parameters")->get<double>("Domain dx",1.0);
this->setName("AnalyticIceGeometry"+PHX::print<EvalT>());
}
//**********************************************************************
template<typename EvalT, typename Traits>
void AnalyticIceGeometry<EvalT, Traits>::
postRegistrationSetup(typename Traits::SetupData d,
PHX::FieldManager<Traits>& fm)
{
this->utils.setFieldData(coordVec,fm);
this->utils.setFieldData(z_s,fm);
this->utils.setFieldData(H,fm);
}
//**********************************************************************
template<typename EvalT, typename Traits>
void AnalyticIceGeometry<EvalT, Traits>::evaluateFields (typename Traits::EvalData workset)
{
for (unsigned int cell=0; cell < workset.numCells; ++cell)
{
for (unsigned int qp=0; qp < numQp; ++qp)
{
MeshScalarT x = coordVec(cell,qp,0);
H (cell,qp) = z_s(cell,qp) = (L -3*dx - x) * 0.0111 /(rho*g);
}
}
}
} // Namespace LandIce
|
9473809a2d1e29dd9ac826c5844b679180918948
|
1a5280acca9f7fee88bf7cb0e837e6c650878de0
|
/SchedulingAlgorithms/1-FCFS_SameArrivalTime.cpp
|
d1ce4a3f3d5069b45c377541704cc0aae47559c0
|
[] |
no_license
|
sudhir98pal/OperatingSystems
|
38afe83181d7696ea0bb8240f1b31a5ad03b9619
|
f98327a9f283a7debe9e0f5191b4dc07593253ce
|
refs/heads/master
| 2023-01-24T17:09:10.927645
| 2020-11-24T08:42:32
| 2020-11-24T08:42:32
| 289,832,014
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 2,922
|
cpp
|
1-FCFS_SameArrivalTime.cpp
|
/*
First in, first out (FIFO),
also known as first come, first served (FCFS),
is the simplest scheduling algorithm.
Completion Time: Time at which process completes its execution.
Turn Around Time: Time Difference between completion time and arrival time. Turn Around Time = Completion Time โ Arrival Time
Waiting Time(W.T): Time Difference between turn around time and burst time.
Waiting Time = (Turn Around Time โ Burst Time)
Burst Time: Time required by a process for CPU execution.
Note: considering that arrival time for all processes is 0.
This is Non-preemptive version
*/
#include<bits/stdc++.h>
using namespace std;
class process
{
public:
int process_number;
int waiting_time;
int burst_time;
int turn_around_time;
};
class fcfs
{
public:
int number_of_process;
process* p;
fcfs(int n)
{
number_of_process=n;
this->p=new process[number_of_process];
}
void initilize();
void find_waiting_time();
void find_turn_aroundtime();
double find_average_waiting_time();
double find_average_turn_around_time();
void display();
};
void fcfs::initilize()
{
for(int i=0;i<number_of_process;i++)
{
p[i].process_number=i+1;
cout<<"Enter "<<(i+1)<<" process 's Burst Time "<<endl;
int bt;
cin>>bt;
p[i].burst_time=bt;
}
}
void fcfs::find_waiting_time()
{
p[0].waiting_time=0;
// Waiting time for first process is 0;
for(int i=1;i<number_of_process;i++)
{
p[i].waiting_time=p[i-1].burst_time+p[i-1].waiting_time;
}
}
void fcfs::find_turn_aroundtime()
{
for(int i=0;i<number_of_process;i++)
{
p[i].turn_around_time=p[i].burst_time+p[i].waiting_time;
}
}
double fcfs::find_average_waiting_time()
{
int total=0;
for(int i=0;i<number_of_process;i++)
{
total+=p[i].waiting_time;
}
return (double)total/(double)(number_of_process);
}
double fcfs::find_average_turn_around_time()
{
int total=0;
for(int i=0;i<number_of_process;i++)
{
total+=p[i].turn_around_time;
}
return (double)total/(double)(number_of_process);
}
void fcfs::display()
{
cout<<"Process NO. "<<" Burst Time "<<" Waiting Time "<<" Turn Around Time "<<endl;
for(int i=0;i<number_of_process;i++)
{
cout<<p[i].process_number<<" ";
cout<<p[i].burst_time<<" ";
cout<<p[i].waiting_time<<" ";
cout<<p[i].turn_around_time<<endl;
}
}
int main()
{
int n;
cout<<"Enter The Number Of process"<<endl;
cin>>n;
fcfs pal(n);
pal.initilize();
pal.find_waiting_time();
pal.find_turn_aroundtime();
pal.display();
cout<<"Average waiting time = ";
cout<<pal.find_average_waiting_time()<<endl;
cout<<"Average turn around time = ";
cout<<pal.find_average_turn_around_time()<<endl;
}
|
d01b1197a1b8726fdc9ebcb8a7ffea731ab71d7a
|
cf3f075bd3504e6b8e3d2b3227cc242f0508a74a
|
/qmlcfmbusmulticfmdemo/base/common/qmlcfmbusmulticfmdemo_guns.hxx
|
1a9e299765e8e22e689418a4c2d9b2642504f99f
|
[] |
no_license
|
liuzitong/demos
|
91e27a52186014788f47883c1205c50a6a137487
|
9afea1317cb88377752470ba7815f16cd6da23f8
|
refs/heads/master
| 2022-08-23T14:59:34.692652
| 2020-05-20T03:25:47
| 2020-05-21T05:51:42
| 265,776,097
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 486
|
hxx
|
qmlcfmbusmulticfmdemo_guns.hxx
|
#ifndef QMLCFMBUSMULTICFMDEMO_GUNS_HXX
#define QMLCFMBUSMULTICFMDEMO_GUNS_HXX
#include <QString>
namespace qmlCfmBusMulticfmDemo {
// ////////////////////////////////////////////////////////////////////////////
/*!
* @brief global unique name stirng
*/
// ////////////////////////////////////////////////////////////////////////////
// application controller name
#define GUNS_AppCtrl QStringLiteral("qmlCfmBusMulticfmDemo::AppCtrl")
// add other unique name here...
}
#endif
|
73d6fed8ee84f9967d9fddc1a547041cb818ca3b
|
86daa852be47faa4b34ab16bfd8a2be09fa052fa
|
/OgrePong/source/object/Paddle.cpp
|
5d59d8719b86ea860c0638059f9eb7291e5594a3
|
[] |
no_license
|
schen59/Pong
|
b4cef06f66e65f2d7238635608931f1429c44dcf
|
ddf29154734f0a78dae18a6695d09a96e7e07cf6
|
refs/heads/master
| 2021-01-23T09:29:34.316611
| 2014-02-27T07:52:01
| 2014-02-27T07:52:01
| 17,161,758
| 2
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 640
|
cpp
|
Paddle.cpp
|
#include "include\object\Paddle.h"
#include "include\object\MotionObject.h"
#include "include\common\Properties.h"
#include "OgreSceneManager.h"
Paddle::Paddle(Ogre::SceneManager* sceneManager, Ogre::Vector3 dimension) : MotionObject(sceneManager, dimension,
PADDLE_ORIGINAL_SPEED, PADDLE_DIRECTION_UP) {
}
void Paddle::load() {
Ogre::SceneManager* sceneManager = getSceneManager();
Ogre::Entity* entity = sceneManager->createEntity("Cube.mesh");
setEntity(entity);
}
void Paddle::reset() {
Ogre::Vector3 position = getPosition();
position.y = 0;
setPosition(position);
setSpeed(PADDLE_ORIGINAL_SPEED);
}
|
10bdd4f78e9f94b982e17e88028890dbd07ba338
|
9aa3ac290b9abd8978187f728de18bf1f7736be2
|
/assignment_package/src/integrators/fulllightingintegrator.cpp
|
3df1d96d4bc7f950c5222915061d4ba99525cebe
|
[] |
no_license
|
JerryYan97/CIS561_HW6
|
7459cd6463d653c677712b8ee102f8c726ff9caf
|
bdd149fffb1332524fe20aff586059706c6df482
|
refs/heads/master
| 2021-02-14T03:19:22.040497
| 2020-03-03T23:20:50
| 2020-03-03T23:20:50
| 244,761,891
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 393
|
cpp
|
fulllightingintegrator.cpp
|
#include "fulllightingintegrator.h"
Color3f FullLightingIntegrator::Li(const Ray &ray, const Scene &scene, std::shared_ptr<Sampler> sampler, int depth) const
{
//TODO
return Color3f(0.f);
}
/*
float BalanceHeuristic(int nf, Float fPdf, int ng, Float gPdf)
{
//TODO
return 0.f;
}
float PowerHeuristic(int nf, Float fPdf, int ng, Float gPdf)
{
//TODO
return 0.f;
}
*/
|
90cb4b83c3890961c17bc2eab580ce83274cb92b
|
617739c6346a41238e2ac29c9a9ef3b016b30bc5
|
/project-serendipity/bookinfo.hpp
|
436168bd148345df2d6f754fbe6db18588affd16
|
[] |
no_license
|
oggunderscore/cs1b
|
3f87b67ee10c8c948c0f00a34f110dba91b0185b
|
06bf980ec7dff68b3a2a34c38a79a216b11897b3
|
refs/heads/master
| 2020-08-24T00:05:39.629284
| 2019-10-21T18:38:34
| 2019-10-21T18:38:34
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 125
|
hpp
|
bookinfo.hpp
|
#ifndef BOOKINFO_H
#define BOOKINFO_H
#include "bookdata.hpp"
void bookInfo(int index, bookType *books[]);
#endif
|
f1906473bc5d91812db9ad43142dfb42b154de76
|
622df67006344be452e62f9b346ec438337f0cab
|
/algo/dp/test.cpp
|
c3924a81d5f9ad982822928cdf673aa7381ffb7f
|
[] |
no_license
|
arpu-nagar/Coding
|
090981921cdeac70641fdb602ebfdad8b49d4867
|
ec71c039784d423eae67b3a5c070c21117771edc
|
refs/heads/master
| 2023-07-14T12:15:35.601131
| 2021-08-31T05:53:22
| 2021-08-31T05:53:22
| 252,650,938
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,342
|
cpp
|
test.cpp
|
#include <bits/stdc++.h>
using namespace std;
template<typename T>
void pop_front(std::vector<T>& vec)
{
assert(!vec.empty());
vec.front() = std::move(vec.back());
vec.pop_back();
}
int main() {
int t; cin >> t;
for (int i = 1; i <= t; i++) {
cout << "Case #" << i << ": ";
string s; cin >> s;
int arr[26] = { 0 };
for (auto& x : s) arr[x - 'a']++;
int f = 0;
for (int j = 0; j < 26 && !f; j++) {
if (arr[j] > (s.size() / 2)) {
cout << "IMPOSSIBLE" << endl;
f = 1;
break;
}
}
if (!f) {
string x = s;
sort(x.begin(), x.end());
string y = x;
reverse(x.begin(), x.end());
map<char, vector<char>> mp;
for (int j = 0; j < x.size(); j++) {
if (y[j] != x[j])
mp[y[j]].push_back(x[j]);
else {
swap(x[j], x[x.size() - 1]);
mp[y[j]].push_back(x[j]);
}
}
for (int j = 0; j < x.size(); j++) {
cout << mp[s[j]][0];
mp[s[j]].front() = std::move(mp[s[j]].back());
mp[s[j]].pop_back();
}
cout << endl;
}
}
}
|
1e85866dc32067010373f9adb6beaa8ab715ce90
|
7906db9e95711f119c4e0202c75f8abf756e7d47
|
/20160328/20160328/3_casting.cpp
|
b7380b0faa487dfad0f57ee3c7bd5bbffa9d0783
|
[] |
no_license
|
kyo504/design-pattern
|
693d02e9040064feb7d898a53b620303f64b1a2a
|
e5c1bb3f8a592581f2c05fa0090d38301a9c56be
|
refs/heads/master
| 2016-08-10T01:18:09.224178
| 2016-04-26T00:42:54
| 2016-04-26T00:42:54
| 54,871,271
| 0
| 0
| null | null | null | null |
UHC
|
C++
| false
| false
| 1,141
|
cpp
|
3_casting.cpp
|
// 3_์บ์คํ
.cpp
#include <iostream>
using namespace std;
// 1. C์ ์บ์คํ
์ ๋น์ด์ฑ์ ์ด๋ค. (์์ ํ ๋๋ ์๊ณ ๊ทธ๋ ์ง ์์ ๋๋ ์๋ค)
// 2. ๊ทธ๋์ C++ ๋ 4๊ฐ์ ์บ์คํ
์ ์๋ก ์ ๊ณตํ๋ค.
// - static_cast: void* -> ๋ค๋ฅธ ํ์
๋๋ ์ฐ๊ด์ฑ ์๋ ์บ์คํ
๋ง ํ์ฉ
// - reinterpret_cast: ๋ฉ๋ชจ๋ฆฌ ์ฌํด์ (ํ๋ซํผ ๋ง๋ค ๋ค๋ฅด๊ฒ ๋์ํ ์ ์๊ธฐ ๋๋ฌธ์ ์ฃผ์ํด์ผ ํ๋ค.)
// - const_cast: ๊ฐ์ฒด์ ์์์ฑ, ํ๋ฐ์ฑ(volitile)์ ์ ๊ฑฐํ๋ ์ฉ๋๋ก๋ง ์ฌ์ฉ
// - dynamic_cast: RTTI ๊ธฐ์ , ๋ค์ด ์บ์คํ
์ฉ๋๋ก ์ฌ์ฉ ๋จ
/*
volitile
๋ฉ๋ชจ๋ฆฌ ๊ฐ์์ฑ์ ์ ๊ฑฐ ํ๊ธฐ ์ํด์ ์ฌ์ฉํจ
*/
int main()
{
const int c = 10;
int* p = const_cast<int*>(&c);
*p = 20;
cout << *p << endl;
cout << c << endl;
}
#if 0
int main()
{
//int *p1 = (int*)malloc(sizeof(100));
int *p1 = static_cast<int*>(malloc(sizeof(100)));
int n = 0;
// double* p = (double*)&n; // c ์คํ์ผ๋ก๋ ์บ์คํ
๋์ง๋ง ๋ฉ๋ชจ๋ฆฌ ์นจ๋ฒ์ด ๋๋ ๋ฌธ์ ๊ฐ ๋ฐ์ํ ์ ์๋ค.
double* p = reinterpret_cast<double*>(&n);
*p = 3.14; // ์ฃผ์ ํด์ผ ํ๋ค
}
#endif
|
332076b13a2041d3fe71e938d9220c0f5fc3ddf3
|
cb4a6ece41f8183a73bfede55d4156e01743c848
|
/Solver.h
|
1f4982a15283ca5b444293ef580e47eab8f038e9
|
[] |
no_license
|
davidwang501/OpenCVPocketCubeSolver
|
e4938d80ad8e2dba53c30fa7cb2c940c9027c343
|
946630f42d28bfc41d448b0ba0a93eb0ff7180ab
|
refs/heads/master
| 2020-04-17T16:45:29.841544
| 2019-01-21T05:37:06
| 2019-01-21T05:37:06
| 166,754,186
| 1
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 983
|
h
|
Solver.h
|
//
// Solver.h
// finalProject2
//
// Created by David Wang on 12/10/18.
//
//
#ifndef __finalProject__Solver__
#define __finalProject__Solver__
#include <stdio.h>
#include <vector>
#include <string>
#include <iostream>
#endif /* defined(__finalProject__Solver__) */
class Solver{
public:
//constructor
Solver(std::string cube);
//number of cubie in solved cube regardless of orientation
std::vector<int> position;
// orientation of cube
std::vector<int> rotation;
std::string moveList = "";
std::vector<std::string> diffMoves {"T", "F", "R", "T'", "F'", "R'"};
std::string inputCube;
void initalizeCube();
void firstLayer();
std::string secondLayer();
void rotateFaces(std::vector<std::string> moves);
std::vector<std::string> tryMoves(int depth);
int findCubie(int cubie);
std::string getColor(std::string file){
}
};
|
a295a21890fcb922e107e1874f36c13be8e3957d
|
180ef8df3983b9e5ac941e6c491cc5c8747bd512
|
/leetcode/algorithms/c++/Divide Two Integers/Divide Two Integers.cpp
|
58b37de91852183a849dd4ee41d1761f2c286969
|
[] |
no_license
|
withelm/Algorytmika
|
71f098cb31c9265065d2d660c24b90dd07a3d078
|
4c37c9b2e75661236046c2af19bb81381ce0a522
|
refs/heads/master
| 2021-12-09T12:58:45.671880
| 2021-08-22T08:03:04
| 2021-08-22T08:03:04
| 10,869,703
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,220
|
cpp
|
Divide Two Integers.cpp
|
class Solution
{
public:
int divide(long long int dividend, long long int divisor)
{
bool isMinus = false;
if (dividend >= 0 && divisor < 0)
isMinus = true;
if (dividend < 0 && divisor >= 0)
isMinus = true;
if (dividend == -2147483648 && divisor == -1)
return 2147483647;
if (dividend == -2147483648 && divisor == 1)
return -2147483648;
dividend = abs(dividend);
divisor = abs(divisor);
if (dividend < divisor)
return 0;
if (dividend == divisor)
if (isMinus)
return -1;
else
return 1;
vector<long long int> memo;
long long int curr = divisor;
while (dividend >= curr)
{
memo.push_back(curr);
curr = curr << 1;
}
int n = memo.size() - 1;
long long int r = 0;
while (n >= 0)
{
if (dividend >= memo[n])
{
r += ((long long int)1) << n;
dividend -= memo[n];
}
--n;
}
if (isMinus)
return -r;
return r;
}
};
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.