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
|
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
f4cb551d13e083e3c7b213da3b6f34ed2fa2ad83
|
966c29605efd37164db92d56432bb05cf0343e71
|
/lab06/Function.h
|
155d8f3aac8436d8d4b7e2c4d2af2adc83506776
|
[] |
no_license
|
dariuszlesiecki/OOP-1
|
81011fc5437b5dc343ff4584b9b878b610b9c9de
|
f93beb6400b7db882d4bf5bb9d586c84d6af81be
|
refs/heads/master
| 2022-09-05T22:59:38.356298
| 2020-05-23T14:17:43
| 2020-05-23T14:17:43
| 266,348,394
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 224
|
h
|
Function.h
|
#pragma once
#include <iostream>
#include <cmath>
class Function{
public:
virtual ~Function();
virtual Function* Copy()=0;
virtual double calc(double) const;
private:
};
|
e7aa22bccfc36204419cc00931caeb6571150fe1
|
d2f493f794151b2f0b927617b10f0f9338572ff0
|
/Contest_28072017/I.cpp
|
f7ffbde0e5806ae68ed06edb8bee4a3ad4523fce
|
[] |
no_license
|
hungnt61h/PTIT-Algorithms
|
320aa078216fc17203ec7f14d70fbfa8a577e2a1
|
d53786a87a0b0a8fe2efbbaaf886f835a0d27f34
|
refs/heads/master
| 2020-03-07T22:46:24.188916
| 2018-04-07T06:39:43
| 2018-04-07T06:39:43
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 668
|
cpp
|
I.cpp
|
#include <iostream>
#include <string>
using namespace std;
const char B = '#';
const char W = '.';
const int MAX = 110;
int a[2][MAX];
int n;
bool down, up, left;
void print() {
for (int i = 0; i < 2; i++) {
for (int j = 0; j < n; j++)
cout<<a[i][j]<<" ";
cout<<endl;
}
}
void init() {
cin>>n;
string s;
cin>>s;
for (int i = 0; s[i]; i++)
if (s[i] == B)
a[0][i] = 1;
else
a[0][i] = 0;
cin>>s;
for (int i = 0; s[i]; i++)
if (s[i] == B)
a[1][i] = 1;
else
a[1][i] = 0;
}
int count() {
int cnt = 0;
for
}
void test() {
init();
print();
}
int main() {
test();
return 0;
}
|
6cb9c23bb46fa7bd363ff22cd312c91e1a0b9d83
|
57d30906de95e20fb45216925791cb809a11b7f1
|
/ase/ase/aseio_getaddrinfo.hpp
|
6af1c5292b4b663db95e825450baa1a21326f90a
|
[
"MIT"
] |
permissive
|
ahiguti/ase
|
ad782902ca3a8713b155769413fc5d9fd537c347
|
f6bc5f337fe7df6eabf676660d9189d3c474150d
|
refs/heads/main
| 2021-06-13T17:39:25.280776
| 2012-06-15T21:01:17
| 2012-06-15T21:01:17
| 4,680,010
| 1
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,399
|
hpp
|
aseio_getaddrinfo.hpp
|
/*
* This file is part of ASE, the abstract script engines.
* Copyright (C) 2006 A.Higuchi. All rights reserved.
* See COPYRIGHT.txt for details.
*/
#ifndef GENTYPE_ASEIO_GETADDRINFO_HPP
#define GENTYPE_ASEIO_GETADDRINFO_HPP
#include <sys/types.h>
#include <sys/socket.h>
#include <cstring>
#include <netdb.h>
#include <ase/ase.hpp>
struct ase_sockaddr_generic {
public:
ase_sockaddr_generic() {
std::memset(&storage, 0, sizeof(storage));
len = sizeof(storage);
}
ase_sockaddr_generic(const ::sockaddr *addr, socklen_t addr_len) {
std::memcpy(&storage, addr, addr_len);
len = addr_len;
}
const ::sockaddr_storage *get_sockaddr_storage() const {
return &storage;
}
::sockaddr_storage *get_sockaddr_storage() {
return &storage;
}
const ::sockaddr *get_sockaddr() const {
return reinterpret_cast<const ::sockaddr *>(&storage);
}
::sockaddr *get_sockaddr() {
return reinterpret_cast< ::sockaddr *>(&storage);
}
socklen_t get_socklen() const {
return len;
}
socklen_t& get_socklen() {
return len;
}
private:
::sockaddr_storage storage;
socklen_t len;
};
ASELIB_DLLEXT void ase_io_getaddrinfo(const char *node, const char *service,
int flags, int family, int socktype, ase_sockaddr_generic& addr_r);
ASELIB_DLLEXT void ase_io_hoststring_to_sockaddr(const char *str,
ase_sockaddr_generic& addr_r);
#endif
|
754847bbaa50adc382106f80d522bcdafefe5c4e
|
f3c4528fea61665729f24e92c31e05e2c5e176fe
|
/src/cpp/detail/data_aggregation.hpp
|
14c63362aeed5d9afcc7a711fabf8ee63d1d3eb9
|
[
"Apache-2.0"
] |
permissive
|
lakeylee2087/Fast-DDS-statistics-backend
|
204de18cfc38b9808a15cdf702235b6b4f69532d
|
1426da39a2294e6364d304d95b9cefc33535c9e8
|
refs/heads/main
| 2023-09-01T14:01:34.079214
| 2021-10-18T13:41:51
| 2021-10-18T13:41:51
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 7,830
|
hpp
|
data_aggregation.hpp
|
// Copyright 2021 Proyectos y Sistemas de Mantenimiento SL (eProsima).
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
/**
* @file data_aggregation.hpp
*/
#ifndef _EPROSIMA_FASTDDS_STATISTICS_BACKEND_DETAIL_DATA_AGGREGATION_HPP_
#define _EPROSIMA_FASTDDS_STATISTICS_BACKEND_DETAIL_DATA_AGGREGATION_HPP_
#include <algorithm> // std::min, std::max, std::nth_element
#include <cassert> // assert
#include <cmath> // std::isnan, std::sqrt
#include <memory> // std::unique_ptr
#include <vector> // std::vector
#include <fastdds_statistics_backend/types/types.hpp>
#include <database/samples.hpp>
#include <detail/data_getters.hpp>
namespace eprosima {
namespace statistics_backend {
namespace detail {
/**
* Generic interface for aggregating raw statistics data into several bins.
*
* It is constructed with the bins configuration and a reference to the resulting
* data collection.
*
* The data returned by the database select() method is processed by the @ref add_data
* method.
*
* To perform final aggregation calculations, method @ref finish should be called.
*/
struct IDataAggregator
{
virtual ~IDataAggregator() = default;
/**
* @brief Construct an IDataAggregator.
* @param bins Number of time intervals in which the measurement time is divided
* @param t_from Starting time of the returned measures
* @param t_to Ending time of the returned measures
* @param returned_data Reference to the collection to be returned by @ref StatisticsBackend::get_data
* @param initial_value Value with which to initialize the contents of returned_data
*/
IDataAggregator(
uint16_t bins,
Timestamp t_from,
Timestamp t_to,
std::vector<StatisticsData>& returned_data,
double initial_value = std::numeric_limits<double>::quiet_NaN())
: data_(returned_data)
{
assert(bins > 0);
prepare_bins(bins, t_from, t_to, initial_value);
}
/**
* @brief Process a collection of data returned by the database.
* @param iterators Reference to the iterator pair returned by @ref get_iterators
*/
void add_data(
IteratorPair& iterators)
{
for (auto& it = *iterators.first; it != *iterators.second; ++it)
{
// Find and check the bin corresponding to the sample timestamp
Timestamp ts = it.get_timestamp() + interval_;
auto index = (ts - data_[0].first) / interval_;
assert((index >= 0) && static_cast<size_t>(index) < data_.size());
// Add sample value to the corresponding bin
add_sample(static_cast<size_t>(index), it.get_value());
}
}
/**
* @brief Performs final aggregation of data.
*/
virtual void finish()
{
}
protected:
/**
* @brief Add a sample to a specific bin.
* @param index Index of the bin where the sample should be added.
* @param value Statistical value to add.
*/
virtual void add_sample(
size_t index,
double value) = 0;
/**
* @brief Assign a value to a bin if it was not given a previous value.
*
* This method is used on aggregators that need to take special actions the first time
* a value is added to a bin.
* For instance, the @ref MaximumAggregator will assign the value the first time, and
* will perform a comparison with the current value on the following ones.
*
* @param index Index of the bin where the sample should be added.
* @param value Statistical value to assign.
* @return whether the value has been assigned to the bin.
*/
bool assign_if_nan(
size_t index,
double value)
{
if (std::isnan(data_[index].second))
{
data_[index].second = value;
return true;
}
return false;
}
//! Reference to the collection to be returned by @ref StatisticsBackend::get_data
std::vector<StatisticsData>& data_;
private:
void prepare_bins(
uint16_t bins,
Timestamp t_from,
Timestamp t_to,
double initial_value)
{
// Perform a single allocation for all the returned bins
data_.reserve(bins);
// Calculate the duration of each bin
interval_ = t_to - t_from;
interval_ /= bins;
// Fill each bin with the initial value and the initial timestamp of the bin
do
{
t_from += interval_;
data_.emplace_back(t_from, initial_value);
bins--;
} while (bins > 0);
}
//! Duration of each bin
Timestamp::duration interval_;
};
#include "data_aggregators/CountAggregator.ipp"
#include "data_aggregators/MaximumAggregator.ipp"
#include "data_aggregators/MeanAggregator.ipp"
#include "data_aggregators/MedianAggregator.ipp"
#include "data_aggregators/MinimumAggregator.ipp"
#include "data_aggregators/NoneAggregator.ipp"
#include "data_aggregators/StdDevAggregator.ipp"
#include "data_aggregators/SumAggregator.ipp"
} // namespace detail
/**
* @brief Get the aggregator required for processing a @ref StatisticsBackend::get_data call.
* @param bins Number of time intervals in which the measurement time is divided
* @param t_from Starting time of the returned measures
* @param t_to Ending time of the returned measures
* @param statistic Kind of aggregation to perform
* @param returned_data Reference to the collection to be returned by @ref StatisticsBackend::get_data
*
*/
std::unique_ptr<detail::IDataAggregator> get_data_aggregator(
uint16_t bins,
Timestamp t_from,
Timestamp t_to,
StatisticKind statistic,
std::vector<StatisticsData>& returned_data)
{
detail::IDataAggregator* ret_val = nullptr;
switch (statistic)
{
case StatisticKind::NONE:
ret_val = new detail::NoneAggregator(bins, t_from, t_to, returned_data);
break;
case StatisticKind::SUM:
ret_val = new detail::SumAggregator(bins, t_from, t_to, returned_data);
break;
case StatisticKind::MEAN:
ret_val = new detail::MeanAggregator(bins, t_from, t_to, returned_data);
break;
case StatisticKind::MEDIAN:
ret_val = new detail::MedianAggregator(bins, t_from, t_to, returned_data);
break;
case StatisticKind::MAX:
ret_val = new detail::MaximumAggregator(bins, t_from, t_to, returned_data);
break;
case StatisticKind::MIN:
ret_val = new detail::MinimumAggregator(bins, t_from, t_to, returned_data);
break;
case StatisticKind::STANDARD_DEVIATION:
ret_val = new detail::StdDevAggregator(bins, t_from, t_to, returned_data);
break;
case StatisticKind::COUNT:
default:
ret_val = new detail::CountAggregator(bins, t_from, t_to, returned_data);
break;
}
return std::unique_ptr<detail::IDataAggregator>(ret_val);
}
} // namespace statistics_backend
} // namespace eprosima
#endif // _EPROSIMA_FASTDDS_STATISTICS_BACKEND_DETAIL_DATA_AGGREGATION_HPP_
|
881a0798fa758106cec6eabeeccafabc4a49dd9d
|
1885ce333f6980ab6aad764b3f8caf42094d9f7d
|
/test/e2e/test_master/wxWidgets/include/wx/motif/button.h
|
fff6ac1ba848817d06c00472d15a5d63c6ad3442
|
[
"MIT"
] |
permissive
|
satya-das/cppparser
|
1dbccdeed4287c36c61edc30190c82de447e415b
|
f9a4cfac1a3af7286332056d7c661d86b6c35eb3
|
refs/heads/master
| 2023-07-06T00:55:23.382303
| 2022-10-03T19:40:05
| 2022-10-03T19:40:05
| 16,642,636
| 194
| 26
|
MIT
| 2023-06-26T13:44:32
| 2014-02-08T12:20:01
|
C++
|
UTF-8
|
C++
| false
| false
| 1,530
|
h
|
button.h
|
/////////////////////////////////////////////////////////////////////////////
// Name: wx/motif/button.h
// Purpose: wxButton class
// Author: Julian Smart
// Modified by:
// Created: 17/09/98
// Copyright: (c) Julian Smart
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_BUTTON_H_
# define _WX_BUTTON_H_
// Pushbutton
class WXDLLIMPEXP_CORE wxButton : public wxButtonBase
{
public:
wxButton()
{
}
wxButton(wxWindow* parent, wxWindowID id, const wxString& label = wxEmptyString, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = 0, const wxValidator& validator = wxDefaultValidator, const wxString& name = wxASCII_STR(wxButtonNameStr))
{
Create(parent, id, label, pos, size, style, validator, name);
}
bool Create(wxWindow* parent, wxWindowID id, const wxString& label = wxEmptyString, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = 0, const wxValidator& validator = wxDefaultValidator, const wxString& name = wxASCII_STR(wxButtonNameStr));
virtual wxWindow* SetDefault();
virtual void Command(wxCommandEvent& event);
static wxSize GetDefaultSize();
// Implementation
virtual wxSize GetMinSize() const;
protected:
virtual wxSize DoGetBestSize() const;
private:
wxSize OldGetBestSize() const;
wxSize OldGetMinSize() const;
void SetDefaultShadowThicknessAndResize();
wxDECLARE_DYNAMIC_CLASS(wxButton);
};
#endif
|
5b9739cdd971c178c938503a8a94da61df12d412
|
33035c05aad9bca0b0cefd67529bdd70399a9e04
|
/src/boost_fusion_adapted_array_begin_impl.hpp
|
c1ac7de75ad5b5928f77f32520af05eb3c10f244
|
[
"LicenseRef-scancode-unknown-license-reference",
"BSL-1.0"
] |
permissive
|
elvisbugs/BoostForArduino
|
7e2427ded5fd030231918524f6a91554085a8e64
|
b8c912bf671868e2182aa703ed34076c59acf474
|
refs/heads/master
| 2023-03-25T13:11:58.527671
| 2021-03-27T02:37:29
| 2021-03-27T02:37:29
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 53
|
hpp
|
boost_fusion_adapted_array_begin_impl.hpp
|
#include <boost/fusion/adapted/array/begin_impl.hpp>
|
5e7936aa1bfd51776f51fc5b71203bd40f9b1dbe
|
4c5b9f058495bc280d6a027fd9ee6177b259264c
|
/kubway_real/Kubway/pay_or_order.cpp
|
28582bd5de568cf96470f5c3c6deb9e892afc3f1
|
[] |
no_license
|
leejewon97/Kubway
|
2ec62ecf4ee8d0dc9f95bb04b8187d89bd93f772
|
3ee72a83b88835068b5c4d36ea9974f95915dbe6
|
refs/heads/master
| 2020-08-29T16:29:45.737354
| 2019-12-10T13:58:14
| 2019-12-10T13:58:14
| 218,091,184
| 0
| 2
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 832
|
cpp
|
pay_or_order.cpp
|
#include "pay_or_order.h"
#include "ui_pay_or_order.h"
#include <QDebug>
pay_or_order::pay_or_order(QWidget *parent) :
QWidget(parent),
ui(new Ui::pay_or_order)
{
ui->setupUi(this);
connect(coc, SIGNAL(buttonPressed()), this, SLOT(closeAll()));
}
pay_or_order::~pay_or_order()
{
delete ui;
}
void pay_or_order::setString(QString s) {
str = s;
}
QString pay_or_order::getString() {
return str;
}
void pay_or_order::on_pay_btn_clicked()
{
coc->setString(getString());
coc->show();
}
void pay_or_order::on_order_btn_clicked()
{
emit buttonPressed();
}
void pay_or_order::on_pushButton_back_clicked()
{
this->hide();
}
void pay_or_order::closeAll()
{
coc->hide();
on_pushButton_home_clicked();
}
void pay_or_order::on_pushButton_home_clicked()
{
emit buttonPressed();
}
|
5bf64d60dfc82955edb7941cce0546f1b5efa7ce
|
8d32836a6c2e7e458a2a6d6f4d89f2e5c659673e
|
/dependencies/SRC/mmaplib/MMapManager.h
|
509aaabcde55bae24067260e5e33cf7c3df4edcd
|
[] |
no_license
|
Sandshroud/Ronin
|
e92e53c81fdab4cefc0de964d2fb8cebc34ee41e
|
94986c95e88abe6cedd240e0ce95f6f213b05d90
|
refs/heads/master
| 2023-05-10T21:58:29.115832
| 2023-04-29T04:26:34
| 2023-04-29T04:26:34
| 74,101,915
| 12
| 7
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 4,443
|
h
|
MMapManager.h
|
/*
* Copyright (C) 2014-2017 Sandshroud <https://github.com/Sandshroud>
*
* 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, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include "SharedDependencyDefines.h"
#include "MMapManagerExt.h"
#define MMAP_MAGIC 0x4d4d4150 // 'MMAP'
#define MMAP_VERSION 4
struct MmapTileHeader
{
uint32 mmapMagic;
uint32 dtVersion;
uint32 mmapVersion;
uint32 size;
bool usesLiquids : 1;
MmapTileHeader() : mmapMagic(MMAP_MAGIC), dtVersion(DT_NAVMESH_VERSION),
mmapVersion(MMAP_VERSION), size(0), usesLiquids(true) {}
};
struct TileReferenceC
{
TileReferenceC(dtTileRef refid) { ID = refid; };
~TileReferenceC() {};
dtTileRef ID;
};
typedef std::map<uint32, TileReferenceC*> ReferenceMap;
typedef std::map<dtTileRef, uint32> ReverseReferenceMap;
class MMapManager : public MMapManagerExt
{
public:
MMapManager(const char* dataPath, uint32 mapid);
~MMapManager();
private:
std::string m_dataPath;
// Mutex m_Lock; // One day we'll need this, but for now, it's our silent knight, always watching...
uint32 ManagerMapId;
dtNavMesh* m_navMesh;
dtNavMeshQuery* m_navMeshQuery;
dtTileRef lastTileRef;
ReferenceMap TileReferences;
ReverseReferenceMap TileLoadCount;
uint32 packTileID(int32 x, int32 y) { return uint32(x << 16 | y); };
public:
bool LoadNavMesh(uint32 x, uint32 y);
void UnloadNavMesh(uint32 x, uint32 y);
bool IsNavmeshLoaded(uint32 x, uint32 y);
Position getNextPositionOnPathToLocation(float startx, float starty, float startz, float endx, float endy, float endz);
Position getBestPositionOnPathToLocation(float startx, float starty, float startz, float endx, float endy, float endz);
PositionMapContainer* BuildFullPath(unsigned short moveFlags, float startx, float starty, float startz, float endx, float endy, float endz, bool straight);
// Poly locating
dtPolyRef GetPathPolyByPosition(dtPolyRef const* polyPath, uint32 polyPathSize, float const* Point, float* Distance = NULL) const;
dtPolyRef GetPolyByLocation(dtQueryFilter* m_filter, dtPolyRef const* polyPath, uint32 polyPathSize, float const* Point, float* Distance) const;
// Smooth pathing
uint32 fixupCorridor(dtPolyRef* path, uint32 npath, uint32 maxPath, dtPolyRef* visited, uint32 nvisited);
bool getSteerTarget(float* startPos, float* endPos, float minTargetDist, dtPolyRef* path, uint32 pathSize, float* steerPos, unsigned char& steerPosFlag, dtPolyRef& steerPosRef);
dtStatus findSmoothPath(dtQueryFilter* m_filter, float* startPos, float* endPos, dtPolyRef* polyPath, uint32 polyPathSize, float* smoothPath, int* smoothPathSize, uint32 smoothPathMaxSize);
bool GetWalkingHeightInternal(float startx, float starty, float startz, float endz, Position& out);
bool getNextPositionOnPathToLocation(float startx, float starty, float startz, float endx, float endy, float endz, Position& out);
private:
float calcAngle( float Position1X, float Position1Y, float Position2X, float Position2Y );
bool inRangeYZX(float* v1, float* v2, float r, float h)
{
float dx = v2[0] - v1[0];
float dy = v2[1] - v1[1]; // elevation
float dz = v2[2] - v1[2];
return (dx*dx + dz*dz) < r*r && fabsf(dy) < h;
}
void dtcopy(float* dest, float* a)
{
dest[0] = a[0];
dest[1] = a[1];
dest[2] = a[2];
}
void dtsub(float* dest, const float* v1, const float* v2)
{
dest[0] = v1[0]-v2[0];
dest[1] = v1[1]-v2[1];
dest[2] = v1[2]-v2[2];
}
float dtdot(float* v1, float* v2)
{
return v1[0]*v2[0] + v1[1]*v2[1] + v1[2]*v2[2];
}
void dtmad(float* dest, float* v1, float* v2, float s)
{
dest[0] = v1[0]+v2[0]*s;
dest[1] = v1[1]+v2[1]*s;
dest[2] = v1[2]+v2[2]*s;
}
};
|
501e6393a3f2ab4f4a59c1569b791cfc5b5e4e80
|
d2190cbb5ea5463410eb84ec8b4c6a660e4b3d0e
|
/hydra2-4.9w/mdc/hmdccalibrater1.h
|
f6597f9855234cff47567af6809a015d95fc4bf6
|
[] |
no_license
|
wesmail/hydra
|
6c681572ff6db2c60c9e36ec864a3c0e83e6aa6a
|
ab934d4c7eff335cc2d25f212034121f050aadf1
|
refs/heads/master
| 2021-07-05T17:04:53.402387
| 2020-08-12T08:54:11
| 2020-08-12T08:54:11
| 149,625,232
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 4,454
|
h
|
hmdccalibrater1.h
|
#ifndef HMDCCALIBRATER1_H
#define HMDCCALIBRATER1_H
#include "hreconstructor.h"
#include "hlocation.h"
#include "TRandom.h"
#include "hstartdef.h"
class HCategory;
class HIterator;
class HMdcCalParRaw;
class HMdcLookupGeom;
class HMdcTimeCut;
class HMdcCutStat;
class HMdcWireStat;
class HMdcRaw;
class HMdcCal1;
class HMdcCalParTdc;
class HMdcCalibrater1 : public HReconstructor {
protected:
HCategory* rawCat; //! pointer to the raw data
HCategory* calCat; //! pointer to the cal data
HCategory* startHitCat; //! pointer to the start cal data
HMdcRaw* raw; //! pointer to raw data word
HMdcCal1* cal; //! pointer to cal1 data word
Bool_t StartandCal; // switch between Cal&&Start,noCal&&Start,noCal&&noStart
Bool_t NoStartandNoCal; // switch between Cal&&Start,noCal&&Start,noCal&&noStart
Bool_t NoStartandCal; // switch between Cal&&Start,noCal&&Start,noCal&&noStart
Bool_t setTimeCut; // switch on/off cuts on time1, time2 and time2-time1
Bool_t hasPrinted; // flag is set if printStatus is called
Int_t embedding; // flag is set if real data should be embedded into simulation data
HLocation loc; //! location for new object.
HIterator* iter; //! iterator on raw data.
HIterator* iterstart; //! iterator on start data.
HMdcCalParRaw* calparraw;//! calibration parameters
HMdcLookupGeom* lookup; //! lookup table for mapping
HMdcTimeCut* timecut; //! container for cuts on time1,time2,time2-time1
HMdcCutStat* cutStat; //! container for statistics on cuts
HMdcWireStat* wireStat; //! container for statistics on cuts
static Float_t globalOffset[4]; //! global offset per plane
static Float_t globalSecOffset[6][4]; //! global offset per plane
static Float_t globalSlope; //! global tdc slope
static Int_t countNrWiresPerMod[6][4]; //! counter array for wires /module/event
static Int_t countNrWiresPerModCal[6][4]; //! counter array for wires /module/event on cal after cuts
Int_t cuts[5]; //! counter array passed/not passed time and multiplicity cuts
Int_t cutthreshold; //! max number of wires in Cal1
Bool_t useMultCut; //! use/ don't use mult cut
Bool_t doprint; //! print flag for mult cut option
Bool_t skipCal; //! skip all mdc cal events
static Bool_t useWireStat; //! skip wires which are broken
void initParameters(void);
void initCounters()
{
for(Int_t i=0;i<6;i++)
{
for(Int_t j=0;j<4;j++)
{
countNrWiresPerMod[i][j]=0;
}
}
};
void initCountersCal()
{
for(Int_t i=0;i<6;i++)
{
for(Int_t j=0;j<4;j++)
{
countNrWiresPerModCal[i][j]=0;
}
}
};
Bool_t doMultCut()
{
for(Int_t i=0;i<6;i++)
{
for(Int_t j=0;j<4;j++)
{
if(countNrWiresPerModCal[i][j]>cutthreshold) return kTRUE;
}
}
return kFALSE;
}
void setParContainers(void);
Float_t getstarttime();
Bool_t testTimeCuts(Float_t,Float_t);
Bool_t translateAddress(Int_t*,Int_t*);
void calcTimes(Float_t*,Float_t*,Float_t,Int_t,HMdcCalParTdc*);
void fillCal1(Float_t ,Float_t ,Int_t );
void countWiresPerMod();
void printWires();
public:
HMdcCalibrater1(void);
HMdcCalibrater1(const Text_t* name,const Text_t* title,Int_t vers=1,Int_t cut=1,Int_t domerge=0);
~HMdcCalibrater1(void);
Bool_t init(void);
void setDoPrint(Bool_t dopr) {doprint=dopr;}
void setSkipCal(Bool_t skip=kTRUE) {skipCal=skip;}
void setUseMultCut(Int_t thresh,Bool_t use=kTRUE){cutthreshold=thresh;useMultCut=use;}
static void setUseWireStat(Bool_t doit) { useWireStat=doit; }
void switchArguments(Int_t,Int_t,Int_t);
void setGlobalOffset(Float_t o0,Float_t o1,Float_t o2,Float_t o3)
{
for(Int_t s=0;s<6;s++) {
globalSecOffset[s][0]=o0;
globalSecOffset[s][1]=o1;
globalSecOffset[s][2]=o2;
globalSecOffset[s][3]=o3;
}
}
void setSecGlobalOffset(Int_t s,Float_t o0,Float_t o1,Float_t o2,Float_t o3)
{
if(s<0 || s>5) return;
globalSecOffset[s][0]=o0;
globalSecOffset[s][1]=o1;
globalSecOffset[s][2]=o2;
globalSecOffset[s][3]=o3;
}
void setGlobalSlope(Float_t s){globalSlope=s;}
Bool_t finalize(void) {return kTRUE;}
void printStatus();
Int_t execute(void);
ClassDef(HMdcCalibrater1,0) // Calibrater raw->cal1 for Mdc data
};
#endif /* !HMDCCALIBRATER1_H */
|
be3d08790004e42d5b2f73e4a72709aaa3b652e8
|
dde923ce9836c908f2f1c385f267de63fe0ad8c2
|
/src/ui/texturewidget.cpp
|
cbf75945a5bf8f0c05ddd7b3e910306a939c6dcf
|
[
"MIT"
] |
permissive
|
giordi91/parallel_image
|
6b3bb6144533444199423ca378c513b6d247e3b5
|
3957aaf00d83738045fa35c2c5662e465b5010a6
|
refs/heads/master
| 2020-06-08T20:50:08.590229
| 2015-04-28T22:09:48
| 2015-04-28T22:09:48
| 32,603,285
| 1
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 11,131
|
cpp
|
texturewidget.cpp
|
#include <iostream>
#include <QtGui/QSurfaceFormat>
#include <ui/texturewidget.h>
#include <QtWidgets/QFileDialog>
//static const texture map declaration
GLfloat const TextureWidget::texcoord[8] = {
0.0f,0.0f,
0.0f,1.0f,
1.0f,1.0f,
1.0f,0.0f,
};
//static index data declaration
GLubyte const TextureWidget::indexData[6] = {0,1,2,0,2,3};
TextureWidget::TextureWidget(QWidget *par) :
QOpenGLWidget(par),
m_glsl_program(nullptr),
m_texture(nullptr),
m_texture_buffer(nullptr),
m_offset(vec2(0.0,0.0)),
m_scale(1),
last_x(0),
last_y(0)
{
//setting wanted opengl version
QSurfaceFormat qformat;
qformat.setDepthBufferSize(24);
qformat.setVersion(4, 3);
qformat.setSwapInterval(0);
setFormat(qformat);
//setting up the frame count
m_frameCount = 0;
m_currentTime = QTime::currentTime();
m_pastTime = m_currentTime;
//setting up shortcuts
reset_short= new QShortcut(QKeySequence("Ctrl+r"), this);
QObject::connect(reset_short, SIGNAL(activated()), this, SLOT(reset_user_transform()));
fit_short= new QShortcut(QKeySequence("Ctrl+f"), this);
QObject::connect(fit_short, SIGNAL(activated()), this, SLOT(fit_to_screen()));
}
////////////////// FILE HANDLING /////////////////
void TextureWidget::open_bmp_from_disk(const char * path)
{
this->show();
//first make sure we cleanup memory before re-allocating
clean_up_texture_data();
//creating and loading the texture to display
m_texture = new Bitmap;
m_texture->open(path);
//creating the texture buffer
m_texture_buffer = new QOpenGLTexture(QOpenGLTexture::Target2D);
m_texture_buffer->create();
m_texture_buffer->bind();
//manually setting up the texture parameters
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT );
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT );
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
//querying texture size
float w,h;
w = (float)m_texture->get_width();
h = (float)m_texture->get_height();
//manually copying the texure data on the gpu
glTexImage2D(GL_TEXTURE_2D,
0, GL_RGB,
w, h, 0,
GL_RGB, GL_UNSIGNED_BYTE,
m_texture->getRawData());
//generating mip maps
m_texture_buffer->generateMipMaps();
//creating the correct positional buffer data
create_vertex_data((int)w,(int)h);
//fitting the image on screen
fit_to_screen();
}
void TextureWidget::upload_cpu_buffer(uint8_t * buffer)
{
float w = (float)m_texture->get_width();
float h = (float)m_texture->get_height();
//manually setting up the texture parameters
m_texture_buffer->bind();
glTexImage2D(GL_TEXTURE_2D,
0, GL_RGB,
w, h, 0,
GL_RGB, GL_UNSIGNED_BYTE,
buffer);
m_texture_buffer->generateMipMaps();
update();
}
void TextureWidget::open()
{
QString fileName = QFileDialog::getOpenFileName(this,
tr("Open Image"), "/home/", tr("Image Files (*.bmp)"));
if (fileName.isNull())
{
return;
}
//TODO CHECK FOR EXCEPTION THROW
open_bmp_from_disk( fileName.toLocal8Bit().constData());
}
Bitmap * TextureWidget::get_image_data() const
{
return m_texture;
}
////////////////// DATA MANAGEMENT ////////////////
void TextureWidget::clean_up_texture_data()
{
makeCurrent();
if (m_texture)
{
delete m_texture;
}
if (m_texture_buffer)
{
m_texture_buffer->destroy();
delete m_texture_buffer;
}
m_texture = nullptr;
m_texture_buffer = nullptr;
}
void TextureWidget::create_vertex_data(const int &width,
const int &height)
{
makeCurrent();
m_vao1->bind();
//creating and setupping the vertex buffer
float positionData[12] = {0.0f, 0.0f, 0.0f,
0.0f, (float)height, 0.0f,
(float)width, (float)height, 0.0f,
(float)width, 0, 0.0f};
m_positionBuffer= (QOpenGLBuffer(QOpenGLBuffer::VertexBuffer));
m_positionBuffer.create();
m_positionBuffer.setUsagePattern( QOpenGLBuffer::StaticDraw );
m_positionBuffer.bind();
m_positionBuffer.allocate(positionData, 12 * (int)sizeof(float));
glVertexAttribPointer( 0, 3, GL_FLOAT, GL_FALSE, 0, (GLubyte *)NULL );
}
////////////////////// UTILITIES /////////////////
void TextureWidget::reset_user_transform()
{
m_scale =1;
m_offset= vec2(0,0);
update();
}
void TextureWidget::fit_to_screen()
{
if (!m_texture)
{
return;
}
m_offset= vec2(0,0);
//set it to the ration
int winW;
winW = this->width();
float ratio = float(winW)/float(m_texture->get_width());
m_scale = ratio;
update();
}
void TextureWidget::computeFps()
{
// Increase frame count
m_frameCount++;
// Get the number of milliseconds since glutInit called
// (or first call to glutGet(GLUT ELAPSED TIME)).
m_currentTime = QTime::currentTime();
// Calculate time passed
m_timeInterval = m_pastTime.msecsTo(m_currentTime);
if(m_timeInterval > 1000)
{
// calculate the number of frames per second
m_fps = m_frameCount / (int)((float)m_timeInterval / 1000.0f);
// Set time
m_pastTime = m_currentTime;
// Reset frame count
m_frameCount = 0;
std::cout<<m_fps<<" FPS"<<std::endl;
}
}
///////////////////////// OPENGL ///////////////////
void TextureWidget::initializeGL()
{
//initializing all the opengl function and context
initializeOpenGLFunctions();
//creatting a new GLSL_program
m_glsl_program = new GLSL_program;
//loading and compiling vertex shaders
m_glsl_program->load_vertex_shader("../textureViewer/texture.vert");
m_glsl_program->load_fragment_shader("../textureViewer/texture.frag");
//setting the program as active
m_glsl_program->use();
//crating vertex array object
m_vao1 = new QOpenGLVertexArrayObject( this );
m_vao1->create();
m_vao1->bind();
//crating and allocating the index buffer
m_indexBuffer= (QOpenGLBuffer(QOpenGLBuffer::IndexBuffer));
m_indexBuffer.create();
m_indexBuffer.setUsagePattern( QOpenGLBuffer::StaticDraw );
m_indexBuffer.bind();
m_indexBuffer.allocate(indexData, 6 * (int)sizeof(GLubyte));
//crating and allocating the text coordinates
m_texture_coord= (QOpenGLBuffer(QOpenGLBuffer::VertexBuffer));
m_texture_coord.create();
m_texture_coord.setUsagePattern( QOpenGLBuffer::StaticDraw );
m_texture_coord.bind();
m_texture_coord.allocate(texcoord, 8 * (int)sizeof(GLfloat));
glVertexAttribPointer( 1, 2, GL_FLOAT, GL_FALSE, 0, (GLubyte *)NULL );
}
void TextureWidget::resizeGL(int w, int h)
{
//setting new size for the viewport and
//re-calculating the ortho matrix for proj
glViewport(0,0,GLsizei(w),GLsizei(h));
m_ortho = glm::ortho<GLfloat>( 0.0f, (GLfloat)w, (GLfloat)h, 0.0f, 1.0f, -1.0f );
}
void TextureWidget::paintGL()
{
if (!m_texture_buffer || !m_texture)
{
return;
}
// computeFps();
glClear(GL_COLOR_BUFFER_BIT);
//binding the needed buffers
m_vao1->bind();
m_texture_buffer->bind();
//computing final matrix as a result of
//the user transformation and projection
//matrix
m_world = glm::mat4(1.0f);
m_world = glm::scale(m_world,glm::vec3(m_scale,m_scale,1));
//we are panning around and we are compensating for the scale factor
m_world = glm::translate(m_world,glm::vec3(m_offset.x/m_scale,
m_offset.y/m_scale,
0.0));
m_final = m_ortho * m_world;
//passing the matrix to the shaders
m_glsl_program->set_shader_attribute("ortho",m_final);
//enabling needed attributes and paint
glEnableVertexAttribArray(0); // Vertex position
glEnableVertexAttribArray(1); // Text maps
glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_BYTE, (GLvoid*)0);
float w,h;
w = (float)m_texture->get_width();
h = (float)m_texture->get_height();
create_vertex_data((int)w,(int)h);
}
void TextureWidget::opengl_version_log()
{
const GLubyte *renderer = glGetString( GL_RENDERER );
const GLubyte *vendor = glGetString( GL_VENDOR );
const GLubyte *version = glGetString( GL_VERSION );
const GLubyte *glslVersion = glGetString( GL_SHADING_LANGUAGE_VERSION );
GLint major, minor;
glGetIntegerv(GL_MAJOR_VERSION, &major);
glGetIntegerv(GL_MINOR_VERSION, &minor);
//log
printf("GL Vendor : %s\n", vendor);
printf("GL Renderer : %s\n", renderer);
printf("GL Version (string) : %s\n", version);
printf("GL Version (integer) : %d.%d\n", major, minor);
printf("GLSL Version : %s\n", glslVersion);
}
////////////////////// MOUSE EVENTS SETUP ////////////
void TextureWidget::mouseMoveEvent(QMouseEvent *e)
{
//extracting the mouse positon
int posX, posY;
posX = e->pos().x();
posY = e->pos().y();
//computing the delta vector respect
//previous position
int deltaX = posX- last_x;
int deltaY = posY- last_y;
if(e->buttons() == Qt::MidButton)
{
//setting the new pan value
m_offset+= vec2(deltaX,deltaY);
//forcing paint
update();
}
else if (e->buttons() == Qt::RightButton)
{
//delcaring delta vec and computing its length
vec2 delta(deltaX,deltaY);
float len =glm::length(delta);
//we perform a dot product to find if we scale
//up or down
if (glm::dot(vec2(1.0f,0),delta)>0)
{
m_scale+=(len/1000.0f);
// m_offset+= vec2(-m_scale * m_texture->get_width()
// ,m_scale * m_texture->get_height());
}else
{
m_scale-=(len/1000.0f);
// m_offset-= vec2(m_scale * m_texture->get_width()
// ,m_scale * m_texture->get_height());
}
//forcing paint
update();
}
//updating previous position
last_x =posX;
last_y =posY;
}
void TextureWidget::mousePressEvent(QMouseEvent *e)
{
//storing the previos pose in case
//the user starts to drag
last_x = e->pos().x();
last_y = e->pos().y();
}
/////////////// DESTRUCTOR ////////////////
TextureWidget::~TextureWidget()
{
//making sure the context is current
makeCurrent();
//deleting the allocated program
if (m_glsl_program)
{
delete m_glsl_program;
}
if (m_vao1)
{
delete m_vao1;
}
clean_up_texture_data();
}
|
de53a3f5736f891ace0107121b197a2cdcf30e5e
|
91c7ea82d661d457402a8d11fa1c75355cf4d82b
|
/lec12/filesystementry.cpp
|
52498bb3af55ea229d502d5ff48a4606b5b93c38
|
[] |
no_license
|
zaychenko-sergei/oop-samples
|
61fa7c354944b9bfb939324aa70715160d27d2d4
|
ec3b3e7aecb01d377ba53bb3e2325e03630b4ada
|
refs/heads/master
| 2020-12-09T14:01:57.482498
| 2016-08-27T22:19:01
| 2016-08-27T22:19:01
| 42,003,142
| 6
| 1
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,292
|
cpp
|
filesystementry.cpp
|
// (C) 2013-2015, Sergei Zaychenko, KNURE, Kharkiv, Ukraine
#include "filesystementry.hpp"
/*****************************************************************************/
FilesystemEntry::FilesystemEntry ( const std::string & _name )
: m_name( _name )
{
ensureValidName( m_name );
}
/*****************************************************************************/
void FilesystemEntry::rename ( const std::string & _newName )
{
ensureValidName( _newName );
m_name = _newName;
}
/*****************************************************************************/
void FilesystemEntry::ensureValidName ( const std::string & _name )
{
if ( _name.empty() )
throw std::logic_error( "Name cannot be empty" );
if ( _name.length() > 255 )
throw std::logic_error( "Name is too long" );
if ( _name.find_first_of( "*:<>?\\/|" ) != std::string::npos )
throw std::logic_error( "Name contains forbidden characters" );
}
/*****************************************************************************/
void FilesystemEntry::show ( std::ostream & _o, int _level ) const
{
for ( int i = 0; i < _level; i++ )
_o << '\t';
_o << '\"' << getName() << "\" (" << getSize() << " bytes)" << std::endl;
}
/*****************************************************************************/
|
a3e9182573b6682a78d5116970c2d9e895348ba3
|
8620d98b00cf0a9f60415408bf82184efd20431a
|
/Codewars/Validate Credit Card Number.cpp
|
bf11e7b7fe14eea3acc98c418a081350615ccb07
|
[] |
no_license
|
SA-Inc/Contest-Tasks
|
628aa4028bb5e3e5efc519c1369f5c95f4b46eff
|
dfffaec7d93fe217f19d532a3c5c799103f2a06d
|
refs/heads/main
| 2023-02-26T21:56:54.067172
| 2021-02-09T07:23:26
| 2021-02-09T07:23:26
| 323,820,065
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,029
|
cpp
|
Validate Credit Card Number.cpp
|
// https://www.codewars.com/kata/5418a1dd6d8216e18a0012b2
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
using namespace std;
int sumVector(vector<int> v) {
int sum = 0;
for (size_t i = 0; i < v.size(); i++) {
sum += v[i];
}
return sum;
}
vector<int> splitNumberIntoDigit(long long int number) {
vector<int> digits;
while (number > 0) {
int digit = number % 10;
number /= 10;
digits.push_back(digit);
}
return digits;
}
class Kata {
public:
static bool validate(long long int n) {
vector<int> digits = splitNumberIntoDigit(n);
for (size_t i = 0; i < digits.size(); i++) {
if (i % 2 != 0) {
digits[i] *= 2;
}
}
for (size_t i = 0; i < digits.size(); i++) {
if (digits[i] > 9) {
digits[i] = sumVector(splitNumberIntoDigit(digits[i]));
}
}
if (sumVector(digits) % 10 == 0){
return true;
} else {
return false;
}
}
};
|
cc4e01f7b1ef0f9b4e003c70237d2170124c7086
|
5a66d961d5d0542be0fcb3f83961d2f07bab2401
|
/PadmeReco/Target/src/TargetGeometry.cc
|
2023c56d28d16543955116e99d7d13e551c11fd0
|
[] |
no_license
|
PADME-Experiment/padme-fw
|
1f2b56899e311b958945d0b1c4f934dfeeba761a
|
bec2a83e3a32b8db38977c404d78f4f36a384f30
|
refs/heads/develop
| 2023-08-06T11:27:10.402467
| 2023-07-18T10:15:50
| 2023-07-18T10:15:50
| 44,676,186
| 11
| 6
| null | 2023-07-18T10:15:52
| 2015-10-21T12:57:21
|
C++
|
UTF-8
|
C++
| false
| false
| 1,231
|
cc
|
TargetGeometry.cc
|
// --------------------------------------------------------------
// History:
//
// Created by Stefania Spagnolo (stefania.spagnolo@le.infn.it) 2019-03-14
//
// --------------------------------------------------------------
#include "Riostream.h"
#include "RecoVChannelID.hh"
#include "TTargetRecoBeam.hh"
#include "TRecoVHit.hh"
#include "TargetGeometry.hh"
TargetGeometry::TargetGeometry()
: PadmeVGeometry()
{
std::cout<<"TargetGeometry being created ............"<<std::endl ;
fRuler=0;
}
void TargetGeometry::Init(PadmeVRecoConfig *cfg, RecoVChannelID *chIdMgr)
{
PadmeVGeometry::Init(cfg, chIdMgr);
fRuler = (double)cfg->GetParOrDefault("GEOMETRY", "Ruler" , 52);
std::cout<<"*********Ruler Position = "<<fRuler<<std::endl ;
fLocOxinPadmeFrame= fLocOxinPadmeFrame+(fRuler-52);
PadmeVGeometry::UpdateTransform();
}
TVector3 TargetGeometry::LocalPosition(Int_t chId)
{
int ix = fChIdx0;
int iy = fChIdy0;
int iz = fChIdz0;
if(chId<17) {
iy=chId;
}
else {
ix=chId;
}
double x = (chId-ix)*fStep1ChLocalX + fChIdx0Offset;
double y = (chId-iy)*fStep1ChLocalY + fChIdy0Offset;
double z = (chId-iz)*fStep1ChLocalZ + fChIdz0Offset;
return TVector3(x,y,z);
}
|
7c970d011e6fe29c253875351df2e062145528aa
|
346e521e15bf7dcf92096253eecbea03e933d458
|
/main.cpp
|
4ddc662f63907accdce39b6981fcf8c6f7ab4618
|
[] |
no_license
|
cryboykevin/SimpleGameEngine
|
8e224b1a707733ec8ad1dbd12df5ef7c69ae04e6
|
ea7a7d49c804ca53d424d101a485e1439a7c62ed
|
refs/heads/master
| 2016-09-06T09:23:43.117774
| 2011-09-05T11:36:26
| 2011-09-05T11:36:26
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 264
|
cpp
|
main.cpp
|
#include <SDL.h>
#include <QApplication>
#include "controlwidget.h"
int main( int argc, char* argv[] )
{
QApplication app( argc, argv );
ControlWidget* ptrWgt = new ControlWidget();
ptrWgt->show();
return app.exec();
}
|
74dbe46cdffc25354a913e0f98c3953f2dac8723
|
caf93a6534419c1ecbb00897d58f21d46eaec81e
|
/Sources code/DLL_miniscope_v2c/ScopedLock.h
|
2542d0462522689a16d15166f6327d29d2be590e
|
[] |
no_license
|
opus506/2_dolar_oscilloscope
|
4916279f9d5be349ed5b096886a918ebed8563b6
|
ff6f2fc56f72beb2d0c6728fabc4f471a26e7d34
|
refs/heads/master
| 2020-03-27T17:14:58.734999
| 2018-08-30T16:52:16
| 2018-08-30T16:52:16
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 418
|
h
|
ScopedLock.h
|
#ifndef ScopedLockH
#define ScopedLockH
// Usage: ScopedLock<Mutex> lock(mutex);
template <class M> class ScopedLock
{
public:
ScopedLock(M& mutex): m_mutex(mutex) {
//OutputDebugString("lock");
m_mutex.lock();
}
~ScopedLock() {
//OutputDebugString("unlock");
m_mutex.unlock();
}
private:
M& m_mutex;
ScopedLock();
ScopedLock(const ScopedLock&);
ScopedLock& operator = (const ScopedLock&);
};
#endif
|
1acdf63670f5de8a841ad4e01c98c1415055a826
|
26bb27b6439ba1c846eb9e1c22bc58c034888752
|
/XmlDataTable/Source/XmlDataTable/Private/DataTableImporterXml.h
|
a51e2d8aa2f83f34840267bba8ffaf203d93fadd
|
[] |
no_license
|
sergeibulavintsev/ue4_plugins
|
0c974b407c7ab64795b4089b05fb354850effb32
|
44d30df3fedc3cad44a6645e815a2942201066d2
|
refs/heads/master
| 2021-04-28T20:52:20.416724
| 2018-04-10T16:26:59
| 2018-04-10T16:26:59
| 121,937,137
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 201
|
h
|
DataTableImporterXml.h
|
#pragma once
#include "CoreMinimal.h"
class UDataTable;
class FDataTableImporterXml
{
public:
bool ReadTable(UDataTable& InDataTable, FString InFileName, TArray<FString>& OutProblems);
};
|
91803953be9b940b0e1c80fb466a47f208c27930
|
f05227cffcfeb9e245394f7c5c54e9e6c9c5827c
|
/HammingCode/Hamming.h
|
9e4cb4964d0a36ff24965077da97ff9fb8a68833
|
[] |
no_license
|
FALCH2000/Tarea1
|
ff9eb22731553145bf48a5ec5ab8623a592a1ccc
|
abff5a941f1d94e2a4476cf0fa2cb5c8b37b6990
|
refs/heads/master
| 2023-07-23T17:20:30.732456
| 2021-09-08T15:20:22
| 2021-09-08T15:20:22
| 401,923,261
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 2,658
|
h
|
Hamming.h
|
#ifndef TAREA_1_HAMMING_H
#define TAREA_1_HAMMING_H
#include <iostream>
#include <vector>
#include <valarray>
class Hamming {
public:
Hamming();
/**
* @brief Agrega los bits de paridad al vector de paridad
* @return
*/
std::vector<bool> agregarBitsDeParidad(std::vector<bool> vectorMsj);
/**
* @brief Devuelve la posición de los bits de paridad de una cadena de bits
* @param vectorMsj
* @return
*/
std::vector<int> posDeBitsDeParidad(std::vector<bool> vectorMsj);
/**
* @brief Recibe la posición de un bit de paridad y devuelve la posición de los bits que verifica,
* si retorna -1, la pos de entrada no es de un bit de paridad o es muy grande
* @param msj
* @param posBitParidad
* @return
*/
std::vector<int> posQueVerificaUnBitDeParidad(std::vector<bool> msj, int posBitParidad);
/**
* @brief Establece los valores de los bits de paridad de forma que cumpla con
* el tipo de paridad
* @param msj
* @return
*/
std::vector<bool> establecerValoresDeParidad(std::vector<bool> msj);
/**
* @brief Altera el bit en la posición de entrada
* @param vectorMsj
* @param pos
* @return
*/
std::vector<bool> modificarBitEnPos(std::vector<bool> vectorMsj, int pos);
/**
* @brief Devuelve un vector con la posición de los bits de paridad que
* detectaron un error.
* @param msj
* @return
*/
std::vector<int> bitsDeParidadQueDetectanError(std::vector<bool> msj);
/**
* @brief Devuelve la posición del bit cambiado, -1 signigica que no hubo error
* @param msj
* @return
*/
int seekError(std::vector<bool> msj);
/**
* @brief Cambia el tipo de paridad
*/
void cambiarTipoParidad();
void print(std::vector<bool> vector);
private:
bool tipoPardida;
/**
* @brief Establece el valor del primer bit, el bit de la paridad total
* @param msj
* @return
*/
std::vector<bool> establecerValoresDeParidadTotal(std::vector<bool> msj);
/**
* @brief Setea el valor del bit
* @param msj
* @param ont_count
* @param pos
* @return
*/
std::vector<bool> setParidad(std::vector<bool> msj, int ont_count, int pos);
/**
* @brief Verifica si el número de 1 cumple con el tipo de paridad
* @param count
* @return
*/
bool numeroUnosCumpleParidad(int count);
/**
* @brief Revisa la paridad de toda la cadena de bits
* @param msj
* @return
*/
bool revisarParidadGeneral(std::vector<bool> msj);
};
#endif //TAREA_1_HAMMING_H
|
286f0bf88ce94dd9ef7b8261de699ee6d4336a9e
|
93c3cd8301d70211718e73f02beb7718223313dd
|
/qt/DsaMediaControlKit/custom_media_player.cpp
|
f48fb76bb68d1fd29e28d57c66b185ce2b6a0a2a
|
[] |
no_license
|
b00dle/DsaMediaControlKit
|
286af1bce088bc36a17d831f707a808e91425886
|
6be42a30625dd9d867b79de3f8e6636d61f74e5e
|
refs/heads/master
| 2021-07-17T12:24:26.364226
| 2017-03-08T13:18:22
| 2017-03-08T13:18:22
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 4,390
|
cpp
|
custom_media_player.cpp
|
#include "custom_media_player.h"
#include <random>
CustomMediaPlayer::CustomMediaPlayer(QObject* parent)
: QMediaPlayer(parent)
, activated_(false)
, current_content_index_(0)
, delay_flag_(false)
, delay_(0)
, delay_timer_(0)
{
delay_timer_ = new QTimer(this);
connect(delay_timer_, SIGNAL(timeout()),
this, SLOT(delayIsOver()));
}
void CustomMediaPlayer::play()
{
Playlist::Playlist* playlist = getCustomPlaylist();
if(playlist){
Playlist::Settings* settings = playlist->getSettings();
setVolume(settings->volume);
// if delay interval is turned on
if (settings->order == Playlist::PlayOrder::ORDERED){
if (settings->loop_flag){
playlist->setPlaybackMode(QMediaPlaylist::Loop);
}else if (!settings->loop_flag){
playlist->setPlaybackMode(QMediaPlaylist::Sequential);
}
} else if (settings->order == Playlist::PlayOrder::SHUFFLE){
playlist->setPlaybackMode(QMediaPlaylist::Random);
int index = getRandomIntInRange(0,playlist->mediaCount()-1);
playlist->setCurrentIndex(index);
} else if (settings->order == Playlist::PlayOrder::WEIGTHED){
// TO DO implement weighted
QMediaPlayer::pause();
}
if (settings->interval_flag){
delay_ = getRandomIntInRange(settings->min_delay_interval,
settings->max_delay_interval);
delay_flag_ = true;
if (activated_){
QMediaPlayer::play();
qDebug() << "Playing Index: "<<playlist->currentIndex();
playlist->setPlaybackMode(QMediaPlaylist::CurrentItemOnce);
}
} else {
delay_flag_ = false;
delay_ = 0;
if (activated_){
QMediaPlayer::play();
qDebug() << "Playing Index: "<<playlist->currentIndex();
}
}
}
}
void CustomMediaPlayer::setPlaylist(Playlist::Playlist *playlist)
{
connect(playlist, SIGNAL(currentIndexChanged(int)),
this, SLOT(currentMediaIndexChanged(int)) );
connect(playlist, SIGNAL(changedSettings()),
this, SLOT(mediaSettingsChanged()) );
QMediaPlayer::setPlaylist(playlist);
}
void CustomMediaPlayer::delayIsOver()
{
delay_timer_->stop();
play();
}
void CustomMediaPlayer::activate()
{
activated_ = true;
emit toggledPlayerActivation(true);
}
void CustomMediaPlayer::deactivate()
{
activated_ = false;
emit toggledPlayerActivation(false);
}
void CustomMediaPlayer::setActivation(bool flag)
{
activated_ = flag;
emit toggledPlayerActivation(flag);
}
int CustomMediaPlayer::getRandomIntInRange(int min, int max)
{
std::random_device rd; // only used once to initialise (seed) engine
std::mt19937 rng(rd()); // random-number engine used (Mersenne-Twister in this case)
std::uniform_int_distribution<int> uni(min,max); // guaranteed unbiased
return uni(rng);
}
void CustomMediaPlayer::currentMediaIndexChanged(int position)
{
current_content_index_ = position;
if (activated_ && delay_flag_){
delay_timer_->start(delay_*1000);
}
}
void CustomMediaPlayer::mediaSettingsChanged()
{
Playlist::Settings* settings = getCustomPlaylist()->getSettings();
setVolume(settings->volume);
if (settings->interval_flag){
delay_flag_ = true;
delay_ = getRandomIntInRange(settings->min_delay_interval,
settings->max_delay_interval);
} else {
delay_flag_ = false;
delay_ = 0;
}
if (settings->order == Playlist::PlayOrder::ORDERED){
} else if (settings->order == Playlist::PlayOrder::SHUFFLE){
getCustomPlaylist()->setPlaybackMode(QMediaPlaylist::Random);
} else if (settings->order == Playlist::PlayOrder::WEIGTHED){
qDebug() << "weigthed not implemented yet";
}
}
void CustomMediaPlayer::mediaVolumeChanged(int val)
{
qDebug() << val;
if (val >= 0 && val <= 100){
setVolume(val);
}
}
Playlist::Playlist *CustomMediaPlayer::getCustomPlaylist() const
{
Playlist::Playlist* pl = qobject_cast<Playlist::Playlist*>( playlist() );
if(pl){
return pl;
} else {
return nullptr;
}
}
|
898d57881b23e75cef513c8a461d5ad8e1b06937
|
2eb3b66b421a1f4a18bcb72b69023a3166273ca1
|
/Codeforces/613/A/A.cc
|
fae7506eba89b07643407815163a1be401d6ec6a
|
[] |
no_license
|
johnathan79717/competitive-programming
|
e1d62016e8b25d8bcb3d003bba6b1d4dc858a62f
|
3c8471b7ebb516147705bbbc4316a511f0fe4dc0
|
refs/heads/master
| 2022-05-07T20:34:21.959511
| 2022-03-31T15:20:28
| 2022-03-31T15:20:28
| 55,674,796
| 2
| 2
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 3,103
|
cc
|
A.cc
|
// Create your own template by modifying this file!
#include <string>
#include <vector>
#include <climits>
#include <cstring>
#include <map>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <cassert>
#include <deque>
#include <stack>
#include <functional>
#define X first
#define Y second
#define MAX(x, a) x = max(x, a)
#define MIN(x, a) x = min(x, a)
#define CASET int ___T; scanf("%d ", &___T); while (___T-- > 0)
#define SZ(X) ((int)(X).size())
#define LEN(X) strlen(X)
#define FOR(i,c) for(auto &i: c)
#define ALL(x) (x).begin(),(x).end()
#define REP(i,n) for(int i=0;i<(n);i++)
#define REP1(i,a,b) for(int i=(a);i<=(b);i++)
#define REPL(i,x) for(int i=0;x[i];i++)
#define PER(i,n) for(int i=(n)-1;i>=0;i--)
#define PER1(i,a,b) for(int i=(a);i>=(b);i--)
#define RI1(x) scanf("%d",&x)
#define RI2(x,y) RI1(x), RI1(y)
#define RI3(x,y...) RI1(x), RI2(y)
#define RI4(x,y...) RI1(x), RI3(y)
#define RI5(x,y...) RI1(x), RI4(y)
#define RI6(x,y...) RI1(x), RI5(y)
#define GET_MACRO(_1, _2, _3, _4, _5, _6, NAME, ...) NAME
#define RI(argv...) GET_MACRO(argv, RI6, RI5, RI4, RI3, RI2, RI1)(argv)
#define DRI(argv...) int argv;RI(argv)
#define RS(x) scanf("%s",x)
#define PI(x) printf("%d\n",x)
#define PIS(x) printf("%d ",x)
#define DRL(x) LL x; RL(x)
#ifdef ONLINE_JUDGE
#define PL(x) printf("%I64d\n",x)
#define RL(x) scanf("%I64d\n",&x)
#else
#define PL(x) printf("%lld\n",x)
#define RL(x) scanf("%lld\n",&x)
#endif
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define BG begin()
#define ED end()
#define PQ priority_queue
#define MS0(x) memset(x,0,sizeof(x))
#define MS1(x) memset(x,-1,sizeof(x))
#define SEP(x) ((x)?'\n':' ')
#define DRA(A, N) VI A(N); REP(i, N) RI(A[i])
using namespace std;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef long long LL;
const int INF = 1000000000;
template<typename T>
using V = std::vector<T>;
#ifdef DEBUG
#define debug(args...) {dbg,args; cerr<<endl;}
#else
#define debug(args...) // Just strip off all debug tokens
#endif
struct debugger
{
template<typename T> debugger& operator , (const T& v)
{
cerr<<v<<" ";
return *this;
}
} dbg;
int main()
{
DRI(N, x, y);
double m = LLONG_MAX, M = LLONG_MIN;
vector<pair<LL,LL>> p;
REP(i, N) {
DRI(xx, yy);
p.EB(xx-x, yy-y);
double dd = 1.0*(x-xx)*(x-xx)+1.0*(y-yy)*(y-yy);
MAX(M, dd);
MIN(m, dd);
}
if (N == 1) {
PI(0);
return 0;
}
p.PB(p[0]);
REP(i, N) {
LL x1 = p[i].first, y1 = p[i].second;
LL x2 = p[i+1].first, y2 = p[i+1].second;
if (x1 == x2 && y1 == y2) continue;
double t = (x2 * (x2 - x1) + y2 * (y2 - y1) ) * 1.0 / ((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
if (t >= 0 && t <= 1) {
double x = t * x1 + (1-t) * x2, y = t * y1 + (1-t) * y2;
MIN(m, x*x + y * y);
}
}
printf("%.18f\n", (M - m) * acos(-1));
}
|
83f2fec4c263c6de42174ac557596bc43d64f155
|
576530c6a3091b65882a5ff66d97e381bc0ea7e2
|
/remote/impl/src/sof/framework/remote/corba/RemoteSOFLauncher.h
|
81407b4a4a87b02548e3f1a2b9ad496751c9035b
|
[] |
no_license
|
jun1017/sof
|
8a37f7575e226db1e8780c890ae6ecbfc08734d6
|
3338ee14150aededc141a243ce6c5e6149c573d3
|
refs/heads/master
| 2021-05-18T17:06:51.762674
| 2020-03-30T14:34:08
| 2020-03-30T14:34:08
| 251,330,896
| 0
| 0
| null | 2020-04-16T13:44:09
| 2020-03-30T14:30:52
|
C++
|
UTF-8
|
C++
| false
| false
| 5,638
|
h
|
RemoteSOFLauncher.h
|
#ifndef REMOTE_SOF_LAUNCHER_H
#define REMOTE_SOF_LAUNCHER_H
#include "sof/framework/Launcher.h"
#include "sof/framework/BundleInfoBase.h"
#include "./registry/IRegistryFacadeImpl.h"
#include "./registry/IRemoteRegistryImpl.h"
#include "../../../services/admin/remote/RemoteAdministrationActivator.h"
#include "IRemoteBundleActivator.h"
#include "IRemoteBundleContextImpl.h"
#include "RemoteBundleInfo.h"
#include "CORBAHelper.h"
#include "../../../services/admin/remote/corba/CORBAAdminServiceImpl.h"
using namespace std;
using namespace sof::framework;
using namespace sof::framework::remote::corba::registry;
using namespace sof::framework::remote::corba;
using namespace sof::services::admin::remote;
using namespace sof::services::admin::remote::corba;
namespace sof { namespace framework { namespace remote { namespace corba {
/**
* The <code>Launcher</code> class is the entry point for
* running the SOF framework.<br>
* The main task of this class is to provide methods
* for starting and stopping bundles.
*
* @author magr74
*/
template<
class ThreadingModel = SingleThreaded,
template <class> class CreationPolicy = NullCreator>
class RemoteSOFLauncher : public IAdministrationProvider
{
protected:
/**
* Provides CORBA relevant helper functions.
*/
CORBAHelper& corbaHelper;
/**
* The name of the SOF process used for registering an administration/diagnosis
* component at naming service.
*/
string processName;
/**
* The IP address where the <code>CORBARegistry</code> object is reachable.
*/
string ipAddress;
/**
* The <code>ObjectCreator</code> instance which is used
* for instantiating the <code>IBundleActivator</code>
* objects.
*/
ObjectCreator<IRemoteBundleActivator,CreationPolicy> objectCreator;
/**
* The registry object which holds all relevant data of
* all bundles. It is the central administration object.
*/
IRegistry* registry;
/**
* The logger instance.
*/
static Logger& logger;
/**
* Creates the registry instance.
*
* @param ip
* The IP address of the <code>CORBARegistry</code> object.
*
* @return
* The registry instance.
*/
virtual IRegistry* createRegistry( const string& ip );
/**
* Creates the bundle context instances.
*
* @param bundleName
* The name of the bundle the bundle context object is
* created for.
*
* @return
* The bundle context instance.
*/
virtual IBundleContext* createBundleContext( const string& bundleName );
/**
* Starts the remote admin service which allows external CORBA clients to
* call administration and diagnosis functions.
*/
virtual void startRemoteAdminService();
public:
/**
* Creates instances of class <code>Launcher</code>.
*
* @param corbaHelper
* Provides CORBA related helper functions.
*
* @param procName
* The name of the SOF process.
*
* @param ip
* The IP address of the <code>CORBARegistry</code> object.
*/
RemoteSOFLauncher( CORBAHelper& corbaHelper, const string& procName, const string& ip );
/**
* Destroys the <code>Launcher</code> instance.
*/
virtual ~RemoteSOFLauncher();
/**
* Sets the log level of the framework. Defines
* for example whether only error messages or
* also debug messages shall be logged.
*
* @param level
* The log level (trace, debug, error).
*/
virtual void setLogLevel( Logger::LogLevel level );
/**
* Starts bundles. The bundles which are started are
* defined in a vector of <code>BundleConfiguration</code>
* objects.
*
* @param configuration
* The vector of <code>BundleConfiguration</code>
* objects whereas each object describes what
* bundle shall be started.
*/
virtual void start( vector<BundleConfiguration> &configuration );
/**
* Stops all bundles which were started.
*/
virtual void stop();
/**
* Starts a specific bundle. Can be also called after
* a <code>start()</code>.
*
* @param bundleConfig
* The object containing information which
* bundle must be started.
*/
virtual void startBundle( BundleConfiguration bundleConfig );
/**
* Stops a bundle.
*
* @param bundleName
* The name of the bundle which is stopped.
*/
virtual void stopBundle( const string& bundleName );
/**
* Starts the administration bundle (which
* provides a console for user inputs).
*/
virtual void startAdministrationBundle();
/**
* Returns the names of all started bundles.
*
* @return
* A vector containing all bundle names.
*/
virtual vector<string> getBundleNames();
/**
* Dumps all information (registered services,
* registered service listeners, services in use)
* of a bundle.
*
* @param bundleName
* The name of the bundle.
*
* @return
* A string containing all information
* about a bundle.
*/
virtual string dumpBundleInfo( const string& bundleName );
/**
* Dumps the name of all started bundles.
*
* @return
* A string containing all bundle names.
*/
virtual string dumpAllBundleNames();
/**
* Returns the bundle info object for the given bundle name.
*
* @param bundleName
* The bundle name.
*
* @return
* The bundle info object.
*/
virtual BundleInfoBase& getBundleInfo( const string& bundleName );
/**
* Returns the registry object.
*
* @return
* The registry object.
*/
virtual IRegistry& getRegistry();
};
#include "RemoteSOFLauncher.cpp"
}}}}
#endif
|
1cabbc82b9c6e1e5fbf4ef8d3a1c1dffbbacc208
|
8e105064236f5dee17638c17c6797e9cac52b084
|
/2842.cpp
|
e1ec84d7ec0386720817674cc1e7383de2377a3d
|
[] |
no_license
|
ParkDaeYi/Algorithm_Study
|
d7d325a05fc25f8668bdabdce1d856b7ad47d9f0
|
522fa801486485e35a8e775c83136293e0728f8a
|
refs/heads/master
| 2021-01-03T18:12:00.169409
| 2020-11-18T08:59:02
| 2020-11-18T08:59:02
| 240,185,918
| 1
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,752
|
cpp
|
2842.cpp
|
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
using namespace std;
typedef pair<int, int> pii;
int n, h[50][50], kcnt; // h: 고도, kcnt: 집의 수
int dy[8] = { 1,-1,0,0,1,1,-1,-1 }; // 수평 수직 대각
int dx[8] = { 0,0,1,-1,1,-1,1,-1 };
char p[50][50]; // 위치
bool visit[50][50]; // 방문 여부
pii src;
vector<int> tired;
int dfs(int y, int x, int left, int right) {
if (h[y][x] < left || right < h[y][x]) return 0; // 범위 초과시 return
int ret = 0;
if (p[y][x] == 'K') ret++;
for (int i = 0; i < 8; ++i) {
int ny = y + dy[i], nx = x + dx[i];
if (ny < 0 || nx < 0 || ny >= n || nx >= n) continue;
if (visit[ny][nx]) continue;
visit[ny][nx] = 1; // 주어진 범위로만 이동하므로 visit을 다시 0으로 해줄 필요 없음
ret += dfs(ny, nx, left, right);
}
return ret;
}
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
cin >> n;
for (int i = 0; i < n; ++i)
for (int j = 0; j < n; ++j) {
cin >> p[i][j];
if (p[i][j] == 'P') src = { i,j }; // 시작 지점
else if (p[i][j] == 'K') kcnt++; // 집 카운팅
}
for (int i = 0; i < n; ++i) for (int j = 0; j < n; ++j) { cin >> h[i][j]; tired.push_back(h[i][j]); }
sort(tired.begin(), tired.end());
tired.erase(unique(tired.begin(), tired.end()), tired.end()); // 연산 수를 줄이기 위해 중복 제거
int low = 0, high = 0, sz = tired.size(), ans = 1e9;
while (low <= high && high < sz) {
fill(&visit[0][0], &visit[n - 1][n], 0);
visit[src.first][src.second] = 1;
if (dfs(src.first, src.second, tired[low], tired[high]) == kcnt) {
ans = min(ans, tired[high] - tired[low++]);
if (low > high && low < sz) high = low;
}
else high++;
}
cout << ans;
return 0;
}
|
8df1657945ed73065d2f8faf48807e034b113646
|
1b6da6feaeeaa3801279781ab8421e7294c5b393
|
/c_plus_plus/lljz_disk/src/account_server/account_server.hpp
|
01e187c831c22d2ad419844b2a503b1037057bdf
|
[] |
no_license
|
doorhinges0/my_projects
|
703bbc92425e6c0604088d546b84be6dca37c0cd
|
f981ca0bfd79c3a119cd52155028f3f338378690
|
refs/heads/master
| 2021-01-13T12:00:06.992906
| 2015-12-28T12:00:42
| 2015-12-28T12:00:42
| 48,828,883
| 0
| 1
| null | 2015-12-31T02:24:37
| 2015-12-31T02:24:37
| null |
UTF-8
|
C++
| false
| false
| 1,651
|
hpp
|
account_server.hpp
|
#ifndef LLJZ_DISK_ACCESS_SERVER_H_
#define LLJZ_DISK_ACCESS_SERVER_H_
#include "tbsys.h"
#include "tbnet.h"
#include "packet_factory.hpp"
#include "connection_manager_to_server.hpp"
#include "connection_manager_from_client.hpp"
#include "ibusiness_packet_handler.h"
namespace lljz {
namespace disk {
class AccountServer : public tbnet::IServerAdapter,
public tbnet::IPacketQueueHandler,
public IBusinessPacketHandler {
public:
AccountServer();
~AccountServer();
void Start();
void Stop();
//IServerAdapter interface
virtual tbnet::IPacketHandler::HPRetCode
handlePacket(tbnet::Connection *connection, tbnet::Packet *packet);
//接收客户端packet处理线程
// IPacketQueueHandler interface
bool handlePacketQueue(tbnet::Packet * apacket, void *args);
//IBusinessPacketHandler interface
bool BusinessHandlePacket(
tbnet::Packet *packet, void *args);
private:
inline int Initialize();
inline int Destroy();
private:
PacketFactory packet_factory_;
tbnet::DefaultPacketStreamer packet_streamer_;
tbnet::Transport from_client_transport_;
tbnet::Transport to_server_transport_;//send packet to business server
tbnet::PacketQueueThread task_queue_thread_;
// server_conf_thread my_server_conf_thread_;
//客户端packet统计信息
uint64_t clientDisconnThrowPackets_; // 客户端连接失效丢弃的请求包数
uint64_t queueThreadTimeoutThrowPackets_; // PacketQueueThread排队超时丢弃的请求包数
ConnectionManagerToServer* conn_manager_to_srv_;
ConnectionManagerFromClient conn_manager_from_client_;
};
}
}
#endif
|
ee39caba055529e02fdb931b6c097963fdf9d6b3
|
c4f8991e188ce32e2c4574395f504881ae437c51
|
/src/GLE.h
|
467968c91d62bf945bde694fa34813b3845fd7cf
|
[] |
no_license
|
baubie/GLEcpp
|
47755b8ac7f60d2df412e739470fd439b59511fb
|
3eab6cfec1a04475d36bc3acda126f7f8af07646
|
refs/heads/master
| 2018-12-29T05:50:06.615693
| 2010-08-27T14:40:08
| 2010-08-27T14:40:08
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 7,587
|
h
|
GLE.h
|
/** GLE++
* GLE interface for C++
* Written by Brandon Aubie
*/
#ifndef GLE_H
#define GLE_H
#include <vector>
#include <map>
#include <cstdio>
#include <string>
#include <fstream>
#include <iostream>
#include <sstream>
#include <stdexcept>
#include <iomanip>
#include <algorithm>
#include <sys/stat.h>
#include <sys/types.h>
#include <boost/filesystem.hpp>
#include <boost/iostreams/device/file_descriptor.hpp>
#include <boost/iostreams/stream.hpp>
#include <math.h>
class GLE
{
public:
typedef int PanelID;
static const int NEW_PANEL = -1;
static const double UNDEFINED = -91348434;
std::string *buffer;
std::vector<std::string> markers;
std::string getMarker();
std::vector<std::string>::iterator iter_marker;
GLE() {
this->markers.push_back("fcircle");
this->markers.push_back("wsquare");
this->markers.push_back("ftriangle");
this->markers.push_back("wdiamond");
this->markers.push_back("wcircle");
this->markers.push_back("fsquare");
this->markers.push_back("wtriangle");
this->markers.push_back("fdiamond");
this->iter_marker = this->markers.begin();
}
struct Color {
float r;
float g;
float b;
Color() :
r(0.0),
g(0.0),
b(0.0)
{}
};
struct CanvasProperties {
float width;
float height;
int columns;
float margin_top;
float margin_left;
bool auto_layout;
CanvasProperties() :
width(8.5),
height(8.5),
columns(1),
margin_top(0.50),
margin_left(0.25),
auto_layout(true)
{}
};
struct PlotProperties {
float lineWidth;
float pointSize;
std::string marker;
bool zeros;
bool nomiss;
bool no_y;
bool usemap;
bool inlegend;
/** For use when no_y = true **/
double y_start;
double y_inc;
Color first;
Color last;
PlotProperties() :
lineWidth(0.010),
pointSize(0.1),
marker("__series__"),
zeros(true),
nomiss(true),
no_y(false),
usemap(false),
inlegend(true),
y_start(1),
y_inc(1)
{}
};
struct PanelProperties {
bool box;
bool legend;
std::string title;
std::string x_title;
std::string y_title;
std::string z_title;
bool y_labels;
bool x_labels;
double x_min;
double x_max;
double y_min;
double y_max;
int y_nticks;
double x_dsubticks;
double x_dticks;
double y_dsubticks;
double y_dticks;
double x_labels_hei;
double y_labels_hei;
double x_labels_dist;
double y_labels_dist;
// Only used when the canvas has autoplacement turned off
// Not yet implemented
int pos_x;
int pos_y;
int width;
int height;
PanelProperties() :
box(true),
legend(false),
title("Some Plot"),
x_title("x"),
y_title("y"),
z_title("z"),
y_labels(true),
x_labels(true),
x_min(UNDEFINED),
x_max(UNDEFINED),
y_min(UNDEFINED),
y_max(UNDEFINED),
y_nticks(UNDEFINED),
x_dsubticks(UNDEFINED),
x_dticks(UNDEFINED),
y_dsubticks(UNDEFINED),
y_dticks(UNDEFINED),
x_labels_hei(UNDEFINED),
y_labels_hei(UNDEFINED),
x_labels_dist(UNDEFINED),
y_labels_dist(UNDEFINED)
{}
};
CanvasProperties canvasProperties;
// Various different plot functions
//This is the main one that other plot()'s call
PanelID plot(std::vector<double> &x, std::vector<std::vector<double> > &y, std::vector<std::vector<double> > &err_up, std::vector<std::vector<double> > &err_down, PlotProperties properties, PanelID panel); // Plot a Multiple x-y curves with the same x by adding it to an existing panel
PanelID plot(std::vector<double> &x, std::vector<double> &y, PlotProperties properties); // Plot a single x-y curve
PanelID plot(std::vector< std::pair<double,double> > &points, PlotProperties properties, PanelID ID); // Plot a set of points
PanelID plot(std::vector<double> &x, std::vector<std::vector<double> > &y, PlotProperties properties); // Plot a Multiple x-y curves with the same x
PanelID plot(std::vector<double> &x, std::vector<std::vector<double> > &y, std::vector<std::vector<double> > &err_up, std::vector<std::vector<double> > &err_down, PlotProperties properties); // Plot a Multiple x-y curves with the same x
PanelID plot(std::vector<double> &x, std::vector<double> &y, PlotProperties properties, PanelID panel); // Plot a single x-y curve by adding it to an existing panel
PanelID plot(std::vector<double> &x, std::vector<double> &y, std::vector<double> &err_up, std::vector<double> &err_down, PlotProperties properties, PanelID panel);
PanelID plot3d(std::vector<double> &x, std::vector<double> &y, std::vector< std::vector<double> > &z, PlotProperties properties, PanelID ID);
PanelID plot3d(std::vector<double> &x, std::vector<double> &y, std::vector< std::vector<double> > &z, PlotProperties properties);
bool setPanelProperties(PanelProperties properties, PanelID ID); // Set the panel properties for a particular panel
bool setPanelProperties(PanelProperties properties); // Set the panel properties for all panels
PanelProperties getPanelProperties(PanelID ID);
bool draw(std::string const &filename); // Draw the plot to a filename
bool draw(); // Draw a plot to the default filename
private:
struct Plot {
std::vector<std::vector<double> > y;
std::vector<std::vector<double> > err_up;
std::vector<std::vector<double> > err_down;
std::vector<double> x;
PlotProperties properties;
std::string data_file;
};
struct Plot3d {
std::vector<double> y;
std::vector<double> x;
std::vector< std::vector<double> > z;
double z_min, z_max;
PlotProperties properties;
std::string data_file;
};
struct Points {
std::vector< std::pair<double,double> > points;
PlotProperties properties;
std::string data_file;
};
struct Panel {
PanelProperties properties;
std::vector<Plot> plots;
std::vector<Points> points;
std::vector<Plot3d> plots3d;
};
std::vector<Panel> panels;
bool verifyData(Plot &plot);
bool data_to_file();
std::string gle_script_to_file();
};
#endif
|
b76a9a7634f83293328b779911ea084adcc32c9b
|
cfe4bc9b0839a688a4d4ab2aeedf98c4492517ca
|
/吉田学園情報ビジネス専門学校 児玉優斗/04_2DSTG[有翼機動戦機 トライファルコン]/有翼機動戦機 トライファルコン/titleLogo.h
|
36c493a6b5fd7cf6f22958a8c8e78d966cc98d5c
|
[] |
no_license
|
kodamayuto/KODAMA_YUTO
|
bdb80c16c4c21171f9785ea615b8669e32e636a8
|
f126507e0bb23846d0025ba729217f3328d1baf5
|
refs/heads/master
| 2020-08-29T23:45:10.973554
| 2019-12-02T05:45:26
| 2019-12-02T05:45:26
| 218,202,881
| 0
| 0
| null | null | null | null |
SHIFT_JIS
|
C++
| false
| false
| 1,113
|
h
|
titleLogo.h
|
//=============================================================================
//
// 爆発クラス処理 [titleLogo.h]
// Author : Kodama Yuto
//
//=============================================================================
#ifndef _TITLELOGO_H_
#define _TITLELOGO_H_
#include "scene.h"
#include "scene2D.h"
//==================================================================
// マクロ定義
//==================================================================
//==================================================================
// クラスの定義
//==================================================================
//プレイヤークラス
class CTitleLogo : public CScene
{
public:
//コンストラクタ&デストラクタ
CTitleLogo();
~CTitleLogo();
static HRESULT Load(void);
static void Unload(void);
HRESULT Init(void);
void Uninit(void);
void Update(void);
void Draw(void);
static CTitleLogo* Create();
private:
static LPDIRECT3DTEXTURE9 m_pTexture; //共有テクスチャへのポインタ
CScene2D* m_pLogo;
protected:
};
#endif // !_TITLELOGO_H_
|
0052d86cf92acc6f1d90d88dc6e2ffc262db9b1b
|
005ead270fdff9ad85513d0b2e345dea11e2fbb4
|
/Q046_Permutations.cpp
|
66e8df16b4e1f084e80a42c70899e586736567f3
|
[] |
no_license
|
wangqinghe95/Code-Leetcode
|
222d5d50e5f81b25549d61810618a50849fc3269
|
3cdcdf2047e0c41485817e04c8e23853e9332c63
|
refs/heads/master
| 2023-04-29T20:44:22.764343
| 2021-05-16T05:40:27
| 2021-05-16T05:40:27
| 274,806,554
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 577
|
cpp
|
Q046_Permutations.cpp
|
/*
回溯法-抄的
*/
class Solution {
public:
void dfs(vector<vector<int>> &res, vector<int>& output, int first, int len){
if (first == len){
res.emplace_back(output);
return;
}
for (int i = first; i < len; ++i){
swap(output[i], output[first]);
dfs(res, output, first+1, len);
swap(output[i], output[first]);
}
}
vector<vector<int>> permute(vector<int>& nums) {
vector<vector<int>> res;
dfs(res, nums, 0, (int)nums.size());
return res;
}
};
|
62a462efab8ac57f843cb40fb169e469045ca699
|
6eb58f3cbbd2833624ec946344f60bd844d146cf
|
/src/echoserver.hpp
|
d311aac49a055a7a3ec1add9dac6e9e925268466
|
[] |
no_license
|
zppratt/rfsis
|
68918b1fceef9a4ba836a2cb2d21cb6180493452
|
ab46613b73efffae5d3a35966ab25fb413922c08
|
refs/heads/master
| 2021-01-11T03:31:29.112099
| 2017-04-22T12:31:07
| 2017-04-22T12:31:07
| 68,948,398
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 7,486
|
hpp
|
echoserver.hpp
|
#ifndef _6193_ECHO_SERVER_H_
#define _6193_ECHO_SERVER_H_
/**
* Description: This file contains the bulk of the code for the tcp echo application. The file also contains the prep code
* to run the application in the picoTCP IP-Stack.
*
* TODO: Clean this file up to be more OOP.
*
* Authors: Brice Aldrich, Devin Aspy, Zach Pratt
*/
#include "std_includes.hpp" //Standard includes that we use a lot, some gloabl vars, and one gloabl debug function
#define BSIZE 2048 //buffer size for TCP Echo
//Function Declarations
void start_server();
void cb_tcpserver(uint16_t ev, struct pico_socket *s);
int send_resp(struct pico_socket *s);
void deferred_exit(pico_time __attribute__((unused)) now, void *arg);
/**
* Class: echoHelper
* Description: This class is used to set and get multiple variables
* used in our TCP echo application throughout multiple functions.
*/
class echoHelper{
public:
echoHelper();
void setRead(int read);
void setPos(int pos);
void setLen(int len);
void setFlag(int flag);
int getRead();
int getPos();
int getLen();
int getFlag();
private:
int read;
int pos;
int len;
int flag;
};
echoHelper::echoHelper(){ //Constructor for echoHelper class
read = 0; //set all our private ints to 0
pos = 0;
len = 0;
flag = 0;
}
void echoHelper::setRead(int read){ // read setter
this->read = read;
}
void echoHelper::setPos(int pos){ // pos setter
this->pos = pos;
}
void echoHelper::setLen(int len){ // len setter
this->len = len;
}
void echoHelper::setFlag(int flag){ // flag setter
this->flag = flag;
}
int echoHelper::getRead(){ // read getter
return read;
}
int echoHelper::getPos(){ // pos getter
return pos;
}
int echoHelper::getLen(){ // len getter
return len;
}
int echoHelper::getFlag(){ // flag getter
return flag;
}
echoHelper help; // Let's create an echoHelper object named help
char recvbuf[BSIZE]; // Declare our buffer of the size above for use in the TCP Echo app
/**
* The bulk of the code for the TCP Echo app
*/
void start_server(){
struct pico_socket *listen_socket; // Creating a pico listening socket
uint16_t port; // our port
int ret; // For error checking
struct pico_ip4 address = {0}; // our listening adress
port = short_be(conf.getPort()); // Have to use their short be thing...
listen_socket = pico_socket_open(PICO_PROTO_IPV4, PICO_PROTO_TCP,
&cb_tcpserver); //Open the listening socket and call our call back function cb_tcpserver
if (!listen_socket) { // Oops we failed to open our socket ):
printf("[ERROR:106] echoserver.hpp =======> Could not open socket. FATAL!!!\n");
exit(1);
}
log_debug("[DEBUG:106] echoserver.hpp =======> Socket successfully opened");
ret = pico_socket_bind(listen_socket, &address, &port); // Bind the listening socket to the address and port connected.
if (ret < 0) {
printf("[ERROR:116] echoserver.hpp =======> Could not bind to socket. FATAL!!!\n");
exit(1);
}
log_debug("[DEBUG:116] echoserver.hpp =======> Socket successfully bound to port " + std::to_string(conf.getPort()) + " ret = " + std::to_string(ret));
ret = pico_socket_listen(listen_socket, 40); // Lets start listening.
if (ret < 0) { // We couldn't listen, like many of our beloved polititions. ):
printf("[ERROR:125] echoserver.hpp =======> Could not listen to socket. FATAL!!!\n");
exit(1);
}
log_debug("[DEBUG:125] echoserver.hpp =======> Successfully listening on socket. ret = " + std::to_string(ret));
}
/**
* The call back function for our TCP echo app.
* @param ev: The protocol as found in "pico_addressing.h".
* (Examples: PICO_PROTO_IPV4, PICO_PROTO_IPV6, PICO_PROTO_UDP)
* @param pico_socket: The socket the use to connect.
*/
void cb_tcpserver(uint16_t ev, struct pico_socket *s) {
log_debug("[DEBUG:133] echoserver.hpp =======> I heard something, I better send it back!");
if (ev & PICO_SOCK_EV_RD) { // Is there data available
if (help.getFlag() & PICO_SOCK_EV_CLOSE) {
log_debug("[DEBUG:138] echoserver.hpp =======> fin received!");
}
while (help.getLen() < BSIZE) { //Let's read the data
help.setRead(pico_socket_read(s, recvbuf + help.getLen(), BSIZE - help.getLen()));
if (help.getRead() > 0) {
help.setLen(help.getLen() + help.getRead());
help.setFlag(help.getFlag() & ~(PICO_SOCK_EV_RD));
} else {
help.setFlag(help.getFlag() | PICO_SOCK_EV_RD);
break;
}
}
if (help.getFlag() & PICO_SOCK_EV_WR) {
help.setFlag(help.getFlag() & ~PICO_SOCK_EV_WR);
if (!conf.getBackup())
send_resp(s); // Send our response to the data.
}
}
if (ev & PICO_SOCK_EV_CONN) {
struct pico_socket *sock_a = {0};
struct pico_ip4 orig = {0};
uint16_t port = 0;
char peer[30] = {0};
uint32_t ka_val = 0;
int yes = 1;
sock_a = pico_socket_accept(s, &orig, &port); //Accept a connection
pico_ipv4_to_string(peer, orig.addr); // get connection origin info
printf("Connection established with %s:%d\n", peer, short_be(port));
pico_socket_setoption(sock_a, PICO_TCP_NODELAY, &yes);
ka_val = 5;
pico_socket_setoption(sock_a, PICO_SOCKET_OPT_KEEPCNT, &ka_val);
ka_val = 30000;
pico_socket_setoption(sock_a, PICO_SOCKET_OPT_KEEPIDLE, &ka_val);
ka_val = 5000;
pico_socket_setoption(sock_a, PICO_SOCKET_OPT_KEEPINTVL, &ka_val);
}
if (ev & PICO_SOCK_EV_FIN) { // If socket closed
log_debug("[DEBUG:184] echoserver.hpp =======> Socket closed. Exiting normally!");
pico_timer_add(2000, deferred_exit, NULL);
}
if (ev & PICO_SOCK_EV_ERR) { //If socket error
log_debug("[DEBUG:189] echoserver.hpp =======> Socket error, better quit while I'm ahead!");
exit(1);
}
if (ev & PICO_SOCK_EV_CLOSE) { // If scoket closed from peer
log_debug("[DEBUG:189] echoserver.hpp =======> Socket received close from peer");
if (help.getFlag() & PICO_SOCK_EV_RD) {
pico_socket_shutdown(s, PICO_SHUT_WR);
log_debug("[DEBUG:189] echoserver.hpp =======> Called shutdown.");
}
}
if (ev & PICO_SOCK_EV_WR) {
if (!conf.getBackup())
help.setRead(send_resp(s));
if (help.getRead() == 0) {
help.setFlag(help.getFlag() | PICO_SOCK_EV_WR);
} else {
help.setFlag(help.getFlag() & (~PICO_SOCK_EV_WR));
}
}
}
int send_resp(struct pico_socket *s) { //send the response
int w, ww = 0;
if (help.getLen() > help.getPos()) {
do {
w = pico_socket_write(s, recvbuf + help.getPos(), help.getLen() - help.getPos());
if (w > 0) {
help.setPos(help.getPos() + w);
ww += w;
if (help.getPos() >= help.getLen()) {
help.setPos(0);
help.setLen(0);
}
}
} while ((w > 0) && (help.getPos() < help.getLen()));
}
return ww;
}
void deferred_exit(pico_time __attribute__((unused)) now, void *arg) { //safe exit
if (arg) {
free(arg);
arg = NULL;
}
log_debug("[DEBUG:189] echoserver.hpp =======> Quitting peacefully.");
exit(0);
}
#endif
|
bd96ea5284ea9348fb976844cf3cc5f6ab3169a3
|
a7764174fb0351ea666faa9f3b5dfe304390a011
|
/src/RWStepGeom/RWStepGeom_RWQuasiUniformSurfaceAndRationalBSplineSurface.cxx
|
50b888373cf2d61924c6f8ccb5c0c7a840b958f5
|
[] |
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
| 10,771
|
cxx
|
RWStepGeom_RWQuasiUniformSurfaceAndRationalBSplineSurface.cxx
|
#include <RWStepGeom_RWQuasiUniformSurfaceAndRationalBSplineSurface.ixx>
#include <StepGeom_QuasiUniformSurface.hxx>
#include <StepGeom_RationalBSplineSurface.hxx>
#include <StepGeom_HArray2OfCartesianPoint.hxx>
#include <StepGeom_CartesianPoint.hxx>
#include <StepGeom_BSplineSurfaceForm.hxx>
#include <StepData_Logical.hxx>
#include <TColStd_HArray2OfReal.hxx>
#include <Interface_EntityIterator.hxx>
#include <StepGeom_QuasiUniformSurfaceAndRationalBSplineSurface.hxx>
// --- Enum : BSplineSurfaceForm ---
static TCollection_AsciiString bssfSurfOfLinearExtrusion(".SURF_OF_LINEAR_EXTRUSION.");
static TCollection_AsciiString bssfPlaneSurf(".PLANE_SURF.");
static TCollection_AsciiString bssfGeneralisedCone(".GENERALISED_CONE.");
static TCollection_AsciiString bssfToroidalSurf(".TOROIDAL_SURF.");
static TCollection_AsciiString bssfConicalSurf(".CONICAL_SURF.");
static TCollection_AsciiString bssfSphericalSurf(".SPHERICAL_SURF.");
static TCollection_AsciiString bssfUnspecified(".UNSPECIFIED.");
static TCollection_AsciiString bssfRuledSurf(".RULED_SURF.");
static TCollection_AsciiString bssfSurfOfRevolution(".SURF_OF_REVOLUTION.");
static TCollection_AsciiString bssfCylindricalSurf(".CYLINDRICAL_SURF.");
static TCollection_AsciiString bssfQuadricSurf(".QUADRIC_SURF.");
RWStepGeom_RWQuasiUniformSurfaceAndRationalBSplineSurface::RWStepGeom_RWQuasiUniformSurfaceAndRationalBSplineSurface () {}
void RWStepGeom_RWQuasiUniformSurfaceAndRationalBSplineSurface::ReadStep
(const Handle(StepData_StepReaderData)& data,
const Standard_Integer num0,
Handle(Interface_Check)& ach,
const Handle(StepGeom_QuasiUniformSurfaceAndRationalBSplineSurface)& ent) const
{
Standard_Integer num = num0;
// --- Instance of plex componant BoundedSurface ---
if (!data->CheckNbParams(num,0,ach,"bounded_surface")) return;
num = data->NextForComplex(num);
// --- Instance of common supertype BSplineSurface ---
if (!data->CheckNbParams(num,7,ach,"b_spline_surface")) return;
// --- field : uDegree ---
Standard_Integer aUDegree;
//szv#4:S4163:12Mar99 `Standard_Boolean stat1 =` not needed
data->ReadInteger (num,1,"u_degree",ach,aUDegree);
// --- field : vDegree ---
Standard_Integer aVDegree;
//szv#4:S4163:12Mar99 `Standard_Boolean stat2 =` not needed
data->ReadInteger (num,2,"v_degree",ach,aVDegree);
// --- field : controlPointsList ---
Handle(StepGeom_HArray2OfCartesianPoint) aControlPointsList;
Handle(StepGeom_CartesianPoint) anent3;
Standard_Integer nsub3;
if (data->ReadSubList (num,3,"control_points_list",ach,nsub3)) {
Standard_Integer nbi3 = data->NbParams(nsub3);
Standard_Integer nbj3 = data->NbParams(data->ParamNumber(nsub3,1));
aControlPointsList = new StepGeom_HArray2OfCartesianPoint (1, nbi3, 1, nbj3);
for (Standard_Integer i3 = 1; i3 <= nbi3; i3 ++) {
Standard_Integer nsi3;
if (data->ReadSubList (nsub3,i3,"sub-part(control_points_list)",ach,nsi3)) {
for (Standard_Integer j3 =1; j3 <= nbj3; j3 ++) {
//szv#4:S4163:12Mar99 `Standard_Boolean stat3 =` not needed
if (data->ReadEntity (nsi3, j3,"cartesian_point", ach,
STANDARD_TYPE(StepGeom_CartesianPoint), anent3))
aControlPointsList->SetValue(i3, j3, anent3);
}
}
}
}
// --- field : surfaceForm ---
StepGeom_BSplineSurfaceForm aSurfaceForm = StepGeom_bssfPlaneSurf;
if (data->ParamType(num,4) == Interface_ParamEnum) {
Standard_CString text = data->ParamCValue(num,4);
if (bssfSurfOfLinearExtrusion.IsEqual(text)) aSurfaceForm = StepGeom_bssfSurfOfLinearExtrusion;
else if (bssfPlaneSurf.IsEqual(text)) aSurfaceForm = StepGeom_bssfPlaneSurf;
else if (bssfGeneralisedCone.IsEqual(text)) aSurfaceForm = StepGeom_bssfGeneralisedCone;
else if (bssfToroidalSurf.IsEqual(text)) aSurfaceForm = StepGeom_bssfToroidalSurf;
else if (bssfConicalSurf.IsEqual(text)) aSurfaceForm = StepGeom_bssfConicalSurf;
else if (bssfSphericalSurf.IsEqual(text)) aSurfaceForm = StepGeom_bssfSphericalSurf;
else if (bssfUnspecified.IsEqual(text)) aSurfaceForm = StepGeom_bssfUnspecified;
else if (bssfRuledSurf.IsEqual(text)) aSurfaceForm = StepGeom_bssfRuledSurf;
else if (bssfSurfOfRevolution.IsEqual(text)) aSurfaceForm = StepGeom_bssfSurfOfRevolution;
else if (bssfCylindricalSurf.IsEqual(text)) aSurfaceForm = StepGeom_bssfCylindricalSurf;
else if (bssfQuadricSurf.IsEqual(text)) aSurfaceForm = StepGeom_bssfQuadricSurf;
else ach->AddFail("Enumeration b_spline_surface_form has not an allowed value");
}
else ach->AddFail("Parameter #4 (surface_form) is not an enumeration");
// --- field : uClosed ---
StepData_Logical aUClosed;
//szv#4:S4163:12Mar99 `Standard_Boolean stat5 =` not needed
data->ReadLogical (num,5,"u_closed",ach,aUClosed);
// --- field : vClosed ---
StepData_Logical aVClosed;
//szv#4:S4163:12Mar99 `Standard_Boolean stat6 =` not needed
data->ReadLogical (num,6,"v_closed",ach,aVClosed);
// --- field : selfIntersect ---
StepData_Logical aSelfIntersect;
//szv#4:S4163:12Mar99 `Standard_Boolean stat7 =` not needed
data->ReadLogical (num,7,"self_intersect",ach,aSelfIntersect);
num = data->NextForComplex(num);
// --- Instance of plex componant GeometricRepresentationItem ---
if (!data->CheckNbParams(num,0,ach,"geometric_representation_item")) return;
num = data->NextForComplex(num);
// --- Instance of plex componant QuasiUniformSurface ---
if (!data->CheckNbParams(num,0,ach,"quasi_uniform_surface")) return;
num = data->NextForComplex(num);
// --- Instance of plex componant RationalBSplineSurface ---
if (!data->CheckNbParams(num,1,ach,"rational_b_spline_surface")) return;
// --- field : weightsData ---
Handle(TColStd_HArray2OfReal) aWeightsData;
Standard_Real aWeightsDataItem;
Standard_Integer nsub8;
if (data->ReadSubList (num,1,"weights_data",ach,nsub8)) {
Standard_Integer nbi8 = data->NbParams(nsub8);
Standard_Integer nbj8 = data->NbParams(data->ParamNumber(nsub8,1));
aWeightsData = new TColStd_HArray2OfReal (1,nbi8,1,nbj8);
for (Standard_Integer i8 = 1; i8 <= nbi8; i8 ++) {
Standard_Integer nsi8;
if (data->ReadSubList (nsub8,i8,"sub-part(weights_data)",ach,nsi8)) {
for (Standard_Integer j8 =1; j8 <= nbj8; j8 ++) {
//szv#4:S4163:12Mar99 `Standard_Boolean stat8 =` not needed
if (data->ReadReal (nsi8,j8,"weights_data",ach,aWeightsDataItem))
aWeightsData->SetValue(i8,j8,aWeightsDataItem);
}
}
}
}
num = data->NextForComplex(num);
// --- Instance of plex componant RepresentationItem ---
if (!data->CheckNbParams(num,1,ach,"representation_item")) return;
// --- field : name ---
Handle(TCollection_HAsciiString) aName;
//szv#4:S4163:12Mar99 `Standard_Boolean stat9 =` not needed
data->ReadString (num,1,"name",ach,aName);
num = data->NextForComplex(num);
// --- Instance of plex componant Surface ---
if (!data->CheckNbParams(num,0,ach,"surface")) return;
//--- Initialisation of the red entity ---
ent->Init(aName,aUDegree,aVDegree,aControlPointsList,aSurfaceForm,aUClosed,aVClosed,aSelfIntersect,aWeightsData);
}
void RWStepGeom_RWQuasiUniformSurfaceAndRationalBSplineSurface::WriteStep
(StepData_StepWriter& SW,
const Handle(StepGeom_QuasiUniformSurfaceAndRationalBSplineSurface)& ent) const
{
// --- Instance of plex componant BoundedSurface ---
SW.StartEntity("BOUNDED_SURFACE");
// --- Instance of common supertype BSplineSurface ---
SW.StartEntity("B_SPLINE_SURFACE");
// --- field : uDegree ---
SW.Send(ent->UDegree());
// --- field : vDegree ---
SW.Send(ent->VDegree());
// --- field : controlPointsList ---
SW.OpenSub();
for (Standard_Integer i3 = 1; i3 <= ent->NbControlPointsListI(); i3 ++) {
SW.NewLine(Standard_False);
SW.OpenSub();
for (Standard_Integer j3 = 1; j3 <= ent->NbControlPointsListJ(); j3 ++) {
SW.Send(ent->ControlPointsListValue(i3,j3));
SW.JoinLast(Standard_False);
}
SW.CloseSub();
}
SW.CloseSub();
// --- field : surfaceForm ---
switch(ent->SurfaceForm()) {
case StepGeom_bssfSurfOfLinearExtrusion : SW.SendEnum (bssfSurfOfLinearExtrusion); break;
case StepGeom_bssfPlaneSurf : SW.SendEnum (bssfPlaneSurf); break;
case StepGeom_bssfGeneralisedCone : SW.SendEnum (bssfGeneralisedCone); break;
case StepGeom_bssfToroidalSurf : SW.SendEnum (bssfToroidalSurf); break;
case StepGeom_bssfConicalSurf : SW.SendEnum (bssfConicalSurf); break;
case StepGeom_bssfSphericalSurf : SW.SendEnum (bssfSphericalSurf); break;
case StepGeom_bssfUnspecified : SW.SendEnum (bssfUnspecified); break;
case StepGeom_bssfRuledSurf : SW.SendEnum (bssfRuledSurf); break;
case StepGeom_bssfSurfOfRevolution : SW.SendEnum (bssfSurfOfRevolution); break;
case StepGeom_bssfCylindricalSurf : SW.SendEnum (bssfCylindricalSurf); break;
case StepGeom_bssfQuadricSurf : SW.SendEnum (bssfQuadricSurf); break;
}
// --- field : uClosed ---
SW.SendLogical(ent->UClosed());
// --- field : vClosed ---
SW.SendLogical(ent->VClosed());
// --- field : selfIntersect ---
SW.SendLogical(ent->SelfIntersect());
// --- Instance of plex componant GeometricRepresentationItem ---
SW.StartEntity("GEOMETRIC_REPRESENTATION_ITEM");
// --- Instance of plex componant QuasiUniformSurface ---
SW.StartEntity("QUASI_UNIFORM_SURFACE");
// --- Instance of plex componant RationalBSplineSurface ---
SW.StartEntity("RATIONAL_B_SPLINE_SURFACE");
// --- field : weightsData ---
SW.OpenSub();
for (Standard_Integer i8 = 1; i8 <= ent->NbWeightsDataI(); i8 ++) {
SW.NewLine(Standard_False);
SW.OpenSub();
for (Standard_Integer j8 = 1; j8 <= ent->NbWeightsDataJ(); j8 ++) {
SW.Send(ent->WeightsDataValue(i8,j8));
SW.JoinLast(Standard_False);
}
SW.CloseSub();
}
SW.CloseSub();
// --- Instance of plex componant RepresentationItem ---
SW.StartEntity("REPRESENTATION_ITEM");
// --- field : name ---
SW.Send(ent->Name());
// --- Instance of plex componant Surface ---
SW.StartEntity("SURFACE");
}
void RWStepGeom_RWQuasiUniformSurfaceAndRationalBSplineSurface::Share(const Handle(StepGeom_QuasiUniformSurfaceAndRationalBSplineSurface)& ent, Interface_EntityIterator& iter) const
{
Standard_Integer nbiElem1 = ent->NbControlPointsListI();
Standard_Integer nbjElem1 = ent->NbControlPointsListJ();
for (Standard_Integer is1=1; is1<=nbiElem1; is1 ++) {
for (Standard_Integer js1=1; js1<=nbjElem1; js1 ++) {
iter.GetOneItem(ent->ControlPointsListValue(is1,js1));
}
}
}
|
c5a71ec6204d208a1baf13a3ca617f3ef2f5b51a
|
0f6169bb87df0dd0e6785c3014a68a1ef0b83f7e
|
/src/hello_world_main/main.cc
|
f010e0d1d9625f05bc66e4a6abc9ab4965d8bcf4
|
[] |
no_license
|
kforo615/ncurses_bazel
|
93c629477306e8f7494e772658d7f61176c0edd9
|
4d9fd5e709748271e3610b75ab8bf53f71788fd0
|
refs/heads/master
| 2023-04-02T05:04:57.061955
| 2021-03-29T16:37:09
| 2021-03-29T16:37:09
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 453
|
cc
|
main.cc
|
#include "src/lib/ncurses_wrapper.h"
#include <iostream>
#include <ncurses.h>
int main() {
NCursesWrapper ncurses_wrapper;
const char *hello_world = ncurses_wrapper.GetHelloWorld().c_str();
initscr(); // Start curses mode
printw(hello_world); // Print Hello World
refresh(); // Print it on to the real screen
getch(); // Wait for user input
endwin(); // End curses mode
return EXIT_SUCCESS;
}
|
80cb0b3ec9638c438f8a3d41cd3f768edb00e5b9
|
30ec2372ac36d40f4557c5f39cb606452e6e6bf5
|
/StRoot/StVecBosAna/utils/ValErrPair.cxx
|
459652d61efa8b27a46d7b05a16c8f238e87d400
|
[] |
no_license
|
yfisyak/star-sw
|
fe77d1f6f246bfa200a0781a0335ede7e3f0ce77
|
449bba9cba3305baacbd7f18f7b3a51c61b81e61
|
refs/heads/main
| 2023-07-12T01:15:45.728968
| 2021-08-04T22:59:16
| 2021-08-04T22:59:16
| 382,115,093
| 2
| 0
| null | 2021-07-01T17:54:02
| 2021-07-01T17:54:01
| null |
UTF-8
|
C++
| false
| false
| 1,541
|
cxx
|
ValErrPair.cxx
|
#include "ValErrPair.h"
ClassImp(ValErrPair)
using namespace std;
ValErrPair::ValErrPair() : TObject(), ve(0, -1), v(ve.first), e(ve.second), first(ve.first), second(ve.second)
{
//v = ve.first;
//e = ve.second;
}
ValErrPair::ValErrPair(Double_t vv, Double_t ee) : TObject(), ve(vv, ee), v(ve.first), e(ve.second), first(ve.first), second(ve.second)
{
//v = ve.first;
//e = ve.second;
}
ValErrPair::ValErrPair(const ValErrPair& vep) : TObject(), ve(vep.ve), v(ve.first), e(ve.second), first(ve.first), second(ve.second)
{
}
/** */
ValErrPair& ValErrPair::operator=(const ValErrPair &vep)
{ //{{{
if (this == &vep)
return *this;
ve = vep.ve;
return *this;
} //}}}
/** */
ostream& operator<<(ostream& os, const ValErrPair &vep)
{ //{{{
os << "array( " << vep.ve.first << ", " << vep.ve.second << " )";
//os << "array( " << vep.first << ", " << vep.second << " )";
//os << "array( " << vep.v << ", " << vep.e << " )";
//os << "first: " << vep.first << ", second: " << vep.second << endl;
//os << "v: " << vep.v << ", e: " << vep.e << endl;
return os;
} //}}}
/** */
bool operator<(const ValErrPair &lhs, const ValErrPair &rhs)
{ //{{{
if (lhs.ve.first < rhs.ve.first) return true;
if (lhs.ve.first == rhs.ve.first && lhs.ve.second < rhs.ve.second) return true;
return false;
} //}}}
/** */
bool operator==(const ValErrPair &lhs, const ValErrPair &rhs)
{ //{{{
if (lhs.ve.first == rhs.ve.first && lhs.ve.second == rhs.ve.second) return true;
return false;
} //}}}
|
8a8e5550e4583d6920ee139ee61b0af757f4c52f
|
3412699711ec0db5ad6a4f4b9638d921ebb86799
|
/C-CPP-API/06.list_2D/src/include/ext3.h
|
fa747a23020bb29e130139f22dc3763a24932002
|
[] |
no_license
|
sha314/glue-c-cpp-with-python
|
fa5ff792a04b7b8500d90cbbe0142efe6fb738ea
|
ee882045fd1c276abaedfe780fe0451b8dbc34da
|
refs/heads/master
| 2020-04-01T23:42:23.138108
| 2019-02-24T14:57:33
| 2019-02-24T14:57:33
| 153,769,182
| 1
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 542
|
h
|
ext3.h
|
#ifndef __HEADER_EXT3_H__
#define __HEADER_EXT3_H__
#include <Python.h>
#include <iostream>
// /****
// Numpy array as input
// *****/
// PyObject * view_numpy_array(PyObject *self, PyArrayObject *np_array);
static PyObject * error_out(PyObject *m);
static PyObject* view(PyObject *self, PyObject *list);
static PyObject* view_matrix(PyObject *self, PyObject *args);
static PyObject* round_trip(PyObject *self, PyObject *list);
static PyObject* mat_mul(
PyObject *self, PyObject *args, PyObject *kwargs);
#endif // __HEADER_EXT3_H__
|
cbcb467ad41fd9b951dc93b5894c34279b5e72c1
|
d5f93049a4ef39d6e90b762f8e7e58b72b27a4f5
|
/2. Intro to C++/vector_board.cpp
|
3c661a276168131ee82724e18a51574adabad105
|
[] |
no_license
|
Pytrader1x/Cpp_Udacity
|
3872cccaf727234eb31d47d2b266fdc3d049fa92
|
8e0546e1d46c0a1b96f5aebb94b9509fbf74f7cc
|
refs/heads/main
| 2023-02-18T17:05:02.283219
| 2021-01-13T00:16:12
| 2021-01-13T00:16:12
| 325,054,965
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 631
|
cpp
|
vector_board.cpp
|
#include <iostream>
#include <vector>
using std::cout;
using std::vector;
// TODO: Add PrintBoard function here.
void PrintBoard(const vector<vector<int>> board){
for(int i = 0; i < board.size(); i++){
for(int j = 0; j < board[i].size();j++){
cout << board[i][j];
}
cout << "\n";
}
}
int main() {
vector<vector<int>> board{{0, 1, 0, 0, 0, 0},
{0, 1, 0, 0, 0, 0},
{0, 1, 0, 0, 0, 0},
{0, 1, 0, 0, 0, 0},
{0, 0, 0, 0, 1, 0}};
// TODO: Call PrintBoard function here.
PrintBoard(board);
}
|
c2737e6630ab92c8c0cffc0fd18c344e54493650
|
176986455dfeeca37515ff3c7041fc152af8bb1b
|
/modules/commands/os_stats.cpp
|
94c8365d8f4918092f89405ee9dd443cb7d06a0c
|
[] |
no_license
|
anope/anope
|
bda831995dccd78acc2fc1d3071dd69df53c6af5
|
0a3ddef3151ef4258e529f5850be08810fa146d3
|
refs/heads/2.0
| 2023-09-03T07:25:54.572371
| 2023-08-31T06:17:56
| 2023-08-31T06:19:00
| 909,217
| 284
| 176
| null | 2023-08-31T06:19:54
| 2010-09-14T06:25:30
|
C++
|
UTF-8
|
C++
| false
| false
| 9,510
|
cpp
|
os_stats.cpp
|
/* OperServ core functions
*
* (C) 2003-2023 Anope Team
* Contact us at team@anope.org
*
* Please read COPYING and README for further details.
*
* Based on the original code of Epona by Lara.
* Based on the original code of Services by Andy Church.
*/
#include "module.h"
#include "modules/os_session.h"
struct Stats : Serializable
{
static Stats *me;
Stats() : Serializable("Stats")
{
me = this;
}
void Serialize(Serialize::Data &data) const anope_override
{
data["maxusercnt"] << MaxUserCount;
data["maxusertime"] << MaxUserTime;
}
static Serializable* Unserialize(Serializable *obj, Serialize::Data &data)
{
data["maxusercnt"] >> MaxUserCount;
data["maxusertime"] >> MaxUserTime;
return me;
}
};
Stats *Stats::me;
/**
* Count servers connected to server s
* @param s The server to start counting from
* @return Amount of servers connected to server s
**/
static int stats_count_servers(Server *s)
{
if (!s)
return 0;
int count = 1;
if (!s->GetLinks().empty())
for (unsigned i = 0, j = s->GetLinks().size(); i < j; ++i)
count += stats_count_servers(s->GetLinks()[i]);
return count;
}
class CommandOSStats : public Command
{
ServiceReference<XLineManager> akills, snlines, sqlines;
private:
void DoStatsAkill(CommandSource &source)
{
int timeout;
if (akills)
{
/* AKILLs */
source.Reply(_("Current number of AKILLs: \002%d\002"), akills->GetCount());
timeout = Config->GetModule("operserv")->Get<time_t>("autokillexpiry", "30d") + 59;
if (timeout >= 172800)
source.Reply(_("Default AKILL expiry time: \002%d days\002"), timeout / 86400);
else if (timeout >= 86400)
source.Reply(_("Default AKILL expiry time: \0021 day\002"));
else if (timeout >= 7200)
source.Reply(_("Default AKILL expiry time: \002%d hours\002"), timeout / 3600);
else if (timeout >= 3600)
source.Reply(_("Default AKILL expiry time: \0021 hour\002"));
else if (timeout >= 120)
source.Reply(_("Default AKILL expiry time: \002%d minutes\002"), timeout / 60);
else if (timeout >= 60)
source.Reply(_("Default AKILL expiry time: \0021 minute\002"));
else
source.Reply(_("Default AKILL expiry time: \002No expiration\002"));
}
if (snlines)
{
/* SNLINEs */
source.Reply(_("Current number of SNLINEs: \002%d\002"), snlines->GetCount());
timeout = Config->GetModule("operserv")->Get<time_t>("snlineexpiry", "30d") + 59;
if (timeout >= 172800)
source.Reply(_("Default SNLINE expiry time: \002%d days\002"), timeout / 86400);
else if (timeout >= 86400)
source.Reply(_("Default SNLINE expiry time: \0021 day\002"));
else if (timeout >= 7200)
source.Reply(_("Default SNLINE expiry time: \002%d hours\002"), timeout / 3600);
else if (timeout >= 3600)
source.Reply(_("Default SNLINE expiry time: \0021 hour\002"));
else if (timeout >= 120)
source.Reply(_("Default SNLINE expiry time: \002%d minutes\002"), timeout / 60);
else if (timeout >= 60)
source.Reply(_("Default SNLINE expiry time: \0021 minute\002"));
else
source.Reply(_("Default SNLINE expiry time: \002No expiration\002"));
}
if (sqlines)
{
/* SQLINEs */
source.Reply(_("Current number of SQLINEs: \002%d\002"), sqlines->GetCount());
timeout = Config->GetModule("operserv")->Get<time_t>("sglineexpiry", "30d") + 59;
if (timeout >= 172800)
source.Reply(_("Default SQLINE expiry time: \002%d days\002"), timeout / 86400);
else if (timeout >= 86400)
source.Reply(_("Default SQLINE expiry time: \0021 day\002"));
else if (timeout >= 7200)
source.Reply(_("Default SQLINE expiry time: \002%d hours\002"), timeout / 3600);
else if (timeout >= 3600)
source.Reply(_("Default SQLINE expiry time: \0021 hour\002"));
else if (timeout >= 120)
source.Reply(_("Default SQLINE expiry time: \002%d minutes\002"), timeout / 60);
else if (timeout >= 60)
source.Reply(_("Default SQLINE expiry time: \0021 minute\002"));
else
source.Reply(_("Default SQLINE expiry time: \002No expiration\002"));
}
}
void DoStatsReset(CommandSource &source)
{
MaxUserCount = UserListByNick.size();
source.Reply(_("Statistics reset."));
return;
}
void DoStatsUptime(CommandSource &source)
{
time_t uptime = Anope::CurTime - Anope::StartTime;
source.Reply(_("Current users: \002%d\002 (\002%d\002 ops)"), UserListByNick.size(), OperCount);
source.Reply(_("Maximum users: \002%d\002 (%s)"), MaxUserCount, Anope::strftime(MaxUserTime, source.GetAccount()).c_str());
source.Reply(_("Services up %s."), Anope::Duration(uptime, source.GetAccount()).c_str());
return;
}
void DoStatsUplink(CommandSource &source)
{
Anope::string buf;
for (std::set<Anope::string>::iterator it = Servers::Capab.begin(); it != Servers::Capab.end(); ++it)
buf += " " + *it;
if (!buf.empty())
buf.erase(buf.begin());
source.Reply(_("Uplink server: %s"), Me->GetLinks().front()->GetName().c_str());
source.Reply(_("Uplink capab: %s"), buf.c_str());
source.Reply(_("Servers found: %d"), stats_count_servers(Me->GetLinks().front()));
return;
}
template<typename T> void GetHashStats(const T& map, size_t& entries, size_t& buckets, size_t& max_chain)
{
entries = map.size(), buckets = map.bucket_count(), max_chain = 0;
for (size_t i = 0; i < buckets; ++i)
if (map.bucket_size(i) > max_chain)
max_chain = map.bucket_size(i);
}
void DoStatsHash(CommandSource &source)
{
size_t entries, buckets, max_chain;
GetHashStats(UserListByNick, entries, buckets, max_chain);
source.Reply(_("Users (nick): %lu entries, %lu buckets, longest chain is %d"), entries, buckets, max_chain);
if (!UserListByUID.empty())
{
GetHashStats(UserListByUID, entries, buckets, max_chain);
source.Reply(_("Users (uid): %lu entries, %lu buckets, longest chain is %d"), entries, buckets, max_chain);
}
GetHashStats(ChannelList, entries, buckets, max_chain);
source.Reply(_("Channels: %lu entries, %lu buckets, longest chain is %d"), entries, buckets, max_chain);
GetHashStats(*RegisteredChannelList, entries, buckets, max_chain);
source.Reply(_("Registered channels: %lu entries, %lu buckets, longest chain is %d"), entries, buckets, max_chain);
GetHashStats(*NickAliasList, entries, buckets, max_chain);
source.Reply(_("Registered nicknames: %lu entries, %lu buckets, longest chain is %d"), entries, buckets, max_chain);
GetHashStats(*NickCoreList, entries, buckets, max_chain);
source.Reply(_("Registered nick groups: %lu entries, %lu buckets, longest chain is %d"), entries, buckets, max_chain);
if (session_service)
{
GetHashStats(session_service->GetSessions(), entries, buckets, max_chain);
source.Reply(_("Sessions: %lu entries, %lu buckets, longest chain is %d"), entries, buckets, max_chain);
}
}
public:
CommandOSStats(Module *creator) : Command(creator, "operserv/stats", 0, 1),
akills("XLineManager", "xlinemanager/sgline"), snlines("XLineManager", "xlinemanager/snline"), sqlines("XLineManager", "xlinemanager/sqline")
{
this->SetDesc(_("Show status of Services and network"));
this->SetSyntax("[AKILL | HASH | UPLINK | UPTIME | ALL | RESET]");
}
void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override
{
Anope::string extra = !params.empty() ? params[0] : "";
Log(LOG_ADMIN, source, this) << extra;
if (extra.equals_ci("RESET"))
return this->DoStatsReset(source);
if (extra.equals_ci("ALL") || extra.equals_ci("AKILL"))
this->DoStatsAkill(source);
if (extra.equals_ci("ALL") || extra.equals_ci("HASH"))
this->DoStatsHash(source);
if (extra.equals_ci("ALL") || extra.equals_ci("UPLINK"))
this->DoStatsUplink(source);
if (extra.empty() || extra.equals_ci("ALL") || extra.equals_ci("UPTIME"))
this->DoStatsUptime(source);
if (!extra.empty() && !extra.equals_ci("ALL") && !extra.equals_ci("AKILL") && !extra.equals_ci("HASH") && !extra.equals_ci("UPLINK") && !extra.equals_ci("UPTIME"))
source.Reply(_("Unknown STATS option: \002%s\002"), extra.c_str());
}
bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override
{
this->SendSyntax(source);
source.Reply(" ");
source.Reply(_("Without any option, shows the current number of users online,\n"
"and the highest number of users online since Services was\n"
"started, and the length of time Services has been running.\n"
" \n"
"With the \002AKILL\002 option, displays the current size of the\n"
"AKILL list and the current default expiry time.\n"
" \n"
"The \002RESET\002 option currently resets the maximum user count\n"
"to the number of users currently present on the network.\n"
" \n"
"The \002UPLINK\002 option displays information about the current\n"
"server Anope uses as an uplink to the network.\n"
" \n"
"The \002HASH\002 option displays information about the hash maps.\n"
" \n"
"The \002ALL\002 option displays all of the above statistics."));
return true;
}
};
class OSStats : public Module
{
CommandOSStats commandosstats;
Serialize::Type stats_type;
Stats stats_saver;
public:
OSStats(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR),
commandosstats(this), stats_type("Stats", Stats::Unserialize)
{
}
void OnUserConnect(User *u, bool &exempt) anope_override
{
if (UserListByNick.size() == MaxUserCount && Anope::CurTime == MaxUserTime)
stats_saver.QueueUpdate();
}
};
MODULE_INIT(OSStats)
|
24fe0afbd6fc19bfe7e21895d695b19075e29215
|
c686b4fda652e43002a0539f17afecd68e9e443c
|
/main.cpp
|
f9a76fc27e04cadaf478361ea0c1dcac0717b77c
|
[
"MIT"
] |
permissive
|
tort-dla-psa/UnnamedRoguelike
|
705f6e445d5709912ce3e89e67f64ed71fe03216
|
e2fc4d3b187e3fb704df58bdda26f1f12c6b0a4b
|
refs/heads/master
| 2021-09-10T06:53:38.849708
| 2018-03-19T09:12:29
| 2018-03-19T09:12:29
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 94
|
cpp
|
main.cpp
|
#include<iostream>
#include"engine.h"
int main(){
engine eng;
eng.MainLoop();
return 0;
}
|
c2e789c4bb9d95d2a288a31821b019d688db4f05
|
e84ff4045bad22d9fc7cd90d3cb1ffdd41a34729
|
/Space Invader/ship.h
|
f52ec5b126fc671ce80af37953ebef223da58ad0
|
[] |
no_license
|
AccentsAMillion/Sprite-Space-Invaders-
|
da4c4c8e1302dd598208eb841c66b66f28a61267
|
a3adb2d121aa31cb2da8a341395b3d5cc1327616
|
refs/heads/master
| 2022-11-18T07:26:11.397815
| 2020-07-21T10:38:51
| 2020-07-21T10:38:51
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 173
|
h
|
ship.h
|
#pragma once
#include "stdafx.h"
#include "entity.h"
class Ship : public Entity
{
public:
Ship(float x, float y);
void Updating();
void Hit(Entity* entity);
private:
};
|
699fdb4bfa290a0ff7a2a9e70eefaa001ccc10ab
|
3e3b78943889822aebc88958aa909f3b1f381d9f
|
/VisaCtrlV1/viophead.h
|
e783be3be8c5bdf631299a0d459c887221059716
|
[] |
no_license
|
jayhood970131/visacontrol
|
9e83f843ba7cbc000a5b60c56613e82e0c9575a2
|
eb6b6c0b2437a193413d04cd0cbefd16f5101fea
|
refs/heads/master
| 2023-06-09T19:00:44.401554
| 2021-06-22T09:51:51
| 2021-06-22T09:51:51
| 371,906,587
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 309
|
h
|
viophead.h
|
#ifndef VIOPHEAD_H
#define VIOPHEAD_H
#include <QObject>
#include <include/visa.h>
class VIOPHead : public QObject
{
Q_OBJECT
public:
explicit VIOPHead(QObject *parent = nullptr);
ViSession *defaultRM;
ViSession *vi;
ViStatus *viStatus;
signals:
public slots:
};
#endif // VIOPHEAD_H
|
b2c94770cca28bebf045aab731c2e117feb6ed6c
|
2c3b2a8c1c0087172e074803df13c90868946f95
|
/string.cpp
|
8f6e7b3c9b83d012e0e2d4c4e34e4eee7feaecd5
|
[] |
no_license
|
elialaralara/programacion
|
be74b33f904bab5156f88cf37773de7985bb706e
|
18bf54ca9b7150fdae78754054a04c223012fc8d
|
refs/heads/master
| 2020-05-25T10:30:07.361959
| 2019-06-16T04:55:52
| 2019-06-16T04:55:52
| 187,760,743
| 0
| 0
| null | null | null | null |
ISO-8859-10
|
C++
| false
| false
| 698
|
cpp
|
string.cpp
|
//UNIVERSIDAD POLITECNICA DE TULANCINGO
//PROF: ARTURO NEGRETE MEDELLIN
//ALUMNA:ELIA AMOR LARA CABAŅAS
//MATRICULA:1830995
//3ER CUATRIMESTRE
//PRIMER PARCIAL
#include <string>
#include<iostream>
using namespace std;
int main()
{
string cadena, token;
cout<<"captura una cadena: ";
getline(cin, cadena);
//cout<<"la cadena mide: "<<cadena.length()<<"bytes."<<endl;
string delimita=" ";
size_t pos=0;
while((pos=cadena.find(delimita))!= string::npos)
{
token=cadena.substr(0,pos);
cout<<token<<endl;
cadena.erase(0,pos+delimita.length());
}
cout<<cadena;
return 0;
}
//HOMEWORK armar un arrelo para que me lo compile odo junto en la parte de abajo
|
08e89fc53c21e55d4cd097fd5329c5c2567bd66c
|
4891106ba038321c468e8f437d0ebde248fadd55
|
/test/experimental/js_compat/user_code/JsCompatMain.cpp
|
9fe9b822533199937af77b966ec9b116863baa04
|
[
"BSD-3-Clause"
] |
permissive
|
node-dot-cpp/node.cpp
|
0237db6a8c5de1333327bd84b136036a4e10bcf2
|
3f3defbec60743c0d9b0cc5c9c942a1911e34e87
|
refs/heads/master
| 2023-04-07T03:52:48.947977
| 2023-04-05T16:18:43
| 2023-04-05T16:18:43
| 136,624,360
| 36
| 4
|
BSD-3-Clause
| 2020-03-13T20:59:16
| 2018-06-08T13:44:16
|
C++
|
UTF-8
|
C++
| false
| false
| 2,005
|
cpp
|
JsCompatMain.cpp
|
// NetSocket.cpp : sample of user-defined code
#include <nodecpp/common.h>
#include <nodecpp/js_compat.h>
#include "./styles.h"
#include "./setMap.h"
#include "../js-compat-tests/misc_tests.h"
nodecpp::stdvector<nodecpp::stdstring> argv;
int main( int argc, char *argv_[] )
{
for ( int i=0; i<argc; ++i )
argv.push_back( argv_[i] );
#ifdef NODECPP_USE_IIBMALLOC
::nodecpp::iibmalloc::ThreadLocalAllocatorT allocManager;
allocManager.initialize();
::nodecpp::iibmalloc::ThreadLocalAllocatorT* formerAlloc = ::nodecpp::iibmalloc::setCurrneAllocator( &allocManager );
#endif
// so far we will used old good printf()
nodecpp::log::Log log;
// log.level = nodecpp::log::LogLevel::info;
log.add( stdout );
nodecpp::logging_impl::currentLog = &log;
nodecpp::logging_impl::instanceId = 0;
log.setCriticalLevel( nodecpp::log::LogLevel::err );
try {
JSVar styles = require<Styles>();
printf( "%s", styles(styles("COLOR TEST\n", "whiteBG"),"cyan").toString().c_str() );
JSVar setMap = require<SetMap>();
printf( "%s", setMap("MAPPED TEST\n", "america").toString().c_str() );
printf( "%s", setMap("MAPPED TEST\n", "rainbow").toString().c_str() );
printf( "%s", setMap("MAPPED TEST\n", "random").toString().c_str() );
printf( "%s", setMap("MAPPED TEST\n", "zebra").toString().c_str() );
printf( "%s", setMap("DROP THE BASS\n", "trap").toString().c_str() );
//auto& colors = import<Colors>();
//printf( "\n~~~~~~~~~~~~~~~\n%s\n~~~~~~~~~~~~~~~\n\n", colors.toString().c_str() );
auto& miscTests = import<MiscTests>();
// printf( "\n~~~~~~~~~~~~~~~%s\n~~~~~~~~~~~~~~~\n\n", miscTests.toString().c_str() );
//JS TEST
/*require('./extendStringPrototype')();
console.log('drop the bass'.trap);*/
}
catch (nodecpp::error::error e)
{
e.log(log, nodecpp::log::LogLevel::fatal);
}
catch (...)
{
nodecpp::log::default_log::fatal("Unknown error happened. About to exit...");
return 0;
}
nodecpp::log::default_log::fatal( "About to exit..." );
return 0;
}
|
4a6647cacdaedc4ab401b28fc52b3c6a72d172c0
|
d6e940986053b873004e37674559e7d65fe30a4e
|
/core/modbussensor.h
|
097797bcc477eeeacba4031ad9b38aa7cfb5d792
|
[] |
no_license
|
alex13sh/GraphicModbus
|
0712da17c3f83d47a6b0c7286d04144ea6d3e47c
|
5c61ce886c3ce99dcc9cf220561ca1da8a7f8e62
|
refs/heads/master
| 2023-01-10T23:15:26.003089
| 2020-09-15T10:04:04
| 2020-09-15T14:23:29
| 312,381,473
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 2,064
|
h
|
modbussensor.h
|
#ifndef MODBUSSENSOR_H
#define MODBUSSENSOR_H
#include <QObject>
#include <QtQml>
#include "defines.h"
enum SensorType{
OtherSensor=0,
Temper,
Davl
};
class ModbusDevice;
class ModbusSensor : public QObject
{
Q_OBJECT
QML_ELEMENT
Q_PROPERTY(QString name READ name CONSTANT)
Q_PROPERTY(float value READ value_float NOTIFY fvalueChanged)
Q_PROPERTY(QString hash READ hash CONSTANT)
Q_PROPERTY(float value_warn MEMBER m_value_warn CONSTANT)
Q_PROPERTY(float value_err MEMBER m_value_err CONSTANT)
Q_PROPERTY(float value_max MEMBER m_value_max NOTIFY value_maxChanged)
public:
explicit ModbusSensor(QObject *parent = nullptr);
ModbusSensor(const QString &name, quint8 pin, ModbusDevice *module);
void setModule(ModbusDevice *m_module, int pin);
const ModbusDevice *module() const {return m_module;}
// void setType_(SensorType_ m_type);
virtual void addValue(quint16 address, ModbusValue* value);
ListValues values() const;
void setInterval(quint16 interval);
void setValueErr(float warn, float err);
QString name() const {return m_name;}
quint8 pin() const {return m_pin;}
QString hash() const;
void updateValue();
ModbusValue *get_Value() {return v_value;}
float get_value_float();
virtual float value_float() const = 0;
float get_value_float_from_int(quint32 ivalue);
virtual float value_float_from_int(quint32 ivalue);
void setValueMax(float value);
// QList<float> convert_value_list(const QList<quint32> &values);
signals:
void fvalueChanged(/*float value*/);
void value_maxChanged();
protected:
QString m_name = "None";
SensorType m_type = OtherSensor;
const ModbusDevice *m_module=nullptr;
quint8 m_pin;
ListValues m_values;
ModbusValue *v_value = nullptr, *v_interval=nullptr;
QMap<QString, ModbusValue*> m_mapNameValue;
// ListValues m_sensorValues, m_optionValues;
float m_value_warn=-1, m_value_err=-1, m_value_max=0;
friend class ModbusDevice;
};
#endif // MODBUSSENSOR_H
|
f6ca0f80ab01ab1d68fdadfe68cbea563a60b1fa
|
828d7c0420090dfb8fec2f636932bd9fd7b3ac06
|
/build/mpl/segmenter/segmenter_logic.cc
|
1c443f6595f2f6f0fda56d4f7b1fb8e66e8fb3da
|
[] |
no_license
|
tmtbb/segmenter
|
2441e1a7470893544c290d178b84e0271181c67e
|
8f4638d48b9d865b1c2cbfb6c125a0d15d0f1221
|
refs/heads/master
| 2021-03-25T03:12:33.761705
| 2016-06-13T09:36:31
| 2016-06-13T09:36:31
| 58,257,110
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 5,554
|
cc
|
segmenter_logic.cc
|
// Copyright (c) 2015-2015 The KID Authors. All rights reserved.
// Created on: 2015年9月14日 Author: kerry
#include "segmenter_logic.h"
#include "relrank_dict.h"
#include "send_comm.h"
#include "basic/basictypes.h"
#include <string>
#include <list>
#include "core/common.h"
#define DEFAULT_CONFIG_PATH "./plugins/segmenter/segmenter_config.xml"
namespace segmenter_logic {
SegmenterManager*
SegmenterManager::instance_ = NULL;
SegmenterManager::SegmenterManager() {
if (!Init())
assert(0);
}
SegmenterManager::~SegmenterManager() {
}
bool SegmenterManager::Init() {
return true;
}
SegmenterManager*
SegmenterManager::GetInstance(){
if (instance_ == NULL)
instance_ = new SegmenterManager();
return instance_;
}
void SegmenterManager::FreeInstance() {
delete instance_;
}
bool SegmenterManager::LoadCharCore(const char* file_prefix,
const char* dfa_file) {
return dict_manager_.load_char_core(file_prefix, dfa_file);
}
float SegmenterManager::GetSegsEx(const char* buf, uint32_t sz,
char**& psegbuf, int*& ptype, float*& pfreq, uint32_t& cnt){
return dict_manager_.get_segs_ex(buf, sz, psegbuf, ptype, pfreq, cnt);
}
float SegmenterManager::GetSegsEx(const wchar_t* buf, uint32_t sz, wchar_t**& psegbuf,
int*& ptype, float*& pfreq, uint32_t& cnt, uint32_t hardbreak) {
return dict_manager_.get_segs_ex(buf, sz, psegbuf, ptype, pfreq, cnt,
hardbreak);
}
Segmenterlogic*
Segmenterlogic::instance_ = NULL;
Segmenterlogic::Segmenterlogic() {
if (!Init())
assert(0);
}
Segmenterlogic::~Segmenterlogic() {
SegmenterManager::FreeInstance();
}
bool Segmenterlogic::Init() {
std::string dict_core = "dict_20150526_web2.core";
std::string dict_dfa = "dfa_file_qss_yk2.map";
LOG_DEBUG2("dict_core%s dict_dfa%s", dict_core.c_str(),
dict_dfa.c_str());
dict_manager_ = SegmenterManager::GetInstance();
dict_manager_->LoadCharCore(dict_core.c_str(), dict_dfa.c_str());
return true;
}
Segmenterlogic*
Segmenterlogic::GetInstance() {
if (instance_ == NULL)
instance_ = new Segmenterlogic();
return instance_;
}
void Segmenterlogic::FreeInstance() {
delete instance_;
instance_ = NULL;
}
bool Segmenterlogic::OnSegmenterConnect(struct server *srv, const int socket) {
return true;
}
bool Segmenterlogic::OnSegmenterMessage(struct server *srv, const int socket,
const void *msg, const int len) {
bool r = false;
struct PacketHead* packet = NULL;
if (srv == NULL || socket < 0 || msg == NULL
|| len < PACKET_HEAD_LENGTH)
return false;
if (!ptl::PacketProsess::UnpackStream(msg, len, &packet)) {
LOG_ERROR2("UnpackStream Error socket %d", socket);
ptl::PacketProsess::HexEncode(msg, len);
return false;
}
assert(packet);
LOG_MSG("dump packet packet");
ptl::PacketProsess::DumpPacket(packet);
switch (packet->operate_code) {
case WORD_SEGMENTER: {
OnSegmentWord(srv,socket,packet);
break;
}
case WORD_RESULT_END: {
OnSegmentEnd(srv,socket,packet);
}
default:
break;
}
ptl::PacketProsess::DeletePacket(msg, len, packet);
return true;
}
bool Segmenterlogic::OnSegmenterClose(struct server *srv, const int socket) {
return true;
}
bool Segmenterlogic::OnBroadcastConnect(struct server *srv, const int socket,
const void *msg, const int len) {
return true;
}
bool Segmenterlogic::OnBroadcastMessage(struct server *srv, const int socket,
const void *msg, const int len) {
return true;
}
bool Segmenterlogic::OnBroadcastClose(struct server *srv, const int socket) {
return true;
}
bool Segmenterlogic::OnIniTimer(struct server *srv) {
return true;
}
bool Segmenterlogic::OnTimeout(struct server *srv, char *id,
int opcode, int time) {
switch (opcode) {
default:
break;
}
return true;
}
bool Segmenterlogic::OnSegmentEnd(struct server* srv, int socket,
struct PacketHead *packet, const void *msg,
int32 len) {
send_headmsg(socket, packet->operate_code, packet->type,packet->is_zip_encrypt,packet->reserved,packet->session_id);
return true;
}
bool Segmenterlogic::OnSegmentWord(struct server* srv, int socket,
struct PacketHead *packet, const void *msg,
int32 len) {
struct SegmenterWord* segmenter_word =
(struct SegmenterWord*)packet;
char** res;
int* type;
float* req;
uint32 bufsz;
int32 base_num = 40;
float sc = dict_manager_->GetSegsEx(segmenter_word->content.c_str(),
segmenter_word->content.length(), res, type, req, bufsz);
struct WordResult word_result;
MAKE_HEAD(word_result, WORD_RESULT, 0, 0, 0, packet->reserved);
for (uint32 i = 0; i < bufsz; i++) {
struct WordUnit* unit = new struct WordUnit;
memset(unit->word, '\0', WORD_SIZE);
memcpy(unit->word, res[i],
(WORD_SIZE - 1) < strlen(res[i]) ?
(WORD_SIZE - 1) : strlen(res[i]));
unit->utype = type[i];
word_result.list.push_back(unit);
if (word_result.list.size() % base_num == 0 &&
word_result.list.size() != 0) {
//发送
send_message(socket, &word_result);
//清理
ptl::PacketProsess::ClearWordList((struct PacketHead*)&word_result);
}
}
//剩余分词
if(word_result.list.size() > 0) {
send_message(socket, &word_result);
ptl::PacketProsess::ClearWordList((struct PacketHead*)&word_result);
}
//结束
//send_headmsg(socket, WORD_RESULT_END, 0, 0,0,0);
return true;
}
}
|
373f0ef49cdbbfd0df655184a74bbda47bb1f2fe
|
b418e15db462002cc190c89f38be547615781848
|
/DirectXProj/1600196_FraserBarker/source/DirectXProj/ShadowShader.cpp
|
872830d89442a63545681532320a46f9a792396c
|
[] |
no_license
|
Shorte240/DirectX-Project
|
911b410818d760395e5886fd2218e6c7d63c7b3a
|
9ead5b6943c3540748838c3de9e5704af66270f7
|
refs/heads/master
| 2020-04-06T09:41:52.809444
| 2018-12-11T18:46:23
| 2018-12-11T18:46:23
| 157,353,011
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 7,499
|
cpp
|
ShadowShader.cpp
|
// Shadow Shader.cpp
#include "shadowshader.h"
ShadowShader::ShadowShader(ID3D11Device* device, HWND hwnd) : BaseShader(device, hwnd)
{
initShader(L"shadow_vs.cso", L"shadow_ps.cso");
}
ShadowShader::~ShadowShader()
{
// Release the sampler state.
if (sampleState)
{
sampleState->Release();
sampleState = 0;
}
// Release the shadow sampler.
if (sampleStateShadow)
{
sampleStateShadow->Release();
sampleStateShadow = 0;
}
// Release the matrix constant buffer.
if (matrixBuffer)
{
matrixBuffer->Release();
matrixBuffer = 0;
}
// Release the layout.
if (layout)
{
layout->Release();
layout = 0;
}
// Release the light constant buffer.
if (lightBuffer)
{
lightBuffer->Release();
lightBuffer = 0;
}
// Release the attenuation constant buffer.
if (attenuationBuffer)
{
attenuationBuffer->Release();
attenuationBuffer = 0;
}
//Release base shader components
BaseShader::~BaseShader();
}
void ShadowShader::initShader(WCHAR* vsFilename, WCHAR* psFilename)
{
D3D11_BUFFER_DESC matrixBufferDesc;
D3D11_SAMPLER_DESC samplerDesc;
D3D11_BUFFER_DESC lightBufferDesc;
D3D11_BUFFER_DESC attenuationBufferDesc;
// Load (+ compile) shader files
loadVertexShader(vsFilename);
loadPixelShader(psFilename);
// Setup the description of the dynamic matrix constant buffer that is in the vertex shader.
matrixBufferDesc.Usage = D3D11_USAGE_DYNAMIC;
matrixBufferDesc.ByteWidth = sizeof(MatrixBufferType);
matrixBufferDesc.BindFlags = D3D11_BIND_CONSTANT_BUFFER;
matrixBufferDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
matrixBufferDesc.MiscFlags = 0;
matrixBufferDesc.StructureByteStride = 0;
renderer->CreateBuffer(&matrixBufferDesc, NULL, &matrixBuffer);
// Create a texture sampler state description.
samplerDesc.Filter = D3D11_FILTER_MIN_MAG_MIP_LINEAR;
samplerDesc.AddressU = D3D11_TEXTURE_ADDRESS_MIRROR;
samplerDesc.AddressV = D3D11_TEXTURE_ADDRESS_MIRROR;
samplerDesc.AddressW = D3D11_TEXTURE_ADDRESS_MIRROR;
samplerDesc.MipLODBias = 0.0f;
samplerDesc.MaxAnisotropy = 1;
samplerDesc.ComparisonFunc = D3D11_COMPARISON_ALWAYS;
samplerDesc.BorderColor[0] = 0;
samplerDesc.BorderColor[1] = 0;
samplerDesc.BorderColor[2] = 0;
samplerDesc.BorderColor[3] = 0;
samplerDesc.MinLOD = 0;
samplerDesc.MaxLOD = D3D11_FLOAT32_MAX;
renderer->CreateSamplerState(&samplerDesc, &sampleState);
// Sampler for shadow map sampling.
samplerDesc.Filter = D3D11_FILTER_MIN_MAG_MIP_POINT;
samplerDesc.AddressU = D3D11_TEXTURE_ADDRESS_BORDER;
samplerDesc.AddressV = D3D11_TEXTURE_ADDRESS_BORDER;
samplerDesc.AddressW = D3D11_TEXTURE_ADDRESS_BORDER;
samplerDesc.BorderColor[0] = 1.0f;
samplerDesc.BorderColor[1] = 1.0f;
samplerDesc.BorderColor[2] = 1.0f;
samplerDesc.BorderColor[3] = 1.0f;
renderer->CreateSamplerState(&samplerDesc, &sampleStateShadow);
// Setup light buffer
lightBufferDesc.Usage = D3D11_USAGE_DYNAMIC;
lightBufferDesc.ByteWidth = sizeof(LightBufferType);
lightBufferDesc.BindFlags = D3D11_BIND_CONSTANT_BUFFER;
lightBufferDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
lightBufferDesc.MiscFlags = 0;
lightBufferDesc.StructureByteStride = 0;
renderer->CreateBuffer(&lightBufferDesc, NULL, &lightBuffer);
// Setup attenuation buffer
// Setup the description of the attenuation factor dynamic constant buffer that is in the pixel shader.
// Note that ByteWidth always needs to be a multiple of 16 if using D3D11_BIND_CONSTANT_BUFFER or CreateBuffer will fail.
attenuationBufferDesc.Usage = D3D11_USAGE_DYNAMIC;
attenuationBufferDesc.ByteWidth = sizeof(AttenuationBufferType);
attenuationBufferDesc.BindFlags = D3D11_BIND_CONSTANT_BUFFER;
attenuationBufferDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
attenuationBufferDesc.MiscFlags = 0;
attenuationBufferDesc.StructureByteStride = 0;
renderer->CreateBuffer(&attenuationBufferDesc, NULL, &attenuationBuffer);
}
void ShadowShader::setShaderParameters(ID3D11DeviceContext* deviceContext, const XMMATRIX &worldMatrix, const XMMATRIX &viewMatrix, const XMMATRIX &projectionMatrix, ID3D11ShaderResourceView* texture, ID3D11ShaderResourceView*depthMap, ID3D11ShaderResourceView*depthMap2, ID3D11ShaderResourceView*depthMap3, Light* lights[MAX_LIGHTS], float spotAngle, float constFactor, float linFactor, float quadFactor)
{
D3D11_MAPPED_SUBRESOURCE mappedResource;
MatrixBufferType* dataPtr;
LightBufferType* lightPtr;
// Transpose the matrices to prepare them for the shader.
XMMATRIX tworld = XMMatrixTranspose(worldMatrix);
XMMATRIX tview = XMMatrixTranspose(viewMatrix);
XMMATRIX tproj = XMMatrixTranspose(projectionMatrix);
// Transpose all the light matrices to prepare them for the shader.
XMMATRIX tLightViewMatrix = XMMatrixTranspose(lights[0]->getViewMatrix());
XMMATRIX tLightProjectionMatrix = XMMatrixTranspose(lights[0]->getOrthoMatrix());
XMMATRIX tLightViewMatrix2 = XMMatrixTranspose(lights[1]->getViewMatrix());
XMMATRIX tLightProjectionMatrix2 = XMMatrixTranspose(lights[1]->getOrthoMatrix());
XMMATRIX tLightViewMatrix3 = XMMatrixTranspose(lights[2]->getViewMatrix());
XMMATRIX tLightProjectionMatrix3 = XMMatrixTranspose(lights[2]->getOrthoMatrix());
// Lock the constant buffer so it can be written to.
// Send all the light matrix data to the vertex shader.
deviceContext->Map(matrixBuffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
dataPtr = (MatrixBufferType*)mappedResource.pData;
dataPtr->world = tworld;// worldMatrix;
dataPtr->view = tview;
dataPtr->projection = tproj;
dataPtr->lightView[0] = tLightViewMatrix;
dataPtr->lightProjection[0] = tLightProjectionMatrix;
dataPtr->lightView[1] = tLightViewMatrix2;
dataPtr->lightProjection[1] = tLightProjectionMatrix2;
dataPtr->lightView[2] = tLightViewMatrix3;
dataPtr->lightProjection[2] = tLightProjectionMatrix3;
deviceContext->Unmap(matrixBuffer, 0);
deviceContext->VSSetConstantBuffers(0, 1, &matrixBuffer);
// Send light data to pixel shader
deviceContext->Map(lightBuffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
lightPtr = (LightBufferType*)mappedResource.pData;
for (int i = 0; i < MAX_LIGHTS; i++)
{
lightPtr->ambient[i] = lights[i]->getAmbientColour();
lightPtr->diffuse[i] = lights[i]->getDiffuseColour();
lightPtr->direction[i] = XMFLOAT4(lights[i]->getDirection().x, lights[i]->getDirection().y, lights[i]->getDirection().z, 0.0f);
}
lightPtr->position = XMFLOAT4(lights[2]->getPosition().x, lights[2]->getPosition().y, lights[2]->getPosition().z, 0.0f);
lightPtr->spotlightAngle = spotAngle;
lightPtr->padding = XMFLOAT3(1.0f, 1.0f, 1.0f);
deviceContext->Unmap(lightBuffer, 0);
deviceContext->PSSetConstantBuffers(0, 1, &lightBuffer);
// Send attenuation data to pixel shader
AttenuationBufferType* attenPtr;
deviceContext->Map(attenuationBuffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
attenPtr = (AttenuationBufferType*)mappedResource.pData;
attenPtr->constantFactor = constFactor;
attenPtr->linearFactor = linFactor;
attenPtr->quadraticFactor = quadFactor;
attenPtr->pad = 0.0f;
deviceContext->Unmap(attenuationBuffer, 0);
deviceContext->PSSetConstantBuffers(1, 1, &attenuationBuffer);
// Set shader texture resource in the pixel shader.
deviceContext->PSSetShaderResources(0, 1, &texture);
deviceContext->PSSetShaderResources(1, 1, &depthMap);
deviceContext->PSSetShaderResources(2, 1, &depthMap2);
deviceContext->PSSetShaderResources(3, 1, &depthMap3);
deviceContext->PSSetSamplers(0, 1, &sampleState);
deviceContext->PSSetSamplers(1, 1, &sampleStateShadow);
}
|
93778ec101cf01c0c57d055c6d661598853ad4dc
|
2cf41d26e24c2ee8630ff0c5e4a312243cc2d062
|
/interpreter/expr/Variable.cpp
|
19eec64eba7adf967fc5057e902170a3c0a367f2
|
[] |
no_license
|
RafaelDiasCampos/MiniPHP
|
fd93409dd613aee8c258723026af0d93f3fdcf1f
|
b8b6a92e996146f4035a216245dfbe6e1f665236
|
refs/heads/master
| 2023-03-14T23:41:37.680259
| 2021-03-28T04:24:24
| 2021-03-28T04:24:24
| 299,467,124
| 1
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 440
|
cpp
|
Variable.cpp
|
#include "Variable.h"
#include "../value/ArrayValue.h"
Variable::Variable(std::string name) : SetExpr(-1, Expr::Variable), m_name(name) {
}
Variable::~Variable() {
}
Type* Variable::expr() {
return Memory::read(m_name);
}
Variable* Variable::instance(std::string name) {
return new Variable(name);
}
std::string Variable::name() {
return m_name;
}
void Variable::setExpr(Type* value) {
Memory::write(m_name, value);
}
|
d608dd4681929b16d2c06149aa60f9eb27bc12d6
|
d4045d9a41bd22efc2cb08638154ea87cb68d84d
|
/QStaticAnalysis/Edge.cpp
|
43abb7b98a2936939e388f8ee76f171ab99564d3
|
[] |
no_license
|
ayass3r/StaticTimingAnalysisQuest
|
7dc94262e1695dc50f9322b264de751d3e500ff9
|
9d95c403331b1f9fd777bf2d58db407ef06bb9a5
|
refs/heads/master
| 2021-01-24T06:30:53.696078
| 2015-05-27T22:01:29
| 2015-05-27T22:01:29
| 35,093,339
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 959
|
cpp
|
Edge.cpp
|
//
// Edge.cpp
// VParser
//
// Created by Mahmoud Khodary on 5/15/15.
// Copyright (c) 2015 Mahmoud Khodary. All rights reserved.
//
#include "Edge.h"
Edge::Edge(gate* source, gate* destination, std::string name, std::string p)
{
if(source == NULL || destination==NULL)
std::cout << "Null pointer: " << name << " "<< std::endl ;
gSource = source;
gDestination = destination;
topVisited = false;
wireName = name;
pin = p;
}
gate* Edge::getSource()
{
return gSource;
}
gate* Edge::getDestination()
{
return gDestination;
}
void Edge::setTopVisited(bool v)
{
topVisited = v;
}
bool Edge::getTopVisited()
{
return topVisited;
}
std::string Edge::getPin()
{
return pin;
}
void Edge::setSlewRate(float c)
{
inSlewRate =c;
}
float Edge::getSlewRate(){
return inSlewRate;
}
void Edge::setNCapacitance(float c)
{
netCapacitance = c;
}
float Edge::getNCapacitance()
{
return netCapacitance;
}
|
c7941c747e4a038a4a5cd25f41796e6e2c5fc40e
|
93a8a02681001999d05b960d0dd8c58fbb522fee
|
/tests/SOBasis_test.cpp
|
30567d63ca39b59f28525e6c3253c22fbb414580
|
[] |
no_license
|
tmhuysen/libwint
|
2dd9e8ff4caa5c6cf2441410bcc0636e14183676
|
eef54653ea9ad8059d69d908578599bd458a7c9e
|
refs/heads/master
| 2021-04-15T09:29:39.649226
| 2018-03-22T18:32:19
| 2018-03-22T18:32:19
| 126,815,700
| 0
| 0
| null | 2018-03-26T11:01:01
| 2018-03-26T11:01:01
| null |
UTF-8
|
C++
| false
| false
| 3,895
|
cpp
|
SOBasis_test.cpp
|
#define BOOST_TEST_MODULE "SOBasis"
#include "SOBasis.hpp"
#include "transformations.hpp"
#include <cpputil.hpp>
#include <boost/test/unit_test.hpp>
#include <boost/test/included/unit_test.hpp> // include this to get main(), otherwise clang++ will complain
BOOST_AUTO_TEST_CASE ( transform_jacobi ) {
// Create an SOBasis instance with a coefficient matrix being the identity matrix (little hack that we can use to test transformations)
libwint::Molecule water ("../tests/ref_data/h2o.xyz"); // the relative path to the input .xyz-file w.r.t. the out-of-source build directory
libwint::AOBasis ao_basis (water, "STO-3G");
ao_basis.calculateIntegrals();
size_t K = ao_basis.calculateNumberOfBasisFunctions();
Eigen::MatrixXd C = Eigen::MatrixXd::Identity(K, K);
libwint::SOBasis so_basis (ao_basis, C);
// Test if the rotateJacobi wrapper transformation is the same as using a Jacobi matrix as transformation matrix
// Specify some Jacobi rotation parameters
size_t p = 2;
size_t q = 5;
double theta = 56.81;
// Use a Jacobi rotation matrix as transformation matrix
Eigen::MatrixXd J = libwint::transformations::jacobiRotationMatrix(p, q, theta, K);
Eigen::MatrixXd h = so_basis.get_h_SO();
Eigen::Tensor<double, 4> g = so_basis.get_g_SO();
Eigen::MatrixXd h_transformed_by_jacobi_matrix = libwint::transformations::transformOneElectronIntegrals(h, J);
Eigen::Tensor<double, 4> g_transformed_by_jacobi_matrix = libwint::transformations::transformTwoElectronIntegrals(g, J);
// Rotate the SO basis
so_basis.rotateJacobi(p, q, theta);
BOOST_REQUIRE(h_transformed_by_jacobi_matrix.isApprox(so_basis.get_h_SO(), 1.0e-12));
BOOST_REQUIRE(cpputil::linalg::areEqual(g_transformed_by_jacobi_matrix, so_basis.get_g_SO(), 1.0e-12));
}
BOOST_AUTO_TEST_CASE ( fcidump_constructor ) {
libwint::SOBasis so_basis ("../tests/ref_data/beh_cation_631g_caitlin.FCIDUMP", 16);
// Check if the one-electron integrals are read in correctly from a previous implementation
Eigen::MatrixXd h_SO = so_basis.get_h_SO();
BOOST_CHECK(std::abs(h_SO(0,0) - (-8.34082)) < 1.0e-5);
BOOST_CHECK(std::abs(h_SO(5,1) - 0.381418) < 1.0e-6);
BOOST_CHECK(std::abs(h_SO(14,0) - 0.163205) < 1.0e-6);
BOOST_CHECK(std::abs(h_SO(13,6) - (-5.53204e-16)) < 1.0e-16);
BOOST_CHECK(std::abs(h_SO(15,11) - (-0.110721)) < 1.0e-6);
// Check if the two-electron integrals are read in correctly from a previous implementation
Eigen::Tensor<double, 4> g_SO = so_basis.get_g_SO();
BOOST_CHECK(std::abs(g_SO(2,5,4,4) - 0.0139645) < 1.0e-6);
BOOST_CHECK(std::abs(g_SO(2,6,3,0) - 5.16622e-18) < 1.0e-17);
BOOST_CHECK(std::abs(g_SO(3,1,3,0) - (-0.0141251)) < 1.0e-6);
BOOST_CHECK(std::abs(g_SO(4,6,4,6) - 0.0107791) < 1.0e-6);
BOOST_CHECK(std::abs(g_SO(4,15,11,1) - (9.33375e-19)) < 1.0e-17);
BOOST_CHECK(std::abs(g_SO(6,10,5,9) - (-3.81422e-18)) < 1.0e-17);
BOOST_CHECK(std::abs(g_SO(7,7,2,1) - (-0.031278)) < 1.0e-6);
BOOST_CHECK(std::abs(g_SO(8,15,9,9) - (-2.80093e-17)) < 1.0e-16);
BOOST_CHECK(std::abs(g_SO(9,14,0,9) - 0.00161985) < 1.0e-7);
BOOST_CHECK(std::abs(g_SO(10,1,4,3) - 0.00264603) < 1.0e-7);
BOOST_CHECK(std::abs(g_SO(11,4,9,3) - (-0.0256623)) < 1.0e-6);
BOOST_CHECK(std::abs(g_SO(12,9,0,4) - 0.0055472) < 1.0e-6);
BOOST_CHECK(std::abs(g_SO(13,15,15,13) - 0.00766898) < 1.0e-7);
BOOST_CHECK(std::abs(g_SO(14,2,12,3) - 0.0104266) < 1.0e-7);
BOOST_CHECK(std::abs(g_SO(15,5,10,10) - 0.00562608) < 1.0e-7);
}
BOOST_AUTO_TEST_CASE ( fcidump_constructor_horton ) {
// Check the same reference value as horton does
libwint::SOBasis so_basis ("../tests/ref_data/h2_psi4_horton.FCIDUMP", 10);
Eigen::Tensor<double, 4> g_SO = so_basis.get_g_SO();
BOOST_CHECK(std::abs(g_SO(6,5,1,0) - 0.0533584656) < 1.0e-7);
}
|
57f5de785c5d241d0cff995b3cd5d9ae680943f9
|
f6fd5f8bcda62e2b9c3c2b0267c8245100316a10
|
/codeforces/a.cpp
|
a26725e8c83d8cedb24a266f400a49c5c53d648a
|
[] |
no_license
|
hymsly/CompetitiveProgramming
|
9f292673dd6b1809deb354b9d9b0e85c820201f1
|
daf91095fab74e5a4f6441e34263ea3db1290d4a
|
refs/heads/master
| 2021-07-24T09:42:33.589976
| 2020-05-19T14:26:58
| 2020-05-19T14:26:58
| 172,566,245
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 2,044
|
cpp
|
a.cpp
|
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
map<int,int> M;
map<int,int> N;
map<int,int> ansM;
map<int,int> ansN;
int func[10000004];
void criba(){
for(ll i=2;i*i<=(10000000);i++){
if(!func[i]){
for(ll j=i*i;j<=(10000000);j+=i) func[j]=i;
}
}
for(int i=2;i<=10000000;i++) if(!func[i]) func[i]=i;
}
void f(ll x){
while(x>1){
int val = func[x];
while(x%val==0){
M[val]++;
x/=val;
}
}
/*for(ll i=2;(i*i)<=x;i++){
while(x%i==0){
M[i]++;
x/=i;
}
}
if(x>1) M[x]++;*/
}
void ff(ll x){
while(x>1){
int val = func[x];
while(x%val==0){
N[val]++;
x/=val;
}
}
/*for(ll i=2;(i*i)<=x;i++){
while(x%i==0){
N[i]++;
x/=i;
}
}
if(x>1) N[x]++;*/
}
void procesar(){
map<int,int> :: iterator it;
for(it=M.begin();it!=M.end();it++){
int primo=(*it).first;
if(N.find(primo)!=N.end()){
if( N[primo]<M[primo]){
ansM[primo]=M[primo]-N[primo];
}
}
else ansM[primo]=M[primo];
}
for(it=N.begin();it!=N.end();it++){
int primo=(*it).first;
if(M.find(primo)!=M.end()){
if( N[primo] > M[primo]){
ansN[primo]=N[primo]-M[primo];
}
}
else ansN[primo]=N[primo];
}
}
int tam(map<int,int> X){
map<int,int> :: iterator it;
int ans=0;
for(it=X.begin();it!=X.end();it++){
ans+=(*it).second;
}
return ans;
}
void mostrar(){
cout<<max(1,tam(ansM))<<" "<<max(1,tam(ansN))<<endl;
map<int,int> :: iterator it;
if(ansM.size()==0) cout<<"1";
for(it=ansM.begin();it!=ansM.end();it++){
int primo=(*it).first;
int cnt=(*it).second;
for(int i=0;i<cnt;i++){
cout<<primo<<" ";
}
}
cout<<'\n';
if(ansN.size()==0) cout<<"1";
for(it=ansN.begin();it!=ansN.end();it++){
int primo=(*it).first;
int cnt=(*it).second;
for(int i=0;i<cnt;i++){
cout<<primo<<" ";
}
}
cout<<'\n';
}
int main(){
ios_base::sync_with_stdio(0);
cin.tie(NULL);
cout.tie(NULL);
criba();
int n,m;cin>>n>>m;
int num;
for(int i=0;i<n;i++){
cin>>num;
f(num);
}
for(int i=0;i<m;i++){
cin>>num;
ff(num);
}
procesar();
mostrar();
return 0;
}
|
5e2228a1614f6c6d4151ec7550f4499b3f9fcf4b
|
7a839b740a64ce82c7993768c95041f2a2cc06da
|
/src/pipedcp/process.cpp
|
661db3029e157a2c8786e6e05c7701e0f6d245c2
|
[] |
no_license
|
eiji03aero/pipedcp
|
e3aef344dc81d7ae0b196f2479ad891ec64ea721
|
51efe3da1f7058c286142f2b2b4c748c0c61af6c
|
refs/heads/master
| 2022-12-13T10:32:33.111483
| 2020-09-19T02:49:47
| 2020-09-19T02:49:47
| 296,606,673
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 258
|
cpp
|
process.cpp
|
#include "pipedcp/process.h"
namespace pipedcp {
void Process::kill() {
::kill(child_pid, SIGKILL);
}
void Process::close() {
::close(outpipefd[0]);
::close(outpipefd[1]);
::close(inpipefd[0]);
::close(inpipefd[1]);
}
} /* namespace pipedcp */
|
6b4219d3e65d28577051d2d3e893df6a0b2375fa
|
6b550d3d0b182bcddda1f0a175d6b6cd07b60fb3
|
/logdevice/server/GetEpochRecoveryMetadataStorageTask.h
|
648b435e1ee1075c3eafc88d313f2baecc0557b4
|
[
"BSD-3-Clause"
] |
permissive
|
Rachelmorrell/LogDevice
|
5bd04f7ab0bdf9cc6e5b2da4a4b51210cdc9a4c8
|
3a8d800033fada47d878b64533afdf41dc79e057
|
refs/heads/master
| 2021-06-24T09:10:20.240011
| 2020-04-21T14:10:52
| 2020-04-21T14:13:09
| 157,563,026
| 1
| 0
|
NOASSERTION
| 2020-04-21T19:20:55
| 2018-11-14T14:43:33
|
C++
|
UTF-8
|
C++
| false
| false
| 2,130
|
h
|
GetEpochRecoveryMetadataStorageTask.h
|
/**
* Copyright (c) 2017-present, Facebook, Inc. and its affiliates.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree.
*/
#pragma once
#include "logdevice/common/Address.h"
#include "logdevice/common/protocol/GET_EPOCH_RECOVERY_METADATA_REPLY_Message.h"
#include "logdevice/common/types_internal.h"
#include "logdevice/include/Err.h"
#include "logdevice/server/locallogstore/LocalLogStore.h"
#include "logdevice/server/storage_tasks/StorageTask.h"
namespace facebook { namespace logdevice {
/**
* @file A task responsible for reading EpochRecoveryMetadata for a
* <logid, epoch> pair if the epoch is clean. It is also responsible
* for sending reply to the GET_EPOCH_RECOVERY_METADATA message
* receieved previously regarding the state of the epoch.
*/
class EpochRecoveryMetadata;
struct GET_EPOCH_RECOVERY_METADATA_Header;
class LocalLogStore;
class LogStorageStateMap;
class GetEpochRecoveryMetadataStorageTask : public StorageTask {
public:
GetEpochRecoveryMetadataStorageTask(
const GET_EPOCH_RECOVERY_METADATA_Header& header,
const Address& reply_to,
const shard_index_t shard);
// see StorageTask.h
void execute() override;
void onDone() override;
void onDropped() override;
StorageTaskPriority getPriority() const override {
// metadata access for purging
return StorageTaskPriority::HIGH;
}
// Public for tests
Status executeImpl(LocalLogStore& store,
LogStorageStateMap& state_map,
StatsHolder* stats = nullptr);
void sendReply();
const EpochRecoveryStateMap& getEpochRecoveryStateMap() const {
return epochRecoveryStateMap_;
}
private:
const logid_t log_id_;
const shard_index_t shard_;
const shard_index_t purging_shard_;
const epoch_t purge_to_;
const epoch_t start_;
const epoch_t end_;
const Address reply_to_;
const request_id_t request_id_;
Status status_;
EpochRecoveryStateMap epochRecoveryStateMap_;
};
}} // namespace facebook::logdevice
|
0d824e8f15adb47527ecc8bfc09a1b853d345b78
|
ec390da9ff15cb2114e16742b6cad780732913b5
|
/iter1/❌49.cpp
|
d2fa76782dd7f681adbd1ca04962798814577620
|
[] |
no_license
|
xiaomi388/LeetCode
|
6107487537eeb1ac6128955cd30868985d1509ea
|
877d0fbccc684e4fd7fee2aca63d2656f71a0241
|
refs/heads/master
| 2021-09-26T19:52:34.207507
| 2021-09-17T20:32:53
| 2021-09-17T20:32:53
| 241,884,416
| 1
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 246
|
cpp
|
❌49.cpp
|
//
// Created by chenyufan on 2020/5/27.
//
#include <vector>
#include <unordered_map>
#include <string>
using namespace std;
class Solution {
public:
vector<vector<string>> groupAnagrams(vector<string>& strs) {
}
};
int main() {
}
|
adfa79df83d6e0117abeeb9cfcbf1042d6a9a04a
|
001cfc06d55c891558db5d1f6ab52d1214f59669
|
/erythrocyte/kinoshita_2007/new-BAND3/TAGFluxProcess.cpp
|
e4c397bd5318ac6fffe5e476c8b38e1eabf24595
|
[] |
no_license
|
naito/ecell3_models
|
4818171d7f09bd91a368dcd70e0ff4924f70fad1
|
0fe92aa7146a10f5d43ddf03e9b4ab2f57c80d8a
|
refs/heads/master
| 2021-01-18T22:39:56.189148
| 2016-04-19T05:04:51
| 2016-04-19T05:04:51
| 2,242,023
| 1
| 1
| null | 2013-09-11T04:55:28
| 2011-08-21T03:13:14
|
C++
|
UTF-8
|
C++
| false
| false
| 1,447
|
cpp
|
TAGFluxProcess.cpp
|
#include "libecs.hpp"
#include "Util.hpp"
#include "PropertyInterface.hpp"
#include "ContinuousProcess.hpp"
#include "System.hpp"
#include "Process.hpp"
//include "iostream.h"
#include "Stepper.hpp"
USE_LIBECS;
LIBECS_DM_CLASS( TAGFluxProcess, ContinuousProcess )
{
public:
LIBECS_DM_OBJECT( TAGFluxProcess, Process ){
INHERIT_PROPERTIES( Process );
PROPERTYSLOT_SET_GET( Real,base );
}
TAGFluxProcess()
:
base(0.0)
{
; // do nothing
}
SIMPLE_SET_GET_METHOD( Real,base);
virtual void initialize(){
Process::initialize();
E0 = getVariableReference( "E0" );
E1 = getVariableReference( "E1" );
count = 0;
}
virtual void fire(){
Real PO2 = E0.getVariable()->getValue();
Real TAG = E1.getVariable()->getValue();
// Real baseline = base + (1e-5);
Real baseline = base + (1e-2);
if ( count == 0 )
{
if ( PO2 > baseline ) TAG = 0;
else
{
TAG = 0;
count = 1;
}
}
else
{
// if ( PO2 < 100-(1e-5) ) TAG = 1;
if ( PO2 < 100+(1e-2) ) TAG = 1;
else
{
TAG = 1;
count = 0;
}
}
E1.getVariable()->setValue(TAG);
}
protected:
VariableReference E0;
VariableReference E1;
Real count;
Real base;
};
LIBECS_DM_INIT( TAGFluxProcess, Process);
|
d19e9cb4cc2906b03b53a4ae12870ac449a001a7
|
f546450b50098fe0b32ecaca265546d7914e8355
|
/main.cpp
|
8dd2bc72ebecce41e83ff3d731267365e8224ca7
|
[] |
no_license
|
DingYuan0118/Beijing
|
a41381705390d7cc85377b612f347c6c80648362
|
eb7c6249f325c32c6f66f3535259538a979d77cb
|
refs/heads/master
| 2020-09-20T18:42:07.512287
| 2019-11-28T03:48:18
| 2019-11-28T03:48:18
| 224,561,624
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 5,193
|
cpp
|
main.cpp
|
#include <opencv2/opencv.hpp>
#include <iostream>
#include <stdio.h>
#include <string>
#include "cv.h"
#include <math.h>
using namespace cv;
using namespace std;
int main()
{
IplImage* pFrame = NULL;//视频中截取的一帧
IplImage* pFrImg = NULL;//当前帧的灰度图
IplImage* pBkImg = NULL;//当前背景的灰度图
IplImage* pFrameTemp = NULL;
CvMat* pFrameMat = NULL;//当前灰度矩阵
CvMat* pFrMat = NULL;//当前前景图矩阵
CvMat* pBkMat = NULL;//当前背景图矩阵
//形态学处理时内核大小
IplConvKernel* Element = cvCreateStructuringElementEx(13,13, 1, 1, CV_SHAPE_RECT, NULL);
//轮廓边缘提取时的参数
CvMemStorage* storage = cvCreateMemStorage(0);
CvSeq* contour = 0;//可动态增长元素序列
int mode = CV_RETR_EXTERNAL;//只检索最外面的轮廓
//在视频中画出感兴趣的区域
CvPoint pt1, pt2, pt3, pt4, pt5;//pt3,pt4为轮廓矩阵的左下右上
pt1.x = 400;//视频左下点
pt1.y = 0;
pt2.x = 0;//视频右上点
pt2.y = 400;
//用cvBoundingRect画出外接矩形时需要的矩形
CvRect bndRect = cvRect(0, 0, 0, 0);
//运动对象中心坐标
int avgX = 0;
int avgY = 0;
//视频捕获
CvCapture* pCapture = NULL;
//图像的帧数
int nFramNum = 0;
//创建窗口
cvNamedWindow("video", 1);
cvNamedWindow("foreground", 1);
cvMoveWindow("video", 30, 0);
cvMoveWindow("foreground", 690, 0);
pCapture = cvCaptureFromFile("video1.avi");
//pFrame = cvQueryFrame(pCapture);
pFrameTemp = cvQueryFrame(pCapture);
pFrame = cvCreateImage(cvGetSize(pFrameTemp), 8, 3);//大小和pFrameTemp相同,8Bit深度3通道图像
cvCopy(pFrameTemp, pFrame);//将所生成的临时帧复制到pFrame
//逐帧读取视频,cvQueryFrame从摄像头或者文件中抓取并返回一帧
while (pFrameTemp = cvQueryFrame(pCapture)){
cvCopy(pFrameTemp, pFrame);
nFramNum++;
//如果是第一帧,申请内存并初始化
if (nFramNum == 1){
pBkImg = cvCreateImage(cvSize(pFrame->width, pFrame->height), IPL_DEPTH_8U, 1);//8Bit深度,单通道图像
pFrImg = cvCreateImage(cvSize(pFrame->width, pFrame->height), IPL_DEPTH_8U, 1);
pBkMat = cvCreateMat(pFrame->height, pFrame->width, CV_32FC1);//CV_32FC1 代表32位浮点型单通道矩阵
pFrMat = cvCreateMat(pFrame->height, pFrame->width, CV_32FC1);
pFrameMat = cvCreateMat(pFrame->height, pFrame->width, CV_32FC1);
cvCvtColor(pFrame, pBkImg, CV_BGR2GRAY);//转换成单通道灰度图
cvCvtColor(pFrame, pFrImg, CV_BGR2GRAY);
cvConvert(pFrImg, pFrameMat);//转换成矩阵
cvConvert(pFrImg, pFrMat);
cvConvert(pFrImg, pBkMat);
}
else if (nFramNum >= 2){
cvCvtColor(pFrame, pFrImg, CV_BGR2GRAY);
cvConvert(pFrImg, pFrameMat);
//先高斯滤波平滑图像
cvSmooth(pFrameMat, pFrameMat, CV_GAUSSIAN, 3, 0, 0);
//在视频中设置并画ROI区域
cvRectangle(pFrame, pt1, pt2, CV_RGB(255, 0, 0), 2, 8, 0);//线条亮度(255,0,0)为白色,粗细2,类型8
//当前帧跟背景图相减,计算两个数组差的绝对值
cvAbsDiff(pFrameMat, pBkMat, pFrMat);
//二值化前景图
cvThreshold(pFrMat, pFrImg, 40, 255.0, CV_THRESH_BINARY);//阈值函数,类型为CV_THRESH_BINARY 二值化
//膨胀操作,内核为Element
cvDilate(pFrImg, pBkImg, Element, 1);
//通过查找边界找出ROI矩形区域内的运动车辆
cvFindContours(pBkImg, storage, &contour, sizeof(CvContour), mode, CV_CHAIN_APPROX_SIMPLE);//二值图像中寻找轮廓
//处理当前框架中移动的轮廓,用函数cvBoundingRect
for (; contour != 0; contour = contour->h_next){
//获得运动车辆的矩形
bndRect = cvBoundingRect(contour, 0);
//获得运动轮廓的平均x坐标
avgX = bndRect.x + (bndRect.width) / 2;
avgY = bndRect.y + (bndRect.height) / 2;
//如果轮廓中心点在ROI内,显示
if (avgX > 0 && avgX < 400 && avgY<400 && avgY>0){
pt3.x = bndRect.x;
pt3.y = bndRect.y;
pt4.x = bndRect.x + bndRect.width;
pt4.y = bndRect.y + bndRect.height;
//去除较小的干扰矩阵
if (bndRect.height>35 && 600<(bndRect.width*bndRect.height)<10000)
{
cvRectangle(pFrame, pt3, pt4, CV_RGB(255, 0, 0), 1, 8, 0);
}
}
}//查找边界for结束
//更新背景//////////////////////
//输入图像或序列-用于累加的图像或序列-移动平均时第一个空image所占的权重-操作符掩码
cvRunningAvg(pFrameMat, pBkMat,0.06, 0);//将pFrameMat累加到pBkMat
//将背景转换成图像格式,用以显示
cvConvert(pBkMat, pBkImg);
//显示图像///////////////////////
cvShowImage("video", pFrame);
cvShowImage("foreground", pFrImg);
cvShowImage("background", pBkImg);
//如果有按键操作,则等待
if (cvWaitKey(2) >= 0)
break;
}
waitKey(50);
}//while循环结束
//删除结构元素
cvReleaseStructuringElement(&Element);
//销毁窗口
cvReleaseMat(&pBkMat);
cvDestroyWindow("video");
cvDestroyWindow("background");
cvDestroyWindow("foreground");
//释放图像和矩阵
cvReleaseImage(&pFrImg);
cvReleaseImage(&pBkImg);
cvReleaseMat(&pFrameMat);
cvReleaseMat(&pFrMat);
}
|
f7ea5623dbc534fe696a7d5f4f1c0e4a4620a800
|
a0dc9204e8eea4e0c429038921cd7f7e69b9e3a9
|
/SlaveReciever/SlaveReciever.ino
|
54b1b7116eb94d188885746e28d60161f0172c8c
|
[] |
no_license
|
LZbuilder/Sdcardthing
|
8b4d44f6f4441a1442aed62c752507ad2c1d2a89
|
00f0f119c0015338e9b250767abcd48474c848d2
|
refs/heads/master
| 2023-08-29T02:52:40.127569
| 2021-10-27T03:31:25
| 2021-10-27T03:31:25
| 302,112,866
| 1
| 0
| null | 2020-12-08T18:50:49
| 2020-10-07T17:36:02
|
C++
|
UTF-8
|
C++
| false
| false
| 3,803
|
ino
|
SlaveReciever.ino
|
#include <Wire.h>
int lukaval = 1;
boolean doingcode = false;
double xval = 0;
double yval = 0;
String x = "";
String y = "";
/*Alexanders Values */
#include <Stepper.h>
#include <Servo.h>
Servo servoy;
int Bedheight = 60; //the height of the centerpoint of the rotating on the Y servo from the print bed
double xValue = 20; // the numbers followed after G1 (example G1 X___ Y)
double yValue = 20; // the numbers followed after G1 X (example G1 X Y___)
int time = 1;
// ↑ varibles used by evreything
int stepsPerRevolution = 2038;
double stepperNewdeg = 0;
double stepperCalculateddeg = 0;
double stepperPreviousdeg = 0;
double stepperCurrentpos = 0;
// ↑ varibles used by the stepper motors
double servoNewsdeg = 0; // the new degree for the servo,formaly called yD
double servoCalculateddeg = 0;
double servoPreviousdeg = 0;
double servoCurrentpos = 0;
// ↑ varibles used by the spinnig servomotor
Stepper Stepper1(stepsPerRevolution, 7, 5, 6, 8);
void setup()
{
Wire.begin(4); // join i2c bus with address #4
Wire.onReceive(receiveEvent); // register event
Serial.begin(9600);
/* Alexanders setup code */
delay(100);
Serial.println("Slave Ready To Print!!!");
Stepper1.setSpeed(5); //rpms
servoy.attach(9);
servoy.write(0);
servoCurrentpos = 0;
}
void loop() {}
void receiveEvent(int howmany)
{
Serial.println("Recieved");
int integer = Wire.read();
if (lukaval == 1)
{
x = integer;
x += ".";
lukaval = 2;
}
else if (lukaval == 2)
{
x += integer;
xval = x.toDouble();
lukaval = 3;
String x = "";
Serial.println("X");
Serial.println(xval);
}
else if (lukaval == 3)
{
y = integer;
y += ".";
lukaval = 4;
}
else if (lukaval == 4)
{
y += integer;
yval = y.toDouble();
lukaval = 1;
String y = "";
Serial.println("Y New Degree");
//Serial.println(yval);
xValue = xval;
yValue = yval;
//Alexanders Code...
double stepperNewdeg = ((atan(xValue / yValue) * 180 / 3.14159265) + 0); // caclulate how much the stepper neews t move
double servoNewdeg = (atan(Bedheight / yValue) * 180 / 3.14159265); // caclulate how much the servo needs to move
stepperCalculateddeg = stepperNewdeg - stepperPreviousdeg; // how far the stepper needs to move in degrees
servoCalculateddeg = servoNewdeg - servoPreviousdeg;
Serial.println(servoNewdeg);
// their are four possibilitys,
//the stepper rotates clockwise and the servo rotates counterclockwise stepperCalculateddeg>0 & servoCalculateddeg<servoPreviousdeg
//the stepper rotates clockwise and the servo rotates clockwise stepperCalculateddeg>0 & servoCalculateddeg>servoPreviousdeg
//the stepper rotates counterclockwise and the servo rotates counterclockwise stepperCalculateddeg<0 & servoCalculateddeg<servoPreviousdeg
//the stepper rotates counterclockwise and the servo rotates clockwise stepperCalculateddeg<0 & servoCalculateddeg>servoPreviousdeg
if (stepperCalculateddeg > 0 && servoCalculateddeg > servoPreviousdeg)
{ // the calculated value for the stepper is more than 0 go forwards,the calculated value for the stepper is more than the last value make the angle more
Serial.println("stepper moving counter clock wise");
Serial.println("degree of the servo should eb getting higher");
// speed = distance/time
// do the formula so the stepper arrives to stepperCalculateddeg the same time the servo arrives to servoCalculateddeg
}
servoy.write(servoNewdeg);
stepperPreviousdeg = stepperNewdeg; // sets the steppers previous degre to the last degre used
servoPreviousdeg = servoNewdeg; // does the same but for the servo
}
}
|
66d0a74dbcf42ff2d60724fce2c022379079535d
|
dc2a81c665f7a79a10760b4bbde6d98d48c0bcbe
|
/3rdparty/imgui/include/imgui/imgui_style_editor.cpp
|
d857c2b5eeb6e7d570454fc07d96505646e0c02e
|
[
"MIT",
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] |
permissive
|
clman94/Wolf-Gang-Engine
|
14b219b9518f6a14317ebcff4e7516de29504b9b
|
52fa71d6be1fb940a0998f29b4e0ce631e624b25
|
refs/heads/master
| 2021-07-23T20:57:44.552521
| 2021-02-11T20:15:50
| 2021-02-11T20:15:50
| 68,487,653
| 5
| 2
| null | 2017-05-21T00:33:37
| 2016-09-18T01:29:31
|
C++
|
UTF-8
|
C++
| false
| false
| 2,097
|
cpp
|
imgui_style_editor.cpp
|
#include "imgui.h"
#include <cmath>
// Play it nice with Windows users. Notepad in 2017 still doesn't display text data with Unix-style \n.
#ifdef _WIN32
#define IM_NEWLINE "\r\n"
#else
#define IM_NEWLINE "\n"
#endif
// Helper to display a little (?) mark which shows a tooltip when hovered.
static void ShowHelpMarker(const char* desc)
{
ImGui::TextDisabled("(?)");
if (ImGui::IsItemHovered())
{
ImGui::BeginTooltip();
ImGui::PushTextWrapPos(ImGui::GetFontSize() * 35.0f);
ImGui::TextUnformatted(desc);
ImGui::PopTextWrapPos();
ImGui::EndTooltip();
}
}
// Demo helper function to select among default colors. See ShowStyleEditor() for more advanced options.
// Here we use the simplified Combo() api that packs items into a single literal string. Useful for quick combo boxes where the choices are known locally.
bool ImGui::ShowStyleSelector(const char* label)
{
static int style_idx = -1;
if (ImGui::Combo(label, &style_idx, "Classic\0Dark\0Light\0"))
{
switch (style_idx)
{
case 0: ImGui::StyleColorsClassic(); break;
case 1: ImGui::StyleColorsDark(); break;
case 2: ImGui::StyleColorsLight(); break;
}
return true;
}
return false;
}
// Demo helper function to select among loaded fonts.
// Here we use the regular BeginCombo()/EndCombo() api which is more the more flexible one.
void ImGui::ShowFontSelector(const char* label)
{
ImGuiIO& io = ImGui::GetIO();
ImFont* font_current = ImGui::GetFont();
if (ImGui::BeginCombo(label, font_current->GetDebugName()))
{
for (int n = 0; n < io.Fonts->Fonts.Size; n++)
if (ImGui::Selectable(io.Fonts->Fonts[n]->GetDebugName(), io.Fonts->Fonts[n] == font_current))
io.FontDefault = io.Fonts->Fonts[n];
ImGui::EndCombo();
}
ImGui::SameLine();
ShowHelpMarker(
"- Load additional fonts with io.Fonts->AddFontFromFileTTF().\n"
"- The font atlas is built when calling io.Fonts->GetTexDataAsXXXX() or io.Fonts->Build().\n"
"- Read FAQ and documentation in misc/fonts/ for more details.\n"
"- If you need to add/remove fonts at runtime (e.g. for DPI change), do it before calling NewFrame().");
}
|
fccde1309f2e77102633fb7f034ad3e383521853
|
bd5d9fd33a613f9fe3e82fee83e91fc3fc957457
|
/Codeforces/CF-A/CF282A/main.cpp
|
d1ab019919a146a5d537e7a0a96d5b7a4c1f3a6b
|
[] |
no_license
|
hazemessamm/Competitive-Programming
|
6d206d16d1543382433f4376186b1a6c71aa7a70
|
4c11b94fa9bf24e80c7b59e15b0316553d94e49d
|
refs/heads/master
| 2023-06-23T20:19:58.466893
| 2021-07-22T18:23:43
| 2021-07-22T18:23:43
| 118,745,329
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 554
|
cpp
|
main.cpp
|
#include <iostream>
using namespace std;
int main()
{
int n=0;
cin>>n;
int x=0;
string operation;
for(int i = 0; i < n; i++)
{
cin>>operation;
if(operation == "++X")
{
++x;
}
else if(operation == "X++")
{
x++;
}
else if(operation == "X--")
{
x--;
}
else if(operation == "--X")
{
--x;
}
else
{
continue;
}
}
cout<<x;
return 0;
}
|
d0234f6702982fc1e442cc834aead041923fb307
|
83d3a568acf7f7fcbf58b57826e2ca1f4bac48fa
|
/AI/Checkers/checkers.cpp
|
2bf44e1e94026f88212af16d9e09455f3c0daf4d
|
[] |
no_license
|
FrederickPullen/USC_Projects
|
1582bf762bc9492b89021a0276c8c8c0967a42a3
|
54efd97d0ff8c1abc85e0cc5b90619f44fbc8828
|
refs/heads/master
| 2018-04-22T01:35:09.825180
| 2017-05-12T16:14:04
| 2017-05-12T16:14:04
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 47,837
|
cpp
|
checkers.cpp
|
#include <string>
#include <fstream>
#include <iostream>
#include <math.h>
#include <vector>
using namespace std;
int max_val(vector<vector<char> >,int,int,int);
//Global Declarations
int cno=0,m_depth=0,posval=0;
char max_depth;
bool king = false;
bool is_mandatory= false,prune=false;
int count=0;
struct states
{
char s_piece[8][8];
}state_no[100][100],state_no1[100][100];
struct currentBconfig
{
char c_piece[8][8];
}c_state[100];
struct position
{
int alpha;
int posi1[100],posj1[100],posi2[100],posj2[100];
int mover[100];
}positions[100];
vector< vector<vector<char> > > getBlackActions(vector<vector<char> > piece)
{
vector< vector<vector<char> > > statesArray;
statesArray.resize(1);
statesArray[0].resize(9);
for(int j=1;j<9;++j)
statesArray[0][j].resize(9);
int j=0,white_coins=0,h=0,stateCount=0;
is_mandatory = false;
// cout << "Black Moves :";
for(int j=1; j<9 ;j++)
{
for(int i=1; i<9; i++)
{
king = false;
//Determine Moves for a Black King-----------------------------
if(piece[j][i] == 'k')
{
//King jumps up towards left
if(j>2 && i>2 && piece[j-1][i-1] == '*')
{
if(j>2 && i>2 && piece[j-2][i-2] == '.')
{
is_mandatory = true;
//cout << "King Got a Jump!! From" << j << "," << i << "to" << j-2 << "," << i-2 << "\n" ;
for(int j1=1; j1<9 ;j1++)
{
for(int i1=1; i1<9; i1++)
{
statesArray[stateCount][j1][i1]= piece[j1][i1];
}
}
statesArray[stateCount][j-2][i-2] = 'k';
statesArray[stateCount][j-1][i-1] = '.';
statesArray[stateCount][j][i]='.';
stateCount++;
statesArray.resize(stateCount+1);
statesArray[stateCount].resize(9);
for(int j=1;j<9;++j)
statesArray[stateCount][j].resize(9);
}
}
//Kings jumps forward towards right
if(j>2 && i<7 && piece[j-1][i+1] == '*')
{
if(j>2 && i<7 && piece[j-2][i+2] == '.')
{
is_mandatory = true;
//cout << "King Got a Jump!! From" << j << "," << i << "to" << j-2 << "," << i+2 << "\n" ;
for(int j1=1; j1<9 ;j1++)
{
for(int i1=1; i1<9; i1++)
{
statesArray[stateCount][j1][i1] = piece[j1][i1];
}
}
statesArray[stateCount][j-2][i+2] = 'k';
statesArray[stateCount][j-1][i+1] = '.';
statesArray[stateCount][j][i]='.';
stateCount++;
statesArray.resize(stateCount+1);
statesArray[stateCount].resize(9);
for(int j=1;j<9;++j)
statesArray[stateCount][j].resize(9);
}
}
//King jumps Backward towards left
if(j<7 && i>2 && piece[j+1][i-1] == '*')
{
if(j<7 && i>2 && piece[j+2][i-2] == '.')
{
is_mandatory = true;
//cout << "King Got a Jump!! From" << j << "," << i << "to" << j+2 << "," << i-2 << "\n" ;
for(int j1=1; j1<9 ;j1++)
{
for(int i1=1; i1<9; i1++)
{
statesArray[stateCount][j1][i1]= piece[j1][i1];
}
}
statesArray[stateCount][j+2][i-2] = 'k';
statesArray[stateCount][j+1][i-1] = '.';
statesArray[stateCount][j][i]='.';
stateCount++;
statesArray.resize(stateCount+1);
statesArray[stateCount].resize(9);
for(int j=1;j<9;++j)
statesArray[stateCount][j].resize(9);
}
}
//King Jumps Backward towards right
if(j<7 && i<7 && piece[j+1][i+1] == '*')
{
if(j<7 && j<7 && piece[j+2][i+2] == '.')
{
is_mandatory = true;
//cout << "King Got a Jump!! From" << j << "," << i << "to" << j+2 << "," << i+2 << "\n" ;
for(int j1=1; j1<9 ;j1++)
{
for(int i1=1; i1<9; i1++)
{
statesArray[stateCount][j1][i1] = piece[j1][i1];
}
}
statesArray[stateCount][j+2][i+2] = 'k';
statesArray[stateCount][j+1][i+1] = '.';
statesArray[stateCount][j][i]='.';
stateCount++;
statesArray.resize(stateCount+1);
statesArray[stateCount].resize(9);
for(int j=1;j<9;++j)
statesArray[stateCount][j].resize(9);
}
}
if(j>2 && i>2 && piece[j-1][i-1] == 'K')
{
if(j>2 && i>2 && piece[j-2][i-2] == '.')
{
is_mandatory = true;
//cout << "King Got a Jump!! From" << j << "," << i << "to" << j-2 << "," << i-2 << "\n" ;
for(int j1=1; j1<9 ;j1++)
{
for(int i1=1; i1<9; i1++)
{
statesArray[stateCount][j1][i1]= piece[j1][i1];
}
}
statesArray[stateCount][j-2][i-2] = 'k';
statesArray[stateCount][j-1][i-1] = '.';
statesArray[stateCount][j][i]='.';
stateCount++;
statesArray.resize(stateCount+1);
statesArray[stateCount].resize(9);
for(int j=1;j<9;++j)
statesArray[stateCount][j].resize(9);
}
}
//Kings jumps forward towards right
if(j>2 && i<7 && piece[j-1][i+1] == 'K')
{
if(j>2 && i<7 && piece[j-2][i+2] == '.')
{
is_mandatory = true;
//cout << "King Got a Jump!! From" << j << "," << i << "to" << j-2 << "," << i+2 << "\n" ;
for(int j1=1; j1<9 ;j1++)
{
for(int i1=1; i1<9; i1++)
{
statesArray[stateCount][j1][i1] = piece[j1][i1];
}
}
statesArray[stateCount][j-2][i+2] = 'k';
statesArray[stateCount][j-1][i+1] = '.';
statesArray[stateCount][j][i]='.';
stateCount++;
statesArray.resize(stateCount+1);
statesArray[stateCount].resize(9);
for(int j=1;j<9;++j)
statesArray[stateCount][j].resize(9);
}
}
//King jumps Backward towards left
if(j<7 && i>2 && piece[j+1][i-1] == 'K')
{
if(j<7 && i>2 && piece[j+2][i-2] == '.')
{
is_mandatory = true;
//cout << "King Got a Jump!! From" << j << "," << i << "to" << j+2 << "," << i-2 << "\n" ;
for(int j1=1; j1<9 ;j1++)
{
for(int i1=1; i1<9; i1++)
{
statesArray[stateCount][j1][i1]= piece[j1][i1];
}
}
statesArray[stateCount][j+2][i-2] = 'k';
statesArray[stateCount][j+1][i-1] = '.';
statesArray[stateCount][j][i]='.';
stateCount++;
statesArray.resize(stateCount+1);
statesArray[stateCount].resize(9);
for(int j=1;j<9;++j)
statesArray[stateCount][j].resize(9);
}
}
//King Jumps Backward towards right
if(j<7 && i<7 && piece[j+1][i+1] == 'K')
{
if(j<7 && j<7 && piece[j+2][i+2] == '.')
{
is_mandatory = true;
//cout << "King Got a Jump!! From" << j << "," << i << "to" << j+2 << "," << i+2 << "\n" ;
for(int j1=1; j1<9 ;j1++)
{
for(int i1=1; i1<9; i1++)
{
statesArray[stateCount][j1][i1] = piece[j1][i1];
}
}
statesArray[stateCount][j+2][i+2] = 'k';
statesArray[stateCount][j+1][i+1] = '.';
statesArray[stateCount][j][i]='.';
stateCount++;
statesArray.resize(stateCount+1);
statesArray[stateCount].resize(9);
for(int j=1;j<9;++j)
statesArray[stateCount][j].resize(9);
}
}
}
if(piece[j][i] == 'o')
{
//Determine available no of jumps for a given piece------------------------
if(j>2 && i>2 && piece[j-1][i-1] == 'K')
{
if(j>2 && i>2 && piece[j-2][i-2] == '.')
{
is_mandatory = true;
//cout << "I Got a Jump!! From" << j << "," << i << "to" << j-2 << "," << i-2 << "\n" ;
for(int j1=1; j1<9 ;j1++)
{
for(int i1=1; i1<9; i1++)
{
statesArray[stateCount][j1][i1] = piece[j1][i1];
}
}
if(j-2 == 1)
{
king = true;
}
if(king)
{
statesArray[stateCount][j-2][i-2] = 'k';
statesArray[stateCount][j-1][i-1] = '.';
statesArray[stateCount][j][i]='.';
}
else
{
statesArray[stateCount][j-2][i-2] = 'o';
statesArray[stateCount][j-1][i-1] = '.';
statesArray[stateCount][j][i]='.';
}
stateCount++;
statesArray.resize(stateCount+1);
statesArray[stateCount].resize(9);
for(int j=1;j<9;++j)
statesArray[stateCount][j].resize(9);
}//if31
}
if(j>2 && i<7 && piece[j-1][i+1] == 'K')
{
if(j>2 && i<7 && piece[j-2][i+2] == '.')
{
is_mandatory = true;
//cout << "I Got a Jump!! From" << j << "," << i << "to" << j-2 << "," << i+2 << "\n" ;
for(int j1=1; j1<9 ;j1++)
{
for(int i1=1; i1<9; i1++)
{
statesArray[stateCount][j1][i1]= piece[j1][i1];
}
}
if(j-2 == 1)
{
king = true;
}
if(king)
{
statesArray[stateCount][j-2][i+2] = 'k';
statesArray[stateCount][j-1][i+1] = '.';
statesArray[stateCount][j][i]='.';
}
else
{
statesArray[stateCount][j-2][i+2] = 'o';
statesArray[stateCount][j-1][i+1] = '.';
statesArray[stateCount][j][i]='.';
}
stateCount++;
statesArray.resize(stateCount+1);
statesArray[stateCount].resize(9);
for(int j=0;j<8;++j)
statesArray[stateCount][j].resize(9);
}//if33
}
if(j>2 && i>2 && piece[j-1][i-1] == '*')
{
if(j>2 && i>2 && piece[j-2][i-2] == '.')
{
is_mandatory = true;
//cout << "I Got a Jump!! From" << j << "," << i << "to" << j-2 << "," << i-2 << "\n" ;
for(int j1=1; j1<9 ;j1++)
{
for(int i1=1; i1<9; i1++)
{
statesArray[stateCount][j1][i1] = piece[j1][i1];
}
}
if(j-2 == 1)
{
king = true;
}
if(king)
{
statesArray[stateCount][j-2][i-2] = 'k';
statesArray[stateCount][j-1][i-1] = '.';
statesArray[stateCount][j][i]='.';
}
else
{
statesArray[stateCount][j-2][i-2] = 'o';
statesArray[stateCount][j-1][i-1] = '.';
statesArray[stateCount][j][i]='.';
}
stateCount++;
statesArray.resize(stateCount+1);
statesArray[stateCount].resize(9);
for(int j=1;j<9;++j)
statesArray[stateCount][j].resize(9);
}//if31
}//if21
if(j>2 && i<7 && piece[j-1][i+1] == '*')
{
if(j>2 && i<7 && piece[j-2][i+2] == '.')
{
is_mandatory = true;
//cout << "I Got a Jump!! From" << j << "," << i << "to" << j-2 << "," << i+2 << "\n" ;
for(int j1=1; j1<9 ;j1++)
{
for(int i1=1; i1<9; i1++)
{
statesArray[stateCount][j1][i1]= piece[j1][i1];
}
}
if(j-2 == 1)
{
king = true;
}
if(king)
{
statesArray[stateCount][j-2][i+2] = 'k';
statesArray[stateCount][j-1][i+1] = '.';
statesArray[stateCount][j][i]='.';
}
else
{
statesArray[stateCount][j-2][i+2] = 'o';
statesArray[stateCount][j-1][i+1] = '.';
statesArray[stateCount][j][i]='.';
}
stateCount++;
statesArray.resize(stateCount+1);
statesArray[stateCount].resize(9);
for(int j=1;j<9;++j)
statesArray[stateCount][j].resize(9);
}//if33
}//if22
//Determine Moves -Provided there are no jumps for a given piece------------------
}//if1
}//end of for 2
}//end of for 1
if(!is_mandatory)
{
for(int j=1; j<9 ;j++)
{
for(int i=1; i<9; i++)
{
if(piece[j][i] == 'k')
{
if(j>1 && i>1 && piece[j-1][i-1] == '.')
{
//cout << "King Got a Move!! From" << j << "," << i << "to" << j-1 << "," << i-1 << "\n" ;
for(int j1=1; j1<9 ;j1++)
{
for(int i1=1; i1<9; i1++)
{
statesArray[stateCount][j1][i1] = piece[j1][i1];
}
}
statesArray[stateCount][j-1][i-1] = 'k';
statesArray[stateCount][j][i] = '.';
stateCount++;
statesArray.resize(stateCount+1);
statesArray[stateCount].resize(9);
for(int j=1;j<9;++j)
statesArray[stateCount][j].resize(9);
}
if(j>1 && i<8 && piece[j-1][i+1] == '.')
{
//cout << "King Got a Move!! From" << j << "," << i << "to" << j-1 << "," << i+1 << "\n" ;
for(int j1=1; j1<9 ;j1++)
{
for(int i1=1; i1<9; i1++)
{
statesArray[stateCount][j1][i1] = piece[j1][i1];
}
}
statesArray[stateCount][j-1][i+1] = 'k';
statesArray[stateCount][j][i] = '.';
stateCount++;
statesArray.resize(stateCount+1);
statesArray[stateCount].resize(9);
for(int j=1;j<9;++j)
statesArray[stateCount][j].resize(9);
}
if(j<8 && i>1 && piece[j+1][i-1] == '.')
{
//cout << "King Got a Move!! From" << j << "," << i << "to" << j+1 << "," << i-1 << "\n" ;
for(int j1=1; j1<9 ;j1++)
{
for(int i1=1; i1<9; i1++)
{
statesArray[stateCount][j1][i1] = piece[j1][i1];
}
}
statesArray[stateCount][j+1][i-1] = 'k';
statesArray[stateCount][j][i] = '.';
stateCount++;
statesArray.resize(stateCount+1);
statesArray[stateCount].resize(9);
for(int j=1;j<9;++j)
statesArray[stateCount][j].resize(9);
}
if(j<8 && i<8 && piece[j+1][i+1] == '.')
{
//cout << "King Got a Move!! From" << j << "," << i << "to" << j+1 << "," << i+1 << "\n" ;
for(int j1=1; j1<9 ;j1++)
{
for(int i1=1; i1<9; i1++)
{
statesArray[stateCount][j1][i1] = piece[j1][i1];
}
}
statesArray[stateCount][j+1][i+1] = 'k';
statesArray[stateCount][j][i] = '.';
stateCount++;
statesArray.resize(stateCount+1);
statesArray[stateCount].resize(9);
for(int j=1;j<9;++j)
statesArray[stateCount][j].resize(9);
}
}
if(piece[j][i] == 'o')
{
if(j>1 && i>1 && piece[j-1][i-1] == '.')
{
//cout << "I Got a Move!! From" << j << "," << i << "to" << j-1 << "," << i-1 << "\n" ;
for(int j1=1; j1<9 ;j1++)
{
for(int i1=1; i1<9; i1++)
{
statesArray[stateCount][j1][i1] = piece[j1][i1];
}
}
if(j-1 == 1)
{
king = true;
}
if(king)
{
statesArray[stateCount][j-1][i-1] = 'k';
statesArray[stateCount][j][i] = '.';
}
else
{
statesArray[stateCount][j-1][i-1] = 'o';
statesArray[stateCount][j][i] = '.';
}
stateCount++;
statesArray.resize(stateCount+1);
statesArray[stateCount].resize(9);
for(int j=1;j<9;++j)
statesArray[stateCount][j].resize(9);
}
if(j>1 && i<8 && piece[j-1][i+1] == '.')
{
//cout << "I Got a Move!! From" << j << "," << i << "to" << j-1 << "," << i+1 << "\n" ;
for(int j1=1; j1<9 ;j1++)
{
for(int i1=1; i1<9; i1++)
{
statesArray[stateCount][j1][i1] = piece[j1][i1];
}
}
if(j-1 == 1)
{
king = true;
}
if(king)
{
statesArray[stateCount][j-1][i+1] = 'k';
statesArray[stateCount][j][i] = '.';
}
else
{
statesArray[stateCount][j-1][i+1] = 'o';
statesArray[stateCount][j][i] = '.';
}
stateCount++;
statesArray.resize(stateCount+1);
statesArray[stateCount].resize(9);
for(int j=1;j<9;++j)
statesArray[stateCount][j].resize(9);
}
}
}
}
}
//return statesArray[stateCount][8][8];
/* cout << "State Count :" << stateCount << "\n";
int no = stateCount;
while(no>=0)
{
cout << "State : " << no << "\n";
for(int i=0;i<8;i++)
{
for(int a=0;a<8;a++)
{
cout <<statesArray[no][i][a] ;
}
cout << "\n";
}
no--;
} */
return statesArray;
}
vector< vector<vector<char> > > getWhiteActions(vector<vector<char> > piece)
{
vector< vector<vector<char> > > statesArray;
statesArray.resize(1);
statesArray[0].resize(9);
for(int j=1;j<9;++j)
statesArray[0][j].resize(9);
int j=0,white_coins=0,h=0,stateCount=0;
is_mandatory = false;
//Find No Of White Pieces
for(int j=1; j<9 ;j++)
{
for(int i=1; i<9; i++)
{
king=false;
//Determine Moves for a White King-----------------------------
if(piece[j][i] == 'K')
{
//Forward Jumps
if(j<7 && i>2 && piece[j+1][i-1] == 'o')
{
if(j<7 && i>2 && piece[j+2][i-2] == '.')
{
is_mandatory = true;
//cout << "King Got a Jump!! From" << j << "," << i << "to" << j+2 << "," << i-2 << "\n" ;
for(int j1=1; j1<9 ;j1++)
{
for(int i1=1; i1<9; i1++)
{
statesArray[stateCount][j1][i1] = piece[j1][i1];
}
}
statesArray[stateCount][j+2][i-2] = 'K';
statesArray[stateCount][j+1][i-1] = '.';
statesArray[stateCount][j][i]='.';
stateCount++;
statesArray.resize(stateCount+1);
statesArray[stateCount].resize(9);
for(int j=1;j<9;++j)
statesArray[stateCount][j].resize(9);
}
}
if(j<7 && i>2 && piece[j+1][i+1] == 'o')
{
if(j<7 && i<7 && piece[j+2][i+2] == '.')
{
is_mandatory = true;
// cout << "King Got a Jump!! From" << j << "," << i << "to" << j+2 << "," << i+2 << "\n" ;
for(int j1=1; j1<9 ;j1++)
{
for(int i1=1; i1<9; i1++)
{
statesArray[stateCount][j1][i1] = piece[j1][i1];
}
}
statesArray[stateCount][j+2][i+2] = 'K';
statesArray[stateCount][j+1][i+1] = '.';
statesArray[stateCount][j][i]='.';
stateCount++;
statesArray.resize(stateCount+1);
statesArray[stateCount].resize(9);
for(int j=1;j<9;++j)
statesArray[stateCount][j].resize(9);
}
}
if(i<7 && j>2 && piece[j-1][i+1] == 'o')
{
//Backward Jumps
if(i<7 && j>2 && piece[j-2][i+2] == '.')
{
is_mandatory = true;
//cout << "King Got a Jump!! From" << j << "," << i << "to" << j-2 << "," << i+2 << "\n" ;
for(int j1=1; j1<9 ;j1++)
{
for(int i1=1; i1<9; i1++)
{
statesArray[stateCount][j1][i1] = piece[j1][i1];
}
}
statesArray[stateCount][j-2][i+2] = 'K';
statesArray[stateCount][j-1][i+1] = '.';
statesArray[stateCount][j][i]='.';
stateCount++;
statesArray.resize(stateCount+1);
statesArray[stateCount].resize(9);
for(int j=1;j<9;++j)
statesArray[stateCount][j].resize(9);
}
}
if(j>2 && i>2 && piece[j-1][i-1] == 'o')
{
if(j>2 && i>2 && piece[j-2][i-2] == '.')
{
is_mandatory = true;
//cout << "King Got a Jump!! From" << j << "," << i << "to" << j-2 << "," << i-2 << "\n" ;
for(int j1=1; j1<9 ;j1++)
{
for(int i1=1; i1<9; i1++)
{
statesArray[stateCount][j1][i1] = piece[j1][i1];
}
}
statesArray[stateCount][j-2][i-2] = 'K';
statesArray[stateCount][j-1][i-1] = '.';
statesArray[stateCount][j][i]='.';
stateCount++;
statesArray.resize(stateCount+1);
statesArray[stateCount].resize(9);
for(int j=1;j<9;++j)
statesArray[stateCount][j].resize(9);
}
}
//Forward Jumps
if(j<7 && i>2 && piece[j+1][i-1] == 'k')
{
if(j<7 && i>2 && piece[j+2][i-2] == '.')
{
is_mandatory = true;
//cout << "King Got a Jump!! From" << j << "," << i << "to" << j+2 << "," << i-2 << "\n" ;
for(int j1=1; j1<9 ;j1++)
{
for(int i1=1; i1<9; i1++)
{
statesArray[stateCount][j1][i1] = piece[j1][i1];
}
}
statesArray[stateCount][j+2][i-2] = 'K';
statesArray[stateCount][j+1][i-1] = '.';
statesArray[stateCount][j][i]='.';
stateCount++;
statesArray.resize(stateCount+1);
statesArray[stateCount].resize(9);
for(int j=1;j<9;++j)
statesArray[stateCount][j].resize(9);
}
}
if(j<7 && i>2 && piece[j+1][i+1] == 'k')
{
if(j<7 && i<7 && piece[j+2][i+2] == '.')
{
is_mandatory = true;
//cout << "King Got a Jump!! From" << j << "," << i << "to" << j+2 << "," << i+2 << "\n" ;
for(int j1=1; j1<9 ;j1++)
{
for(int i1=1; i1<9; i1++)
{
statesArray[stateCount][j1][i1] = piece[j1][i1];
}
}
statesArray[stateCount][j+2][i+2] = 'K';
statesArray[stateCount][j+1][i+1] = '.';
statesArray[stateCount][j][i]='.';
stateCount++;
statesArray.resize(stateCount+1);
statesArray[stateCount].resize(9);
for(int j=1;j<9;++j)
statesArray[stateCount][j].resize(9);
}
}
if(i<7 && j>2 && piece[j-1][i+1] == 'k')
{
//Backward Jumps
if(i<7 && j>2 && piece[j-2][i+2] == '.')
{
is_mandatory = true;
//cout << "King Got a Jump!! From" << j << "," << i << "to" << j-2 << "," << i+2 << "\n" ;
for(int j1=1; j1<9 ;j1++)
{
for(int i1=1; i1<9; i1++)
{
statesArray[stateCount][j1][i1] = piece[j1][i1];
}
}
statesArray[stateCount][j-2][i+2] = 'K';
statesArray[stateCount][j-1][i+1] = '.';
statesArray[stateCount][j][i]='.';
stateCount++;
statesArray.resize(stateCount+1);
statesArray[stateCount].resize(9);
for(int j=1;j<9;++j)
statesArray[stateCount][j].resize(9);
}
}
if(j>2 && i>2 && piece[j-1][i-1] == 'k')
{
if(j>2 && i>2 && piece[j-2][i-2] == '.')
{
is_mandatory = true;
//cout << "King Got a Jump!! From" << j << "," << i << "to" << j-2 << "," << i-2 << "\n" ;
for(int j1=1; j1<9 ;j1++)
{
for(int i1=1; i1<9; i1++)
{
statesArray[stateCount][j1][i1] = piece[j1][i1];
}
}
statesArray[stateCount][j-2][i-2] = 'K';
statesArray[stateCount][j-1][i-1] = '.';
statesArray[stateCount][j][i]='.';
stateCount++;
statesArray.resize(stateCount+1);
statesArray[stateCount].resize(9);
for(int j=1;j<9;++j)
statesArray[stateCount][j].resize(9);
}
}
}
if(piece[j][i] == '*')
{
//Determine available no of jumps for a given piece------------------------
if(j<7 && i>2 && piece[j+1][i-1] == 'k')
{
if(j<7 && i>2 && piece[j+2][i-2] == '.')
{
is_mandatory = true;
//cout << "I Got a Jump!! From" << j << "," << i << "to" << j+2 << "," << i-2 << "\n" ;
for(int j1=1; j1<9 ;j1++)
{
for(int i1=1; i1<9; i1++)
{
statesArray[stateCount][j1][i1] = piece[j1][i1];
}
}
if(j+2 == 8)
{
king = true;
}
if(king)
{
statesArray[stateCount][j+2][i-2] = 'K';
statesArray[stateCount][j+1][i-1] = '.';
statesArray[stateCount][j][i]='.';
}
else
{
statesArray[stateCount][j+2][i-2] = '*';
statesArray[stateCount][j+1][i-1] = '.';
statesArray[stateCount][j][i]='.';
}
stateCount++;
statesArray.resize(stateCount+1);
statesArray[stateCount].resize(9);
for(int j=1;j<9;++j)
statesArray[stateCount][j].resize(9);
}//if31
}//if21
if(j<7 && i>2 && piece[j+1][i-1] == 'o')
{
if(j<7 && i>2 && piece[j+2][i-2] == '.')
{
is_mandatory = true;
//cout << "I Got a Jump!! From" << j << "," << i << "to" << j+2 << "," << i-2 << "\n" ;
for(int j1=1; j1<9 ;j1++)
{
for(int i1=1; i1<9; i1++)
{
statesArray[stateCount][j1][i1] = piece[j1][i1];
}
}
if(j+2 == 8)
{
king = true;
}
if(king)
{
statesArray[stateCount][j+2][i-2] = 'K';
statesArray[stateCount][j+1][i-1] = '.';
statesArray[stateCount][j][i]='.';
}
else
{
statesArray[stateCount][j+2][i-2] = '*';
statesArray[stateCount][j+1][i-1] = '.';
statesArray[stateCount][j][i]='.';
}
stateCount++;
statesArray.resize(stateCount+1);
statesArray[stateCount].resize(9);
for(int j=1;j<9;++j)
statesArray[stateCount][j].resize(9);
}//if31
}//if21
if(j<7 && i<7 && piece[j+1][i+1] == 'k')
{
if(j<7 && i<7 && piece[j+2][i+2] == '.')
{
is_mandatory = true;
//cout << "I Got a Jump!! From" << j << "," << i << "to" << j+2 << "," << i+2 << "\n" ;
for(int j1=1; j1<9 ;j1++)
{
for(int i1=1; i1<9; i1++)
{
statesArray[stateCount][j1][i1] = piece[j1][i1];
}
}
if(j+2 == 8)
{
king = true;
}
if(king)
{
statesArray[stateCount][j+2][i+2] = 'K';
statesArray[stateCount][j+1][i+1] = '.';
statesArray[stateCount][j][i]='.';
}
else
{
statesArray[stateCount][j+2][i+2] = '*';
statesArray[stateCount][j+1][i+1] = '.';
statesArray[stateCount][j][i]='.';
}
stateCount++;
statesArray.resize(stateCount+1);
statesArray[stateCount].resize(9);
for(int j=1;j<9;++j)
statesArray[stateCount][j].resize(9);
}//if33
}
if(j<7 && i<7 && piece[j+1][i+1] == 'o')
{
if(j<7 && i<7 && piece[j+2][i+2] == '.')
{
is_mandatory = true;
//cout << "I Got a Jump!! From" << j << "," << i << "to" << j+2 << "," << i+2 << "\n" ;
for(int j1=1; j1<9 ;j1++)
{
for(int i1=1; i1<9; i1++)
{
statesArray[stateCount][j1][i1] = piece[j1][i1];
}
}
if(j+2 == 8)
{
king = true;
}
if(king)
{
statesArray[stateCount][j+2][i+2] = 'K';
statesArray[stateCount][j+1][i+1] = '.';
statesArray[stateCount][j][i]='.';
}
else
{
statesArray[stateCount][j+2][i+2] = '*';
statesArray[stateCount][j+1][i+1] = '.';
statesArray[stateCount][j][i]='.';
}
stateCount++;
statesArray.resize(stateCount+1);
statesArray[stateCount].resize(9);
for(int j=1;j<9;++j)
statesArray[stateCount][j].resize(9);
}//if33
}//if22
//Determine Moves -Provided there are no jumps for a given piece------------------
}//if1
}//end of for 2
}//end of for 1
if(!is_mandatory)
{
for(int j=1; j<9 ;j++)
{
for(int i=1; i<9; i++)
{
if(piece[j][i] == 'K')
{
if(j<8 && i>1 && piece[j+1][i-1] == '.')
{
//cout << "King Got a Move!! From" << j << "," << i << "to" << j+1 << "," << i-1 << "\n" ;
for(int j1=1; j1<9 ;j1++)
{
for(int i1=1; i1<9; i1++)
{
statesArray[stateCount][j1][i1] = piece[j1][i1];
}
}
statesArray[stateCount][j+1][i-1] = 'K';
statesArray[stateCount][j][i] = '.';
stateCount++;
statesArray.resize(stateCount+1);
statesArray[stateCount].resize(9);
for(int j=1;j<9;++j)
statesArray[stateCount][j].resize(9);
}
if(j<8 && i<8 && piece[j+1][i+1] == '.')
{
// cout << "King Got a Move!! From" << j << "," << i << "to" << j+1 << "," << i+1 << "\n" ;
for(int j1=1; j1<9 ;j1++)
{
for(int i1=1; i1<9; i1++)
{
statesArray[stateCount][j1][i1] = piece[j1][i1];
}
}
statesArray[stateCount][j+1][i+1] = 'K';
statesArray[stateCount][j][i] = '.';
stateCount++;
statesArray.resize(stateCount+1);
statesArray[stateCount].resize(9);
for(int j=1;j<9;++j)
statesArray[stateCount][j].resize(9);
}
if(j>1 && i>1 && piece[j-1][i-1] == '.')
{
//cout << "King Got a Move!! From" << j << "," << i << "to" << j-1 << "," << i-1 << "\n" ;
for(int j1=1; j1<9 ;j1++)
{
for(int i1=1; i1<9; i1++)
{
statesArray[stateCount][j1][i1] = piece[j1][i1];
}
}
statesArray[stateCount][j-1][i-1] = 'K';
statesArray[stateCount][j][i] = '.';
stateCount++;
statesArray.resize(stateCount+1);
statesArray[stateCount].resize(9);
for(int j=1;j<9;++j)
statesArray[stateCount][j].resize(9);
}
if(j>1 && i<8 && piece[j-1][i+1] == '.')
{
//cout << "King Got a Move!! From" << j << "," << i << "to" << j-1 << "," << i+1 << "\n" ;
for(int j1=1; j1<9 ;j1++)
{
for(int i1=1; i1<9; i1++)
{
statesArray[stateCount][j1][i1] = piece[j1][i1];
}
}
statesArray[stateCount][j-1][i+1] = 'K';
statesArray[stateCount][j][i] = '.';
stateCount++;
statesArray.resize(stateCount+1);
statesArray[stateCount].resize(9);
for(int j=1;j<9;++j)
statesArray[stateCount][j].resize(9);
}
}
if(piece[j][i] == '*')
{
if(j<8 && i>1 && piece[j+1][i-1] == '.')
{
//cout << "I Got a Move!! From" << j << "," << i << "to" << j+1 << "," << i-1 << "\n" ;
for(int j1=1; j1<9 ;j1++)
{
for(int i1=1; i1<9; i1++)
{
statesArray[stateCount][j1][i1] = piece[j1][i1];
}
}
if(j+1 == 8)
{
king = true;
}
if(king)
{
statesArray[stateCount][j+1][i-1] = 'K';
statesArray[stateCount][j][i] = '.';
}
else
{
statesArray[stateCount][j+1][i-1] = '*';
statesArray[stateCount][j][i] = '.';
}
stateCount++;
statesArray.resize(stateCount+1);
statesArray[stateCount].resize(9);
for(int j=1;j<9;++j)
statesArray[stateCount][j].resize(9);
}
if(j<8 && i<8 && piece[j+1][i+1] == '.')
{
//cout << "I Got a Move!! From" << j << "," << i << "to" << j+1 << "," << i+1 << "\n" ;
for(int j1=1; j1<9 ;j1++)
{
for(int i1=1; i1<9; i1++)
{
statesArray[stateCount][j1][i1] = piece[j1][i1];
}
}
if(j+1 == 8)
{
king = true;
}
if(king)
{
statesArray[stateCount][j+1][i+1] = 'K';
statesArray[stateCount][j][i] = '.';
}
else
{
statesArray[stateCount][j+1][i+1] = '*';
statesArray[stateCount][j][i] = '.';
}
stateCount++;
statesArray.resize(stateCount+1);
statesArray[stateCount].resize(9);
for(int j=1;j<9;++j)
statesArray[stateCount][j].resize(9);
}
}
}
}
}
/*cout << "StateCount : "<<stateCount;
int numStates=statesArray.size()-1;
cout<< "numStates :" << numStates;
for(int i=0;i<8;++i){
cout<<"\n";
for(int j=0;j<8;++j){
cout<<"\n";
for(int k=0;k<8;++k){
cout<<statesArray[i][j][k]<<" ";
}
}
}
cout << "Exit White Actions";*/
return statesArray;
}
bool CutoffTest(int depth)
{
return depth>=m_depth;
}
string calculatetabs(int depth)
{
string tabs = "";
for(int i=0;i<depth;i++)
{
tabs = tabs + " ";
}
return tabs;
}
void printMoveB(vector<vector<char> > c_state,vector<vector<char> > cState, int c_depth)
{
bool forward = false;
string tabs;
int moverate=0,countforward=0;
int movei[200],movej[200];
for(int i=1;i<9;i++)
for(int j=1;j<9;j++)
if(c_state[i][j] != cState[i][j])
{
if(c_state[i][j] == '.' && countforward==0)
{
forward = true;
countforward++;
}
else
{
forward = false;
}
movei[moverate] = i;
movej[moverate] = j;
moverate++;
}
tabs = calculatetabs(c_depth);
if(prune == false && moverate > 2)
{
if(forward)
{
cout << tabs << "Depth " << c_depth << " : B Jumps from " << "[" << movei[0] << "," << movej[0] << "] To" << "[" << movei[2] << "," << movej[2] << "]" << "\n";
if(c_depth == 0)
{
positions[posval].posi1[posval] = movei[0];
positions[posval].posj1[posval] = movej[0];
positions[posval].posi2[posval] = movei[2];
positions[posval].posj2[posval] = movej[2];
}
}
else{
cout << tabs << "Depth " << c_depth << " : B Jumps from " << "[" << movei[2] << "," << movej[2] << "] To" << "[" << movei[0] << "," << movej[0] << "]" << "\n";
if(c_depth == 0)
{
positions[posval].posi1[posval] = movei[2];
positions[posval].posj1[posval] = movej[2];
positions[posval].posi2[posval] = movei[0];
positions[posval].posj2[posval] = movej[0];
}
}
}
else if(prune == false && moverate <= 2)
{
if(forward)
{
cout << tabs<<"Depth " << c_depth << ": B Moves from " << "[" << movei[0] << "," << movej[0] << "] To" << "[" << movei[1] << "," << movej[1] << "]"<<"\n";
if(c_depth == 0)
{
positions[posval].posi1[posval] = movei[0];
positions[posval].posj1[posval] = movej[0];
positions[posval].posi2[posval] = movei[1];
positions[posval].posj2[posval] = movej[1];
}
}
else
{
cout << tabs<<"Depth " << c_depth << ": B Moves from " << "[" << movei[1] << "," << movej[1] << "] To" << "[" << movei[0] << "," << movej[0] << "]"<<"\n";
if(c_depth == 0)
{
positions[posval].posi1[posval] = movei[1];
positions[posval].posj1[posval] = movej[1];
positions[posval].posi2[posval] = movei[0];
positions[posval].posj2[posval] = movej[0];
}
}
}
else if(prune == true && moverate > 2){
if(forward)
cout << tabs<< "Depth " << c_depth << " : Pruning B's Jump From" << "[" << movei[0] << "," << movej[0] << "] To" << "[" << movei[2] << "," << movej[2] << "]" << "\n";
else
cout << tabs << "Depth " << c_depth << " : Pruning B's Jump From " << "[" << movei[2] << "," << movej[2] << "] To" << "[" << movei[0] << "," << movej[0] << "]" << "\n";
}
else if(prune == true && moverate <= 2){
if(forward)
cout << tabs<<"Depth " << c_depth << ": Pruning B's Move From " << "[" << movei[0] << "," << movej[0] << "] To" << "[" << movei[1] << "," << movej[1] << "]"<<"\n";
else
cout << tabs<<"Depth " << c_depth << ": Pruning B's Move From" << "[" << movei[1] << "," << movej[1] << "] To" << "[" << movei[0] << "," << movej[0] << "]"<<"\n";
}
}
void printMove(vector<vector<char> > c_state,vector<vector<char> > cState, int c_depth)
{
bool forward = false;
string tabs;
int moverate=0,countforward=0;
int movei[200],movej[200];
for(int i=1;i<9;i++)
for(int j=1;j<9;j++)
if(c_state[i][j] != cState[i][j])
{
if(c_state[i][j] == '.' && countforward==0)
{
forward = true;
countforward++;
}
else
{
forward = false;
}
movei[moverate] = i;
movej[moverate] = j;
//cout << movei[moverate] << "," << movej[moverate] << "\t";
moverate++;
}
tabs = calculatetabs(c_depth);
if(prune == false && moverate > 2)
{
if(forward)
{
cout <<tabs<< "Depth " << c_depth << " :A Jumps from " << "[" << movei[0] << "," << movej[0] << "] To" << "[" << movei[2] << "," << movej[2] << "]"<<"\n";
if(c_depth == 0)
{
positions[posval].posi1[posval] = movei[0];
positions[posval].posj1[posval] = movej[0];
positions[posval].posi2[posval] = movei[2];
positions[posval].posj2[posval] = movej[2];
positions[posval].mover[posval] = moverate;
//cout << "Depth " << c_depth << " : A Jumps from " << "[" << movei[2] << "," << movej[2] << "] To" << "[" << movei[0] << "," << movej[0] << "]"<<"\n\n";
}
}
else
{
cout <<tabs<< "Depth " << c_depth << " :A Jumps from " << "[" << movei[2] << "," << movej[2] << "] To" << "[" << movei[0] << "," << movej[0] << "]"<<"\n";
if(c_depth == 0)
{
positions[posval].posi1[posval] = movei[2];
positions[posval].posj1[posval] = movej[2];
positions[posval].posi2[posval] = movei[0];
positions[posval].posj2[posval] = movej[0];
positions[posval].mover[posval] = moverate;
//cout << "Depth " << c_depth << " : A Jumps from " << "[" << movei[2] << "," << movej[2] << "] To" << "[" << movei[0] << "," << movej[0] << "]"<<"\n\n";
}
}
}
else if(prune == false && moverate <= 2)
{
if(forward)
{
cout <<tabs<<"Depth " << c_depth << ": A Moves from " << "[" << movei[0] << "," << movej[0] << "] To" << "[" << movei[1] << "," << movej[1] << "]"<<"\n";
if(c_depth == 0)
{
positions[posval].posi1[posval] = movei[0];
positions[posval].posj1[posval] = movej[0];
positions[posval].posi2[posval] = movei[1];
positions[posval].posj2[posval] = movej[1];
positions[posval].mover[posval] = moverate;
//cout << "Depth " << c_depth << " : A Jumps from " << "[" << movei[2] << "," << movej[2] << "] To" << "[" << movei[0] << "," << movej[0] << "]"<<"\n\n";
}
}
else
{
cout <<tabs<<"Depth " << c_depth << ": A Moves from " << "[" << movei[1] << "," << movej[1] << "] To" << "[" << movei[0] << "," << movej[0] << "]"<<"\n";
if(c_depth == 0)
{
positions[posval].posi1[posval] = movei[1];
positions[posval].posj1[posval] = movej[1];
positions[posval].posi2[posval] = movei[0];
positions[posval].posj2[posval] = movej[0];
positions[posval].mover[posval] = moverate;
//cout << "Depth " << c_depth << " : A Jumps from " << "[" << movei[2] << "," << movej[2] << "] To" << "[" << movei[0] << "," << movej[0] << "]"<<"\n\n";
}
}
}
else if(prune == true && moverate > 2){
if(!forward)
cout <<tabs<<"Depth " << c_depth << " :Pruning A's Jump From " << "[" << movei[2] << "," << movej[2] << "] To" << "[" << movei[0] << "," << movej[0] << "]"<<"\n";
else
cout <<tabs<< "Depth " << c_depth << " :Pruning A's Jump From " << "[" << movei[0] << "," << movej[0] << "] To" << "[" << movei[2] << "," << movej[2] << "]"<<"\n";
}
else if(prune == true && moverate <= 2){
if(!forward)
cout <<tabs<< "Depth " << c_depth << ": Pruning A's move From " << "[" << movei[1] << "," << movej[1] << "] To" << "[" << movei[0] << "," << movej[0] << "]"<<"\n";
else
cout <<tabs<<"Depth " << c_depth << ": Pruning A's move From " << "[" << movei[0] << "," << movej[0] << "] To" << "[" << movei[1] << "," << movej[1] << "]"<<"\n";
}
}
int eval(vector<vector<char> > count,char c)
{
int x=0;
for(int i=1;i<9;i++)
for(int j=1;j<9;j++)
if(count[i][j] == c)
x++;
return x;
}
int evalKings(vector<vector<char> > count,char c)
{
int x=0;
for(int i=1;i<9;i++)
for(int j=1;j<9;j++)
if(count[i][j] == c)
x=x+2;
return x;
}
int min_val(vector<vector<char> > state,int c_depth,int alpha,int beta)
{
string tabs;
prune = false;
c_depth++;
tabs = calculatetabs(c_depth);
//cout << "Min_Val Depth :" << c_depth << "\n";
if(CutoffTest(c_depth))
{
//cout << "Min Depth Limit Reached!!" << "\n";
int c=0;
int b = eval(state,'*');
int a = eval(state,'o');
int f = evalKings(state,'k');
int e = evalKings(state,'K');
if((b+e) == 0)
{
//cout << "Depth "<<c_depth<< ": Heuristic Value Of the Current Board = "<< c << "\n";
prune = false;
return 10000;
}
else if((a+f) ==0)
{
//cout << "Depth "<<c_depth<< ": Heuristic Value Of the Current Board = "<< c << "\n";
prune = false;
return -10000;
}
else
{
//cout << "No Kings";
c = (a+f) - (b+e);
}
//c_depth--;
cout <<tabs<< "Depth "<<c_depth<< ": Heuristic Value Of the Current Board = "<< c << "\n";
// cout << "alpha : " << alpha << "," << "beta :" << beta << "\n";
prune = false;
return c;
}
vector< vector<vector<char> > > statesArray=getWhiteActions(state);
int numStates=statesArray.size()-1;
if(numStates == 0)
{
int b = eval(state,'*');
int a = eval(state,'o');
int f = evalKings(state,'k');
int e = evalKings(state,'K');
//int c = (a+f) - (b+e);
prune = false;
return 10000;
}
for(int i=0;i<numStates;++i){
vector<vector<char> > cState=statesArray[i];
if(prune == false){
printMoveB(state,cState,c_depth);
int temp=max_val(cState,c_depth,alpha,beta);
beta=min(beta,temp);
}
if(beta<=alpha){
if(prune == true) {
printMoveB(state,cState,c_depth);
}
prune = true;
if(i == (numStates-1)){
cout << "Beta :" << beta << ",";
cout << "Alpha :"<<alpha << "\n";
prune = false;
return alpha;
}
}
}
statesArray.clear();
//cout << "Min Return Beta :"<<beta << "\n";
prune = false;
return beta;
}
int max_val(vector<vector<char> > state,int c_depth,int alpha,int beta)
{
prune = false;
c_depth++;
string tabs;
tabs = calculatetabs(c_depth);
// cout << "C_depth" <<c_depth<<"\n";
// cout << "Max_Val Depth :" << c_depth << "\n";
if(CutoffTest(c_depth))
{
//cout << "Max Depth Limit Reached!!" << "\n";
int c;
int b = eval(state,'*');
int a = eval(state,'o');
int f = evalKings(state,'k');
int e = evalKings(state,'K');
if((b+e) == 0)
{
// cout << "Depth "<<c_depth<< ": Heuristic Value Of the Current Board = "<< c << "\n";
prune = false;
return 10000;
}
else if((a+f) ==0)
{
// cout << "Depth "<<c_depth<< ": Heuristic Value Of the Current Board = "<< c << "\n";
prune = false;
return -10000;
}
else
{
//cout << "No Kings";
c = (a+f) - (b+e);
}
//c_depth--;
cout << tabs <<"Depth "<<c_depth<< "\t : Heuristic Value Of the Current Board = "<< c << "\n \n ";
//cout << "alpha : " << alpha << "," << "beta :" << beta << "\n";
prune = false;
return c;
}
vector< vector<vector<char> > > statesArray=getBlackActions(state);
int numStates=statesArray.size()-1;
if(numStates == 0)
{
int b = eval(state,'*');
int a = eval(state,'o');
int f = evalKings(state,'k');
int e = evalKings(state,'K');
//int c = (a+f) - (b+e);
prune = false;
return -10000;
}
for(int i=0;i<numStates;++i){
vector<vector<char> > cState=statesArray[i];
if(prune == false){
printMove(state,cState,c_depth);
//depth ==0 ,save position
int temp=min_val(cState,c_depth,alpha,beta);
alpha=max(alpha,temp);
if(c_depth == 0){
positions[posval].alpha = alpha;
cout << "Alpha :" << positions[posval].alpha << " @ Pos Val :" << posval << "Beta" << beta <<"\n";
posval++;
}
}
if(alpha>=beta){
if(prune == true){
printMove(state,cState,c_depth);
}
prune = true;
if(i == (numStates-1)){
cout << "Alpha :" << alpha << ",";
cout << "Beta :"<<beta << "\n";
prune = false;
return beta;
}
}
cState.clear();
}
statesArray.clear();
//cout << "Max Return alpha :"<<alpha << "\n";
prune = false;
return alpha;
}
int main()
{
bool max_call = false;
vector<vector<char> > state;
vector<vector<char> > piece;
state.resize(9);
for(int i=1;i<9;++i)
state[i].resize(9);
piece.resize(9);
for(int i=1;i<9;++i)
piece[i].resize(9);
const int SIZE = 70;
int rowcount=0,colcount=0,noofpieces=0,a=1,b=1,alpha=-10000,beta=10000,c_depth=-1;
char pieces[SIZE];
char str;
std::ifstream fin("input.txt");
for (int i = 1; (fin >> str) && (i <= SIZE+1); ++i)
{
pieces[i] = str;
noofpieces++;
}
fin.close();
//cout << "\n No Of Pieces : " << noofpieces << "\n";
max_depth = pieces[noofpieces-1];
string last_row = "";
//Board Configuration
for (int i = 1; i <=64; i++)
{
for (int j =1; j<9; j++)
{
piece[b][j] = pieces[a];
a = a+1;
}
b = b+1;
i = i+8;
}
for (int i = 65; i <=noofpieces; ++i)
{
//get the last row value
last_row = last_row + pieces[i];
}
//cout << "\n Last row " << last_row << "\n";
//cout << "Maximum Depth " << max_depth << "\n \n";
m_depth = atoi(last_row.c_str());
//cout << "m_depth" << m_depth;
//copy piece array into state array to pass it to max_val
for(int i=1;i<9;i++)
{
for(int j=1;j<9;j++)
{
state[i][j] = piece[i][j];
}
}
int v;
for(int i=1;i<9;i++)
{
for(int j=1;j<9;j++)
{
if(state[i][j] == 'o' || state[i][j] == 'k')
{
max_call = true;
}
}
}
if(max_call == true)
v=max_val(state,c_depth,alpha,beta);
else
v=-10000;
//Print Max Players First Move
int max;
for(int i=0;i<posval;i++)
{
max = positions[0].alpha;
if(positions[i].alpha>max)
max = positions[i].alpha;
}
cout << "Expansions Completed!! " << "\n\n";
for(int i=0;i<posval;i++)
{
if(positions[i].alpha == max)
{
if(positions[posval].mover[posval] <= 2)
{
cout << "A moves the piece at " << "[" << positions[i].posi1[i] << "," << positions[i].posj1[i] << "] To" << "[" << positions[i].posi2[i] << "," << positions[i].posj2[i] << "]"<<"\n\n";
break;
}
else{
cout << "A Jumps the piece at " << "[" << positions[i].posi1[i] << "," << positions[i].posj1[i] << "] To" << "[" << positions[i].posi2[i] << "," << positions[i].posj2[i] << "]"<<"\n\n";
break;
}
}
}
cout << "Returned Final Heuristic Board Value : " << v <<"\n";
}
|
594d724024aeab973c86df4831c13620f03e4194
|
83b4e73c391a81feeea027f7ce4b80fb92a16d36
|
/lite/src/main/cpp/native-lib.cpp
|
3ec700b236649599c3128661dd1ee741edfff0e2
|
[] |
no_license
|
BrainBear/ProtoBuf-Cpp-Android
|
d46a8eebc3f930e9317ac033181245c289883412
|
8e0d5da84b4263d18625fb98df02346a0714fd20
|
refs/heads/master
| 2020-05-18T01:35:13.716186
| 2019-04-29T15:19:14
| 2019-04-29T15:19:14
| 184,094,328
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 660
|
cpp
|
native-lib.cpp
|
//
// Created by canxiong lian on 2019-04-28.
//
#include <jni.h>
#include <string>
#include "log.h"
#include "test.pb.h"
extern "C" JNIEXPORT jstring JNICALL
Java_me_brainbear_lite_Lite_stringFromJNI(
JNIEnv *env,
jobject /* this */) {
std::string hello = "Hello from C++";
Test test;
test.add_v1(1);
test.add_v1(2);
test.add_v1(3);
test.add_v1(3);
std::string str = test.SerializeAsString();
Test test1;
test1.ParseFromString(str);
LOGI("%d", test1.v1(0));
LOGI("%d", test1.v1(1));
LOGI("%d", test1.v1(2));
LOGI("%d", test1.v1(3));
return env->NewStringUTF(hello.c_str());
}
|
1a1fe3cf83f23fe84d416e3ceaa20c9506162a48
|
85e7caac6bc4a962b85286dae2318a42d5741d31
|
/blackjack.h
|
48345b1390856faa24f10715da55e0ff121b0aa3
|
[] |
no_license
|
zedek/CS_blackjack
|
9a57b93ddcb191da366b0680b9b95ff0152d7d3b
|
09e281ff24b51e549b5b1c24d882e0ab40d94123
|
refs/heads/master
| 2021-01-18T11:17:13.882322
| 2015-04-03T21:31:56
| 2015-04-03T21:31:56
| 33,032,015
| 0
| 0
| null | 2015-03-28T12:09:21
| 2015-03-28T12:09:21
| null |
UTF-8
|
C++
| false
| false
| 1,887
|
h
|
blackjack.h
|
#ifndef BLACKJACK_H
#define BLACKJACK_H
#include <iostream>
#include <Windows.h>
#include <vector>
#include <stdio.h>
#include <ctime>
#include <string>
#include "card.h"
#include "blackjack.h"
using namespace std;
class Deck {
public:
Deck();
Deck(int x);
void shuffle();
Card draw_card();
bool empty();
int _top();
private:
int ndeck;
vector<Card> cards;
int top;
};
class Hand {
public:
Hand();
int getrank(int i);
void setcard(int i, Card& x);
void total(); // to control scoreh
void hit(Deck& d);
int size();
int getscore();
void bust();
void show_hands();
int bet(int x);
int ace;
int get_betValue();
bool get_fold();
bool get_call();
void is_blackjack();
void call(int min);
bool get_blackjack();
void split_back(Card& card);
Card& get_card(int i);
bool mode();
private:
vector<Card> cards_in_hand;
int score;
bool hascalled;
int bet_value;
bool blackjack;
bool folded;
bool has_hit = false;
};
class Player : public Hand {
public:
Player(Deck& d);
void showhands();
string player_name();
string player_name(int x);
int get_money();
void set_money(int x);
void split(Deck& du);
bool has_split();
void betting();
void showsplit();
Hand split_hand;
void split_fold();
friend ostream& operator<< (ostream& output, Player& h);
private:
int money;
string name;
bool _split = false;
};
class Dealer : public Hand { // a hybrid between a player class and hand class, it doesn't
public:
Dealer(Deck& d);
Dealer();
void dealermove(Deck& d);
friend ostream& operator<< (ostream& output, Dealer* d);
};
class Game {
public:
Game(int x);
void betTurn();
void next_player();
void print_score();
void game_hand();
void calcWinner();
void hitTurn();
int num_players();
int minbet();
void game_board();
Deck du;
int player = 0;
Dealer* dealer;
vector<Player> players;
};
#endif
|
3dcf275b8000f4caedbd312361b91024c21c9792
|
12c1611032f58263b34260045a5e3b1fc4c7272f
|
/src/calfilter.cpp
|
7789ef00f9107227e8f86dfd5bffecd3a8140e91
|
[] |
no_license
|
KDE/kcalendarcore
|
8a60e29f09ca1dc6383619a58a68adbf1d7c96dd
|
29055998c8ea3538113cbacf2f0d4e6d101e1225
|
refs/heads/master
| 2023-08-31T11:58:44.201834
| 2023-08-29T21:27:51
| 2023-08-29T21:27:51
| 209,340,459
| 5
| 1
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 5,349
|
cpp
|
calfilter.cpp
|
/*
This file is part of the kcalcore library.
SPDX-FileCopyrightText: 2001 Cornelius Schumacher <schumacher@kde.org>
SPDX-FileCopyrightText: 2003-2004 Reinhold Kainhofer <reinhold@kainhofer.com>
SPDX-FileCopyrightText: 2004 Bram Schoenmakers <bramschoenmakers@kde.nl>
SPDX-License-Identifier: LGPL-2.0-or-later
*/
/**
@file
This file is part of the API for handling calendar data and
defines the CalFilter class.
@brief
Provides a filter for calendars.
@author Cornelius Schumacher \<schumacher@kde.org\>
@author Reinhold Kainhofer \<reinhold@kainhofer.com\>
@author Bram Schoenmakers \<bramschoenmakers@kde.nl\>
*/
#include "calfilter.h"
using namespace KCalendarCore;
/**
Private class that helps to provide binary compatibility between releases.
@internal
*/
//@cond PRIVATE
class Q_DECL_HIDDEN KCalendarCore::CalFilter::Private
{
public:
Private()
{
}
QString mName; // filter name
QStringList mCategoryList;
QStringList mEmailList;
int mCriteria = 0;
int mCompletedTimeSpan = 0;
bool mEnabled = true;
};
//@endcond
CalFilter::CalFilter()
: d(new KCalendarCore::CalFilter::Private)
{
}
CalFilter::CalFilter(const QString &name)
: d(new KCalendarCore::CalFilter::Private)
{
d->mName = name;
}
CalFilter::~CalFilter()
{
delete d;
}
bool KCalendarCore::CalFilter::operator==(const CalFilter &filter) const
{
return d->mName == filter.d->mName && d->mCriteria == filter.d->mCriteria && d->mCategoryList == filter.d->mCategoryList
&& d->mEmailList == filter.d->mEmailList && d->mCompletedTimeSpan == filter.d->mCompletedTimeSpan;
}
void CalFilter::apply(Event::List *eventList) const
{
if (!d->mEnabled) {
return;
}
auto it = std::remove_if(eventList->begin(), eventList->end(), [=](const Incidence::Ptr &incidence) {
return !filterIncidence(incidence);
});
eventList->erase(it, eventList->end());
}
// TODO: avoid duplicating apply() code
void CalFilter::apply(Todo::List *todoList) const
{
if (!d->mEnabled) {
return;
}
auto it = std::remove_if(todoList->begin(), todoList->end(), [=](const Incidence::Ptr &incidence) {
return !filterIncidence(incidence);
});
todoList->erase(it, todoList->end());
}
void CalFilter::apply(Journal::List *journalList) const
{
if (!d->mEnabled) {
return;
}
auto it = std::remove_if(journalList->begin(), journalList->end(), [=](const Incidence::Ptr &incidence) {
return !filterIncidence(incidence);
});
journalList->erase(it, journalList->end());
}
bool CalFilter::filterIncidence(const Incidence::Ptr &incidence) const
{
if (!d->mEnabled) {
return true;
}
Todo::Ptr todo = incidence.dynamicCast<Todo>();
if (todo) {
if ((d->mCriteria & HideCompletedTodos) && todo->isCompleted()) {
// Check if completion date is suffently long ago:
if (todo->completed().addDays(d->mCompletedTimeSpan) < QDateTime::currentDateTimeUtc()) {
return false;
}
}
if ((d->mCriteria & HideInactiveTodos) && ((todo->hasStartDate() && QDateTime::currentDateTimeUtc() < todo->dtStart()) || todo->isCompleted())) {
return false;
}
if (d->mCriteria & HideNoMatchingAttendeeTodos) {
bool iAmOneOfTheAttendees = false;
const Attendee::List &attendees = todo->attendees();
if (!attendees.isEmpty()) {
iAmOneOfTheAttendees = std::any_of(attendees.cbegin(), attendees.cend(), [this](const Attendee &att) {
return d->mEmailList.contains(att.email());
});
} else {
// no attendees, must be me only
iAmOneOfTheAttendees = true;
}
if (!iAmOneOfTheAttendees) {
return false;
}
}
}
if (d->mCriteria & HideRecurring) {
if (incidence->recurs() || incidence->hasRecurrenceId()) {
return false;
}
}
const QStringList incidenceCategories = incidence->categories();
bool isFound = false;
for (const auto &category : std::as_const(d->mCategoryList)) {
if (incidenceCategories.contains(category)) {
isFound = true;
break;
}
}
return (d->mCriteria & ShowCategories) ? isFound : !isFound;
}
void CalFilter::setName(const QString &name)
{
d->mName = name;
}
QString CalFilter::name() const
{
return d->mName;
}
void CalFilter::setEnabled(bool enabled)
{
d->mEnabled = enabled;
}
bool CalFilter::isEnabled() const
{
return d->mEnabled;
}
void CalFilter::setCriteria(int criteria)
{
d->mCriteria = criteria;
}
int CalFilter::criteria() const
{
return d->mCriteria;
}
void CalFilter::setCategoryList(const QStringList &categoryList)
{
d->mCategoryList = categoryList;
}
QStringList CalFilter::categoryList() const
{
return d->mCategoryList;
}
void CalFilter::setEmailList(const QStringList &emailList)
{
d->mEmailList = emailList;
}
QStringList CalFilter::emailList() const
{
return d->mEmailList;
}
void CalFilter::setCompletedTimeSpan(int timespan)
{
d->mCompletedTimeSpan = timespan;
}
int CalFilter::completedTimeSpan() const
{
return d->mCompletedTimeSpan;
}
|
342b0fb4311c9cbee2a53f7f4dfb7ca8e780eddc
|
26f7d65fab41986228344ed9be221b870d8b1efa
|
/DataServices/include/sqliteOperationFactory.h
|
b2309bfdafd588d69ca68ac3a1a116122cd7872f
|
[
"MIT"
] |
permissive
|
jeremydumais/TeacherHelper
|
a01d1c8bd5f864fd0bc95238fd013fc1223e0503
|
f90db9c18a74ca3020c26d79eb2160a0c4e53efb
|
refs/heads/master
| 2023-03-27T07:43:30.418046
| 2021-03-28T17:04:24
| 2021-03-28T17:04:24
| 260,787,000
| 0
| 0
|
MIT
| 2021-03-28T15:14:47
| 2020-05-02T22:33:02
|
C++
|
UTF-8
|
C++
| false
| false
| 1,536
|
h
|
sqliteOperationFactory.h
|
#pragma once
#include "IStorageOperationFactory.h"
class SQLiteOperationFactory : public IStorageOperationFactory
{
public:
std::unique_ptr<IStorageSelectOperation> createSelectOperation(const IDatabaseConnection &connection,
const std::string &query,
const std::vector<std::string> &args = std::vector<std::string>()) override;
std::unique_ptr<IStorageInsertOperation> createInsertOperation(const IDatabaseConnection &connection,
const std::string &query,
const std::vector<std::string> &args) override;
std::unique_ptr<IStorageUpdateOperation> createUpdateOperation(const IDatabaseConnection &connection,
const std::string &query,
const std::vector<std::string> &args) override;
std::unique_ptr<IStorageDeleteOperation> createDeleteOperation(const IDatabaseConnection &connection,
const std::string &query,
const std::vector<std::string> &args) override;
std::unique_ptr<IStorageDDLOperation> createDDLOperation(const IDatabaseConnection &connection,
const std::string &query,
const std::vector<std::string> &args = std::vector<std::string>()) override;
};
|
5c7bc9af4feb34f0c2f27b1bacf066b4c8b47e07
|
94394b06b5f180e471a6f78ffc6e995564ce80b9
|
/pa1/my_tests/test.cpp
|
be1d01b47a4096d82fb9641d92120ea40043471e
|
[] |
no_license
|
MatthewMong/CPSC-221
|
c7044cff09f04b3cdac594ce912ec8fedaec4c52
|
2c73b04c7016d21347c00941af6d8413202165d7
|
refs/heads/master
| 2022-01-07T14:24:00.290393
| 2019-05-08T05:31:33
| 2019-05-08T05:31:33
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 434
|
cpp
|
test.cpp
|
#define CATCH_CONFIG_MAIN // This tells Catch to provide a main() - only do this in one cpp file
#include "chain.h"
#include "block.h"
#include <iostream>
#include "../cs221util/PNG.h"
#include "catch.hpp"
using namespace cs221util;
using namespace std;
TEST_CASE("test insert_back",""){
Block b1(1);
Block b2(2);
Block b3(3);
Chain c;
c.insertBack(b1);
c.insertBack(b2);
c.insertBack(b3);
REQUIRE(c.size() == 3);
}
|
eb735a2c0b8f9ba82cb9fb80950d9a2eced0e2d7
|
970079e4bd221f1e2c8dc43b556ec9e793f5d7aa
|
/1201. Ugly number III.cpp
|
701d36644e28fd8267c99316e699cc4d87ad6922
|
[] |
no_license
|
amreenabbas/Leet-Code-Solutions
|
ae814eaafe25c89f45e5fa74934be75502c97420
|
da3154950ce337dda26eb72966435079b3a3e574
|
refs/heads/master
| 2023-07-04T19:04:53.061305
| 2021-08-15T13:25:18
| 2021-08-15T13:25:18
| 257,496,352
| 0
| 3
| null | 2021-08-09T12:42:40
| 2020-04-21T06:06:59
|
C++
|
UTF-8
|
C++
| false
| false
| 1,174
|
cpp
|
1201. Ugly number III.cpp
|
Question Link : https://leetcode.com/problems/ugly-number-iii/
//Solution by Amreen
class Solution {
public:
#define ll long long
ll l1,l2,l3,l4;
ll gcd(ll a, ll b)
{
if(b==0)
return a;
return gcd(b,a%b);
}
void lcm(ll a, ll b, ll c)
{
l1 = (a*b)/gcd(b,a);
l2 = (b*c)/gcd(c,b);
l3 = (a*c)/gcd(c,a);
l4 = l2*a/gcd(l2,a);
}
ll factors(ll m, ll a, ll b, ll c)
{
ll g = 0;
g+=m/a;
g+=m/b;
g+=m/c;
g-=m/l1;
g-=m/l2;
g-=m/l3;
g+=m/l4;
return g;
}
int nthUglyNumber(int n, int a, int b, int c) {
vector<int> v = {a,b,c};
sort(v.begin(),v.end());
a = v[0];
b = v[1];
c = v[2];
lcm(a,b,c);
ll i = a, j = a*n;
while(i<j)
{
ll mi = i+(j-i)/2;
ll f = factors(mi,a,b,c);
if(f<n)
i = mi+1;
else
j = mi;
}
int ans = i;
if(i%a !=0 && i%b !=0 && i%c !=0)
ans = min((i/a)*a,min((i/b)*b,(i/c)*c));
return ans;
}
};
|
11122a01f0d0c780afac614f140e0e2392ffa8ce
|
f6320e18668aab494fdb769eff80cbdce379b863
|
/modules/stereo_camera/src/json_struct/json_gyro_angle.cpp
|
de379b3c71eacbb7a7e8923cd204ad410456532e
|
[
"MIT"
] |
permissive
|
dzyswy/stereo-client
|
6b1a6fcfe3a20cbf1b480e2f92e967f526a087cb
|
2855500187047e535a6834dcad31cf3c6f2b86a3
|
refs/heads/master
| 2021-06-25T03:45:39.785061
| 2021-03-14T16:05:21
| 2021-03-14T16:05:21
| 201,775,718
| 2
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,847
|
cpp
|
json_gyro_angle.cpp
|
#include "json_gyro_angle.h"
#include "json/json.h"
using namespace std;
json_gyro_angle::json_gyro_angle()
{
}
json_gyro_angle::json_gyro_angle(struct stereo_gyro_angle &value)
{
data_ = value;
}
struct stereo_gyro_angle json_gyro_angle::to_struct()
{
return data_;
}
int json_gyro_angle::from_string(std::string &value)
{
struct stereo_gyro_angle data;
try {
Json::Reader reader;
Json::Value jroot;
Json::Value jgyro_angle;
if (!reader.parse(value, jroot))
return -1;
if (jroot["gyro_angle"].empty())
return -1;
jgyro_angle = jroot["gyro_angle"];
if (jgyro_angle["xabs"].empty())
return -1;
if (jgyro_angle["yabs"].empty())
return -1;
if (jgyro_angle["zabs"].empty())
return -1;
if (jgyro_angle["roll"].empty())
return -1;
if (jgyro_angle["pitch"].empty())
return -1;
data.xabs = jgyro_angle["xabs"].asFloat();
data.yabs = jgyro_angle["yabs"].asFloat();
data.zabs = jgyro_angle["zabs"].asFloat();
data.roll = jgyro_angle["roll"].asFloat();
data.pitch = jgyro_angle["pitch"].asFloat();
} catch(std::exception &ex)
{
printf( "jsoncpp struct error: %s.\n", ex.what());
return -1;
}
data_ = data;
return 0;
}
int json_gyro_angle::to_string(std::string &value)
{
try {
Json::Value jroot;
Json::Value jgyro_angle;
jgyro_angle["xabs"] = data_.xabs;
jgyro_angle["yabs"] = data_.yabs;
jgyro_angle["zabs"] = data_.zabs;
jgyro_angle["roll"] = data_.roll;
jgyro_angle["pitch"] = data_.pitch;
jroot["gyro_angle"] = jgyro_angle;
// value = jroot.toStyledString();
Json::StreamWriterBuilder builder;
builder["indentation"] = "";
value = Json::writeString(builder, jroot);
}
catch(std::exception &ex)
{
printf( "jsoncpp struct error: %s.\n", ex.what());
return -1;
}
return 0;
}
|
924156b167c350e0fb902cbe2bc48d42fb91d596
|
56a2235810d493bf17c5b684334685deddacd946
|
/driver/src/sick_scan_common_nw.cpp
|
be91b734d8f17248082962d63b1fd2ca06f41b65
|
[
"Apache-2.0"
] |
permissive
|
SICKAG/sick_scan
|
ddfd7bb1d7981dc4ae3de35bbe77c8d886612469
|
b44cd27a3d385e04bc098725d441fb6c42067eb9
|
refs/heads/master
| 2023-01-25T01:36:36.670218
| 2022-09-05T10:25:24
| 2022-09-05T10:25:24
| 113,834,423
| 137
| 122
|
Apache-2.0
| 2023-01-17T09:43:08
| 2017-12-11T08:46:30
|
C++
|
UTF-8
|
C++
| false
| false
| 17,435
|
cpp
|
sick_scan_common_nw.cpp
|
/**
* \file
* \brief Laser Scanner network communication
*
* Copyright (C) 2018,2017, Ing.-Buero Dr. Michael Lehning, Hildesheim
* Copyright (C) 2018,2017, SICK AG, Waldkirch
*
* All rights reserved.
* \class SickScanCommonNw
*
* \brief Interface for TCP/IP
*
* This class provides an interface for TCP/IP communication.
* It also contains simple methods for accessing the essential contents of the SOPAS message
* (for example, determining the payload and the SOPAS command used).
* It based on an example of SICK AG.
*
* Doxygen example: http://www-numi.fnal.gov/offline_software/srt_public_context/WebDocs/doxygen-howto.html
*
*/
#include "sick_scan/sick_scan_common_nw.h"
#include "sick_scan/tcp/colaa.hpp"
#include "sick_scan/tcp/colab.hpp"
#include "sick_scan/tcp/BasicDatatypes.hpp"
#include "sick_scan/tcp/tcp.hpp"
#include <map> // for std::map
#include "sick_scan/tcp/tcp.hpp"
#include "sick_scan/tcp/errorhandler.hpp"
#include "sick_scan/tcp/toolbox.hpp"
#include "sick_scan/tcp/Mutex.hpp"
#include <assert.h>
SickScanCommonNw::SickScanCommonNw()
{
m_state = CONSTRUCTED;
m_beVerbose = false;
}
SickScanCommonNw::~SickScanCommonNw()
{
// Disconnect and shut down receive thread.
if (isConnected() == true)
{
// Change from CONNECTED to CONSTRUCTED
disconnect();
}
}
//
// Disconnect from the scanner, and close the interface.
//
bool SickScanCommonNw::disconnect()
{
closeTcpConnection();
// Change back to CONSTRUCTED
m_state = CONSTRUCTED;
return true;
}
//
// Initialisation from Scanner class:
// Parameter setup only. Afterwards, call connect() to connect to the scanner.
//
bool SickScanCommonNw::init(std::string ipAddress,
unsigned short portNumber,
Tcp::DisconnectFunction disconnectFunction,
void *obj)
{
m_ipAddress = ipAddress;
m_portNumber = portNumber;
m_tcp.setDisconnectCallbackFunction(disconnectFunction, obj);
return true;
}
bool SickScanCommonNw::setReadCallbackFunction(Tcp::ReadFunction readFunction,
void *obj)
{
m_tcp.setReadCallbackFunction(readFunction, obj);
return (true);
}
//
// Verbinde mit dem unter init() eingestellten Geraet, und pruefe die Verbindung
// durch einen DeviceIdent-Aufruf.
//
// true = Erfolgreich.
//
bool SickScanCommonNw::connect()
{
assert (m_state == CONSTRUCTED); // must not be opened or running already
// Initialise buffer variables
m_numberOfBytesInReceiveBuffer = 0; // Buffer is empty
m_numberOfBytesInResponseBuffer = 0; // Buffer is empty
// Establish connection here
// Set the data input callback for our TCP connection
// m_tcp.setReadCallbackFunction(&SickScanCommonNw::readCallbackFunctionS, this); // , this, _1, _2));
bool success = openTcpConnection();
if (success == true)
{
// Check if scanner type matches
m_state = CONNECTED;
}
return success;
}
//
// True, if state is CONNECTED, that is:
// - A TCP-connection exists
// - Read thread is running
//
bool SickScanCommonNw::isConnected()
{
return (m_state == CONNECTED);
}
/**
* Open TCP-connection to endpoint (usually IP-address and port)
*
* true = Connected, false = no connection
*/
bool SickScanCommonNw::openTcpConnection()
{
// printInfoMessage("SickScanCommonNw::openTcpConnection: Connecting TCP/IP connection to " + m_ipAddress + ":" + toString(m_portNumber) + " ...", m_beVerbose);
bool success = m_tcp.open(m_ipAddress, m_portNumber, m_beVerbose);
if (success == false)
{
// printError("SickScanCommonNw::openTcpConnection: ERROR: Failed to establish TCP connection, aborting!");
return false;
}
return true;
}
//
// Close TCP-connection and shut down read thread
//
void SickScanCommonNw::closeTcpConnection()
{
if (m_tcp.isOpen())
{
m_tcp.close();
}
}
//
// Static entry point.
//
void SickScanCommonNw::readCallbackFunctionS(void *obj, UINT8 *buffer, UINT32 &numOfBytes)
{
((SickScanCommonNw *) obj)->readCallbackFunction(buffer, numOfBytes);
}
/**
* Read callback. Diese Funktion wird aufgerufen, sobald Daten auf der Schnittstelle
* hereingekommen sind.
*/
void SickScanCommonNw::readCallbackFunction(UINT8 *buffer, UINT32 &numOfBytes)
{
bool beVerboseHere = false;
printInfoMessage(
"SickScanCommonNw::readCallbackFunction(): Called with " + toString(numOfBytes) + " available bytes.",
beVerboseHere);
ScopedLock lock(&m_receiveDataMutex); // Mutex for access to the input buffer
UINT32 remainingSpace = sizeof(m_receiveBuffer) - m_numberOfBytesInReceiveBuffer;
UINT32 bytesToBeTransferred = numOfBytes;
if (remainingSpace < numOfBytes)
{
bytesToBeTransferred = remainingSpace;
// printWarning("SickScanCommonNw::readCallbackFunction(): Input buffer space is to small, transferring only " +
// ::toString(bytesToBeTransferred) + " of " + ::toString(numOfBytes) + " bytes.");
}
else
{
// printInfoMessage("SickScanCommonNw::readCallbackFunction(): Transferring " + ::toString(bytesToBeTransferred) +
// " bytes from TCP to input buffer.", beVerboseHere);
}
if (bytesToBeTransferred > 0)
{
// Data can be transferred into our input buffer
memcpy(&(m_receiveBuffer[m_numberOfBytesInReceiveBuffer]), buffer, bytesToBeTransferred);
m_numberOfBytesInReceiveBuffer += bytesToBeTransferred;
UINT32 size = 0;
while (1)
{
// Now work on the input buffer until all received datasets are processed
SopasEventMessage frame = findFrameInReceiveBuffer();
size = frame.size();
if (size == 0)
{
// Framesize = 0: There is no valid frame in the buffer. The buffer is either empty or the frame
// is incomplete, so leave the loop
printInfoMessage("SickScanCommonNw::readCallbackFunction(): No complete frame in input buffer, we are done.",
beVerboseHere);
// Leave the loop
break;
}
else
{
// A frame was found in the buffer, so process it now.
printInfoMessage(
"SickScanCommonNw::readCallbackFunction(): Processing a frame of length " + ::toString(frame.size()) +
" bytes.", beVerboseHere);
processFrame(frame);
}
}
}
else
{
// There was input data from the TCP interface, but our input buffer was unable to hold a single byte.
// Either we have not read data from our buffer for a long time, or something has gone wrong. To re-sync,
// we clear the input buffer here.
m_numberOfBytesInReceiveBuffer = 0;
}
}
//
// Look for 23-frame (STX/ETX) in receive buffer.
// Move frame to start of buffer
//
// Return: 0 : No (complete) frame found
// >0 : Frame length
//
SopasEventMessage SickScanCommonNw::findFrameInReceiveBuffer()
{
UINT32 frameLen = 0;
UINT32 i;
// Depends on protocol...
if (m_protocol == CoLa_A)
{
//
// COLA-A
//
// Must start with STX (0x02)
if (m_receiveBuffer[0] != 0x02)
{
// Look for starting STX (0x02)
for (i = 1; i < m_numberOfBytesInReceiveBuffer; i++)
{
if (m_receiveBuffer[i] == 0x02)
{
break;
}
}
// Found beginning of frame?
if (i >= m_numberOfBytesInReceiveBuffer)
{
// No start found, everything can be discarded
m_numberOfBytesInReceiveBuffer = 0; // Invalidate buffer
return SopasEventMessage(); // No frame found
}
// Move frame start to index 0
UINT32 newLen = m_numberOfBytesInReceiveBuffer - i;
memmove(&(m_receiveBuffer[0]), &(m_receiveBuffer[i]), newLen);
m_numberOfBytesInReceiveBuffer = newLen;
}
// Look for ending ETX (0x03)
for (i = 1; i < m_numberOfBytesInReceiveBuffer; i++)
{
if (m_receiveBuffer[i] == 0x03)
{
break;
}
}
// Found end?
if (i >= m_numberOfBytesInReceiveBuffer)
{
// No end marker found, so it's not a complete frame (yet)
return SopasEventMessage(); // No frame found
}
// Calculate frame length in byte
frameLen = i + 1;
return SopasEventMessage(m_receiveBuffer, CoLa_A, frameLen);
}
else if (m_protocol == CoLa_B)
{
UINT32 magicWord;
UINT32 payloadlength;
if (m_numberOfBytesInReceiveBuffer < 4)
{
return SopasEventMessage();
}
UINT16 pos = 0;
magicWord = colab::getIntegerFromBuffer<UINT32>(m_receiveBuffer, pos);
if (magicWord != 0x02020202)
{
// Look for starting STX (0x02020202)
for (i = 1; i <= m_numberOfBytesInReceiveBuffer - 4; i++)
{
pos = i; // this is needed, as the position value is updated by getIntegerFromBuffer
magicWord = colab::getIntegerFromBuffer<UINT32>(m_receiveBuffer, pos);
if (magicWord == 0x02020202)
{
// found magic word
break;
}
}
// Found beginning of frame?
if (i > m_numberOfBytesInReceiveBuffer - 4)
{
// No start found, everything can be discarded
m_numberOfBytesInReceiveBuffer = 0; // Invalidate buffer
return SopasEventMessage(); // No frame found
}
else
{
// Move frame start to index
UINT32 bytesToMove = m_numberOfBytesInReceiveBuffer - i;
memmove(&(m_receiveBuffer[0]), &(m_receiveBuffer[i]), bytesToMove); // payload+magic+length+s+checksum
m_numberOfBytesInReceiveBuffer = bytesToMove;
}
}
// Pruefe Laenge des Pufferinhalts
if (m_numberOfBytesInReceiveBuffer < 9)
{
// Es sind nicht genug Daten fuer einen Frame
printInfoMessage("SickScanCommonNw::findFrameInReceiveBuffer: Frame cannot be decoded yet, only " +
::toString(m_numberOfBytesInReceiveBuffer) + " bytes in the buffer.", m_beVerbose);
return SopasEventMessage();
}
// Read length of payload
pos = 4;
payloadlength = colab::getIntegerFromBuffer<UINT32>(m_receiveBuffer, pos);
printInfoMessage(
"SickScanCommonNw::findFrameInReceiveBuffer: Decoded payload length is " + ::toString(payloadlength) +
" bytes.", m_beVerbose);
// Ist die Datenlaenge plausibel und wuede in den Puffer passen?
if (payloadlength > (sizeof(m_receiveBuffer) - 9))
{
// magic word + length + checksum = 9
printWarning(
"SickScanCommonNw::findFrameInReceiveBuffer: Frame too big for receive buffer. Frame discarded with length:"
+ ::toString(payloadlength) + ".");
m_numberOfBytesInReceiveBuffer = 0;
return SopasEventMessage();
}
if ((payloadlength + 9) > m_numberOfBytesInReceiveBuffer)
{
// magic word + length + s + checksum = 10
printInfoMessage(
"SickScanCommonNw::findFrameInReceiveBuffer: Frame not complete yet. Waiting for the rest of it (" +
::toString(payloadlength + 9 - m_numberOfBytesInReceiveBuffer) + " bytes missing).", m_beVerbose);
return SopasEventMessage(); // frame not complete
}
// Calculate the total frame length in bytes: Len = Frame (9 bytes) + Payload
frameLen = payloadlength + 9;
//
// test checksum of payload
//
UINT8 temp = 0;
UINT8 temp_xor = 0;
UINT8 checkSum;
// Read original checksum
pos = frameLen - 1;
checkSum = colab::getIntegerFromBuffer<UINT8>(m_receiveBuffer, pos);
// Erzeuge die Pruefsumme zum Vergleich
for (UINT16 i = 8; i < (frameLen - 1); i++)
{
pos = i;
temp = colab::getIntegerFromBuffer<UINT8>(m_receiveBuffer, pos);
temp_xor = temp_xor ^ temp;
}
// Vergleiche die Pruefsummen
if (temp_xor != checkSum)
{
printWarning("SickScanCommonNw::findFrameInReceiveBuffer: Wrong checksum, Frame discarded.");
m_numberOfBytesInReceiveBuffer = 0;
return SopasEventMessage();
}
return SopasEventMessage(m_receiveBuffer, CoLa_B, frameLen);
}
// Return empty frame
return SopasEventMessage();
}
/**
* Send contents of buffer to scanner using according framing.
*
* Send buffer is limited to 1024 byte!
*/
void SickScanCommonNw::sendCommandBuffer(UINT8 *buffer, UINT16 len)
{
m_tcp.write(buffer, len);
}
/**
* Reads one frame from receive buffer and decodes it.
* Switches directly to the decoder of the protocol.
*
*/
void SickScanCommonNw::processFrame(SopasEventMessage &frame)
{
if (m_protocol == CoLa_A)
{
printInfoMessage(
"SickScanCommonNw::processFrame: Calling processFrame_CoLa_A() with " + ::toString(frame.size()) + " bytes.",
m_beVerbose);
// processFrame_CoLa_A(frame);
}
else if (m_protocol == CoLa_B)
{
printInfoMessage(
"SickScanCommonNw::processFrame: Calling processFrame_CoLa_B() with " + ::toString(frame.size()) + " bytes.",
m_beVerbose);
// processFrame_CoLa_B(frame);
}
}
//
// Copies a complete frame - in any protocol - from the main input buffer to
// the response buffer.
// The frame is *not* removed from the main input buffer.
//
void SickScanCommonNw::copyFrameToResposeBuffer(UINT32 frameLength)
{
printInfoMessage("SickScanCommonNw::copyFrameToResposeBuffer: Copying a frame of " + ::toString(frameLength) +
" bytes to response buffer.", m_beVerbose);
if (frameLength <= sizeof(m_responseBuffer))
{
// Wir duerfen kopieren
memcpy(m_responseBuffer, m_receiveBuffer, frameLength);
m_numberOfBytesInResponseBuffer = frameLength;
}
else
{
// Der respose-Buffer ist zu klein
printError("SickScanCommonNw::copyFrameToResposeBuffer: Failed to copy frame (Length=" + ::toString(frameLength) +
" bytes) to response buffer because the response buffer is too small (buffer size=" +
::toString(sizeof(m_responseBuffer)) + " bytes).");
m_numberOfBytesInResponseBuffer = 0;
}
}
//
// Removes a complete frame - in any protocol - from the main input buffer.
//
void SickScanCommonNw::removeFrameFromReceiveBuffer(UINT32 frameLength)
{
// Remove frame from receive buffer
if (frameLength < m_numberOfBytesInReceiveBuffer)
{
// More data in buffer, move them to the buffer start
UINT32 newLen = m_numberOfBytesInReceiveBuffer - frameLength;
printInfoMessage("SickScanCommonNw::removeFrameFromReceiveBuffer: Removing " + ::toString(frameLength) +
" bytes from the input buffer. New length is " + ::toString(newLen) + " bytes.", m_beVerbose);
memmove(m_receiveBuffer, &(m_receiveBuffer[frameLength]), newLen);
m_numberOfBytesInReceiveBuffer = newLen;
}
else
{
// No other data in buffer, just mark as empty
printInfoMessage("SickScanCommonNw::removeFrameFromReceiveBuffer: Done, no more data in input buffer.",
m_beVerbose);
m_numberOfBytesInReceiveBuffer = 0;
}
}
//
// ************************* SOPAS FRAME ************************************************** //
//
SopasEventMessage::SopasEventMessage() :
m_buffer(NULL), m_protocol(CoLa_A), m_frameLength(0)
{
}
SopasEventMessage::SopasEventMessage(BYTE *buffer, SopasProtocol protocol, UINT32 frameLength) :
m_buffer(buffer), m_protocol(protocol), m_frameLength(frameLength)
{
// Constructor
}
UINT32 SopasEventMessage::getPayLoadLength() const
{
UINT32 payLoadLength = 0;
switch (m_protocol)
{
case CoLa_A:
payLoadLength = m_frameLength - 2; // everything except the 0x02 0x03 frame
break;
case CoLa_B:
payLoadLength =
m_frameLength - 9; // everything except start 0x02020202(4byte), payloadLength(4byte) and checksum(1 byte)
}
return payLoadLength;
}
/** \brief Returns two character long command
* \return string container command
*
* Returns the core command of a sopas message (e.g. "WN") for ..sWN <whatever>
*
*/
std::string SopasEventMessage::getCommandString() const
{
std::string commandString;
switch (m_protocol)
{
case CoLa_A:
commandString = std::string((char *) &m_buffer[2], 2);
break;
case CoLa_B:
commandString = std::string((char *) &m_buffer[9], 2);
}
return commandString;
}
/** \brief Returns a pointer to the first payload byte.
* \return Pointer to payload part of message
*
* Returns a pointer to the first payload byte.
* CoLa-A: Points beyond the leading "0x02" to the "s..." data.
* CoLa-B: Points beyond the magic word and length bytes, to the "s..." data.
*/
BYTE *SopasEventMessage::getPayLoad()
{
BYTE *bufferPos = NULL;
switch (m_protocol)
{
case CoLa_A:
bufferPos = &m_buffer[1];
break;
case CoLa_B:
bufferPos = &m_buffer[8];
break;
}
return bufferPos;
}
/** \brief get SOPAS raw data include header and CRC
* \return Pointer to raw data message
*
* The raw data is stored in m_buffer.
* This function returns a pointer to this buffer.
*/
BYTE *SopasEventMessage::getRawData()
{
BYTE *bufferPos = NULL;
bufferPos = &m_buffer[0];
return bufferPos;
}
INT32 SopasEventMessage::getVariableIndex()
{
INT32 index = -1;
BYTE *bufferPos = &getPayLoad()[3];
switch (m_protocol)
{
case CoLa_A:
index = (INT32) (colaa::decodeUINT16(bufferPos));
break;
case CoLa_B:
index = (INT32) (colab::decodeUINT16(bufferPos));
break;
default:
printError("SopasEventMessage::getVariableIndex: Unknown protocol!");
}
return index;
}
|
57bfdfd45a272abd3fcc7305b8d37e232bcdd884
|
e353e543ce291f474b4811e182f0061cfbe70cc4
|
/sst-elements-library-7.1.0/src/sst/elements/ariel/libariel.cc
|
85301ac6b8c9e3abfaf7ae3ab9f4864069133965
|
[] |
no_license
|
skaramati/sst_network_optimization
|
e5a4dd91dfd93137d21c675db959326645395896
|
5e051ee92cbfe8d22828d9688f6d7043e72d288c
|
refs/heads/master
| 2021-01-02T09:41:46.107056
| 2017-08-04T21:11:06
| 2017-08-04T21:11:06
| 99,277,946
| 1
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 10,170
|
cc
|
libariel.cc
|
// Copyright 2009-2017 Sandia Corporation. Under the terms
// of Contract DE-NA0003525 with Sandia Corporation, the U.S.
// Government retains certain rights in this software.
//
// Copyright (c) 2009-2017, Sandia Corporation
// All rights reserved.
//
// Portions are copyright of other developers:
// See the file CONTRIBUTORS.TXT in the top level directory
// the distribution for more information.
//
// This file is part of the SST software package. For license
// information, see the LICENSE file in the top level directory of the
// distribution.
#include <sst_config.h>
#define SST_ELI_COMPILE_OLD_ELI_WITHOUT_DEPRECATION_WARNINGS
#include "sst/core/element.h"
#include "sst/core/component.h"
#include "sst/core/subcomponent.h"
//#include "ariel.h"
#include "arielcpu.h"
#include "arieltexttracegen.h"
#include "arielmemmgr_simple.h"
#include "arielmemmgr_malloc.h"
#ifdef HAVE_LIBZ
#include "arielgzbintracegen.h"
#endif
#define STRINGIZE(input) #input
using namespace SST;
using namespace SST::ArielComponent;
static Component* create_Ariel(ComponentId_t id, Params& params)
{
return new ArielCPU( id, params );
};
static Module* load_TextTrace( Component* comp, Params& params) {
return new ArielTextTraceGenerator(comp, params);
};
static SubComponent* load_ArielMemoryManagerSimple(Component * owner, Params& params) {
return new ArielMemoryManagerSimple(owner, params);
};
static SubComponent* load_ArielMemoryManagerMalloc(Component * owner, Params& params) {
return new ArielMemoryManagerMalloc(owner, params);
};
static const ElementInfoStatistic ariel_statistics[] = {
{ "read_requests", "Stat read_requests", "requests", 1}, // Name, Desc, Enable Level
{ "write_requests", "Stat write_requests", "requests", 1},
{ "split_read_requests", "Stat split_read_requests", "requests", 1},
{ "split_write_requests", "Stat split_write_requests", "requests", 1},
{ "no_ops", "Stat no_ops", "instructions", 1},
{ "instruction_count", "Statistic for counting instructions", "instructions", 1 },
{ "fp_dp_ins", "Statistic for counting DP-floating point instructions", "instructions", 1 },
{ "fp_dp_simd_ins", "Statistic for counting DP-FP SIMD instructons", "instructions", 1 },
{ "fp_dp_scalar_ins", "Statistic for counting DP-FP Non-SIMD instructons", "instructions", 1 },
{ "fp_dp_ops", "Statistic for counting DP-FP operations (inst * SIMD width)", "instructions", 1 },
{ "fp_sp_ins", "Statistic for counting SP-floating point instructions", "instructions", 1 },
{ "fp_sp_simd_ins", "Statistic for counting SP-FP SIMD instructons", "instructions", 1 },
{ "fp_sp_scalar_ins", "Statistic for counting SP-FP Non-SIMD instructons", "instructions", 1 },
{ "fp_sp_ops", "Statistic for counting SP-FP operations (inst * SIMD width)", "instructions", 1 },
{ "no_ops", "Stat no_ops", "instructions", 1},
{ NULL, NULL, NULL, 0 }
};
static const ElementInfoParam ariel_text_trace_params[] = {
{ "trace_prefix", "Sets the prefix for the trace file", "ariel-core-" },
{ NULL, NULL, NULL }
};
#ifdef HAVE_LIBZ
static Module* load_CompressedBinaryTrace( Component* comp, Params& params) {
return new ArielCompressedBinaryTraceGenerator(comp, params);
};
static const ElementInfoParam ariel_gzbinary_trace_params[] = {
{ "trace_prefix", "Sets the prefix for the trace file", "ariel-core-" },
{ NULL, NULL, NULL }
};
#endif
static const ElementInfoParam ariel_params[] = {
{"verbose", "Verbosity for debugging. Increased numbers for increased verbosity.", "0"},
{"profilefunctions", "Profile functions for Ariel execution, 0 = none, >0 = enable", "0" },
{"alloctracker", "Use an allocation tracker (e.g. memSieve)", "0"},
{"corecount", "Number of CPU cores to emulate", "1"},
{"checkaddresses", "Verify that addresses are valid with respect to cache lines", "0"},
{"maxissuepercycle", "Maximum number of requests to issue per cycle, per core", "1"},
{"maxcorequeue", "Maximum queue depth per core", "64"},
{"maxtranscore", "Maximum number of pending transactions", "16"},
{"pipetimeout", "Read timeout between Ariel and traced application", "10"},
{"cachelinesize", "Line size of the attached caching strucutre", "64"},
{"arieltool", "Path to the Ariel PIN-tool shared library", ""},
{"launcher", "Specify the launcher to be used for instrumentation, default is path to PIN", STRINGIZE(PINTOOL_EXECUTABLE)},
{"executable", "Executable to trace", ""},
{"launchparamcount", "Number of parameters supplied for the launch tool", "0" },
{"launchparam%(launchparamcount)", "Set the parameter to the launcher", "" },
{"envparamcount", "Number of environment parameters to supply to the Ariel executable, default=-1 (use SST environment)", "-1"},
{"envparamname%(envparamcount)", "Sets the environment parameter name", ""},
{"envparamval%(envparamcount)", "Sets the environment parameter value", ""},
{"appargcount", "Number of arguments to the traced executable", "0"},
{"apparg%(appargcount)d", "Arguments for the traced executable", ""},
{"arielmode", "Tool interception mode, set to 1 to trace entire program (default), set to 0 to delay tracing until ariel_enable() call., set to 2 to attempt auto-detect", "2"},
{"arielinterceptcalls", "Toggle intercepting library calls", "0"},
{"arielstack", "Dump stack on malloc calls (also requires enabling arielinterceptcalls). May increase overhead due to keeping a shadow stack.", "0"},
{"tracePrefix", "Prefix when tracing is enable", ""},
{"clock", "Clock rate at which events are generated and processed", "1GHz"},
{"tracegen", "Select the trace generator for Ariel (which records traced memory operations", ""},
{"memmgr", "Memory manager to use for address translation", "ariel.MemoryManagerSimple"},
{NULL, NULL, NULL}
};
static const ElementInfoPort ariel_ports[] = {
{"cache_link_%(corecount)d", "Each core's link to its cache", NULL},
{"alloc_link_%(corecount)d", "Each core's link to an allocation tracker (e.g. memSieve)", NULL},
{NULL, NULL, NULL}
};
static const ElementInfoParam ArielMemoryManagerSimple_params[] = {
{"verbose", "Verbosity for debugging. Increased numbers for increased verbosity.", "0"},
{"vtop_translate", "Set to yes to perform virt-phys translation (TLB) or no to disable", "yes"},
{"pagemappolicy", "Select the page mapping policy for Ariel [LINEAR|RANDOMIZED]", "LINEAR"},
{"translatecacheentries", "Keep a translation cache of this many entries to improve emulated core performance", "4096"},
{"pagesize0", "Page size", "4096"},
{"pagecount0", "Page count", "131072"},
{"page_populate_0", "Pre-populate/partially pre-poulate the page table, this is the file to read in.", ""},
{NULL, NULL, NULL}
};
static const ElementInfoParam ArielMemoryManagerMalloc_params[] = {
{"verbose", "Verbosity for debugging. Increased numbers for increased verbosity.", "0"},
{"vtop_translate", "Set to yes to perform virt-phys translation (TLB) or no to disable", "yes"},
{"pagemappolicy", "Select the page mapping policy for Ariel [LINEAR|RANDOMIZED]", "LINEAR"},
{"translatecacheentries", "Keep a translation cache of this many entries to improve emulated core performance", "4096"},
{"memorylevels", "Number of memory levels in the system", "1"},
{"defaultlevel", "Default memory level", "0"},
{"pagesize%(memorylevels)d", "Page size for memory Level x", "4096"},
{"pagecount%(memorylevels)d", "Page count for memory Level x", "131072"},
{"page_populate_%(memorylevels)d", "Pre-populate/partially pre-populate a page table for a level in memory, this is the file to read in.", ""},
{NULL, NULL, NULL}
};
static const ElementInfoStatistic ArielMemoryManager_statistics[] = {
{ "tlb_hits", "Hits in the simple Ariel TLB", "hits", 2 },
{ "tlb_evicts", "Number of evictions in the simple Ariel TLB", "evictions", 2 },
{ "tlb_translate_queries","Number of TLB translations performed", "translations", 2 },
{ "tlb_shootdown", "Number of TLB clears because of page-frees", "shootdowns", 2 },
{ "tlb_page_allocs", "Number of pages allocated by the memory manager", "pages", 2 },
{ NULL, NULL, NULL, 0 }
};
static const ElementInfoModule modules[] = {
{
"TextTraceGenerator",
"Provides tracing to text file capabilities",
NULL,
NULL,
load_TextTrace,
ariel_text_trace_params,
"SST::ArielComponent::ArielTraceGenerator"
},
#ifdef HAVE_LIBZ
{
"CompressedBinaryTraceGenerator",
"Provides tracing to compressed file capabilities",
NULL,
NULL,
load_CompressedBinaryTrace,
ariel_gzbinary_trace_params,
"SST::ArielComponent::ArielTraceGenerator"
},
#endif
{ NULL, NULL, NULL, NULL, NULL, NULL }
};
static const ElementInfoComponent components[] = {
{ "ariel",
"PIN-based CPU model",
NULL,
create_Ariel,
ariel_params,
ariel_ports,
COMPONENT_CATEGORY_PROCESSOR,
ariel_statistics
},
{ NULL, NULL, NULL, NULL, NULL, NULL, 0 }
};
static const ElementInfoSubComponent subcomponents[] = {
{
"MemoryManagerSimple",
"Simple allocate-on-first-touch memory manager",
NULL,
load_ArielMemoryManagerSimple,
ArielMemoryManagerSimple_params,
ArielMemoryManager_statistics,
"SST::ArielComponent::ArielMemoryManager"
},
{
"MemoryManagerMalloc",
"MLM memory manager which supports malloc/free in different memory pools",
NULL,
load_ArielMemoryManagerMalloc,
ArielMemoryManagerMalloc_params,
ArielMemoryManager_statistics,
"SST::ArielComponent::ArielMemoryManager"
},
{ NULL, NULL, NULL, NULL, NULL, NULL }
};
extern "C" {
ElementLibraryInfo ariel_eli = {
"ariel",
"PIN-based CPU models",
components,
NULL, /* Events */
NULL, /* Introspectors */
modules,
subcomponents
};
}
|
311b39a02b2b212b6c453afaf9d584ccd77e4552
|
a280aa9ac69d3834dc00219e9a4ba07996dfb4dd
|
/regularexpress/home/weilaidb/software/zeromq-4.1.5/src/stream_engine.cpp
|
b18db10061142bf1c3c0648abed7db68c2cd0cad
|
[] |
no_license
|
weilaidb/PythonExample
|
b2cc6c514816a0e1bfb7c0cbd5045cf87bd28466
|
798bf1bdfdf7594f528788c4df02f79f0f7827ce
|
refs/heads/master
| 2021-01-12T13:56:19.346041
| 2017-07-22T16:30:33
| 2017-07-22T16:30:33
| 68,925,741
| 4
| 2
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 2,105
|
cpp
|
stream_engine.cpp
|
#if defined ZMQ_HAVE_WINDOWS
#if defined ZMQ_HAVE_OPENBSD
#define ucred sockpeercred
zmq::stream_engine_t::stream_engine_t (fd_t fd_, const options_t &options_,
const std::string &endpoint_) :
s (fd_),
inpos (NULL),
insize (0),
decoder (NULL),
outpos (NULL),
outsize (0),
encoder (NULL),
metadata (NULL),
handshaking (true),
greeting_size (v2_greeting_size),
greeting_bytes_read (0),
session (NULL),
options (options_),
endpoint (endpoint_),
plugged (false),
next_msg (&stream_engine_t::identity_msg),
process_msg (&stream_engine_t::process_identity_msg),
io_error (false),
subscription_required (false),
mechanism (NULL),
input_stopped (false),
output_stopped (false),
has_handshake_timer (false),
socket (NULL)
zmq::stream_engine_t::~stream_engine_t ()
void zmq::stream_engine_t::plug (io_thread_t *io_thread_,
session_base_t *session_)
void zmq::stream_engine_t::unplug ()
void zmq::stream_engine_t::terminate ()
void zmq::stream_engine_t::in_event ()
void zmq::stream_engine_t::out_event ()
void zmq::stream_engine_t::restart_output ()
void zmq::stream_engine_t::restart_input ()
bool zmq::stream_engine_t::handshake ()
int zmq::stream_engine_t::identity_msg (msg_t *msg_)
int zmq::stream_engine_t::process_identity_msg (msg_t *msg_)
int zmq::stream_engine_t::next_handshake_command (msg_t *msg_)
int zmq::stream_engine_t::process_handshake_command (msg_t *msg_)
void zmq::stream_engine_t::zap_msg_available ()
void zmq::stream_engine_t::mechanism_ready ()
int zmq::stream_engine_t::pull_msg_from_session (msg_t *msg_)
int zmq::stream_engine_t::push_msg_to_session (msg_t *msg_)
int zmq::stream_engine_t::push_raw_msg_to_session (msg_t *msg_)
int zmq::stream_engine_t::write_credential (msg_t *msg_)
int zmq::stream_engine_t::pull_and_encode (msg_t *msg_)
int zmq::stream_engine_t::decode_and_push (msg_t *msg_)
int zmq::stream_engine_t::push_one_then_decode_and_push (msg_t *msg_)
int zmq::stream_engine_t::write_subscription_msg (msg_t *msg_)
void zmq::stream_engine_t::error (error_reason_t reason)
void zmq::stream_engine_t::set_handshake_timer ()
void zmq::stream_engine_t::timer_event (int id_)
|
22bfa2d1eefc8484430dcef6d8b11a0d9d02b701
|
4a56edb91cbbab416174e86e3db9ee8bf61f283f
|
/Test/NodeContainerTests.cpp
|
47f8ad69d651c6068bd96f5b042c3ea228b26de2
|
[
"MIT"
] |
permissive
|
chrisoldwood/XML
|
d64de2dd399e217b202997dacf40bcecdae874a6
|
5fdd74f6725fd4b492f7646d8fa337ebc4e215cd
|
refs/heads/master
| 2023-04-13T19:25:47.093788
| 2023-03-20T22:17:28
| 2023-03-20T22:17:28
| 13,755,862
| 1
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 3,541
|
cpp
|
NodeContainerTests.cpp
|
////////////////////////////////////////////////////////////////////////////////
//! \file NodeContainerTests.cpp
//! \brief The unit tests for the NodeContainer class.
//! \author Chris Oldwood
#include "Common.hpp"
#include <Core/UnitTest.hpp>
#include <XML/ElementNode.hpp>
#include <XML/CommentNode.hpp>
TEST_SET(NodeContainer)
{
TEST_CASE("a node container is initially empty")
{
XML::ElementNodePtr container = XML::makeElement();
TEST_FALSE(container->hasChildren());
TEST_TRUE(container->getChildCount() == 0);
}
TEST_CASE_END
TEST_CASE("after adding a child node the container is not empty")
{
XML::ElementNodePtr container = XML::makeElement();
XML::ElementNodePtr child = XML::makeElement(TXT("child"));
container->appendChild(child);
TEST_TRUE(container->hasChildren());
TEST_TRUE(container->getChildCount() == 1);
}
TEST_CASE_END
TEST_CASE("a child can be retrieved by its index")
{
XML::ElementNodePtr container = XML::makeElement();
XML::ElementNodePtr child = XML::makeElement(TXT("child"));
container->appendChild(child);
TEST_TRUE(container->getChild(0) == child);
}
TEST_CASE_END
TEST_CASE("a child can be retrieved by its index and downcast to its concrete node type")
{
XML::ElementNodePtr container = XML::makeElement();
XML::ElementNodePtr child = XML::makeElement(TXT("child"));
container->appendChild(child);
TEST_TRUE(container->getChild<XML::ElementNode>(0)->name() == TXT("child"));
}
TEST_CASE_END
TEST_CASE("retrieving a child node and down-casting to the wrong type throws")
{
XML::ElementNodePtr container = XML::makeElement();
XML::ElementNodePtr child = XML::makeElement(TXT("child"));
container->appendChild(child);
TEST_THROWS(container->getChild<XML::CommentNode>(0));
}
TEST_CASE_END
TEST_CASE("attempting to retrieve a child by an invalid index throws an exception")
{
XML::ElementNodePtr container = XML::makeElement();
TEST_THROWS(container->getChild(0));
}
TEST_CASE_END
TEST_CASE("child nodes maintain the order they are added")
{
XML::ElementNodePtr container = XML::makeElement();
XML::ElementNodePtr first = XML::makeElement(TXT("first"));
XML::ElementNodePtr second = XML::makeElement(TXT("second"));
container->appendChild(first);
container->appendChild(second);
TEST_TRUE(container->getChild(0) == first);
TEST_TRUE(container->getChild(1) == second);
}
TEST_CASE_END
TEST_CASE("the child nodes can be iterated in the order they were added")
{
XML::ElementNodePtr container = XML::makeElement();
XML::ElementNodePtr first = XML::makeElement(TXT("first"));
XML::ElementNodePtr second = XML::makeElement(TXT("second"));
container->appendChild(first);
container->appendChild(second);
XML::NodeContainer::iterator it = container->beginChild();
XML::NodeContainer::iterator end = container->endChild();
TEST_TRUE(*it++ == first);
TEST_TRUE(*it++ == second);
TEST_TRUE(it == end);
}
TEST_CASE_END
TEST_CASE("iterating the children of a const node requires a const iterator")
{
XML::ElementNodePtr container = XML::makeElement();
XML::ElementNodePtr first = XML::makeElement(TXT("first"));
XML::ElementNodePtr second = XML::makeElement(TXT("second"));
container->appendChild(first);
container->appendChild(second);
const XML::ElementNodePtr constContainer = container;
XML::NodeContainer::const_iterator it = constContainer->beginChild();
XML::NodeContainer::const_iterator end = constContainer->endChild();
TEST_TRUE(*it++ == first);
TEST_TRUE(*it++ == second);
TEST_TRUE(it == end);
}
TEST_CASE_END
}
TEST_SET_END
|
6e7c00335535fa69e2ce67e0f1da394e136ba5e3
|
99fd128e25c1aef4813198b9594d1366b6e23943
|
/Techs/software-craft/know-design/design-pattern/structural-patterns/adapter/simple_adapter/src/duck.hpp
|
966e3535d3c97eccd70ec77ba2d636676f4d2894
|
[] |
no_license
|
tcfh2016/knowledge-map
|
68a06e33f8b9da62f9260035123b9f86850316f0
|
23aff8bf83c07330f1d6422fc6d634d3ecf88da4
|
refs/heads/master
| 2023-08-24T19:14:58.838786
| 2023-08-13T12:04:37
| 2023-08-13T12:04:45
| 83,497,980
| 2
| 2
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 305
|
hpp
|
duck.hpp
|
#pragma once
#include <iostream>
class Duck {
public:
virtual void quack() = 0;
virtual void fly() = 0;
};
class MallardDuck : public Duck {
public:
void quack() {
std::cout <<"Mallard quck quack" <<std::endl;
}
void fly() {
std::cout <<"Mallark duck is flying..." <<std::endl;
}
};
|
85bfd0981a31a825c9146839bf3ba3ce98c9fb4c
|
9c5948eb0f583e8d523528d3ec57296094a11933
|
/main.cpp
|
499745f0864b3cf56e7c65afcd1f3f4194fd1c17
|
[] |
no_license
|
williamjiamin/8.CPP_Intro_If
|
d28183b29b549bb57fad92a5a5a653ac1a0bb8ab
|
be8a27fa89035dfa2fd0652538461a746e796052
|
refs/heads/master
| 2022-11-08T19:42:32.606753
| 2020-06-26T14:32:51
| 2020-06-26T14:32:51
| 275,176,419
| 1
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 696
|
cpp
|
main.cpp
|
//乐学偶得版权所有,主讲人:William 公众号:乐学Fintech 网站:lexueoude.com
// Created by william from lexueoude.com
//
#include <iostream>
using namespace std;
int main() {
string saved_passwd = "lexueoude.com/William";
cout << "Please enter your password :" << flush;
string input;
cin >> input;
// cout << "The password you entered is : " << input << endl;
// 我们可以通过加上逻辑进行判断
if(input == saved_passwd){
cout << "You have entered the right password~" << endl;
}
if(input != saved_passwd){
cout << "You have entered the wrong password~Access denied,Sorry~." << endl;
}
return 0;
}
|
e13f4b71b9cbfdb76a91b71c2c4e53c47f6bd3fc
|
646182cc74ac8b8bdc9750c5b0afbc86ff7f7601
|
/source/option/option.h
|
931825597fda94d73622bc59715b6623c0c4ec00
|
[
"LicenseRef-scancode-mulanpsl-2.0-en",
"MulanPSL-2.0",
"LicenseRef-scancode-unknown-license-reference"
] |
permissive
|
qqsskk/tinyToolkit
|
04d42cfbedd1f8b8f4343de1c016ce6a5ecdb547
|
6387b8865d85cfbccac6b2acd758e497bd111a85
|
refs/heads/master
| 2022-12-20T12:05:40.856443
| 2020-10-21T03:18:13
| 2020-10-21T03:18:13
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 2,189
|
h
|
option.h
|
#ifndef __OPTION__OPTION__H__
#define __OPTION__OPTION__H__
/**
*
* 作者: hm
*
* 说明: 解析器
*
*/
#include "description.h"
#include <unordered_map>
namespace tinyToolkit
{
namespace option
{
class API_TYPE Option
{
public:
/**
*
* 单例对象
*
* @return 单例对象
*
*/
static Option & Instance();
/**
*
* 解析
*
* @param argc 选项个数
* @param argv 选项数组
*
*/
void Parse(int argc, const char * argv[]);
/**
*
* 添加描述组
*
* @param group 描述组
*
*/
void AddDescriptionGroup(const std::shared_ptr<DescriptionGroup> & group);
/**
*
* 是否存在
*
* @param option 选项
*
* @return 是否存在
*
*/
bool Exits(const std::string & option) const;
/**
*
* 详细信息
*
* @return 详细信息
*
*/
std::string Verbose();
/**
*
* 获取数据
*
* @param option 选项
*
* @return 获取的数据
*
*/
template<typename ValueTypeT>
ValueTypeT Get(const std::string & option)
{
auto find = _options.find(option);
if (find == _options.end())
{
throw std::runtime_error("Option invalid : " + option);
}
if (!find->second->IsRequired())
{
throw std::runtime_error("Option not value : " + option);
}
if (!find->second->IsValid())
{
throw std::runtime_error("Option value invalid : " + option);
}
auto real = dynamic_cast<RealValue<ValueTypeT> *>(find->second->Value().get());
if (!real->_value.template Is<ValueTypeT>())
{
throw std::runtime_error("Option value type invalid : " + option);
}
return real->_value.template Get<ValueTypeT>();
}
private:
std::size_t _modeWidth{ 0 };
std::size_t _optionWidth{ 0 };
std::vector<std::shared_ptr<DescriptionGroup>> _groups{ };
std::unordered_map<std::string, DescriptionInfo *> _options{ };
std::unordered_map<std::string, DescriptionInfo *> _longOptions{ };
std::unordered_map<std::string, DescriptionInfo *> _shortOptions{ };
};
}
}
#endif // __OPTION__OPTION__H__
|
715ea3c24bc2a5fb8dffbafb3b8c60f2ea571d5a
|
5f9f7897a1714a78d6ce51bfb7244a52c1a94606
|
/Actividad4/AlumnoNodo.h
|
d4c0a5f1927c14b28a0e557362c6d1a51e5ee81a
|
[] |
no_license
|
DavidUlloa99/EjerciciosdeProgramacion3
|
11ed868ae54e7d4c8db27caf096a48318f323355
|
6dc4d922608f1a57ea955bc3bf72c370c13fc9b1
|
refs/heads/master
| 2023-06-05T10:54:18.153930
| 2021-06-23T17:50:13
| 2021-06-23T17:50:13
| 361,351,228
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 382
|
h
|
AlumnoNodo.h
|
#pragma once
#ifndef ALUMNONODO_H
#define ALUMNONODO_H
class AlumnoNodo
{
private:
char* nombre;
float nota;
AlumnoNodo* siguiente;
public:
AlumnoNodo(void);
AlumnoNodo(char*, float, AlumnoNodo*);
void setNombre(char*);
char* getNombre();
void setNota(float);
float getNota();
void setSiguiente(AlumnoNodo*);
AlumnoNodo* getSiguiente();
};
#endif // !ALUMNONODO_H
|
b9f221d12e1fd9c68b17b734e284d354455fa6da
|
f6807f1ccf192c03b9eacffbdf7aabff6e691f78
|
/ProductReaders/MACCSMetadata/include/SEN2CORMetadataReader.hpp
|
11c384433374dfbeac388ff18aab1250e81b7fb3
|
[] |
no_license
|
mpotanin/sen2agri-processors
|
aacb07a95c3f867041957205c2380320230dc846
|
9006414396b61404d71bd0021f3b7ddd5b9bff23
|
refs/heads/master
| 2020-08-05T01:58:21.908066
| 2020-06-01T06:34:15
| 2020-06-01T06:34:15
| 212,355,431
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 637
|
hpp
|
SEN2CORMetadataReader.hpp
|
#pragma once
#include <memory>
#include "itkObjectFactory.h"
#include "otb_tinyxml.h"
#include "MACCSMetadata.hpp"
namespace itk
{
class SEN2CORMetadataReader : public itk::LightObject
{
public:
typedef SEN2CORMetadataReader Self;
typedef itk::LightObject Superclass;
typedef itk::SmartPointer<Self> Pointer;
typedef itk::SmartPointer<const Self> ConstPointer;
public:
itkNewMacro(Self)
itkTypeMacro(SEN2CORMetadataReader, itk::LightObject)
std::unique_ptr<MACCSFileMetadata> ReadMetadataXml(const TiXmlDocument &doc);
std::unique_ptr<MACCSFileMetadata> ReadMetadata(const std::string &path);
};
}
|
0e46e57702bbedf821f31bc59c4174fc11731ef1
|
9355672a584710dc6869e5e846f54452f989435d
|
/gearbox.h
|
456a5d26462d913d52e099ec60ba6a2c4a538aec
|
[] |
no_license
|
S0urcemaster/dbsDriver
|
f46876888d09d855dc85636c918d1eae9496cca9
|
3e94b323ac5033de208e35258727f77402b2f7ea
|
refs/heads/main
| 2023-05-27T06:50:45.274734
| 2021-05-22T11:03:37
| 2021-05-22T11:03:37
| 369,783,439
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,070
|
h
|
gearbox.h
|
#ifndef GEARBOX_H
#define GEARBOX_H
#include <array>
#include <gear.h>
#include <QDebug>
using namespace std;
/**
* @brief The Gearbox class
* Gearbox struct and logic
*/
class Gearbox
{
array<Gear*, 7> gears {
new Gear("R", 8.47, 180, 60), new Gear("N", 0, 250, 150), new Gear("1", 8.47, 180, 60),
new Gear("2", 4.54, 150, 50), new Gear("3", 2.678, 100, 33), new Gear("4", 1.954, 75, 25),
new Gear("5", 1.401, 50, 17)
};
int gearIndex{1};
int maxIndex{6};
Gear* current{gears[gearIndex]};
double axis{3200};
double tyre{1993};
public:
Gearbox();
void switchUp();
void switchDown();
Gear* getCurrent();
double getAxis();
double getTyre();
/**
* @brief previousRatio
* @return ratio of next gear
*/
double previousRatio();
/**
* @brief nextRatio
* @return ratio of previous gear
*/
double nextRatio();
/**
* @brief getGearMax
* @return highest gear
*/
Gear* getGearMax();
~Gearbox();
};
#endif // GEARBOX_H
|
d33bdd7b444e3b591ecdc9094b8ef3f009ec78ad
|
edf4f46f7b473ce341ba292f84e3d1760218ebd1
|
/src/test-apps/MockNPServer.h
|
1a3502a0816b411e303f49fb7cd297d5fe0ee597
|
[
"LicenseRef-scancode-proprietary-license",
"Apache-2.0"
] |
permissive
|
openweave/openweave-core
|
7e7e6f6c089e2e8015a8281f74fbdcaf4aca5d2a
|
e3c8ca3d416a2e1687d6f5b7cec0b7d0bf1e590e
|
refs/heads/master
| 2022-11-01T17:21:59.964473
| 2022-08-10T16:36:19
| 2022-08-10T16:36:19
| 101,915,019
| 263
| 125
|
Apache-2.0
| 2022-10-17T18:48:30
| 2017-08-30T18:22:10
|
C++
|
UTF-8
|
C++
| false
| false
| 4,621
|
h
|
MockNPServer.h
|
/*
*
* Copyright (c) 2013-2017 Nest Labs, Inc.
* All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* @file
* This file defines a derived unsolicited responder
* (i.e., server) for the Weave Network Provisioning profile used
* for the Weave mock device command line functional testing
* tool.
*
*/
#ifndef MOCKNPSERVER_H_
#define MOCKNPSERVER_H_
#include <Weave/Core/WeaveCore.h>
#include <Weave/Profiles/network-provisioning/NetworkProvisioning.h>
#include <Weave/Profiles/network-provisioning/NetworkInfo.h>
#include <Weave/Profiles/network-provisioning/WirelessRegConfig.h>
using nl::Weave::System::PacketBuffer;
using nl::Weave::WeaveExchangeManager;
using nl::Weave::Profiles::NetworkProvisioning::NetworkInfo;
using nl::Weave::Profiles::NetworkProvisioning::WirelessRegConfig;
using nl::Weave::Profiles::NetworkProvisioning::NetworkProvisioningServer;
using nl::Weave::Profiles::NetworkProvisioning::NetworkProvisioningDelegate;
class MockNetworkProvisioningServer: private NetworkProvisioningServer, private NetworkProvisioningDelegate
{
public:
MockNetworkProvisioningServer();
enum
{
kMaxScanResults = 4,
kMaxProvisionedNetworks = 10
};
NetworkInfo ScanResults[kMaxScanResults];
NetworkInfo ProvisionedNetworks[kMaxProvisionedNetworks];
uint32_t NextNetworkId;
WirelessRegConfig RegConfig;
WEAVE_ERROR Init(WeaveExchangeManager *exchangeMgr);
WEAVE_ERROR Shutdown();
void Reset();
void Preconfig();
protected:
union
{
uint8_t networkType;
PacketBuffer *networkInfoTLV;
uint32_t networkId;
uint8_t flags;
uint16_t rendezvousMode;
PacketBuffer *regConfigTLV;
} mOpArgs;
virtual WEAVE_ERROR HandleScanNetworks(uint8_t networkType);
virtual WEAVE_ERROR HandleAddNetwork(PacketBuffer *networkInfoTLV);
virtual WEAVE_ERROR HandleUpdateNetwork(PacketBuffer *networkInfoTLV);
virtual WEAVE_ERROR HandleRemoveNetwork(uint32_t networkId);
virtual WEAVE_ERROR HandleGetNetworks(uint8_t flags);
virtual WEAVE_ERROR HandleEnableNetwork(uint32_t networkId);
virtual WEAVE_ERROR HandleDisableNetwork(uint32_t networkId);
virtual WEAVE_ERROR HandleTestConnectivity(uint32_t networkId);
virtual WEAVE_ERROR HandleSetRendezvousMode(uint16_t rendezvousMode);
virtual WEAVE_ERROR HandleGetWirelessRegulatoryConfig(void);
virtual WEAVE_ERROR HandleSetWirelessRegulatoryConfig(PacketBuffer* regConfigTLV);
virtual void EnforceAccessControl(nl::Weave::ExchangeContext *ec, uint32_t msgProfileId, uint8_t msgType,
const nl::Weave::WeaveMessageInfo *msgInfo, AccessControlResult& result);
virtual bool IsPairedToAccount() const;
void CompleteOrDelayCurrentOp(const char *opName);
void CompleteCurrentOp();
WEAVE_ERROR CompleteScanNetworks(uint8_t networkType);
WEAVE_ERROR CompleteAddNetwork(PacketBuffer *networkInfoTLV);
WEAVE_ERROR CompleteUpdateNetwork(PacketBuffer *networkInfoTLV);
WEAVE_ERROR CompleteRemoveNetwork(uint32_t networkId);
WEAVE_ERROR CompleteGetNetworks(uint8_t flags);
WEAVE_ERROR CompleteEnableNetwork(uint32_t networkId);
WEAVE_ERROR CompleteDisableNetwork(uint32_t networkId);
WEAVE_ERROR CompleteTestConnectivity(uint32_t networkId);
WEAVE_ERROR CompleteSetRendezvousMode(uint16_t rendezvousMode);
WEAVE_ERROR CompleteGetWirelessRegulatoryConfig(void);
WEAVE_ERROR CompleteSetWirelessRegulatoryConfig(PacketBuffer* regConfigTLV);
virtual WEAVE_ERROR SendStatusReport(uint32_t statusProfileId, uint16_t statusCode, WEAVE_ERROR sysError = WEAVE_NO_ERROR);
WEAVE_ERROR ValidateNetworkConfig(NetworkInfo& netConfig);
static void PrintNetworkInfo(NetworkInfo& netInfo, const char *prefix);
static void PrintWirelessRegConfig(WirelessRegConfig& regConfig, const char *prefix);
static void HandleOpDelayComplete(nl::Weave::System::Layer* lSystemLayer, void* aAppState, nl::Weave::System::Error aError);
};
#endif /* MOCKNPSERVER_H_ */
|
3d072bf32419eef11255e3978b16579f18c53da1
|
684dae01b042726405044d6c74e1a3f544be5db2
|
/Tracker/Platform.cpp
|
e64a7796b954094001187a895b98e4a29794ef3a
|
[] |
no_license
|
AiYong/Tracer
|
08eca878fd62b98543c5a1f4840a330f1b1a722e
|
c06ebac0425cfc85668ec6aed9b6610a920572e6
|
refs/heads/master
| 2021-01-13T14:29:09.318773
| 2016-05-12T07:48:21
| 2016-05-12T07:48:21
| 54,728,502
| 0
| 1
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 2,129
|
cpp
|
Platform.cpp
|
#include "Platform.h"
AccountInfo::AccountInfo(double dAvailableMargin, const QList<Instrument *> &lInstrument, const QMap<QString, PositionCost *> &hPositionCost)
:m_dAvailableMargin(dAvailableMargin),m_lInstrument(lInstrument),m_hPositionCost(hPositionCost)
{
}
AccountInfo::~AccountInfo()
{
}
double AccountInfo::GetAvailableMargin() const
{
return m_dAvailableMargin;
}
QList<Instrument*> const& AccountInfo::GetInstruments() const
{
return m_lInstrument;
}
QMap<QString,PositionCost*> const& AccountInfo::GetPositionCost() const
{
return m_hPositionCost;
}
Platform::Platform()
{
}
Platform::~Platform()
{
}
shared_ptr<OrderProcessor> Platform::GetOrderProcessor(Account const*pAccount,bool bCreateIfNotExist)
{
shared_ptr<OrderProcessor> pResult;
if(m_mOrderProcessor.contains(pAccount->GetName()))
{
pResult = m_mOrderProcessor[pAccount->GetName()];
}
if(pResult == nullptr && bCreateIfNotExist)
{
pResult = CreateOrderProcessor(pAccount);
m_mOrderProcessor.insert(pAccount->GetID(),pResult);
}
return pResult;
}
shared_ptr<OrderSubscriber> Platform::GetOrderSubscriber(Account const*pAccount,bool bCreateIfNotExist)
{
shared_ptr<OrderSubscriber> pResult;
if(m_mOrderSubscriber.contains(pAccount->GetID()))
{
pResult = m_mOrderSubscriber[pAccount->GetID()];
}
if(pResult == nullptr && bCreateIfNotExist)
{
pResult = CreateOrderSubsriber(pAccount);
m_mOrderSubscriber.insert(pAccount->GetID(),pResult);
}
return pResult;
}
shared_ptr<MarketDataSubscriber> Platform::GetMarketDataSubscriber(Account const*pAccount,bool bCreateIfNotExist)
{
shared_ptr<MarketDataSubscriber> pResult;
if(m_mMarketDataSubscriber.contains(pAccount->GetID()))
{
pResult = m_mMarketDataSubscriber[pAccount->GetID()];
}
if(pResult == nullptr && bCreateIfNotExist)
{
pResult = CreateMarketDataSubscriber(pAccount);
m_mMarketDataSubscriber.insert(pAccount->GetID(),pResult);
}
return pResult;
}
QString Platform::GetLastError() const
{
return m_strError;
}
|
76539ff9192e8d4cd9194bdb909a55dcf4d96788
|
2d3cbf5933567ce3c3dcb8f004f1571067742f87
|
/libgraph/include/katana/analytics/matrix_completion/matrix_completion.h
|
4af6cb8036c865794fc1bb848774b8254cef358b
|
[
"BSD-3-Clause",
"LicenseRef-scancode-warranty-disclaimer"
] |
permissive
|
KatanaGraph/katana
|
9de617944264873198ec7db5ed022d356b1a529a
|
350b6606da9c52bc82ff80f64ffdde8c4bfdacce
|
refs/heads/master
| 2022-06-24T02:50:16.426847
| 2022-03-29T12:23:22
| 2022-03-29T12:23:22
| 310,108,707
| 85
| 83
|
NOASSERTION
| 2023-08-09T00:07:55
| 2020-11-04T20:19:01
|
C++
|
UTF-8
|
C++
| false
| false
| 4,910
|
h
|
matrix_completion.h
|
#ifndef KATANA_LIBGRAPH_KATANA_ANALYTICS_MATRIXCOMPLETION_MATRIXCOMPLETION_H_
#define KATANA_LIBGRAPH_KATANA_ANALYTICS_MATRIXCOMPLETION_MATRIXCOMPLETION_H_
#include <fstream>
#include <iostream>
#include "katana/Properties.h"
#include "katana/PropertyGraph.h"
#include "katana/analytics/Plan.h"
namespace katana::analytics {
/// A computational plan to for MatrixCompletion, specifying the algorithm and any parameters
/// associated with it.
class MatrixCompletionPlan : public Plan {
public:
enum Algorithm {
kSGDByItems,
};
enum Step { kBold, kBottou, kIntel, kInverse, kPurdue };
static constexpr double kDefaultLearningRate = 0.012;
static constexpr double kDefaultDecayRate = 0.015;
static constexpr double kDefaultLambda = 0.05;
static constexpr double kDefaultTolerance = 0.01;
static constexpr bool kDefaultUseSameLatentVector = false;
static constexpr uint32_t kDefaultMaxUpdates = 100;
static constexpr uint32_t kDefaultUpdatesPerEdge = 1;
static constexpr uint32_t kDefaultFixedRounds = 0;
static constexpr bool kDefaultUseExactError = false;
static constexpr bool kDefaultUseDetInit = false;
static constexpr Step kDefaultLearningRateFunction = kBold;
private:
Algorithm algorithm_;
double learning_rate_;
double decay_rate_;
double lambda_;
double tolerance_;
bool use_same_latent_vector_;
uint32_t max_updates_;
uint32_t updates_per_edge_;
uint32_t fixed_rounds_;
bool use_exact_error_;
bool use_det_init_;
Step learning_rate_function_;
MatrixCompletionPlan(
Architecture architecture, Algorithm algorithm, double learning_rate,
double decay_rate, double lambda, double tolerance,
bool use_same_latent_vector, uint32_t max_updates,
uint32_t updates_per_edge, uint32_t fixed_rounds, bool use_exact_error,
bool use_det_init, Step learning_rate_function)
: Plan(architecture),
algorithm_(algorithm),
learning_rate_(learning_rate),
decay_rate_(decay_rate),
lambda_(lambda),
tolerance_(tolerance),
use_same_latent_vector_(use_same_latent_vector),
max_updates_(max_updates),
updates_per_edge_(updates_per_edge),
fixed_rounds_(fixed_rounds),
use_exact_error_(use_exact_error),
use_det_init_(use_det_init),
learning_rate_function_(learning_rate_function) {}
public:
MatrixCompletionPlan()
: MatrixCompletionPlan{
kCPU,
kSGDByItems,
kDefaultLearningRate,
kDefaultDecayRate,
kDefaultLambda,
kDefaultTolerance,
kDefaultUseSameLatentVector,
kDefaultMaxUpdates,
kDefaultUpdatesPerEdge,
kDefaultFixedRounds,
kDefaultUseExactError,
kDefaultUseDetInit,
kDefaultLearningRateFunction} {}
Algorithm algorithm() const { return algorithm_; }
double learningRate() const { return learning_rate_; }
double decayRate() const { return decay_rate_; }
double lambda() const { return lambda_; }
double tolerance() const { return tolerance_; }
bool useSameLatentVector() const { return use_same_latent_vector_; }
uint32_t maxUpdates() const { return max_updates_; }
uint32_t updatesPerEdge() const { return updates_per_edge_; }
uint32_t fixedRounds() const { return fixed_rounds_; }
bool useExactError() const { return use_exact_error_; }
bool useDetInit() const { return use_det_init_; }
Step learningRateFunction() const { return learning_rate_function_; }
static MatrixCompletionPlan SGDByItems(
double learning_rate = kDefaultLearningRate,
double decay_rate = kDefaultDecayRate, double lambda = kDefaultLambda,
double tolerance = kDefaultTolerance,
bool use_same_latent_vector = kDefaultUseSameLatentVector,
uint32_t max_updates = kDefaultMaxUpdates,
uint32_t updates_per_edge = kDefaultUpdatesPerEdge,
uint32_t fixed_rounds = kDefaultFixedRounds,
bool use_exact_error = kDefaultUseExactError,
bool use_det_init = kDefaultUseDetInit,
Step learning_rate_function = kDefaultLearningRateFunction) {
return {
kCPU,
kSGDByItems,
learning_rate,
decay_rate,
lambda,
tolerance,
use_same_latent_vector,
max_updates,
updates_per_edge,
fixed_rounds,
use_exact_error,
use_det_init,
learning_rate_function};
}
};
/// Performs matrix completion using stochastic gradient descent (SGD) algortihm
/// on a bipartite graph and learns latent vectors for each node that is stored in
/// an ArrayProperty.
/// The plan controls the algorithm and parameters used to compute the latent vectors.
KATANA_EXPORT Result<void> MatrixCompletion(
katana::PropertyGraph* pg, katana::TxnContext* txn_ctx,
MatrixCompletionPlan plan = {});
} // namespace katana::analytics
#endif
|
30c2b5f1111f8911bfd872634ff1802b16cfcc2c
|
049e35db51719064ef5e6a2f386145ed9ca1e6d1
|
/example/Ex_GPIO.ino
|
59e0f4cafe6ae8aef2ca1bce41796ec394460125
|
[] |
no_license
|
gravitech-engineer/KB_Chain_Keypad
|
138e11f93651fb7034c78b4c19204e096a2eb396
|
3850e9c481dc31b03cc0ebe0d864abafff4a246b
|
refs/heads/master
| 2020-04-19T08:35:49.550097
| 2019-03-20T01:26:33
| 2019-03-20T01:26:33
| 168,082,713
| 0
| 0
| null | 2019-03-20T01:26:35
| 2019-01-29T03:29:48
|
C++
|
UTF-8
|
C++
| false
| false
| 389
|
ino
|
Ex_GPIO.ino
|
#include "KB_Keypad.h"
KB_Chain_4x4_Keypad key;
void setup() {
key.begin(0x20); // Setting address default 0x20 OR 0x21
Serial.begin(9600);
Serial.println("I/O Start");
}
void loop() {
key.digitalWrite(1, HIGH); // PIN 1 is HIGH
delay(250);
key.digitalWrite(1, LOW); // PIN 1 is LOW
delay(250);
}
|
dbc3d5ecbe1b149f431e734ef5baa00f6939aef0
|
f2767f0ff4333d5bc5035f1d5abb7aa5388569f0
|
/MyForm.cpp
|
62c4a8989d81f1c5ca81395a8bd16917fc798361
|
[] |
no_license
|
I-vac/Transportation-Hub
|
a77144a41200755e264b7baab8f2b5e56fd58728
|
387e23671875422ad5f979dd59ced898efbea7f0
|
refs/heads/master
| 2023-04-22T16:20:00.180215
| 2021-05-19T19:54:37
| 2021-05-19T19:54:37
| 368,664,247
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 188
|
cpp
|
MyForm.cpp
|
#include "MyForm.h"
using namespace System;
using namespace System::Windows::Forms;
[STAThread]
int main() {
TransporthubFINAL::MyForm Form;
Form.ShowDialog();
return 0;
}
|
1d74ab740102bc67d6ddfb8fbdcd4db3ef279fa8
|
88ae8695987ada722184307301e221e1ba3cc2fa
|
/buildtools/third_party/libc++/trunk/benchmarks/stringstream.bench.cpp
|
828ef4b405f47aca94622566abc0ea9e232895ab
|
[
"NCSA",
"LLVM-exception",
"MIT",
"Apache-2.0",
"BSD-3-Clause"
] |
permissive
|
iridium-browser/iridium-browser
|
71d9c5ff76e014e6900b825f67389ab0ccd01329
|
5ee297f53dc7f8e70183031cff62f37b0f19d25f
|
refs/heads/master
| 2023-08-03T16:44:16.844552
| 2023-07-20T15:17:00
| 2023-07-23T16:09:30
| 220,016,632
| 341
| 40
|
BSD-3-Clause
| 2021-08-13T13:54:45
| 2019-11-06T14:32:31
| null |
UTF-8
|
C++
| false
| false
| 946
|
cpp
|
stringstream.bench.cpp
|
#include "benchmark/benchmark.h"
#include "test_macros.h"
#include <sstream>
TEST_NOINLINE double istream_numbers();
double istream_numbers() {
const char *a[] = {
"-6 69 -71 2.4882e-02 -100 101 -2.00005 5000000 -50000000",
"-25 71 7 -9.3262e+01 -100 101 -2.00005 5000000 -50000000",
"-14 53 46 -6.7026e-02 -100 101 -2.00005 5000000 -50000000"
};
int a1, a2, a3, a4, a5, a6, a7;
double f1 = 0.0, f2 = 0.0, q = 0.0;
for (int i=0; i < 3; i++) {
std::istringstream s(a[i]);
s >> a1
>> a2
>> a3
>> f1
>> a4
>> a5
>> f2
>> a6
>> a7;
q += (a1 + a2 + a3 + a4 + a5 + a6 + a7 + f1 + f2)/1000000;
}
return q;
}
static void BM_Istream_numbers(benchmark::State &state) {
double i = 0;
while (state.KeepRunning())
benchmark::DoNotOptimize(i += istream_numbers());
}
BENCHMARK(BM_Istream_numbers)->RangeMultiplier(2)->Range(1024, 4096);
BENCHMARK_MAIN();
|
95381d32f8697c0fd31f8d9af75b7de8562a5c12
|
9160d5980d55c64c2bbc7933337e5e1f4987abb0
|
/solver/src/sgpp/solver/sle/fista/RegularizationFunction.hpp
|
2bdc20851e37620e94d334c84f4de956309a45c1
|
[
"LicenseRef-scancode-generic-exception",
"BSD-3-Clause"
] |
permissive
|
SGpp/SGpp
|
55e82ecd95ac98efb8760d6c168b76bc130a4309
|
52f2718e3bbca0208e5e08b3c82ec7c708b5ec06
|
refs/heads/master
| 2022-08-07T12:43:44.475068
| 2021-10-20T08:50:38
| 2021-10-20T08:50:38
| 123,916,844
| 68
| 44
|
NOASSERTION
| 2022-06-23T08:28:45
| 2018-03-05T12:33:52
|
C++
|
UTF-8
|
C++
| false
| false
| 1,149
|
hpp
|
RegularizationFunction.hpp
|
// Copyright (C) 2008-today The SG++ project
// This file is part of the SG++ project. For conditions of distribution and
// use, please see the copyright notice provided with SG++ or at
// sgpp.sparsegrids.org
#ifndef NONSMOOTHFUNCTION_HPP
#define NONSMOOTHFUNCTION_HPP
#include <sgpp/base/datatypes/DataVector.hpp>
#include <sgpp/base/operation/hash/OperationMultipleEval.hpp>
namespace sgpp {
namespace solver {
/**
* @brief The RegularizationFunction class is a baseclass for regularization functions
* that can be used in conjunction with a proximal solver.
*/
class RegularizationFunction {
public:
virtual ~RegularizationFunction() {}
/**
* @brief eval evaluates the regularization function for weights.
* @param weights
*/
virtual double eval(base::DataVector weights) = 0;
/**
* @brief prox evaluates the proximal operator for the function for weights.
* @param weights
* @param stepsize is the stepsize used for the proximal step
*/
virtual base::DataVector prox(const base::DataVector& weights, double stepsize) = 0;
};
} // namespace solver
} // namespace sgpp
#endif // NONSMOOTHFUNCTION_HPP
|
bfae1de1f0f48f17a277cccd7d8334a4ef6e1818
|
41434498606d4061c90663ada78de55085c32931
|
/Comparison/include/feature_matching.hpp
|
00406c3890abd229af13072f0a7c87079c12f6a4
|
[
"MIT"
] |
permissive
|
vvoZokk/object-detecting
|
5e749e3c279830bc9946d7e9514cd6ec013b9b29
|
809ee719f32a12731fa12870acac5223e5ba99bb
|
refs/heads/master
| 2020-05-20T12:26:31.823346
| 2017-02-01T09:03:51
| 2017-06-08T19:08:20
| 80,468,407
| 1
| 1
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 668
|
hpp
|
feature_matching.hpp
|
//
// Comparison of object detection methods
// FeatureMatching class header file
#ifndef INCLUDE_FEATURE_MATCHING_HPP
#define INCLUDE_FEATURE_MATCHING_HPP
#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/features2d/features2d.hpp>
#include <opencv2/calib3d/calib3d.hpp>
#include <opencv2/nonfree/nonfree.hpp>
#include "method.hpp"
class FeatureMatching : public Method {
protected:
cv::Mat descriptors_object, descriptors_image;
public:
FeatureMatching();
~FeatureMatching();
void setImages(cv::Mat image, cv::Mat object, cv::Point *answer);
void setThreshold(double value);
float recognize(int parameter);
};
#endif // INCLUDE_FEATURE_MATCHING_HPP
|
01e10813a43ef0771040d469ee8cc023b04449f1
|
e04f52ed50f42ad255c66d7b6f87ba642f41e125
|
/appseed/aura/aura/os/metrowin/metrowin_user.cpp
|
0426047fa0c1433d4769d9cde9da74a1f63f7213
|
[] |
no_license
|
ca2/app2018
|
6b5f3cfecaa56b0e8c8ec92ed26e8ce44f9b44c0
|
89e713c36cdfb31329e753ba9d7b9ff5b80fe867
|
refs/heads/main
| 2023-03-19T08:41:48.729250
| 2018-11-15T16:27:31
| 2018-11-15T16:27:31
| 98,031,531
| 3
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,886
|
cpp
|
metrowin_user.cpp
|
#include "framework.h"
//#include "metrowin.h"
CLASS_DECL_AURA WINBOOL GetCursorPos(LPPOINT lppoint);
CLASS_DECL_AURA int_bool ui_get_cursor_pos(POINT * ppt)
{
if (ppt == NULL)
return FALSE;
int_bool iRet = FALSE;
point ptCursor;
::wait(Windows::ApplicationModel::Core::CoreApplication::MainView->CoreWindow->Dispatcher->RunAsync(Windows::UI::Core::CoreDispatcherPriority::Normal, ref new Windows::UI::Core::DispatchedHandler([=, &ptCursor, &iRet]()
{
try
{
iRet = ::GetCursorPos(&ptCursor);
}
catch (...)
{
}
})));
if (iRet != FALSE)
{
*ppt = ptCursor;
}
return iRet;
}
extern int g_iMouse;
CLASS_DECL_AURA WINBOOL GetCursorPos(LPPOINT lppoint)
{
lppoint->x = 0;
lppoint->y = 0;
if (g_iMouse < 0)
return FALSE;
::wait(Windows::ApplicationModel::Core::CoreApplication::MainView->CoreWindow->Dispatcher->RunAsync(::Windows::UI::Core::CoreDispatcherPriority::Normal,
ref new Windows::UI::Core::DispatchedHandler([lppoint]()
{
Windows::Foundation::Collections::IVectorView < Windows::Devices::Input::PointerDevice ^ > ^ deva = ::Windows::Devices::Input::PointerDevice::GetPointerDevices();
for (unsigned int ui = 0; ui < deva->Size; ui++)
{
Windows::Devices::Input::PointerDevice ^ dev = deva->GetAt(ui);
if (dev->PointerDeviceType == ::Windows::Devices::Input::PointerDeviceType::Mouse)
{
Windows::UI::Input::PointerPoint ^ pointerPoint = Windows::UI::Input::PointerPoint::GetCurrentPoint(g_iMouse);
lppoint->x = (LONG)pointerPoint->RawPosition.X;
lppoint->y = (LONG)pointerPoint->RawPosition.Y;
}
}
})));
return TRUE;
}
CLASS_DECL_AURA void defer_dock_application(bool bDock)
{
UNREFERENCED_PARAMETER(bDock);
}
|
179f97bd866d7b1256bef9dd57b67666d8dc069d
|
abf573a66e8d30b3b24a7de232d877769f3ccd67
|
/OpenCLRaytracerModule/OpenCLRaytracerModuleStub.cpp
|
eaeeba4960a9275dababbe60b7055b64e229de69
|
[] |
no_license
|
cyrillefavreau/OpenCLRaytracer
|
e538506905b6f5bd1f1fb73e12c359c4a675fd0a
|
3818a134e4b999b3314a1964697ce6cba99e7851
|
refs/heads/master
| 2021-01-10T19:22:28.100442
| 2015-08-16T08:58:13
| 2015-08-16T08:58:13
| 40,805,475
| 10
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 8,734
|
cpp
|
OpenCLRaytracerModuleStub.cpp
|
/*
* OpenCL Raytracer
* Copyright (C) 2011-2012 Cyrille Favreau <cyrille_favreau@hotmail.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*
* Author: Cyrille Favreau <cyrille_favreau@hotmail.com>
*
*/
#include <windows.h>
#include "OpenCLRaytracerModuleStub.h"
#include <fstream>
#include "OpenCLKernel.h"
OpenCLKernel* oclKernel = 0;
// Global variables
int gImageWidth = 0;
int gImageHeight = 0;
bool gViewHasChanged = true;
BYTE* gRenderBitmap = 0;
double gTime = 0.0f;
// Gesture
cl_float gAngleX = 0.f;
cl_float gAngleY = 0.f;
cl_float gAngleZ = 0.f;
cl_float gDistance = 0.f;
// Textures
cl_float4 gEye;
cl_float4 gDir;
// --------------------------------------------------------------------------------
// Forward declarations
// --------------------------------------------------------------------------------
extern "C" void setTextureFilterMode(
bool bLinearFilter);
// --------------------------------------------------------------------------------
// Implementation
// --------------------------------------------------------------------------------
extern "C" OPENCLRAYTRACERMODULE_API
long RayTracer_CreateScene(
int platformId,
int deviceId,
char* kernelCode,
int width,
int height,
int nbPrimitives,
int nbLamps,
int nbMaterials,
int nbTextures,
int nbWorkingItems,
HANDLE& display,
HANDLE& kinect)
{
gImageWidth = width;
gImageHeight = height;
gRenderBitmap = new BYTE[width*height*gColorDepth];
gTime = 0.f;
oclKernel = new OpenCLKernel( platformId, deviceId, nbWorkingItems, 1 );
oclKernel->compileKernels( kst_string, kernelCode, "", "" );
oclKernel->initializeDevice( width, height, nbPrimitives, nbLamps, nbMaterials, nbTextures, gRenderBitmap );
gViewHasChanged = true;
display = gRenderBitmap; // Returns the rended bitmap to the caller
return 0;
}
// --------------------------------------------------------------------------------
extern "C" OPENCLRAYTRACERMODULE_API
long RayTracer_DeleteScene()
{
// kernel_finalizeOPENCL();
if( gRenderBitmap ) delete [] gRenderBitmap;
if( oclKernel ) delete oclKernel;
return 0;
}
// --------------------------------------------------------------------------------
extern "C" OPENCLRAYTRACERMODULE_API
void RayTracer_SetCamera(
double eye_x, double eye_y, double eye_z,
double dir_x, double dir_y, double dir_z,
double angle_x, double angle_y, double angle_z )
{
cl_float4 eye;
eye.s[0] = static_cast<cl_float>(eye_x);
eye.s[1] = static_cast<cl_float>(eye_y);
eye.s[2] = static_cast<cl_float>(eye_z + gDistance);
gDir.s[0] = static_cast<cl_float>(dir_x);
gDir.s[1] = static_cast<cl_float>(dir_y);
gDir.s[2] = static_cast<cl_float>(dir_z);
cl_float4 angles;
angles.s[0] = static_cast<cl_float>(angle_x + gAngleX);
angles.s[1] = static_cast<cl_float>(angle_y + gAngleY);
angles.s[2] = static_cast<cl_float>(angle_z + gAngleZ);
oclKernel->setCamera( eye, gDir, angles );
}
// --------------------------------------------------------------------------------
extern "C" OPENCLRAYTRACERMODULE_API
long RayTracer_RunKernel( double timer, double transparentColor )
{
oclKernel->render(
gImageWidth, gImageHeight,
gRenderBitmap,
static_cast<cl_float>(gTime),
static_cast<cl_float>(transparentColor) );
gTime += 0.1f;
return 0;
}
// --------------------------------------------------------------------------------
extern "C" OPENCLRAYTRACERMODULE_API
long RayTracer_AddPrimitive( int type )
{
return oclKernel->addPrimitive( type );
}
// --------------------------------------------------------------------------------
extern "C" OPENCLRAYTRACERMODULE_API
long RayTracer_SetPrimitive(
int index,
double center_x,
double center_y,
double center_z,
double width,
double height,
int materialId,
int materialPadding )
{
oclKernel->setPrimitive(
index,
static_cast<cl_float>(center_x),
static_cast<cl_float>(center_y),
static_cast<cl_float>(center_z),
static_cast<cl_float>(width),
static_cast<cl_float>(height),
materialId, materialPadding );
return 0;
}
extern "C" OPENCLRAYTRACERMODULE_API long RayTracer_RotatePrimitive(
int index,
double center_x,
double center_y,
double center_z)
{
oclKernel->rotatePrimitive(
index,
static_cast<cl_float>(center_x),
static_cast<cl_float>(center_y),
static_cast<cl_float>(center_z));
return 0;
}
extern "C" OPENCLRAYTRACERMODULE_API long RayTracer_SetPrimitiveMaterial(
int index,
int materialId)
{
oclKernel->setPrimitiveMaterial(
index,
materialId);
return 0;
}
// --------------------------------------------------------------------------------
extern "C" OPENCLRAYTRACERMODULE_API
long RayTracer_AddLamp()
{
return oclKernel->addLamp();
}
// --------------------------------------------------------------------------------
extern "C" OPENCLRAYTRACERMODULE_API
long RayTracer_SetLamp(
int index,
double center_x,
double center_y,
double center_z,
double intensity,
double color_r,
double color_g,
double color_b )
{
oclKernel->setLamp(
index,
static_cast<cl_float>(center_x), static_cast<cl_float>(center_y), static_cast<cl_float>(center_z),
static_cast<cl_float>(intensity),
static_cast<cl_float>(color_r), static_cast<cl_float>(color_g), static_cast<cl_float>(color_b) );
return 0;
}
// --------------------------------------------------------------------------------
extern "C" OPENCLRAYTRACERMODULE_API long RayTracer_UpdateSkeletons(
double center_x, double center_y, double center_z,
double size,
double radius, int materialId,
double head_radius, int head_materialId,
double hands_radius, int hands_materialId,
double feet_radius, int feet_materialId)
{
#if USE_KINECT
return oclKernel->updateSkeletons(
center_x, center_y, center_z,
size,
radius, materialId,
head_radius, head_materialId,
hands_radius, hands_materialId,
feet_radius, feet_materialId);
#else
return 0;
#endif // USE_KINECT
}
// --------------------------------------------------------------------------------
extern "C" OPENCLRAYTRACERMODULE_API long RayTracer_AddTexture( char* filename )
{
return oclKernel->addTexture( filename );
}
// --------------------------------------------------------------------------------
extern "C" OPENCLRAYTRACERMODULE_API long RayTracer_SetTexture( int index, HANDLE texture )
{
oclKernel->setTexture(
index,
static_cast<BYTE*>(texture) );
return 0;
}
// ---------- Materials ----------
extern "C" OPENCLRAYTRACERMODULE_API long RayTracer_AddMaterial()
{
return oclKernel->addMaterial();
}
extern "C" OPENCLRAYTRACERMODULE_API long RayTracer_SetMaterial(
int index,
double color_r,
double color_g,
double color_b,
double reflection,
double refraction,
int textured,
float transparency,
int textureId,
double specValue,
double specPower,
double specCoef,
double innerIllumination)
{
oclKernel->setMaterial(
index,
static_cast<cl_float>(color_r),
static_cast<cl_float>(color_g),
static_cast<cl_float>(color_b),
static_cast<cl_float>(reflection),
static_cast<cl_float>(refraction),
textured,
static_cast<cl_float>(transparency),
textureId,
static_cast<cl_float>(specValue),
static_cast<cl_float>(specPower),
static_cast<cl_float>(specCoef ),
static_cast<cl_float>(innerIllumination));
return 0;
}
|
8c64dc55d2953904302cc7a35471bff9e4cb3271
|
629b8cab0e6c45ff3f46e0180039610c323944e7
|
/particle.cc
|
ccfe4734c194af1b129cac34dab2f4bade6f2ebb
|
[
"MIT",
"Zlib"
] |
permissive
|
Acedio/ludumdare45
|
de73385505bdd4d8f2cd76d8940f6511bc8c3620
|
56bade6d977c21f25411fd6d1e1142539233dd8b
|
refs/heads/master
| 2020-08-07T04:43:02.572259
| 2019-10-18T05:01:48
| 2019-10-18T05:01:48
| 213,300,847
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 806
|
cc
|
particle.cc
|
#include "particle.h"
void ParticleManager::Add(const Particle& particle) {
particles.push_back(particle);
}
void ParticleManager::Update(double t) {
for (auto p = particles.begin(); p != particles.end(); ++p) {
p->vel.y += 50.0*t;
p->rect.x += p->vel.x*t;
p->rect.y += p->vel.y*t;
p->angle += p->rot_vel*t;
if (!Intersects(p->rect, bounds)) {
p->remove = true;
}
}
auto new_end = std::remove_if(particles.begin(), particles.end(),
[](const Particle& p) { return p.remove; });
if (new_end != particles.end()) {
particles.erase(new_end, particles.end());
}
}
void ParticleManager::Draw(SDL_Renderer* renderer) const {
for (const Particle& p : particles) {
p.sprite.DrawAngle(renderer, ToSDLRect(p.rect), p.angle);
}
}
|
5a93e8e0ad666cca5b7763053ba99b58967d8408
|
4e38faaa2dc1d03375010fd90ad1d24322ed60a7
|
/include/RED4ext/Scripting/Natives/Generated/game/InventoryListenerData_ItemAdded.hpp
|
b275a1aad28342b02024dfdb4aced42d28cbe55b
|
[
"MIT"
] |
permissive
|
WopsS/RED4ext.SDK
|
0a1caef8a4f957417ce8fb2fdbd821d24b3b9255
|
3a41c61f6d6f050545ab62681fb72f1efd276536
|
refs/heads/master
| 2023-08-31T08:21:07.310498
| 2023-08-18T20:51:18
| 2023-08-18T20:51:18
| 324,193,986
| 68
| 25
|
MIT
| 2023-08-18T20:51:20
| 2020-12-24T16:17:20
|
C++
|
UTF-8
|
C++
| false
| false
| 714
|
hpp
|
InventoryListenerData_ItemAdded.hpp
|
#pragma once
// clang-format off
// This file is generated from the Game's Reflection data
#include <cstdint>
#include <RED4ext/Common.hpp>
#include <RED4ext/Scripting/Natives/Generated/game/InventoryListenerData_Base.hpp>
namespace RED4ext
{
namespace game
{
struct InventoryListenerData_ItemAdded : game::InventoryListenerData_Base
{
static constexpr const char* NAME = "gameInventoryListenerData_ItemAdded";
static constexpr const char* ALIAS = NAME;
uint8_t unk38[0x50 - 0x38]; // 38
};
RED4EXT_ASSERT_SIZE(InventoryListenerData_ItemAdded, 0x50);
} // namespace game
using gameInventoryListenerData_ItemAdded = game::InventoryListenerData_ItemAdded;
} // namespace RED4ext
// clang-format on
|
71896298c3889c112a7f65871dc5211e35052b98
|
d087c4afcb7fc124ef5b720f2445a8b886574a3c
|
/horizslider.h
|
e2c7a92ea76f1c1194110d0d794be3b763fdcdad
|
[] |
no_license
|
FS-NulL/New-Quake-3-Particle-Studio
|
b489ad17a2a6961aa07302ba41fb1abe1a78b575
|
9d93f0896f8317fa216df341ace3fdeb61050b16
|
refs/heads/master
| 2016-09-11T07:06:36.901546
| 2012-11-17T17:59:09
| 2012-11-17T17:59:09
| 1,564,594
| 7
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,763
|
h
|
horizslider.h
|
#ifndef _HORIZ_SLIDER
#define _HORIZ_SLIDER
#include <windows.h>
#include <functional>
#include "basicstructs.h"
#include "baseEnt.h"
#include "label.h"
enum {
TYPE_FLOAT,
TYPE_INT
};
class horizSlider : public baseEnt
{
int sliderWidth;
int sliderPosition;
int leftValue;
int rightValue;
int intermediateValue;
int intermediatePosition;
bool useIntermediate;
bool active;
bool hoverActive;
RGBf bgColor;
RGBf sliderColor;
RGBf bgColor_active;
RGBf bgColor_hoverActive;
RGBf sliderColor_active;
RGBf sliderColor_hoverActive;
int calcValue();
int setValueIntern();
public:
std::function<void(int)> onChange;
//void (*onChange)(int);
int type;
//vec2D location;
//vec2D size;
int setLocation(int x, int y); // Return -1 when out of bounds?
int setSize(int x, int y); // Return -1 when error
int setSliderWidth(int x); // Return -1 on error
int setSliderPosition(int x); // Default Position, NOTE position on screen not value, also set value
int setValue(int v); // Must set sliderPosition Inside function, Return -1 on bounds error
int setValue_nochange(int v);
int setBounds(float left, float right); // Standard Linear interpolation
int setBounds(float left, float right, float inter); // 3 Point interpolation
int setIntermediatePosition(int x);
int setBgColor(float r, float g, float b);
int setSliderColor(float r, float g, float b);
int eventHandler(UINT message,WPARAM key,int mousex,int mousey);
int setOnChange(std::function<void(int)> p);
void setLabelName(char *s);
horizSlider();
~horizSlider();
int draw();
int forceUnActive();
int value;
bool useLabelName;
bool useLabelValue;
label l_name;
label l_value;
void setType(int t);
float getFloatValue();
int entType();
};
#endif // _HORIZ_SLIDER
|
7c7651a157c1cfc69c0c047190a10ebf95727385
|
4b250da9813bd51979b7211778f720c0757eb82e
|
/gcodejam/2021/quals/B/B.cpp
|
b747090e7ff69f743a62e25fca8c48900fba7a2c
|
[
"MIT"
] |
permissive
|
mathemage/CompetitiveProgramming
|
07f7d4c269cca0b89955518131b01d037a5a1597
|
11a1a57c6ed144201b58eaeb34248f560f18d250
|
refs/heads/master
| 2023-04-16T17:55:24.948628
| 2023-04-14T19:16:54
| 2023-04-14T19:16:54
| 26,391,626
| 2
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 5,690
|
cpp
|
B.cpp
|
/* ========================================
* File Name : B.cpp
* Creation Date : 26-03-2021
* Last Modified : Sat 27 Mar 2021 08:29:31 PM CET
* Created By : Karel Ha <mathemage@gmail.com>
* URL : https://codingcompetitions.withgoogle.com/codejam/round/000000000043580a/00000000006d1145
* Points/Time :
* 1h
* +1h19m10s = 2h19m10s :-/
*
* Total/ETA : 5+11+1pts ~40m
* Status :
* AC (the 2 visible testsets)
* + WA (hidden testset) :-/
*
==========================================*/
#include <algorithm>
#include <bits/stdc++.h>
#include <string>
using namespace std;
#define endl "\n"
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
#define ALL(A) (A).begin(), (A).end()
#define REVALL(A) (A).rbegin(), (A).rend()
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define MTP make_tuple
#define MINUPDATE(A,B) A = min((A), (B));
#define MAXUPDATE(A,B) A = max((A), (B));
#define SGN(X) ((X) ? ( (X)>0?1:-1 ) : 0)
#define CONTAINS(S,E) ((S).find(E) != (S).end())
#define SZ(x) ((int) (x).size())
#ifdef ONLINE_JUDGE
#undef MATHEMAGE_DEBUG
#endif
#ifdef MATHEMAGE_DEBUG
#define MSG(a) cerr << "> " << (#a) << ": " << (a) << endl;
#define MSG_VEC_VEC(v) cerr << "> " << (#v) << ":\n" << (v) << endl;
#define MSG_VEC_PAIRS(v) print_vector_pairs((v), (#v));
#define LINESEP1 cerr << "----------------------------------------------- " << endl;
#define LINESEP2 cerr << "_________________________________________________________________" << endl;
#else
#define MSG(a)
#define MSG_VEC_VEC(v)
#define MSG_VEC_PAIRS(v)
#define LINESEP1
#define LINESEP2
#endif
ostream& operator<<(ostream& os, const vector<string> & vec) {
os << endl;
for (const auto & s: vec) cerr << s << endl;
return os;
}
template<typename T>
ostream& operator<<(ostream& os, const vector<T> & vec) {
for (const auto & x: vec) os << x << " ";
return os;
}
template<typename T>
ostream& operator<<(ostream& os, const vector<vector<T>> & vec) {
for (const auto & v: vec) os << v << endl;
return os;
}
template<typename T>
ostream& operator<<(ostream& os, const set<T>& vec) {
os << "{ | ";
for (const auto & x: vec) os << x << "| ";
os << "}";
return os;
}
template<typename T1, typename T2>
void print_vector_pairs(const vector<pair<T1, T2>> & vec, const string & name) {
cerr << "> " << name << ": ";
for (const auto & x: vec) cerr << "(" << x.F << ", " << x.S << ")\t";
cerr << endl;
}
template<typename T>
inline bool bounded(const T & x, const T & u, const T & l=0) {
return min(l,u)<=x && x<max(l,u);
}
const int CLEAN = -1;
// const int UNDEF = -42;
const char UNDEF = '_';
const long long MOD = 1000000007;
const double EPS = 1e-8;
const int INF = INT_MAX;
const long long INF_LL = LLONG_MAX;
const long long INF_ULL = ULLONG_MAX;
const vector<int> DX4 = { 0, 0, -1, 1};
const vector<int> DY4 = {-1, 1, 0, 0};
const vector<pair<int,int>> DXY4 = { {0,-1}, {0,1}, {-1,0}, {1,0} };
const vector<int> DX8 = {-1, -1, -1, 0, 0, 1, 1, 1};
const vector<int> DY8 = {-1, 0, 1, -1, 1, -1, 0, 1};
const vector<pair<int,int>> DXY8 = {
{-1,-1}, {-1,0}, {-1,1},
{ 0,-1}, { 0,1},
{ 1,-1}, { 1,0}, { 1,1}
};
void solve() {
int x,y;
string s;
cin >> x >> y >> s;
MSG(s);
vector<string> options = {"CC", "JJ", "CJ", "JC"};
map<string, int> cost;
cost["CC"] = cost["JJ"] = 0;
cost["CJ"] = x; cost["JC"] = y;
map<string, char> prevChar;
// for (auto & opt: options) prevChar[opt]=UNDEF;
for (auto & opt: options) prevChar[opt]=opt[0];
map<string, int> deltas;
int n=s.size();
int result = 0;
int delta;
string key;
FOR(pos,1,n-1) {
LINESEP1;
// MSG(pos-1); MSG(pos);
MSG(s.substr(pos-1));
MSG(s[pos-1]); MSG(s[pos]);
if (s[pos]=='?') {
LINESEP1;
MSG(prevChar["CC"]) MSG(prevChar["JJ"]) MSG(prevChar["CJ"]) MSG(prevChar["JC"]);
if (s[pos-1]=='?') { // ??
for (auto & opt: {"CJ", "JC"} ) {
s[pos-1]=opt[0];
s[pos]=opt[1];
deltas[opt] += cost[s.substr(pos-1,2)];
prevChar[opt]^='C'^'J';
}
s[pos-1]='?';
} else { // C? or J?
for (auto & opt: options) {
s[pos]=opt[0];
deltas[opt] += cost[s.substr(pos-1,2)];
prevChar[opt]=opt[0];
}
}
s[pos]='?';
LINESEP1;
MSG(prevChar["CC"]) MSG(prevChar["JJ"]) MSG(prevChar["CJ"]) MSG(prevChar["JC"]);
MSG(deltas["CC"]) MSG(deltas["JJ"]) MSG(deltas["CJ"]) MSG(deltas["JC"]);
if (pos==n-1) {
result+=min( min(deltas["CC"], deltas["JJ"]), min(deltas["CJ"], deltas["JC"]) );
}
} else { // J or C
if (s[pos-1]=='?') { // ?C or ?J
MSG(prevChar["CC"]) MSG(prevChar["JJ"]) MSG(prevChar["CJ"]) MSG(prevChar["JC"]);
for (auto & opt: options) {
s[pos-1]=prevChar[opt];
deltas[opt] += cost[s.substr(pos-1,2)];
}
delta=min( min(deltas["CC"], deltas["JJ"]), min(deltas["CJ"], deltas["JC"]) );
MSG(deltas["CC"]) MSG(deltas["JJ"]) MSG(deltas["CJ"]) MSG(deltas["JC"])
deltas["CC"]=deltas["JJ"]=deltas["CJ"]=deltas["JC"]=0;
s[pos-1]='?';
} else {
delta=cost[s.substr(pos-1,2)];
}
MSG(delta);
result += delta;
}
MSG(result);
}
cout << result << endl;
}
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
int cases = 1;
cin >> cases;
REP(i,cases) {
cout << "Case #" << i+1 << ": ";
solve();
LINESEP2;
}
return 0;
}
|
cb32065c0481be0965b0bfcba96f1c0a86b04d40
|
e80018a14a349136e4d29b9e8ebb1a2b0eadd952
|
/3.BOJ/DP/10844 쉬운계단수.cpp
|
efaadb49b12888e8c7ea51281f11aed45c88de05
|
[] |
no_license
|
HenryNoh/Coding-Test
|
9a857df974dcce54488083d531365ecde93b14ec
|
a65e09fa611f2b1db18cb5950e5e2ce84f998bdc
|
refs/heads/master
| 2023-04-26T09:40:00.599140
| 2021-05-13T05:07:41
| 2021-05-13T05:07:41
| 347,883,090
| 0
| 0
| null | null | null | null |
UHC
|
C++
| false
| false
| 964
|
cpp
|
10844 쉬운계단수.cpp
|
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#define _CRT_SECURE_NO_WARNINGS
long DP[101][11]; //100까지 받을수 있고 0~9 까지 10개 이므로 100*10 2차원배열 설정
int compare(int a, int b) {
return (a <= b) ? a : b;
}
int main(void) {
int num, i;
long sum;
scanf("%d", &num);
for (i = 1; i <= 9; i++) { //입력 받은 수가 1자리 일 경우 DP의 첫 배열은 1로 초기화
DP[1][i] = 1;
}
for (i = 2; i <= num; i++) { //입력 받은 수가 2자리 이상 일 경우
DP[i][0] = DP[i - 1][1]; //끝자리가 0인 경우는 이전 DP배열의 1번째와 같음 0은 1로부터만 옴
for (int j = 1; j <= 9; j++) { // 끝자리가 1~9인 경우 이전 DP배열의 양옆의 합과 같음
DP[i][j] = (DP[i - 1][j - 1] + DP[i - 1][j + 1]) % 1000000000;
}
}
sum = 0;
for (i = 0; i < 10; i++) { //최종 DP배열의 각 자리수 합
sum += DP[num][i];
}
printf("%d\n", sum % 1000000000);
return 0;
}
|
54c957dbd68c2b09640c6859b4a98b3c776a8111
|
54f62e14405fb25bae9c88e4767944a1d75dec2e
|
/files/asobiba/Banana/RGISSmallKoudo.h
|
3366b5631aa7f2d52bd210f97d522bfa111ac379
|
[] |
no_license
|
Susuo/rtilabs
|
408975914dde59f44c1670ce3db663ed785d00b2
|
822a39d1605de7ea2639bdffdc016d8cc46b0875
|
refs/heads/master
| 2020-12-11T01:48:08.562065
| 2012-04-10T14:22:37
| 2012-04-10T14:22:37
| null | 0
| 0
| null | null | null | null |
SHIFT_JIS
|
C++
| false
| false
| 1,311
|
h
|
RGISSmallKoudo.h
|
// RGISSmallKoudo.h: RGISSmallKoudo クラスのインターフェイス
//
//////////////////////////////////////////////////////////////////////
#if !defined(AFX_RGISSMALLKOUDO_H__64951FB0_C1D4_4A71_8A91_CDEC65DDF919__INCLUDED_)
#define AFX_RGISSMALLKOUDO_H__64951FB0_C1D4_4A71_8A91_CDEC65DDF919__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#include "comm.h"
#include "RGISSmallType.h"
#include "RException.h"
#include "RGISSmallDraw.h"
#include "RGISSmallDrawEffect.h"
#include "RGISAllTest.h"
struct SmallKoudoData
{
unsigned char Level;
RGISSmallType CV;
};
class RGISSmallKoudo
{
friend class RGISAllTest; //テストクラスがこいつの中をいじりまわせるように.
public:
RGISSmallKoudo();
virtual ~RGISSmallKoudo();
void Create(unsigned long inBlock , unsigned long inDataSize ,unsigned long inDataCount ,char* ioBuffer) throw(RException);
//線/点の描画
void Draw1(const RGISSmallDraw *inDraw);
//塗りつぶし
void Draw2(const RGISSmallDraw *inDraw);
void Delete();
private:
COLORREF selectColor(unsigned char inShubetsu) const;
COLORREF selectSize(unsigned char inShubetsu) const;
private:
SmallKoudoData* Points;
int Count;
};
#endif // !defined(AFX_RGISSMALLKOUDO_H__64951FB0_C1D4_4A71_8A91_CDEC65DDF919__INCLUDED_)
|
e88529c105a17af5b5dbf38506249f2475f4fbea
|
566832512dfbde99226261612bbb74b9a8c7cc38
|
/Extra Credit/extraHashing/has.cpp
|
3bceb5cc381d84c40cdf6a5417b7330ac463552e
|
[] |
no_license
|
vyas0189/COSC-2430
|
ee15c20eab38ea63acc9256c2aada423e88d5274
|
b896ce8979fdb8ffe2b4eceaaf21b4d0b0c128d2
|
refs/heads/master
| 2021-09-19T19:58:10.633433
| 2018-07-31T13:26:13
| 2018-07-31T13:26:13
| 132,435,637
| 1
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,503
|
cpp
|
has.cpp
|
#include <iostream>
#include <List>
#include <ctime>
#include<chrono>
#include "List.h"
using namespace std;
class Hash
{
int BUCKET; // No. of buckets
// Pointer to an array containing buckets
List *table;
public:
Hash(int V); // Constructor
// inserts a key into hash table
void insertItem(int x);
// hash function to map values to key
int hashFunction(int x)
{
return (x % BUCKET);
}
void displayHash();
void searchKey(int key);
};
Hash::Hash(int b)
{
this->BUCKET = b;
table = new List[BUCKET];
}
void Hash::insertItem(int key)
{
int index = hashFunction(key);
table[index].push_back(key);
}
void Hash::displayHash()
{
for (int i = 0; i < BUCKET; i++)
{
cout << i << ": ";
table[i].display();
cout << endl;
}
}
void Hash::searchKey(int key){
int index = hashFunction(key);
int itemLoc = table[index].getLoc(key);
if(itemLoc != -1){
cout<<"The value: '"<<key<<"' is found in List: "
<<index<<" Location: "<< itemLoc <<endl;
}
else{
cout<<"The item can't be found in the list"<<endl;
}
}
// Driver program
int main()
{
srand(time(NULL));
Hash h(10);
int ran = 0;
for (int i = 0; i < 100; i++)
{
ran = rand() % 101;
h.insertItem(ran);
}
h.displayHash();
int n;
cout << "Enter a number to look for : ";
cin >> n;
h.searchKey(n);
return 0;
}
|
6897846a31c130b5b00561de01793445b31f351a
|
193d4e8887201414cc9d46b7c68493bf6c6f072e
|
/cbmc_bounds_check_unbounded_loop_using_assumptions/main.cc
|
77e8025a7543cb0854cb0846d86594bc344575fd
|
[] |
no_license
|
mateuskl/cpp
|
8fd2ec9cd257f380f0ba26e42d58e1abd84cbdcf
|
e581ddab2e36ed224f9749b14a08f884035fbe29
|
refs/heads/master
| 2021-01-01T15:30:10.583424
| 2015-05-08T21:05:01
| 2015-05-08T21:05:01
| 4,272,151
| 0
| 1
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 344
|
cc
|
main.cc
|
#ifndef CBMC
#include <cassert>
#include <iostream>
using namespace std;
#endif
int main(int argc, char **argv)
{
#ifndef CBMC
cout << argv[1] << "," << argv[2] << endl;
#endif
int dec[10];
int m = (int) argv[1];
__CPROVER_assume(m < 10);
for(int i = 0; i < m; i++)
{
dec[i] = i;
}
return 0;
}
|
2dc65778a465dbf3e04ae0cf9ea9597416583f68
|
07edc5c9cb2c598a581ea476d816761596ec2040
|
/addons/tm_rhs_extra_content/CfgWeapons.hpp
|
da2b496954761075fe4952450cdfe26aca45b63e
|
[] |
no_license
|
Sniperhid/1tac_misc
|
c0e8e67ba67eba522d2983a8c6c3032082eaa23d
|
b463578bc335edcfa07f199c9b4ea37e598e37b6
|
refs/heads/master
| 2023-04-28T18:42:48.522316
| 2023-04-21T17:17:44
| 2023-04-21T17:17:44
| 66,861,199
| 12
| 36
| null | 2023-04-26T18:14:35
| 2016-08-29T16:37:09
|
C++
|
UTF-8
|
C++
| false
| false
| 231
|
hpp
|
CfgWeapons.hpp
|
class CfgWeapons {
class ItemCore;
#include "CfgWeapons_ak74m.hpp"
#include "CfgWeapons_hgu56p.hpp"
#include "CfgWeapons_mich.hpp"
#include "CfgWeapons_plateframe.hpp"
#include "CfgWeapons_usm.hpp"
};
|
2d2e0a10caf342ff6494ebc7f6b59db21982f03d
|
d54259e11b684c4124723376c1485b99e387a5e0
|
/pointerExamle/PointerArithmatic.cpp
|
273f98f131811fb2441dfa5a6fb4462e299f4f08
|
[] |
no_license
|
Saurabh-12/learn_cpp
|
754e5f1efdfe021beaf7425f9b1592cae58fd19e
|
805c0b2131481ac14bd1510868a638040ae1e605
|
refs/heads/master
| 2022-03-06T12:39:44.456471
| 2022-02-28T17:16:58
| 2022-02-28T17:16:58
| 116,156,269
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,068
|
cpp
|
PointerArithmatic.cpp
|
#include<iostream>
int main()
{
int value = 7;
int *ptr = &value;
std::cout << ptr << '\n';
std::cout << ptr+1 << '\n';
std::cout << ptr+2 << '\n';
std::cout << ptr+3 << '\n';
int array [5] = { 9, 7, 5, 3, 1 };
std::cout << &array[1] << '\n'; // print memory address of array element 1
std::cout << array+1 << '\n'; // print memory address of array pointer + 1
std::cout << array[1] << '\n'; // prints 7
std::cout << *(array+1) << '\n'; // prints 7 (note the parenthesis required here)
int array2[] = { 8, 4, 9, 7, 1 };
std::cout << "Element 0 is at address: " << &array2[0] << '\n';
std::cout << "Element 1 is at address: " << &array2[1] << '\n';
std::cout << "Element 2 is at address: " << &array2[2] << '\n';
std::cout << "Element 3 is at address: " << &array2[3] << '\n';
std::cout << "Element 0 is at address: "<<array2<<"\n";
std::cout << "Element 1 is at address: "<<(array2+1)<<"\n";
std::cout << "Element 2 is at address: "<<(array2+2)<<"\n";
return 0;
}
|
39a028a00117a85c69f97794b695e37704501fd8
|
3582dd2dad0ce85ee694536018c48806e215d529
|
/Zombies/Event.cpp
|
7b4608e07e2b785e71e06d195f717f6ae00a50c9
|
[] |
no_license
|
Benner727/ZombieSquares
|
1ab9001a32502ff780a5128adb487f2626033728
|
88597d9721de7940cf1eeb0c12e15c78553b6e2e
|
refs/heads/master
| 2022-01-12T07:43:09.268621
| 2019-05-19T15:25:01
| 2019-05-19T15:25:01
| 187,494,141
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 573
|
cpp
|
Event.cpp
|
#include "Event.h"
Event::Event(Map* map, Vector2 pos, float rotation)
: Actor(map)
{
mTimer = Timer::Instance();
mAudio = AudioManager::Instance();
mLifeTimer = 10.0f;
mSprite = nullptr;
}
Event::~Event()
{
delete mSprite;
}
void Event::Hit(PhysEntity* other)
{
}
bool Event::CleanUp()
{
return !(Active());
}
void Event::Update()
{
if (Active())
mSprite->Update();
mLifeTimer -= mTimer->DeltaTime();
if (mLifeTimer <= 0.0f)
Active(false);
}
void Event::Render()
{
if (Active() && mMap->InFOV(this))
mSprite->Render();
PhysEntity::Render();
}
|
0080c1d0575fb32aab24cd63ba4ff73c6b45a821
|
6a86efd2e8e261bbc63fab00764ce75065bbff7b
|
/tool-function.h
|
b18c601c67ad491134536bf8ac9f1ee3f6af2482
|
[] |
no_license
|
kcyeu/nodejs-wrapper
|
88a18ee5d7a3f3f714af41d3d31fe47fa95a41fe
|
f8daca02f9541e4cc87045c16e0422f2c2cb0d8c
|
refs/heads/master
| 2020-06-22T02:28:08.722303
| 2016-02-26T06:15:23
| 2016-02-26T06:15:23
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 915
|
h
|
tool-function.h
|
#ifndef _TOOL_FUNCTION_H_
#define _TOOL_FUNCTION_H_
#include <iostream>
#include <string>
#include <fstream>
using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::fstream;
using std::ios;
template <class valueType>
void OutputCallbackMessage(valueType data) {
cout << data << endl;
}
template <class valueType>
void OutputCallbackMessage(valueType data, fstream& f_File) {
// cout << data << endl;
if (f_File) {
f_File << data << endl;
} else {
// cout << data << endl;
}
}
template<class valueType>
void OutputCallbackMessage(string varName, valueType varValue) {
cout << varName << varValue << endl;
}
template<class valueType>
void OutputCallbackMessage(string varName, valueType varValue, fstream& f_File) {
// cout << varName << varValue << endl;
if (f_File) {
f_File << varName << varValue << endl;
} else {
// cout << varName << varValue << endl;
}
}
#endif
|
0672ddcef951cd6a3a347ccea90af76e11776e56
|
32df40e8a8b78a3e2a75c8d1b7ec57781647669f
|
/Subset Sums/subset.cpp
|
731fd582c531bf634c6948a0a30b4687716d7790
|
[] |
no_license
|
AShiTheCoder/USACO
|
ac1a7be98d865279420e029903855e225187450e
|
ae768998bc11812572364c9ca2c082ae085cbe65
|
refs/heads/master
| 2020-04-17T23:08:00.035791
| 2017-01-12T06:07:42
| 2017-01-12T06:07:42
| 67,574,523
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 900
|
cpp
|
subset.cpp
|
/*
ID: ashilol1
PROG: subset
LANG: C++11
*/
#include <iostream>
#include <fstream>
using namespace std;
long ways[391][40];
unsigned long numWays(long sum, long k){
if (sum < 0 || k < 0) return 0;
if (ways[sum][k] != -1) return ways[sum][k];
else{
ways[sum][k] = numWays(sum, k - 1) + numWays(sum - k, k - 1);
return ways[sum][k];
}
}
int main() {
long N, sum;
for (long i = 0; i < 391; i++){
for (long j = 0; j < 40; j++){
ways[i][j] = -1;
}
}
ways[0][0] = 1;
// ifstream in ("/Users/AShi/Documents/Repos/USACO/Subset Sums/subset.txt");
ifstream in ("subset.in");
ofstream out ("subset.out");
in >> N;
in.close();
if (((N + 1) * N) % 4 != 0){
out << 0 << "\n";
return 0;
}
sum = (N + 1) * N / 4;
out << numWays(sum, N)/2 << "\n";
return 0;
}
|
3e77fba2f97b5f6e4bba8859466f2644d8a2acf4
|
941be079d7d6b215e2a06defd53d2651392f7004
|
/StaticArray.TestDriver/StaticArray.h
|
ca248e67a9349f934767315c97048282dc8c96a2
|
[] |
no_license
|
Nyokoyama297/COMSC260_Assignment_2_Part1
|
3776a8799e63b8640cebe2e26de6b5a7f4f960e8
|
a1303bbbf4034bf5e999544f3baeea7dd64be68d
|
refs/heads/master
| 2020-03-28T19:12:20.320988
| 2018-09-16T23:36:19
| 2018-09-16T23:36:19
| 148,954,249
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 907
|
h
|
StaticArray.h
|
// Student's name: Naoyuki Yokoyama
// Student's ID; 1635297
#ifndef Array_h
#define Array_h
#include <algorithm>
using namespace std;
template<typename T, int CAP>
class StaticArray
{
T value[CAP];
T dummy;
public:
StaticArray()
{
if (typeid(T) == typeid(char)) {
fill(value,value + CAP, '0');
}
else if (typeid(T) == typeid(string)) {
fill(value, value + CAP, '0');
}
else
fill(value, value + CAP, 0);
}
int capacity() const
{
return CAP;
}
T operator[](int) const;
T& operator[](int);
};
template <typename T, int CAP>
T StaticArray<T, CAP>::operator[](int index) const
{
if (index < 0 || index > CAP - 1) {
return dummy;
}
else {
return value[index];
}
}
template <typename T, int CAP>
T& StaticArray<T, CAP>::operator[](int index)
{
if (index < 0 || index > CAP - 1) {
return dummy;
}
else {
return value[index];
}
}
#endif // ! Array_h
|
a30015ce815cd350bea22b6cb59f776040a58b80
|
ff427f244fbe9193395fa177f7c371682ad0d858
|
/ch5/BasicInvaders/Invaders/Game.h
|
017fab367784a7c97f155b9b768ed9de9e9b5ae2
|
[] |
no_license
|
borfus/GameProgramming
|
c207119f16f48f370a26e74c910fe8c6ec8fdda4
|
a569d39395f9ac86b3915fea4aafae30022fbfba
|
refs/heads/master
| 2022-10-16T05:12:28.509356
| 2020-06-13T02:19:57
| 2020-06-13T02:19:57
| 268,660,889
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 477
|
h
|
Game.h
|
// Main Game loop control
#pragma once
#include <vector>
#include "MyFiles.h"
#include "surface.h"
#include "Objects.h"
#include "Input.h"
#define SCRWIDTH 320
#define SCRHEIGHT 240
using namespace std;
class Game
{
public:
Game();
~Game();
void Update(float DTime, MyFiles* FileHandler, Input* InputHandler,Surface* a_Screen);
bool Init(MyFiles* FileHandler);
Objects* Bob;
private:
bool InitDone ;
};
|
b6dba21e50d6ede3300ac06c6b178d619b66197b
|
d84a8687c99b435e75fa49061aaebb48190a98df
|
/action_manager/src/action_manager_node.cpp
|
5d7b168896820d3408698a45461c6549cb7b4028
|
[] |
no_license
|
SiChiTong/ariac-2018-controls
|
185413771723ebac1d9371dadc8f11be7c5e28f8
|
2e3173a4ca1895a658392d8985e70b2e7c12ade4
|
refs/heads/master
| 2020-06-05T14:52:22.292145
| 2018-10-07T18:44:56
| 2018-10-07T18:44:56
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 225
|
cpp
|
action_manager_node.cpp
|
#include <ros/ros.h>
#include <action_manager/ActionManager.hpp>
int main( int argc, char* argv[] ){
ros::init( argc, argv, "action_manager_node" );
control::ActionManager am{};
ros::waitForShutdown();
return 0;
}
|
5c5831e51bebe46b21fddc39aa2d442af59796e2
|
180a3795a115c0da71078f81efbde45ab2025ca0
|
/C++_code/2019_interview/tengxun0817/03qujianfugai.cpp
|
73149403fc27e2c7d9805bb9e655fb83f3e58c09
|
[] |
no_license
|
lizhe960118/Machine-Learning
|
a7593e6788433408bcf072e5e25672debd931ee4
|
2d6fe2373839964645d632895ed2a7dcb9de48b0
|
refs/heads/master
| 2020-03-31T15:53:57.408037
| 2019-08-18T12:29:11
| 2019-08-18T12:29:11
| 152,355,543
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,397
|
cpp
|
03qujianfugai.cpp
|
//poj1089
#include<iostream>
#include<algorithm>
#include<stdio.h>
#include<vector>
using namespace std;
// #define max_num 0x7fffffff;
typedef long long LL;
int N = 1e5+10;
int L = 1e9+10;
struct node{
int start;
int end;
} a[100000 + 10];
int cmp(struct node a, struct node b){
return a.start < b.start;
}
int main(){
int n;
int l; // l is the [0, L]
cin >> n;
cin >> l;
for(int i=0; i <n; i++){
cin >> a[i].start >> a[i].end;
}
vector<struct node> result;
sort(a, a + n, cmp);
int ta = a[0].start;
int tb = a[0].end;
// a[n].start = max_num;
// a[n].end = max_num;
for(int i = 1; i < n; i++){
if(tb < a[i].start){ // 前一个end小于后面的start
if(tb + 1 == a[i].start){ //刚好连起
struct node tmp;
tmp.start = ta;
tmp.end = tb;
result.push_back(tmp);
ta = a[i].start;
tb = a[i].end;
}
// 不能连起
cout << -1 << endl;
return 0;
}
else if (tb >= a[i].start ){ // 前一个end大于等于后一个的start,能连起来
if (tb <= a[i].end){ //前一个end小于等于后一个的end
tb = a[i].end; // 更新tb
}
}
}
cout << result.size() << endl;
return 0;
}
|
1e14c78de9bf324a29129bf2bcd4dbcd20360720
|
f0a1b225a7d2ceca2cba3d5cd9cb3ea145ec66f4
|
/trunk/lib/slave/examples/imagefilter_opencl/main.cpp
|
9ad85f4baf4cfa5b3cfa6eb3f90bf738fedee9ba
|
[] |
no_license
|
lopec/LoPEC
|
7d5503e2fbd709849c403c501b6ca444db462f15
|
29a3989c48a60e5990615dea17bad9d24d770f7b
|
refs/heads/master
| 2016-09-06T19:19:06.440261
| 2010-01-14T19:56:44
| 2010-01-14T19:56:44
| 502,996
| 2
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,760
|
cpp
|
main.cpp
|
/*
main.c
Author:Christofer Ferm
An Image/Audio filter application for
LoPEC Low Power Erlang-based Cluster
*/
#include "sharpen.h"
using namespace std;
/*prints out the results */
void printResults(const cl_float *res, cl_int *col, cl_uint count);
#define DATA_SIZE (1)
#define OUTPUT_SIZE (1024*1024)
int colorvals[3] = {255,255,0};
color map[16];
char *pid_file_path;
/*writes a pid file*/
int writePID(int pid)
{
FILE *pid_file;
char *file = (char*)malloc(sizeof(char)*100);
char *value = (char*)malloc(sizeof(char)*100);
int size =0;
sprintf(file, "%s%d.pid", pid_file_path,pid);
size = sprintf(value, "%d",pid);
pid_file=fopen(file,"w");
if(pid_file == NULL)
{
return -1;
}
fwrite(value,1,size,pid_file);
fclose(pid_file);
return 0;
}
int main(int argc, char* argv[]){
if(argc < 2)
{
cout << "usage:filter <type|(s)harpen (b)lur (g)rayscale (e)mboss> <input_image_filename>" << endl;
exit(0);
}
else
{
if(strcmp(argv[1],"s")==0)
{
sharpen(argv[2]);
// cout << "sharpen" << argv[2] << endl;
}
else if(strcmp(argv[1],"b")==0)
{
//blur(argv[2]);
cout << "blur" << argv[2] << endl;
}
else if(strcmp(argv[1],"g")==0)
{
cout << "grayscale" << argv[2] << endl;
//grayscale(argv[2]);
}
else if(strcmp(argv[1],"e")==0)
{
cout << "emboss" << argv[2] << endl;
//emboss(argv[2]);
}
else if(strcmp(argv[1],"a")==0)
{
}
else
{
cout << "invalid filter " << argv[1] << endl;
cout << "usage:filter <type|(s)harpen (b)lur (g)rayscale (e)mboss> <input_image_filename>" << endl;
exit(0);
}
}
return 0;
}
|
920b87d147021785078e0e92f9bbc5c2530aaeb7
|
20a103fa1938cd916ab36d502ab80fa57f5ef6db
|
/esp32-api-server.ino
|
0ba82b4e894cb3be239fb753db100edf1615edeb
|
[] |
no_license
|
jcbrunhera/esp32-pin-api-server
|
a6bc10aeba67e83a43b9ebf17e459dc712ec6826
|
f2c97ddc3b5417e0bc9ad3b459f24d7eceb17dd8
|
refs/heads/main
| 2023-05-15T15:04:29.645226
| 2021-06-02T22:14:53
| 2021-06-02T22:14:53
| 373,315,780
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,831
|
ino
|
esp32-api-server.ino
|
#include <Arduino.h>
#include <WiFi.h>
#include <WebServer.h>
const char *SSID = "your_ssid";
const char *PWD = "your_pswd";
WebServer server(80);
void connectToWiFi() {
// -- fixed IP
IPAddress local_IP(192, 168, 15, 36);
IPAddress gateway(192, 168, 1, 1);
IPAddress subnet(255, 255, 0, 0);
IPAddress primaryDNS(8, 8, 8, 8); //optional
IPAddress secondaryDNS(8, 8, 4, 4); //optional
if (!WiFi.config(local_IP, gateway, subnet, primaryDNS, secondaryDNS)) {
Serial.println("STA Failed to configure");
}
// ------- fixed IP
Serial.print("Connecting to ");
Serial.println(SSID);
WiFi.begin(SSID, PWD);
while (WiFi.status() != WL_CONNECTED) {
Serial.print(".");
delay(500);
}
Serial.print("Connected. IP: ");
Serial.println(WiFi.localIP());
}
void setup_routing() {
server.on("/GetPinValue", GetPinValue);
server.on("/SetPinValue", HTTP_POST, SetPinValue);
server.begin();
}
void GetPinValue() {
Serial.println("getPinValue");
int pinNumber = server.arg("pinNumber").toInt();
char str[250];
float pinValue = analogRead(pinNumber);
sprintf(str, "{ 'pinNumber': %i, 'Value': %f }", pinNumber, pinValue);
server.send(200,"application/json",str);
Serial.println(str);
}
void SetPinValue() {
Serial.println("SetPinValue");
int pinNumber = server.arg("pinNumber").toInt();
int pinValue = server.arg("pinValue").toInt();
char str[250];
sprintf(str, "{ 'RespCode':0, 'pinNumber': %i, 'Value': %i }", pinNumber, pinValue);
server.send(200,"application/json",str);
Serial.println(str);
pinMode(pinNumber,OUTPUT);
digitalWrite( pinNumber, pinValue);
}
void setup() {
Serial.begin(115200);
connectToWiFi();
setup_routing();
}
void loop() {
server.handleClient();
}
|
cdae45c3595f10f2e4093c4a41dfca57f0c416aa
|
cb7ac15343e3b38303334f060cf658e87946c951
|
/source/runtime/CoreObject/Public/Serialization/BulkDataCommon.h
|
3b1e2da01b8273f3b07d4fe410b0a400153cc012
|
[] |
no_license
|
523793658/Air2.0
|
ac07e33273454442936ce2174010ecd287888757
|
9e04d3729a9ce1ee214b58c2296188ec8bf69057
|
refs/heads/master
| 2021-11-10T16:08:51.077092
| 2021-11-04T13:11:59
| 2021-11-04T13:11:59
| 178,317,006
| 1
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 4,012
|
h
|
BulkDataCommon.h
|
// Copyright Epic Games, Inc. All Rights Reserved.
#pragma once
// NOTE: This file only needs to exist as long as we need to maintain the editor and runtime versions of Bulkdata.
// Code common to both can be placed here.
/**
* Flags serialized with the bulk data.
*/
enum EBulkDataFlags : uint32
{
/** Empty flag set. */
BULKDATA_None = 0,
/** If set, payload is stored at the end of the file and not inline. */
BULKDATA_PayloadAtEndOfFile = 1 << 0,
/** If set, payload should be [un]compressed using ZLIB during serialization. */
BULKDATA_SerializeCompressedZLIB = 1 << 1,
/** Force usage of SerializeElement over bulk serialization. */
BULKDATA_ForceSingleElementSerialization = 1 << 2,
/** Bulk data is only used once at runtime in the game. */
BULKDATA_SingleUse = 1 << 3,
/** Bulk data won't be used and doesn't need to be loaded. */
BULKDATA_Unused = 1 << 5,
/** Forces the payload to be saved inline, regardless of its size. */
BULKDATA_ForceInlinePayload = 1 << 6,
/** Flag to check if either compression mode is specified. */
BULKDATA_SerializeCompressed = (BULKDATA_SerializeCompressedZLIB),
/** Forces the payload to be always streamed, regardless of its size. */
BULKDATA_ForceStreamPayload = 1 << 7,
/** If set, payload is stored in a .upack file alongside the uasset. */
BULKDATA_PayloadInSeperateFile = 1 << 8,
/** DEPRECATED: If set, payload is compressed using platform specific bit window. */
BULKDATA_SerializeCompressedBitWindow = 1 << 9,
/** There is a new default to inline unless you opt out. */
BULKDATA_Force_NOT_InlinePayload = 1 << 10,
/** This payload is optional and may not be on device. */
BULKDATA_OptionalPayload = 1 << 11,
/** This payload will be memory mapped, this requires alignment, no compression etc. */
BULKDATA_MemoryMappedPayload = 1 << 12,
/** Bulk data size is 64 bits long. */
BULKDATA_Size64Bit = 1 << 13,
/** Duplicate non-optional payload in optional bulk data. */
BULKDATA_DuplicateNonOptionalPayload = 1 << 14,
/** Indicates that an old ID is present in the data, at some point when the DDCs are flushed we can remove this. */
BULKDATA_BadDataVersion = 1 << 15,
/** BulkData did not have it's offset changed during the cook and does not need the fix up at load time */
BULKDATA_NoOffsetFixUp = 1 << 16,
/* Runtime only flags below this point! Note that they take the high bits in reverse order! */
/** Assigned at runtime to indicate that the BulkData should be using the IoDispatcher when loading, not filepaths. */
BULKDATA_UsesIoDispatcher = 1u << 31u,
/** Assigned at runtime to indicate that the BulkData allocation is a memory mapped region of a file and not raw data. */
BULKDATA_DataIsMemoryMapped = 1 << 30,
/** Assigned at runtime to indicate that the BulkData object has an async loading request in flight and will need to wait on it. */
BULKDATA_HasAsyncReadPending = 1 << 29,
/** Assigned at runtime to indicate that the BulkData object should be considered for discard even if it cannot load from disk. */
BULKDATA_AlwaysAllowDiscard = 1 << 28,
};
/**
* Allows FArchive to serialize EBulkDataFlags, this will not be required once EBulkDataFlags is promoted
* to be a enum class.
*/
FORCEINLINE FArchive& operator<<(FArchive& Ar, EBulkDataFlags& Flags)
{
Ar << (uint32&)Flags;
return Ar;
}
/**
* Enumeration for bulk data lock status.
*/
enum EBulkDataLockStatus
{
/** Unlocked array */
LOCKSTATUS_Unlocked = 0,
/** Locked read-only */
LOCKSTATUS_ReadOnlyLock = 1,
/** Locked read-write-realloc */
LOCKSTATUS_ReadWriteLock = 2,
};
/**
* Enumeration for bulk data lock behavior
*/
enum EBulkDataLockFlags
{
LOCK_READ_ONLY = 1,
LOCK_READ_WRITE = 2,
};
namespace BulkDataExt
{
extern const FString Export; // Stored in the export data
extern const FString Default; // Stored in a separate file
extern const FString MemoryMapped; // Stored in a separate file aligned for memory mapping
extern const FString Optional; // Stored in a separate file that is optional
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.