blob_id stringlengths 40 40 | directory_id stringlengths 40 40 | path stringlengths 4 201 | content_id stringlengths 40 40 | detected_licenses listlengths 0 85 | license_type stringclasses 2
values | repo_name stringlengths 7 100 | snapshot_id stringlengths 40 40 | revision_id stringlengths 40 40 | branch_name stringclasses 260
values | visit_date timestamp[us] | revision_date timestamp[us] | committer_date timestamp[us] | github_id int64 11.4k 681M ⌀ | star_events_count int64 0 209k | fork_events_count int64 0 110k | gha_license_id stringclasses 17
values | gha_event_created_at timestamp[us] | gha_created_at timestamp[us] | gha_language stringclasses 80
values | src_encoding stringclasses 28
values | language stringclasses 1
value | is_vendor bool 1
class | is_generated bool 2
classes | length_bytes int64 8 9.86M | extension stringclasses 52
values | content stringlengths 8 9.86M | authors listlengths 1 1 | author stringlengths 0 119 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
2ec92893884c1f2c81137ef6e164c1cdc90d3b44 | 4713905cac43e44c8fc350a5f616e73edd2c8010 | /common/clisence.h | 48ea5cb59eb00d5cbaa5108dc97794d38fc1139f | [] | no_license | awfeequdng/storage | da2512a64d7e5b504cb0cba253d55b066c7b548e | 8cbf67ab6b99025fd7b6df249e0fd8ef95a74350 | refs/heads/master | 2021-01-10T14:00:34.570570 | 2015-12-28T09:35:33 | 2015-12-28T09:35:33 | 48,143,788 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 768 | h | #ifndef CLISENCE_H
#define CLISENCE_H
#include "GlobalData/GlobalDef.h"
#define MAC_LEN 12
#define CPUID_LEN 32
#define HDD_SN_LEN 20
#define LOCK_LEN 16
#define KEY_LEN 512
class CLisence
{
public:
CLisence(void);
~CLisence(void);
BYTE *GetLock();
BYTE *GetKey();
BYTE *GetKey(BYTE *byLock,size_t len);
BYTE *GetKeyFromFile(char *sFileName);
BOOL GetMacAddress();
BOOL GetCPUID();
BOOL GetHDDSerialNumber();
private:
BYTE m_byMac[MAC_LEN];
BYTE m_byCPUID[CPUID_LEN];
BYTE m_byHDDSerialNumber[HDD_SN_LEN];
BYTE m_byLock[LOCK_LEN];
BYTE m_byKey[KEY_LEN];
CHAR *ConvertSENDCMDOUTPARAMSBufferToString( const DWORD *dwDiskData, DWORD nFirstIndex, DWORD nLastIndex );
};
#endif // CLISENCE_H
| [
"caipengxiang@caipengxiang-VirtualBox.(none)"
] | caipengxiang@caipengxiang-VirtualBox.(none) |
ab1b6bdcef549c5f0d8dcb74694d0148715eee25 | 7119b560890a95797de0b0f37469a45965f58334 | /Tugas luas segitiga.cpp | bebd83de70e177bac6d8549848630a2229ed5c09 | [] | no_license | jovianalthaf/Kuliah | 6106978f27aa6465558b2e42114bc220d1bb7afe | 15c39325292b699d4129ef1ed65bcac34fb29694 | refs/heads/main | 2023-07-28T21:39:50.032077 | 2021-09-25T14:17:55 | 2021-09-25T14:17:55 | 410,290,442 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 384 | cpp | #include <iostream>
#include <stdio.h>
#include <conio.h>
using namespace std;
main()
{
/*Deklarasi*/
float alas;
float tinggi;
float luas;
/*Algoritma*/
cout<< "Input Alasnya berapa = ";
cin>>alas;
cout<< "Input Tinggi berapa = ";
cin>>tinggi;
luas = 0.5 *alas * tinggi;
cout>>"Luas Segitiga adalah " << luas << endl;
return 0;
}
| [
"noreply@github.com"
] | noreply@github.com |
3964f35a257159c47ad51db5635cb3343998e387 | 1de8f665a63118273dd507404ef02d5f4c8805d8 | /include/mach_mem.h | 4ea7ab5a94ae6533b513203b7f616379823434be | [
"MIT"
] | permissive | wiluite/rmc_parser | e891027fa13ff3280a778d607371b018dffd6ef3 | 7e8d57407c4ad9fe0784b313f283341ca649a20a | refs/heads/master | 2020-12-04T05:28:02.611324 | 2020-03-24T18:01:41 | 2020-03-24T18:01:41 | 231,628,286 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 381 | h | #pragma once
namespace serial
{
template <size_t, typename>
class machine;
template <class M>
class machine_memento
{
template <size_t, typename>
friend class machine;
typename M::const_iterator b;
typename M::const_iterator e;
public:
explicit machine_memento (M const & m) : b(m.begin()), e(m.end()) {}
};
}
| [
"tetasoft@yandex.ru"
] | tetasoft@yandex.ru |
02a0c22098800e8e626b5ea41cfc207d8373c2e9 | ecebedbc8f13e05eb1f3327d97a7e283b35f84b6 | /usaco/crypt1/crypt1.cpp | acf984005e6c1ca2453769952733757d2a0eb458 | [] | no_license | arkajit/puzzles | d435175e5ddd7435f3db12bab0f9c72947fd32c4 | f1ff44aa27793601e421944a8c0ca08d27f7e40b | refs/heads/master | 2022-06-28T05:22:08.157970 | 2022-06-01T18:12:15 | 2022-06-01T18:12:15 | 1,018,775 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,084 | cpp | /*
ID: arkajit.d1
PROG: crypt1
LANG: C++
*/
#include <iostream>
#include <fstream>
#define MAXN 9
using namespace std;
int n, digits[10]; // 1 if we can use the digit
int is_num_valid(int num, int len) {
for (; len > 0; len--) {
if (num && digits[num % 10]) {
num /= 10;
} else {
return 0;
}
}
return (num == 0) ? 1 : 0;
}
int main() {
ofstream fout("crypt1.out");
ifstream fin("crypt1.in");
int d, total = 0;
for (int i = 0; i < 10; i++) {
digits[i] = 0;
}
fin >> n;
for (int i = 0; i < n; i++) {
fin >> d;
digits[d] = 1;
}
fin.close();
// a = 3-digit top number
// b = 2-digit bottom number
for (int a = 111; a < 1000; a++) {
if (is_num_valid(a, 3)) {
for (int b = 11; b < 100; b++) {
if (is_num_valid(b, 2)) {
// check total product and both partial products
if (is_num_valid(a*b, 4) &&
is_num_valid(a*(b % 10), 3) &&
is_num_valid(a*(b / 10), 3)) {
total += 1;
//cout << "a = " << a << ", b = " << b << endl;
}
}
}
}
}
fout << total << endl;
fout.close();
return 0;
}
| [
"arkajit.dey@gmail.com"
] | arkajit.dey@gmail.com |
acab0a2719d9f7aed7723b1c26272cde4971bd0b | a33aac97878b2cb15677be26e308cbc46e2862d2 | /program_data/PKU_raw/59/622.c | d6a9e00a36fb10019a3baff5afe416725eea1292 | [] | no_license | GabeOchieng/ggnn.tensorflow | f5d7d0bca52258336fc12c9de6ae38223f28f786 | 7c62c0e8427bea6c8bec2cebf157b6f1ea70a213 | refs/heads/master | 2022-05-30T11:17:42.278048 | 2020-05-02T11:33:31 | 2020-05-02T11:33:31 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 774 | c | /*
* main.cpp
*
* Created on: 2012-11-11
* Author: ??
* ????
*/
int main()
{
char a[110][110],b[110][110];
int i,j,n,m,sum=0,t;
cin>>n;
for (i=1;i<=n;i++)
for (j=1;j<=n;j++)
cin>>a[i][j];
cin>>m;
for (i=0;i<=n+1;i++)
{
a[0][i]='#';a[n+1][i]='#';a[i][0]='#';a[i][n+1]='#';
}
for (t=1;t<m;t++)
{
for (i=1;i<=n;i++)
for (j=1;j<=n;j++)
{
if (a[i][j]=='.')
if ((a[i][j-1]=='@')||(a[i][j+1]=='@')||(a[i-1][j]=='@')||(a[i+1][j]=='@'))
b[i][j]='@';
else
b[i][j]='.';
else
b[i][j]=a[i][j];
}
for (i=1;i<=n;i++)
for (j=1;j<=n;j++)
a[i][j]=b[i][j];
}
for (i=1;i<=n;i++)
for (j=1;j<=n;j++)
if (a[i][j]=='@') sum++;
cout<<sum;
return 0;
} | [
"bdqnghi@gmail.com"
] | bdqnghi@gmail.com |
849fa746b55fe5281a1a30c53773e9f03c2db433 | 0ef4a19859fc0902c002a479f6c220b9e00aab58 | /Constructor.h | dc503644dddbbc8c04406b951cd6a778a517c08e | [] | no_license | LabmanD3/Cpp_Learn_Code | 34cd8fbf4ec5919ec0a3587d424924fef070b668 | de0d3b72be138f66e3be8f1614d2dc3e1a104650 | refs/heads/master | 2022-12-25T23:25:23.801124 | 2020-10-06T09:51:04 | 2020-10-06T09:51:04 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 658 | h | #ifndef CONSTRUCTOR_H
#define CONSTRUCTOR_H
#include <iostream>
using namespace std;
class String
{
private:
char *ptr;
public:
// String() = default; // default constructor (not used)
explicit String(int size = 0); // constructor with parameter
String(const char *p); // constructor
String(const String&); // copy constructor
~String(); // destructor
friend ostream& operator<<(ostream &cout, String &s); // overloaded operator
String& operator=(const String &s); // copy-assginment operator
};
#endif // CONSTRUCTOR_H | [
"tong.lin@bitland.corp-partner.google.com"
] | tong.lin@bitland.corp-partner.google.com |
8f33e5623f96629ce4aec4088f790fd1a18a1f49 | 198f071c0f3db78fc2b2209a2ab7da65f8f3b66e | /Codeforces/Round 561 (Div.2) (1166)/E. The LCMs Must be Large.cpp | 3a9730beffacc9ad4fbb053db438537d1aff03bc | [] | no_license | gratus907/Gratus_PS | a33924836f67c14c3b1f8d4eecdfea73cd5cb98f | 7efdc7f37f268dccd2f8a0ec562aa7a4a67adf15 | refs/heads/master | 2023-07-27T03:43:17.731930 | 2021-08-31T17:26:54 | 2021-08-31T17:26:54 | 235,131,504 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,453 | cpp | #include <bits/stdc++.h>
#pragma GCC optimize ("O3")
#pragma GCC optimize ("Ofast")
#define ll long long
#define MAX(A,B) ((A)>(B)?(A):(B))
#define MIN(A,B) ((A)<(B)?(A):(B))
#define gcd(A,B) (__gcd(A,B))
#define lcm(A,B) A/(__gcd(A,B))*B
#define MP make_pair
#define PB push_back
#define EPS 1e-9
#define ld long double
#define mod 1000000007LL
#define all(x) x.begin(), x.end()
#define usecppio ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
using namespace std;
typedef pair<int,int> pii;
typedef pair<int,string> pis;
typedef pair<int,double> pid;
bool bb[51][10010];
int n,m;
bool comsub(int a, int b) // check if b is subset of complementary of a.
{
for (int i = 0; i<10010; i++)
{
if (bb[b][i])
{
if (bb[a][i])
return false;
}
}
return true;
}
int main()
{
scanf("%d %d",&m,&n);
for (int i = 0; i<m; i++)
{
int s;
scanf("%d",&s);
for (int j = 0; j<s; j++)
{
int buy;
scanf("%d",&buy);
bb[i][buy] = 1;
}
}
bool ans = true;
for (int i = 0; i<m; i++)
{
for (int j = 0; j<m; j++)
{
if (comsub(i, j))
{
//printf("%d is comsub of %d\n",i,j);
ans = false;
break;
}
}
if (!ans)
break;
}
printf("%s",ans?"possible":"impossible");
}
| [
"gratus907@naver.com"
] | gratus907@naver.com |
9be7ebf5d47bb28ac643d4f02a42ed1fe4d5e69c | 00801b4bb53307000ad9ff66ed9d98b1bf7fb627 | /ml-practice/linear_model/linear_regression.cpp | 1a7ffae21933533b6efaec455d4d5b211c5d7f78 | [] | no_license | cherubjywh/ml-practice | 03c9974acaabb1fb82fa031169df0fb08bd969f5 | 7f53bb737375683f76b7b64d0a7ec2f21b62c149 | refs/heads/master | 2021-01-20T11:14:03.972957 | 2015-11-18T07:43:36 | 2015-11-18T07:43:36 | 45,351,470 | 1 | 0 | null | 2015-11-01T21:04:56 | 2015-11-01T18:08:16 | C++ | UTF-8 | C++ | false | false | 2,522 | cpp | //
// linear_regression.cpp
// ml-practice
//
// Created by Yuyin Sun on 15-11-1.
// Copyright (c) 2015年 Yuyin Sun. All rights reserved.
//
#include "linear_regression.h"
using namespace regression;
LinearRegression::LinearRegression(const arma::mat& predicators,
const arma::mat& responses,
const double lambda,
const bool intercept,
const arma::vec& weights) :
lambda (lambda), intercept(intercept)
{
// predicators: A is a N x D matrix, where N is the number of examples, and D is the number features
const size_t n_dims = predicators.n_cols;
const size_t n_insts = predicators.n_rows;
// We need to do some preprocessing over A
// We don't want to do manipulation on the original data. Such that we copy the data into a new matrix
arma::mat p = predicators;
arma::vec r = responses;
// Add psudo-feature x_0 for the bias term
if (intercept)
{
p.insert_cols(0, arma::ones<arma::mat>(n_insts, 1));
}
if (weights.n_elem > 0) {
p = arma::diagmat(sqrt(weights)) * p;
r = arma::sqrt(weights) % responses;
}
// Get B = [A; sqrt(\lambda)I], if lambda is non-zero
if (lambda != 0.0)
{
p.insert_rows(p.n_rows, n_dims);
p.submat(p.n_rows - n_dims + 1, p.n_cols - n_dims, n_dims, n_dims) =
sqrt(lambda) * arma::eye<arma::mat>(n_dims, n_dims);
}
// Perform QR decomposition
arma::mat Q, R;
arma::qr(Q, R, p);
// Solve the linear system
if (lambda == 0.0)
{
arma::solve(parameters, R, arma::trans(Q)*r);
}
else
{
r.insert_rows(n_insts, n_dims);
arma::solve(parameters, R, arma::trans(Q)*r);
}
}
LinearRegression::LinearRegression(const LinearRegression& linearRegression) : parameters(linearRegression.parameters),
lambda(linearRegression.lambda)
{
}
void LinearRegression::Predict (const arma::mat& points, arma::vec & predictions) const
{
if (!intercept) {
predictions = points * parameters;
} else
{
predictions = points * parameters.subvec(1, parameters.n_rows - 1);
predictions = predictions + parameters(0);
}
}
double LinearRegression::ComputeError (const arma::mat& points, const arma::vec& responses) const
{
arma::vec temp;
Predict(points, temp);
temp = temp - responses;
const double err = arma::dot(temp, temp) / points.n_rows;
return err;
}
| [
"cherubjywh@gmail.com"
] | cherubjywh@gmail.com |
efddabbdf5843abc938d4328630dcfad25dbd54a | 8c5f7ef81a92887fcadfe9ef0c62db5d68d49659 | /src/include/guinsoodb/execution/operator/aggregate/physical_window.hpp | e15496286fc11f817fc6c44580add2ab7e443430 | [
"MIT"
] | permissive | xunliu/guinsoodb | 37657f00456a053558e3abc433606bc6113daee5 | 0e90f0743c3b69f8a8c2c03441f5bb1232ffbcf0 | refs/heads/main | 2023-04-10T19:53:35.624158 | 2021-04-21T03:25:44 | 2021-04-21T03:25:44 | 378,399,976 | 0 | 1 | MIT | 2021-06-19T11:51:49 | 2021-06-19T11:51:48 | null | UTF-8 | C++ | false | false | 1,796 | hpp | //===----------------------------------------------------------------------===//
// GuinsooDB
//
// guinsoodb/execution/operator/aggregate/physical_window.hpp
//
//
//===----------------------------------------------------------------------===//
#pragma once
#include "guinsoodb/common/types/chunk_collection.hpp"
#include "guinsoodb/execution/physical_sink.hpp"
#include "guinsoodb/parallel/pipeline.hpp"
namespace guinsoodb {
//! PhysicalWindow implements window functions
//! It assumes that all functions have a common partitioning and ordering
class PhysicalWindow : public PhysicalSink {
public:
PhysicalWindow(vector<LogicalType> types, vector<unique_ptr<Expression>> select_list, idx_t estimated_cardinality,
PhysicalOperatorType type = PhysicalOperatorType::WINDOW);
void GetChunkInternal(ExecutionContext &context, DataChunk &chunk, PhysicalOperatorState *state) override;
unique_ptr<PhysicalOperatorState> GetOperatorState() override;
// sink stuff
void Sink(ExecutionContext &context, GlobalOperatorState &state, LocalSinkState &lstate, DataChunk &input) override;
void Combine(ExecutionContext &context, GlobalOperatorState &state, LocalSinkState &lstate) override;
void Finalize(Pipeline &pipeline, ClientContext &context, unique_ptr<GlobalOperatorState> gstate) override;
unique_ptr<LocalSinkState> GetLocalSinkState(ExecutionContext &context) override;
unique_ptr<GlobalOperatorState> GetGlobalState(ClientContext &context) override;
idx_t MaxThreads(ClientContext &context);
unique_ptr<ParallelState> GetParallelState();
string ParamsToString() const override;
public:
//! The projection list of the WINDOW statement (may contain aggregates)
vector<unique_ptr<Expression>> select_list;
};
} // namespace guinsoodb
| [
"bqjimaster@gmail.com"
] | bqjimaster@gmail.com |
222b3bec4607d205b66cc72dac2fb56302f5559d | d1a0d697798704d2a989b068574587cf6ca1ece9 | /components/view_manager/view_manager_service_unittest.cc | 72a986a315597a5b5b11f3a7f46926ace69e6a4d | [
"BSD-3-Clause"
] | permissive | lihui7115/ChromiumGStreamerBackend | 983199aa76e052d3e9ea21ff53d0dd4cf4c995dc | 6e41f524b780f2ff8d731f9986be743414a49a33 | refs/heads/master | 2021-01-17T10:26:00.070404 | 2015-08-05T16:39:35 | 2015-08-05T17:09:06 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 24,669 | cc | // Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include <string>
#include <vector>
#include "base/message_loop/message_loop.h"
#include "components/view_manager/client_connection.h"
#include "components/view_manager/connection_manager.h"
#include "components/view_manager/connection_manager_delegate.h"
#include "components/view_manager/display_manager.h"
#include "components/view_manager/display_manager_factory.h"
#include "components/view_manager/ids.h"
#include "components/view_manager/public/cpp/types.h"
#include "components/view_manager/public/cpp/util.h"
#include "components/view_manager/public/interfaces/view_manager.mojom.h"
#include "components/view_manager/server_view.h"
#include "components/view_manager/test_change_tracker.h"
#include "components/view_manager/view_manager_root_connection.h"
#include "components/view_manager/view_manager_service_impl.h"
#include "mojo/application/public/interfaces/service_provider.mojom.h"
#include "mojo/converters/geometry/geometry_type_converters.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/gfx/geometry/rect.h"
using mojo::Array;
using mojo::ERROR_CODE_NONE;
using mojo::InterfaceRequest;
using mojo::ServiceProvider;
using mojo::ServiceProviderPtr;
using mojo::String;
using mojo::ViewDataPtr;
namespace view_manager {
namespace {
// -----------------------------------------------------------------------------
// ViewManagerClient implementation that logs all calls to a TestChangeTracker.
// TODO(sky): refactor so both this and ViewManagerServiceAppTest share code.
class TestViewManagerClient : public mojo::ViewManagerClient {
public:
TestViewManagerClient() {}
~TestViewManagerClient() override {}
TestChangeTracker* tracker() { return &tracker_; }
private:
// ViewManagerClient:
void OnEmbed(uint16_t connection_id,
ViewDataPtr root,
mojo::ViewManagerServicePtr view_manager_service,
mojo::Id focused_view_id) override {
// TODO(sky): add test coverage of |focused_view_id|.
tracker_.OnEmbed(connection_id, root.Pass());
}
void OnEmbedForDescendant(
uint32_t view,
mojo::URLRequestPtr request,
const OnEmbedForDescendantCallback& callback) override {}
void OnEmbeddedAppDisconnected(uint32_t view) override {
tracker_.OnEmbeddedAppDisconnected(view);
}
void OnViewBoundsChanged(uint32_t view,
mojo::RectPtr old_bounds,
mojo::RectPtr new_bounds) override {
tracker_.OnViewBoundsChanged(view, old_bounds.Pass(), new_bounds.Pass());
}
void OnViewViewportMetricsChanged(
mojo::ViewportMetricsPtr old_metrics,
mojo::ViewportMetricsPtr new_metrics) override {
tracker_.OnViewViewportMetricsChanged(old_metrics.Pass(),
new_metrics.Pass());
}
void OnViewHierarchyChanged(uint32_t view,
uint32_t new_parent,
uint32_t old_parent,
Array<ViewDataPtr> views) override {
tracker_.OnViewHierarchyChanged(view, new_parent, old_parent, views.Pass());
}
void OnViewReordered(uint32_t view_id,
uint32_t relative_view_id,
mojo::OrderDirection direction) override {
tracker_.OnViewReordered(view_id, relative_view_id, direction);
}
void OnViewDeleted(uint32_t view) override { tracker_.OnViewDeleted(view); }
void OnViewVisibilityChanged(uint32_t view, bool visible) override {
tracker_.OnViewVisibilityChanged(view, visible);
}
void OnViewDrawnStateChanged(uint32_t view, bool drawn) override {
tracker_.OnViewDrawnStateChanged(view, drawn);
}
void OnViewSharedPropertyChanged(uint32_t view,
const String& name,
Array<uint8_t> new_data) override {
tracker_.OnViewSharedPropertyChanged(view, name, new_data.Pass());
}
void OnViewInputEvent(uint32_t view,
mojo::EventPtr event,
const mojo::Callback<void()>& callback) override {
tracker_.OnViewInputEvent(view, event.Pass());
}
void OnViewFocused(uint32_t focused_view_id) override {
tracker_.OnViewFocused(focused_view_id);
}
TestChangeTracker tracker_;
DISALLOW_COPY_AND_ASSIGN(TestViewManagerClient);
};
// -----------------------------------------------------------------------------
// ClientConnection implementation that vends TestViewManagerClient.
class TestClientConnection : public ClientConnection {
public:
explicit TestClientConnection(scoped_ptr<ViewManagerServiceImpl> service_impl)
: ClientConnection(service_impl.Pass(), &client_) {}
TestViewManagerClient* client() { return &client_; }
private:
~TestClientConnection() override {}
TestViewManagerClient client_;
DISALLOW_COPY_AND_ASSIGN(TestClientConnection);
};
// -----------------------------------------------------------------------------
// Empty implementation of ConnectionManagerDelegate.
class TestConnectionManagerDelegate : public ConnectionManagerDelegate {
public:
TestConnectionManagerDelegate() : last_connection_(nullptr) {}
~TestConnectionManagerDelegate() override {}
TestViewManagerClient* last_client() {
return last_connection_ ? last_connection_->client() : nullptr;
}
TestClientConnection* last_connection() { return last_connection_; }
private:
// ConnectionManagerDelegate:
void OnNoMoreRootConnections() override {}
ClientConnection* CreateClientConnectionForEmbedAtView(
ConnectionManager* connection_manager,
mojo::InterfaceRequest<mojo::ViewManagerService> service_request,
mojo::ConnectionSpecificId creator_id,
mojo::URLRequestPtr request,
const ViewId& root_id) override {
scoped_ptr<ViewManagerServiceImpl> service(
new ViewManagerServiceImpl(connection_manager, creator_id, root_id));
last_connection_ = new TestClientConnection(service.Pass());
return last_connection_;
}
ClientConnection* CreateClientConnectionForEmbedAtView(
ConnectionManager* connection_manager,
mojo::InterfaceRequest<mojo::ViewManagerService> service_request,
mojo::ConnectionSpecificId creator_id,
const ViewId& root_id,
mojo::ViewManagerClientPtr client) override {
// Used by ConnectionManager::AddRoot.
scoped_ptr<ViewManagerServiceImpl> service(
new ViewManagerServiceImpl(connection_manager, creator_id, root_id));
last_connection_ = new TestClientConnection(service.Pass());
return last_connection_;
}
TestClientConnection* last_connection_;
DISALLOW_COPY_AND_ASSIGN(TestConnectionManagerDelegate);
};
// -----------------------------------------------------------------------------
class TestViewManagerRootConnection : public ViewManagerRootConnection {
public:
TestViewManagerRootConnection(scoped_ptr<ViewManagerRootImpl> root,
ConnectionManager* manager)
: ViewManagerRootConnection(root.Pass(), manager) {}
~TestViewManagerRootConnection() override {}
private:
// ViewManagerRootDelegate:
void OnDisplayInitialized() override {
connection_manager()->AddRoot(this);
set_view_manager_service(connection_manager()->EmbedAtView(
kInvalidConnectionId,
view_manager_root()->root_view()->id(),
mojo::ViewManagerClientPtr()));
}
DISALLOW_COPY_AND_ASSIGN(TestViewManagerRootConnection);
};
// -----------------------------------------------------------------------------
// Empty implementation of DisplayManager.
class TestDisplayManager : public DisplayManager {
public:
TestDisplayManager() {}
~TestDisplayManager() override {}
// DisplayManager:
void Init(DisplayManagerDelegate* delegate) override {
// It is necessary to tell the delegate about the ViewportMetrics to make
// sure that the ViewManagerRootConnection is correctly initialized (and a
// root-view is created).
mojo::ViewportMetrics metrics;
metrics.size_in_pixels = mojo::Size::From(gfx::Size(400, 300));
metrics.device_pixel_ratio = 1.f;
delegate->OnViewportMetricsChanged(mojo::ViewportMetrics(), metrics);
}
void SchedulePaint(const ServerView* view, const gfx::Rect& bounds) override {
}
void SetViewportSize(const gfx::Size& size) override {}
const mojo::ViewportMetrics& GetViewportMetrics() override {
return display_metrices_;
}
private:
mojo::ViewportMetrics display_metrices_;
DISALLOW_COPY_AND_ASSIGN(TestDisplayManager);
};
// Factory that dispenses TestDisplayManagers.
class TestDisplayManagerFactory : public DisplayManagerFactory {
public:
TestDisplayManagerFactory() {}
~TestDisplayManagerFactory() {}
DisplayManager* CreateDisplayManager(
bool is_headless,
mojo::ApplicationImpl* app_impl,
const scoped_refptr<gles2::GpuState>& gpu_state) override {
return new TestDisplayManager();
}
private:
DISALLOW_COPY_AND_ASSIGN(TestDisplayManagerFactory);
};
mojo::EventPtr CreatePointerDownEvent(int x, int y) {
mojo::EventPtr event(mojo::Event::New());
event->action = mojo::EVENT_TYPE_POINTER_DOWN;
event->pointer_data = mojo::PointerData::New();
event->pointer_data->pointer_id = 1u;
event->pointer_data->x = x;
event->pointer_data->y = y;
return event.Pass();
}
mojo::EventPtr CreatePointerUpEvent(int x, int y) {
mojo::EventPtr event(mojo::Event::New());
event->action = mojo::EVENT_TYPE_POINTER_UP;
event->pointer_data = mojo::PointerData::New();
event->pointer_data->pointer_id = 1u;
event->pointer_data->x = x;
event->pointer_data->y = y;
return event.Pass();
}
} // namespace
// -----------------------------------------------------------------------------
class ViewManagerServiceTest : public testing::Test {
public:
ViewManagerServiceTest() : wm_client_(nullptr) {}
~ViewManagerServiceTest() override {}
// ViewManagerServiceImpl for the window manager.
ViewManagerServiceImpl* wm_connection() {
return connection_manager_->GetConnection(1);
}
TestViewManagerClient* last_view_manager_client() {
return delegate_.last_client();
}
TestClientConnection* last_client_connection() {
return delegate_.last_connection();
}
ConnectionManager* connection_manager() { return connection_manager_.get(); }
TestViewManagerClient* wm_client() { return wm_client_; }
TestViewManagerRootConnection* root_connection() { return root_connection_; }
protected:
// testing::Test:
void SetUp() override {
DisplayManager::set_factory_for_testing(&display_manager_factory_);
// TODO(fsamuel): This is probably broken. We need a root.
connection_manager_.reset(new ConnectionManager(&delegate_));
ViewManagerRootImpl* root = new ViewManagerRootImpl(
connection_manager_.get(), true /* is_headless */, nullptr,
scoped_refptr<gles2::GpuState>());
// TODO(fsamuel): This is way too magical. We need to find a better way to
// manage lifetime.
root_connection_ = new TestViewManagerRootConnection(
make_scoped_ptr(root), connection_manager_.get());
root->Init(root_connection_);
wm_client_ = delegate_.last_client();
}
private:
// TestViewManagerClient that is used for the WM connection.
TestViewManagerClient* wm_client_;
TestDisplayManagerFactory display_manager_factory_;
TestConnectionManagerDelegate delegate_;
TestViewManagerRootConnection* root_connection_;
scoped_ptr<ConnectionManager> connection_manager_;
base::MessageLoop message_loop_;
DISALLOW_COPY_AND_ASSIGN(ViewManagerServiceTest);
};
namespace {
const ServerView* GetFirstCloned(const ServerView* view) {
for (const ServerView* child : view->GetChildren()) {
if (child->id() == ClonedViewId())
return child;
}
return nullptr;
}
// Provides common setup for animation tests. Creates the following views:
// 0,1 (the root, provided by view manager)
// 1,1 the second connection is embedded here (view owned by wm_connection()).
// 2,1 bounds=1,2 11x22
// 2,2 bounds=2,3 6x7
// 2,3 bounds=3,4 6x7
// CloneAndAnimate() is invoked for 2,2.
void SetUpAnimate1(ViewManagerServiceTest* test, ViewId* embed_view_id) {
*embed_view_id = ViewId(test->wm_connection()->id(), 1);
EXPECT_EQ(ERROR_CODE_NONE, test->wm_connection()->CreateView(*embed_view_id));
EXPECT_TRUE(test->wm_connection()->SetViewVisibility(*embed_view_id, true));
EXPECT_TRUE(test->wm_connection()->AddView(*(test->wm_connection()->root()),
*embed_view_id));
mojo::URLRequestPtr request(mojo::URLRequest::New());
test->wm_connection()->EmbedAllowingReembed(*embed_view_id, request.Pass(),
mojo::Callback<void(bool)>());
ViewManagerServiceImpl* connection1 =
test->connection_manager()->GetConnectionWithRoot(*embed_view_id);
ASSERT_TRUE(connection1 != nullptr);
ASSERT_NE(connection1, test->wm_connection());
const ViewId child1(connection1->id(), 1);
EXPECT_EQ(ERROR_CODE_NONE, connection1->CreateView(child1));
const ViewId child2(connection1->id(), 2);
EXPECT_EQ(ERROR_CODE_NONE, connection1->CreateView(child2));
const ViewId child3(connection1->id(), 3);
EXPECT_EQ(ERROR_CODE_NONE, connection1->CreateView(child3));
ServerView* v1 = connection1->GetView(child1);
v1->SetVisible(true);
v1->SetBounds(gfx::Rect(1, 2, 11, 22));
ServerView* v2 = connection1->GetView(child2);
v2->SetVisible(true);
v2->SetBounds(gfx::Rect(2, 3, 6, 7));
ServerView* v3 = connection1->GetView(child3);
v3->SetVisible(true);
v3->SetBounds(gfx::Rect(3, 4, 6, 7));
EXPECT_TRUE(connection1->AddView(*embed_view_id, child1));
EXPECT_TRUE(connection1->AddView(child1, child2));
EXPECT_TRUE(connection1->AddView(child2, child3));
TestViewManagerClient* connection1_client = test->last_view_manager_client();
connection1_client->tracker()->changes()->clear();
test->wm_client()->tracker()->changes()->clear();
EXPECT_TRUE(test->connection_manager()->CloneAndAnimate(child2));
EXPECT_TRUE(connection1_client->tracker()->changes()->empty());
EXPECT_TRUE(test->wm_client()->tracker()->changes()->empty());
// We cloned v2. The cloned view ends up as a sibling of it.
const ServerView* cloned_view = GetFirstCloned(connection1->GetView(child1));
ASSERT_TRUE(cloned_view);
// |cloned_view| should have one and only one cloned child (corresponds to
// |child3|).
ASSERT_EQ(1u, cloned_view->GetChildren().size());
EXPECT_TRUE(cloned_view->GetChildren()[0]->id() == ClonedViewId());
// Cloned views should match the bounds of the view they were cloned from.
EXPECT_EQ(v2->bounds(), cloned_view->bounds());
EXPECT_EQ(v3->bounds(), cloned_view->GetChildren()[0]->bounds());
// Cloned views are owned by the ConnectionManager and shouldn't be returned
// from ViewManagerServiceImpl::GetView.
EXPECT_TRUE(connection1->GetView(ClonedViewId()) == nullptr);
EXPECT_TRUE(test->wm_connection()->GetView(ClonedViewId()) == nullptr);
}
} // namespace
// Verifies ViewManagerService::GetViewTree() doesn't return cloned views.
TEST_F(ViewManagerServiceTest, ConnectionsCantSeeClonedViews) {
ViewId embed_view_id;
EXPECT_NO_FATAL_FAILURE(SetUpAnimate1(this, &embed_view_id));
ViewManagerServiceImpl* connection1 =
connection_manager()->GetConnectionWithRoot(embed_view_id);
const ViewId child1(connection1->id(), 1);
const ViewId child2(connection1->id(), 2);
const ViewId child3(connection1->id(), 3);
// Verify the root doesn't see any cloned views.
std::vector<const ServerView*> views(
wm_connection()->GetViewTree(*wm_connection()->root()));
ASSERT_EQ(5u, views.size());
ASSERT_TRUE(views[0]->id() == *wm_connection()->root());
ASSERT_TRUE(views[1]->id() == embed_view_id);
ASSERT_TRUE(views[2]->id() == child1);
ASSERT_TRUE(views[3]->id() == child2);
ASSERT_TRUE(views[4]->id() == child3);
// Verify connection1 doesn't see any cloned views.
std::vector<const ServerView*> v1_views(
connection1->GetViewTree(embed_view_id));
ASSERT_EQ(4u, v1_views.size());
ASSERT_TRUE(v1_views[0]->id() == embed_view_id);
ASSERT_TRUE(v1_views[1]->id() == child1);
ASSERT_TRUE(v1_views[2]->id() == child2);
ASSERT_TRUE(v1_views[3]->id() == child3);
}
TEST_F(ViewManagerServiceTest, ClonedViewsPromotedOnConnectionClose) {
ViewId embed_view_id;
EXPECT_NO_FATAL_FAILURE(SetUpAnimate1(this, &embed_view_id));
// Destroy connection1, which should force the cloned view to become a child
// of where it was embedded (the embedded view still exists).
connection_manager()->OnConnectionError(last_client_connection());
ServerView* embed_view = wm_connection()->GetView(embed_view_id);
ASSERT_TRUE(embed_view != nullptr);
const ServerView* cloned_view = GetFirstCloned(embed_view);
ASSERT_TRUE(cloned_view);
ASSERT_EQ(1u, cloned_view->GetChildren().size());
EXPECT_TRUE(cloned_view->GetChildren()[0]->id() == ClonedViewId());
// Because the cloned view changed parents its bounds should have changed.
EXPECT_EQ(gfx::Rect(3, 5, 6, 7), cloned_view->bounds());
// The bounds of the cloned child should not have changed though.
EXPECT_EQ(gfx::Rect(3, 4, 6, 7), cloned_view->GetChildren()[0]->bounds());
}
TEST_F(ViewManagerServiceTest, ClonedViewsPromotedOnHide) {
ViewId embed_view_id;
EXPECT_NO_FATAL_FAILURE(SetUpAnimate1(this, &embed_view_id));
ViewManagerServiceImpl* connection1 =
connection_manager()->GetConnectionWithRoot(embed_view_id);
// Hide the parent of the cloned view, which should force the cloned view to
// become a sibling of the parent.
const ServerView* view_to_hide =
connection1->GetView(ViewId(connection1->id(), 1));
ASSERT_TRUE(connection1->SetViewVisibility(view_to_hide->id(), false));
const ServerView* cloned_view = GetFirstCloned(view_to_hide->parent());
ASSERT_TRUE(cloned_view);
ASSERT_EQ(1u, cloned_view->GetChildren().size());
EXPECT_TRUE(cloned_view->GetChildren()[0]->id() == ClonedViewId());
EXPECT_EQ(2u, cloned_view->parent()->GetChildren().size());
EXPECT_TRUE(cloned_view->parent()->GetChildren()[1] == cloned_view);
}
// Clone and animate on a tree with more depth. Basically that of
// SetUpAnimate1() but cloning 2,1.
TEST_F(ViewManagerServiceTest, CloneAndAnimateLargerDepth) {
const ViewId embed_view_id(wm_connection()->id(), 1);
EXPECT_EQ(ERROR_CODE_NONE, wm_connection()->CreateView(embed_view_id));
EXPECT_TRUE(wm_connection()->SetViewVisibility(embed_view_id, true));
EXPECT_TRUE(
wm_connection()->AddView(*(wm_connection()->root()), embed_view_id));
mojo::URLRequestPtr request(mojo::URLRequest::New());
wm_connection()->EmbedAllowingReembed(embed_view_id, request.Pass(),
mojo::Callback<void(bool)>());
ViewManagerServiceImpl* connection1 =
connection_manager()->GetConnectionWithRoot(embed_view_id);
ASSERT_TRUE(connection1 != nullptr);
ASSERT_NE(connection1, wm_connection());
const ViewId child1(connection1->id(), 1);
EXPECT_EQ(ERROR_CODE_NONE, connection1->CreateView(child1));
const ViewId child2(connection1->id(), 2);
EXPECT_EQ(ERROR_CODE_NONE, connection1->CreateView(child2));
const ViewId child3(connection1->id(), 3);
EXPECT_EQ(ERROR_CODE_NONE, connection1->CreateView(child3));
ServerView* v1 = connection1->GetView(child1);
v1->SetVisible(true);
connection1->GetView(child2)->SetVisible(true);
connection1->GetView(child3)->SetVisible(true);
EXPECT_TRUE(connection1->AddView(embed_view_id, child1));
EXPECT_TRUE(connection1->AddView(child1, child2));
EXPECT_TRUE(connection1->AddView(child2, child3));
TestViewManagerClient* connection1_client = last_view_manager_client();
connection1_client->tracker()->changes()->clear();
wm_client()->tracker()->changes()->clear();
EXPECT_TRUE(connection_manager()->CloneAndAnimate(child1));
EXPECT_TRUE(connection1_client->tracker()->changes()->empty());
EXPECT_TRUE(wm_client()->tracker()->changes()->empty());
// We cloned v1. The cloned view ends up as a sibling of it.
const ServerView* cloned_view = GetFirstCloned(v1->parent());
ASSERT_TRUE(cloned_view);
// |cloned_view| should have a child and its child should have a child.
ASSERT_EQ(1u, cloned_view->GetChildren().size());
const ServerView* cloned_view_child = cloned_view->GetChildren()[0];
EXPECT_EQ(1u, cloned_view_child->GetChildren().size());
EXPECT_TRUE(cloned_view_child->id() == ClonedViewId());
}
// Verifies focus correctly changes on pointer events.
TEST_F(ViewManagerServiceTest, FocusOnPointer) {
const ViewId embed_view_id(wm_connection()->id(), 1);
EXPECT_EQ(ERROR_CODE_NONE, wm_connection()->CreateView(embed_view_id));
EXPECT_TRUE(wm_connection()->SetViewVisibility(embed_view_id, true));
EXPECT_TRUE(
wm_connection()->AddView(*(wm_connection()->root()), embed_view_id));
root_connection()->view_manager_root()->root_view()->
SetBounds(gfx::Rect(0, 0, 100, 100));
mojo::URLRequestPtr request(mojo::URLRequest::New());
wm_connection()->EmbedAllowingReembed(embed_view_id, request.Pass(),
mojo::Callback<void(bool)>());
ViewManagerServiceImpl* connection1 =
connection_manager()->GetConnectionWithRoot(embed_view_id);
ASSERT_TRUE(connection1 != nullptr);
ASSERT_NE(connection1, wm_connection());
connection_manager()
->GetView(embed_view_id)
->SetBounds(gfx::Rect(0, 0, 50, 50));
const ViewId child1(connection1->id(), 1);
EXPECT_EQ(ERROR_CODE_NONE, connection1->CreateView(child1));
EXPECT_TRUE(connection1->AddView(embed_view_id, child1));
ServerView* v1 = connection1->GetView(child1);
v1->SetVisible(true);
v1->SetBounds(gfx::Rect(20, 20, 20, 20));
TestViewManagerClient* connection1_client = last_view_manager_client();
connection1_client->tracker()->changes()->clear();
wm_client()->tracker()->changes()->clear();
connection_manager()->OnEvent(root_connection()->view_manager_root(),
CreatePointerDownEvent(21, 22));
// Focus should go to child1. This results in notifying both the window
// manager and client connection being notified.
EXPECT_EQ(v1, connection_manager()->GetFocusedView());
ASSERT_GE(wm_client()->tracker()->changes()->size(), 1u);
EXPECT_EQ("Focused id=2,1",
ChangesToDescription1(*wm_client()->tracker()->changes())[0]);
ASSERT_GE(connection1_client->tracker()->changes()->size(), 1u);
EXPECT_EQ(
"Focused id=2,1",
ChangesToDescription1(*connection1_client->tracker()->changes())[0]);
connection_manager()->OnEvent(root_connection()->view_manager_root(),
CreatePointerUpEvent(21, 22));
wm_client()->tracker()->changes()->clear();
connection1_client->tracker()->changes()->clear();
// Press outside of the embedded view. Focus should go to the root. Notice
// the client1 doesn't see who has focus as the focused view (root) isn't
// visible to it.
connection_manager()->OnEvent(root_connection()->view_manager_root(),
CreatePointerDownEvent(61, 22));
EXPECT_EQ(root_connection()->view_manager_root()->root_view(),
connection_manager()->GetFocusedView());
ASSERT_GE(wm_client()->tracker()->changes()->size(), 1u);
EXPECT_EQ("Focused id=0,2",
ChangesToDescription1(*wm_client()->tracker()->changes())[0]);
ASSERT_GE(connection1_client->tracker()->changes()->size(), 1u);
EXPECT_EQ(
"Focused id=null",
ChangesToDescription1(*connection1_client->tracker()->changes())[0]);
connection_manager()->OnEvent(root_connection()->view_manager_root(),
CreatePointerUpEvent(21, 22));
wm_client()->tracker()->changes()->clear();
connection1_client->tracker()->changes()->clear();
// Press in the same location. Should not get a focus change event (only input
// event).
connection_manager()->OnEvent(root_connection()->view_manager_root(),
CreatePointerDownEvent(61, 22));
EXPECT_EQ(root_connection()->view_manager_root()->root_view(),
connection_manager()->GetFocusedView());
ASSERT_EQ(wm_client()->tracker()->changes()->size(), 1u);
EXPECT_EQ("InputEvent view=0,2 event_action=4",
ChangesToDescription1(*wm_client()->tracker()->changes())[0]);
EXPECT_TRUE(connection1_client->tracker()->changes()->empty());
}
} // namespace view_manager
| [
"j.isorce@samsung.com"
] | j.isorce@samsung.com |
48a2ed549218a778646096b111f909c76dadb497 | 5a61f104872788485c63c39a41d6699d38ce9b24 | /Source/C++11/pow-test.cc | c9c309ffd065c2de3939f711dd2309efa3d645d6 | [
"CC0-1.0"
] | permissive | msporny/equihash | 841da83cd367895816fe209989a2b7ba37d67426 | 1b1eb1369ad6173d0e85a29323465f996552bb3e | refs/heads/master | 2021-01-01T18:50:59.634770 | 2017-07-26T17:28:51 | 2017-07-26T17:28:51 | 98,448,349 | 1 | 0 | null | 2017-07-26T17:24:23 | 2017-07-26T17:24:23 | null | UTF-8 | C++ | false | false | 2,702 | cc | /*Code by Dmitry Khovratovich, 2016
CC0 license
*/
#include "pow.h"
#include <inttypes.h>
#include <ctime>
#include "string.h"
#include <cstdlib>
using namespace _POW;
void TestEquihash(unsigned n, unsigned k, Seed seed)
{
Equihash equihash(n,k,seed);
Proof p = equihash.FindProof();
p.Test();
}
static void fatal(const char *error) {
fprintf(stderr, "Error: %s\n", error);
exit(1);
}
static void usage(const char *cmd) {
printf("Usage: %s [-n N] [-k K] "
"[-s S]\n",
cmd);
printf("Parameters:\n");
printf("\t-n N \t\tSets the tuple length of iterations to N\n");
printf("\t-k K\t\tSets the number of steps to K \n");
printf("\t-s S\t\tSets seed to S\n");
}
int main(int argc, char *argv[]) {
uint32_t n = 0, k=0;
Seed seed;
if (argc < 2) {
usage(argv[0]);
return 1;
}
/* parse options */
for (int i = 1; i < argc; i++) {
const char *a = argv[i];
unsigned long input = 0;
if (!strcmp(a, "-n")) {
if (i < argc - 1) {
i++;
input = strtoul(argv[i], NULL, 10);
if (input == 0 ||
input > 255) {
fatal("bad numeric input for -n");
}
n = input;
continue;
}
else {
fatal("missing -n argument");
}
}
else if (!strcmp(a, "-k")) {
if (i < argc - 1) {
i++;
input = strtoul(argv[i], NULL, 10);
if (input == 0 ||
input > 20) {
fatal("bad numeric input for -k");
}
k = input;
continue;
}
else {
fatal("missing -k argument");
}
}
if (!strcmp(a, "-s")) {
if (i < argc - 1) {
i++;
input = strtoul(argv[i], NULL, 10);
if (input == 0 ||
input > 0xFFFFFF) {
fatal("bad numeric input for -s");
}
seed = Seed(input);
continue;
}
else {
fatal("missing -s argument");
}
}
}
printf("N:\t%" PRIu32 " \n", n);
printf("K:\t%" PRIu32 " \n", k);
printf("SEED: ");
for (unsigned i = 0; i < SEED_LENGTH; ++i) {
printf(" \t%" PRIu32 " ", seed[i]);
}
printf("\n");
printf("Memory:\t\t%" PRIu64 "KiB\n", ((((uint32_t)1) << (n / (k + 1)))*LIST_LENGTH*k*sizeof(uint32_t)) / (1UL << 10));
TestEquihash(n,k,seed);
return 0;
}
| [
"khovratovich@gmail.com"
] | khovratovich@gmail.com |
10908bd0c98940ca78254404c3fae02dd7daa2b4 | 7646b14aa690ab0a56bfa8bef56ce9b0a5035b9b | /PSA13/PSA13_P3/p3/main.cpp | 48a1175d78ca33553239a5108574ce85adbb65b4 | [] | no_license | ChiaYi-LIN/Computer-Programming | 6176d562ac2e8b28061afe43fac08f21981e8bc4 | 6f8c1850e88b965ce62824fafd5477ea7d55bd0e | refs/heads/main | 2023-03-08T19:13:01.260345 | 2021-02-26T04:28:26 | 2021-02-26T04:28:26 | 342,324,699 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 972 | cpp | #include <iostream>
#include <iomanip>
#include "AveStudent.h"
using namespace std;
int main(){
AveStudent first("Heron", 75);
cout << "====Highest score====" <<endl;
cout << "Name >> " << first.getName() << endl;
cout << "Score >> " << first.getScore() << endl;
cout << "AveScore >> " << first.getAveScore() << endl;
cout << "=====================" <<endl;
string name;
int score;
while(first.getAveScore()>70){
cout << "New name >> ";
cin >> name;
cout << name <<"'s score >> ";
cin >> score;
cout << "====Update score====" <<endl;
if(score>=first.getScore()){
first.setName(name);
first.setScore(score);
}
first.setAveScore(score);
first.print();
cout << "=====================" <<endl;
}
cout << "====Highest score====" <<endl;
first.print();
cout << "=====================" <<endl;
return 0;
}
//class Student =>setName(),setScore(),getName(),getScore(),print()
//class AveStudent =>setAveScore(),getAveScore(),print()
| [
"b04704016@ntu.edu.tw"
] | b04704016@ntu.edu.tw |
a3902582fcc5b333be2e99cb1af00a201c04e3e6 | 49bd03a81641e531dbce907ceac6d09bc6819994 | /src/tensor_free.cc | 58cdd7088e577552b22f38ad6c33328853604f2e | [] | no_license | mapleyustat/tensor-1 | 8d401011185630b6c9863212450c5a58886f040f | e057acd50e1dcc8db59e39501ecc3143abb986a3 | refs/heads/master | 2020-12-28T23:50:20.554149 | 2011-11-04T22:41:53 | 2011-11-04T22:41:53 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,908 | cc |
#include "error.h"
#include "memory.h"
#include "tensor.h"
#include "utility.h"
#include <stdio.h>
#include <assert.h>
void
tensor_storage_free(tensor_storage_base_t *storage)
{
superfluous("tensor_storage_free((tensor_storage_base_t*)0x%x)\n", storage);
safe_free(storage->callbacks);
}
void
tensor_storage_free(tensor_storage_coordinate_t *storage)
{
superfluous("tensor_storage_free((tensor_storage_coordinate_t*)0x%x)\n", storage);
safe_free(storage->tuples);
}
void
tensor_storage_free(tensor_storage_compressed_t *storage)
{
superfluous("tensor_storage_free((tensor_storage_compressed_t*)0x%x)\n", storage);
safe_free(storage->RO);
safe_free(storage->CO);
safe_free(storage->TO);
safe_free(storage->KO);
}
void
tensor_storage_free(tensor_storage_extended_t *storage)
{
superfluous("tensor_storage_free((tensor_storage_extended_t*)0x%x)\n", storage);
safe_free(storage->RO);
safe_free(storage->CK);
}
void
tensor_storage_free(tensor_t *tensor)
{
superfluous("tensor_storage_free(0x%x)\n", tensor);
if (!tensor->storage) {
return;
}
tensor_storage_free(STORAGE_BASE(tensor));
switch (tensor->strategy) {
case strategy::coordinate:
tensor_storage_free(STORAGE_COORIDINATE(tensor));
break;
case strategy::compressed:
case strategy::slice:
tensor_storage_free(STORAGE_COMPRESSED(tensor));
break;
case strategy::ekmr:
case strategy::zzekmr:
tensor_storage_free(STORAGE_EXTENDED(tensor));
break;
default:
die("Tensor storage strategy '%d' is not supported.\n",
strategy_to_string(tensor->strategy));
}
safe_free(tensor->storage);
}
void
tensor_free(tensor_t *tensor)
{
superfluous("tensor_free(0x%x)\n", tensor);
if (!tensor) {
return;
}
if (ownership::creator == tensor->owner) {
safe_free(tensor->values);
tensor_storage_free(tensor);
}
safe_free(tensor);
}
| [
"ben.burnett@gmail.com"
] | ben.burnett@gmail.com |
28eede603d0b47350b75f985294d5d24244ecf62 | 49c72004aadead48ab24b4a8c73524254a1833f8 | /~20210117/20201216(1) 애니메이숀/playGround.h | 6a94006cff6f4e6c1be9a9723c8e68e6b3868b65 | [] | no_license | hyhgo0903/study | 2eba6c831340a8c21f2e342df5675dfef9dc1846 | db9ecc75a21dcfe7895a02b35634e10d0407ea84 | refs/heads/master | 2023-02-25T00:05:59.594043 | 2021-01-26T08:53:22 | 2021-01-26T08:53:22 | 329,924,847 | 0 | 0 | null | null | null | null | UHC | C++ | false | false | 439 | h | #pragma once
#include "gameNode.h"
#include "pixelCollision.h"
#include "animationTest.h"
class playGround : public gameNode
{
private:
pixelCollision* _pc;
animationTest* _at;
public:
playGround();
~playGround();
virtual HRESULT init(); //초기화 전용 함수
virtual void release(); //메모리 해제 함수
virtual void update(); //연산 전용
virtual void render(); //그리기 전용
int _count; // 비교용
};
| [
"hyhgo0903@gmail.com"
] | hyhgo0903@gmail.com |
9d68fc2384787fb4b4813ee52ce41782adc2cbda | 4e8e04ce9b873178ac60245a627570bffdb7c9c9 | /src/uint256.h | e86df5d99098beadbcb01544529a2d7733f1123e | [
"MIT"
] | permissive | blockarraygroup/bitcoinarray | 85fba20bb82faaf5f9269fc1eb71e6a03864ed5c | 4f7c01f5baeb8278538d0da3eb6c796022c97fd6 | refs/heads/master | 2021-09-02T02:22:52.845412 | 2017-12-29T18:12:15 | 2017-12-29T18:12:15 | 115,743,777 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,365 | h | // Copyright (c) 2009-2010 Satoshi Nakamoto
// Copyright (c) 2009-2016 The Bitcoin Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#ifndef BITCOINARRAY_UINT256_H
#define BITCOINARRAY_UINT256_H
#include "crypto/common.h"
#include <assert.h>
#include <cstring>
#include <stdexcept>
#include <stdint.h>
#include <string>
#include <vector>
/** Template base class for fixed-sized opaque blobs. */
template <unsigned int BITS>
class base_blob
{
protected:
enum { WIDTH = BITS / 8 };
uint8_t data[WIDTH];
public:
base_blob()
{
memset(data, 0, sizeof(data));
}
explicit base_blob(const std::vector<unsigned char>& vch);
bool IsNull() const
{
for (int i = 0; i < WIDTH; i++)
if (data[i] != 0)
return false;
return true;
}
void SetNull()
{
memset(data, 0, sizeof(data));
}
inline int Compare(const base_blob& other) const { return memcmp(data, other.data, sizeof(data)); }
friend inline bool operator==(const base_blob& a, const base_blob& b) { return a.Compare(b) == 0; }
friend inline bool operator!=(const base_blob& a, const base_blob& b) { return a.Compare(b) != 0; }
friend inline bool operator<(const base_blob& a, const base_blob& b) { return a.Compare(b) < 0; }
std::string GetHex() const;
void SetHex(const char* psz);
void SetHex(const std::string& str);
std::string ToString() const;
unsigned char* begin()
{
return &data[0];
}
unsigned char* end()
{
return &data[WIDTH];
}
const unsigned char* begin() const
{
return &data[0];
}
const unsigned char* end() const
{
return &data[WIDTH];
}
unsigned int size() const
{
return sizeof(data);
}
uint64_t GetUint64(int pos) const
{
const uint8_t* ptr = data + pos * 8;
return ((uint64_t)ptr[0]) |
((uint64_t)ptr[1]) << 8 |
((uint64_t)ptr[2]) << 16 |
((uint64_t)ptr[3]) << 24 |
((uint64_t)ptr[4]) << 32 |
((uint64_t)ptr[5]) << 40 |
((uint64_t)ptr[6]) << 48 |
((uint64_t)ptr[7]) << 56;
}
template <typename Stream>
void Serialize(Stream& s) const
{
s.write((char*)data, sizeof(data));
}
template <typename Stream>
void Unserialize(Stream& s)
{
s.read((char*)data, sizeof(data));
}
};
/** 160-bit opaque blob.
* @note This type is called uint160 for historical reasons only. It is an opaque
* blob of 160 bits and has no integer operations.
*/
class uint160 : public base_blob<160>
{
public:
uint160() {}
uint160(const base_blob<160>& b) : base_blob<160>(b) {}
explicit uint160(const std::vector<unsigned char>& vch) : base_blob<160>(vch) {}
};
/** 256-bit opaque blob.
* @note This type is called uint256 for historical reasons only. It is an
* opaque blob of 256 bits and has no integer operations. Use arith_uint256 if
* those are required.
*/
class uint256 : public base_blob<256>
{
public:
uint256() {}
uint256(const base_blob<256>& b) : base_blob<256>(b) {}
explicit uint256(const std::vector<unsigned char>& vch) : base_blob<256>(vch) {}
/** A cheap hash function that just returns 64 bits from the result, it can be
* used when the contents are considered uniformly random. It is not appropriate
* when the value can easily be influenced from outside as e.g. a network adversary could
* provide values to trigger worst-case behavior.
*/
uint64_t GetCheapHash() const
{
return ReadLE64(data);
}
};
/* uint256 from const char *.
* This is a separate function because the constructor uint256(const char*) can result
* in dangerously catching uint256(0).
*/
inline uint256 uint256S(const char* str)
{
uint256 rv;
rv.SetHex(str);
return rv;
}
/* uint256 from std::string.
* This is a separate function because the constructor uint256(const std::string &str) can result
* in dangerously catching uint256(0) via std::string(const char*).
*/
inline uint256 uint256S(const std::string& str)
{
uint256 rv;
rv.SetHex(str);
return rv;
}
#endif // BITCOINARRAY_UINT256_H
| [
"33236954+blockarray@users.noreply.github.com"
] | 33236954+blockarray@users.noreply.github.com |
84cbdebf2d87ee75dac1f50121de5ced9c31278c | e3646ddf6283df78c8f449c5faca0e9e4d31c3de | /leetcode/链表/147.对链表进行插入排序.cpp | 9f982b39dd4adde79253932eb385b4e3eebe5c14 | [] | no_license | SeizeTheMoment/Solution-to-Algorithm-Excercise | 54ec930e02bde179eb37b76d550f2c4765858346 | 79df5e6f1d89e359f815ea2c562b8c60c7035422 | refs/heads/master | 2021-09-26T16:36:54.729191 | 2021-09-25T13:26:58 | 2021-09-25T13:26:58 | 244,899,936 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 792 | cpp | /**
* Definition for singly-linked list.
* struct ListNode {
* int val;
* ListNode *next;
* ListNode(int x) : val(x), next(NULL) {}
* };
*/
class Solution {
public:
ListNode* insertionSortList(ListNode* head) {
if(head==NULL)
return NULL;
ListNode* L = new ListNode();
L->next = head;
ListNode* p = head->next;
ListNode* q, *prev, *temp;
head->next = NULL;
while(p!=NULL)
{
q = L->next;
prev = L;
while(q!=NULL && q->val<p->val)
{
prev = q;
q = q->next;
}
temp = p->next;
p->next = q;
prev->next = p;
p = temp;
}
return L->next;
}
}; | [
"1072118803@qq.com"
] | 1072118803@qq.com |
19d5bc5b060b1e4836b1c01ac230539bf668715a | d0a793ef7454f6ecc61fa422378ca04a9e2432e6 | /VBR/VBR_basic.h | 2c3212eb61c67fecb209ad656b975cf867f70ecc | [] | no_license | aldwng/thesis-VSRA | 44e9b5a62c92b003343bc88cab06f10e89d3d225 | f97790d9aaf3eac4b48a1619a9d4ee037a58f1c2 | refs/heads/master | 2023-04-10T04:47:45.411330 | 2018-04-21T01:06:22 | 2018-04-21T01:06:22 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 982 | h | #pragma once
#ifndef VBR_BASIC_H
#define VBR_BASIC_H
#include <time.h>
#include <stdlib.h>
#include <iostream>
#include <vector>
#include <string>
#include <unordered_map>
#include <map>
#include <algorithm>
#include <fstream>
const int MAXVOTER = 30;
const int MAXCANDIDATE = 40;
const float FAKEVOTER = 1.0;
const int ITERATION = 15; // the number of iterations will be tested during the routine
const int METHODS = 6;
const int RANGE = 99;
const int DECREASEFACTOR = 0.01;
const int INCREASEFACTOR = 100;
const int CONSTBALLOT = 9; // mischief voters' true ballot for every candidate
const int COMPROMISING_NUM = (MAXCANDIDATE / 2); // the number of ballot-compromised candidates
const int BURYING_NUM = (MAXCANDIDATE / 2); // the number of ballot-buried candidates
const int MODIFY_FACTOR = 3;
const int PROMOTE_FACTOR = 0.4;
const int PROMOTE_ROUNDS = 3;
// const int ALLIANCES = (MAXCANDIDATE / 5);
using namespace std;
#endif
| [
"noreply@github.com"
] | noreply@github.com |
b99a0e73b84f78bbdb85344b6a149db4a912d299 | e469e0c4e3f2bfca42ba96025fadf41ec987d09f | /SceneObject.cc | ec0cdf2c3f999bd9d5f1a2652c9bf84c277eb796 | [] | no_license | tabishr/RayTracer | ed7fd4ddcf258709464cb573f64ab721633666e9 | c43c5e79d67733730b343aa65ff7b37df075be96 | refs/heads/master | 2021-01-01T18:29:50.735120 | 2015-02-16T03:32:15 | 2015-02-16T03:32:15 | 27,144,213 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 497 | cc | #include "SceneObject.hh"
#include "RGBColor.hh"
SceneObject :: SceneObject(void){
surfaceColor = RGBColor(0.5, 0.5, 0.5);
}
RGBColor SceneObject :: get_surfaceColor(void) const{
return surfaceColor;
}
void SceneObject :: set_surfaceColor(const RGBColor &color){
surfaceColor = color;
}
RGBColor SceneObject :: surfaceColorAtPoint(const Vector3F &point) const{
/* Simple implementation for now; will add textures later */
return surfaceColor;
}
SceneObject :: ~SceneObject(void){ }
| [
"tabishr@gmail.com"
] | tabishr@gmail.com |
0cb2ba62af74f7b8b5b7864c3eb00e594cb8e52f | 38862301faaa0e8ab0ac434a91e315354bab2b3a | /Plant_Bin_Sensors.ino | 1baff9ef6a680b63010a6139f67607fe6fba7239 | [] | no_license | SeanWolfgang/Plant_Bin_Sensors | 598b60166125097626d65d5ad63865ac4a29f7cd | c8824a530a53c8163904ba96c9160fbecafb5866 | refs/heads/main | 2023-01-27T17:00:10.340997 | 2020-12-01T16:38:44 | 2020-12-01T16:38:44 | 317,389,431 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 8,022 | ino | // HTS221 Temperature and Humidity Libraries
#include <Wire.h>
#include <Adafruit_HTS221.h>
#include <Adafruit_Sensor.h>
// Soil Sensor Library
#include "Adafruit_seesaw.h"
// BH1750 Light Libraries
#include <Arduino.h>
#include <hp_BH1750.h> // include the library
// RTC library
#include <DS3231.h>
// SD Library
#include "SdFat.h"
// Include the liquid crystal library
#include <LiquidCrystal.h>
// Declaring class variables for sensors
Adafruit_HTS221 hts; // Temperature humidity
Adafruit_seesaw ss; // Soil
hp_BH1750 BH1750; // Light
// Initialize the DS3231 using the hardware interface
DS3231 rtc(SDA,SCL);
// Initialize SD module variable
#define SD_PIN 10
String SDFileName;
SdFat SD;
// initialize the library by associating any needed LCD interface pin
// with the arduino pin number it is connected to
//const int rs = 6, en = 7, d4 = 5, d5 = 4, d6 = 3, d7 = 2;
//LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
// Sensor data struct to store all readings in a central place
struct sensorData {
String timestamp;
float HTS221_temp;
float HTS221_humid;
float soil_temp;
float soil_humid;
float BH1750_light;
float VPD;
};
typedef struct sensorData SensorData;
SensorData plantSensorData;
// Define loop delay in milliseconds
int loopDelay = 5000;
void setup() {
// Start serial monitor at 9600
Serial.begin(9600);
// set up the LCD's number of columns and rows:
//lcd.begin(16, 2);
//lcd.print("Initializing...");
// Declar built in LED as output
pinMode(LED_BUILTIN, OUTPUT);
// Initialize temperature/humidity, soil, and light sensors
bool HTS221_avail = hts.begin_I2C();
bool soil_avail = ss.begin(0x36);
bool BH1750_avail = BH1750.begin(BH1750_TO_GROUND);
// Initalize the RTC
rtc.begin();
// Initialize SD card
initializeSD(SD_PIN);
assignFileName();
logHeader();
// Check if all the sensors initialized
if (!HTS221_avail || !soil_avail || !BH1750_avail) {
// Print status of sensor initialization if something failed
Serial.println("Some sensor was not started correctly.");
Serial.println("HTS221 = " + booleanOutput(HTS221_avail));
Serial.println("Soil = " + booleanOutput(soil_avail));
Serial.println("BH1750 = " + booleanOutput(BH1750_avail));
// Stick in infinite loop and blink LED to notify failure
while(1) {
//lcd.clear();
//lcd.print("Init failed.");
}
}
// If initialization succeeded, say so on LCD
//lcd.clear();
//lcd.print("Init OK.");
delay(1000);
}
void loop() {
// Get light reading in Lux from BH1750 sensor
//BH1750.start();
//float lux = BH1750.getLux();
//lcd.clear();
//lcd.print("Lux: " + String(lux));
// (note: line 1 is the second row, since counting begins with 0):
//lcd.setCursor(0, 1);
// print the number of seconds since reset:
//lcd.print(upTime());
//serialPrintSensors();
logSensorData();
delay(loopDelay);
}
// Takes a boolean input and returns the string of what it is
String booleanOutput(bool booleanInput) {
if (booleanInput) {
return "True";
} else {
return "False";
}
}
// Blink the built in LED defined in setup with the specified delay
void blinkWithDelay(int millisecondDelay) {
digitalWrite(LED_BUILTIN, HIGH); // turn the LED on (HIGH is the voltage level)
delay(millisecondDelay); // wait for a delay
digitalWrite(LED_BUILTIN, LOW); // turn the LED off by making the voltage LOW
delay(millisecondDelay); // wait for a delay
}
void serialPrintSensors() {
// Log sensor data for each data entry
populateSensorData();
// Print datetime
Serial.println(plantSensorData.timestamp);
// Print sensor readings
Serial.print("HTS221 temp: "); Serial.println(plantSensorData.HTS221_temp);
Serial.print("HTS221 hum: "); Serial.println(plantSensorData.HTS221_humid);
Serial.print("SS temp: "); Serial.println(plantSensorData.soil_temp);
Serial.print("SS moist: "); Serial.println(plantSensorData.soil_humid);
Serial.print("BH1750 Lux: "); Serial.println(plantSensorData.BH1750_light);
Serial.print("VPD: "); Serial.println(plantSensorData.VPD);
Serial.print("\n");
}
void initializeSD(int pinSD) {
// Serial.print("Initializing SD card...");
if (!SD.begin(pinSD)) {
// Serial.println("initialization failed!");
//lcd.clear();
//lcd.print("Wait SD...");
blinkWithDelay(1000);
delay(5000);
initializeSD(SD_PIN);
}
// Serial.println("initialization done.");
}
void assignFileName() {
// Print formatted time to character buffer
char buff[50];
String dateString = rtc.getDateStr(FORMAT_LONG,FORMAT_MIDDLEENDIAN,'-');
String timeString = rtc.getTimeStr();
timeString.replace(':','-');
String togetherString = dateString + "_" + timeString + ".txt";
togetherString.toCharArray(buff, 50);
// Set global SD file name to the formatted timestamp
SDFileName = buff;
}
void logHeader() {
// Using local file variable to log to
File logFile;
// Open log file with formatted file name assigned in assignFileName
logFile = SD.open(SDFileName, FILE_WRITE);
// Log headers for each data entry
logFile.print("Timestamp"); logFile.print("\t");
logFile.print("HTS221_Temp"); logFile.print("\t");
logFile.print("HTS221_Hum"); logFile.print("\t");
logFile.print("SS_Temp"); logFile.print("\t");
logFile.print("SS_Moist"); logFile.print("\t");
logFile.print("BH1750_Lux"); logFile.print("\t");
logFile.print("VPD"); logFile.print("\n");
logFile.close();
}
void logSensorData() {
// Log sensor data for each data entry
populateSensorData();
// Using local file variable to log to
File logFile;
// Open log file with formatted file name assigned in assignFileName
logFile = SD.open(SDFileName, FILE_WRITE);
// Print datetime
logFile.print(plantSensorData.timestamp); logFile.print("\t");
// Print sensor readings
logFile.print(plantSensorData.HTS221_temp); logFile.print("\t");
logFile.print(plantSensorData.HTS221_humid); logFile.print("\t");
logFile.print(plantSensorData.soil_temp); logFile.print("\t");
logFile.print(plantSensorData.soil_humid); logFile.print("\t");
logFile.print(plantSensorData.BH1750_light); logFile.print("\t");
logFile.print(plantSensorData.VPD); logFile.print("\n");
logFile.close();
}
void populateSensorData() {
// Get temperature and humidity readings from HTS221 sensor
sensors_event_t HTS_temp;
sensors_event_t HTS_humidity;
hts.getEvent(&HTS_humidity, &HTS_temp);
// Get soil moisture from soil sensor
float ssTempC = ss.getTemp();
uint16_t ssMoist = ss.touchRead(0);
// Get light reading in Lux from BH1750 sensor
BH1750.start();
float lux = BH1750.getLux();
String dateTimeStamp;
dateTimeStamp.concat(rtc.getDateStr(FORMAT_LONG,FORMAT_MIDDLEENDIAN,'/'));
dateTimeStamp.concat(" ");
dateTimeStamp.concat(rtc.getTimeStr());
plantSensorData.timestamp = dateTimeStamp;
plantSensorData.HTS221_temp = HTS_temp.temperature;
plantSensorData.HTS221_humid = HTS_humidity.relative_humidity;
plantSensorData.soil_temp = ssTempC;
plantSensorData.soil_humid = ssMoist;
plantSensorData.BH1750_light = lux;
plantSensorData.VPD = calcVPD(HTS_temp.temperature, HTS_humidity.relative_humidity);
}
// Return vapor pressure deficit to air
float calcVPD(float temp, float hum) {
// Calculation from: https://betterorganix.com/blog/what-is-how-to-calculate-vapour-pressure-deficit/#:~:text=To%20Get%20VPD%2C%20we%20need,And%20VOILA%2C%20you%20have%20VPD.
float VPsat = ((610.7 * pow(10, (7.5 * temp) / (237.3 + temp))) / 1000);
float VPair = VPsat * (hum / 100);
return VPsat - VPair;
}
String upTime() {
unsigned long upMillis = millis();
char outChars[22];
int hours = upMillis / 3600000;
int minutes = (upMillis / 60000) % 60;
int seconds = (upMillis / 1000) % 60;
sprintf(outChars, "%d:%02d:%02d", hours, minutes, seconds);
return (String(outChars));
}
| [
"seanwolfgang.wachtel@gmail.com"
] | seanwolfgang.wachtel@gmail.com |
05ccc2617820f47da717838ed19d4185a7c841b9 | 00c96f48bc1662999faec7b51cea4a86a71c0cfd | /QBase/Kqueue.h | f5cd481699315baad6af9f6b62ea3955b29fd09d | [
"MIT"
] | permissive | loveyacper/Qedis | 3dd34a0247f60e3975ee1fbae8f865a1409480e4 | a68b8261737b860da5e906563be151b91af1835a | refs/heads/master | 2023-08-11T02:06:36.694605 | 2023-05-04T03:50:03 | 2023-05-04T03:50:03 | 23,990,558 | 192 | 52 | MIT | 2021-04-02T06:10:56 | 2014-09-13T09:25:22 | C++ | UTF-8 | C++ | false | false | 491 | h | #ifndef BERT_KQUEUE_H
#define BERT_KQUEUE_H
#if defined(__APPLE__)
#include "Poller.h"
#include <vector>
class Kqueue : public Poller
{
public:
Kqueue();
~Kqueue();
bool AddSocket(int sock, int events, void* userPtr);
bool ModSocket(int sock, int events, void* userPtr);
bool DelSocket(int sock, int events);
int Poll(std::vector<FiredEvent>& events, std::size_t maxEvent, int timeoutMs);
private:
std::vector<struct kevent> events_;
};
#endif
#endif
| [
"bertyoung666@gmail.com"
] | bertyoung666@gmail.com |
3087844cff5545169ede15d0721a2cc5f427c96b | c48ec32b65ec2a83ee3502e1aed3028f1544b08d | /3DHomeEngine/src/main/jni/src/skia/core/SkWriter32.h | c8ebb6a6ef62dede71dc51cdea73c73c21e7ea3b | [] | no_license | 3DHome/3DHome | 76e915b0dc4a9861b9dd0928d63a0cfb451f00d5 | bb8cafc233e672029f68da103d9c236457940f43 | refs/heads/master | 2021-01-20T00:56:49.582553 | 2019-03-09T09:34:11 | 2019-03-13T13:53:26 | 26,866,756 | 34 | 23 | null | 2014-12-09T10:30:15 | 2014-11-19T15:09:55 | C++ | UTF-8 | C++ | false | false | 4,584 | h | /*
* Copyright (C) 2008 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef SkWriter32_DEFINED
#define SkWriter32_DEFINED
#include "SkTypes.h"
#include "SkScalar.h"
#include "SkPoint.h"
#include "SkRect.h"
class SkStream;
class SkWStream;
class SkWriter32 : SkNoncopyable {
public:
SkWriter32(size_t minSize) {
fMinSize = minSize;
fSize = 0;
fHead = fTail = NULL;
fSingleBlock = NULL;
}
~SkWriter32();
/**
* Returns the single block backing the writer, or NULL if the memory is
* to be dynamically allocated.
*/
void* getSingleBlock() const { return fSingleBlock; }
/**
* Specify the single block to back the writer, rathern than dynamically
* allocating the memory. If block == NULL, then the writer reverts to
* dynamic allocation (and resets).
*/
void reset(void* block, size_t size);
bool writeBool(bool value) {
this->writeInt(value);
return value;
}
void writeInt(int32_t value) {
*(int32_t*)this->reserve(sizeof(value)) = value;
}
void write8(int32_t value) {
*(int32_t*)this->reserve(sizeof(value)) = value & 0xFF;
}
void write16(int32_t value) {
*(int32_t*)this->reserve(sizeof(value)) = value & 0xFFFF;
}
void write32(int32_t value) {
*(int32_t*)this->reserve(sizeof(value)) = value;
}
void writeScalar(SkScalar value) {
*(SkScalar*)this->reserve(sizeof(value)) = value;
}
void writePoint(const SkPoint& pt) {
*(SkPoint*)this->reserve(sizeof(pt)) = pt;
}
void writeRect(const SkRect& rect) {
*(SkRect*)this->reserve(sizeof(rect)) = rect;
}
// write count bytes (must be a multiple of 4)
void writeMul4(const void* values, size_t size) {
this->write(values, size);
}
/**
* Write size bytes from values. size must be a multiple of 4, though
* values need not be 4-byte aligned.
*/
void write(const void* values, size_t size) {
SkASSERT(SkAlign4(size) == size);
// if we could query how much is avail in the current block, we might
// copy that much, and then alloc the rest. That would reduce the waste
// in the current block
memcpy(this->reserve(size), values, size);
}
void writePad(const void* src, size_t size);
/**
* Writes a string to the writer, which can be retrieved with
* SkReader32::readString().
* The length can be specified, or if -1 is passed, it will be computed by
* calling strlen(). The length must be < 0xFFFF
*/
void writeString(const char* str, size_t len = (size_t)-1);
/**
* Computes the size (aligned to multiple of 4) need to write the string
* in a call to writeString(). If the length is not specified, it will be
* computed by calling strlen().
*/
static size_t WriteStringSize(const char* str, size_t len = (size_t)-1);
// return the current offset (will always be a multiple of 4)
uint32_t size() const { return fSize; }
void reset();
uint32_t* reserve(size_t size); // size MUST be multiple of 4
// return the address of the 4byte int at the specified offset (which must
// be a multiple of 4. This does not allocate any new space, so the returned
// address is only valid for 1 int.
uint32_t* peek32(size_t offset);
// copy into a single buffer (allocated by caller). Must be at least size()
void flatten(void* dst) const;
// read from the stream, and write up to length bytes. Return the actual
// number of bytes written.
size_t readFromStream(SkStream*, size_t length);
bool writeToStream(SkWStream*);
private:
size_t fMinSize;
uint32_t fSize;
char* fSingleBlock;
uint32_t fSingleBlockSize;
struct Block;
Block* fHead;
Block* fTail;
Block* newBlock(size_t bytes);
};
#endif
| [
"yangfeng@yangfengdeMacBook-Pro.local"
] | yangfeng@yangfengdeMacBook-Pro.local |
45799c531ace0b2c4f1fc92475f17b972ff5fb54 | d19d5f5f2f7e44884932aa087c63a549f53f0907 | /SwingEngine/SEGeometricTools/Distance/SEDistSegment2Segment2.h | b0025b998285686d7067a5b1dd1988585717cd54 | [] | no_license | jazzboysc/SwingEngine2 | d26c60f4cbf89f0d7207e5152cae69677a4d7b18 | d7dbd09a5e7748def0bd3fa6a547b1c734529f61 | refs/heads/master | 2021-03-27T11:05:20.543758 | 2018-07-13T09:42:22 | 2018-07-13T09:42:22 | 44,491,987 | 3 | 0 | null | null | null | null | GB18030 | C++ | false | false | 1,806 | h | // Swing Engine Version 2 Source Code
// Most of techniques in the engine are mainly based on David Eberly's
// Wild Magic 4 and 5 open-source game engine. The author of Swing Engine
// learned a lot from Eberly's experience of architecture and algorithm.
// Several subsystems are totally new, and others are reorganized or
// reimplimented based on Wild Magic's subsystems.
// Copyright (c) 2007-2011
//
// David Eberly's permission:
// Geometric Tools, LLC
// Copyright (c) 1998-2010
// Distributed under the Boost Software License, Version 1.0.
// http://www.boost.org/LICENSE_1_0.txt
// http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt
#ifndef Swing_DistSegment2Segment2_H
#define Swing_DistSegment2Segment2_H
#include "SEGeometricToolsLIB.h"
#include "SEDistance.h"
#include "SESegment2.h"
namespace Swing
{
//----------------------------------------------------------------------------
// Description:
// Date:20090119
//----------------------------------------------------------------------------
class SE_GEOMETRICTOOLS_API SEDistSegment2Segment2f : public SEDistance<float,
SEVector2f>
{
public:
SEDistSegment2Segment2f(const SESegment2f& rSegment0,
const SESegment2f& rSegment1);
// 对象访问.
const SESegment2f& GetSegment0(void) const;
const SESegment2f& GetSegment1(void) const;
// static distance查询.
virtual float Get(void);
virtual float GetSquared(void);
// 用于dynamic distance查询的convex function计算.
virtual float Get(float fT, const SEVector2f& rVelocity0,
const SEVector2f& rVelocity1);
virtual float GetSquared(float fT, const SEVector2f& rVelocity0,
const SEVector2f& rVelocity1);
private:
const SESegment2f* m_pSegment0;
const SESegment2f* m_pSegment1;
};
}
#endif
| [
"S515380c"
] | S515380c |
a265314fa4f124e3fe89d5595e5f70a2f883b21c | 7252ca0228705a1cfd47c6437fa45eec9b19565e | /kimug2145/17136/17136.cpp14.cpp | 80f57740b5f31b06828a6e799458f946754a4c97 | [] | no_license | seungjae-yu/Algorithm-Solving-BOJ | 1acf12668dc803413af28f8c0dc61f923d6e2e17 | e294d631b2808fdcfc80317bd2b0bccccc7fc065 | refs/heads/main | 2023-08-19T00:30:13.832180 | 2021-10-06T14:49:12 | 2021-10-06T14:49:12 | 414,241,010 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,308 | cpp | #include <iostream>
#include <algorithm>
#include <cmath>
#include <cstring>
using namespace std;
typedef pair<int, int> pii;
#define INF 1987654321
int inp[10][10], cnt[6], ans = INF;
pii chk(int arr[10][10]) {
for (int i = 0; i < 10; i++)
for (int j = 0; j < 10; j++)
if (arr[i][j]) return { i,j };
return { -INF,-INF };
}
bool isOk(int arr[10][10], pii p, int sz) {
for (int i = p.first; i < p.first + sz; i++)
for (int j = p.second; j < p.second + sz; j++)
if (i > 9 || j > 9 || arr[i][j] == 0) return false;
return true;
}
void func(int arr[10][10], int ssum, int cnt[6]) {
if (ssum > 25 || ssum >= ans) return;
pii p = chk(arr);
if (p == make_pair(-INF, -INF)) { ans = min(ans, ssum); return; }
for (int k = 5; k >= 1; k--) {
if (cnt[k] <= 0) continue;
if (isOk(arr, p, k)) {
int tmp[10][10] = { 0, };
memcpy(tmp, arr, sizeof(tmp));
for (int i = p.first; i < p.first + k; i++)
for (int j = p.second; j < p.second + k; j++)
tmp[i][j] = 0;
cnt[k]--;
func(tmp, ssum + 1, cnt);
cnt[k]++;
}
}
}
int main() {
for (int i = 0; i < 10; i++)
for (int j = 0; j < 10; j++)
scanf("%d", &inp[i][j]);
fill(cnt, cnt + 6, 5);
func(inp, 0, cnt);
printf("%d\n", ans == INF ? -1 : ans);
} | [
"kimug2145@gmail.com"
] | kimug2145@gmail.com |
7e2bfffa41d0cf5c3e17d026b24f7a2588be8261 | 1b1f4fbd33229b3dcad1790ee7601a6e400d1b3a | /Programming Challenges/Chapter03/3_18.cpp | 1fc16467d3b30f0c58574b90ca28df86982fbb9e | [] | no_license | mistervunguyen/starting-out-with-c-plus-plus-early-objects-solutions | 2c30749d97485f5f1dec32731ba23ac0875b7811 | cd496d3652e254752afad5868c3e2d09a127ff53 | refs/heads/master | 2021-03-05T11:51:52.603305 | 2020-04-17T22:53:29 | 2020-04-17T22:53:29 | 246,120,410 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,798 | cpp | // Chapter 3 - Programming Challenge 18, Senior Citizen Property Tax
// This program computes the assessed value and property tax
// on a senior citizen's property.
#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
const double
ASSESS_FACTOR = .60, // Factor to figure assessment value
SENIOR_EXEMPTION = 5000.00; // Senior citizen homeowner exemption
const int
NUM_QTRS = 4; // Number of annual (quarterly) payments
double actualValue, // Actual value of property
assessedValue, // Assessed value of property
taxRate, // County tax amount per $100
propertyTax, // Amount of tax on property
quarterlyPmt; // Amount due per payment
// Get user input
cout << "Enter the actual property value: $ ";
cin >> actualValue;
cout << "Enter the amount of tax per $100 of assessed value: $";
cin >> taxRate;
// Perform computations
assessedValue = actualValue * ASSESS_FACTOR - SENIOR_EXEMPTION;
propertyTax = (assessedValue / 100) * taxRate;
quarterlyPmt = propertyTax / NUM_QTRS;
// Display results
cout << fixed << showpoint << setprecision(2) << endl;
cout << "Property Value: $" << setw(10) << actualValue << endl;
cout << "Assessed Value: $" << setw(10) << assessedValue << endl;
cout << "Property Tax: $" << setw(10) << propertyTax << endl;
cout << "Quarterly Payment: $" << setw(10) << quarterlyPmt << endl;
return 0;
}
/* SAMPLE RUN RESULTS
Enter the actual property value: $ 158000
Enter the amount of tax per $100 of assessed value: $2.64
Property Value: $ 158000.00
Assessed Value: $ 89800.00
Property Tax: $ 2370.72
Quarterly Payment: $ 592.68
*/
| [
"noreply@github.com"
] | noreply@github.com |
436b3fe8642951f63b7700bbdfcca5d1a56f9386 | 4523e0aa41717ba9f7f8815a423bfbd2e5eea28d | /ToonTanksProjectSetup_4.22/ToonTanksProjectSetup_4.22/ToonTanks/Intermediate/Build/Win64/UE4Editor/Inc/ToonTanks/TankGameModeBase.generated.h | 05fe6458b3c761d17aca13e2ff2786a247d10c3e | [] | no_license | ricethief0/Unreal_Study | 5a7d49a4033e86ff4a80564448598b720df85cab | 81bddb5899d89940de2588e59585ab8063e1b015 | refs/heads/main | 2023-02-21T10:13:55.639135 | 2021-01-28T00:59:04 | 2021-01-28T00:59:04 | 331,244,078 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 5,002 | h | // Copyright 1998-2019 Epic Games, Inc. All Rights Reserved.
/*===========================================================================
Generated code exported from UnrealHeaderTool.
DO NOT modify this manually! Edit the corresponding .h files instead!
===========================================================================*/
#include "UObject/ObjectMacros.h"
#include "UObject/ScriptMacros.h"
PRAGMA_DISABLE_DEPRECATION_WARNINGS
#ifdef TOONTANKS_TankGameModeBase_generated_h
#error "TankGameModeBase.generated.h already included, missing '#pragma once' in TankGameModeBase.h"
#endif
#define TOONTANKS_TankGameModeBase_generated_h
#define ToonTanks_Source_ToonTanks_GameModes_TankGameModeBase_h_17_RPC_WRAPPERS
#define ToonTanks_Source_ToonTanks_GameModes_TankGameModeBase_h_17_RPC_WRAPPERS_NO_PURE_DECLS
#define ToonTanks_Source_ToonTanks_GameModes_TankGameModeBase_h_17_EVENT_PARMS \
struct TankGameModeBase_eventGameOver_Parms \
{ \
bool PlayerWon; \
};
#define ToonTanks_Source_ToonTanks_GameModes_TankGameModeBase_h_17_CALLBACK_WRAPPERS
#define ToonTanks_Source_ToonTanks_GameModes_TankGameModeBase_h_17_INCLASS_NO_PURE_DECLS \
private: \
static void StaticRegisterNativesATankGameModeBase(); \
friend struct Z_Construct_UClass_ATankGameModeBase_Statics; \
public: \
DECLARE_CLASS(ATankGameModeBase, AGameModeBase, COMPILED_IN_FLAGS(0 | CLASS_Transient), CASTCLASS_None, TEXT("/Script/ToonTanks"), NO_API) \
DECLARE_SERIALIZER(ATankGameModeBase)
#define ToonTanks_Source_ToonTanks_GameModes_TankGameModeBase_h_17_INCLASS \
private: \
static void StaticRegisterNativesATankGameModeBase(); \
friend struct Z_Construct_UClass_ATankGameModeBase_Statics; \
public: \
DECLARE_CLASS(ATankGameModeBase, AGameModeBase, COMPILED_IN_FLAGS(0 | CLASS_Transient), CASTCLASS_None, TEXT("/Script/ToonTanks"), NO_API) \
DECLARE_SERIALIZER(ATankGameModeBase)
#define ToonTanks_Source_ToonTanks_GameModes_TankGameModeBase_h_17_STANDARD_CONSTRUCTORS \
/** Standard constructor, called after all reflected properties have been initialized */ \
NO_API ATankGameModeBase(const FObjectInitializer& ObjectInitializer = FObjectInitializer::Get()); \
DEFINE_DEFAULT_OBJECT_INITIALIZER_CONSTRUCTOR_CALL(ATankGameModeBase) \
DECLARE_VTABLE_PTR_HELPER_CTOR(NO_API, ATankGameModeBase); \
DEFINE_VTABLE_PTR_HELPER_CTOR_CALLER(ATankGameModeBase); \
private: \
/** Private move- and copy-constructors, should never be used */ \
NO_API ATankGameModeBase(ATankGameModeBase&&); \
NO_API ATankGameModeBase(const ATankGameModeBase&); \
public:
#define ToonTanks_Source_ToonTanks_GameModes_TankGameModeBase_h_17_ENHANCED_CONSTRUCTORS \
/** Standard constructor, called after all reflected properties have been initialized */ \
NO_API ATankGameModeBase(const FObjectInitializer& ObjectInitializer = FObjectInitializer::Get()) : Super(ObjectInitializer) { }; \
private: \
/** Private move- and copy-constructors, should never be used */ \
NO_API ATankGameModeBase(ATankGameModeBase&&); \
NO_API ATankGameModeBase(const ATankGameModeBase&); \
public: \
DECLARE_VTABLE_PTR_HELPER_CTOR(NO_API, ATankGameModeBase); \
DEFINE_VTABLE_PTR_HELPER_CTOR_CALLER(ATankGameModeBase); \
DEFINE_DEFAULT_OBJECT_INITIALIZER_CONSTRUCTOR_CALL(ATankGameModeBase)
#define ToonTanks_Source_ToonTanks_GameModes_TankGameModeBase_h_17_PRIVATE_PROPERTY_OFFSET \
FORCEINLINE static uint32 __PPO__StartDelay() { return STRUCT_OFFSET(ATankGameModeBase, StartDelay); }
#define ToonTanks_Source_ToonTanks_GameModes_TankGameModeBase_h_14_PROLOG \
ToonTanks_Source_ToonTanks_GameModes_TankGameModeBase_h_17_EVENT_PARMS
#define ToonTanks_Source_ToonTanks_GameModes_TankGameModeBase_h_17_GENERATED_BODY_LEGACY \
PRAGMA_DISABLE_DEPRECATION_WARNINGS \
public: \
ToonTanks_Source_ToonTanks_GameModes_TankGameModeBase_h_17_PRIVATE_PROPERTY_OFFSET \
ToonTanks_Source_ToonTanks_GameModes_TankGameModeBase_h_17_RPC_WRAPPERS \
ToonTanks_Source_ToonTanks_GameModes_TankGameModeBase_h_17_CALLBACK_WRAPPERS \
ToonTanks_Source_ToonTanks_GameModes_TankGameModeBase_h_17_INCLASS \
ToonTanks_Source_ToonTanks_GameModes_TankGameModeBase_h_17_STANDARD_CONSTRUCTORS \
public: \
PRAGMA_ENABLE_DEPRECATION_WARNINGS
#define ToonTanks_Source_ToonTanks_GameModes_TankGameModeBase_h_17_GENERATED_BODY \
PRAGMA_DISABLE_DEPRECATION_WARNINGS \
public: \
ToonTanks_Source_ToonTanks_GameModes_TankGameModeBase_h_17_PRIVATE_PROPERTY_OFFSET \
ToonTanks_Source_ToonTanks_GameModes_TankGameModeBase_h_17_RPC_WRAPPERS_NO_PURE_DECLS \
ToonTanks_Source_ToonTanks_GameModes_TankGameModeBase_h_17_CALLBACK_WRAPPERS \
ToonTanks_Source_ToonTanks_GameModes_TankGameModeBase_h_17_INCLASS_NO_PURE_DECLS \
ToonTanks_Source_ToonTanks_GameModes_TankGameModeBase_h_17_ENHANCED_CONSTRUCTORS \
private: \
PRAGMA_ENABLE_DEPRECATION_WARNINGS
template<> TOONTANKS_API UClass* StaticClass<class ATankGameModeBase>();
#undef CURRENT_FILE_ID
#define CURRENT_FILE_ID ToonTanks_Source_ToonTanks_GameModes_TankGameModeBase_h
PRAGMA_ENABLE_DEPRECATION_WARNINGS
| [
"net050722@gmail.com"
] | net050722@gmail.com |
67ec4c4c83e63096ffb6afa61c77b5420a63db37 | 0390f93fe60533ac9ba8aa11aa8cbbddd4bc5a3d | /src/irc.cpp | fadc796fb2d987275f2c74f0a5a1deed7c78a7f0 | [
"MIT"
] | permissive | nanoteccoin/Source-Code | adbe31875eb21f114ca46212d7a89e1c9ae09565 | eda186cc58ba992253d1e7efa9670cb380c8a2c2 | refs/heads/master | 2021-05-11T17:46:23.050452 | 2018-01-17T08:09:03 | 2018-01-17T08:09:03 | 117,804,941 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 10,956 | cpp | // Copyright (c) 2009-2010 Satoshi Nakamoto
// Copyright (c) 2009-2012 The Bitcoin developers
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include "irc.h"
#include "net.h"
#include "strlcpy.h"
#include "base58.h"
using namespace std;
using namespace boost;
int nGotIRCAddresses = 0;
void ThreadIRCSeed2(void* parg);
#pragma pack(push, 1)
struct ircaddr
{
struct in_addr ip;
short port;
};
#pragma pack(pop)
string EncodeAddress(const CService& addr)
{
struct ircaddr tmp;
if (addr.GetInAddr(&tmp.ip))
{
tmp.port = htons(addr.GetPort());
vector<unsigned char> vch(UBEGIN(tmp), UEND(tmp));
return string("u") + EncodeBase58Check(vch);
}
return "";
}
bool DecodeAddress(string str, CService& addr)
{
vector<unsigned char> vch;
if (!DecodeBase58Check(str.substr(1), vch))
return false;
struct ircaddr tmp;
if (vch.size() != sizeof(tmp))
return false;
memcpy(&tmp, &vch[0], sizeof(tmp));
addr = CService(tmp.ip, ntohs(tmp.port));
return true;
}
static bool Send(SOCKET hSocket, const char* pszSend)
{
if (strstr(pszSend, "PONG") != pszSend)
printf("IRC SENDING: %s\n", pszSend);
const char* psz = pszSend;
const char* pszEnd = psz + strlen(psz);
while (psz < pszEnd)
{
int ret = send(hSocket, psz, pszEnd - psz, MSG_NOSIGNAL);
if (ret < 0)
return false;
psz += ret;
}
return true;
}
bool RecvLineIRC(SOCKET hSocket, string& strLine)
{
while (true)
{
bool fRet = RecvLine(hSocket, strLine);
if (fRet)
{
if (fShutdown)
return false;
vector<string> vWords;
ParseString(strLine, ' ', vWords);
if (vWords.size() >= 1 && vWords[0] == "PING")
{
strLine[1] = 'O';
strLine += '\r';
Send(hSocket, strLine.c_str());
continue;
}
}
return fRet;
}
}
int RecvUntil(SOCKET hSocket, const char* psz1, const char* psz2=NULL, const char* psz3=NULL, const char* psz4=NULL)
{
while (true)
{
string strLine;
strLine.reserve(10000);
if (!RecvLineIRC(hSocket, strLine))
return 0;
printf("IRC %s\n", strLine.c_str());
if (psz1 && strLine.find(psz1) != string::npos)
return 1;
if (psz2 && strLine.find(psz2) != string::npos)
return 2;
if (psz3 && strLine.find(psz3) != string::npos)
return 3;
if (psz4 && strLine.find(psz4) != string::npos)
return 4;
}
}
bool Wait(int nSeconds)
{
if (fShutdown)
return false;
printf("IRC waiting %d seconds to reconnect\n", nSeconds);
for (int i = 0; i < nSeconds; i++)
{
if (fShutdown)
return false;
MilliSleep(1000);
}
return true;
}
bool RecvCodeLine(SOCKET hSocket, const char* psz1, string& strRet)
{
strRet.clear();
while (true)
{
string strLine;
if (!RecvLineIRC(hSocket, strLine))
return false;
vector<string> vWords;
ParseString(strLine, ' ', vWords);
if (vWords.size() < 2)
continue;
if (vWords[1] == psz1)
{
printf("IRC %s\n", strLine.c_str());
strRet = strLine;
return true;
}
}
}
bool GetIPFromIRC(SOCKET hSocket, string strMyName, CNetAddr& ipRet)
{
Send(hSocket, strprintf("USERHOST %s\r", strMyName.c_str()).c_str());
string strLine;
if (!RecvCodeLine(hSocket, "302", strLine))
return false;
vector<string> vWords;
ParseString(strLine, ' ', vWords);
if (vWords.size() < 4)
return false;
string str = vWords[3];
if (str.rfind("@") == string::npos)
return false;
string strHost = str.substr(str.rfind("@")+1);
// Hybrid IRC used by lfnet always returns IP when you userhost yourself,
// but in case another IRC is ever used this should work.
printf("GetIPFromIRC() got userhost %s\n", strHost.c_str());
CNetAddr addr(strHost, true);
if (!addr.IsValid())
return false;
ipRet = addr;
return true;
}
void ThreadIRCSeed(void* parg)
{
// Make this thread recognisable as the IRC seeding thread
RenameThread("nanotec-ircseed");
try
{
ThreadIRCSeed2(parg);
}
catch (std::exception& e) {
PrintExceptionContinue(&e, "ThreadIRCSeed()");
} catch (...) {
PrintExceptionContinue(NULL, "ThreadIRCSeed()");
}
printf("ThreadIRCSeed exited\n");
}
void ThreadIRCSeed2(void* parg)
{
// Don't connect to IRC if we won't use IPv4 connections.
if (IsLimited(NET_IPV4))
return;
// ... or if we won't make outbound connections and won't accept inbound ones.
if (mapArgs.count("-connect") && fNoListen)
return;
// ... or if IRC is not enabled.
if (!GetBoolArg("-irc", false))
return;
printf("ThreadIRCSeed started\n");
int nErrorWait = 10;
int nRetryWait = 10;
int nNameRetry = 0;
while (!fShutdown)
{
CService addrConnect("92.243.23.21", 6667); // irc.lfnet.org
CService addrIRC("irc.lfnet.org", 6667, true);
if (addrIRC.IsValid())
addrConnect = addrIRC;
SOCKET hSocket;
if (!ConnectSocket(addrConnect, hSocket))
{
printf("IRC connect failed\n");
nErrorWait = nErrorWait * 11 / 10;
if (Wait(nErrorWait += 60))
continue;
else
return;
}
if (!RecvUntil(hSocket, "Found your hostname", "using your IP address instead", "Couldn't look up your hostname", "ignoring hostname"))
{
closesocket(hSocket);
hSocket = INVALID_SOCKET;
nErrorWait = nErrorWait * 11 / 10;
if (Wait(nErrorWait += 60))
continue;
else
return;
}
CNetAddr addrIPv4("1.2.3.4"); // arbitrary IPv4 address to make GetLocal prefer IPv4 addresses
CService addrLocal;
string strMyName;
// Don't use our IP as our nick if we're not listening
// or if it keeps failing because the nick is already in use.
if (!fNoListen && GetLocal(addrLocal, &addrIPv4) && nNameRetry<3)
strMyName = EncodeAddress(GetLocalAddress(&addrConnect));
if (strMyName == "")
strMyName = strprintf("x%"PRIu64"", GetRand(1000000000));
Send(hSocket, strprintf("NICK %s\r", strMyName.c_str()).c_str());
Send(hSocket, strprintf("USER %s 8 * : %s\r", strMyName.c_str(), strMyName.c_str()).c_str());
int nRet = RecvUntil(hSocket, " 004 ", " 433 ");
if (nRet != 1)
{
closesocket(hSocket);
hSocket = INVALID_SOCKET;
if (nRet == 2)
{
printf("IRC name already in use\n");
nNameRetry++;
Wait(10);
continue;
}
nErrorWait = nErrorWait * 11 / 10;
if (Wait(nErrorWait += 60))
continue;
else
return;
}
nNameRetry = 0;
MilliSleep(500);
// Get our external IP from the IRC server and re-nick before joining the channel
CNetAddr addrFromIRC;
if (GetIPFromIRC(hSocket, strMyName, addrFromIRC))
{
printf("GetIPFromIRC() returned %s\n", addrFromIRC.ToString().c_str());
// Don't use our IP as our nick if we're not listening
if (!fNoListen && addrFromIRC.IsRoutable())
{
// IRC lets you to re-nick
AddLocal(addrFromIRC, LOCAL_IRC);
strMyName = EncodeAddress(GetLocalAddress(&addrConnect));
Send(hSocket, strprintf("NICK %s\r", strMyName.c_str()).c_str());
}
}
if (fTestNet) {
Send(hSocket, "JOIN #nanotecTEST\r");
Send(hSocket, "WHO #nanotecTEST\r");
} else {
// randomly join #nanotec00-#nanotec05
int channel_number = GetRandInt(5);
// Channel number is always 0 for initial release
//int channel_number = 0;
Send(hSocket, strprintf("JOIN #nanotec%02d\r", channel_number).c_str());
Send(hSocket, strprintf("WHO #nanotec%02d\r", channel_number).c_str());
}
int64_t nStart = GetTime();
string strLine;
strLine.reserve(10000);
while (!fShutdown && RecvLineIRC(hSocket, strLine))
{
if (strLine.empty() || strLine.size() > 900 || strLine[0] != ':')
continue;
vector<string> vWords;
ParseString(strLine, ' ', vWords);
if (vWords.size() < 2)
continue;
char pszName[10000];
pszName[0] = '\0';
if (vWords[1] == "352" && vWords.size() >= 8)
{
// index 7 is limited to 16 characters
// could get full length name at index 10, but would be different from join messages
strlcpy(pszName, vWords[7].c_str(), sizeof(pszName));
printf("IRC got who\n");
}
if (vWords[1] == "JOIN" && vWords[0].size() > 1)
{
// :username!username@50000007.F000000B.90000002.IP JOIN :#channelname
strlcpy(pszName, vWords[0].c_str() + 1, sizeof(pszName));
if (strchr(pszName, '!'))
*strchr(pszName, '!') = '\0';
printf("IRC got join\n");
}
if (pszName[0] == 'u')
{
CAddress addr;
if (DecodeAddress(pszName, addr))
{
addr.nTime = GetAdjustedTime();
if (addrman.Add(addr, addrConnect, 51 * 60))
printf("IRC got new address: %s\n", addr.ToString().c_str());
nGotIRCAddresses++;
}
else
{
printf("IRC decode failed\n");
}
}
}
closesocket(hSocket);
hSocket = INVALID_SOCKET;
if (GetTime() - nStart > 20 * 60)
{
nErrorWait /= 3;
nRetryWait /= 3;
}
nRetryWait = nRetryWait * 11 / 10;
if (!Wait(nRetryWait += 60))
return;
}
}
#ifdef TEST
int main(int argc, char *argv[])
{
WSADATA wsadata;
if (WSAStartup(MAKEWORD(2,2), &wsadata) != NO_ERROR)
{
printf("Error at WSAStartup()\n");
return false;
}
ThreadIRCSeed(NULL);
WSACleanup();
return 0;
}
#endif
| [
"nanotechnologycoin@gmail.com"
] | nanotechnologycoin@gmail.com |
0abf66bc691143b523ef707174fc8d2c2cefe65b | 9b111f5b75ad1d95451602783f8e12d72775b8c0 | /cpp/hello.cpp | b0ec594736b21a682107eed9fff966ed213183f0 | [] | no_license | mehdou92/webAssembly-demo | 5608c818cce9915b55802a73952063645a59445c | c6ba7cd3328281ccef4c3c4db06bc321c08df501 | refs/heads/master | 2020-05-15T13:15:09.997696 | 2019-04-19T16:37:34 | 2019-04-19T16:37:34 | 182,292,262 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 114 | cpp | #include<iostream>
#include "fib.h"
int main() {
std::cout << "fib(6) = " << fib(6) << std::endl;
return 0;
} | [
"mehdiab92@gmail.com"
] | mehdiab92@gmail.com |
b3d1d95647c571d98e1e4a143d79d3ad9f96253d | fa3050f5e5ee850ba39ccb602804c001d9b4dede | /third_party/blink/public/common/storage_key/storage_key.h | 22d2affd07001ae230bfaef456a04f721ba48e20 | [
"Apache-2.0",
"LGPL-2.0-or-later",
"MIT",
"GPL-1.0-or-later",
"LicenseRef-scancode-warranty-disclaimer",
"LGPL-2.1-only",
"GPL-2.0-only",
"LGPL-2.0-only",
"BSD-2-Clause",
"LicenseRef-scancode-other-copyleft",
"BSD-3-Clause"
] | permissive | wayou/chromium | a64c9df7d9c6190f8f9f730e7f68a998ffcabfc9 | f5f51fc460df28cef915df71b4161aaa6b668004 | refs/heads/main | 2023-06-27T18:09:41.425496 | 2021-09-08T23:02:28 | 2021-09-08T23:02:28 | 404,525,907 | 1 | 0 | BSD-3-Clause | 2021-09-08T23:38:08 | 2021-09-08T23:38:08 | null | UTF-8 | C++ | false | false | 6,163 | h | // Copyright 2021 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef THIRD_PARTY_BLINK_PUBLIC_COMMON_STORAGE_KEY_STORAGE_KEY_H_
#define THIRD_PARTY_BLINK_PUBLIC_COMMON_STORAGE_KEY_STORAGE_KEY_H_
#include <iosfwd>
#include <string>
#include "base/strings/string_piece.h"
#include "base/unguessable_token.h"
#include "net/base/schemeful_site.h"
#include "third_party/abseil-cpp/absl/types/optional.h"
#include "third_party/blink/public/common/common_export.h"
#include "url/origin.h"
namespace blink {
// A class representing the key that Storage APIs use to key their storage on.
//
// StorageKey contains an origin, a top-level site, and an optional nonce. Using
// the nonce is still unsupported since serialization and deserialization don't
// take it into account. For more details on the overall design, see
// https://docs.google.com/document/d/1xd6MXcUhfnZqIe5dt2CTyCn6gEZ7nOezAEWS0W9hwbQ/edit.
class BLINK_COMMON_EXPORT StorageKey {
public:
// This will create a StorageKey with an opaque `origin_` and
// `top_level_site_`. These two opaque members will not be the same (i.e.,
// their origin's nonce will be different).
StorageKey() = default;
// The following three constructors all create a StorageKey without a nonce;
// the first of which creates a StorageKey with an implicit top-level site
// matching the origin. These are currently kept as constructors, rather than
// as static creation method(s), because of the large number of usages of
// StorageKey without a top-level site specified. Eventually these will all
// merge into a static function(s) that will require the caller to explicitly
// specify that they do not want a top-level site.
explicit StorageKey(const url::Origin& origin)
: StorageKey(origin, net::SchemefulSite(origin), nullptr) {}
StorageKey(const url::Origin& origin, const url::Origin& top_level_site)
: StorageKey(origin, net::SchemefulSite(top_level_site), nullptr) {}
StorageKey(const url::Origin& origin,
const net::SchemefulSite& top_level_site)
: StorageKey(origin, top_level_site, nullptr) {}
// This function does not take a top-level site as the nonce makes it globally
// unique anyway. Implementation wise however, the top-level site is set to
// the `origin`'s site.
static StorageKey CreateWithNonce(const url::Origin& origin,
const base::UnguessableToken& nonce);
// Copyable and Moveable.
StorageKey(const StorageKey& other) = default;
StorageKey& operator=(const StorageKey& other) = default;
StorageKey(StorageKey&& other) noexcept = default;
StorageKey& operator=(StorageKey&& other) noexcept = default;
~StorageKey() = default;
// Returns a newly constructed StorageKey from, a previously serialized, `in`.
// If `in` is invalid then the return value will be nullopt. If this returns a
// non-nullopt value, it will be a valid, non-opaque StorageKey. A
// deserialized StorageKey will be equivalent to the StorageKey that was
// initially serialized.
//
// Can be called on the output of either Serialize() or
// SerializeForLocalStorage(), as it can handle both formats.
static absl::optional<StorageKey> Deserialize(base::StringPiece in);
// Transforms a string into a StorageKey if possible (and an opaque StorageKey
// if not). Currently calls Deserialize, but this may change in future.
// For use in tests only.
static StorageKey CreateFromStringForTesting(const std::string& origin);
// Returns true if ThirdPartyStoragePartitioning feature flag is enabled.
static bool IsThirdPartyStoragePartitioningEnabled();
// Serializes the `StorageKey` into a string.
// This function will return the spec url of the underlying Origin. Do not
// call if `this` is opaque.
std::string Serialize() const;
// Serializes into a string in the format used for localStorage (without
// trailing slashes). Prefer Serialize() for uses other than localStorage. Do
// not call if `this` is opaque.
std::string SerializeForLocalStorage() const;
const url::Origin& origin() const { return origin_; }
const net::SchemefulSite& top_level_site() const { return top_level_site_; }
const absl::optional<base::UnguessableToken>& nonce() const { return nonce_; }
std::string GetDebugString() const;
// Provides a concise string representation suitable for memory dumps.
// Limits the length to `max_length` chars and strips special characters.
std::string GetMemoryDumpString(size_t max_length) const;
private:
StorageKey(const url::Origin& origin,
const net::SchemefulSite& top_level_site,
const base::UnguessableToken* nonce)
: origin_(origin),
top_level_site_(top_level_site),
nonce_(nonce ? absl::make_optional(*nonce) : absl::nullopt) {}
BLINK_COMMON_EXPORT
friend bool operator==(const StorageKey& lhs, const StorageKey& rhs);
BLINK_COMMON_EXPORT
friend bool operator!=(const StorageKey& lhs, const StorageKey& rhs);
// Allows StorageKey to be used as a key in STL (for example, a std::set or
// std::map).
BLINK_COMMON_EXPORT
friend bool operator<(const StorageKey& lhs, const StorageKey& rhs);
url::Origin origin_;
// The "top-level site"/"top-level frame"/"main frame" of the context
// this StorageKey was created for (for storage partitioning purposes).
//
// Like everything, this too has exceptions:
// * If the nonce is populated then this value doesn't matter.
// * For extensions or related enterprise policies this may not represent the
// top-level site.
net::SchemefulSite top_level_site_;
// An optional nonce, forcing a partitioned storage from anything else. Used
// by anonymous iframes:
// https://github.com/camillelamy/explainers/blob/master/anonymous_iframes.md
absl::optional<base::UnguessableToken> nonce_;
};
BLINK_COMMON_EXPORT
std::ostream& operator<<(std::ostream& ostream, const StorageKey& sk);
} // namespace blink
#endif // THIRD_PARTY_BLINK_PUBLIC_COMMON_STORAGE_KEY_STORAGE_KEY_H_
| [
"chromium-scoped@luci-project-accounts.iam.gserviceaccount.com"
] | chromium-scoped@luci-project-accounts.iam.gserviceaccount.com |
c6614f7ecf17354379cd999342e25aeef302a4fb | 836753ece75f1ee3334049ac83cd464019678dfe | /Dolthy.h | 2698ea6efc0c6b73a17d964cddf0f8d04cb035f0 | [] | no_license | gio-gee/BattleShipHW | c0f4cf228443c7f0385313643c537dfd4c6eec58 | 11648c7cddc32f942c6b2c087cd1165d621c01a8 | refs/heads/master | 2022-04-20T00:41:12.052864 | 2020-04-17T17:24:25 | 2020-04-17T17:24:25 | 256,561,630 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 271 | h | #ifndef DOLTHY_H
#define DOLTHY_H
#include <iostream>
#include "BattleShip.h"
using namespace std;
class Dolthy : public BattleShip
{
public:
Dolthy(int);
~Dolthy();
//void WhoFires(int);
protected:
private:
};
#endif // DOLTHY_H
| [
"gdgee.1011@gmail.com"
] | gdgee.1011@gmail.com |
1352fdb45b89c22a8fb2e8add42aa225adc43981 | bc0bb5d12f6f178f5a07bdcb027853e9bd344821 | /GLFW/empty-project/src/skybox/Skybox.cpp | c7cf26511863cbe648c6e1323cf1aec133a146d3 | [] | no_license | zymix/openGL-test | 377276b3f96a0069ba0a4f2e4a3eff806be7ad46 | 98850bba351123be02bc716aad02ca697177bf9e | refs/heads/master | 2020-03-18T06:43:07.648993 | 2019-07-24T01:49:14 | 2019-07-24T01:49:14 | 134,411,538 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,802 | cpp | #include "Skybox.h"
#include "../shader/Shader.h"
float Skybox::_skyboxVertices[] = {
// positions
-1.0f, 1.0f, -1.0f,
-1.0f, -1.0f, -1.0f,
1.0f, -1.0f, -1.0f,
1.0f, -1.0f, -1.0f,
1.0f, 1.0f, -1.0f,
-1.0f, 1.0f, -1.0f,
-1.0f, -1.0f, 1.0f,
-1.0f, -1.0f, -1.0f,
-1.0f, 1.0f, -1.0f,
-1.0f, 1.0f, -1.0f,
-1.0f, 1.0f, 1.0f,
-1.0f, -1.0f, 1.0f,
1.0f, -1.0f, -1.0f,
1.0f, -1.0f, 1.0f,
1.0f, 1.0f, 1.0f,
1.0f, 1.0f, 1.0f,
1.0f, 1.0f, -1.0f,
1.0f, -1.0f, -1.0f,
-1.0f, -1.0f, 1.0f,
-1.0f, 1.0f, 1.0f,
1.0f, 1.0f, 1.0f,
1.0f, 1.0f, 1.0f,
1.0f, -1.0f, 1.0f,
-1.0f, -1.0f, 1.0f,
-1.0f, 1.0f, -1.0f,
1.0f, 1.0f, -1.0f,
1.0f, 1.0f, 1.0f,
1.0f, 1.0f, 1.0f,
-1.0f, 1.0f, 1.0f,
-1.0f, 1.0f, -1.0f,
-1.0f, -1.0f, -1.0f,
-1.0f, -1.0f, 1.0f,
1.0f, -1.0f, -1.0f,
1.0f, -1.0f, -1.0f,
-1.0f, -1.0f, 1.0f,
1.0f, -1.0f, 1.0f
};
Skybox::Skybox()
{
glGenVertexArrays(1, &_skyboxVAO);
glGenBuffers(1, &_skyboxVBO);
glBindVertexArray(_skyboxVAO);
glBindBuffer(GL_ARRAY_BUFFER, _skyboxVBO);
glBufferData(GL_ARRAY_BUFFER, sizeof(_skyboxVertices), _skyboxVertices, GL_STATIC_DRAW);
glEnableVertexAttribArray(0);
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 3*sizeof(float), (void *)0);
glBindVertexArray(0);
}
Skybox::~Skybox()
{
glDeleteVertexArrays(1, &_skyboxVAO);
glDeleteBuffers(1, &_skyboxVBO);
}
void Skybox::setTextureFaces(std::vector<std::string>& faces)
{
_cubemapTexture.loadCubeMap(faces);
}
void Skybox::draw(Shader& shader)
{
unsigned int id = _cubemapTexture._textureID;
if (id >= 0)
{
glDepthFunc(GL_LEQUAL);
glBindVertexArray(_skyboxVAO);
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_CUBE_MAP, id);
glDrawArrays(GL_TRIANGLES, 0, 36);
glBindVertexArray(0);
glDepthFunc(GL_LESS);
}
} | [
"xiankang.he@foxmail.com"
] | xiankang.he@foxmail.com |
2761853450cfce040fcfe081b774a7ca3d87781b | b79f92411e9fbd3196908a7f74fb53fc2055cd63 | /src/new_delete_operators/global_operators.cpp | cc7f9a9c410f15aab1270d455811f43065c167da | [
"Beerware"
] | permissive | victorcruceru/my_tour_of_cplusplus | e793f7467a9a13c874fae0ed3e79a13db0b4e0ea | e589ce99c4a3044b393abf019e45e29d42c8dbc1 | refs/heads/master | 2022-02-11T03:44:23.340430 | 2022-01-23T16:30:55 | 2022-01-23T16:30:55 | 164,347,369 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 1,711 | cpp | /*
* ----------------------------------------------------------------------------
* "THE BEER-WARE LICENSE" (Revision 42):
* Victor Cruceru wrote this file. As long as you retain this notice you
* can do whatever you want with this stuff. If we meet some day, and you think
* this stuff is worth it, you can buy me a beer in return.
* ----------------------------------------------------------------------------
*/
#include <cstdlib>
#include <string>
#include <iostream>
// replacing (overloading) global new operator
void* operator new(std::size_t sz){
std::printf("operator new size %zu\n", sz);
return std::malloc(sz);
}
// replacing (overloading) global new[] operator
void* operator new[](std::size_t sz){
std::printf("operator new[] size %zu\n", sz);
return std::malloc(sz);
}
// replacing (overloading) global delete operator
void operator delete (void* ptr) noexcept {
std::printf( "operator delete for addr %p\n", ptr);
return std::free(ptr);
}
void operator delete (void* ptr, std::size_t sz) noexcept {
std::printf( "operator delete2 for addr %p\n", ptr);
return std::free(ptr);
}
// replacing (overloading) global delete operator
void operator delete[](void* ptr) noexcept{
std::printf( "operator delete[] for addr. %p\n", ptr);
return std::free(ptr);
}
void operator delete[] (void* ptr, std::size_t sz) noexcept {
std::printf( "operator delete2[] for addr %p\n", ptr);
return std::free(ptr);
}
int main(){
char* x1 = new char;
double* x2 = new double;
std::uint64_t* x3 = new std::uint64_t[10];
delete x1;
delete x2;
delete [] x3;
return (EXIT_SUCCESS);
} | [
"victor.cruceru@gmail.com"
] | victor.cruceru@gmail.com |
760bc84b743ad48337618d91a945b9fe3e2bbd65 | afb18a6661c7392a1fa8ea2fa1b71cadaa826419 | /src/wrapping/wrap-quoted.cpp | 4b4355e3afd082ae0fa20fe64cb32f2309f2f826 | [
"MIT"
] | permissive | HaikuArchives/NewsBe | 2e0a9394cba27f221cbc6c1af12c5d6a4d6c0306 | a8ea8cc3b377c29db13fbc98cf1b66d6c2087f61 | refs/heads/master | 2022-02-04T22:57:13.167723 | 2022-01-13T19:46:47 | 2022-01-14T07:52:07 | 24,564,567 | 1 | 3 | MIT | 2022-01-14T07:52:08 | 2014-09-28T16:47:02 | C++ | UTF-8 | C++ | false | false | 14,726 | cpp | /*
* $Id$
*/
/*
Missing:
* logic for multi-byte line termination on some platforms
* handling text buffer size limits on some platforms
*/
/* Some commmon portability macro's */
#include "wrapping/wrappers.h"
#include "SupportDefs.h"
/* char *RewrapText (char **text, long start_index, long end_index)
*
* Call RewrapText to copy a block of text into the buffer quoted
* (quoted is allocated by NewQuotedText but will need to be freed by
* the caller). While copying the text into quoted, RewrapText does
* wrapping w/paragraph filling (i.e. keeping the quote prefix and
* putting the text on to as few lines as possible).
*
* INPUT: Consists of a handle to the text to be copied, a starting and
* ending index (in case you don't want to act on the full
* text). The starting position should be either at the
* beginning of the text or following a new line, the ending
* should follow a new line or the end of the text.
*
* None of the input variables are changed by RewrapText.
*
* EFFECTS:
* RewrapText allocates and returns a null-terminated buffer
* with the properly wrapped text in it (or NULL if unable to
* allocate it). The global variables: quoteprefix, oldprefix,
* number_of_chars_on_line, here, h, hEnd, firsttime, quoteindex
* are modified.
*
* POSSIBLE IMPROVEMENTS:
* The recursion could be eliminated, this would reduce the need
* for several of the globals and make it more practical to pass
* the others in as parameters. Also the check for what is and
* is not part of the prefix could be made smarter in several
* ways (wrapping it in a function and making comparisons to the
* surrounding lines, allowing specific sequences [[say ++, and
* : only if not followed by [,],( or )]], a check could be made
* to see if a char is in the input string quoteString, or the
* list of allowed chars could be expanded.
*/
/* static void copy_and_wrap_with_paragraph_fill (void)
*
* copy_and_wrap_with_paragraph_fill copies the current line from
* here into quoted, if there hasn't been a change in the prefix/quote
* level and the line is under STD_LINE_LENGTH long, the text will be
* kept on the same line.
EXAMPLE:
>
> > This line will be a little over 72 chars (not too much over, but enough).
> > And this line is only 35 chars.
> Short line, not wrapped.
That would get you:
>
> > This line will be a little over 72 chars (not too much over, but
> > enough). And this line is only 35 chars.
> Short line, not wrapped.
*
*/
#define MAX_LINE_LENGTH 80
#define STD_LINE_LENGTH 72
#define MAX_PREFIX_LENGTH 32
#define CR '\r'
#define LF '\n'
#define LP ')'
#define DS '-'
#define Qt (char) 30
/* J$: I can't recall what Mac OS compilers actually define; a workaround */
// typedef enum _bool {false = 0, true} bool;
#define MemAlloc(n) malloc(n)
#define MemReAlloc(b,n) realloc(b,n)
#define MemFree(b) free(b)
#include <stdio.h>
#include <stdlib.h>
#define NL LF
/* Declaration of global vars */
char quoteprefix[MAX_PREFIX_LENGTH+1] = "",
oldprefix[MAX_PREFIX_LENGTH+1] = "";
long quoteindex = 0;
int number_of_chars_on_line = 0;
bool firsttime = TRUE;
char *quoted = NULL, *here;
long h, hEnd;
void copy_and_wrap_with_paragraph_fill (void)
{
long i, h_bol;
int quotelen;
bool quitloop = false;
quotelen = strlen(quoteprefix);
i = 0;
/* Is this line's quotation identical to the previous line's? */
if (strcmp(quoteprefix,oldprefix))
number_of_chars_on_line = 0; /* if not start a new line below */
/* if this isn't the very first time we were here and we are starting */
/* a new line then put a NL at the end of the previous line */
if (!firsttime && !number_of_chars_on_line) {
quoted[quoteindex++] = NL;
#if defined(USECRLF)
quoted[quoteindex++] = LF;
#endif
}
firsttime = false;
if (here[h] != NL && (h < hEnd)) {
/* copy the quoteprefix over if starting a new line */
if (!number_of_chars_on_line)
for (; i < quotelen; quoted[quoteindex++] = quoteprefix[i++]) ;
strcpy(oldprefix, quoteprefix);
number_of_chars_on_line += i;
h_bol=h;
/* OK - this is the heart of it, copy text from here to quoted */
/* until we come to the end of the line -- if the quoteprefix is */
/* different then we started a new line, if it was the same then */
/* we are on the same line as the last time through */
while ((here[h] != NL) && (h < hEnd) && (quitloop != true)) {
quoted[quoteindex++] = here[h++];
number_of_chars_on_line++;
if ((number_of_chars_on_line >= STD_LINE_LENGTH) && (here[h] != NL)) {
/* this is the rest of it -- the line is too long so we need to */
/* back up and then start a newline (by recursively calling this */
/* procedure with the number_of_chars_on_line set to zero (which */
/* is a flag above to add the NL and then the prefix) */
while (
(number_of_chars_on_line > quotelen) && (h > h_bol) &&
(here[h] != ' ') &&
(here[h] != Qt) &&
(here[h] != DS) &&
(here[h] != LP) &&
(here[h] != NL)) {
quoteindex--;
number_of_chars_on_line--;
h--;
} /*this backs it up to first place to break */
number_of_chars_on_line--;
/* maybe there wasn't a place to break? Then break anyway*/
if (number_of_chars_on_line <= quotelen) {
while (number_of_chars_on_line < STD_LINE_LENGTH) {
quoted[quoteindex++] = here[h++];
number_of_chars_on_line++;
}
}
/* cause it to add a NL next time through the loop */
number_of_chars_on_line = 0;
if (here[h] == ' ')
h++; /* don't start next line off with a space */
if (here[h] == NL) { /* finished with this line */
#if defined(USECRLF)
quoted[quoteindex++] = LF;
#endif
} else /* put the rest of this line on another line */
/* (except if it's too long in which case do it again) */
copy_and_wrap_with_paragraph_fill();
quitloop = true;
}
}
} else { /* here[h] == NL || h >= hEnd */
if (number_of_chars_on_line != 0) {
quoted[quoteindex++] = NL;
#if defined(USECRLF)
quoted[quoteindex++] = LF;
#endif
}
for (i=0; i<quotelen; quoted[quoteindex++]=quoteprefix[i++])
;
#if defined(USECRLF)
if(here[h+1] == LF) h++;
#endif
if (++h >= hEnd) {
quoted[quoteindex++] = NL;
#if defined(USECRLF)
quoted[quoteindex++] = LF;
#endif
}
/* cause it to add a NL next time through the loop */
number_of_chars_on_line = 0;
quitloop = true;
}
/* if we didn't stop the loop because it was too long then add a space */
if (!quitloop) {
quoted[quoteindex] = '\0';
quoted[quoteindex] = ' ';
if (quoted[quoteindex-1] != ' ') {
quoteindex++;
number_of_chars_on_line++;
}
h++;
#if defined(USECRLF)
if(here[h] == LF) h++;
#endif
}
}
char *RewrapText (char **text, long start_index, long end_index)
{
long newlen ;
int i;
/* Make sure all global vars are safe to use */
quoteprefix[0] = '\0'; number_of_chars_on_line = 0;
oldprefix[0] = '\0'; firsttime = true;
h = 0; hEnd = 0;
here = NULL; quoted = NULL;
quoteindex = 0;
hEnd = end_index - start_index;
newlen = 3*hEnd/2; /* A rather crude (over)estimate */
quoted = (char *) MemAlloc(newlen); /* To be freed by caller */
if (quoted == NULL) {
return NULL; /* ERROR! No memory! */
}
here = *text + start_index; /* Use the dereferencing`*' only if text is char ** */
h = 0;
while (h < hEnd) {
i = 0;
/* Skip quote prefix, storing it in quoteprefix */
while( (h <= hEnd) && (i < MAX_PREFIX_LENGTH)
&& ( here[h] == ' '
|| here[h] == '>'
|| here[h] == ':'
|| here[h] == '|' /* J$: whatever... */
|| here[h] == ']'
)
) {
quoteprefix[i++] = here[h++];
}
quoteprefix[i] = 0;
copy_and_wrap_with_paragraph_fill();
}
quoted[quoteindex-1] = NL; /* Either a space or NL, make sure it is a NL */
#if defined(USECRLF)
quoted[quoteindex++] = LF; /* Add LF if we must */
#endif
quoted[quoteindex] = '\0'; /* Null-termination */
return quoted;
}
/* Sample invocations of RewrapText function */
#if 0
if((wrapped = RewrapText(&charbuf, 0, strlen(charbuf))) != NULL) {
// whatever needs be done with "wrapped" buf
} else {
// error!
}
new_text_buf = RewrapText(old_text_handle, start_index, end_index});
if (new_text_buf != NULL) {
// whatever
} else {
// report a nerror -- didn't have enough memory to allocate buffer
}
#endif
/* char *NewQuotedText (char **text, long start, long end, char *quoteString)
*
* Call NewQuotedText to copy a block of text into the buffer
* quoted (quoted is allocated by NewQuotedText but will need to be
* freed by the caller). NewQuotedText is passed a prefix to be added
* to each line (typically this will be "> ") in quoteString, but
* it will maintain any existing prefix (if it uses the recognized
* quote chars) as long as the total prefix length is less than
* MAX_PREFIX_LENGTH.
*
* INPUT: Consists of a handle to the text to be copied, a starting and
* ending index (in case you don't want to quote the full text).
* The starting position should be either at the beginning of
* the text or following a new line, the ending should follow
* a new line or the end of the text. quoteString MUST NOT be
* NULL.
*
* None of the input variables are changed by NewQuoteText.
*
* OUTPUT:
* NewQuotedText allocates and returns a null-terminated
* buffer with the properly prefixed text in it (or NULL if
* unable to allocate it). The global variables: quoteprefix,
* number_of_chars_on_line, here, h, hEnd and quoteindex, are
* modified. Individual long lines are wrapped as needed, but
* otherwise the output is simply the lines in text preceded by
* the prefix in quoteString.
*
* POSSIBLE IMPROVEMENTS:
* The recursion can be eliminated with a GOTO, this would reduce
* the need for several of the globals and make it more practical
* to pass the others in as parameters. Also the check for what
* is and is not part of the prefix could be made smarter in
* several ways (wrapping it in a function and making comparisons
* to the surrounding lines, allowing specific sequences [[say
* ++, and : only if not followed by [,],( or )]], a check could
* be made to see if a char is in the input string quoteString,
* or the list of allowed chars could be expanded.
*
* EXAMPLE:
>
> > This line will be over 80 chars (not too much over, but enough to get wrapped).
> > And this line is only 35 chars.
> Short line, not wrapped.
Gets turned into:
>
> > This line will be over 80 chars (not too much over, but enough to
> > get wrapped).
> > And this line is only 35 chars.
> Short line, not wrapped.
*/
/* static void quote_wrap_rest_of_line (void)
*
* quote_wrap_rest_of_line copies the current line from here into quoted.
*
* Quoting and wrapping are done as necessary to keep the length under
* MAX_LINE_LENGTH. When wrapping the current quote prefix/cascade is
* maintained. Lines which are over MAX_LINE_LENGTH are wrapped at or
* before STD_LINE_LENGTH.
*/
static void quote_wrap_rest_of_line (void)
{
long i, linelen ;
int quotelen ;
bool quitloop ;
/* Start the new line by copying over the prefix */
quotelen = strlen(quoteprefix);
i = 0;
while (i < quotelen)
quoted[quoteindex++] = quoteprefix[i++];
linelen = i-1;
quitloop = false;
if (here[h] != NL)
while ((here[h] != NL) && (h < hEnd) && (quitloop != true)) {
quoted[quoteindex++] = here[h++];
linelen++;
//fprintf(stdout, "Idx: %ld, Char: %d (%c)\n", quoteindex, here[h], here[h]);
/* Wrap unacceptably long lines, by calling ourselves recursively */
if (linelen >= MAX_LINE_LENGTH) {
h = h - (MAX_LINE_LENGTH - STD_LINE_LENGTH);
quoteindex = quoteindex - (MAX_LINE_LENGTH - STD_LINE_LENGTH);
linelen = linelen - (MAX_LINE_LENGTH - STD_LINE_LENGTH);
/* Find a break point (adjust as needed for non-english systems)*/
while ( (linelen > quotelen)
&& (here[h] != ' ')
&& (here[h] != '\'')
&& (here[h] != DS)
&& (here[h] != ')')) {
quoteindex--;
linelen--;
h--;
}
linelen--;
/* If there wasn't a break point then break it anyway */
if (linelen <= quotelen) {
while (linelen < STD_LINE_LENGTH) {
quoted[quoteindex++] = here[h++];
linelen++;
}
linelen++;
}
quoted[quoteindex++] = NL;
#if defined(USECRLF)
quoted[quoteindex++] = LF;
#endif
/* If we broke on a space, skip it */
if (here[h] == ' ')
h++;
/* make another line -- this is where the recursion takes place*/
quote_wrap_rest_of_line();
quitloop = true;
}
} /* while loop */
/* add a new line if at the end of this long line */
if (quitloop != true) {
quoted[quoteindex++] = NL;
h++;
#if defined(USECRLF)
quoted[quoteindex++] = LF;
if(here[h] == LF)
h++;
#endif
}
}
char *NewQuotedText (char **text, long start, long end, char *quoteString)
{
long newlen;
int i;
char default_quote_string[] = {"> "};
/* Make sure all global vars are safe to use */
quoteprefix[0] = '\0'; number_of_chars_on_line = 0;
if (quoteString==NULL)
quoteString = &default_quote_string[0];
hEnd = end-start;
newlen = 3*hEnd/2; /* A rather crude (over)estimate */
quoted = (char *) MemAlloc(newlen); /* To be freed by the caller */
if (quoted == NULL) {
return NULL; /* ERROR! No memory! */
}
quoteindex = 0;
/* Use the dereferencing`*' only if text is char ** */
here = *text + start; /* start/end allow only quoting part of the text */
h = 0;
while (h < hEnd) {
i = 0;
/* Copy the user's quotestring/char to beginning of this lines prefix */
newlen=strlen(quoteString);
while (i < newlen)
quoteprefix[i++] = quoteString[i];
/* Skip quote prefix, storing it in quoteprefix */
while( (h <= hEnd) && (i < MAX_PREFIX_LENGTH)
&& ( here[h] == ' '
|| here[h] == '>'
|| here[h] == ':'
|| here[h] == '|' /* J$: whatever... */
|| here[h] == ']' /* JM: could be extracted into a function and made smarter */
) /* JM: but I'm leaving that as a exercise for the reader */
) {
quoteprefix[i++] = here[h++];
}
quoteprefix[i] = 0;
quote_wrap_rest_of_line(); /* quote and wrap the rest of the current line */
}
quoted[quoteindex] = '\0'; /* Null-termination */
return quoted;
}
| [
""
] | |
6ba72f09640e7ca1c665a654f4507160f98cc2be | e4292f314826330f70cb21deb993f07003a60c95 | /Public/Network/GameNetworkPrivate.h | 3d6d92a4f27f63e9aa6d8036bf5842223b6c375e | [] | no_license | djq1996/game-network-server-ue4 | 981c4ac2b6bc44541d3d95892e86c9853b033b4b | fc639058d70fcd62de107fba4adc9db433d676b2 | refs/heads/master | 2021-09-23T15:29:03.774634 | 2018-09-25T05:22:40 | 2018-09-25T05:22:40 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 934 | h | //$ Copyright 2015-18 Code Respawn Pvt Ltd, All rights reserved $//
#pragma once
#include "CoreMinimal.h"
/** Defines the desired size of socket send buffers (in bytes). */
#define GAMENETWORK_SEND_BUFFER_SIZE 2 * 1024 * 1024
/** Defines the desired size of socket receive buffers (in bytes). */
#define GAMENETWORK_RECEIVE_BUFFER_SIZE 2 * 1024 * 1024
/** Defines a magic number for the the game network message transport. */
#define GAMENETWORK_TRANSPORT_PROTOCOL_MAGIC 0x82F2C74F
/** Defines the protocol version of the game network message transport. */
namespace EGameNetworkVersion
{
enum Type
{
Initial,
// -----<new versions can be added before this line>-------------------------------------------------
// - this needs to be the last line (see note below)
VersionPlusOne,
LatestVersion = VersionPlusOne - 1,
// bump this when break need to break compatibility.
OldestSupportedVersion = Initial
};
}
| [
"ali.akbar@coderespawn.com"
] | ali.akbar@coderespawn.com |
ccfed4810b9bec79f40f9eeeff85eac9cd6da475 | 16cd50735968723faa5f55429343b0c7e204f52a | /leetcode/solve.cpp | 632de72e2baaba11555570df6e38b5eac7c8b438 | [] | no_license | xinzhu-cai/LeetPro | b8c09acb17a1a51affeb3bc59601df7a1a388884 | 9b119cc8c50699ef914e0f61dc4c7fb5e2ba1409 | refs/heads/master | 2021-09-10T22:19:05.027384 | 2018-04-03T07:34:48 | 2018-04-03T07:34:48 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,203 | cpp | class Solution {
public:
void solve(vector<vector<char>> &board) {
if (board.empty() || board[0].empty()) return;
r = board.size(); c = board[0].size();
queue<pair<int, int> > q;
for (int j=0; j<c; ++j) {
enque(board, q, 0, j);
enque(board, q, r-1, j);
}
for (int i=0; i<r; ++i) {
enque(board, q, i, 0);
enque(board, q, i, c-1);
}
while (!q.empty()) {
int i = q.front().first;
int j = q.front().second;
q.pop();
for (int k=0; k<4; ++k) enque(board, q, i+dx[k], j+dy[k]);
}
for (int i=0; i<r; ++i) for (int j=0; j<c; ++j)
if (board[i][j] == 'O') board[i][j] = 'X';
for (int i=0; i<r; ++i) for (int j=0; j<c; ++j)
if (board[i][j] == 'D') board[i][j] = 'O';
}
private:
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};
int r, c;
void enque(vector<vector<char>> &board, queue<pair<int, int>> &q, int i, int j) {
if ((i<0)||(i>=r)||(j<0)||(j>=c)||(board[i][j]!='O')) return;
board[i][j] = 'D';
q.push(make_pair(i, j));
}
};
| [
"noreply@github.com"
] | noreply@github.com |
2b33d51b3715cb296b09a37f3b0da69c3d6f0b2a | 02d85c02cc4acd789970139ddef21bc2d6d78fca | /src/readcountmatrix.cpp | ecf55b242e70d4471a438422f0f77fd5d68da266 | [
"LicenseRef-scancode-warranty-disclaimer"
] | no_license | korjcjeong/AncesTree | a3bfd268dc46e744a497489030dce60ddbbcc9c9 | 3dfb14d5d8df0c240339504d3e9793ae932b673b | refs/heads/master | 2021-01-22T20:13:11.698548 | 2015-04-01T17:02:07 | 2015-04-01T17:02:07 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 6,088 | cpp | /*
* readcountmatrix.cpp
*
* Created on: 10-jan-2015
* Author: M. El-Kebir
*/
#include "readcountmatrix.h"
#include <sstream>
#include <boost/algorithm/string.hpp>
#include <boost/math/distributions/beta.hpp>
namespace vaff {
ReadCountMatrix::ReadCountMatrix()
: Matrix()
, _C()
, _D()
{
}
ReadCountMatrix::ReadCountMatrix(int m, int n)
: Matrix(m, n)
, _C(m, StlIntVector(n, 0))
, _D(m, StlIntVector(n, 0))
{
}
void ReadCountMatrix::remapLabels(const StlIntMatrix& toOrgColumns,
const ReadCountMatrix& orgR,
int max_cluster_size)
{
typedef std::vector<std::string> StringVector;
typedef StringVector::const_iterator StringVectorIt;
for (int j = 0; j < _m; ++j)
{
const StlIntVector& orgColumns = toOrgColumns[j];
std::string new_label = "";
bool first = true;
int count = 0;
for (StlIntVectorIt it = orgColumns.begin(); it != orgColumns.end() && count < max_cluster_size; ++it, ++count)
{
int org_j = *it;
if (first)
{
first = false;
}
else
{
new_label += "\n";
}
StringVector s2 ;
boost::split(s2, orgR.getRowLabel(org_j), boost::is_any_of(","));
new_label += s2.front();
}
if (count == max_cluster_size && orgColumns.size() > max_cluster_size)
{
new_label += "\n...";
}
setRowLabel(j, new_label);
}
}
std::ostream& operator<<(std::ostream& out,
const ReadCountMatrix& matrix)
{
out << "gene_id";
for (int j = 0; j < matrix._n; ++j)
{
out << "\t" << matrix.getColLabel(j) << "\t" << matrix.getColLabel(j);
}
out << std::endl;
for (int i = 0; i < matrix._m; ++i)
{
out << matrix.getRowLabel(i);
for (int j = 0; j < matrix._n; ++j)
{
out << "\t" << matrix._D[i][j] << "\t" << matrix._C[i][j];
}
out << std::endl;
}
return out;
}
std::istream& operator>>(std::istream& in,
ReadCountMatrix& matrix)
{
typedef std::vector<std::string> StringVector;
std::string line;
std::getline(in, line);
StringVector s;
boost::split(s, line, boost::is_any_of("\t"));
if (s.empty())
{
throw std::runtime_error("Error: empty sample labels");
}
// pop first element
s = StringVector(++s.begin(), s.end());
if (s.size() % 2 != 0)
{
throw std::runtime_error("Error: odd number of samples");
}
matrix._n = s.size() / 2;
matrix._colLabel = StringVector(matrix._n);
for (int j = 0; j < matrix._n; ++j)
{
if (s[2*j] != s[2*j + 1])
{
throw std::runtime_error("Error: unequal sample label between ref and alt");
}
matrix._colLabel[j] = s[2*j];
}
matrix._rowLabel.clear();
matrix._C.clear();
matrix._D.clear();
while (std::getline(in, line).good() && line != "")
{
boost::split(s, line, boost::is_any_of("\t"));
if (s.size() != 1+ 2*matrix._n)
{
throw std::runtime_error("Error: invalid number of columns");
}
matrix._rowLabel.push_back(s[0]);
matrix._C.push_back(StlIntVector(matrix._n));
matrix._D.push_back(StlIntVector(matrix._n));
// pop first element
s = StringVector(++s.begin(), s.end());
for (int j = 0; j < matrix._n; ++j)
{
int ref = -1;
int alt = -1;
if (s[2*j] == "")
{
ref = 0;
}
else
{
ref = atoi(s[2*j].c_str());
if (ref < 0)
{
throw std::runtime_error("Error: ref count is negative");
}
}
if (s[2*j+1] == "")
{
alt = 0;
}
else
{
alt = atoi(s[2*j+1].c_str());
if (ref < 0)
{
throw std::runtime_error("Error: alt count is negative");
}
}
matrix._C.back()[j] = alt;
matrix._D.back()[j] = ref;
}
}
matrix._m = matrix._rowLabel.size();
return in;
}
ReadCountMatrix ReadCountMatrix::collapse(StlIntMatrix& toOrgColumns) const
{
int nrNewMutations = toOrgColumns.size();
ReadCountMatrix R(nrNewMutations, _n);
R._colLabel = _colLabel;
char buf[1024];
for (int i = 0; i < nrNewMutations; ++i)
{
snprintf(buf, 1024, "%d", i);
R._rowLabel[i] = buf;
const StlIntVector& M = toOrgColumns[i];
for (StlIntVectorIt it = M.begin(); it != M.end(); ++it)
{
for (int sample = 0; sample < _n; ++sample)
{
R._C[i][sample] += _C[*it][sample];
R._D[i][sample] += _D[*it][sample];
}
}
}
return R;
}
void ReadCountMatrix::computeConfidenceIntervals(RealIntervalMatrix& CI,
double gamma) const
{
typedef boost::math::beta_distribution<double> BetaDistribution;
CI = RealIntervalMatrix(_n, _m);
// samples
for (int i = 0; i < _n; ++i)
{
// mutations
for (int j = 0; j < _m; ++j)
{
if (_C[j][i] == 0 && _D[j][i] == 0)
{
// degenerate case:
CI.set(i, j, RealInterval(0, 0));
}
else
{
BetaDistribution B(1 + getAlt(j, i), 1 + getRef(j, i));
double UB;
if (_D[j][i] == 0)
{
UB = 1;
}
else
{
UB = boost::math::quantile(B, 1 - gamma / 2);
}
double LB;
if (_C[j][i] == 0)
{
LB = 0;
}
else
{
LB = boost::math::quantile(B, gamma / 2);
}
assert(0 <= LB && LB <= UB && UB <= 1);
CI.set(i, j, RealInterval(LB, UB));
}
}
}
}
void ReadCountMatrix::computePointEstimates(RealMatrix& F) const
{
F = RealMatrix(_n, _m);
for (int i = 0; i < _n; ++i)
{
F.setRowLabel(i, getColLabel(i));
for (int j = 0; j < _m; ++j)
{
double ref = getRef(j, i);
double alt = getAlt(j, i);
if (ref + alt != 0)
F.set(i, j, alt / (ref + alt));
}
}
for (int j = 0; j < _m; ++j)
{
F.setColLabel(j, getRowLabel(j));
}
}
} // namespace vaff
| [
"melkebir@cs.brown.edu"
] | melkebir@cs.brown.edu |
5704e9c6af7806b45dc28c02859fa285eb2b8d89 | 594ee15b20c5ec5390fbafe1cf731a182d075ba1 | /src/controlL297.cpp | 00d7138271f1c8f0466202b529440e29582cbc18 | [] | no_license | TristanFranc/SOCRATE | 5d2a0e67d76a1b110f18c0300d58b6acd73b7dcd | b98ef3d25694fc1de16f65adbf7aec23687d6a77 | refs/heads/main | 2023-04-13T18:34:15.842787 | 2021-03-29T18:47:28 | 2021-03-29T18:47:28 | 346,756,460 | 0 | 0 | null | 2021-04-15T19:24:28 | 2021-03-11T15:56:02 | C | UTF-8 | C++ | false | false | 3,824 | cpp | /*
* controlL297.cpp
*
* Created on: Mar 16, 2021
* Author: 201723940
*/
#include "controlL297.h"
controlL297::controlL297(_L297_SELECT_ selection)
{
config = new hardwareConfig();
config->GPIO_Config(GPIOB, 0, OUTPUT);//enable de tout les moteurs
config->GPIO_Config(GPIOB, 1, OUTPUT);//half full
config->GPIO_Pin_Enable(GPIOB, 1);
//config->GPIO_Pin_Disable(GPIOB,1);
speed = 1;// vitesse en HZ
lock = true;// actif bas
chanel=0;
_selection= selection;
enabled = false;
switch (selection) {
case L297_1://master
//init pinout
chanel = 2;
config->GPIO_Config(GPIOB, 3, ALTERNATE,1);//voir datasheet à table 11 pour les details de AFR
config->GPIO_Config(GPIOA, 10, OUTPUT);// direction
config->GPIO_Config(GPIOC, 9, OUTPUT);// lock
timer = new Timer(TIM2,50000,false);
timer->enablePWM(chanel,speed);
break;
case L297_2://master
//init pinout
chanel = 1;
config->GPIO_Config(GPIOB, 6, ALTERNATE, 2);//voir datasheet à table 11 pour les details de AFR
config->GPIO_Config(GPIOA, 11, OUTPUT);// direction
config->GPIO_Config(GPIOC, 8, OUTPUT);// lock
timer = new Timer(TIM4,50000,false);
timer->enablePWM(chanel, speed);
break;
case L297_3_4: // master
//init pinout
chanel = 2;
config->GPIO_Config(GPIOB, 5, ALTERNATE, 2);//voir datasheet à table 11 pour les details de AFR
config->GPIO_Config(GPIOA, 12, OUTPUT);// direction
config->GPIO_Config(GPIOC, 7, OUTPUT);// lock
timer= new Timer(TIM3, 50000, false);
timer->enablePWM(chanel, speed);
// L297_4: slave de L297_3
// pas besoin de sa propre clk, mais suivre les mouvements de L297_3;
//init pinout
config->GPIO_Config(GPIOB, 12, OUTPUT);// lock
config->GPIO_Config(GPIOC, 12, OUTPUT);// direction
break;
}
//timer->start();
}
controlL297::~controlL297()
{
if(config)
delete config;
if(timer)
delete timer;
}
void controlL297::setSpeed(uint32_t speed)
{
this->speed = speed;
timer->stop();
timer->enablePWM(chanel, speed);
timer->start();
}
void controlL297::setDirection(_DIRECTION_ dir)
{
switch (dir) {
case CCW:
if(_selection==0)
config->GPIO_Pin_Enable(GPIOA, 10);
if(_selection==1)
config->GPIO_Pin_Enable(GPIOA, 11);
if(_selection==2)
{
//les directions sont inverses, car les moteurs sont vis à vis
config->GPIO_Pin_Enable(GPIOA, 12);
config->GPIO_Pin_Disable(GPIOC, 12);
}
break;
case CW:
if(_selection==0)
config->GPIO_Pin_Disable(GPIOA, 10);
if(_selection==1)
config->GPIO_Pin_Disable(GPIOA, 11);
if(_selection==2)
{
//les directions sont inverses, car les moteurs sont vis à vis
config->GPIO_Pin_Disable(GPIOA, 12);
config->GPIO_Pin_Enable(GPIOC, 12);
}
break;
}
}
void controlL297::setLockState(_STATE_ state)
{
this->lock= state;
switch (state) {
case UNLOCK :
if(_selection==0)
config->GPIO_Pin_Enable(GPIOC, 9);
if(_selection==1)
config->GPIO_Pin_Enable(GPIOC, 8);
if(_selection==2)
{
config->GPIO_Pin_Enable(GPIOC, 7);
//config->GPIO_Pin_Enable(GPIOB, 12);
}
break;
case LOCK:
if(_selection==0)
config->GPIO_Pin_Disable(GPIOC, 9);
if(_selection==1)
config->GPIO_Pin_Disable(GPIOC, 8);
if(_selection==2)
{
config->GPIO_Pin_Disable(GPIOC, 7);
//config->GPIO_Pin_Disable(GPIOB, 12);// la trace dois être arranger avant de pouvoir parré ce moteur
//à revoir
}
break;
}
}
void controlL297::setEnable(bool state)
{
this->enabled= state;
switch (state) {
case true:
config->GPIO_Pin_Enable(GPIOB, 0);
break;
default:
config->GPIO_Pin_Disable(GPIOB, 0);
break;
}
}
uint32_t controlL297::getSpeed()
{
return this->speed;
}
bool controlL297::getDirection()
{
return 0;
}
bool controlL297::getLockState()
{
if (lock==LOCK)
{
return 0;
}
return 1;
}
bool controlL297::isEnables()
{
return enabled;
}
| [
"Tristan19992010@gmail.com"
] | Tristan19992010@gmail.com |
a786c29ff9a22716861170f83193b1f8ff4f1f3c | 536656cd89e4fa3a92b5dcab28657d60d1d244bd | /components/favicon/core/favicon_handler.cc | 95a979c852138d82a63897d29d96a08945cd5236 | [
"BSD-3-Clause"
] | permissive | ECS-251-W2020/chromium | 79caebf50443f297557d9510620bf8d44a68399a | ac814e85cb870a6b569e184c7a60a70ff3cb19f9 | refs/heads/master | 2022-08-19T17:42:46.887573 | 2020-03-18T06:08:44 | 2020-03-18T06:08:44 | 248,141,336 | 7 | 8 | BSD-3-Clause | 2022-07-06T20:32:48 | 2020-03-18T04:52:18 | null | UTF-8 | C++ | false | false | 27,723 | cc | // Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "components/favicon/core/favicon_handler.h"
#include <algorithm>
#include <cmath>
#include <utility>
#include <vector>
#include "base/bind.h"
#include "base/bind_helpers.h"
#include "base/feature_list.h"
#include "base/memory/ref_counted_memory.h"
#include "base/metrics/histogram_functions.h"
#include "base/metrics/histogram_macros.h"
#include "build/build_config.h"
#include "components/favicon/core/favicon_service.h"
#include "components/favicon/core/features.h"
#include "components/favicon_base/favicon_util.h"
#include "components/favicon_base/select_favicon_frames.h"
#include "skia/ext/image_operations.h"
#include "ui/gfx/codec/png_codec.h"
#include "ui/gfx/image/image_skia.h"
#include "ui/gfx/image/image_util.h"
namespace favicon {
namespace {
const int kLargestIconSize = 192;
// Return true if |bitmap_result| is expired.
bool IsExpired(const favicon_base::FaviconRawBitmapResult& bitmap_result) {
return bitmap_result.expired;
}
// Return true if |bitmap_result| is valid.
bool IsValid(const favicon_base::FaviconRawBitmapResult& bitmap_result) {
return bitmap_result.is_valid();
}
// Returns true if |bitmap_results| is non-empty and:
// - At least one of the bitmaps in |bitmap_results| is expired
// OR
// - |bitmap_results| is missing favicons for |desired_size_in_dip| and one of
// the scale factors in favicon_base::GetFaviconScales().
bool HasExpiredOrIncompleteResult(
int desired_size_in_dip,
const std::vector<favicon_base::FaviconRawBitmapResult>& bitmap_results) {
if (bitmap_results.empty())
return false;
// Check if at least one of the bitmaps is expired.
auto it =
std::find_if(bitmap_results.begin(), bitmap_results.end(), IsExpired);
if (it != bitmap_results.end())
return true;
// Any favicon size is good if the desired size is 0.
if (desired_size_in_dip == 0)
return false;
// Check if the favicon for at least one of the scale factors is missing.
// |bitmap_results| should always be complete for data inserted by
// FaviconHandler as the FaviconHandler stores favicons resized to all
// of favicon_base::GetFaviconScales() into the history backend.
// Examples of when |bitmap_results| can be incomplete:
// - Favicons inserted into the history backend by sync.
// - Favicons for imported bookmarks.
std::vector<gfx::Size> favicon_sizes;
for (const auto& bitmap_result : bitmap_results)
favicon_sizes.push_back(bitmap_result.pixel_size);
std::vector<float> favicon_scales = favicon_base::GetFaviconScales();
for (float favicon_scale : favicon_scales) {
int edge_size_in_pixel = std::ceil(desired_size_in_dip * favicon_scale);
gfx::Size value(edge_size_in_pixel, edge_size_in_pixel);
if (!base::Contains(favicon_sizes, value))
return true;
}
return false;
}
// Returns true if at least one of |bitmap_results| is valid.
bool HasValidResult(
const std::vector<favicon_base::FaviconRawBitmapResult>& bitmap_results) {
return std::find_if(bitmap_results.begin(), bitmap_results.end(), IsValid) !=
bitmap_results.end();
}
std::vector<int> GetDesiredPixelSizes(
FaviconDriverObserver::NotificationIconType handler_type) {
switch (handler_type) {
case FaviconDriverObserver::NON_TOUCH_16_DIP: {
std::vector<int> pixel_sizes;
for (float scale_factor : favicon_base::GetFaviconScales()) {
pixel_sizes.push_back(
static_cast<int>(ceil(scale_factor * gfx::kFaviconSize)));
}
return pixel_sizes;
}
case FaviconDriverObserver::NON_TOUCH_LARGEST:
case FaviconDriverObserver::TOUCH_LARGEST:
return std::vector<int>(1U, kLargestIconSize);
}
NOTREACHED();
return std::vector<int>();
}
bool FaviconURLEquals(const FaviconURL& lhs, const FaviconURL& rhs) {
return lhs.icon_url == rhs.icon_url && lhs.icon_type == rhs.icon_type &&
lhs.icon_sizes == rhs.icon_sizes;
}
} // namespace
////////////////////////////////////////////////////////////////////////////////
// static
FaviconHandler::FaviconCandidate
FaviconHandler::FaviconCandidate::FromFaviconURL(
const favicon::FaviconURL& favicon_url,
const std::vector<int>& desired_pixel_sizes,
bool want_largest_icon) {
FaviconCandidate candidate;
candidate.icon_url = favicon_url.icon_url;
candidate.icon_type = favicon_url.icon_type;
if (!favicon_url.icon_sizes.empty()) {
// For candidates with explicit size information, the score is computed
// based on similarity with |desired_pixel_sizes|.
SelectFaviconFrameIndices(favicon_url.icon_sizes, desired_pixel_sizes,
/*best_indices=*/nullptr, &candidate.score);
} else if (want_largest_icon) {
// If looking for largest icon (mobile), candidates without explicit size
// information are scored low because they are likely small.
candidate.score = 0.0f;
} else {
// If looking for small icons (desktop), candidates without explicit size
// information are scored highest, as high as candidates with an ideal
// explicit size information. This guarantees all candidates without
// explicit size information will be processed until an ideal candidate is
// found (if available).
candidate.score = 1.0f;
}
return candidate;
}
////////////////////////////////////////////////////////////////////////////////
FaviconHandler::FaviconHandler(
FaviconService* service,
Delegate* delegate,
FaviconDriverObserver::NotificationIconType handler_type)
: handler_type_(handler_type),
got_favicon_from_history_(false),
initial_history_result_expired_or_incomplete_(false),
redownload_icons_(false),
icon_types_(FaviconHandler::GetIconTypesFromHandlerType(handler_type)),
download_largest_icon_(
handler_type == FaviconDriverObserver::NON_TOUCH_LARGEST ||
handler_type == FaviconDriverObserver::TOUCH_LARGEST),
candidates_received_(false),
error_other_than_404_found_(false),
notification_icon_type_(favicon_base::IconType::kInvalid),
service_(service),
delegate_(delegate),
current_candidate_index_(0u) {
DCHECK(delegate_);
}
FaviconHandler::~FaviconHandler() {
}
// static
favicon_base::IconTypeSet FaviconHandler::GetIconTypesFromHandlerType(
FaviconDriverObserver::NotificationIconType handler_type) {
switch (handler_type) {
case FaviconDriverObserver::NON_TOUCH_16_DIP:
case FaviconDriverObserver::NON_TOUCH_LARGEST:
return {favicon_base::IconType::kFavicon};
case FaviconDriverObserver::TOUCH_LARGEST:
return {favicon_base::IconType::kTouchIcon,
favicon_base::IconType::kTouchPrecomposedIcon,
favicon_base::IconType::kWebManifestIcon};
}
return {};
}
void FaviconHandler::FetchFavicon(const GURL& page_url, bool is_same_document) {
cancelable_task_tracker_for_page_url_.TryCancelAll();
cancelable_task_tracker_for_candidates_.TryCancelAll();
// We generally clear |page_urls_| and start clean unless there are obvious
// reasons to think URLs share favicons: the navigation must be within the
// same document (e.g. fragment navigation) AND it happened so early that no
// candidates were received for the previous URL(s) (e.g. redirect-like
// history.replaceState() during page load).
if (!is_same_document || candidates_received_) {
page_urls_.clear();
}
page_urls_.insert(page_url);
last_page_url_ = page_url;
initial_history_result_expired_or_incomplete_ = false;
redownload_icons_ = false;
got_favicon_from_history_ = false;
manifest_download_request_.Cancel();
image_download_request_.Cancel();
candidates_received_ = false;
manifest_url_ = GURL();
non_manifest_original_candidates_.clear();
final_candidates_.reset();
notification_icon_url_ = GURL();
notification_icon_type_ = favicon_base::IconType::kInvalid;
current_candidate_index_ = 0u;
best_favicon_ = DownloadedFavicon();
// Request the favicon from the history service. In parallel to this the
// renderer is going to notify us (well WebContents) when the favicon url is
// available. We use |last_page_url_| specifically (regardless of other
// possible values in |page_urls_|) because we want to use the most
// up-to-date / latest URL for DB lookups, which is the page URL for which
// we get <link rel="icon"> candidates (FaviconHandler::OnUpdateCandidates()).
service_->GetFaviconForPageURL(
last_page_url_, icon_types_, preferred_icon_size(),
base::BindOnce(
&FaviconHandler::OnFaviconDataForInitialURLFromFaviconService,
base::Unretained(this)),
&cancelable_task_tracker_for_page_url_);
}
bool FaviconHandler::ShouldDownloadNextCandidate() const {
// Stop downloading if the current candidate is the last candidate.
if (current_candidate_index_ + 1 >= final_candidates_->size())
return false;
// Continue downloading if no valid favicon has been downloaded yet.
if (best_favicon_.candidate.icon_type == favicon_base::IconType::kInvalid)
return true;
// |next_candidate_score| is based on the sizes provided in the <link> tag,
// see FaviconCandidate::FromFaviconURL().
float next_candidate_score =
(*final_candidates_)[current_candidate_index_ + 1].score;
// Continue downloading only if the next candidate is better than the best one
// observed so far.
return next_candidate_score > best_favicon_.candidate.score;
}
void FaviconHandler::SetFavicon(const GURL& icon_url,
const gfx::Image& image,
favicon_base::IconType icon_type) {
// Associate the icon to all URLs in |page_urls_|, which contains page URLs
// within the same site/document that have been considered to reliably share
// the same icon candidates.
if (!delegate_->IsOffTheRecord())
service_->SetFavicons(page_urls_, icon_url, icon_type, image);
NotifyFaviconUpdated(icon_url, icon_type, image);
}
void FaviconHandler::MaybeDeleteFaviconMappings() {
DCHECK(candidates_received_);
DCHECK(got_favicon_from_history_);
// The order of these conditions is important because we want the feature
// state to be checked at the very end.
if (!error_other_than_404_found_ &&
notification_icon_type_ != favicon_base::IconType::kInvalid) {
if (!delegate_->IsOffTheRecord())
service_->DeleteFaviconMappings(page_urls_, notification_icon_type_);
delegate_->OnFaviconDeleted(last_page_url_, handler_type_);
notification_icon_url_ = GURL();
notification_icon_type_ = favicon_base::IconType::kInvalid;
}
}
void FaviconHandler::NotifyFaviconUpdated(
const std::vector<favicon_base::FaviconRawBitmapResult>&
favicon_bitmap_results) {
DCHECK(!favicon_bitmap_results.empty());
gfx::Image resized_image = favicon_base::SelectFaviconFramesFromPNGs(
favicon_bitmap_results,
favicon_base::GetFaviconScales(),
preferred_icon_size());
// The history service sends back results for a single icon URL and icon
// type, so it does not matter which result we get |icon_url| and |icon_type|
// from.
const GURL icon_url = favicon_bitmap_results[0].icon_url;
favicon_base::IconType icon_type = favicon_bitmap_results[0].icon_type;
NotifyFaviconUpdated(icon_url, icon_type, resized_image);
}
void FaviconHandler::NotifyFaviconUpdated(const GURL& icon_url,
favicon_base::IconType icon_type,
const gfx::Image& image) {
if (image.IsEmpty())
return;
gfx::Image image_with_adjusted_colorspace = image;
favicon_base::SetFaviconColorSpace(&image_with_adjusted_colorspace);
delegate_->OnFaviconUpdated(last_page_url_, handler_type_, icon_url,
icon_url != notification_icon_url_,
image_with_adjusted_colorspace);
notification_icon_url_ = icon_url;
notification_icon_type_ = icon_type;
}
void FaviconHandler::OnUpdateCandidates(
const GURL& page_url,
const std::vector<FaviconURL>& candidates,
const GURL& manifest_url) {
if (last_page_url_ != page_url)
return;
// |candidates| or |manifest_url| could have been modified via Javascript. If
// neither changed, ignore the call.
if (candidates_received_ && manifest_url_ == manifest_url &&
(non_manifest_original_candidates_.size() == candidates.size() &&
std::equal(candidates.begin(), candidates.end(),
non_manifest_original_candidates_.begin(),
&FaviconURLEquals))) {
return;
}
candidates_received_ = true;
error_other_than_404_found_ = false;
non_manifest_original_candidates_ = candidates;
final_candidates_.reset();
cancelable_task_tracker_for_candidates_.TryCancelAll();
manifest_download_request_.Cancel();
image_download_request_.Cancel();
current_candidate_index_ = 0u;
best_favicon_ = DownloadedFavicon();
manifest_url_ = manifest_url;
// Check if the manifest was previously blacklisted (e.g. returned a 404) and
// ignore the manifest URL if that's the case.
if (!manifest_url_.is_empty() &&
service_->WasUnableToDownloadFavicon(manifest_url_)) {
DVLOG(1) << "Skip failed Manifest: " << manifest_url;
manifest_url_ = GURL();
}
// If no manifest available, proceed with the regular candidates only.
if (manifest_url_.is_empty()) {
OnGotFinalIconURLCandidates(candidates);
return;
}
// See if there is a cached favicon for the manifest. This will update the DB
// mappings only if the manifest URL is cached.
GetFaviconAndUpdateMappingsUnlessIncognito(
/*icon_url=*/manifest_url_, favicon_base::IconType::kWebManifestIcon,
base::BindOnce(
&FaviconHandler::OnFaviconDataForManifestFromFaviconService,
base::Unretained(this)));
}
void FaviconHandler::OnFaviconDataForManifestFromFaviconService(
const std::vector<favicon_base::FaviconRawBitmapResult>&
favicon_bitmap_results) {
// The database lookup for the page URL is guaranteed to be completed because
// the HistoryBackend uses a SequencedTaskRunner, and we also know that
// FetchFavicon() was called before OnUpdateCandidates().
DCHECK(got_favicon_from_history_);
bool has_valid_result = HasValidResult(favicon_bitmap_results);
bool has_expired_or_incomplete_result =
!has_valid_result || HasExpiredOrIncompleteResult(preferred_icon_size(),
favicon_bitmap_results);
if (has_valid_result &&
(notification_icon_url_ != manifest_url_ ||
notification_icon_type_ != favicon_base::IconType::kWebManifestIcon)) {
// There is a valid favicon. Notify any observers. It is useful to notify
// the observers even if the favicon is expired or incomplete (incorrect
// size) because temporarily showing the user an expired favicon or
// streched favicon is preferable to showing the user the default favicon.
NotifyFaviconUpdated(favicon_bitmap_results);
}
if (has_expired_or_incomplete_result) {
manifest_download_request_.Reset(base::BindOnce(
&FaviconHandler::OnDidDownloadManifest, base::Unretained(this)));
delegate_->DownloadManifest(manifest_url_,
manifest_download_request_.callback());
}
}
void FaviconHandler::OnDidDownloadManifest(
const std::vector<FaviconURL>& candidates) {
// Mark manifest download as finished.
manifest_download_request_.Cancel();
if (!candidates.empty()) {
OnGotFinalIconURLCandidates(candidates);
return;
}
// If either the downloading of the manifest failed, OR the manifest contains
// no icons, proceed with the list of icons listed in the HTML.
DVLOG(1) << "Could not fetch Manifest icons from " << manifest_url_
<< ", falling back to inlined ones, which are "
<< non_manifest_original_candidates_.size();
service_->UnableToDownloadFavicon(manifest_url_);
manifest_url_ = GURL();
OnGotFinalIconURLCandidates(non_manifest_original_candidates_);
}
void FaviconHandler::OnGotFinalIconURLCandidates(
const std::vector<FaviconURL>& candidates) {
DCHECK(!final_candidates_);
const std::vector<int> desired_pixel_sizes =
GetDesiredPixelSizes(handler_type_);
std::vector<FaviconCandidate> sorted_candidates;
for (const FaviconURL& candidate : candidates) {
if (!candidate.icon_url.is_empty() &&
(icon_types_.count(candidate.icon_type) != 0)) {
sorted_candidates.push_back(FaviconCandidate::FromFaviconURL(
candidate, desired_pixel_sizes, download_largest_icon_));
}
}
std::stable_sort(sorted_candidates.begin(), sorted_candidates.end(),
&FaviconCandidate::CompareScore);
final_candidates_ = std::move(sorted_candidates);
if (got_favicon_from_history_)
OnGotInitialHistoryDataAndIconURLCandidates();
}
// static
int FaviconHandler::GetMaximalIconSize(
FaviconDriverObserver::NotificationIconType handler_type,
bool candidates_from_web_manifest) {
int max_size = 0;
for (int size : GetDesiredPixelSizes(handler_type)) {
max_size = std::max(max_size, size);
}
return max_size;
}
void FaviconHandler::OnGotInitialHistoryDataAndIconURLCandidates() {
DCHECK(final_candidates_);
DCHECK(got_favicon_from_history_);
DCHECK_EQ(0U, current_candidate_index_);
if (final_candidates_->empty()) {
// The page lists no candidates that match our target |icon_types_|, so
// check if any existing mappings should be deleted.
MaybeDeleteFaviconMappings();
return;
}
if (!initial_history_result_expired_or_incomplete_ &&
current_candidate()->icon_url == notification_icon_url_ &&
current_candidate()->icon_type == notification_icon_type_) {
// - The data from history is valid and not expired.
// - The icon URL of the history data matches one of the page's icon URLs.
// - The icon URL of the history data matches the icon URL of the last
// OnFaviconAvailable() notification.
// We are done. No additional downloads or history requests are needed.
// TODO: Store all of the icon URLs associated with a page in history so
// that we can check whether the page's icon URLs match the page's icon URLs
// at the time that the favicon data was stored to the history database.
return;
}
DownloadCurrentCandidateOrAskFaviconService();
}
void FaviconHandler::OnDidDownloadFavicon(
favicon_base::IconType icon_type,
int id,
int http_status_code,
const GURL& image_url,
const std::vector<SkBitmap>& bitmaps,
const std::vector<gfx::Size>& original_bitmap_sizes) {
// Mark download as finished.
image_download_request_.Cancel();
if (bitmaps.empty()) {
if (http_status_code == 404) {
DVLOG(1) << "Failed to Download Favicon:" << image_url;
service_->UnableToDownloadFavicon(image_url);
} else if (http_status_code != 0) {
error_other_than_404_found_ = true;
}
} else {
float score = 0.0f;
gfx::ImageSkia image_skia;
if (download_largest_icon_) {
std::vector<size_t> best_indices;
SelectFaviconFrameIndices(original_bitmap_sizes,
GetDesiredPixelSizes(handler_type_),
&best_indices, &score);
DCHECK_EQ(1U, best_indices.size());
image_skia =
gfx::ImageSkia::CreateFrom1xBitmap(bitmaps[best_indices.front()]);
} else {
image_skia = CreateFaviconImageSkia(bitmaps,
original_bitmap_sizes,
preferred_icon_size(),
&score);
}
if (!image_skia.isNull() && score > best_favicon_.candidate.score) {
best_favicon_.image = gfx::Image(image_skia);
best_favicon_.candidate.icon_url = image_url;
best_favicon_.candidate.icon_type = icon_type;
best_favicon_.candidate.score = score;
}
}
if (ShouldDownloadNextCandidate()) {
// Process the next candidate.
++current_candidate_index_;
DCHECK_LT(current_candidate_index_, final_candidates_->size());
DownloadCurrentCandidateOrAskFaviconService();
} else {
if (best_favicon_.candidate.icon_type == favicon_base::IconType::kInvalid) {
// No valid icon found, so check if mappings should be deleted.
MaybeDeleteFaviconMappings();
} else {
// We have either found the ideal candidate or run out of candidates.
// No more icons to request, set the favicon from the candidate. The
// manifest URL, if available, is used instead of the icon URL.
SetFavicon(manifest_url_.is_empty() ? best_favicon_.candidate.icon_url
: manifest_url_,
best_favicon_.image,
manifest_url_.is_empty()
? best_favicon_.candidate.icon_type
: favicon_base::IconType::kWebManifestIcon);
}
// Clear download related state.
current_candidate_index_ = final_candidates_->size();
best_favicon_ = DownloadedFavicon();
}
}
const std::vector<GURL> FaviconHandler::GetIconURLs() const {
std::vector<GURL> icon_urls;
for (const FaviconCandidate& candidate : *final_candidates_)
icon_urls.push_back(candidate.icon_url);
return icon_urls;
}
bool FaviconHandler::HasPendingTasksForTest() {
return !image_download_request_.IsCancelled() ||
!manifest_download_request_.IsCancelled() ||
cancelable_task_tracker_for_page_url_.HasTrackedTasks() ||
cancelable_task_tracker_for_candidates_.HasTrackedTasks();
}
void FaviconHandler::OnFaviconDataForInitialURLFromFaviconService(
const std::vector<favicon_base::FaviconRawBitmapResult>&
favicon_bitmap_results) {
got_favicon_from_history_ = true;
bool has_valid_result = HasValidResult(favicon_bitmap_results);
initial_history_result_expired_or_incomplete_ =
!has_valid_result ||
HasExpiredOrIncompleteResult(preferred_icon_size(),
favicon_bitmap_results);
redownload_icons_ = initial_history_result_expired_or_incomplete_ &&
!favicon_bitmap_results.empty();
if (has_valid_result) {
// Propagate mappings to all redirects, in case the redirect chain is
// different from the one observed the previous time the page URL was
// visited.
//
// Do the propagation now because we want the propagation to occur in all
// scenarios and this is an easy way of guaranteeing it. For instance, we
// want the propagation to occur when:
// - The favicon in the database is expired.
// AND
// - Redownloading the favicon fails with a non-404 error code.
if (!delegate_->IsOffTheRecord() &&
base::FeatureList::IsEnabled(kAllowPropagationOfFaviconCacheHits)) {
service_->CloneFaviconMappingsForPages(last_page_url_, icon_types_,
page_urls_);
}
// The db knows the favicon (although it may be out of date). Set the
// favicon now, and if the favicon turns out to be expired (or the wrong
// url) we'll fetch later on. This way the user doesn't see a flash of the
// default favicon.
NotifyFaviconUpdated(favicon_bitmap_results);
}
if (final_candidates_)
OnGotInitialHistoryDataAndIconURLCandidates();
}
void FaviconHandler::DownloadCurrentCandidateOrAskFaviconService() {
DCHECK(image_download_request_.IsCancelled());
DCHECK(manifest_download_request_.IsCancelled());
DCHECK(current_candidate());
const GURL icon_url = current_candidate()->icon_url;
const favicon_base::IconType icon_type = current_candidate()->icon_type;
// If the icons listed in a manifest are being processed, skip the cache
// lookup for |icon_url| since the manifest's URL is used for caching, not the
// icon URL, and this lookup has happened earlier.
if (redownload_icons_ || !manifest_url_.is_empty()) {
// We have the mapping, but the favicon is out of date. Download it now.
ScheduleImageDownload(icon_url, icon_type);
} else {
GetFaviconAndUpdateMappingsUnlessIncognito(
icon_url, icon_type,
base::BindOnce(&FaviconHandler::OnFaviconData, base::Unretained(this)));
}
}
void FaviconHandler::GetFaviconAndUpdateMappingsUnlessIncognito(
const GURL& icon_url,
favicon_base::IconType icon_type,
favicon_base::FaviconResultsCallback callback) {
// We don't know the favicon, but we may have previously downloaded the
// favicon for another page that shares the same favicon. Ask for the
// favicon given the favicon URL.
if (delegate_->IsOffTheRecord()) {
service_->GetFavicon(icon_url, icon_type, preferred_icon_size(),
std::move(callback),
&cancelable_task_tracker_for_candidates_);
} else {
// Ask the history service for the icon. This does two things:
// 1. Attempts to fetch the favicon data from the database.
// 2. If the favicon exists in the database, this updates the database to
// include the mapping between the page url and the favicon url.
// This is asynchronous. The history service will call back when done.
service_->UpdateFaviconMappingsAndFetch(
page_urls_, icon_url, icon_type, preferred_icon_size(),
std::move(callback), &cancelable_task_tracker_for_candidates_);
}
}
void FaviconHandler::OnFaviconData(const std::vector<
favicon_base::FaviconRawBitmapResult>& favicon_bitmap_results) {
bool has_valid_result = HasValidResult(favicon_bitmap_results);
bool has_expired_or_incomplete_result =
!has_valid_result || HasExpiredOrIncompleteResult(preferred_icon_size(),
favicon_bitmap_results);
if (has_valid_result) {
// There is a valid favicon. Notify any observers. It is useful to notify
// the observers even if the favicon is expired or incomplete (incorrect
// size) because temporarily showing the user an expired favicon or
// streched favicon is preferable to showing the user the default favicon.
NotifyFaviconUpdated(favicon_bitmap_results);
}
if (has_expired_or_incomplete_result) {
ScheduleImageDownload(current_candidate()->icon_url,
current_candidate()->icon_type);
}
}
void FaviconHandler::ScheduleImageDownload(const GURL& image_url,
favicon_base::IconType icon_type) {
DCHECK(image_url.is_valid());
// Note that CancelableCallback starts cancelled.
DCHECK(image_download_request_.IsCancelled())
<< "More than one ongoing download";
if (service_->WasUnableToDownloadFavicon(image_url)) {
DVLOG(1) << "Skip Failed FavIcon: " << image_url;
OnDidDownloadFavicon(icon_type, 0, 0, image_url, std::vector<SkBitmap>(),
std::vector<gfx::Size>());
return;
}
image_download_request_.Reset(
base::BindOnce(&FaviconHandler::OnDidDownloadFavicon,
base::Unretained(this), icon_type));
// A max bitmap size is specified to avoid receiving huge bitmaps in
// OnDidDownloadFavicon(). See FaviconDriver::StartDownload()
// for more details about the max bitmap size.
const int download_id = delegate_->DownloadImage(
image_url, GetMaximalIconSize(handler_type_, !manifest_url_.is_empty()),
image_download_request_.callback());
DCHECK_NE(download_id, 0);
}
} // namespace favicon
| [
"pcding@ucdavis.edu"
] | pcding@ucdavis.edu |
0738878c1023c24798335f7114e2763f8dd1e067 | 24ee99f16666f5ae662c7a062bde01dff359ebd9 | /2. Recursion/4. Decode Ways LC - 91.cpp | 3a77bcf52631756e05e32433ece97dca962c81b2 | [] | no_license | Anurag-c/Codes | d103cf2d406175ce8c6a5eab2c0163e1e6c5877f | d69df2a1a6d6d33fe3f0f9d52e32b98cd5abcde2 | refs/heads/main | 2023-03-29T14:00:42.576632 | 2021-04-11T08:11:09 | 2021-04-11T08:11:09 | 324,210,053 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 592 | cpp |
string hm[27] = {"","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"};
int solve(string s, string ans)
{
if(s.length() == 0)
{
cout<<ans<<"\n";
return 1;
}
if(s[0] == '0') return 0;
int count = 0;
count += solve(s.substr(1), ans + hm[s[0] - '0']);
if(s.length() > 1)
{
int num = ((s[0] - '0') * 10) + (s[1] - '0');
if(num <= 26) count += solve(s.substr(2), ans + hm[num]);
}
return count;
}
int numDecodings(string s)
{
return solve(s, "");
} | [
"anurag.nampally@gmail.com"
] | anurag.nampally@gmail.com |
6b1cace66cc8873142ba6fd9f7988c89d8f7253a | 229eec27e408f5b4abfd970632f4b80ebe7a15bf | /OncomingPreAlpha/Item/Throwable/Food/LumpyPorridge.cpp | 837a4eae9ef7d1728ebc7e95b0e41a95052e4bde | [] | no_license | TriFuse-Infrared/Oncoming-Pre-Alpha | 2d937c344212ed1291bcfdc23d70af273c827ecc | 7eab3bd2cd3de1c633c43d11f65dd940b539e6ba | refs/heads/master | 2021-01-18T09:49:26.516608 | 2015-09-19T03:35:19 | 2015-09-19T03:35:19 | 42,758,317 | 1 | 0 | null | 2015-09-19T03:41:46 | 2015-09-19T03:41:45 | null | UTF-8 | C++ | false | false | 765 | cpp | // All rights reserved Trifuse. Written by AidoP
#include "OncomingPreAlpha.h"
#include "LumpyPorridge.h"
ALumpyPorridge::ALumpyPorridge(const FObjectInitializer& ObjectInitializer) : Super(ObjectInitializer) {
PrimaryActorTick.bCanEverTick = true; // Ensure that the item doesn't tick as we don't need to for the base!
static ConstructorHelpers::FObjectFinder<UTexture2D> IconObj(TEXT("/Game/Items/LumpyPorridgeIcon")); // Get instance of hat texture
Icon = IconObj.Object; // Set hat texture to icon
Name = "Porridge"; // Set the name
Description = "Well preserved lumpy porridge. So good it will make you cry."; // Set the description
Weight = 0.75f; // Set the weight
Mass = 1.25f; // Set the mass for calculating shit
} | [
"AidoP@EyeMac.local"
] | AidoP@EyeMac.local |
04c16a717bbf1f3c9f08a57f03d17522a4762c00 | 92d5a45cd6c197087adc3ae6b9949ba58905a115 | /ColorMaps.h | 9cadcf8fdad68d1fe07cd7cc1b67d51fdc4b4705 | [
"MIT"
] | permissive | embeddedmz/QwtWaterfallplot | ceb67d7b0335cbf91b4bb651ee17416a2585c99d | 58403c2c294188c4de4ff35da66d2a6407907d6a | refs/heads/master | 2020-06-20T17:54:20.477947 | 2020-06-10T15:59:53 | 2020-06-10T15:59:53 | 197,200,108 | 9 | 4 | null | null | null | null | UTF-8 | C++ | false | false | 512 | h | #ifndef WATERFALLCOLORMAPS_H
#define WATERFALLCOLORMAPS_H
#include <tuple>
#include <vector>
namespace ColorMaps
{
/* x (control point), red, green, blue
* all values must be defined between 0.0 and 1.0
* ControlPoints must be sorted in ascending order of 'x' points.
*/
typedef std::tuple<double, double, double, double> ControlPoint;
typedef std::vector<ControlPoint> ControlPoints;
ControlPoints BlackBodyRadiation();
ControlPoints CoolToWarm();
ControlPoints Jet();
}
#endif // WATERFALLCOLORMAPS_H
| [
"aminemzoughi@febus-optics.com"
] | aminemzoughi@febus-optics.com |
59640bb02aad3eb3fd075573c08c5f7e5d8e2d4c | 47c3fe1ffc4970f27b4c211d922ea944db246fd5 | /Exception.cpp | b8f3aec750ba992018e293d080d992fd6e5a1f6d | [] | no_license | luizbag/evaluate | 55d1c3ee0c73ca47942fa23a954d77676aba5cca | ca72df9c15d86e4ec143786f294e926987eb7413 | refs/heads/master | 2020-05-18T16:24:47.213040 | 2014-09-26T17:52:32 | 2014-09-26T17:52:32 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 281 | cpp | /*
* Exception.cpp
*
* Created on: Sep 28, 2011
* Author: Marcus
*/
#include"Exception.h"
/* Implementation of Exception methods */
Exception::Exception() : cErrorMessage("Invalid Method Called"){}
void Exception::showError(){
cout << cErrorMessage << endl;
}
| [
"luizbag@gmail.com"
] | luizbag@gmail.com |
2718c92f237e8cd97f36c5da461cede1ec874bd9 | 6d64c36b9e0c158829ca11e275fe8759e2bc0eff | /src/zmq/zmqconfig.h | 30f99e27006c4466b00410727c55d6eaabbf3827 | [
"MIT"
] | permissive | thehomosapien/dutcoin | 65e4ae372f7622b96df4d80a87706d609c4e56f0 | 43a2a3e42713260eec7dac62145c991e59bb3287 | refs/heads/master | 2020-07-01T03:36:21.234004 | 2019-08-07T13:01:27 | 2019-08-07T13:01:27 | 200,853,776 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 512 | h | // Copyright (c) 2015
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#ifndef BITCOIN_ZMQ_ZMQCONFIG_H
#define BITCOIN_ZMQ_ZMQCONFIG_H
#if defined(HAVE_CONFIG_H)
#include "config/dutcoin-config.h"
#endif
#include <stdarg.h>
#include <string>
#if ENABLE_ZMQ
#include <zmq.h>
#endif
#include "primitives/block.h"
#include "primitives/transaction.h"
void zmqError(const char *str);
#endif // BITCOIN_ZMQ_ZMQCONFIG_H
| [
"rishabhshukla@opulasoft.com"
] | rishabhshukla@opulasoft.com |
0f1aed33348040f1a784758d7f7bba7ed11916a8 | 20508d3405b86a8b00dcc9ac554f53a0e6a75ba1 | /june/review/6603.cpp | 3c49dc94c4df915c2bf6e8a16de35a2061c0548f | [] | no_license | edgarSang/algorithm-learn | d9ec71bec5fe1e0d2fbcc8a7a0f9aa976619c300 | 686da5e797dc27f85cb5de73c276ce3041809bf5 | refs/heads/master | 2021-05-11T17:06:50.073664 | 2019-10-16T14:16:30 | 2019-10-16T14:16:30 | 117,785,707 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 895 | cpp | #include <cstdio>
#include <cstring>
#include <vector>
using namespace std;
int T,N;
int S[12];
void printfDap(vector<int>& dap) {
for(int i=0; i<6; i++) {
printf("%d ", S[dap[i]]);
}
printf("\n");
}
void go(int n, vector<int>& dap) {
int size = dap.size();
if(size > 6) return;
//dap의 사이즈가 6개를 체웠을경우 출력
if(size==6) {
printfDap(dap);
return;
}
for(int i=n+1; i<N; i++) {
//만약 6개를 넘기는 위치의 인덱스를 선택하면종료
//if(size+(N-n) < 6) return;
dap.push_back(i);
go(i, dap);
dap.pop_back();
}
}
int main() {
while(1) {
memset(S,0,sizeof(S));
scanf("%d", &N);
if(N==0) break;
for(int i=0; i<N; i++) {
scanf("%d", &S[i]);
}
vector<int> dap;
for(int i=0; i<N; i++) {
dap.push_back(i);
go(i, dap);
dap.pop_back();
}
printf("\n");
}
return 0;
} | [
"poseidon0288@gmail.com"
] | poseidon0288@gmail.com |
46b507967b0dca55d67cd1f12f7ac5015aaf6468 | 8c8820fb84dea70d31c1e31dd57d295bd08dd644 | /Engine/Private/TriggerActors.cpp | 273387636aa2ff608cd859dc98c36bc56a6e8243 | [] | no_license | redisread/UE-Runtime | e1a56df95a4591e12c0fd0e884ac6e54f69d0a57 | 48b9e72b1ad04458039c6ddeb7578e4fc68a7bac | refs/heads/master | 2022-11-15T08:30:24.570998 | 2020-06-20T06:37:55 | 2020-06-20T06:37:55 | 274,085,558 | 3 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 6,332 | cpp | // Copyright Epic Games, Inc. All Rights Reserved.
/*=============================================================================
TriggerActors.cpp: Trigger implementation
=============================================================================*/
#include "CoreMinimal.h"
#include "Engine/EngineTypes.h"
#include "GameFramework/Actor.h"
#include "Components/BillboardComponent.h"
#include "Engine/TriggerBox.h"
#include "Engine/TriggerCapsule.h"
#include "Engine/TriggerSphere.h"
#include "Components/BoxComponent.h"
#include "Components/SphereComponent.h"
#include "Components/CapsuleComponent.h"
namespace
{
static const FColor TriggerBaseColor(100, 255, 100, 255);
static const FName TriggerCollisionProfileName(TEXT("Trigger"));
}
ATriggerCapsule::ATriggerCapsule(const FObjectInitializer& ObjectInitializer)
: Super(ObjectInitializer.SetDefaultSubobjectClass<UCapsuleComponent>(TEXT("CollisionComp")))
{
UCapsuleComponent* CapsuleCollisionComponent = CastChecked<UCapsuleComponent>(GetCollisionComponent());
CapsuleCollisionComponent->ShapeColor = TriggerBaseColor;
CapsuleCollisionComponent->InitCapsuleSize(+40.0f, +80.0f);
CapsuleCollisionComponent->SetCollisionProfileName(TriggerCollisionProfileName);
bCollideWhenPlacing = true;
SpawnCollisionHandlingMethod = ESpawnActorCollisionHandlingMethod::AdjustIfPossibleButDontSpawnIfColliding;
#if WITH_EDITORONLY_DATA
if (UBillboardComponent* TriggerSpriteComponent = GetSpriteComponent())
{
TriggerSpriteComponent->SetupAttachment(CapsuleCollisionComponent);
}
#endif
}
#if WITH_EDITOR
void ATriggerCapsule::EditorApplyScale(const FVector& DeltaScale, const FVector* PivotLocation, bool bAltDown, bool bShiftDown, bool bCtrlDown)
{
const FVector ModifiedScale = DeltaScale * ( AActor::bUsePercentageBasedScaling ? 500.0f : 5.0f );
UCapsuleComponent * CapsuleComponent = CastChecked<UCapsuleComponent>(GetRootComponent());
if ( bCtrlDown )
{
// CTRL+Scaling modifies trigger collision height. This is for convenience, so that height
// can be changed without having to use the non-uniform scaling widget (which is
// inaccessable with spacebar widget cycling).
const float CapsuleRadius = CapsuleComponent->GetUnscaledCapsuleRadius();
float CapsuleHalfHeight = CapsuleComponent->GetUnscaledCapsuleHalfHeight();
CapsuleHalfHeight += ModifiedScale.X;
CapsuleHalfHeight = FMath::Max( 0.0f, CapsuleHalfHeight );
CapsuleComponent->SetCapsuleSize(CapsuleRadius, CapsuleHalfHeight);
}
else
{
float CapsuleRadius = CapsuleComponent->GetUnscaledCapsuleRadius();
float CapsuleHalfHeight = CapsuleComponent->GetUnscaledCapsuleHalfHeight();
CapsuleRadius += ModifiedScale.X;
CapsuleRadius = FMath::Max( 0.0f, CapsuleRadius );
// If non-uniformly scaling, Z scale affects height and Y can affect radius too.
if ( !ModifiedScale.AllComponentsEqual() )
{
// *2 to keep the capsule more capsule shaped during scaling
CapsuleHalfHeight+= ModifiedScale.Z * 2.0f;
CapsuleHalfHeight = FMath::Max( 0.0f, CapsuleHalfHeight );
CapsuleRadius += ModifiedScale.Y;
CapsuleRadius = FMath::Max( 0.0f, CapsuleRadius );
}
else
{
// uniform scaling, so apply to height as well
// *2 to keep the capsule more capsule shaped during scaling
CapsuleHalfHeight += ModifiedScale.Z * 2.0f;
CapsuleHalfHeight = FMath::Max( 0.0f, CapsuleHalfHeight );
}
CapsuleComponent->SetCapsuleSize(CapsuleRadius, CapsuleHalfHeight);
}
}
#endif //WITH_EDITOR
ATriggerBox::ATriggerBox(const FObjectInitializer& ObjectInitializer)
: Super(ObjectInitializer.SetDefaultSubobjectClass<UBoxComponent>(TEXT("CollisionComp")))
{
UBoxComponent* BoxCollisionComponent = CastChecked<UBoxComponent>(GetCollisionComponent());
BoxCollisionComponent->ShapeColor = TriggerBaseColor;
BoxCollisionComponent->InitBoxExtent(FVector(40.0f, 40.0f, 40.0f));
BoxCollisionComponent->SetCollisionProfileName(TriggerCollisionProfileName);
#if WITH_EDITORONLY_DATA
if (UBillboardComponent* TriggerSpriteComponent = GetSpriteComponent())
{
TriggerSpriteComponent->SetupAttachment(BoxCollisionComponent);
}
#endif
}
#if WITH_EDITOR
void ATriggerBox::EditorApplyScale(const FVector& DeltaScale, const FVector* PivotLocation, bool bAltDown, bool bShiftDown, bool bCtrlDown)
{
const FVector ModifiedScale = DeltaScale * ( AActor::bUsePercentageBasedScaling ? 500.0f : 5.0f );
UBoxComponent * BoxComponent = CastChecked<UBoxComponent>(GetRootComponent());
if ( bCtrlDown )
{
// CTRL+Scaling modifies trigger collision height. This is for convenience, so that height
// can be changed without having to use the non-uniform scaling widget (which is
// inaccessable with spacebar widget cycling).
FVector Extent = BoxComponent->GetUnscaledBoxExtent() + FVector(0, 0, ModifiedScale.X);
Extent.Z = FMath::Max(0.0f, Extent.Z);
BoxComponent->SetBoxExtent(Extent);
}
else
{
FVector Extent = BoxComponent->GetUnscaledBoxExtent() + FVector(ModifiedScale.X, ModifiedScale.Y, ModifiedScale.Z);
Extent.X = FMath::Max(0.0f, Extent.X);
Extent.Y = FMath::Max(0.0f, Extent.Y);
Extent.Z = FMath::Max(0.0f, Extent.Z);
BoxComponent->SetBoxExtent(Extent);
}
}
#endif //WITH_EDITOR
ATriggerSphere::ATriggerSphere(const FObjectInitializer& ObjectInitializer)
: Super(ObjectInitializer.SetDefaultSubobjectClass<USphereComponent>(TEXT("CollisionComp")))
{
USphereComponent* SphereCollisionComponent = CastChecked<USphereComponent>(GetCollisionComponent());
SphereCollisionComponent->ShapeColor = TriggerBaseColor;
SphereCollisionComponent->InitSphereRadius(+40.0f);
SphereCollisionComponent->SetCollisionProfileName(TriggerCollisionProfileName);
#if WITH_EDITORONLY_DATA
if (UBillboardComponent* TriggerSpriteComponent = GetSpriteComponent())
{
TriggerSpriteComponent->SetupAttachment(SphereCollisionComponent);
}
#endif
}
#if WITH_EDITOR
void ATriggerSphere::EditorApplyScale(const FVector& DeltaScale, const FVector* PivotLocation, bool bAltDown, bool bShiftDown, bool bCtrlDown)
{
const FVector ModifiedScale = DeltaScale * ( AActor::bUsePercentageBasedScaling ? 500.0f : 5.0f );
USphereComponent * SphereComponent = CastChecked<USphereComponent>(GetRootComponent());
SphereComponent->SetSphereRadius(FMath::Max<float>(0.0f, SphereComponent->GetUnscaledSphereRadius() + ModifiedScale.X));
}
#endif //WITH_EDITOR
| [
"wujiahong19981022@outlook.com"
] | wujiahong19981022@outlook.com |
b626d647de52bf8f8fadabe07ce31dfd6360dc5b | 04101fb4c49840c54d314b44ecdfbacaea99d9ec | /test_217/test_217/main.cpp | 31429b722e65729c9f0c2f3ae37d4d3b28048bf9 | [] | no_license | lantian-fz/test_cpp | b3e14da51e84876a20244f3693364e66e47b904d | 8b0a776be3b00591f08deca9b208130ccdbedb8c | refs/heads/master | 2021-07-16T00:25:39.257501 | 2020-10-17T08:07:14 | 2020-10-17T08:07:14 | 216,210,039 | 0 | 0 | null | null | null | null | GB18030 | C++ | false | false | 2,127 | cpp | #define _CRT_SECURE_NO_WARNINGS 1
//剑指offer-二叉搜索树与双向链表
//输入一棵二叉搜索树,将该二叉搜索树转换成一个排序的双向链表。
//要求不能创建任何新的结点,只能调整树中结点指针的指向。
#include <iostream>
#include <vector>
using namespace std;
struct TreeNode
{
int val;
struct TreeNode *left;
struct TreeNode *right;
TreeNode(int x) :val(x), left(NULL), right(NULL) {}
};
void ConvertNode(TreeNode* pNode, TreeNode*& pInList)
{
if (pNode == nullptr)
return;
TreeNode* current = pNode;
if (current->left != nullptr)
ConvertNode(current->left, pInList);
current->left = pInList;
if (pInList != nullptr)
pInList->right = current;
pInList = current;
if (current->right != nullptr)
ConvertNode(current->right, pInList);
}
TreeNode* Convert(TreeNode* pRootOfTree)
{
TreeNode* pInList = nullptr;//用来指向双向链表的尾结点
ConvertNode(pRootOfTree, pInList);
TreeNode* head = pInList;
while (head != nullptr && head->left != nullptr)
head = head->left;
return head;
}
////////////////////////////////////////////////////////////
void print(TreeNode* root, vector<TreeNode*>& arr)
{
if (root == nullptr)
return;
print(root->left, arr);
arr.push_back(root);
print(root->right, arr);
}
TreeNode* Convert_2(TreeNode* pRootOfTree)
{
TreeNode* p = pRootOfTree;
vector<TreeNode*> arr;
if (!p)
return nullptr;
print(pRootOfTree, arr);
if (arr.size() == 1)
return arr[0];
arr[0]->left = nullptr;
arr[0]->right = arr[1];
int i = 0;
for (i = 1; i < arr.size()-1; i++)
{
arr[i]->left = arr[i - 1];
arr[i]->right = arr[i + 1];
}
arr[i]->left = arr[i - 1];
arr[i]->right = nullptr;
return arr[0];
}
void main()
{
TreeNode* root = new TreeNode(10);
root->left = new TreeNode(6);
root->right = new TreeNode(14);
root->left->left = new TreeNode(4);
root->left->right = new TreeNode(8);
root->right->left = new TreeNode(12);
root->right->right = new TreeNode(16);
TreeNode* head = Convert_2(root);
TreeNode* p = head;
while (p)
{
cout << p->val << " ";
p = p->right;
}
cout << endl;
} | [
"2459396922@qq.com"
] | 2459396922@qq.com |
2a930d85312b726b49026b73b80af6db4b695503 | f0371b845905b5afbaa238cacc37a92986f04133 | /cli-svr-example/intro.cpp | da39fb6d422e25592266fc8879bcd15178e8f8c7 | [
"LicenseRef-scancode-warranty-disclaimer"
] | no_license | aryan-gupta/ECGR3123 | 312bf2001fd9fd2edb068819490a1fadc26c4270 | 829a3e8d012cdfb167b82df5ffc8d0ae58bf2a64 | refs/heads/master | 2021-03-22T04:22:48.920450 | 2018-08-14T13:39:25 | 2018-08-14T13:39:25 | 118,788,540 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 318 | cpp |
//#include <windows.h>
#include <iostream>
#include <winsock2.h>
int main() {
WSADATA wsaData;
// Initialize Winsock
int iResult = WSAStartup(MAKEWORD(2,2), &wsaData);
if (iResult != 0) {
std::cout << "WSAStartup failed: " << iResult << "\n";
return 1;
}
SOCKET sock = socket(PF_INET, SOCKET_STREAM)
} | [
"kuantum.freak@gmail.com"
] | kuantum.freak@gmail.com |
22123f32fad27582c2690a012cc22f13de026afc | 9795f4b83e894a512fa69ebe79a97b4530fa8fe5 | /1818/src/Commands/Autonomous/AutonomousRight.cpp | 107fa6d08deb3d82554f804849c1f554841fb787 | [] | no_license | FRC-1818/CommandBot | b94545f8b675a57d4925d495702d351c0d6eeb65 | a66ceea6f0d2e23c0470f5ba5bcd74c721a0ceac | refs/heads/master | 2021-05-01T08:26:27.060917 | 2017-03-24T02:36:08 | 2017-03-24T02:36:08 | 79,667,059 | 1 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 883 | cpp | #include "AutonomousRight.h"
AutonomousRight::AutonomousRight() {
Requires(Robot::drivebaseSubsystem.get());
timer.reset(new Timer());
timer->Reset();
timer->Start();
}
void AutonomousRight::Initialize() {
timer->Reset();
timer->Start();
}
void AutonomousRight::Execute() {
if(timer->Get() < 2.35)
Robot::drivebaseSubsystem->MecanumDrive(0.0, 0.5, 0.0, 0.0);
if(timer->Get() > 2.35 && timer->Get() < 3.25)
Robot::drivebaseSubsystem->MecanumDrive(0.0, 0.0, 0.5, 0.0);
if(timer->Get() > 3.25 && timer->Get() < 3.90 )
Robot::drivebaseSubsystem->MecanumDrive(-0.5, 0.0, 0.0, 0.0);
}
bool AutonomousRight::IsFinished() {
return false;
}
void AutonomousRight::End() {
timer->Stop();
//Robot::drivebaseSubsystem->MecanumDrive(0.0, 0.0, 0.0, 0.0);
}
void AutonomousRight::Interrupted() {
timer->Stop();
//Robot::drivebaseSubsystem->MecanumDrive(0.0, 0.0, 0.0, 0.0);
}
| [
"noreply@github.com"
] | noreply@github.com |
b30355995bc0da6b8875ccb2bc2066301e7a8749 | d83ceeafd709e03577d0ed5f996719128b621223 | /Baekjoon/Baekjoon/1652_누울_자리를_찾아라.cpp | 64ac11ddcd0a125d2d1a758cf37fd97b5577e7ab | [] | no_license | hyunynim/Algorithm_Study | 58b56457e48471dfc3a6de2a758534babfffe4c0 | 1112a57ef95344b66f8313464f5fde428bb5bc3d | refs/heads/master | 2021-10-18T16:20:25.524826 | 2019-01-15T08:39:32 | 2019-01-15T08:39:32 | 125,656,431 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 645 | cpp | #include<cstdio>
bool room[123][123];
int main() {
char msg[123];
int n;
scanf("%d", &n);
for (int i = 0; i < n; ++i) {
scanf("%s", msg);
for (int j = 0; j < n; ++j) {
if (msg[j] == '.')
room[i][j] = 1;
else
room[i][j] = 0;
}
}
int ans[2] = { 0 };
for (int i = 0; i < n; ++i) {
int cnt = 0;
for (int j = 0; j < n; ++j) {
if (room[i][j])
++cnt;
else
cnt = 0;
if (cnt == 2)
++ans[0];
}
}
for (int i = 0; i < n; ++i) {
int cnt = 0;
for (int j = 0; j < n; ++j) {
if (room[j][i])
++cnt;
else
cnt = 0;
if (cnt == 2)
++ans[1];
}
}
printf("%d %d", ans[0], ans[1]);
} | [
"hyunynim1@naver.com"
] | hyunynim1@naver.com |
eadabd7778ef0e2c592fd23db4610bf5a0fc3873 | 297497957c531d81ba286bc91253fbbb78b4d8be | /third_party/libwebrtc/api/video/video_frame_type.h | bfb75931104b26a4ffec7a3a96ea66cb48deea33 | [
"LicenseRef-scancode-unknown-license-reference",
"BSD-3-Clause"
] | permissive | marco-c/gecko-dev-comments-removed | 7a9dd34045b07e6b22f0c636c0a836b9e639f9d3 | 61942784fb157763e65608e5a29b3729b0aa66fa | refs/heads/master | 2023-08-09T18:55:25.895853 | 2023-08-01T00:40:39 | 2023-08-01T00:40:39 | 211,297,481 | 0 | 0 | NOASSERTION | 2019-09-29T01:27:49 | 2019-09-27T10:44:24 | C++ | UTF-8 | C++ | false | false | 224 | h |
#ifndef API_VIDEO_VIDEO_FRAME_TYPE_H_
#define API_VIDEO_VIDEO_FRAME_TYPE_H_
namespace webrtc {
enum class VideoFrameType {
kEmptyFrame = 0,
kVideoFrameKey = 3,
kVideoFrameDelta = 4,
};
}
#endif
| [
"mcastelluccio@mozilla.com"
] | mcastelluccio@mozilla.com |
cc440d47e8584d0cd11a907c9c8085370fb7290a | ae15f88b3c6982ba672d6ec6e400c772d41a51a6 | /trideni.cpp | 02c0acd238e9a256589a1425acf346155ddfd886 | [] | no_license | fs-cvut-pia/sorting-lieskjur | 9ab8ff92a5049bfe161f873ccefc8c845b81fcf6 | e92e19addf1612f1d0bbb4d50eda639f33205831 | refs/heads/main | 2023-01-02T05:43:10.646152 | 2020-10-22T12:49:56 | 2020-10-22T12:49:56 | 304,311,776 | 0 | 0 | null | 2020-10-15T11:59:36 | 2020-10-15T11:59:27 | C++ | UTF-8 | C++ | false | false | 557 | cpp | #include "trideni.h"
#include <fstream>
#include <iostream>
void nacti(std::string nazev, seznam_slov &jmena){
/*
std::ifstream file
file.open(nazev.c_sttr());
*/
std::ifstream file(nazev);
std::string str;
while(std::getline(file,str)){
//getline stores characters from "file" into "str" until end-line
//(delimiter can be added)
jmena.push_back(str);
}
}
/*
void serad(seznam_slov &jmena){
}
bool zeptej_se_jestli_vypsat(){
}
*/
void vypis(seznam_slov &jmena){
for (int i=0;i<jmena.size();i++){
std::cout << jmena[i] << std::endl;
}
}
| [
"lieskovsky.juraj@gmail.com"
] | lieskovsky.juraj@gmail.com |
a5926339584d298736721c563131aa6924100f2d | 4c524689815694e7cec656221b92bda6a3bd9f07 | /network-lib/Networking/BaseServer.h | e77519b2ec9c6ccb66aa92c6292fb46657f6b653 | [] | no_license | Kitzunu/NovusCore-Common | fb6e121a83de81dc87d4ab78f29d4eaf79f72a78 | 102ca30c43bb5c06c9652be8aa19312107f427c8 | refs/heads/master | 2020-12-13T06:07:14.617567 | 2020-01-11T00:24:18 | 2020-01-11T00:24:18 | 234,331,603 | 0 | 0 | null | 2020-01-16T13:55:27 | 2020-01-16T13:55:26 | null | UTF-8 | C++ | false | false | 865 | h | #pragma once
#include <asio.hpp>
#include "Connection.h"
class BaseServer
{
public:
using tcp = asio::ip::tcp;
BaseServer(asio::io_service& ioService, i16 port, bool isInternal = false) : _ioService(ioService), _acceptor(ioService, tcp::endpoint(tcp::v4(), port)), _isRunning(false), _isInternal(isInternal)
{
_connections.reserve(4096);
}
void Start();
void Stop();
void Listen();
void Run();
void HandleNewConnection(tcp::socket* socket, const asio::error_code& error);
u16 GetPort() { return _acceptor.local_endpoint().port(); }
bool IsRunning() { return _isRunning; }
private:
asio::io_service& _ioService;
asio::ip::tcp::acceptor _acceptor;
std::mutex _mutex;
std::thread runThread;
bool _isRunning;
bool _isInternal;
std::vector<std::shared_ptr<Connection>> _connections;
}; | [
"nickiarpejensen@gmail.com"
] | nickiarpejensen@gmail.com |
a49fe94e9e82bb62f3207fc49702fbaa53870d34 | 3718003e41a009403996bdc5dde9e4ae1d5ea3e7 | /src/FloorPlan.cpp | 30359170241e06a702b4557f8318b919d9e3f4ba | [] | no_license | CS2303-JasonDykstra/CS2303_HW4 | de7779f29e89e4114bab2a3d5941dc150ee3be7b | e6dbc080125ef732bc6954b2440c77ebf0f644f9 | refs/heads/master | 2022-01-04T19:22:02.948810 | 2019-10-30T01:22:45 | 2019-10-30T01:22:45 | 218,416,508 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,260 | cpp | /*
* FloorPlan.cpp
*
* Created on: Sep 15, 2019
* Author: jasondykstra
*/
#include "FloorPlan.h"
FloorPlan::FloorPlan() {
// TODO Auto-generated constructor stub
Production prod;
edges = prod.readFile().floorPlan;
nRooms = prod.readFile().numRooms;
position = 0;
treasureFound = 0;
roomsVisited = 0;
rooms[0].wasVisited();
}
FloorPlan::~FloorPlan() {
// TODO Auto-generated destructor stub
}
void FloorPlan::listPossibleMoves(){
cout << "Currently in room: " << position << endl;
cout << "Possible moves include room(s): ";
for(int i = 0; i < nRooms; i++){
if(edges -> isEdge(position, i)){
cout << i << " ";
}
}
cout << endl;
}
void FloorPlan::moveRooms(){
int nextRoom = 0;
cout << "Which room would you like to move to?: ";
cin >> nextRoom;
//make sure its a possible move
bool legal = false;
for(int i = 0; i < nRooms; i++){
if(edges -> isEdge(position, nextRoom)){
legal = true;
}
}
//if user makes a legal move, go on with the program and move rooms
if(legal){
ofstream output;
output.open("output.txt", std::ios_base::app);
position = nextRoom;
if(!rooms[position].getVisited()){
treasureFound += rooms[position].treasure;
rooms[position].wasVisited();
roomsVisited++;
cout << "You found " << rooms[position].treasure << " treasure in this room!" << endl;
//also write to file
output << position << " " << treasureFound << endl;
} else {
cout << "No treasure found, you've already visited this room." << endl;
}
cout << "Total treasure so far: " << treasureFound << endl;
cout << "Total rooms visited: " << roomsVisited << endl;
output.close();
} else {
cout << "You can not move to this room, please pick a different room." << endl;
}
}
void FloorPlan::initRooms(){
//get contents of rooms.txt in an array, line by line
string data[20];
std::ifstream roomData("rooms.txt");
int counter = 0;
for(std::string line; getline(roomData, line);){
data[counter] = line;
counter++;
}
//interpret data
//start reading treasure amounts after the adj matrix
for(int i = 0; i < nRooms; i++){
rooms[i].setTreasure(stof(data[i + nRooms + 1]));
cout << "set room " << i << " to " << stof(data[i + nRooms + 1]) << " treasure" << endl;
}
}
| [
"jasondykstra2000@gmail.com"
] | jasondykstra2000@gmail.com |
3b504c28446f4b288ac084419291d155a16cd3d7 | d7b7dcec797f3294b1de671d1f84e354c93a1308 | /physx/source/simulationcontroller/src/ScSoftBodyShapeSim.h | f83a6ae8d2f3043c17d3ffdee50d32a5f44b3751 | [
"BSD-3-Clause"
] | permissive | NVIDIA-Omniverse/PhysX | c93ed4287a57d51fda56798b5fae8aaa65cdfa13 | e8c8deb2d548dc635db4f61083ea0e745c0102a0 | refs/heads/main | 2023-08-16T14:46:51.919670 | 2023-07-25T17:22:31 | 2023-07-25T17:22:31 | 545,381,143 | 1,814 | 216 | BSD-3-Clause | 2023-08-28T19:47:10 | 2022-10-04T09:07:32 | C++ | UTF-8 | C++ | false | false | 3,097 | h | // Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of NVIDIA CORPORATION nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved.
#ifndef SC_SOFTBODY_SHAPE_SIM_H
#define SC_SOFTBODY_SHAPE_SIM_H
#include "foundation/PxPreprocessor.h"
#if PX_SUPPORT_GPU_PHYSX
#include "PxPhysXConfig.h"
#include "ScElementSim.h"
#include "ScShapeSimBase.h"
namespace physx
{
namespace Sc
{
class SoftBodySim;
/**
A collision detection primitive for soft body.
*/
class SoftBodyShapeSim : public ShapeSimBase
{
PxTransform initialTransform;
PxReal initialScale;
SoftBodyShapeSim& operator=(const SoftBodyShapeSim &);
public:
SoftBodyShapeSim(SoftBodySim& softbody);
virtual ~SoftBodyShapeSim();
PX_FORCE_INLINE void setInitialTransform(const PxTransform& transform, PxReal scale)
{
initialTransform = transform;
initialScale = scale;
//The base class constructor ensures that getElementID() points to a valid entry in the bounds array
getScene().getBoundsArray().setBounds(getWorldBounds(), getElementID());
}
void attachShapeCore(const ShapeCore* core);
// ElementSim implementation
virtual void getFilterInfo(PxFilterObjectAttributes& filterAttr, PxFilterData& filterData) const;
// ~ElementSim
PxBounds3 getWorldBounds() const;
//PX_FORCE_INLINE SoftBodySim& getBodySim() const { return static_cast<SoftBodySim&>(getActor()); }
SoftBodySim& getBodySim() const;
void updateBounds();
void updateBoundsInAABBMgr();
PxBounds3 getBounds() const;
void createLowLevelVolume();
void destroyLowLevelVolume();
};
} // namespace Sc
}
#endif
#endif
| [
"preist@nvidia.com"
] | preist@nvidia.com |
b238c36faa27eec37944611502f3241cd2e3ce51 | c5fd4bba1511d494d78b254aea437a27bcb32ef0 | /includes/include/SAPHIRE/Saphire/Core/Threads/ICpuThread.h | 33f0a697ffe7f869b6e349fc8f0a0c75cb1e459a | [] | no_license | rastabaddon/saphire | f8f0a3e38ee54ff628dca9c846af2b2ab5a8b1b0 | 66c5ebcec446c5fd78c9fb3f30f5d6da53bf82ee | refs/heads/master | 2020-04-05T22:50:55.802570 | 2015-09-13T17:48:38 | 2015-09-13T17:48:38 | 32,226,790 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 369 | h | /*
* ICpuThread.h
*
* Created on: 6 wrz 2015
* Author: rast
*/
#ifndef INCLUDE_SAPHIRE_SAPHIRE_CORE_THREADS_ICPUTHREAD_H_
#define INCLUDE_SAPHIRE_SAPHIRE_CORE_THREADS_ICPUTHREAD_H_
namespace Saphire {
namespace Threads {
class ICpuThread : public Saphire::IBaseObject {
};
}
}
#endif /* INCLUDE_SAPHIRE_SAPHIRE_CORE_THREADS_ICPUTHREAD_H_ */
| [
"rafal.klimaszewski@gmail.com"
] | rafal.klimaszewski@gmail.com |
39d9f2a7d1b168810f18cce8e3407949523b919f | 7dc5f20c674d1a53edf17f0dc0471b2087e6ab31 | /graph/s2v_mvc/mvc_lib/src/lib/mvc_env.cpp | 02d6df40b08cc83bcf004df07e5941d8ad0cb42f | [
"MIT"
] | permissive | NH333/MICCAI2020 | a3fada7d1cbd964562e7c6456ad1710829d4347b | 54f7ab1e0218a18b624899a6480b43f150da99e1 | refs/heads/master | 2022-05-24T10:58:01.108026 | 2020-04-25T14:52:46 | 2020-04-25T14:52:46 | 252,101,859 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,000 | cpp | #include "mvc_env.h"
#include "graph.h"
//#include <mkl.h>
#include <cassert>
#include <random>
#include <algorithm>
#include <vector>
MvcEnv::MvcEnv(double _norm) : IEnv(_norm)
{
}
void MvcEnv::s0(std::shared_ptr<Graph> _g)
{
graph = _g;
covered_set.clear();
action_list.clear();
sumEigenValues = 0;
//numCoveredEdges = 0;
state_seq.clear();
act_seq.clear();
reward_seq.clear();
sum_rewards.clear();
}
double MvcEnv::step(int a)
{
assert(graph);
assert(covered_set.count(a) == 0);
state_seq.push_back(action_list);
act_seq.push_back(a);
covered_set.insert(a);
action_list.push_back(a);
/*对加入的a,在矩阵中a行a列置零,求特征值*/
MatrixXd tmp_W = graph->adj_Matrix;
MatrixXd D;
MatrixXd L;
MatrixXd tmp_;
MatrixXd eigenVal;
std::vector<double> eigen_values;
double old_sumEigenValues = sumEigenValues;
eigen_values.clear();
D.setZero(148, 148);
L.setZero(148, 148);
tmp_.setZero(148,1);
for(auto covered:covered_set){
for(int i=0;i<148;++i){
tmp_W(i,covered) = 0;
tmp_W(covered,i) = 0;
}
}
for(int i=0;i<148;++i){
tmp_W(i,a) = 0;
tmp_W(a,i) = 0;
}
tmp_ = tmp_W.rowwise().sum();
for (int i = 0; i < 148; ++i) {
D(i, i) = tmp_(i,0);
}
L = D - tmp_W;
eigenVal = L.eigenvalues().real();
for (int i = 0; i < 148; ++i) {
eigen_values.push_back(eigenVal(i, 0));
}
std::sort(eigen_values.begin(),eigen_values.end());
sumEigenValues = 0;
for(int i=0;i<148;++i){
sumEigenValues += eigen_values[i];
}
// for (auto& neigh : graph->adj_list[a])
// if (covered_set.count(neigh) == 0)
// numCoveredEdges++;
double r_t = getReward(old_sumEigenValues);
reward_seq.push_back(r_t);
sum_rewards.push_back(r_t);
return r_t;
}
int MvcEnv::randomAction()
{
assert(graph);
avail_list.clear();
for (int i = 0; i < graph->num_nodes; ++i)
if (covered_set.count(i) == 0)
avail_list.push_back(i);
// for (int i = 0; i < graph->num_nodes; ++i)
// if (covered_set.count(i) == 0)
// {
// bool useful = false;
// for (auto& neigh : graph->adj_list[i])
// if (covered_set.count(neigh) == 0)
// {
// useful = true;
// break;
// }
// if (useful)
// avail_list.push_back(i);
// }
assert(avail_list.size());
int idx = rand() % avail_list.size();
return avail_list[idx];
}
bool MvcEnv::isTerminal()
{
assert(graph);
return((int)covered_set.size()==8);
//return graph->num_edges == numCoveredEdges;
}
double MvcEnv::getReward(double old_sumEigenValues)
{
//return -1.0 / norm;
//return -(sumEigenValues-old_sumEigenValues) / 34.0;
return -(sumEigenValues-old_sumEigenValues)/148.0;
}
| [
"842414969@qq.com"
] | 842414969@qq.com |
e6de7dcc394f0c6ca443872d74bfb903d7804d1b | e4ffd15e9cf875638883615256bc333404b3f248 | /common_anagrams/main.cpp | ef251524c01225d0e9935ab73e0a07c8bd1590e8 | [] | no_license | Thomas-McKanna/Kattis | a49938663b4cc168eb7c51cd85f9d3d6a116c22c | 0477ee7d39f694e98ca033dd32151cde11e7a9b1 | refs/heads/master | 2021-06-18T13:37:48.920524 | 2021-01-19T23:37:28 | 2021-01-19T23:37:28 | 149,032,585 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,649 | cpp | #include <iostream>
#include <string>
#include <algorithm>
using std::cout;
using std::cin;
using std::endl;
using std::string;
int main() {
int t;
cin >> t;
int len;
string a, b;
for (int it = 0; it < t; it++) {
cin >> len;
cin >> a >> b;
/*
int a_letters[26] = {0};
int b_letters[26] = {0};
for (int i = 0; i < len; i++) {
(a_letters[a[i] - 'A'])++;
(b_letters[b[i] - 'A'])++;
}
cout << "A:" << endl;
for (int i = 0; i < 26; i++) {
cout << char('A' + i) << ": " << a_letters[i] << endl;
}
cout << "A:" << endl;
for (int i = 0; i < 26; i++) {
cout << char('A' + i) << ": " << b_letters[i] << endl;
}
int ans = 0;
int shift_count = len;
bool flag;
for (int i = 1; i <= len; i++) {
// shift over len / i times
for (int j = 0; j < shift_count; j++) {
flag = true;
for (int k = 0; k < i; k++) {
if (a_letters[k + j] != b_letters[k + j]) {
flag = false;
break;
}
}
if (flag) {
ans++;
shift_count--;
continue;
}
}
shift_count--;
}
cout << "Case #" << it + 1 << ": " << ans << endl;
*/
std::sort(a.begin(), a.end());
std::sort(b.begin(), b.end());
cout << a << endl;
cout << b << endl;
}
return 0;
}
| [
"thomasmckanna@gmail.com"
] | thomasmckanna@gmail.com |
ddde5b922741888271841c2b06a1c1257528f587 | 98b4a64748a1b1a3d38478b0ae4966550ec6b998 | /planet.h | 715a387529b5e1cc6d385e912d97393347fc3201 | [] | no_license | He370/Spaceship-VR | 5f39b4bc876a94b2ddc2e061285e5fb2551537e3 | 0c640626db7c4182e18e39431ee856859a2c7f80 | refs/heads/master | 2021-01-20T08:00:17.242942 | 2017-08-31T21:37:05 | 2017-08-31T21:37:05 | 90,075,572 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 1,160 | h | #pragma once
#include <GL/glew.h>
#include <GL/freeglut.h>
#include <GL/gl.h>
#include <GL/glext.h>
#include <glm/glm.hpp>
#include <glm/gtc/matrix_transform.hpp>
#include <glm/gtx/transform.hpp>
#include <glm/gtc/type_ptr.hpp>
#include <iostream>
#include "LoadMesh.h"
#include "LoadTexture.h"
using namespace std;
class Planet
{
//const std::string mesh_name = "planet.obj";
//const std::string texture_name = "earthSurface.jpg";
//const std::string texture_02_name = "earthLights.jpg";
//const std::string texture_name = "yavin.jpg";
//parameters
float p_pos_x = 4.242f;
float p_pos_y = 4.398f;
float p_pos_z = -18.0f;
float p_scale = 19.0f;
float p_angle = 0;
public:
MeshData mesh;
GLuint texture_planet = -1;
GLuint texture_02_planet = -1;
void init(std::string mesh_name, std::string texture_name, std::string texture_02_name);
void setScale(float scale) { p_scale = scale; }
void setPosition(float x, float y, float z) { p_pos_x = x; p_pos_y = y; p_pos_z = z; };
void draw(glm::mat4 PV, glm::mat4 M0);
void drawDebugUI();
glm::vec3 getPosVec3() { return glm::vec3(p_pos_x, p_pos_y, p_pos_z); }
Planet();
~Planet();
};
| [
"ldh.sjtu@gmail.com"
] | ldh.sjtu@gmail.com |
2f75bdaa2e703c48fa08692884f5c82f1b536a07 | 6d1d231061dbc0d685cce462f0c25d508bb8e395 | /EyeScreen/win95/src/ActionObject014.h | 73eeaa103a186b6e94fb5cdadac76bbe25722634 | [] | no_license | freegroup/ScreenSaver | cae66f67c48ba56e625794e0246920312d5a442a | 94cb5b4377307711f87075e9817c0e001b6abdfa | refs/heads/master | 2021-01-10T11:08:03.527540 | 2015-05-24T13:44:27 | 2015-05-24T13:47:26 | 36,174,206 | 1 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 750 | h | /**
* Title: EyeScreen
* Description: Simple ScreenSaver for windows
* Copyright: Copyright (c) 2001
* Company: FreeGroup (www.FreeGroup.de)
* Author: Andreas Herz (a.herz@FreeGroup.de)
* Version: 1.0
*/
#if !defined(AFX_ACTIONOBJECT014_H__41D3D47D_D1C4_11D4_A669_00104B59BDBD__INCLUDED_)
#define AFX_ACTIONOBJECT014_H__41D3D47D_D1C4_11D4_A669_00104B59BDBD__INCLUDED_
#include "ActionObject.h"
class ActionObject014 : public ActionObject
{
public:
ActionObject014(int screenWidth, int screenHeight, QPoint startPos);
virtual ActionObject* getSuccessor(bool objectVisible);
protected:
};
#endif // !defined(AFX_ACTIONOBJECT014_H__41D3D47D_D1C4_11D4_A669_00104B59BDBD__INCLUDED_)
| [
"a.herz@freegroup.de"
] | a.herz@freegroup.de |
8f8b94c91733d3bbe4ac31714f0bf2cf50617647 | 86bf5ce19538b120467b2674324b44ac79854e2b | /src/types/dictionarytrajectory.cpp | 4d7eefcb8018d6164c45810798aafbafa5cf8e66 | [] | no_license | squirrel-project/kukadu | 2294b56e55a9577e5847e3c76330abf12a5673c0 | 530054db8c409fdef97ed3927e55d63b0cb8f152 | refs/heads/master | 2021-01-18T02:48:59.742813 | 2017-03-25T17:54:39 | 2017-03-25T17:54:39 | 53,591,719 | 0 | 8 | null | 2017-03-25T17:54:40 | 2016-03-10T14:40:04 | C++ | UTF-8 | C++ | false | false | 7,435 | cpp | #include <kukadu/types/dictionarytrajectory.hpp>
using namespace std;
using namespace arma;
namespace kukadu {
DictionaryTrajectory::DictionaryTrajectory(std::string baseFolder, double az, double bz) : Trajectory() {
this->baseFolder = baseFolder;
vector<string> files = getFilesInDirectory(baseFolder);
queryFiles = sortPrefix(files, "query");
trajFiles = sortPrefix(files, "traj");
dmpFiles = sortPrefix(files, "dmp");
if(dmpFiles.size() == 0) {
// learn dmps
queryPoints = mapFiles(queryFiles, trajFiles, "query", "traj");
KUKADU_SHARED_PTR<JointDMPLearner> dmpLearner;
vector<mat> jointsVec;
double tMax = 0.0;
for(int i = 0; i < queryPoints.size(); ++i) {
mat joints = readMovements((string(baseFolder) + string(queryPoints.at(i).getFileDataPath())).c_str());
degOfFreedom = joints.n_cols - 1;
queryPoints.at(i).setQueryPoint(readQuery(string(baseFolder) + string(queryPoints.at(i).getFileQueryPath())));
jointsVec.push_back(joints);
double currentTMax = joints(joints.n_rows - 1, 0);
if(tMax < currentTMax)
tMax = currentTMax;
}
for(int i = 0; i < jointsVec.size(); ++i) {
QueryPoint currentQueryPoint = queryPoints.at(i);
mat joints = jointsVec.at(i);
joints = fillTrajectoryMatrix(joints, tMax);
dmpLearner = KUKADU_SHARED_PTR<JointDMPLearner>(new JointDMPLearner(az, bz, joints));
KUKADU_SHARED_PTR<Dmp> learnedDmps = dmpLearner->fitTrajectories();
learnedDmps->serialize(baseFolder + currentQueryPoint.getFileDmpPath());
queryPoints.at(i).setDmp(learnedDmps);
startingPos = queryPoints.at(i).getDmp()->getY0();
cout << "(DMPGeneralizer) goals for query point [" << currentQueryPoint.getQueryPoint().t() << "]" << endl << "\t [";
cout << currentQueryPoint.getDmp()->getG().t() << "]" << endl;
//delete dmpLearner;
dmpLearner = KUKADU_SHARED_PTR<JointDMPLearner>();
}
} else {
queryPoints = mapFiles(queryFiles, trajFiles, dmpFiles, "query", "traj", "dmp");
}
degOfFreedom = queryPoints.at(0).getDmp()->getDegreesOfFreedom();
}
std::vector<arma::vec> DictionaryTrajectory::getCoefficients() {
return coefficients;
}
void DictionaryTrajectory::setCoefficients(std::vector<arma::vec> coeffs) {
coefficients = coeffs;
}
DictionaryTrajectory::DictionaryTrajectory(const DictionaryTrajectory& copy) : Trajectory(copy) {
this->degOfFreedom = copy.degOfFreedom;
this->baseFolder = copy.baseFolder;
this->files = copy.files;
this->queryFiles = copy.queryFiles;
this->trajFiles = copy.trajFiles;
this->queryPoints = copy.queryPoints;
this->startingPos = copy.startingPos;
}
DictionaryTrajectory::DictionaryTrajectory() {
}
int DictionaryTrajectory::getDegreesOfFreedom() const {
return degOfFreedom;
}
// TODO: implement == operator
int DictionaryTrajectory::operator==(DictionaryTrajectory const& comp) const {
string errStr = "(DictionaryTrajectory) == operator not implemted yet";
cerr << errStr << endl;
throw KukaduException(errStr.c_str());
}
vector<QueryPoint> DictionaryTrajectory::mapFiles(vector<string> queryFiles, vector<string> trajFiles, string prefix1, string prefix2) {
vector<QueryPoint> ret;
int prefix1Size = prefix1.size();
int prefix2Size = prefix2.size();
int querySize = queryFiles.size();
int trajSize = trajFiles.size();
for(int i = 0; i < querySize; ++i) {
string currentQueryFile = string(queryFiles.at(i));
string queryAppendix = currentQueryFile.substr(prefix1Size, currentQueryFile.size() - 1);
for(int j = 0; j < trajSize; ++j) {
string currentTrajFile = string(trajFiles.at(j));
string trajAppendix = currentTrajFile.substr(prefix2Size, currentTrajFile.size() - 1);
if(!queryAppendix.compare(trajAppendix)) {
QueryPoint toAdd(queryFiles.at(i), trajFiles.at(j), string("dmp") + trajAppendix, KUKADU_SHARED_PTR<Dmp>(new JointDmp()), vec());
ret.push_back(toAdd);
if(i == 0)
startingPos = toAdd.getDmp()->getY0();
}
}
}
return ret;
}
vector<QueryPoint> DictionaryTrajectory::mapFiles(vector<string> queryFiles, vector<string> trajFiles, vector<string> dmpFiles, string prefix1, string prefix2, string prefix3) {
vector<QueryPoint> ret;
int prefix1Size = prefix1.size();
int prefix2Size = prefix2.size();
int prefix3Size = prefix3.size();
int querySize = queryFiles.size();
int trajSize = trajFiles.size();
int dmpSize = dmpFiles.size();
for(int i = 0; i < querySize; ++i) {
string currentQueryFile = string(queryFiles.at(i));
string queryAppendix = currentQueryFile.substr(prefix1Size, currentQueryFile.size() - 1);
for(int j = 0; j < trajSize; ++j) {
string currentTrajFile = string(trajFiles.at(j));
string trajAppendix = currentTrajFile.substr(prefix2Size, currentTrajFile.size() - 1);
if(!queryAppendix.compare(trajAppendix)) {
for(int k = 0; k < dmpSize; ++k) {
string currentDmpFile = string(dmpFiles.at(k));
string dmpAppendix = currentDmpFile.substr(prefix3Size, currentDmpFile.size() - 1);
if(!dmpAppendix.compare(queryAppendix)) {
// load dmp from file
QueryPoint toAdd(queryFiles.at(i), trajFiles.at(j), prefix3 + trajAppendix, KUKADU_SHARED_PTR<Dmp>(new JointDmp(baseFolder + prefix3 + trajAppendix)), vec());
toAdd.setQueryPoint(readQuery(string(baseFolder) + string(toAdd.getFileQueryPath())));
ret.push_back(toAdd);
if(i == 0)
startingPos = toAdd.getDmp()->getY0();
}
}
}
}
}
return ret;
}
void DictionaryTrajectory::setTmax(double tmax) {
for(int i = 0; i < queryPoints.size(); ++i)
queryPoints.at(i).getDmp()->setTmax(tmax);
}
double DictionaryTrajectory::getTmax() {
return queryPoints.at(0).getDmp()->getTmax();
}
std::vector<QueryPoint> DictionaryTrajectory::getQueryPoints() {
return queryPoints;
}
arma::vec DictionaryTrajectory::getStartingPos() {
string errStr = "(DictionaryTrajectory) no starting position set yet";
if(startingPos.n_elem > 0)
return startingPos;
cerr << errStr << endl;
throw errStr;
}
KUKADU_SHARED_PTR<Trajectory> DictionaryTrajectory::copy() {
return KUKADU_SHARED_PTR<Trajectory>(new DictionaryTrajectory(*this));
}
}
| [
"simon.hangl@uibk.ac.at"
] | simon.hangl@uibk.ac.at |
d5be319fd8bff36a8dff3965314810c2aad4973c | 71f4c55fccac2be0c5c4dbdcf1b7d069458c3af1 | /langdetectpp/src/profiles/langs/zh_cn.cpp | d260fc877a8b24fcd9b615c80291701dc93c64dc | [
"Apache-2.0"
] | permissive | IMelker/langdetectpp | a334717cfa8fe08124add6c06cdbd26edd7f3005 | d6da1b16272a89f486d0334141e1e55c12ca4a22 | refs/heads/master | 2023-04-08T21:48:55.032461 | 2021-04-02T23:59:33 | 2021-04-02T23:59:33 | 353,118,296 | 3 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 102,786 | cpp | #include "profiles/langs/zh_cn.h"
#include <unordered_map>
#include <tuple>
static const std::unordered_map<uint32_t, size_t> zh_cn_one_grams {
{ 65292, 211761 },
{ 19976, 146015 },
{ 30340, 145656 },
{ 19969, 117148 },
{ 12290, 93258 },
{ 12289, 80590 },
{ 19981, 69712 },
{ 26159, 61140 },
{ 20351, 59599 },
{ 65288, 53630 },
{ 65289, 53342 },
{ 19968, 51232 },
{ 22269, 50445 },
{ 20241, 48239 },
{ 24180, 47488 },
{ 20013, 47239 },
{ 20122, 46408 },
{ 20026, 43069 },
{ 20110, 42781 },
{ 20154, 38353 },
{ 22312, 35727 },
{ 22823, 34268 },
{ 23478, 33525 },
{ 23398, 28915 },
{ 20056, 28571 },
{ 22320, 26817 },
{ 23567, 25275 },
{ 26377, 24992 },
{ 21644, 23304 },
{ 20197, 21926 },
{ 20309, 21331 },
{ 26085, 21151 },
{ 20132, 20817 },
{ 21517, 20347 },
{ 20010, 19411 },
{ 20107, 19248 },
{ 29983, 19204 },
{ 21306, 18524 },
{ 21450, 17913 },
{ 20081, 17692 },
{ 35199, 17559 },
{ 30001, 17497 },
{ 20043, 17358 },
{ 20844, 17034 },
{ 31216, 17001 },
{ 20250, 16875 },
{ 25104, 16718 },
{ 65306, 15751 },
{ 26376, 15728 },
{ 20027, 15497 },
{ 19978, 15305 },
{ 21335, 15302 },
{ 20998, 15267 },
{ 19989, 15196 },
{ 25991, 14966 },
{ 34892, 14959 },
{ 20316, 14815 },
{ 26102, 14785 },
{ 20221, 14596 },
{ 37096, 14531 },
{ 19982, 14330 },
{ 26031, 13962 },
{ 29289, 13958 },
{ 29992, 13911 },
{ 26412, 13564 },
{ 20301, 13424 },
{ 21488, 13293 },
{ 12298, 12801 },
{ 21457, 12789 },
{ 12299, 12787 },
{ 19996, 12690 },
{ 23665, 12651 },
{ 38271, 12428 },
{ 31561, 12322 },
{ 20854, 12214 },
{ 21518, 12165 },
{ 183, 11798 },
{ 25152, 11521 },
{ 31532, 11099 },
{ 22810, 11036 },
{ 25110, 10994 },
{ 27665, 10950 },
{ 28207, 10900 },
{ 21069, 10878 },
{ 30005, 10706 },
{ 20195, 10675 },
{ 32654, 10457 },
{ 31185, 10282 },
{ 26368, 10271 },
{ 21160, 10155 },
{ 23646, 10137 },
{ 29305, 10095 },
{ 33267, 9855 },
{ 19998, 9778 },
{ 36335, 9754 },
{ 31859, 9738 },
{ 33521, 9686 },
{ 31435, 9651 },
{ 23376, 9623 },
{ 29702, 9553 },
{ 25945, 9551 },
{ 26469, 9550 },
{ 39321, 9519 },
{ 32780, 9496 },
{ 30446, 9318 },
{ 24037, 9317 },
{ 19990, 9256 },
{ 39640, 8988 },
{ 24314, 8867 },
{ 33258, 8792 },
{ 32463, 8789 },
{ 21033, 8681 },
{ 20102, 8577 },
{ 21516, 8476 },
{ 29616, 8430 },
{ 28286, 8336 },
{ 24503, 8327 },
{ 35201, 8323 },
{ 38388, 8313 },
{ 31995, 8292 },
{ 20869, 8287 },
{ 20063, 8266 },
{ 37324, 8179 },
{ 19994, 8072 },
{ 20307, 8040 },
{ 19979, 7962 },
{ 26426, 7949 },
{ 19977, 7927 },
{ 34987, 7905 },
{ 20449, 7840 },
{ 21512, 7745 },
{ 21487, 7699 },
{ 24191, 7680 },
{ 20811, 7641 },
{ 36890, 7604 },
{ 32447, 7551 },
{ 24067, 7549 },
{ 24030, 7529 },
{ 20182, 7464 },
{ 21270, 7453 },
{ 32773, 7418 },
{ 24182, 7400 },
{ 23545, 7380 },
{ 20840, 7377 },
{ 24320, 7255 },
{ 21152, 7203 },
{ 21592, 7153 },
{ 21496, 7147 },
{ 20891, 7136 },
{ 20849, 7134 },
{ 25968, 7124 },
{ 25289, 7109 },
{ 39532, 7083 },
{ 26399, 7068 },
{ 26519, 7036 },
{ 21046, 7035 },
{ 22825, 7035 },
{ 29699, 6996 },
{ 36825, 6952 },
{ 24335, 6888 },
{ 21326, 6868 },
{ 24230, 6769 },
{ 21407, 6718 },
{ 27515, 6678 },
{ 25112, 6655 },
{ 32479, 6645 },
{ 22522, 6619 },
{ 30028, 6597 },
{ 36710, 6585 },
{ 38754, 6531 },
{ 32599, 6436 },
{ 36816, 6417 },
{ 20108, 6378 },
{ 21040, 6365 },
{ 36807, 6354 },
{ 23450, 6314 },
{ 35774, 6237 },
{ 22240, 6183 },
{ 24120, 6171 },
{ 32852, 6161 },
{ 31449, 6147 },
{ 36187, 5990 },
{ 24179, 5989 },
{ 22235, 5911 },
{ 25351, 5889 },
{ 27743, 5857 },
{ 22806, 5857 },
{ 65307, 5849 },
{ 22330, 5846 },
{ 32452, 5795 },
{ 32422, 5717 },
{ 37329, 5677 },
{ 33021, 5645 },
{ 21495, 5641 },
{ 37325, 5583 },
{ 20219, 5559 },
{ 20848, 5551 },
{ 24635, 5550 },
{ 38470, 5534 },
{ 27827, 5488 },
{ 34920, 5479 },
{ 27492, 5466 },
{ 35745, 5438 },
{ 20135, 5405 },
{ 27700, 5383 },
{ 21439, 5347 },
{ 21313, 5342 },
{ 21448, 5333 },
{ 29579, 5331 },
{ 22478, 5315 },
{ 20048, 5294 },
{ 27954, 5289 },
{ 24403, 5254 },
{ 24052, 5253 },
{ 30465, 5247 },
{ 21153, 5246 },
{ 37117, 5243 },
{ 36827, 5216 },
{ 23612, 5208 },
{ 26893, 5185 },
{ 23433, 5174 },
{ 38498, 5166 },
{ 31867, 5149 },
{ 27835, 5001 },
{ 22768, 4998 },
{ 23707, 4996 },
{ 21147, 4944 },
{ 24471, 4936 },
{ 27425, 4906 },
{ 24341, 4831 },
{ 21253, 4823 },
{ 38899, 4816 },
{ 27604, 4805 },
{ 20004, 4794 },
{ 20041, 4779 },
{ 20851, 4776 },
{ 35813, 4765 },
{ 38376, 4685 },
{ 20256, 4668 },
{ 38081, 4586 },
{ 23427, 4574 },
{ 31243, 4573 },
{ 35270, 4552 },
{ 27969, 4509 },
{ 38463, 4439 },
{ 20837, 4429 },
{ 21475, 4422 },
{ 31038, 4420 },
{ 20070, 4419 },
{ 24433, 4410 },
{ 21697, 4389 },
{ 22242, 4373 },
{ 26143, 4368 },
{ 26415, 4302 },
{ 31616, 4298 },
{ 36215, 4293 },
{ 38469, 4272 },
{ 21019, 4231 },
{ 23558, 4225 },
{ 26410, 4221 },
{ 25552, 4221 },
{ 36798, 4214 },
{ 20294, 4207 },
{ 20803, 4144 },
{ 36164, 4130 },
{ 22788, 4116 },
{ 32426, 4115 },
{ 27491, 4102 },
{ 32593, 4079 },
{ 24418, 4076 },
{ 32423, 4065 },
{ 23454, 4032 },
{ 21382, 4017 },
{ 33609, 3994 },
{ 38431, 3990 },
{ 35828, 3972 },
{ 22914, 3936 },
{ 40857, 3881 },
{ 28246, 3858 },
{ 31354, 3846 },
{ 26397, 3840 },
{ 37327, 3834 },
{ 20174, 3822 },
{ 23637, 3788 },
{ 25509, 3776 },
{ 26063, 3701 },
{ 22899, 3642 },
{ 28436, 3628 },
{ 21830, 3626 },
{ 32500, 3625 },
{ 28216, 3622 },
{ 21508, 3613 },
{ 26657, 3605 },
{ 33394, 3575 },
{ 21035, 3560 },
{ 25300, 3550 },
{ 23578, 3502 },
{ 24212, 3484 },
{ 22521, 3476 },
{ 31070, 3463 },
{ 28857, 3443 },
{ 20116, 3431 },
{ 26080, 3416 },
{ 25324, 3402 },
{ 22885, 3388 },
{ 20445, 3387 },
{ 26465, 3385 },
{ 35770, 3372 },
{ 38750, 3368 },
{ 30707, 3358 },
{ 22987, 3351 },
{ 26500, 3349 },
{ 26631, 3335 },
{ 20140, 3333 },
{ 31119, 3324 },
{ 19987, 3303 },
{ 26366, 3299 },
{ 22120, 3296 },
{ 25163, 3277 },
{ 22826, 3274 },
{ 21360, 3243 },
{ 35793, 3205 },
{ 21017, 3203 },
{ 25913, 3194 },
{ 36873, 3181 },
{ 21345, 3152 },
{ 21095, 3129 },
{ 33487, 3117 },
{ 33457, 3115 },
{ 36817, 3105 },
{ 20030, 3076 },
{ 21521, 3047 },
{ 35758, 3045 },
{ 28304, 3031 },
{ 24029, 3028 },
{ 25454, 3024 },
{ 21333, 3024 },
{ 35282, 3015 },
{ 24050, 3013 },
{ 32467, 3008 },
{ 30452, 3003 },
{ 33879, 2998 },
{ 26685, 2997 },
{ 23548, 2989 },
{ 35328, 2970 },
{ 32946, 2953 },
{ 36896, 2929 },
{ 39046, 2926 },
{ 31350, 2923 },
{ 20809, 2911 },
{ 23601, 2894 },
{ 25903, 2892 },
{ 21442, 2872 },
{ 36523, 2869 },
{ 21363, 2844 },
{ 20170, 2840 },
{ 27963, 2831 },
{ 21150, 2818 },
{ 36830, 2790 },
{ 36793, 2785 },
{ 22270, 2777 },
{ 26435, 2775 },
{ 22253, 2775 },
{ 21464, 2770 },
{ 19975, 2760 },
{ 27431, 2758 },
{ 20123, 2757 },
{ 35748, 2753 },
{ 36275, 2749 },
{ 26354, 2749 },
{ 20134, 2742 },
{ 27874, 2738 },
{ 20113, 2725 },
{ 25216, 2723 },
{ 26222, 2707 },
{ 22369, 2693 },
{ 36136, 2689 },
{ 28982, 2677 },
{ 25103, 2673 },
{ 24093, 2672 },
{ 24072, 2671 },
{ 22307, 2664 },
{ 21327, 2640 },
{ 26381, 2639 },
{ 28165, 2634 },
{ 27721, 2630 },
{ 25253, 2620 },
{ 22495, 2609 },
{ 24231, 2603 },
{ 32534, 2591 },
{ 33324, 2569 },
{ 20889, 2568 },
{ 23384, 2538 },
{ 24102, 2534 },
{ 32435, 2534 },
{ 33829, 2531 },
{ 30333, 2529 },
{ 29255, 2527 },
{ 20061, 2519 },
{ 21463, 2511 },
{ 39118, 2500 },
{ 25773, 2492 },
{ 20271, 2492 },
{ 21453, 2487 },
{ 20855, 2485 },
{ 23616, 2483 },
{ 21462, 2479 },
{ 30011, 2451 },
{ 23569, 2443 },
{ 29615, 2438 },
{ 22996, 2437 },
{ 20204, 2426 },
{ 27468, 2416 },
{ 20826, 2412 },
{ 33410, 2402 },
{ 38738, 2398 },
{ 21021, 2398 },
{ 38480, 2379 },
{ 39033, 2377 },
{ 39302, 2371 },
{ 38215, 2371 },
{ 27801, 2368 },
{ 35760, 2357 },
{ 20234, 2356 },
{ 22836, 2350 },
{ 20105, 2347 },
{ 21629, 2331 },
{ 24076, 2317 },
{ 33322, 2316 },
{ 22827, 2315 },
{ 35266, 2303 },
{ 35299, 2300 },
{ 40644, 2293 },
{ 22870, 2274 },
{ 23458, 2272 },
{ 33402, 2269 },
{ 31215, 2267 },
{ 22659, 2254 },
{ 27982, 2241 },
{ 26681, 2240 },
{ 35268, 2234 },
{ 34903, 2230 },
{ 12354, 2229 },
{ 32676, 2218 },
{ 20420, 2213 },
{ 27494, 2208 },
{ 30343, 2205 },
{ 20379, 2204 },
{ 26524, 2196 },
{ 32455, 2183 },
{ 21513, 2174 },
{ 35265, 2171 },
{ 28595, 2170 },
{ 29233, 2167 },
{ 36895, 2166 },
{ 25918, 2159 },
{ 25512, 2158 },
{ 32844, 2157 },
{ 24352, 2153 },
{ 30693, 2149 },
{ 22303, 2149 },
{ 26089, 2138 },
{ 12450, 2133 },
{ 25345, 2131 },
{ 23041, 2129 },
{ 21482, 2126 },
{ 20845, 2119 },
{ 36234, 2100 },
{ 20808, 2098 },
{ 26356, 2085 },
{ 23447, 2085 },
{ 38451, 2041 },
{ 21322, 2037 },
{ 36739, 2013 },
{ 35789, 2012 },
{ 21608, 2010 },
{ 33719, 2004 },
{ 39064, 1997 },
{ 30000, 1994 },
{ 31639, 1987 },
{ 25910, 1975 },
{ 27668, 1964 },
{ 24773, 1949 },
{ 23621, 1947 },
{ 20843, 1932 },
{ 21307, 1928 },
{ 36716, 1925 },
{ 27966, 1913 },
{ 36229, 1907 },
{ 25925, 1906 },
{ 40657, 1900 },
{ 26131, 1898 },
{ 20262, 1894 },
{ 35937, 1888 },
{ 26408, 1876 },
{ 35805, 1875 },
{ 33832, 1866 },
{ 30334, 1846 },
{ 35895, 1826 },
{ 29420, 1820 },
{ 28779, 1816 },
{ 20065, 1808 },
{ 20852, 1795 },
{ 21338, 1783 },
{ 22260, 1767 },
{ 32622, 1765 },
{ 23494, 1755 },
{ 29677, 1750 },
{ 27597, 1743 },
{ 35768, 1740 },
{ 26449, 1739 },
{ 24459, 1732 },
{ 20915, 1729 },
{ 32418, 1720 },
{ 24565, 1709 },
{ 24405, 1700 },
{ 22797, 1700 },
{ 27004, 1695 },
{ 19971, 1693 },
{ 21733, 1688 },
{ 25237, 1684 },
{ 26009, 1677 },
{ 25252, 1665 },
{ 36719, 1659 },
{ 35834, 1644 },
{ 36149, 1643 },
{ 21355, 1639 },
{ 30528, 1639 },
{ 21214, 1639 },
{ 26696, 1633 },
{ 23425, 1619 },
{ 24378, 1613 },
{ 36824, 1606 },
{ 23618, 1590 },
{ 26597, 1580 },
{ 26446, 1577 },
{ 38500, 1569 },
{ 20987, 1569 },
{ 24448, 1560 },
{ 24178, 1556 },
{ 31163, 1553 },
{ 31034, 1536 },
{ 21452, 1530 },
{ 32032, 1524 },
{ 40065, 1516 },
{ 23626, 1515 },
{ 35777, 1510 },
{ 25972, 1497 },
{ 35843, 1492 },
{ 35759, 1488 },
{ 33853, 1487 },
{ 28909, 1483 },
{ 27809, 1471 },
{ 24211, 1470 },
{ 32476, 1469 },
{ 40092, 1464 },
{ 24577, 1462 },
{ 36758, 1462 },
{ 26497, 1459 },
{ 29366, 1446 },
{ 38382, 1446 },
{ 39134, 1436 },
{ 23736, 1431 },
{ 21547, 1431 },
{ 24215, 1431 },
{ 28145, 1422 },
{ 38134, 1422 },
{ 20247, 1421 },
{ 32493, 1408 },
{ 21161, 1407 },
{ 36153, 1407 },
{ 21709, 1404 },
{ 36733, 1404 },
{ 25171, 1400 },
{ 20146, 1398 },
{ 26679, 1395 },
{ 22238, 1392 },
{ 27979, 1385 },
{ 65293, 1381 },
{ 26680, 1380 },
{ 39135, 1377 },
{ 30721, 1376 },
{ 36753, 1374 },
{ 26725, 1371 },
{ 19995, 1367 },
{ 39039, 1362 },
{ 29976, 1358 },
{ 38395, 1352 },
{ 36125, 1346 },
{ 30149, 1344 },
{ 26053, 1334 },
{ 33713, 1327 },
{ 22830, 1321 },
{ 36828, 1319 },
{ 33268, 1313 },
{ 22374, 1302 },
{ 25143, 1297 },
{ 26045, 1293 },
{ 33041, 1283 },
{ 26434, 1265 },
{ 23500, 1265 },
{ 32929, 1262 },
{ 22791, 1259 },
{ 32454, 1259 },
{ 22909, 1250 },
{ 20303, 1250 },
{ 20028, 1241 },
{ 32034, 1233 },
{ 21315, 1226 },
{ 24109, 1225 },
{ 25490, 1222 },
{ 20877, 1221 },
{ 20044, 1217 },
{ 38472, 1215 },
{ 24687, 1214 },
{ 25511, 1211 },
{ 36755, 1210 },
{ 36131, 1208 },
{ 36127, 1207 },
{ 20892, 1200 },
{ 38656, 1195 },
{ 37051, 1194 },
{ 38485, 1187 },
{ 21435, 1176 },
{ 20302, 1173 },
{ 25317, 1168 },
{ 38450, 1166 },
{ 24247, 1164 },
{ 20196, 1161 },
{ 32473, 1157 },
{ 38543, 1152 },
{ 20225, 1149 },
{ 29260, 1136 },
{ 32456, 1135 },
{ 28201, 1133 },
{ 20165, 1129 },
{ 32899, 1126 },
{ 35782, 1123 },
{ 26494, 1118 },
{ 24213, 1106 },
{ 39564, 1104 },
{ 37326, 1099 },
{ 23627, 1097 },
{ 23459, 1095 },
{ 30830, 1094 },
{ 35780, 1093 },
{ 38454, 1080 },
{ 26087, 1079 },
{ 33098, 1076 },
{ 31227, 1075 },
{ 30331, 1073 },
{ 32536, 1067 },
{ 25191, 1062 },
{ 37197, 1056 },
{ 23467, 1054 },
{ 27490, 1051 },
{ 20029, 1041 },
{ 27833, 1041 },
{ 32487, 1038 },
{ 27714, 1033 },
{ 25151, 1033 },
{ 32988, 1031 },
{ 26641, 1023 },
{ 27719, 1020 },
{ 38889, 1018 },
{ 26395, 1007 },
{ 20215, 1006 },
{ 28040, 1003 },
{ 29031, 1002 },
{ 25215, 1002 },
{ 35797, 1000 },
{ 23453, 999 },
{ 24863, 998 },
{ 23721, 988 },
{ 20020, 983 },
{ 32553, 977 },
{ 33647, 977 },
{ 26174, 972 },
{ 22686, 971 },
{ 21319, 971 },
{ 35799, 967 },
{ 26049, 959 },
{ 31574, 957 },
{ 40060, 955 },
{ 26391, 953 },
{ 24198, 953 },
{ 26432, 947 },
{ 24377, 947 },
{ 35835, 946 },
{ 33328, 942 },
{ 39044, 942 },
{ 24441, 939 },
{ 22833, 939 },
{ 27807, 938 },
{ 33778, 926 },
{ 26550, 926 },
{ 24322, 925 },
{ 27454, 923 },
{ 25239, 915 },
{ 37089, 912 },
{ 31461, 907 },
{ 32445, 906 },
{ 28789, 903 },
{ 36135, 901 },
{ 32626, 901 },
{ 30008, 900 },
{ 39057, 899 },
{ 36951, 895 },
{ 26149, 892 },
{ 20173, 888 },
{ 23186, 887 },
{ 31080, 886 },
{ 25209, 885 },
{ 30053, 871 },
{ 21183, 871 },
{ 25442, 868 },
{ 27010, 864 },
{ 21103, 860 },
{ 25105, 858 },
{ 23519, 855 },
{ 20248, 845 },
{ 20064, 841 },
{ 27605, 833 },
{ 36130, 832 },
{ 21378, 831 },
{ 38144, 827 },
{ 28385, 827 },
{ 26029, 823 },
{ 26234, 818 },
{ 20016, 817 },
{ 21551, 817 },
{ 26480, 812 },
{ 30417, 811 },
{ 33406, 805 },
{ 21171, 804 },
{ 32511, 800 },
{ 21387, 796 },
{ 29595, 789 },
{ 30041, 781 },
{ 23486, 780 },
{ 39029, 780 },
{ 35753, 773 },
{ 21556, 771 },
{ 24310, 769 },
{ 27602, 762 },
{ 21367, 760 },
{ 36731, 756 },
{ 27901, 750 },
{ 20037, 747 },
{ 20914, 743 },
{ 31169, 738 },
{ 35686, 737 },
{ 38047, 734 },
{ 21451, 732 },
{ 31361, 730 },
{ 26202, 728 },
{ 36718, 727 },
{ 38452, 725 },
{ 31687, 721 },
{ 20391, 721 },
{ 34429, 721 },
{ 22336, 719 },
{ 30422, 717 },
{ 25668, 716 },
{ 39030, 716 },
{ 36797, 711 },
{ 38505, 710 },
{ 1072, 705 },
{ 34013, 701 },
{ 20917, 701 },
{ 24402, 696 },
{ 233, 695 },
{ 30784, 692 },
{ 22278, 692 },
{ 33635, 690 },
{ 23681, 688 },
{ 26472, 679 },
{ 35832, 678 },
{ 33922, 676 },
{ 20185, 673 },
{ 21381, 672 },
{ 21016, 669 },
{ 24085, 667 },
{ 35272, 667 },
{ 20129, 667 },
{ 36141, 664 },
{ 21628, 663 },
{ 38182, 662 },
{ 32508, 661 },
{ 20572, 661 },
{ 38582, 660 },
{ 20859, 660 },
{ 1080, 659 },
{ 31454, 659 },
{ 36712, 655 },
{ 33033, 651 },
{ 32477, 650 },
{ 30772, 649 },
{ 20912, 646 },
{ 36866, 644 },
{ 1086, 642 },
{ 25193, 636 },
{ 38236, 635 },
{ 20857, 634 },
{ 37322, 634 },
{ 39034, 631 },
{ 27178, 631 },
{ 32517, 631 },
{ 20876, 628 },
{ 38590, 627 },
{ 38477, 626 },
{ 20813, 623 },
{ 36133, 623 },
{ 35757, 622 },
{ 36865, 619 },
{ 31508, 614 },
{ 21414, 614 },
{ 26144, 608 },
{ 30010, 605 },
{ 30424, 598 },
{ 38024, 594 },
{ 38177, 594 },
{ 20005, 592 },
{ 20104, 591 },
{ 23725, 590 },
{ 44032, 589 },
{ 24217, 584 }
};
static const std::unordered_map<std::tuple<uint32_t, uint32_t>, size_t> zh_cn_bigrams {
{ std::make_tuple<uint32_t, uint32_t>(32, 24180), 38848 },
{ std::make_tuple<uint32_t, uint32_t>(65289, 65292), 14139 },
{ std::make_tuple<uint32_t, uint32_t>(24180, 32), 13993 },
{ std::make_tuple<uint32_t, uint32_t>(32, 26376), 13702 },
{ std::make_tuple<uint32_t, uint32_t>(20013, 22269), 13581 },
{ std::make_tuple<uint32_t, uint32_t>(65292, 26159), 13170 },
{ std::make_tuple<uint32_t, uint32_t>(65289, 26159), 10848 },
{ std::make_tuple<uint32_t, uint32_t>(32, 26085), 10844 },
{ std::make_tuple<uint32_t, uint32_t>(19976, 19976), 10643 },
{ std::make_tuple<uint32_t, uint32_t>(20110, 32), 10544 },
{ std::make_tuple<uint32_t, uint32_t>(26376, 32), 10522 },
{ std::make_tuple<uint32_t, uint32_t>(19968, 20010), 9742 },
{ std::make_tuple<uint32_t, uint32_t>(30340, 19968), 9462 },
{ std::make_tuple<uint32_t, uint32_t>(39321, 28207), 8632 },
{ std::make_tuple<uint32_t, uint32_t>(26159, 19968), 8458 },
{ std::make_tuple<uint32_t, uint32_t>(32, 65292), 8290 },
{ std::make_tuple<uint32_t, uint32_t>(65292, 32), 8207 },
{ std::make_tuple<uint32_t, uint32_t>(32, 31859), 6968 },
{ std::make_tuple<uint32_t, uint32_t>(22320, 21306), 6955 },
{ std::make_tuple<uint32_t, uint32_t>(20301, 20110), 6910 },
{ std::make_tuple<uint32_t, uint32_t>(21488, 28286), 6649 },
{ std::make_tuple<uint32_t, uint32_t>(32654, 22269), 6262 },
{ std::make_tuple<uint32_t, uint32_t>(20844, 21496), 6085 },
{ std::make_tuple<uint32_t, uint32_t>(19976, 19969), 6021 },
{ std::make_tuple<uint32_t, uint32_t>(32, 19976), 5741 },
{ std::make_tuple<uint32_t, uint32_t>(20197, 21450), 5720 },
{ std::make_tuple<uint32_t, uint32_t>(33267, 32), 5691 },
{ std::make_tuple<uint32_t, uint32_t>(26085, 26412), 5547 },
{ std::make_tuple<uint32_t, uint32_t>(20026, 32), 5249 },
{ std::make_tuple<uint32_t, uint32_t>(19969, 19976), 5202 },
{ std::make_tuple<uint32_t, uint32_t>(19976, 65292), 5165 },
{ std::make_tuple<uint32_t, uint32_t>(65292, 19976), 5138 },
{ std::make_tuple<uint32_t, uint32_t>(30340, 19976), 5079 },
{ std::make_tuple<uint32_t, uint32_t>(21306, 65292), 4940 },
{ std::make_tuple<uint32_t, uint32_t>(26893, 29289), 4924 },
{ std::make_tuple<uint32_t, uint32_t>(19968, 20122), 4760 },
{ std::make_tuple<uint32_t, uint32_t>(22823, 23398), 4751 },
{ std::make_tuple<uint32_t, uint32_t>(20043, 19968), 4710 },
{ std::make_tuple<uint32_t, uint32_t>(65292, 22312), 4524 },
{ std::make_tuple<uint32_t, uint32_t>(29983, 38271), 4500 },
{ std::make_tuple<uint32_t, uint32_t>(30446, 21069), 4402 },
{ std::make_tuple<uint32_t, uint32_t>(22823, 38470), 4400 },
{ std::make_tuple<uint32_t, uint32_t>(22312, 32), 4342 },
{ std::make_tuple<uint32_t, uint32_t>(20027, 35201), 4270 },
{ std::make_tuple<uint32_t, uint32_t>(65292, 19969), 4254 },
{ std::make_tuple<uint32_t, uint32_t>(30340, 22320), 4246 },
{ std::make_tuple<uint32_t, uint32_t>(19969, 65292), 4237 },
{ std::make_tuple<uint32_t, uint32_t>(31216, 20026), 4237 },
{ std::make_tuple<uint32_t, uint32_t>(12289, 19976), 4209 },
{ std::make_tuple<uint32_t, uint32_t>(22269, 22823), 4205 },
{ std::make_tuple<uint32_t, uint32_t>(22269, 23478), 4191 },
{ std::make_tuple<uint32_t, uint32_t>(22320, 65292), 4149 },
{ std::make_tuple<uint32_t, uint32_t>(12290, 32), 4085 },
{ std::make_tuple<uint32_t, uint32_t>(65306, 65289), 4083 },
{ std::make_tuple<uint32_t, uint32_t>(32, 12290), 4044 },
{ std::make_tuple<uint32_t, uint32_t>(21517, 65306), 4034 },
{ std::make_tuple<uint32_t, uint32_t>(65288, 32), 4029 },
{ std::make_tuple<uint32_t, uint32_t>(65292, 24182), 4017 },
{ std::make_tuple<uint32_t, uint32_t>(20122, 65306), 3961 },
{ std::make_tuple<uint32_t, uint32_t>(32, 19969), 3946 },
{ std::make_tuple<uint32_t, uint32_t>(65292, 30001), 3911 },
{ std::make_tuple<uint32_t, uint32_t>(19990, 30028), 3851 },
{ std::make_tuple<uint32_t, uint32_t>(20998, 24067), 3839 },
{ std::make_tuple<uint32_t, uint32_t>(23398, 21517), 3799 },
{ std::make_tuple<uint32_t, uint32_t>(65288, 65289), 3758 },
{ std::make_tuple<uint32_t, uint32_t>(19981, 20132), 3736 },
{ std::make_tuple<uint32_t, uint32_t>(65289, 12290), 3713 },
{ std::make_tuple<uint32_t, uint32_t>(19969, 19969), 3673 },
{ std::make_tuple<uint32_t, uint32_t>(65288, 23398), 3658 },
{ std::make_tuple<uint32_t, uint32_t>(65292, 30446), 3648 },
{ std::make_tuple<uint32_t, uint32_t>(29289, 12290), 3636 },
{ std::make_tuple<uint32_t, uint32_t>(19976, 30340), 3617 },
{ std::make_tuple<uint32_t, uint32_t>(65292, 20026), 3616 },
{ std::make_tuple<uint32_t, uint32_t>(65292, 20854), 3552 },
{ std::make_tuple<uint32_t, uint32_t>(20110, 19981), 3550 },
{ std::make_tuple<uint32_t, uint32_t>(65292, 29983), 3542 },
{ std::make_tuple<uint32_t, uint32_t>(65292, 20197), 3498 },
{ std::make_tuple<uint32_t, uint32_t>(31532, 19968), 3441 },
{ std::make_tuple<uint32_t, uint32_t>(30340, 19969), 3401 },
{ std::make_tuple<uint32_t, uint32_t>(31616, 31216), 3399 },
{ std::make_tuple<uint32_t, uint32_t>(19981, 25300), 3372 },
{ std::make_tuple<uint32_t, uint32_t>(20013, 65292), 3371 },
{ std::make_tuple<uint32_t, uint32_t>(23646, 30340), 3366 },
{ std::make_tuple<uint32_t, uint32_t>(65292, 20294), 3353 },
{ std::make_tuple<uint32_t, uint32_t>(31561, 22320), 3350 },
{ std::make_tuple<uint32_t, uint32_t>(21253, 25324), 3325 },
{ std::make_tuple<uint32_t, uint32_t>(38271, 20110), 3283 },
{ std::make_tuple<uint32_t, uint32_t>(20351, 29992), 3270 },
{ std::make_tuple<uint32_t, uint32_t>(65292, 20063), 3256 },
{ std::make_tuple<uint32_t, uint32_t>(65292, 32780), 3223 },
{ std::make_tuple<uint32_t, uint32_t>(19969, 20351), 3178 },
{ std::make_tuple<uint32_t, uint32_t>(25300, 32), 3155 },
{ std::make_tuple<uint32_t, uint32_t>(22269, 38469), 3114 },
{ std::make_tuple<uint32_t, uint32_t>(20154, 24037), 3099 },
{ std::make_tuple<uint32_t, uint32_t>(38470, 30340), 3096 },
{ std::make_tuple<uint32_t, uint32_t>(31859, 30340), 3087 },
{ std::make_tuple<uint32_t, uint32_t>(22269, 30340), 3079 },
{ std::make_tuple<uint32_t, uint32_t>(19969, 30340), 3074 },
{ std::make_tuple<uint32_t, uint32_t>(30340, 32), 3036 },
{ std::make_tuple<uint32_t, uint32_t>(24180, 65292), 3020 },
{ std::make_tuple<uint32_t, uint32_t>(20013, 21326), 3016 },
{ std::make_tuple<uint32_t, uint32_t>(30001, 20154), 3013 },
{ std::make_tuple<uint32_t, uint32_t>(23478, 65292), 2992 },
{ std::make_tuple<uint32_t, uint32_t>(20351, 65292), 2980 },
{ std::make_tuple<uint32_t, uint32_t>(26685, 22521), 2968 },
{ std::make_tuple<uint32_t, uint32_t>(12290, 20998), 2961 },
{ std::make_tuple<uint32_t, uint32_t>(19976, 12289), 2959 },
{ std::make_tuple<uint32_t, uint32_t>(65292, 21448), 2947 },
{ std::make_tuple<uint32_t, uint32_t>(24341, 20122), 2921 },
{ std::make_tuple<uint32_t, uint32_t>(32, 65289), 2917 },
{ std::make_tuple<uint32_t, uint32_t>(22521, 12290), 2913 },
{ std::make_tuple<uint32_t, uint32_t>(20122, 26685), 2911 },
{ std::make_tuple<uint32_t, uint32_t>(30340, 26893), 2910 },
{ std::make_tuple<uint32_t, uint32_t>(24037, 24341), 2908 },
{ std::make_tuple<uint32_t, uint32_t>(31995, 32479), 2897 },
{ std::make_tuple<uint32_t, uint32_t>(65289, 12289), 2880 },
{ std::make_tuple<uint32_t, uint32_t>(20013, 30340), 2873 },
{ std::make_tuple<uint32_t, uint32_t>(20351, 31350), 2862 },
{ std::make_tuple<uint32_t, uint32_t>(32, 12298), 2860 },
{ std::make_tuple<uint32_t, uint32_t>(32, 65288), 2857 },
{ std::make_tuple<uint32_t, uint32_t>(26159, 20013), 2851 },
{ std::make_tuple<uint32_t, uint32_t>(21335, 12289), 2847 },
{ std::make_tuple<uint32_t, uint32_t>(23578, 26410), 2839 },
{ std::make_tuple<uint32_t, uint32_t>(33521, 25991), 2834 },
{ std::make_tuple<uint32_t, uint32_t>(65292, 20110), 2786 },
{ std::make_tuple<uint32_t, uint32_t>(32, 30340), 2781 },
{ std::make_tuple<uint32_t, uint32_t>(65292, 19981), 2776 },
{ std::make_tuple<uint32_t, uint32_t>(65292, 20301), 2756 },
{ std::make_tuple<uint32_t, uint32_t>(31859, 33267), 2745 },
{ std::make_tuple<uint32_t, uint32_t>(35199, 12289), 2735 },
{ std::make_tuple<uint32_t, uint32_t>(21069, 23578), 2725 },
{ std::make_tuple<uint32_t, uint32_t>(26410, 30001), 2714 },
{ std::make_tuple<uint32_t, uint32_t>(21487, 20197), 2687 },
{ std::make_tuple<uint32_t, uint32_t>(30005, 35270), 2674 },
{ std::make_tuple<uint32_t, uint32_t>(20013, 20351), 2667 },
{ std::make_tuple<uint32_t, uint32_t>(19976, 32), 2639 },
{ std::make_tuple<uint32_t, uint32_t>(25104, 31435), 2637 },
{ std::make_tuple<uint32_t, uint32_t>(12289, 19969), 2633 },
{ std::make_tuple<uint32_t, uint32_t>(20351, 29702), 2624 },
{ std::make_tuple<uint32_t, uint32_t>(20241, 65292), 2609 },
{ std::make_tuple<uint32_t, uint32_t>(19976, 65288), 2586 },
{ std::make_tuple<uint32_t, uint32_t>(32, 26159), 2568 },
{ std::make_tuple<uint32_t, uint32_t>(24180, 65289), 2514 },
{ std::make_tuple<uint32_t, uint32_t>(36816, 21160), 2493 },
{ std::make_tuple<uint32_t, uint32_t>(29983, 20110), 2477 },
{ std::make_tuple<uint32_t, uint32_t>(30340, 19981), 2462 },
{ std::make_tuple<uint32_t, uint32_t>(20063, 26159), 2441 },
{ std::make_tuple<uint32_t, uint32_t>(19968, 33324), 2436 },
{ std::make_tuple<uint32_t, uint32_t>(12289, 32), 2429 },
{ std::make_tuple<uint32_t, uint32_t>(65292, 22240), 2416 },
{ std::make_tuple<uint32_t, uint32_t>(65288, 33521), 2411 },
{ std::make_tuple<uint32_t, uint32_t>(36710, 31449), 2410 },
{ std::make_tuple<uint32_t, uint32_t>(25104, 20026), 2403 },
{ std::make_tuple<uint32_t, uint32_t>(32, 20010), 2399 },
{ std::make_tuple<uint32_t, uint32_t>(25991, 65306), 2387 },
{ std::make_tuple<uint32_t, uint32_t>(19968, 65292), 2377 },
{ std::make_tuple<uint32_t, uint32_t>(33521, 22269), 2374 },
{ std::make_tuple<uint32_t, uint32_t>(21382, 20351), 2363 },
{ std::make_tuple<uint32_t, uint32_t>(20154, 65292), 2362 },
{ std::make_tuple<uint32_t, uint32_t>(20154, 27665), 2356 },
{ std::make_tuple<uint32_t, uint32_t>(26159, 32), 2352 },
{ std::make_tuple<uint32_t, uint32_t>(65292, 19968), 2351 },
{ std::make_tuple<uint32_t, uint32_t>(26377, 32), 2350 },
{ std::make_tuple<uint32_t, uint32_t>(21457, 23637), 2345 },
{ std::make_tuple<uint32_t, uint32_t>(37096, 20998), 2341 },
{ std::make_tuple<uint32_t, uint32_t>(20351, 30340), 2300 },
{ std::make_tuple<uint32_t, uint32_t>(21448, 31216), 2280 },
{ std::make_tuple<uint32_t, uint32_t>(36827, 34892), 2271 },
{ std::make_tuple<uint32_t, uint32_t>(31038, 20250), 2250 },
{ std::make_tuple<uint32_t, uint32_t>(12299, 65288), 2220 },
{ std::make_tuple<uint32_t, uint32_t>(19969, 12289), 2210 },
{ std::make_tuple<uint32_t, uint32_t>(34892, 19981), 2204 },
{ std::make_tuple<uint32_t, uint32_t>(65289, 30340), 2201 },
{ std::make_tuple<uint32_t, uint32_t>(21450, 20013), 2186 },
{ std::make_tuple<uint32_t, uint32_t>(21360, 24230), 2180 },
{ std::make_tuple<uint32_t, uint32_t>(19969, 20241), 2172 },
{ std::make_tuple<uint32_t, uint32_t>(19990, 32426), 2136 },
{ std::make_tuple<uint32_t, uint32_t>(31532, 20108), 2122 },
{ std::make_tuple<uint32_t, uint32_t>(19969, 12290), 2121 },
{ std::make_tuple<uint32_t, uint32_t>(19976, 12290), 2119 },
{ std::make_tuple<uint32_t, uint32_t>(29289, 65292), 2113 },
{ std::make_tuple<uint32_t, uint32_t>(25991, 21270), 2111 },
{ std::make_tuple<uint32_t, uint32_t>(65289, 20026), 2108 },
{ std::make_tuple<uint32_t, uint32_t>(32, 20154), 2100 },
{ std::make_tuple<uint32_t, uint32_t>(20849, 21644), 2100 },
{ std::make_tuple<uint32_t, uint32_t>(21518, 65292), 2099 },
{ std::make_tuple<uint32_t, uint32_t>(19981, 12289), 2097 },
{ std::make_tuple<uint32_t, uint32_t>(20844, 37324), 2086 },
{ std::make_tuple<uint32_t, uint32_t>(21644, 22269), 2085 },
{ std::make_tuple<uint32_t, uint32_t>(24320, 22987), 2055 },
{ std::make_tuple<uint32_t, uint32_t>(19981, 21516), 2049 },
{ std::make_tuple<uint32_t, uint32_t>(30005, 24433), 2044 },
{ std::make_tuple<uint32_t, uint32_t>(32, 12289), 2042 },
{ std::make_tuple<uint32_t, uint32_t>(12289, 23665), 2033 },
{ std::make_tuple<uint32_t, uint32_t>(65292, 31616), 2029 },
{ std::make_tuple<uint32_t, uint32_t>(19969, 20122), 2029 },
{ std::make_tuple<uint32_t, uint32_t>(26159, 19976), 2026 },
{ std::make_tuple<uint32_t, uint32_t>(23646, 20110), 2022 },
{ std::make_tuple<uint32_t, uint32_t>(33521, 20122), 2018 },
{ std::make_tuple<uint32_t, uint32_t>(32452, 32455), 2012 },
{ std::make_tuple<uint32_t, uint32_t>(26381, 21153), 2010 },
{ std::make_tuple<uint32_t, uint32_t>(26159, 30001), 1948 },
{ std::make_tuple<uint32_t, uint32_t>(65292, 20351), 1942 },
{ std::make_tuple<uint32_t, uint32_t>(20026, 19976), 1939 },
{ std::make_tuple<uint32_t, uint32_t>(20854, 20013), 1933 },
{ std::make_tuple<uint32_t, uint32_t>(19981, 20351), 1931 },
{ std::make_tuple<uint32_t, uint32_t>(28216, 25103), 1924 },
{ std::make_tuple<uint32_t, uint32_t>(30340, 20351), 1923 },
{ std::make_tuple<uint32_t, uint32_t>(20195, 34920), 1920 },
{ std::make_tuple<uint32_t, uint32_t>(30340, 20154), 1919 },
{ std::make_tuple<uint32_t, uint32_t>(23398, 38498), 1919 },
{ std::make_tuple<uint32_t, uint32_t>(12290, 22312), 1915 },
{ std::make_tuple<uint32_t, uint32_t>(38081, 36335), 1902 },
{ std::make_tuple<uint32_t, uint32_t>(19969, 32), 1901 },
{ std::make_tuple<uint32_t, uint32_t>(22235, 24029), 1896 },
{ std::make_tuple<uint32_t, uint32_t>(26159, 25351), 1893 },
{ std::make_tuple<uint32_t, uint32_t>(24191, 19996), 1877 },
{ std::make_tuple<uint32_t, uint32_t>(24067, 20110), 1877 },
{ std::make_tuple<uint32_t, uint32_t>(23398, 23478), 1872 },
{ std::make_tuple<uint32_t, uint32_t>(32, 20013), 1862 },
{ std::make_tuple<uint32_t, uint32_t>(19981, 30340), 1824 },
{ std::make_tuple<uint32_t, uint32_t>(24180, 20195), 1820 },
{ std::make_tuple<uint32_t, uint32_t>(12299, 65292), 1819 },
{ std::make_tuple<uint32_t, uint32_t>(32, 20844), 1819 },
{ std::make_tuple<uint32_t, uint32_t>(22823, 30340), 1819 },
{ std::make_tuple<uint32_t, uint32_t>(20154, 21475), 1818 },
{ std::make_tuple<uint32_t, uint32_t>(20854, 20182), 1807 },
{ std::make_tuple<uint32_t, uint32_t>(31532, 32), 1806 },
{ std::make_tuple<uint32_t, uint32_t>(19968, 12290), 1805 },
{ std::make_tuple<uint32_t, uint32_t>(20027, 20041), 1789 },
{ std::make_tuple<uint32_t, uint32_t>(32463, 27982), 1788 },
{ std::make_tuple<uint32_t, uint32_t>(24314, 19969), 1787 },
{ std::make_tuple<uint32_t, uint32_t>(19976, 20241), 1776 },
{ std::make_tuple<uint32_t, uint32_t>(12290, 36825), 1769 },
{ std::make_tuple<uint32_t, uint32_t>(25945, 32946), 1765 },
{ std::make_tuple<uint32_t, uint32_t>(35774, 35745), 1764 },
{ std::make_tuple<uint32_t, uint32_t>(26102, 26399), 1763 },
{ std::make_tuple<uint32_t, uint32_t>(38899, 20048), 1761 },
{ std::make_tuple<uint32_t, uint32_t>(32422, 32), 1747 },
{ std::make_tuple<uint32_t, uint32_t>(37325, 35201), 1745 },
{ std::make_tuple<uint32_t, uint32_t>(22478, 20107), 1744 },
{ std::make_tuple<uint32_t, uint32_t>(20113, 21335), 1737 },
{ std::make_tuple<uint32_t, uint32_t>(33879, 21517), 1735 },
{ std::make_tuple<uint32_t, uint32_t>(26159, 39321), 1732 },
{ std::make_tuple<uint32_t, uint32_t>(20110, 20013), 1731 },
{ std::make_tuple<uint32_t, uint32_t>(21033, 20122), 1729 },
{ std::make_tuple<uint32_t, uint32_t>(30340, 20241), 1722 },
{ std::make_tuple<uint32_t, uint32_t>(20122, 35328), 1720 },
{ std::make_tuple<uint32_t, uint32_t>(20351, 12290), 1718 },
{ std::make_tuple<uint32_t, uint32_t>(12289, 24191), 1717 },
{ std::make_tuple<uint32_t, uint32_t>(31185, 23398), 1716 },
{ std::make_tuple<uint32_t, uint32_t>(36275, 29699), 1709 },
{ std::make_tuple<uint32_t, uint32_t>(12354, 12354), 1707 },
{ std::make_tuple<uint32_t, uint32_t>(19969, 65288), 1706 },
{ std::make_tuple<uint32_t, uint32_t>(65292, 20013), 1697 },
{ std::make_tuple<uint32_t, uint32_t>(20241, 30340), 1686 },
{ std::make_tuple<uint32_t, uint32_t>(19978, 30340), 1685 },
{ std::make_tuple<uint32_t, uint32_t>(30001, 20110), 1683 },
{ std::make_tuple<uint32_t, uint32_t>(23665, 22369), 1678 },
{ std::make_tuple<uint32_t, uint32_t>(23478, 22269), 1673 },
{ std::make_tuple<uint32_t, uint32_t>(32, 19990), 1671 },
{ std::make_tuple<uint32_t, uint32_t>(65292, 20027), 1658 },
{ std::make_tuple<uint32_t, uint32_t>(24067, 22312), 1655 },
{ std::make_tuple<uint32_t, uint32_t>(36890, 24120), 1655 },
{ std::make_tuple<uint32_t, uint32_t>(19981, 27835), 1654 },
{ std::make_tuple<uint32_t, uint32_t>(25216, 26415), 1644 },
{ std::make_tuple<uint32_t, uint32_t>(12450, 12450), 1643 },
{ std::make_tuple<uint32_t, uint32_t>(19981, 23478), 1629 },
{ std::make_tuple<uint32_t, uint32_t>(22996, 21592), 1628 },
{ std::make_tuple<uint32_t, uint32_t>(30340, 31532), 1619 },
{ std::make_tuple<uint32_t, uint32_t>(31995, 20351), 1617 },
{ std::make_tuple<uint32_t, uint32_t>(20043, 38388), 1601 },
{ std::make_tuple<uint32_t, uint32_t>(20122, 12289), 1600 },
{ std::make_tuple<uint32_t, uint32_t>(19996, 19981), 1592 },
{ std::make_tuple<uint32_t, uint32_t>(19968, 37096), 1591 },
{ std::make_tuple<uint32_t, uint32_t>(27431, 27954), 1589 },
{ std::make_tuple<uint32_t, uint32_t>(65292, 36825), 1581 },
{ std::make_tuple<uint32_t, uint32_t>(20241, 19976), 1574 },
{ std::make_tuple<uint32_t, uint32_t>(65292, 22810), 1573 },
{ std::make_tuple<uint32_t, uint32_t>(25552, 20379), 1571 },
{ std::make_tuple<uint32_t, uint32_t>(27665, 22269), 1569 },
{ std::make_tuple<uint32_t, uint32_t>(32852, 20241), 1568 },
{ std::make_tuple<uint32_t, uint32_t>(21306, 30340), 1567 },
{ std::make_tuple<uint32_t, uint32_t>(32, 21495), 1564 },
{ std::make_tuple<uint32_t, uint32_t>(12289, 28246), 1562 },
{ std::make_tuple<uint32_t, uint32_t>(65292, 65289), 1561 },
{ std::make_tuple<uint32_t, uint32_t>(23398, 26657), 1549 },
{ std::make_tuple<uint32_t, uint32_t>(26085, 65292), 1548 },
{ std::make_tuple<uint32_t, uint32_t>(30340, 29305), 1539 },
{ std::make_tuple<uint32_t, uint32_t>(24503, 22269), 1532 },
{ std::make_tuple<uint32_t, uint32_t>(38754, 31215), 1528 },
{ std::make_tuple<uint32_t, uint32_t>(26368, 22823), 1527 },
{ std::make_tuple<uint32_t, uint32_t>(30340, 23567), 1525 },
{ std::make_tuple<uint32_t, uint32_t>(26377, 38480), 1519 },
{ std::make_tuple<uint32_t, uint32_t>(37324, 65292), 1518 },
{ std::make_tuple<uint32_t, uint32_t>(22320, 19981), 1517 },
{ std::make_tuple<uint32_t, uint32_t>(20316, 20026), 1517 },
{ std::make_tuple<uint32_t, uint32_t>(35748, 20026), 1515 },
{ std::make_tuple<uint32_t, uint32_t>(19981, 37096), 1509 },
{ std::make_tuple<uint32_t, uint32_t>(19976, 31185), 1509 },
{ std::make_tuple<uint32_t, uint32_t>(12290, 35813), 1506 },
{ std::make_tuple<uint32_t, uint32_t>(20026, 20013), 1501 },
{ std::make_tuple<uint32_t, uint32_t>(22312, 20013), 1500 },
{ std::make_tuple<uint32_t, uint32_t>(23567, 35828), 1496 },
{ std::make_tuple<uint32_t, uint32_t>(19978, 19981), 1488 },
{ std::make_tuple<uint32_t, uint32_t>(65292, 26377), 1486 },
{ std::make_tuple<uint32_t, uint32_t>(21517, 30340), 1485 },
{ std::make_tuple<uint32_t, uint32_t>(36825, 20010), 1485 },
{ std::make_tuple<uint32_t, uint32_t>(12290, 23427), 1480 },
{ std::make_tuple<uint32_t, uint32_t>(20122, 32), 1478 },
{ std::make_tuple<uint32_t, uint32_t>(22240, 27492), 1473 },
{ std::make_tuple<uint32_t, uint32_t>(20107, 65292), 1473 },
{ std::make_tuple<uint32_t, uint32_t>(21326, 20154), 1471 },
{ std::make_tuple<uint32_t, uint32_t>(19976, 20122), 1470 },
{ std::make_tuple<uint32_t, uint32_t>(26102, 38388), 1469 },
{ std::make_tuple<uint32_t, uint32_t>(20351, 22242), 1466 },
{ std::make_tuple<uint32_t, uint32_t>(19981, 20140), 1465 },
{ std::make_tuple<uint32_t, uint32_t>(65292, 20056), 1464 },
{ std::make_tuple<uint32_t, uint32_t>(19978, 65292), 1461 },
{ std::make_tuple<uint32_t, uint32_t>(19981, 65292), 1460 },
{ std::make_tuple<uint32_t, uint32_t>(32452, 25104), 1458 },
{ std::make_tuple<uint32_t, uint32_t>(26159, 22312), 1454 },
{ std::make_tuple<uint32_t, uint32_t>(20122, 65292), 1453 },
{ std::make_tuple<uint32_t, uint32_t>(32, 20351), 1450 },
{ std::make_tuple<uint32_t, uint32_t>(31216, 32), 1447 },
{ std::make_tuple<uint32_t, uint32_t>(20316, 21697), 1438 },
{ std::make_tuple<uint32_t, uint32_t>(26159, 19969), 1437 },
{ std::make_tuple<uint32_t, uint32_t>(21488, 19981), 1436 },
{ std::make_tuple<uint32_t, uint32_t>(20351, 19976), 1433 },
{ std::make_tuple<uint32_t, uint32_t>(32, 19975), 1431 },
{ std::make_tuple<uint32_t, uint32_t>(24320, 21457), 1428 },
{ std::make_tuple<uint32_t, uint32_t>(21517, 20026), 1425 },
{ std::make_tuple<uint32_t, uint32_t>(32852, 21512), 1420 },
{ std::make_tuple<uint32_t, uint32_t>(31449, 65292), 1417 },
{ std::make_tuple<uint32_t, uint32_t>(65292, 23427), 1417 },
{ std::make_tuple<uint32_t, uint32_t>(19981, 19976), 1417 },
{ std::make_tuple<uint32_t, uint32_t>(20351, 12289), 1407 },
{ std::make_tuple<uint32_t, uint32_t>(24403, 26102), 1404 },
{ std::make_tuple<uint32_t, uint32_t>(32599, 26031), 1403 },
{ std::make_tuple<uint32_t, uint32_t>(65292, 20241), 1379 },
{ std::make_tuple<uint32_t, uint32_t>(23567, 30340), 1375 },
{ std::make_tuple<uint32_t, uint32_t>(12290, 20182), 1369 },
{ std::make_tuple<uint32_t, uint32_t>(12289, 20056), 1367 },
{ std::make_tuple<uint32_t, uint32_t>(21517, 31216), 1365 },
{ std::make_tuple<uint32_t, uint32_t>(30340, 20027), 1363 },
{ std::make_tuple<uint32_t, uint32_t>(19981, 19969), 1361 },
{ std::make_tuple<uint32_t, uint32_t>(21516, 26102), 1360 },
{ std::make_tuple<uint32_t, uint32_t>(21160, 29289), 1359 },
{ std::make_tuple<uint32_t, uint32_t>(24180, 30340), 1358 },
{ std::make_tuple<uint32_t, uint32_t>(20241, 19969), 1348 },
{ std::make_tuple<uint32_t, uint32_t>(24037, 20316), 1348 },
{ std::make_tuple<uint32_t, uint32_t>(22269, 19981), 1345 },
{ std::make_tuple<uint32_t, uint32_t>(38480, 20844), 1343 },
{ std::make_tuple<uint32_t, uint32_t>(19976, 20081), 1342 },
{ std::make_tuple<uint32_t, uint32_t>(23612, 20122), 1342 },
{ std::make_tuple<uint32_t, uint32_t>(65292, 20182), 1341 },
{ std::make_tuple<uint32_t, uint32_t>(65292, 29616), 1341 },
{ std::make_tuple<uint32_t, uint32_t>(12289, 19981), 1336 },
{ std::make_tuple<uint32_t, uint32_t>(12289, 22235), 1328 },
{ std::make_tuple<uint32_t, uint32_t>(65292, 25110), 1328 },
{ std::make_tuple<uint32_t, uint32_t>(23478, 12290), 1319 },
{ std::make_tuple<uint32_t, uint32_t>(32593, 32476), 1319 },
{ std::make_tuple<uint32_t, uint32_t>(21457, 29983), 1318 },
{ std::make_tuple<uint32_t, uint32_t>(22823, 21033), 1318 },
{ std::make_tuple<uint32_t, uint32_t>(21592, 65292), 1310 },
{ std::make_tuple<uint32_t, uint32_t>(20154, 30340), 1301 },
{ std::make_tuple<uint32_t, uint32_t>(24179, 19981), 1296 },
{ std::make_tuple<uint32_t, uint32_t>(28246, 21335), 1294 },
{ std::make_tuple<uint32_t, uint32_t>(65292, 25104), 1293 },
{ std::make_tuple<uint32_t, uint32_t>(20030, 34892), 1293 },
{ std::make_tuple<uint32_t, uint32_t>(20241, 12290), 1293 },
{ std::make_tuple<uint32_t, uint32_t>(65292, 21253), 1287 },
{ std::make_tuple<uint32_t, uint32_t>(27809, 26377), 1287 },
{ std::make_tuple<uint32_t, uint32_t>(23646, 65288), 1286 },
{ std::make_tuple<uint32_t, uint32_t>(20043, 21518), 1285 },
{ std::make_tuple<uint32_t, uint32_t>(12289, 27827), 1285 },
{ std::make_tuple<uint32_t, uint32_t>(22240, 20026), 1284 },
{ std::make_tuple<uint32_t, uint32_t>(32, 19981), 1283 },
{ std::make_tuple<uint32_t, uint32_t>(25112, 20105), 1282 },
{ std::make_tuple<uint32_t, uint32_t>(20013, 22830), 1281 },
{ std::make_tuple<uint32_t, uint32_t>(22269, 22269), 1280 },
{ std::make_tuple<uint32_t, uint32_t>(31435, 20110), 1279 },
{ std::make_tuple<uint32_t, uint32_t>(26102, 65292), 1279 },
{ std::make_tuple<uint32_t, uint32_t>(26159, 32654), 1276 },
{ std::make_tuple<uint32_t, uint32_t>(27491, 24335), 1275 },
{ std::make_tuple<uint32_t, uint32_t>(23398, 65292), 1273 },
{ std::make_tuple<uint32_t, uint32_t>(36890, 36807), 1270 },
{ std::make_tuple<uint32_t, uint32_t>(65292, 21407), 1270 },
{ std::make_tuple<uint32_t, uint32_t>(22810, 29983), 1267 },
{ std::make_tuple<uint32_t, uint32_t>(20013, 23398), 1267 },
{ std::make_tuple<uint32_t, uint32_t>(20132, 65292), 1266 },
{ std::make_tuple<uint32_t, uint32_t>(27665, 20849), 1266 },
{ std::make_tuple<uint32_t, uint32_t>(26681, 25454), 1261 },
{ std::make_tuple<uint32_t, uint32_t>(65292, 19982), 1258 },
{ std::make_tuple<uint32_t, uint32_t>(65292, 20840), 1258 },
{ std::make_tuple<uint32_t, uint32_t>(31561, 12290), 1256 },
{ std::make_tuple<uint32_t, uint32_t>(65292, 21518), 1255 },
{ std::make_tuple<uint32_t, uint32_t>(34892, 30340), 1255 },
{ std::make_tuple<uint32_t, uint32_t>(24029, 12289), 1254 },
{ std::make_tuple<uint32_t, uint32_t>(26631, 20309), 1254 },
{ std::make_tuple<uint32_t, uint32_t>(30340, 26159), 1254 },
{ std::make_tuple<uint32_t, uint32_t>(19969, 23646), 1251 },
{ std::make_tuple<uint32_t, uint32_t>(31435, 30340), 1250 },
{ std::make_tuple<uint32_t, uint32_t>(25104, 30340), 1249 },
{ std::make_tuple<uint32_t, uint32_t>(35745, 20221), 1242 },
{ std::make_tuple<uint32_t, uint32_t>(20107, 20132), 1241 },
{ std::make_tuple<uint32_t, uint32_t>(21592, 20250), 1240 },
{ std::make_tuple<uint32_t, uint32_t>(21326, 27665), 1238 },
{ std::make_tuple<uint32_t, uint32_t>(27963, 21160), 1238 },
{ std::make_tuple<uint32_t, uint32_t>(29992, 30340), 1236 },
{ std::make_tuple<uint32_t, uint32_t>(12289, 20113), 1236 },
{ std::make_tuple<uint32_t, uint32_t>(19981, 21306), 1235 },
{ std::make_tuple<uint32_t, uint32_t>(30340, 65292), 1232 },
{ std::make_tuple<uint32_t, uint32_t>(30340, 22823), 1230 },
{ std::make_tuple<uint32_t, uint32_t>(24191, 35199), 1228 },
{ std::make_tuple<uint32_t, uint32_t>(29992, 20110), 1226 },
{ std::make_tuple<uint32_t, uint32_t>(19996, 12289), 1223 },
{ std::make_tuple<uint32_t, uint32_t>(26397, 40092), 1221 },
{ std::make_tuple<uint32_t, uint32_t>(22522, 19969), 1219 },
{ std::make_tuple<uint32_t, uint32_t>(26426, 26500), 1217 },
{ std::make_tuple<uint32_t, uint32_t>(33402, 26415), 1217 },
{ std::make_tuple<uint32_t, uint32_t>(35199, 19981), 1211 },
{ std::make_tuple<uint32_t, uint32_t>(21335, 37096), 1207 },
{ std::make_tuple<uint32_t, uint32_t>(20420, 32599), 1205 },
{ std::make_tuple<uint32_t, uint32_t>(24030, 12289), 1204 },
{ std::make_tuple<uint32_t, uint32_t>(30340, 22269), 1201 },
{ std::make_tuple<uint32_t, uint32_t>(35199, 20122), 1199 },
{ std::make_tuple<uint32_t, uint32_t>(20056, 22823), 1199 },
{ std::make_tuple<uint32_t, uint32_t>(12289, 12298), 1198 },
{ std::make_tuple<uint32_t, uint32_t>(30340, 20013), 1197 },
{ std::make_tuple<uint32_t, uint32_t>(65292, 20134), 1195 },
{ std::make_tuple<uint32_t, uint32_t>(20844, 36335), 1194 },
{ std::make_tuple<uint32_t, uint32_t>(25104, 21592), 1194 },
{ std::make_tuple<uint32_t, uint32_t>(65289, 32), 1194 },
{ std::make_tuple<uint32_t, uint32_t>(19981, 29616), 1191 },
{ std::make_tuple<uint32_t, uint32_t>(32, 24179), 1187 },
{ std::make_tuple<uint32_t, uint32_t>(19976, 23478), 1182 },
{ std::make_tuple<uint32_t, uint32_t>(20309, 65292), 1182 },
{ std::make_tuple<uint32_t, uint32_t>(20154, 12290), 1182 },
{ std::make_tuple<uint32_t, uint32_t>(26085, 32), 1181 },
{ std::make_tuple<uint32_t, uint32_t>(26102, 20195), 1179 },
{ std::make_tuple<uint32_t, uint32_t>(65306, 32), 1177 },
{ std::make_tuple<uint32_t, uint32_t>(20241, 20241), 1177 },
{ std::make_tuple<uint32_t, uint32_t>(65288, 65292), 1176 },
{ std::make_tuple<uint32_t, uint32_t>(21046, 20316), 1175 },
{ std::make_tuple<uint32_t, uint32_t>(12290, 20854), 1173 },
{ std::make_tuple<uint32_t, uint32_t>(21040, 32), 1169 },
{ std::make_tuple<uint32_t, uint32_t>(20110, 19976), 1169 },
{ std::make_tuple<uint32_t, uint32_t>(34892, 65292), 1162 },
{ std::make_tuple<uint32_t, uint32_t>(32599, 39532), 1148 },
{ std::make_tuple<uint32_t, uint32_t>(29983, 29289), 1143 },
{ std::make_tuple<uint32_t, uint32_t>(22312, 19976), 1143 },
{ std::make_tuple<uint32_t, uint32_t>(20081, 19976), 1142 },
{ std::make_tuple<uint32_t, uint32_t>(33322, 31354), 1141 },
{ std::make_tuple<uint32_t, uint32_t>(32, 22312), 1140 },
{ std::make_tuple<uint32_t, uint32_t>(19981, 19981), 1140 },
{ std::make_tuple<uint32_t, uint32_t>(24180, 65288), 1135 },
{ std::make_tuple<uint32_t, uint32_t>(38485, 35199), 1134 },
{ std::make_tuple<uint32_t, uint32_t>(31119, 24314), 1133 },
{ std::make_tuple<uint32_t, uint32_t>(31532, 19977), 1132 },
{ std::make_tuple<uint32_t, uint32_t>(33719, 24471), 1131 },
{ std::make_tuple<uint32_t, uint32_t>(21457, 34892), 1130 },
{ std::make_tuple<uint32_t, uint32_t>(19976, 19968), 1128 },
{ std::make_tuple<uint32_t, uint32_t>(65292, 26368), 1122 },
{ std::make_tuple<uint32_t, uint32_t>(38388, 65292), 1121 },
{ std::make_tuple<uint32_t, uint32_t>(37096, 65292), 1121 },
{ std::make_tuple<uint32_t, uint32_t>(20027, 25945), 1120 },
{ std::make_tuple<uint32_t, uint32_t>(28246, 19981), 1117 },
{ std::make_tuple<uint32_t, uint32_t>(38388, 30340), 1117 },
{ std::make_tuple<uint32_t, uint32_t>(38271, 22312), 1116 },
{ std::make_tuple<uint32_t, uint32_t>(20026, 20027), 1114 },
{ std::make_tuple<uint32_t, uint32_t>(20013, 25991), 1113 },
{ std::make_tuple<uint32_t, uint32_t>(19969, 19981), 1113 },
{ std::make_tuple<uint32_t, uint32_t>(27604, 36187), 1111 },
{ std::make_tuple<uint32_t, uint32_t>(25289, 19969), 1110 },
{ std::make_tuple<uint32_t, uint32_t>(19981, 24335), 1110 },
{ std::make_tuple<uint32_t, uint32_t>(20241, 12289), 1110 },
{ std::make_tuple<uint32_t, uint32_t>(24037, 31243), 1106 },
{ std::make_tuple<uint32_t, uint32_t>(24314, 31435), 1106 },
{ std::make_tuple<uint32_t, uint32_t>(35201, 30340), 1104 },
{ std::make_tuple<uint32_t, uint32_t>(12289, 27743), 1104 },
{ std::make_tuple<uint32_t, uint32_t>(65292, 21487), 1101 },
{ std::make_tuple<uint32_t, uint32_t>(24093, 22269), 1098 },
{ std::make_tuple<uint32_t, uint32_t>(19976, 23567), 1097 },
{ std::make_tuple<uint32_t, uint32_t>(23398, 12289), 1095 },
{ std::make_tuple<uint32_t, uint32_t>(20351, 32), 1090 },
{ std::make_tuple<uint32_t, uint32_t>(20056, 27743), 1087 },
{ std::make_tuple<uint32_t, uint32_t>(29305, 26377), 1087 },
{ std::make_tuple<uint32_t, uint32_t>(19976, 20351), 1087 },
{ std::make_tuple<uint32_t, uint32_t>(35768, 22810), 1084 },
{ std::make_tuple<uint32_t, uint32_t>(29616, 22312), 1080 },
{ std::make_tuple<uint32_t, uint32_t>(24433, 21709), 1080 },
{ std::make_tuple<uint32_t, uint32_t>(23478, 12289), 1079 },
{ std::make_tuple<uint32_t, uint32_t>(35745, 31639), 1077 },
{ std::make_tuple<uint32_t, uint32_t>(25317, 26377), 1075 },
{ std::make_tuple<uint32_t, uint32_t>(30340, 20132), 1075 },
{ std::make_tuple<uint32_t, uint32_t>(36149, 24030), 1074 },
{ std::make_tuple<uint32_t, uint32_t>(20840, 22269), 1074 },
{ std::make_tuple<uint32_t, uint32_t>(25991, 23398), 1074 },
{ std::make_tuple<uint32_t, uint32_t>(29702, 35770), 1071 },
{ std::make_tuple<uint32_t, uint32_t>(29702, 23398), 1070 },
{ std::make_tuple<uint32_t, uint32_t>(37096, 30340), 1067 },
{ std::make_tuple<uint32_t, uint32_t>(30005, 23376), 1067 },
{ std::make_tuple<uint32_t, uint32_t>(20010, 20154), 1067 },
{ std::make_tuple<uint32_t, uint32_t>(27665, 26063), 1066 },
{ std::make_tuple<uint32_t, uint32_t>(12299, 12289), 1065 },
{ std::make_tuple<uint32_t, uint32_t>(20241, 32), 1064 },
{ std::make_tuple<uint32_t, uint32_t>(65292, 26366), 1063 },
{ std::make_tuple<uint32_t, uint32_t>(20844, 22253), 1063 },
{ std::make_tuple<uint32_t, uint32_t>(25152, 26377), 1061 },
{ std::make_tuple<uint32_t, uint32_t>(36719, 20132), 1060 },
{ std::make_tuple<uint32_t, uint32_t>(23567, 65292), 1060 },
{ std::make_tuple<uint32_t, uint32_t>(20122, 19976), 1056 },
{ std::make_tuple<uint32_t, uint32_t>(12289, 35199), 1056 },
{ std::make_tuple<uint32_t, uint32_t>(20855, 26377), 1055 },
{ std::make_tuple<uint32_t, uint32_t>(31185, 19976), 1055 },
{ std::make_tuple<uint32_t, uint32_t>(29420, 31435), 1054 },
{ std::make_tuple<uint32_t, uint32_t>(29976, 32899), 1053 },
{ std::make_tuple<uint32_t, uint32_t>(19968, 20123), 1051 },
{ std::make_tuple<uint32_t, uint32_t>(21644, 32), 1051 },
{ std::make_tuple<uint32_t, uint32_t>(65292, 24120), 1051 },
{ std::make_tuple<uint32_t, uint32_t>(34987, 31216), 1048 },
{ std::make_tuple<uint32_t, uint32_t>(19968, 20301), 1048 },
{ std::make_tuple<uint32_t, uint32_t>(20851, 31995), 1044 },
{ std::make_tuple<uint32_t, uint32_t>(30446, 30340), 1041 },
{ std::make_tuple<uint32_t, uint32_t>(21327, 20250), 1039 },
{ std::make_tuple<uint32_t, uint32_t>(19969, 65289), 1039 },
{ std::make_tuple<uint32_t, uint32_t>(19969, 22269), 1036 },
{ std::make_tuple<uint32_t, uint32_t>(22806, 65292), 1036 },
{ std::make_tuple<uint32_t, uint32_t>(20110, 21488), 1035 },
{ std::make_tuple<uint32_t, uint32_t>(12290, 19976), 1034 },
{ std::make_tuple<uint32_t, uint32_t>(29305, 21035), 1034 },
{ std::make_tuple<uint32_t, uint32_t>(26377, 19968), 1032 },
{ std::make_tuple<uint32_t, uint32_t>(26031, 183), 1031 },
{ std::make_tuple<uint32_t, uint32_t>(21644, 19976), 1029 },
{ std::make_tuple<uint32_t, uint32_t>(65292, 21363), 1029 },
{ std::make_tuple<uint32_t, uint32_t>(20110, 19969), 1020 },
{ std::make_tuple<uint32_t, uint32_t>(65292, 35813), 1018 },
{ std::make_tuple<uint32_t, uint32_t>(19976, 19981), 1018 },
{ std::make_tuple<uint32_t, uint32_t>(19976, 20811), 1016 },
{ std::make_tuple<uint32_t, uint32_t>(19981, 38754), 1014 },
{ std::make_tuple<uint32_t, uint32_t>(20132, 22823), 1013 },
{ std::make_tuple<uint32_t, uint32_t>(26399, 38388), 1013 },
{ std::make_tuple<uint32_t, uint32_t>(19968, 26465), 1013 },
{ std::make_tuple<uint32_t, uint32_t>(23478, 30340), 1013 },
{ std::make_tuple<uint32_t, uint32_t>(22823, 20351), 1012 },
{ std::make_tuple<uint32_t, uint32_t>(30005, 33041), 1011 },
{ std::make_tuple<uint32_t, uint32_t>(20132, 36890), 1010 },
{ std::make_tuple<uint32_t, uint32_t>(27743, 12289), 1010 },
{ std::make_tuple<uint32_t, uint32_t>(19976, 20056), 1009 },
{ std::make_tuple<uint32_t, uint32_t>(20122, 30340), 1008 },
{ std::make_tuple<uint32_t, uint32_t>(35199, 20221), 1008 },
{ std::make_tuple<uint32_t, uint32_t>(20309, 30340), 1007 },
{ std::make_tuple<uint32_t, uint32_t>(25104, 65292), 1007 },
{ std::make_tuple<uint32_t, uint32_t>(24076, 33098), 1007 },
{ std::make_tuple<uint32_t, uint32_t>(32, 22823), 1004 },
{ std::make_tuple<uint32_t, uint32_t>(22269, 27665), 1000 },
{ std::make_tuple<uint32_t, uint32_t>(21457, 29616), 998 },
{ std::make_tuple<uint32_t, uint32_t>(65292, 25152), 997 },
{ std::make_tuple<uint32_t, uint32_t>(19981, 29983), 996 },
{ std::make_tuple<uint32_t, uint32_t>(30340, 30005), 996 },
{ std::make_tuple<uint32_t, uint32_t>(19969, 20891), 992 },
{ std::make_tuple<uint32_t, uint32_t>(20182, 20204), 991 },
{ std::make_tuple<uint32_t, uint32_t>(21518, 26469), 990 },
{ std::make_tuple<uint32_t, uint32_t>(22269, 20154), 990 },
{ std::make_tuple<uint32_t, uint32_t>(23567, 19976), 990 },
{ std::make_tuple<uint32_t, uint32_t>(20316, 23478), 983 },
{ std::make_tuple<uint32_t, uint32_t>(20250, 65288), 981 },
{ std::make_tuple<uint32_t, uint32_t>(20122, 27954), 979 },
{ std::make_tuple<uint32_t, uint32_t>(65292, 33521), 974 },
{ std::make_tuple<uint32_t, uint32_t>(27743, 35199), 972 },
{ std::make_tuple<uint32_t, uint32_t>(29983, 20135), 971 },
{ std::make_tuple<uint32_t, uint32_t>(32, 25110), 968 },
{ std::make_tuple<uint32_t, uint32_t>(20225, 19994), 965 },
{ std::make_tuple<uint32_t, uint32_t>(26368, 39640), 965 },
{ std::make_tuple<uint32_t, uint32_t>(65292, 22914), 965 },
{ std::make_tuple<uint32_t, uint32_t>(21487, 33021), 964 },
{ std::make_tuple<uint32_t, uint32_t>(19976, 23398), 961 },
{ std::make_tuple<uint32_t, uint32_t>(20004, 20010), 961 },
{ std::make_tuple<uint32_t, uint32_t>(20154, 29289), 960 },
{ std::make_tuple<uint32_t, uint32_t>(20998, 21035), 959 },
{ std::make_tuple<uint32_t, uint32_t>(12289, 20013), 959 },
{ std::make_tuple<uint32_t, uint32_t>(19969, 183), 957 },
{ std::make_tuple<uint32_t, uint32_t>(24212, 29992), 955 },
{ std::make_tuple<uint32_t, uint32_t>(183, 19969), 954 },
{ std::make_tuple<uint32_t, uint32_t>(36234, 21335), 953 },
{ std::make_tuple<uint32_t, uint32_t>(20026, 19969), 953 },
{ std::make_tuple<uint32_t, uint32_t>(20135, 29983), 952 },
{ std::make_tuple<uint32_t, uint32_t>(65289, 21644), 952 },
{ std::make_tuple<uint32_t, uint32_t>(20026, 19968), 949 },
{ std::make_tuple<uint32_t, uint32_t>(19989, 19976), 949 },
{ std::make_tuple<uint32_t, uint32_t>(19981, 20107), 949 },
{ std::make_tuple<uint32_t, uint32_t>(19968, 27425), 948 },
{ std::make_tuple<uint32_t, uint32_t>(19976, 23646), 948 },
{ std::make_tuple<uint32_t, uint32_t>(20241, 20351), 948 },
{ std::make_tuple<uint32_t, uint32_t>(31435, 65292), 948 },
{ std::make_tuple<uint32_t, uint32_t>(23601, 26159), 947 },
{ std::make_tuple<uint32_t, uint32_t>(19979, 65292), 946 },
{ std::make_tuple<uint32_t, uint32_t>(20122, 183), 946 },
{ std::make_tuple<uint32_t, uint32_t>(20154, 19969), 945 },
{ std::make_tuple<uint32_t, uint32_t>(23478, 32), 943 },
{ std::make_tuple<uint32_t, uint32_t>(20182, 30340), 941 },
{ std::make_tuple<uint32_t, uint32_t>(12290, 19969), 940 },
{ std::make_tuple<uint32_t, uint32_t>(20154, 31867), 940 },
{ std::make_tuple<uint32_t, uint32_t>(26377, 26893), 939 },
{ std::make_tuple<uint32_t, uint32_t>(26519, 20013), 937 },
{ std::make_tuple<uint32_t, uint32_t>(20351, 19969), 935 },
{ std::make_tuple<uint32_t, uint32_t>(20056, 30340), 934 },
{ std::make_tuple<uint32_t, uint32_t>(21335, 19981), 934 },
{ std::make_tuple<uint32_t, uint32_t>(20351, 20848), 933 },
{ std::make_tuple<uint32_t, uint32_t>(23376, 65292), 932 },
{ std::make_tuple<uint32_t, uint32_t>(23398, 29983), 932 },
{ std::make_tuple<uint32_t, uint32_t>(20154, 38395), 930 },
{ std::make_tuple<uint32_t, uint32_t>(12290, 30001), 929 },
{ std::make_tuple<uint32_t, uint32_t>(32, 19989), 929 },
{ std::make_tuple<uint32_t, uint32_t>(31859, 65292), 928 },
{ std::make_tuple<uint32_t, uint32_t>(19976, 19989), 925 },
{ std::make_tuple<uint32_t, uint32_t>(19981, 20844), 924 },
{ std::make_tuple<uint32_t, uint32_t>(20110, 39321), 923 },
{ std::make_tuple<uint32_t, uint32_t>(33410, 30446), 923 },
{ std::make_tuple<uint32_t, uint32_t>(28595, 38376), 921 },
{ std::make_tuple<uint32_t, uint32_t>(36825, 20123), 921 },
{ std::make_tuple<uint32_t, uint32_t>(20056, 19976), 920 },
{ std::make_tuple<uint32_t, uint32_t>(32, 20241), 920 },
{ std::make_tuple<uint32_t, uint32_t>(21516, 30340), 919 },
{ std::make_tuple<uint32_t, uint32_t>(65292, 20132), 917 },
{ std::make_tuple<uint32_t, uint32_t>(26368, 21518), 916 },
{ std::make_tuple<uint32_t, uint32_t>(23398, 30340), 914 },
{ std::make_tuple<uint32_t, uint32_t>(38382, 39064), 913 },
{ std::make_tuple<uint32_t, uint32_t>(19979, 30340), 912 },
{ std::make_tuple<uint32_t, uint32_t>(20122, 19969), 910 },
{ std::make_tuple<uint32_t, uint32_t>(21517, 12290), 910 },
{ std::make_tuple<uint32_t, uint32_t>(12289, 20154), 909 },
{ std::make_tuple<uint32_t, uint32_t>(21152, 20056), 908 },
{ std::make_tuple<uint32_t, uint32_t>(21333, 20301), 907 },
{ std::make_tuple<uint32_t, uint32_t>(19969, 26031), 907 },
{ std::make_tuple<uint32_t, uint32_t>(26469, 33258), 905 },
{ std::make_tuple<uint32_t, uint32_t>(22788, 29702), 904 },
{ std::make_tuple<uint32_t, uint32_t>(21496, 65292), 904 },
{ std::make_tuple<uint32_t, uint32_t>(20351, 19978), 903 },
{ std::make_tuple<uint32_t, uint32_t>(20026, 20102), 902 },
{ std::make_tuple<uint32_t, uint32_t>(30340, 12290), 902 },
{ std::make_tuple<uint32_t, uint32_t>(23433, 19969), 901 },
{ std::make_tuple<uint32_t, uint32_t>(12298, 19976), 900 },
{ std::make_tuple<uint32_t, uint32_t>(22312, 19969), 899 },
{ std::make_tuple<uint32_t, uint32_t>(29616, 20195), 899 },
{ std::make_tuple<uint32_t, uint32_t>(27665, 20027), 899 },
{ std::make_tuple<uint32_t, uint32_t>(20241, 65288), 899 },
{ std::make_tuple<uint32_t, uint32_t>(20256, 32479), 899 },
{ std::make_tuple<uint32_t, uint32_t>(20445, 25252), 898 },
{ std::make_tuple<uint32_t, uint32_t>(65292, 21516), 895 },
{ std::make_tuple<uint32_t, uint32_t>(32, 23567), 894 },
{ std::make_tuple<uint32_t, uint32_t>(20154, 20351), 892 },
{ std::make_tuple<uint32_t, uint32_t>(29615, 22659), 892 },
{ std::make_tuple<uint32_t, uint32_t>(19968, 24231), 888 },
{ std::make_tuple<uint32_t, uint32_t>(29699, 38431), 888 },
{ std::make_tuple<uint32_t, uint32_t>(21069, 32), 886 },
{ std::make_tuple<uint32_t, uint32_t>(65292, 24403), 886 },
{ std::make_tuple<uint32_t, uint32_t>(20869, 20449), 885 },
{ std::make_tuple<uint32_t, uint32_t>(65292, 36890), 884 },
{ std::make_tuple<uint32_t, uint32_t>(20107, 30340), 883 },
{ std::make_tuple<uint32_t, uint32_t>(23478, 65288), 883 },
{ std::make_tuple<uint32_t, uint32_t>(65292, 20154), 883 },
{ std::make_tuple<uint32_t, uint32_t>(65292, 20174), 880 },
{ std::make_tuple<uint32_t, uint32_t>(26031, 29305), 879 },
{ std::make_tuple<uint32_t, uint32_t>(38134, 34892), 879 },
{ std::make_tuple<uint32_t, uint32_t>(20316, 65292), 878 },
{ std::make_tuple<uint32_t, uint32_t>(33258, 30001), 876 },
{ std::make_tuple<uint32_t, uint32_t>(22768, 20219), 875 },
{ std::make_tuple<uint32_t, uint32_t>(19969, 20056), 875 },
{ std::make_tuple<uint32_t, uint32_t>(21448, 21517), 874 },
{ std::make_tuple<uint32_t, uint32_t>(24052, 20351), 874 },
{ std::make_tuple<uint32_t, uint32_t>(32852, 36187), 872 },
{ std::make_tuple<uint32_t, uint32_t>(36335, 32447), 871 },
{ std::make_tuple<uint32_t, uint32_t>(22823, 19976), 869 },
{ std::make_tuple<uint32_t, uint32_t>(25968, 25454), 868 },
{ std::make_tuple<uint32_t, uint32_t>(26031, 22374), 867 },
{ std::make_tuple<uint32_t, uint32_t>(26519, 19979), 866 },
{ std::make_tuple<uint32_t, uint32_t>(30340, 20056), 866 },
{ std::make_tuple<uint32_t, uint32_t>(65292, 20998), 865 },
{ std::make_tuple<uint32_t, uint32_t>(39640, 36895), 865 },
{ std::make_tuple<uint32_t, uint32_t>(12289, 36149), 865 },
{ std::make_tuple<uint32_t, uint32_t>(20056, 19995), 864 },
{ std::make_tuple<uint32_t, uint32_t>(24037, 19994), 864 },
{ std::make_tuple<uint32_t, uint32_t>(26368, 26089), 864 },
{ std::make_tuple<uint32_t, uint32_t>(65292, 34987), 862 },
{ std::make_tuple<uint32_t, uint32_t>(25110, 32773), 862 },
{ std::make_tuple<uint32_t, uint32_t>(12289, 21360), 861 },
{ std::make_tuple<uint32_t, uint32_t>(65292, 19996), 861 },
{ std::make_tuple<uint32_t, uint32_t>(19976, 23376), 859 },
{ std::make_tuple<uint32_t, uint32_t>(21306, 12289), 855 },
{ std::make_tuple<uint32_t, uint32_t>(27827, 21335), 853 },
{ std::make_tuple<uint32_t, uint32_t>(20250, 65292), 853 },
{ std::make_tuple<uint32_t, uint32_t>(19996, 21335), 852 },
{ std::make_tuple<uint32_t, uint32_t>(32, 21644), 850 },
{ std::make_tuple<uint32_t, uint32_t>(23478, 19969), 849 },
{ std::make_tuple<uint32_t, uint32_t>(36335, 65292), 847 },
{ std::make_tuple<uint32_t, uint32_t>(32654, 27954), 847 },
{ std::make_tuple<uint32_t, uint32_t>(24182, 19969), 847 },
{ std::make_tuple<uint32_t, uint32_t>(36127, 36131), 846 },
{ std::make_tuple<uint32_t, uint32_t>(21629, 21517), 845 },
{ std::make_tuple<uint32_t, uint32_t>(65292, 20221), 844 },
{ std::make_tuple<uint32_t, uint32_t>(25152, 20197), 844 },
{ std::make_tuple<uint32_t, uint32_t>(29983, 27963), 843 },
{ std::make_tuple<uint32_t, uint32_t>(29983, 30340), 842 },
{ std::make_tuple<uint32_t, uint32_t>(24418, 24335), 842 },
{ std::make_tuple<uint32_t, uint32_t>(65292, 23646), 841 },
{ std::make_tuple<uint32_t, uint32_t>(25925, 20107), 840 },
{ std::make_tuple<uint32_t, uint32_t>(31561, 65292), 840 },
{ std::make_tuple<uint32_t, uint32_t>(21270, 23398), 839 },
{ std::make_tuple<uint32_t, uint32_t>(22320, 12289), 838 },
{ std::make_tuple<uint32_t, uint32_t>(20998, 20026), 837 },
{ std::make_tuple<uint32_t, uint32_t>(20241, 22914), 834 },
{ std::make_tuple<uint32_t, uint32_t>(12289, 29976), 833 },
{ std::make_tuple<uint32_t, uint32_t>(65292, 35199), 833 },
{ std::make_tuple<uint32_t, uint32_t>(23384, 22312), 833 },
{ std::make_tuple<uint32_t, uint32_t>(19968, 23478), 830 },
{ std::make_tuple<uint32_t, uint32_t>(20107, 12290), 826 },
{ std::make_tuple<uint32_t, uint32_t>(20316, 30340), 824 },
{ std::make_tuple<uint32_t, uint32_t>(20869, 19969), 823 },
{ std::make_tuple<uint32_t, uint32_t>(65293, 32), 821 },
{ std::make_tuple<uint32_t, uint32_t>(20061, 40857), 820 },
{ std::make_tuple<uint32_t, uint32_t>(24052, 20056), 819 },
{ std::make_tuple<uint32_t, uint32_t>(25110, 32), 819 },
{ std::make_tuple<uint32_t, uint32_t>(20221, 22260), 818 },
{ std::make_tuple<uint32_t, uint32_t>(26469, 30340), 817 },
{ std::make_tuple<uint32_t, uint32_t>(20056, 19969), 814 },
{ std::make_tuple<uint32_t, uint32_t>(26399, 30340), 814 },
{ std::make_tuple<uint32_t, uint32_t>(20122, 20122), 814 },
{ std::make_tuple<uint32_t, uint32_t>(26085, 65289), 813 },
{ std::make_tuple<uint32_t, uint32_t>(22269, 12289), 813 },
{ std::make_tuple<uint32_t, uint32_t>(32, 21488), 812 },
{ std::make_tuple<uint32_t, uint32_t>(32, 33521), 812 },
{ std::make_tuple<uint32_t, uint32_t>(32467, 26500), 811 },
{ std::make_tuple<uint32_t, uint32_t>(21019, 31435), 811 },
{ std::make_tuple<uint32_t, uint32_t>(27827, 19981), 810 },
{ std::make_tuple<uint32_t, uint32_t>(20307, 32946), 809 },
{ std::make_tuple<uint32_t, uint32_t>(24180, 33267), 809 },
{ std::make_tuple<uint32_t, uint32_t>(19976, 26519), 809 },
{ std::make_tuple<uint32_t, uint32_t>(24050, 32463), 808 },
{ std::make_tuple<uint32_t, uint32_t>(27743, 33487), 807 },
{ std::make_tuple<uint32_t, uint32_t>(19969, 25945), 806 },
{ std::make_tuple<uint32_t, uint32_t>(21306, 12290), 806 },
{ std::make_tuple<uint32_t, uint32_t>(21517, 65292), 804 },
{ std::make_tuple<uint32_t, uint32_t>(25991, 20351), 804 },
{ std::make_tuple<uint32_t, uint32_t>(65292, 22823), 803 },
{ std::make_tuple<uint32_t, uint32_t>(26031, 19969), 803 },
{ std::make_tuple<uint32_t, uint32_t>(12299, 26159), 802 },
{ std::make_tuple<uint32_t, uint32_t>(29677, 19969), 801 },
{ std::make_tuple<uint32_t, uint32_t>(32463, 33829), 801 },
{ std::make_tuple<uint32_t, uint32_t>(32899, 12289), 800 },
{ std::make_tuple<uint32_t, uint32_t>(12289, 38485), 800 },
{ std::make_tuple<uint32_t, uint32_t>(20013, 12289), 800 },
{ std::make_tuple<uint32_t, uint32_t>(21495, 65292), 798 },
{ std::make_tuple<uint32_t, uint32_t>(36825, 20122), 795 },
{ std::make_tuple<uint32_t, uint32_t>(30340, 21517), 795 },
{ std::make_tuple<uint32_t, uint32_t>(27515, 20851), 792 },
{ std::make_tuple<uint32_t, uint32_t>(21830, 19994), 792 },
{ std::make_tuple<uint32_t, uint32_t>(36807, 31243), 791 },
{ std::make_tuple<uint32_t, uint32_t>(33258, 28982), 791 },
{ std::make_tuple<uint32_t, uint32_t>(31215, 32), 789 },
{ std::make_tuple<uint32_t, uint32_t>(65292, 23567), 789 },
{ std::make_tuple<uint32_t, uint32_t>(19969, 20081), 789 },
{ std::make_tuple<uint32_t, uint32_t>(33258, 19969), 786 },
{ std::make_tuple<uint32_t, uint32_t>(19976, 26159), 785 },
{ std::make_tuple<uint32_t, uint32_t>(24418, 25104), 784 },
{ std::make_tuple<uint32_t, uint32_t>(20351, 20241), 784 },
{ std::make_tuple<uint32_t, uint32_t>(23450, 30340), 781 },
{ std::make_tuple<uint32_t, uint32_t>(20132, 12290), 780 },
{ std::make_tuple<uint32_t, uint32_t>(22825, 20027), 779 },
{ std::make_tuple<uint32_t, uint32_t>(20844, 20849), 779 },
{ std::make_tuple<uint32_t, uint32_t>(37096, 20221), 779 },
{ std::make_tuple<uint32_t, uint32_t>(19969, 20316), 779 },
{ std::make_tuple<uint32_t, uint32_t>(24503, 183), 778 },
{ std::make_tuple<uint32_t, uint32_t>(20351, 65288), 777 },
{ std::make_tuple<uint32_t, uint32_t>(25512, 19981), 777 },
{ std::make_tuple<uint32_t, uint32_t>(65292, 31532), 777 },
{ std::make_tuple<uint32_t, uint32_t>(24180, 22312), 775 },
{ std::make_tuple<uint32_t, uint32_t>(29992, 26469), 773 },
{ std::make_tuple<uint32_t, uint32_t>(35199, 29677), 773 },
{ std::make_tuple<uint32_t, uint32_t>(29992, 65292), 772 },
{ std::make_tuple<uint32_t, uint32_t>(34892, 12290), 771 },
{ std::make_tuple<uint32_t, uint32_t>(183, 19976), 771 },
{ std::make_tuple<uint32_t, uint32_t>(32, 20081), 770 },
{ std::make_tuple<uint32_t, uint32_t>(21160, 65292), 770 },
{ std::make_tuple<uint32_t, uint32_t>(19969, 26159), 769 },
{ std::make_tuple<uint32_t, uint32_t>(20135, 21697), 768 },
{ std::make_tuple<uint32_t, uint32_t>(20132, 20241), 767 },
{ std::make_tuple<uint32_t, uint32_t>(19976, 19998), 767 },
{ std::make_tuple<uint32_t, uint32_t>(22312, 19981), 766 },
{ std::make_tuple<uint32_t, uint32_t>(20250, 35758), 766 },
{ std::make_tuple<uint32_t, uint32_t>(25945, 20241), 765 },
{ std::make_tuple<uint32_t, uint32_t>(24191, 24030), 765 },
{ std::make_tuple<uint32_t, uint32_t>(30340, 12298), 764 },
{ std::make_tuple<uint32_t, uint32_t>(20110, 26085), 763 },
{ std::make_tuple<uint32_t, uint32_t>(25968, 23398), 761 },
{ std::make_tuple<uint32_t, uint32_t>(38463, 25289), 760 },
{ std::make_tuple<uint32_t, uint32_t>(12290, 27492), 760 },
{ std::make_tuple<uint32_t, uint32_t>(32773, 65292), 759 },
{ std::make_tuple<uint32_t, uint32_t>(19976, 23665), 758 },
{ std::make_tuple<uint32_t, uint32_t>(32, 20056), 758 },
{ std::make_tuple<uint32_t, uint32_t>(33609, 22320), 757 },
{ std::make_tuple<uint32_t, uint32_t>(21450, 32), 757 },
{ std::make_tuple<uint32_t, uint32_t>(65292, 20849), 756 },
{ std::make_tuple<uint32_t, uint32_t>(21517, 20351), 755 },
{ std::make_tuple<uint32_t, uint32_t>(20132, 30340), 754 },
{ std::make_tuple<uint32_t, uint32_t>(30340, 37325), 753 },
{ std::make_tuple<uint32_t, uint32_t>(20250, 30340), 752 },
{ std::make_tuple<uint32_t, uint32_t>(20840, 29699), 752 },
{ std::make_tuple<uint32_t, uint32_t>(20221, 65292), 752 },
{ std::make_tuple<uint32_t, uint32_t>(20122, 65288), 751 },
{ std::make_tuple<uint32_t, uint32_t>(65292, 21488), 750 },
{ std::make_tuple<uint32_t, uint32_t>(24635, 32479), 750 },
{ std::make_tuple<uint32_t, uint32_t>(25552, 19981), 749 },
{ std::make_tuple<uint32_t, uint32_t>(26159, 26085), 749 },
{ std::make_tuple<uint32_t, uint32_t>(23665, 19996), 748 },
{ std::make_tuple<uint32_t, uint32_t>(35199, 21335), 748 },
{ std::make_tuple<uint32_t, uint32_t>(26519, 19976), 747 },
{ std::make_tuple<uint32_t, uint32_t>(65292, 24635), 746 },
{ std::make_tuple<uint32_t, uint32_t>(29983, 22312), 746 },
{ std::make_tuple<uint32_t, uint32_t>(65288, 19976), 745 },
{ std::make_tuple<uint32_t, uint32_t>(21442, 19982), 744 },
{ std::make_tuple<uint32_t, uint32_t>(32, 20998), 744 },
{ std::make_tuple<uint32_t, uint32_t>(19981, 12290), 742 },
{ std::make_tuple<uint32_t, uint32_t>(12290, 20056), 742 },
{ std::make_tuple<uint32_t, uint32_t>(26377, 30340), 742 },
{ std::make_tuple<uint32_t, uint32_t>(22269, 29579), 741 },
{ std::make_tuple<uint32_t, uint32_t>(20294, 26159), 741 },
{ std::make_tuple<uint32_t, uint32_t>(30340, 26368), 739 },
{ std::make_tuple<uint32_t, uint32_t>(20026, 21488), 739 },
{ std::make_tuple<uint32_t, uint32_t>(22269, 32), 738 },
{ std::make_tuple<uint32_t, uint32_t>(20056, 19968), 737 },
{ std::make_tuple<uint32_t, uint32_t>(39033, 30446), 737 },
{ std::make_tuple<uint32_t, uint32_t>(21046, 36896), 737 },
{ std::make_tuple<uint32_t, uint32_t>(21306, 22495), 737 },
{ std::make_tuple<uint32_t, uint32_t>(26376, 65292), 734 },
{ std::make_tuple<uint32_t, uint32_t>(20309, 33021), 734 },
{ std::make_tuple<uint32_t, uint32_t>(36873, 20030), 733 },
{ std::make_tuple<uint32_t, uint32_t>(32, 20122), 733 },
{ std::make_tuple<uint32_t, uint32_t>(65306, 65292), 733 },
{ std::make_tuple<uint32_t, uint32_t>(29992, 12290), 732 },
{ std::make_tuple<uint32_t, uint32_t>(22269, 19969), 732 },
{ std::make_tuple<uint32_t, uint32_t>(32, 20309), 732 },
{ std::make_tuple<uint32_t, uint32_t>(21253, 21547), 732 },
{ std::make_tuple<uint32_t, uint32_t>(20081, 65292), 730 },
{ std::make_tuple<uint32_t, uint32_t>(21450, 19976), 729 },
{ std::make_tuple<uint32_t, uint32_t>(33258, 32), 728 },
{ std::make_tuple<uint32_t, uint32_t>(32447, 30340), 727 },
{ std::make_tuple<uint32_t, uint32_t>(38081, 23478), 726 },
{ std::make_tuple<uint32_t, uint32_t>(33258, 27835), 726 },
{ std::make_tuple<uint32_t, uint32_t>(36164, 26009), 726 },
{ std::make_tuple<uint32_t, uint32_t>(21019, 20316), 725 },
{ std::make_tuple<uint32_t, uint32_t>(26159, 19981), 724 },
{ std::make_tuple<uint32_t, uint32_t>(21407, 21517), 724 },
{ std::make_tuple<uint32_t, uint32_t>(21508, 20122), 724 },
{ std::make_tuple<uint32_t, uint32_t>(24120, 29983), 724 },
{ std::make_tuple<uint32_t, uint32_t>(65292, 21335), 723 },
{ std::make_tuple<uint32_t, uint32_t>(20132, 19981), 722 },
{ std::make_tuple<uint32_t, uint32_t>(65292, 39321), 721 },
{ std::make_tuple<uint32_t, uint32_t>(19976, 36710), 720 },
{ std::make_tuple<uint32_t, uint32_t>(19968, 25152), 719 },
{ std::make_tuple<uint32_t, uint32_t>(20221, 12289), 719 },
{ std::make_tuple<uint32_t, uint32_t>(20309, 29992), 717 },
{ std::make_tuple<uint32_t, uint32_t>(21322, 23707), 715 },
{ std::make_tuple<uint32_t, uint32_t>(20063, 26377), 715 },
{ std::make_tuple<uint32_t, uint32_t>(22826, 24179), 714 },
{ std::make_tuple<uint32_t, uint32_t>(32, 22269), 713 },
{ std::make_tuple<uint32_t, uint32_t>(19976, 22320), 713 },
{ std::make_tuple<uint32_t, uint32_t>(23478, 19976), 713 },
{ std::make_tuple<uint32_t, uint32_t>(23427, 26159), 712 },
{ std::make_tuple<uint32_t, uint32_t>(39532, 26469), 712 },
{ std::make_tuple<uint32_t, uint32_t>(19995, 20013), 711 },
{ std::make_tuple<uint32_t, uint32_t>(20849, 21516), 711 },
{ std::make_tuple<uint32_t, uint32_t>(24335, 65292), 710 },
{ std::make_tuple<uint32_t, uint32_t>(21069, 36523), 709 },
{ std::make_tuple<uint32_t, uint32_t>(20811, 26031), 708 },
{ std::make_tuple<uint32_t, uint32_t>(20154, 19976), 706 },
{ std::make_tuple<uint32_t, uint32_t>(20108, 21313), 706 },
{ std::make_tuple<uint32_t, uint32_t>(39046, 22495), 706 },
{ std::make_tuple<uint32_t, uint32_t>(21496, 65288), 706 },
{ std::make_tuple<uint32_t, uint32_t>(23545, 20110), 704 },
{ std::make_tuple<uint32_t, uint32_t>(20056, 65292), 704 },
{ std::make_tuple<uint32_t, uint32_t>(37117, 26159), 704 },
{ std::make_tuple<uint32_t, uint32_t>(22269, 65292), 704 },
{ std::make_tuple<uint32_t, uint32_t>(20107, 22330), 701 },
{ std::make_tuple<uint32_t, uint32_t>(29289, 29702), 701 },
{ std::make_tuple<uint32_t, uint32_t>(32426, 24565), 701 },
{ std::make_tuple<uint32_t, uint32_t>(23665, 35199), 700 },
{ std::make_tuple<uint32_t, uint32_t>(20891, 20107), 699 },
{ std::make_tuple<uint32_t, uint32_t>(20449, 24687), 699 },
{ std::make_tuple<uint32_t, uint32_t>(20869, 30340), 698 },
{ std::make_tuple<uint32_t, uint32_t>(20849, 26377), 696 },
{ std::make_tuple<uint32_t, uint32_t>(23398, 65288), 696 },
{ std::make_tuple<uint32_t, uint32_t>(19968, 19976), 695 },
{ std::make_tuple<uint32_t, uint32_t>(22269, 19976), 695 },
{ std::make_tuple<uint32_t, uint32_t>(20998, 65292), 694 },
{ std::make_tuple<uint32_t, uint32_t>(19976, 20043), 694 },
{ std::make_tuple<uint32_t, uint32_t>(26159, 21488), 693 },
{ std::make_tuple<uint32_t, uint32_t>(20998, 31867), 693 },
{ std::make_tuple<uint32_t, uint32_t>(35828, 65292), 693 },
{ std::make_tuple<uint32_t, uint32_t>(21033, 29992), 693 },
{ std::make_tuple<uint32_t, uint32_t>(22242, 20307), 692 },
{ std::make_tuple<uint32_t, uint32_t>(32, 39321), 692 },
{ std::make_tuple<uint32_t, uint32_t>(19976, 20854), 691 },
{ std::make_tuple<uint32_t, uint32_t>(20316, 29992), 691 },
{ std::make_tuple<uint32_t, uint32_t>(20301, 65292), 691 },
{ std::make_tuple<uint32_t, uint32_t>(20154, 20056), 690 },
{ std::make_tuple<uint32_t, uint32_t>(22522, 30784), 690 },
{ std::make_tuple<uint32_t, uint32_t>(65292, 12298), 690 },
{ std::make_tuple<uint32_t, uint32_t>(24314, 20110), 690 },
{ std::make_tuple<uint32_t, uint32_t>(36187, 65292), 689 },
{ std::make_tuple<uint32_t, uint32_t>(12289, 21488), 689 },
{ std::make_tuple<uint32_t, uint32_t>(38750, 27954), 689 },
{ std::make_tuple<uint32_t, uint32_t>(20027, 24109), 689 },
{ std::make_tuple<uint32_t, uint32_t>(21442, 21152), 688 },
{ std::make_tuple<uint32_t, uint32_t>(20122, 12290), 687 },
{ std::make_tuple<uint32_t, uint32_t>(21453, 24212), 687 },
{ std::make_tuple<uint32_t, uint32_t>(25511, 21046), 687 },
{ std::make_tuple<uint32_t, uint32_t>(33324, 29983), 684 },
{ std::make_tuple<uint32_t, uint32_t>(26368, 19976), 683 },
{ std::make_tuple<uint32_t, uint32_t>(24503, 20122), 680 },
{ std::make_tuple<uint32_t, uint32_t>(12289, 31119), 680 },
{ std::make_tuple<uint32_t, uint32_t>(35268, 20221), 679 },
{ std::make_tuple<uint32_t, uint32_t>(30340, 20309), 678 },
{ std::make_tuple<uint32_t, uint32_t>(32447, 65292), 677 },
{ std::make_tuple<uint32_t, uint32_t>(19969, 36817), 677 },
{ std::make_tuple<uint32_t, uint32_t>(32, 21517), 675 },
{ std::make_tuple<uint32_t, uint32_t>(26085, 22312), 675 },
{ std::make_tuple<uint32_t, uint32_t>(25104, 12290), 674 },
{ std::make_tuple<uint32_t, uint32_t>(20998, 19969), 674 },
{ std::make_tuple<uint32_t, uint32_t>(24191, 22330), 674 },
{ std::make_tuple<uint32_t, uint32_t>(35774, 31435), 673 },
{ std::make_tuple<uint32_t, uint32_t>(25104, 20309), 673 },
{ std::make_tuple<uint32_t, uint32_t>(19982, 19976), 673 },
{ std::make_tuple<uint32_t, uint32_t>(27605, 19994), 667 },
{ std::make_tuple<uint32_t, uint32_t>(38271, 32), 666 },
{ std::make_tuple<uint32_t, uint32_t>(65288, 20170), 666 },
{ std::make_tuple<uint32_t, uint32_t>(32780, 25104), 666 },
{ std::make_tuple<uint32_t, uint32_t>(32, 38463), 664 },
{ std::make_tuple<uint32_t, uint32_t>(22522, 26412), 664 },
{ std::make_tuple<uint32_t, uint32_t>(20221, 24180), 663 },
{ std::make_tuple<uint32_t, uint32_t>(65292, 21069), 662 },
{ std::make_tuple<uint32_t, uint32_t>(21450, 20854), 661 },
{ std::make_tuple<uint32_t, uint32_t>(32676, 23707), 661 },
{ std::make_tuple<uint32_t, uint32_t>(36830, 25509), 661 },
{ std::make_tuple<uint32_t, uint32_t>(65292, 27492), 660 },
{ std::make_tuple<uint32_t, uint32_t>(19976, 183), 660 },
{ std::make_tuple<uint32_t, uint32_t>(19969, 25991), 660 },
{ std::make_tuple<uint32_t, uint32_t>(22330, 65292), 659 },
{ std::make_tuple<uint32_t, uint32_t>(22659, 20869), 659 },
{ std::make_tuple<uint32_t, uint32_t>(21697, 65292), 659 },
{ std::make_tuple<uint32_t, uint32_t>(12299, 32), 659 },
{ std::make_tuple<uint32_t, uint32_t>(21448, 35793), 658 },
{ std::make_tuple<uint32_t, uint32_t>(19981, 20241), 658 },
{ std::make_tuple<uint32_t, uint32_t>(20241, 30011), 658 },
{ std::make_tuple<uint32_t, uint32_t>(29579, 26397), 657 },
{ std::make_tuple<uint32_t, uint32_t>(20219, 20309), 656 },
{ std::make_tuple<uint32_t, uint32_t>(28304, 20110), 655 },
{ std::make_tuple<uint32_t, uint32_t>(20351, 26412), 654 },
{ std::make_tuple<uint32_t, uint32_t>(21160, 30011), 653 },
{ std::make_tuple<uint32_t, uint32_t>(35793, 20026), 652 },
{ std::make_tuple<uint32_t, uint32_t>(22312, 21488), 652 },
{ std::make_tuple<uint32_t, uint32_t>(24191, 20056), 652 },
{ std::make_tuple<uint32_t, uint32_t>(20250, 32), 652 },
{ std::make_tuple<uint32_t, uint32_t>(23567, 37117), 652 },
{ std::make_tuple<uint32_t, uint32_t>(20030, 21150), 651 },
{ std::make_tuple<uint32_t, uint32_t>(32, 22810), 650 },
{ std::make_tuple<uint32_t, uint32_t>(20309, 25104), 650 },
{ std::make_tuple<uint32_t, uint32_t>(36229, 36807), 649 },
{ std::make_tuple<uint32_t, uint32_t>(20013, 19968), 647 },
{ std::make_tuple<uint32_t, uint32_t>(30001, 32), 647 },
{ std::make_tuple<uint32_t, uint32_t>(32, 20043), 647 },
{ std::make_tuple<uint32_t, uint32_t>(21307, 23398), 647 },
{ std::make_tuple<uint32_t, uint32_t>(32, 19968), 646 },
{ std::make_tuple<uint32_t, uint32_t>(24230, 12289), 646 },
{ std::make_tuple<uint32_t, uint32_t>(23478, 20122), 645 },
{ std::make_tuple<uint32_t, uint32_t>(65292, 25925), 644 },
{ std::make_tuple<uint32_t, uint32_t>(19996, 30465), 644 },
{ std::make_tuple<uint32_t, uint32_t>(21019, 21150), 644 },
{ std::make_tuple<uint32_t, uint32_t>(25110, 31216), 642 },
{ std::make_tuple<uint32_t, uint32_t>(19976, 20107), 642 },
{ std::make_tuple<uint32_t, uint32_t>(34892, 20026), 642 },
{ std::make_tuple<uint32_t, uint32_t>(21644, 19969), 641 },
{ std::make_tuple<uint32_t, uint32_t>(20102, 32), 641 },
{ std::make_tuple<uint32_t, uint32_t>(23478, 24459), 640 },
{ std::make_tuple<uint32_t, uint32_t>(22823, 25112), 639 },
{ std::make_tuple<uint32_t, uint32_t>(30340, 23478), 638 },
{ std::make_tuple<uint32_t, uint32_t>(65292, 29992), 638 },
{ std::make_tuple<uint32_t, uint32_t>(19976, 22823), 637 },
{ std::make_tuple<uint32_t, uint32_t>(19976, 21644), 636 },
{ std::make_tuple<uint32_t, uint32_t>(19987, 36753), 636 },
{ std::make_tuple<uint32_t, uint32_t>(19976, 33267), 636 },
{ std::make_tuple<uint32_t, uint32_t>(36798, 32), 635 },
{ std::make_tuple<uint32_t, uint32_t>(12289, 26085), 634 },
{ std::make_tuple<uint32_t, uint32_t>(26377, 19976), 634 },
{ std::make_tuple<uint32_t, uint32_t>(23427, 30340), 633 },
{ std::make_tuple<uint32_t, uint32_t>(19969, 24215), 632 },
{ std::make_tuple<uint32_t, uint32_t>(19976, 20132), 632 },
{ std::make_tuple<uint32_t, uint32_t>(36187, 20107), 631 },
{ std::make_tuple<uint32_t, uint32_t>(20197, 32), 631 },
{ std::make_tuple<uint32_t, uint32_t>(19969, 22320), 630 },
{ std::make_tuple<uint32_t, uint32_t>(27969, 34892), 630 },
{ std::make_tuple<uint32_t, uint32_t>(30340, 35199), 629 },
{ std::make_tuple<uint32_t, uint32_t>(19976, 20026), 629 },
{ std::make_tuple<uint32_t, uint32_t>(20107, 21153), 628 },
{ std::make_tuple<uint32_t, uint32_t>(27010, 24565), 628 },
{ std::make_tuple<uint32_t, uint32_t>(36164, 35759), 628 },
{ std::make_tuple<uint32_t, uint32_t>(30340, 20081), 628 },
{ std::make_tuple<uint32_t, uint32_t>(31449, 12290), 627 },
{ std::make_tuple<uint32_t, uint32_t>(26159, 20301), 626 },
{ std::make_tuple<uint32_t, uint32_t>(20026, 26159), 626 },
{ std::make_tuple<uint32_t, uint32_t>(22269, 31435), 626 },
{ std::make_tuple<uint32_t, uint32_t>(38656, 35201), 625 },
{ std::make_tuple<uint32_t, uint32_t>(35199, 37096), 624 },
{ std::make_tuple<uint32_t, uint32_t>(20154, 32), 623 },
{ std::make_tuple<uint32_t, uint32_t>(20309, 19969), 623 },
{ std::make_tuple<uint32_t, uint32_t>(12289, 23433), 622 },
{ std::make_tuple<uint32_t, uint32_t>(22823, 37096), 622 },
{ std::make_tuple<uint32_t, uint32_t>(31185, 25216), 622 },
{ std::make_tuple<uint32_t, uint32_t>(26085, 33267), 621 },
{ std::make_tuple<uint32_t, uint32_t>(30446, 65292), 621 },
{ std::make_tuple<uint32_t, uint32_t>(19981, 20891), 620 },
{ std::make_tuple<uint32_t, uint32_t>(19976, 29699), 620 },
{ std::make_tuple<uint32_t, uint32_t>(25945, 19969), 619 },
{ std::make_tuple<uint32_t, uint32_t>(26102, 30340), 619 },
{ std::make_tuple<uint32_t, uint32_t>(19969, 20848), 618 },
{ std::make_tuple<uint32_t, uint32_t>(30340, 20316), 618 },
{ std::make_tuple<uint32_t, uint32_t>(29983, 65292), 616 },
{ std::make_tuple<uint32_t, uint32_t>(19969, 22823), 616 },
{ std::make_tuple<uint32_t, uint32_t>(23398, 20351), 616 },
{ std::make_tuple<uint32_t, uint32_t>(32479, 27835), 615 },
{ std::make_tuple<uint32_t, uint32_t>(19969, 20811), 614 },
{ std::make_tuple<uint32_t, uint32_t>(20110, 32654), 614 },
{ std::make_tuple<uint32_t, uint32_t>(22788, 65292), 614 },
{ std::make_tuple<uint32_t, uint32_t>(26399, 65292), 613 },
{ std::make_tuple<uint32_t, uint32_t>(20309, 12290), 612 },
{ std::make_tuple<uint32_t, uint32_t>(30452, 25509), 612 },
{ std::make_tuple<uint32_t, uint32_t>(32422, 19976), 612 },
{ std::make_tuple<uint32_t, uint32_t>(32553, 20889), 612 },
{ std::make_tuple<uint32_t, uint32_t>(38463, 20122), 611 },
{ std::make_tuple<uint32_t, uint32_t>(20174, 32), 609 },
{ std::make_tuple<uint32_t, uint32_t>(35282, 33394), 608 },
{ std::make_tuple<uint32_t, uint32_t>(20307, 65292), 607 },
{ std::make_tuple<uint32_t, uint32_t>(39640, 19969), 607 },
{ std::make_tuple<uint32_t, uint32_t>(20195, 30340), 607 },
{ std::make_tuple<uint32_t, uint32_t>(20351, 20013), 607 },
{ std::make_tuple<uint32_t, uint32_t>(21335, 31561), 606 },
{ std::make_tuple<uint32_t, uint32_t>(26377, 20851), 606 },
{ std::make_tuple<uint32_t, uint32_t>(31216, 65292), 606 },
{ std::make_tuple<uint32_t, uint32_t>(23447, 25945), 606 },
{ std::make_tuple<uint32_t, uint32_t>(24180, 38388), 605 },
{ std::make_tuple<uint32_t, uint32_t>(21592, 12290), 605 },
{ std::make_tuple<uint32_t, uint32_t>(26031, 65288), 605 },
{ std::make_tuple<uint32_t, uint32_t>(20110, 23665), 605 },
{ std::make_tuple<uint32_t, uint32_t>(23454, 38469), 605 },
{ std::make_tuple<uint32_t, uint32_t>(19976, 20013), 605 },
{ std::make_tuple<uint32_t, uint32_t>(31449, 65288), 605 },
{ std::make_tuple<uint32_t, uint32_t>(25945, 20250), 604 },
{ std::make_tuple<uint32_t, uint32_t>(30340, 21457), 604 },
{ std::make_tuple<uint32_t, uint32_t>(21270, 30340), 604 },
{ std::make_tuple<uint32_t, uint32_t>(23665, 35895), 602 },
{ std::make_tuple<uint32_t, uint32_t>(12290, 29616), 602 },
{ std::make_tuple<uint32_t, uint32_t>(20122, 20351), 601 },
{ std::make_tuple<uint32_t, uint32_t>(12289, 20241), 601 },
{ std::make_tuple<uint32_t, uint32_t>(32, 23478), 600 },
{ std::make_tuple<uint32_t, uint32_t>(19976, 12299), 600 },
{ std::make_tuple<uint32_t, uint32_t>(24030, 20107), 599 },
{ std::make_tuple<uint32_t, uint32_t>(20351, 20195), 599 },
{ std::make_tuple<uint32_t, uint32_t>(30340, 20122), 598 },
{ std::make_tuple<uint32_t, uint32_t>(65292, 32463), 598 },
{ std::make_tuple<uint32_t, uint32_t>(65292, 32654), 598 },
{ std::make_tuple<uint32_t, uint32_t>(24191, 25773), 596 },
{ std::make_tuple<uint32_t, uint32_t>(30340, 20221), 596 },
{ std::make_tuple<uint32_t, uint32_t>(23450, 20041), 596 },
{ std::make_tuple<uint32_t, uint32_t>(12299, 20013), 595 },
{ std::make_tuple<uint32_t, uint32_t>(21512, 20316), 595 },
{ std::make_tuple<uint32_t, uint32_t>(20108, 27425), 594 },
{ std::make_tuple<uint32_t, uint32_t>(24314, 12289), 593 },
{ std::make_tuple<uint32_t, uint32_t>(23398, 20013), 593 },
{ std::make_tuple<uint32_t, uint32_t>(65292, 20081), 593 },
{ std::make_tuple<uint32_t, uint32_t>(26377, 26102), 593 },
{ std::make_tuple<uint32_t, uint32_t>(23186, 20307), 593 },
{ std::make_tuple<uint32_t, uint32_t>(22825, 20241), 592 },
{ std::make_tuple<uint32_t, uint32_t>(26089, 26399), 592 },
{ std::make_tuple<uint32_t, uint32_t>(31639, 26426), 592 },
{ std::make_tuple<uint32_t, uint32_t>(21482, 26377), 591 },
{ std::make_tuple<uint32_t, uint32_t>(19976, 33609), 591 },
{ std::make_tuple<uint32_t, uint32_t>(20197, 19976), 590 },
{ std::make_tuple<uint32_t, uint32_t>(32479, 30340), 590 },
{ std::make_tuple<uint32_t, uint32_t>(38431, 65292), 590 },
{ std::make_tuple<uint32_t, uint32_t>(23707, 12289), 590 },
{ std::make_tuple<uint32_t, uint32_t>(32, 20301), 590 },
{ std::make_tuple<uint32_t, uint32_t>(36807, 32), 590 },
{ std::make_tuple<uint32_t, uint32_t>(25237, 36164), 588 },
{ std::make_tuple<uint32_t, uint32_t>(20869, 65292), 588 },
{ std::make_tuple<uint32_t, uint32_t>(38500, 20102), 587 },
{ std::make_tuple<uint32_t, uint32_t>(19994, 65292), 586 },
{ std::make_tuple<uint32_t, uint32_t>(65292, 25351), 584 },
{ std::make_tuple<uint32_t, uint32_t>(33487, 32852), 584 },
{ std::make_tuple<uint32_t, uint32_t>(32467, 19969), 584 },
{ std::make_tuple<uint32_t, uint32_t>(21518, 30340), 584 },
{ std::make_tuple<uint32_t, uint32_t>(31995, 65292), 584 },
{ std::make_tuple<uint32_t, uint32_t>(26159, 20197), 583 },
{ std::make_tuple<uint32_t, uint32_t>(35270, 21488), 583 },
{ std::make_tuple<uint32_t, uint32_t>(20803, 32), 583 },
{ std::make_tuple<uint32_t, uint32_t>(26366, 32463), 583 },
{ std::make_tuple<uint32_t, uint32_t>(65288, 19969), 582 },
{ std::make_tuple<uint32_t, uint32_t>(20998, 23376), 582 },
{ std::make_tuple<uint32_t, uint32_t>(19969, 35199), 582 },
{ std::make_tuple<uint32_t, uint32_t>(32, 22825), 581 },
{ std::make_tuple<uint32_t, uint32_t>(34429, 28982), 581 },
{ std::make_tuple<uint32_t, uint32_t>(23427, 20204), 581 },
{ std::make_tuple<uint32_t, uint32_t>(30340, 22522), 581 },
{ std::make_tuple<uint32_t, uint32_t>(31354, 38388), 581 }
};
static const std::unordered_map<std::tuple<uint32_t, uint32_t, uint32_t>, size_t> zh_cn_trigrams {
{ std::make_tuple<uint32_t, uint32_t, uint32_t>(32, 24180, 32), 13492 },
{ std::make_tuple<uint32_t, uint32_t, uint32_t>(32, 26376, 32), 10460 },
{ std::make_tuple<uint32_t, uint32_t, uint32_t>(20013, 22269, 22823), 3854 },
{ std::make_tuple<uint32_t, uint32_t, uint32_t>(22269, 22823, 38470), 3832 },
{ std::make_tuple<uint32_t, uint32_t, uint32_t>(65288, 23398, 21517), 3651 },
{ std::make_tuple<uint32_t, uint32_t, uint32_t>(22320, 21306, 65292), 3536 },
{ std::make_tuple<uint32_t, uint32_t, uint32_t>(23398, 21517, 65306), 3527 },
{ std::make_tuple<uint32_t, uint32_t, uint32_t>(65292, 30446, 21069), 3438 },
{ std::make_tuple<uint32_t, uint32_t, uint32_t>(21517, 65306, 65289), 3257 },
{ std::make_tuple<uint32_t, uint32_t, uint32_t>(29983, 38271, 20110), 3254 },
{ std::make_tuple<uint32_t, uint32_t, uint32_t>(19981, 25300, 32), 3152 },
{ std::make_tuple<uint32_t, uint32_t, uint32_t>(30340, 22320, 21306), 3123 },
{ std::make_tuple<uint32_t, uint32_t, uint32_t>(30340, 19968, 20010), 3092 },
{ std::make_tuple<uint32_t, uint32_t, uint32_t>(22823, 38470, 30340), 3080 },
{ std::make_tuple<uint32_t, uint32_t, uint32_t>(31561, 22320, 65292), 3010 },
{ std::make_tuple<uint32_t, uint32_t, uint32_t>(32, 31859, 30340), 3008 },
{ std::make_tuple<uint32_t, uint32_t, uint32_t>(65292, 29983, 38271), 2942 },
{ std::make_tuple<uint32_t, uint32_t, uint32_t>(20110, 19981, 25300), 2931 },
{ std::make_tuple<uint32_t, uint32_t, uint32_t>(12290, 20998, 24067), 2922 },
{ std::make_tuple<uint32_t, uint32_t, uint32_t>(30001, 20154, 24037), 2914 },
{ std::make_tuple<uint32_t, uint32_t, uint32_t>(38271, 20110, 19981), 2913 },
{ std::make_tuple<uint32_t, uint32_t, uint32_t>(26685, 22521, 12290), 2912 },
{ std::make_tuple<uint32_t, uint32_t, uint32_t>(20122, 26685, 22521), 2910 },
{ std::make_tuple<uint32_t, uint32_t, uint32_t>(20154, 24037, 24341), 2908 },
{ std::make_tuple<uint32_t, uint32_t, uint32_t>(31859, 30340, 22320), 2908 },
{ std::make_tuple<uint32_t, uint32_t, uint32_t>(24037, 24341, 20122), 2908 },
{ std::make_tuple<uint32_t, uint32_t, uint32_t>(24341, 20122, 26685), 2908 },
{ std::make_tuple<uint32_t, uint32_t, uint32_t>(30340, 26893, 29289), 2905 },
{ std::make_tuple<uint32_t, uint32_t, uint32_t>(22320, 65292, 29983), 2896 },
{ std::make_tuple<uint32_t, uint32_t, uint32_t>(26893, 29289, 12290), 2891 },
{ std::make_tuple<uint32_t, uint32_t, uint32_t>(23646, 30340, 26893), 2824 },
{ std::make_tuple<uint32_t, uint32_t, uint32_t>(29289, 12290, 20998), 2814 },
{ std::make_tuple<uint32_t, uint32_t, uint32_t>(31859, 33267, 32), 2743 },
{ std::make_tuple<uint32_t, uint32_t, uint32_t>(32, 31859, 33267), 2742 },
{ std::make_tuple<uint32_t, uint32_t, uint32_t>(30446, 21069, 23578), 2723 },
{ std::make_tuple<uint32_t, uint32_t, uint32_t>(21069, 23578, 26410), 2719 },
{ std::make_tuple<uint32_t, uint32_t, uint32_t>(26410, 30001, 20154), 2713 },
{ std::make_tuple<uint32_t, uint32_t, uint32_t>(23578, 26410, 30001), 2713 },
{ std::make_tuple<uint32_t, uint32_t, uint32_t>(65289, 26159, 19968), 2670 },
{ std::make_tuple<uint32_t, uint32_t, uint32_t>(32, 24180, 65292), 2603 },
{ std::make_tuple<uint32_t, uint32_t, uint32_t>(65292, 20301, 20110), 2555 },
{ std::make_tuple<uint32_t, uint32_t, uint32_t>(65289, 65292, 26159), 2411 },
{ std::make_tuple<uint32_t, uint32_t, uint32_t>(32, 24180, 65289), 2400 },
{ std::make_tuple<uint32_t, uint32_t, uint32_t>(20043, 19968, 65292), 2267 },
{ std::make_tuple<uint32_t, uint32_t, uint32_t>(26159, 19968, 20122), 2252 },
{ std::make_tuple<uint32_t, uint32_t, uint32_t>(26159, 19968, 20010), 2236 },
{ std::make_tuple<uint32_t, uint32_t, uint32_t>(65292, 26159, 19968), 2180 },
{ std::make_tuple<uint32_t, uint32_t, uint32_t>(26159, 20013, 22269), 2142 },
{ std::make_tuple<uint32_t, uint32_t, uint32_t>(65292, 20110, 32), 2118 },
{ std::make_tuple<uint32_t, uint32_t, uint32_t>(21450, 20013, 22269), 2044 },
{ std::make_tuple<uint32_t, uint32_t, uint32_t>(20197, 21450, 20013), 2006 },
{ std::make_tuple<uint32_t, uint32_t, uint32_t>(20849, 21644, 22269), 1949 },
{ std::make_tuple<uint32_t, uint32_t, uint32_t>(65292, 31616, 31216), 1929 },
{ std::make_tuple<uint32_t, uint32_t, uint32_t>(65306, 65289, 26159), 1905 },
{ std::make_tuple<uint32_t, uint32_t, uint32_t>(20998, 24067, 20110), 1823 },
{ std::make_tuple<uint32_t, uint32_t, uint32_t>(20043, 19968, 12290), 1753 },
{ std::make_tuple<uint32_t, uint32_t, uint32_t>(26159, 39321, 28207), 1721 },
{ std::make_tuple<uint32_t, uint32_t, uint32_t>(20998, 24067, 22312), 1639 },
{ std::make_tuple<uint32_t, uint32_t, uint32_t>(65288, 65289, 65292), 1527 },
{ std::make_tuple<uint32_t, uint32_t, uint32_t>(33521, 25991, 65306), 1509 },
{ std::make_tuple<uint32_t, uint32_t, uint32_t>(30340, 19968, 20122), 1477 },
{ std::make_tuple<uint32_t, uint32_t, uint32_t>(65292, 20063, 26159), 1477 },
{ std::make_tuple<uint32_t, uint32_t, uint32_t>(32, 24180, 20195), 1447 },
{ std::make_tuple<uint32_t, uint32_t, uint32_t>(32, 19990, 32426), 1447 },
{ std::make_tuple<uint32_t, uint32_t, uint32_t>(65306, 65289, 20026), 1432 },
{ std::make_tuple<uint32_t, uint32_t, uint32_t>(65292, 21448, 31216), 1386 },
{ std::make_tuple<uint32_t, uint32_t, uint32_t>(32, 26085, 65292), 1367 },
{ std::make_tuple<uint32_t, uint32_t, uint32_t>(20110, 20013, 22269), 1363 },
{ std::make_tuple<uint32_t, uint32_t, uint32_t>(26377, 38480, 20844), 1342 },
{ std::make_tuple<uint32_t, uint32_t, uint32_t>(38480, 20844, 21496), 1342 },
{ std::make_tuple<uint32_t, uint32_t, uint32_t>(33521, 20122, 65306), 1340 },
{ std::make_tuple<uint32_t, uint32_t, uint32_t>(65288, 33521, 25991), 1335 },
{ std::make_tuple<uint32_t, uint32_t, uint32_t>(20013, 22269, 30340), 1325 },
{ std::make_tuple<uint32_t, uint32_t, uint32_t>(12354, 12354, 12354), 1321 },
{ std::make_tuple<uint32_t, uint32_t, uint32_t>(65292, 26159, 20013), 1286 },
{ std::make_tuple<uint32_t, uint32_t, uint32_t>(12450, 12450, 12450), 1275 },
{ std::make_tuple<uint32_t, uint32_t, uint32_t>(20154, 27665, 20849), 1261 },
{ std::make_tuple<uint32_t, uint32_t, uint32_t>(27665, 20849, 21644), 1261 },
{ std::make_tuple<uint32_t, uint32_t, uint32_t>(65292, 22810, 29983), 1256 },
{ std::make_tuple<uint32_t, uint32_t, uint32_t>(21306, 65292, 22810), 1252 },
{ std::make_tuple<uint32_t, uint32_t, uint32_t>(12289, 22235, 24029), 1251 },
{ std::make_tuple<uint32_t, uint32_t, uint32_t>(20013, 21326, 27665), 1237 },
{ std::make_tuple<uint32_t, uint32_t, uint32_t>(22235, 24029, 12289), 1228 },
{ std::make_tuple<uint32_t, uint32_t, uint32_t>(32, 20844, 37324), 1220 },
{ std::make_tuple<uint32_t, uint32_t, uint32_t>(65292, 19968, 33324), 1217 },
{ std::make_tuple<uint32_t, uint32_t, uint32_t>(21326, 27665, 22269), 1215 },
{ std::make_tuple<uint32_t, uint32_t, uint32_t>(22996, 21592, 20250), 1211 },
{ std::make_tuple<uint32_t, uint32_t, uint32_t>(65292, 20027, 35201), 1207 },
{ std::make_tuple<uint32_t, uint32_t, uint32_t>(20420, 32599, 26031), 1205 },
{ std::make_tuple<uint32_t, uint32_t, uint32_t>(31216, 20026, 32), 1204 },
{ std::make_tuple<uint32_t, uint32_t, uint32_t>(26893, 29289, 65292), 1199 },
{ std::make_tuple<uint32_t, uint32_t, uint32_t>(26159, 32654, 22269), 1183 },
{ std::make_tuple<uint32_t, uint32_t, uint32_t>(12289, 20113, 21335), 1182 },
{ std::make_tuple<uint32_t, uint32_t, uint32_t>(22312, 20013, 22269), 1180 },
{ std::make_tuple<uint32_t, uint32_t, uint32_t>(32, 12289, 32), 1160 },
{ std::make_tuple<uint32_t, uint32_t, uint32_t>(21326, 20154, 27665), 1156 },
{ std::make_tuple<uint32_t, uint32_t, uint32_t>(20013, 21326, 20154), 1156 },
{ std::make_tuple<uint32_t, uint32_t, uint32_t>(65292, 22240, 27492), 1152 },
{ std::make_tuple<uint32_t, uint32_t, uint32_t>(65292, 21253, 25324), 1127 },
{ std::make_tuple<uint32_t, uint32_t, uint32_t>(65288, 65289, 26159), 1113 },
{ std::make_tuple<uint32_t, uint32_t, uint32_t>(20844, 37324, 65292), 1108 },
{ std::make_tuple<uint32_t, uint32_t, uint32_t>(29983, 38271, 22312), 1097 },
{ std::make_tuple<uint32_t, uint32_t, uint32_t>(20113, 21335, 12289), 1087 },
{ std::make_tuple<uint32_t, uint32_t, uint32_t>(32, 65292, 26159), 1072 },
{ std::make_tuple<uint32_t, uint32_t, uint32_t>(32, 26085, 32), 1067 },
{ std::make_tuple<uint32_t, uint32_t, uint32_t>(31435, 20110, 32), 1061 },
{ std::make_tuple<uint32_t, uint32_t, uint32_t>(32, 24179, 19981), 1027 },
{ std::make_tuple<uint32_t, uint32_t, uint32_t>(34892, 19981, 21306), 1022 },
{ std::make_tuple<uint32_t, uint32_t, uint32_t>(65288, 33521, 20122), 1020 },
{ std::make_tuple<uint32_t, uint32_t, uint32_t>(65292, 65289, 65292), 1007 },
{ std::make_tuple<uint32_t, uint32_t, uint32_t>(65292, 20197, 21450), 1003 },
{ std::make_tuple<uint32_t, uint32_t, uint32_t>(65289, 65292, 21448), 980 },
{ std::make_tuple<uint32_t, uint32_t, uint32_t>(30340, 29305, 26377), 970 },
{ std::make_tuple<uint32_t, uint32_t, uint32_t>(26368, 22823, 30340), 950 },
{ std::make_tuple<uint32_t, uint32_t, uint32_t>(20026, 20013, 22269), 948 },
{ std::make_tuple<uint32_t, uint32_t, uint32_t>(12299, 12289, 12298), 946 },
{ std::make_tuple<uint32_t, uint32_t, uint32_t>(22269, 30340, 29305), 945 },
{ std::make_tuple<uint32_t, uint32_t, uint32_t>(65292, 20854, 20013), 943 },
{ std::make_tuple<uint32_t, uint32_t, uint32_t>(26377, 26893, 29289), 938 },
{ std::make_tuple<uint32_t, uint32_t, uint32_t>(29305, 26377, 26893), 935 },
{ std::make_tuple<uint32_t, uint32_t, uint32_t>(25104, 31435, 20110), 917 },
{ std::make_tuple<uint32_t, uint32_t, uint32_t>(20110, 39321, 28207), 916 },
{ std::make_tuple<uint32_t, uint32_t, uint32_t>(20132, 22823, 21033), 915 },
{ std::make_tuple<uint32_t, uint32_t, uint32_t>(32, 24180, 30340), 914 },
{ std::make_tuple<uint32_t, uint32_t, uint32_t>(65292, 20013, 22269), 911 },
{ std::make_tuple<uint32_t, uint32_t, uint32_t>(34987, 31216, 20026), 866 },
{ std::make_tuple<uint32_t, uint32_t, uint32_t>(20844, 21496, 65292), 865 },
{ std::make_tuple<uint32_t, uint32_t, uint32_t>(12289, 24191, 35199), 861 },
{ std::make_tuple<uint32_t, uint32_t, uint32_t>(12289, 36149, 24030), 848 },
{ std::make_tuple<uint32_t, uint32_t, uint32_t>(32, 65289, 65292), 840 },
{ std::make_tuple<uint32_t, uint32_t, uint32_t>(36149, 24030, 12289), 836 },
{ std::make_tuple<uint32_t, uint32_t, uint32_t>(20013, 65292, 30446), 813 },
{ std::make_tuple<uint32_t, uint32_t, uint32_t>(12289, 29976, 32899), 804 },
{ std::make_tuple<uint32_t, uint32_t, uint32_t>(38485, 35199, 12289), 802 },
{ std::make_tuple<uint32_t, uint32_t, uint32_t>(24191, 35199, 12289), 800 },
{ std::make_tuple<uint32_t, uint32_t, uint32_t>(29976, 32899, 12289), 797 },
{ std::make_tuple<uint32_t, uint32_t, uint32_t>(12289, 21360, 24230), 793 },
{ std::make_tuple<uint32_t, uint32_t, uint32_t>(19969, 23646, 65288), 793 },
{ std::make_tuple<uint32_t, uint32_t, uint32_t>(12289, 38485, 35199), 793 },
{ std::make_tuple<uint32_t, uint32_t, uint32_t>(24179, 19981, 20844), 791 },
{ std::make_tuple<uint32_t, uint32_t, uint32_t>(32, 24180, 33267), 781 },
{ std::make_tuple<uint32_t, uint32_t, uint32_t>(33879, 21517, 30340), 779 },
{ std::make_tuple<uint32_t, uint32_t, uint32_t>(19976, 65288, 23398), 778 },
{ std::make_tuple<uint32_t, uint32_t, uint32_t>(32, 26085, 65289), 775 },
{ std::make_tuple<uint32_t, uint32_t, uint32_t>(30340, 19968, 37096), 774 },
{ std::make_tuple<uint32_t, uint32_t, uint32_t>(38754, 31215, 32), 773 },
{ std::make_tuple<uint32_t, uint32_t, uint32_t>(35199, 29677, 19969), 773 },
{ std::make_tuple<uint32_t, uint32_t, uint32_t>(12289, 28246, 19981), 767 },
{ std::make_tuple<uint32_t, uint32_t, uint32_t>(19981, 20844, 37324), 767 },
{ std::make_tuple<uint32_t, uint32_t, uint32_t>(28246, 19981, 12289), 763 },
{ std::make_tuple<uint32_t, uint32_t, uint32_t>(24191, 19996, 12289), 761 },
{ std::make_tuple<uint32_t, uint32_t, uint32_t>(20110, 21488, 28286), 746 },
{ std::make_tuple<uint32_t, uint32_t, uint32_t>(22825, 20027, 25945), 743 },
{ std::make_tuple<uint32_t, uint32_t, uint32_t>(12289, 24191, 19996), 743 },
{ std::make_tuple<uint32_t, uint32_t, uint32_t>(24180, 65289, 65292), 737 },
{ std::make_tuple<uint32_t, uint32_t, uint32_t>(19981, 21516, 30340), 722 },
{ std::make_tuple<uint32_t, uint32_t, uint32_t>(12289, 28246, 21335), 720 },
{ std::make_tuple<uint32_t, uint32_t, uint32_t>(36710, 31449, 65292), 720 },
{ std::make_tuple<uint32_t, uint32_t, uint32_t>(32, 20013, 22269), 719 },
{ std::make_tuple<uint32_t, uint32_t, uint32_t>(20110, 26085, 26412), 718 },
{ std::make_tuple<uint32_t, uint32_t, uint32_t>(21152, 20056, 22823), 716 },
{ std::make_tuple<uint32_t, uint32_t, uint32_t>(24180, 33267, 32), 713 },
{ std::make_tuple<uint32_t, uint32_t, uint32_t>(19976, 23646, 30340), 710 },
{ std::make_tuple<uint32_t, uint32_t, uint32_t>(24180, 65288, 32), 710 },
{ std::make_tuple<uint32_t, uint32_t, uint32_t>(65292, 39321, 28207), 708 },
{ std::make_tuple<uint32_t, uint32_t, uint32_t>(32, 19976, 19976), 703 },
{ std::make_tuple<uint32_t, uint32_t, uint32_t>(32, 26159, 19968), 701 },
{ std::make_tuple<uint32_t, uint32_t, uint32_t>(65292, 25152, 20197), 699 },
{ std::make_tuple<uint32_t, uint32_t, uint32_t>(26159, 26085, 26412), 698 },
{ std::make_tuple<uint32_t, uint32_t, uint32_t>(32, 65289, 26159), 697 },
{ std::make_tuple<uint32_t, uint32_t, uint32_t>(32, 24180, 22312), 695 },
{ std::make_tuple<uint32_t, uint32_t, uint32_t>(37325, 35201, 30340), 693 },
{ std::make_tuple<uint32_t, uint32_t, uint32_t>(20844, 21496, 65288), 690 },
{ std::make_tuple<uint32_t, uint32_t, uint32_t>(28246, 21335, 12289), 689 },
{ std::make_tuple<uint32_t, uint32_t, uint32_t>(21306, 65292, 19968), 689 },
{ std::make_tuple<uint32_t, uint32_t, uint32_t>(22320, 21306, 30340), 687 },
{ std::make_tuple<uint32_t, uint32_t, uint32_t>(19968, 33324, 29983), 684 },
{ std::make_tuple<uint32_t, uint32_t, uint32_t>(65292, 24120, 29983), 669 },
{ std::make_tuple<uint32_t, uint32_t, uint32_t>(12289, 23665, 22369), 669 },
{ std::make_tuple<uint32_t, uint32_t, uint32_t>(30340, 20027, 35201), 669 },
{ std::make_tuple<uint32_t, uint32_t, uint32_t>(21306, 65292, 24120), 666 },
{ std::make_tuple<uint32_t, uint32_t, uint32_t>(22522, 19969, 25945), 662 },
{ std::make_tuple<uint32_t, uint32_t, uint32_t>(65292, 20026, 20013), 658 },
{ std::make_tuple<uint32_t, uint32_t, uint32_t>(65292, 22312, 32), 658 },
{ std::make_tuple<uint32_t, uint32_t, uint32_t>(32, 26085, 22312), 655 },
{ std::make_tuple<uint32_t, uint32_t, uint32_t>(65292, 24182, 19969), 652 },
{ std::make_tuple<uint32_t, uint32_t, uint32_t>(19976, 19976, 65292), 642 },
{ std::make_tuple<uint32_t, uint32_t, uint32_t>(19969, 20351, 12289), 641 },
{ std::make_tuple<uint32_t, uint32_t, uint32_t>(12289, 27743, 35199), 640 },
{ std::make_tuple<uint32_t, uint32_t, uint32_t>(12290, 30001, 20110), 637 },
{ std::make_tuple<uint32_t, uint32_t, uint32_t>(32, 39321, 28207), 632 },
{ std::make_tuple<uint32_t, uint32_t, uint32_t>(19976, 19976, 19969), 631 },
{ std::make_tuple<uint32_t, uint32_t, uint32_t>(20043, 38388, 30340), 629 },
{ std::make_tuple<uint32_t, uint32_t, uint32_t>(22810, 29983, 38271), 627 },
{ std::make_tuple<uint32_t, uint32_t, uint32_t>(12289, 20056, 27743), 625 },
{ std::make_tuple<uint32_t, uint32_t, uint32_t>(65289, 26159, 19976), 621 },
{ std::make_tuple<uint32_t, uint32_t, uint32_t>(27743, 35199, 12289), 618 },
{ std::make_tuple<uint32_t, uint32_t, uint32_t>(32, 26085, 33267), 616 },
{ std::make_tuple<uint32_t, uint32_t, uint32_t>(20869, 19969, 20351), 615 },
{ std::make_tuple<uint32_t, uint32_t, uint32_t>(26085, 33267, 32), 606 },
{ std::make_tuple<uint32_t, uint32_t, uint32_t>(26159, 21488, 28286), 602 },
{ std::make_tuple<uint32_t, uint32_t, uint32_t>(30340, 31532, 19968), 601 },
{ std::make_tuple<uint32_t, uint32_t, uint32_t>(20056, 27743, 12289), 593 },
{ std::make_tuple<uint32_t, uint32_t, uint32_t>(35745, 31639, 26426), 592 },
{ std::make_tuple<uint32_t, uint32_t, uint32_t>(20301, 20110, 39321), 588 },
{ std::make_tuple<uint32_t, uint32_t, uint32_t>(26159, 20301, 20110), 587 },
{ std::make_tuple<uint32_t, uint32_t, uint32_t>(12289, 31119, 24314), 587 },
{ std::make_tuple<uint32_t, uint32_t, uint32_t>(21335, 31561, 22320), 586 },
{ std::make_tuple<uint32_t, uint32_t, uint32_t>(65292, 21448, 21517), 585 },
{ std::make_tuple<uint32_t, uint32_t, uint32_t>(65292, 21488, 28286), 584 }
};
static const std::tuple<size_t, size_t, size_t> zh_cn_n_words {
4792118, 1709982, 314544
};
namespace langdetectpp { namespace profiles { namespace langs {
std::unordered_map<uint32_t, size_t> get_zh_cn_one_grams() {
std::unordered_map<uint32_t, size_t> result = zh_cn_one_grams;
return result;
}
std::unordered_map<std::tuple<uint32_t, uint32_t>, size_t> get_zh_cn_bigrams() {
std::unordered_map<std::tuple<uint32_t, uint32_t>, size_t> result = zh_cn_bigrams;
return result;
}
std::unordered_map<std::tuple<uint32_t, uint32_t, uint32_t>, size_t> get_zh_cn_trigrams() {
std::unordered_map<std::tuple<uint32_t, uint32_t, uint32_t>, size_t> result = zh_cn_trigrams;
return result;
}
std::tuple<size_t, size_t, size_t> get_zh_cn_n_words() {
std::tuple<size_t, size_t, size_t> result = zh_cn_n_words;
return result;
}
}}} // langdetectpp::profiles::langs
| [
"scott.ivey@gmail.com"
] | scott.ivey@gmail.com |
08b1f4ffd657d06797d71fc7c144336c0279c032 | 92b6aaade5a3f323d7f8e7d02fb9fec09f4c2f50 | /CP-Codes/cf_1167c.cpp | dad610d702f0f2bded3f6ed3cd9375bc33191f71 | [] | no_license | suraj1611/Competitive_Programming | 846dee00396e2f2b6d13e2ea8aaed444a34062af | 82bd88081ac067ad4170553afedc6c479bb53753 | refs/heads/master | 2020-04-22T17:27:18.116585 | 2019-12-16T19:42:29 | 2019-12-16T19:42:29 | 170,541,477 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,402 | cpp | /* Code by : Suraj (@suraj1611) */
#include<bits/stdc++.h>
#include <string>
using namespace std;
#define ll long long int
#define rep(i,n) for(int i=0; i<n; i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define mx INT_MAX
#define mn INT_MIN
#define md 1000000007
#define pb push_back
#define mp make_pair
#define maxsize 500005
#define lb cout<<endl;
#define endl "\n"
#define F first
#define S second
#define label cout<<"hello!"<<endl
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);
ll ar[maxsize],sz[maxsize],n,m;
void init()
{
rep1(i,n)
{
ar[i]=i;
sz[i] = 1;
}
}
ll root(ll i)
{
while(ar[i]!=i)
{
i=ar[i];
}
return i;
}
void sunion(ll a,ll b)
{
ll ra,rb;
ra=root(a);rb=root(b);
if(sz[ra]<sz[rb])
{
ar[ra]=ar[rb];
sz[rb]+=sz[ra];
}
else
{
ar[rb]=ar[ra];
sz[ra]+=sz[rb];
}
}
ll find(ll a,ll b)
{
if(root(a)==root(b))
return 1;
else
return 0;
}
int main()
{
IOS
#ifndef ONLINE_JUDGE
freopen("in.txt", "r", stdin);
freopen("out.txt", "w", stdout);
#endif
cin>>n>>m;
init();
rep1(i,m)
{
ll x,y,z;
cin>>x;
if(x>0)
cin>>y;
else
continue;
x=x-1;
rep(j,x)
{
cin>>z;
if(!find(y,z))
sunion(y,z);
}
}
rep1(i,n)
{
cout<<sz[root(i)]<<" ";
}
cout<<endl;
#ifndef ONLINE_JUDGE
cout<<"\nTime Elapsed : " << 1.0*clock() / CLOCKS_PER_SEC << " s\n";
#endif
return 0;
} | [
"surajsk1611@gmail.com"
] | surajsk1611@gmail.com |
db5c0fce245a6d949c04c7c19347aa88a96a24b2 | e39b3fad5b4ee23f926509a7e5fc50e84d9ebdc8 | /Codeforces/Educational-Codeforces/071-080/077/a.cpp | e966c7ba141904748f1d5bee83df3210c345598f | [] | no_license | izumo27/competitive-programming | f755690399c5ad1c58d3db854a0fa21eb8e5f775 | e721fc5ede036ec5456da9a394648233b7bfd0b7 | refs/heads/master | 2021-06-03T05:59:58.460986 | 2021-05-08T14:39:58 | 2021-05-08T14:39:58 | 123,675,037 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,189 | cpp | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define REP(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)
#define DEBUG(x) cout<<#x<<": "<<(x)<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()
template<typename T> inline void CHMAX(T& a, const T b) {if(a<b) a=b;}
template<typename T> inline void CHMIN(T& a, const T b) {if(a>b) a=b;}
constexpr ll MOD=1000000007ll;
// constexpr ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD
const double EPS=1e-11;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)
int main(){
ios::sync_with_stdio(false);
cin.tie(0);
// cout<<setprecision(10)<<fixed;
int n;
cin>>n;
REP(i, n){
int c, sum;
cin>>c>>sum;
int ans=0;
REP(j, c){
if(j<sum%c){
ans+=((sum/c)+1)*((sum/c)+1);
}
else{
ans+=(sum/c)*(sum/c);
}
}
cout<<ans<<'\n';
}
return 0;
}
| [
"22386882+izumo27@users.noreply.github.com"
] | 22386882+izumo27@users.noreply.github.com |
0bf7c6ddead86630509d1d4157f53542101469ec | 1e35a16c37703581e7fb4fd9be05805b1e7da90a | /AspirinSnmpCommunicator/stdafx.h | 40c8fa311e03e68b1e0b4665e6ed1fa3a3016cad | [] | no_license | aliakseis/snmp-com-example | afcb13fed5f0e26d2cf8f4ba0f59f57a97bfe00b | 0cfd396b99c3e25cfcf88b953820a75845e27e10 | refs/heads/master | 2021-05-15T02:22:31.325209 | 2017-09-27T13:28:03 | 2017-09-27T13:28:03 | 33,600,691 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,528 | h | // stdafx.h : include file for standard system include files,
// or project specific include files that are used frequently,
// but are changed infrequently
#pragma once
#ifndef STRICT
#define STRICT
#endif
// Modify the following defines if you have to target a platform prior to the ones specified below.
// Refer to MSDN for the latest info on corresponding values for different platforms.
#ifndef WINVER // Allow use of features specific to Windows XP or later.
#define WINVER 0x0501 // Change this to the appropriate value to target other versions of Windows.
#endif
#ifndef _WIN32_WINNT // Allow use of features specific to Windows XP or later.
#define _WIN32_WINNT 0x0501 // Change this to the appropriate value to target other versions of Windows.
#endif
#ifndef _WIN32_WINDOWS // Allow use of features specific to Windows 98 or later.
#define _WIN32_WINDOWS 0x0410 // Change this to the appropriate value to target Windows Me or later.
#endif
#ifndef _WIN32_IE // Allow use of features specific to IE 6.0 or later.
#define _WIN32_IE 0x0600 // Change this to the appropriate value to target other versions of IE.
#endif
#define _ATL_APARTMENT_THREADED
#define _ATL_NO_AUTOMATIC_NAMESPACE
#define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS // some CString constructors will be explicit
#include <stdio.h>
#include <atlbase.h>
#include <atlcom.h>
#include <atlwin.h>
#include <atltypes.h>
#include <atlctl.h>
#include <atlhost.h>
using namespace ATL; | [
"aliaksei.sanko@gmail.com@1b6c1c8d-a735-928e-056a-728d89c3144f"
] | aliaksei.sanko@gmail.com@1b6c1c8d-a735-928e-056a-728d89c3144f |
e07a6be8d91d6bc79d7860d920934b1484853383 | fbeb266f1226381b837bef62c4ddb16d2b4e92c1 | /Report_Bluetooth/BT_basic_setting.ino | 42262bbf5154669513340c839b6b8d9404196e5c | [] | no_license | sjh836/arduino_codelab | f1ddb093deb86adbf3a62830858897192f08f87e | 70fec281b4e9cf8af727254f9c15a2f0338728c3 | refs/heads/master | 2021-01-18T18:07:20.618743 | 2017-04-01T16:43:14 | 2017-04-01T16:43:14 | 86,844,996 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 810 | ino | /* 블루투스 Setting */
#include <SoftwareSerial.h> //시리얼통신 라이브러리 호출
SoftwareSerial BT(12, 13); //블루투스모듈에 연결하고 Tx를 12번 pin, Rx를 13번 pin으로 설정한다
void setup()
{
Serial.begin(9600); //시리얼 통신을 9600속도로 시작
BT.begin(9600); //블루투스 통신을 9600속도로 시작
}
void loop()
{
if (BT.available()) //블루투스 포트의 수신 버퍼에 저장된 데이터 개수를 반환
{
Serial.write(BT.read()); //블루투스에서 전송된 문자를 읽어 시리얼모니터 출력
}
if (Serial.available()) //시리얼 포트의 수신 버퍼에 저장된 데이터 개수를 반환
{
BT.write(Serial.read()); //시리얼모니터에서 전송된 문자를 읽어 블루투스에 출력
}
}
| [
"sjh836@gmail.com"
] | sjh836@gmail.com |
7eb38f85a90f4e2a82cfd1fa68f9c5e45ef71ec9 | 4f81ad42bfb5e8328b3983e3e68ade58e6d15b6e | /src/qt/bitcoinunits.cpp | bcba7ecb4255410474594922421dc97404d998db | [
"MIT"
] | permissive | gingram68/eaglecoin | 7e0977af1540e74a461d44251e43ee94d17f4e3f | a6f0afa98865fdb4eda6d45b3d7997942b14b038 | refs/heads/master | 2021-05-27T05:01:42.310132 | 2013-07-19T11:20:25 | 2013-07-19T11:20:25 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,342 | cpp | #include "bitcoinunits.h"
#include <QStringList>
BitcoinUnits::BitcoinUnits(QObject *parent):
QAbstractListModel(parent),
unitlist(availableUnits())
{
}
QList<BitcoinUnits::Unit> BitcoinUnits::availableUnits()
{
QList<BitcoinUnits::Unit> unitlist;
unitlist.append(BTC);
unitlist.append(mBTC);
unitlist.append(uBTC);
return unitlist;
}
bool BitcoinUnits::valid(int unit)
{
switch(unit)
{
case BTC:
case mBTC:
case uBTC:
return true;
default:
return false;
}
}
QString BitcoinUnits::name(int unit)
{
switch(unit)
{
case BTC: return QString("EGC");
case mBTC: return QString("mEGC");
case uBTC: return QString::fromUtf8("μEGC");
default: return QString("???");
}
}
QString BitcoinUnits::description(int unit)
{
switch(unit)
{
case BTC: return QString("EagleCoin");
case mBTC: return QString("milliEagleCoin (1 / 1,000)");
case uBTC: return QString("microEagleCoin (1 / 1,000,000)");
default: return QString("???");
}
}
//a single unit (.00000001) of EagleCoin is called a "wander."
qint64 BitcoinUnits::factor(int unit)
{
switch(unit)
{
case BTC: return 100000000;
case mBTC: return 100000;
case uBTC: return 100;
default: return 100000000;
}
}
int BitcoinUnits::amountDigits(int unit)
{
switch(unit)
{
case BTC: return 8; // 21,000,000 (# digits, without commas)
case mBTC: return 11; // 21,000,000,000
case uBTC: return 14; // 21,000,000,000,000
default: return 0;
}
}
int BitcoinUnits::decimals(int unit)
{
switch(unit)
{
case BTC: return 8;
case mBTC: return 5;
case uBTC: return 2;
default: return 0;
}
}
QString BitcoinUnits::format(int unit, qint64 n, bool fPlus)
{
// Note: not using straight sprintf here because we do NOT want
// localized number formatting.
if(!valid(unit))
return QString(); // Refuse to format invalid unit
qint64 coin = factor(unit);
int num_decimals = decimals(unit);
qint64 n_abs = (n > 0 ? n : -n);
qint64 quotient = n_abs / coin;
qint64 remainder = n_abs % coin;
QString quotient_str = QString::number(quotient);
QString remainder_str = QString::number(remainder).rightJustified(num_decimals, '0');
// Right-trim excess 0's after the decimal point
int nTrim = 0;
for (int i = remainder_str.size()-1; i>=2 && (remainder_str.at(i) == '0'); --i)
++nTrim;
remainder_str.chop(nTrim);
if (n < 0)
quotient_str.insert(0, '-');
else if (fPlus && n > 0)
quotient_str.insert(0, '+');
return quotient_str + QString(".") + remainder_str;
}
QString BitcoinUnits::formatWithUnit(int unit, qint64 amount, bool plussign)
{
return format(unit, amount, plussign) + QString(" ") + name(unit);
}
bool BitcoinUnits::parse(int unit, const QString &value, qint64 *val_out)
{
if(!valid(unit) || value.isEmpty())
return false; // Refuse to parse invalid unit or empty string
int num_decimals = decimals(unit);
QStringList parts = value.split(".");
if(parts.size() > 2)
{
return false; // More than one dot
}
QString whole = parts[0];
QString decimals;
if(parts.size() > 1)
{
decimals = parts[1];
}
if(decimals.size() > num_decimals)
{
return false; // Exceeds max precision
}
bool ok = false;
QString str = whole + decimals.leftJustified(num_decimals, '0');
if(str.size() > 18)
{
return false; // Longer numbers will exceed 63 bits
}
qint64 retvalue = str.toLongLong(&ok);
if(val_out)
{
*val_out = retvalue;
}
return ok;
}
int BitcoinUnits::rowCount(const QModelIndex &parent) const
{
Q_UNUSED(parent);
return unitlist.size();
}
QVariant BitcoinUnits::data(const QModelIndex &index, int role) const
{
int row = index.row();
if(row >= 0 && row < unitlist.size())
{
Unit unit = unitlist.at(row);
switch(role)
{
case Qt::EditRole:
case Qt::DisplayRole:
return QVariant(name(unit));
case Qt::ToolTipRole:
return QVariant(description(unit));
case UnitRole:
return QVariant(static_cast<int>(unit));
}
}
return QVariant();
}
| [
"ilya-stromberg@yandex.ru"
] | ilya-stromberg@yandex.ru |
7799312a42cdd19ded03092d2d981883305066c0 | fff80cdaf12712704f36038479f50418253f42f3 | /fbthrift/thrift/compiler/test/fixtures/qualified/gen-cpp2/module2_metadata.cpp | 00ccac3d6640d55a7f7abaeb0d76a97d043ff112 | [] | no_license | rudolfkopriva/Facebook | 1ea0cfbc116f68ae0317332eeb9155461af5645a | 56e4c6a83f992bb01849ad353004b28409e53eef | refs/heads/master | 2023-02-14T01:54:36.519860 | 2021-01-05T02:09:26 | 2021-01-05T02:09:26 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,193 | cpp | /**
* Autogenerated by Thrift
*
* DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
* @generated
*/
#include <thrift/lib/cpp2/gen/module_metadata_cpp.h>
#include "thrift/compiler/test/fixtures/qualified/gen-cpp2/module2_metadata.h"
namespace apache {
namespace thrift {
namespace detail {
namespace md {
using ThriftMetadata = ::apache::thrift::metadata::ThriftMetadata;
using ThriftPrimitiveType = ::apache::thrift::metadata::ThriftPrimitiveType;
using ThriftType = ::apache::thrift::metadata::ThriftType;
using ThriftService = ::apache::thrift::metadata::ThriftService;
using ThriftServiceContext = ::apache::thrift::metadata::ThriftServiceContext;
using ThriftFunctionGenerator = void (*)(ThriftMetadata&, ThriftService&);
const ::apache::thrift::metadata::ThriftStruct&
StructMetadata<::module2::Struct>::gen(ThriftMetadata& metadata) {
auto res = metadata.structs_ref()->emplace("module2.Struct", ::apache::thrift::metadata::ThriftStruct{});
if (!res.second) {
return res.first->second;
}
::apache::thrift::metadata::ThriftStruct& module2_Struct = res.first->second;
module2_Struct.name_ref() = "module2.Struct";
module2_Struct.is_union_ref() = false;
static const std::tuple<int32_t, const char*, bool, std::unique_ptr<MetadataTypeInterface>>
module2_Struct_fields[] = {
std::make_tuple(1, "first", false, std::make_unique<Struct< ::module0::Struct>>("module0.Struct")),
std::make_tuple(2, "second", false, std::make_unique<Struct< ::module1::Struct>>("module1.Struct")),
};
for (const auto& f : module2_Struct_fields) {
::apache::thrift::metadata::ThriftField field;
field.id_ref() = std::get<0>(f);
field.name_ref() = std::get<1>(f);
field.is_optional_ref() = std::get<2>(f);
std::get<3>(f)->writeAndGenType(*field.type_ref(), metadata);
module2_Struct.fields_ref()->push_back(std::move(field));
}
return res.first->second;
}
const ::apache::thrift::metadata::ThriftStruct&
StructMetadata<::module2::BigStruct>::gen(ThriftMetadata& metadata) {
auto res = metadata.structs_ref()->emplace("module2.BigStruct", ::apache::thrift::metadata::ThriftStruct{});
if (!res.second) {
return res.first->second;
}
::apache::thrift::metadata::ThriftStruct& module2_BigStruct = res.first->second;
module2_BigStruct.name_ref() = "module2.BigStruct";
module2_BigStruct.is_union_ref() = false;
static const std::tuple<int32_t, const char*, bool, std::unique_ptr<MetadataTypeInterface>>
module2_BigStruct_fields[] = {
std::make_tuple(1, "s", false, std::make_unique<Struct< ::module2::Struct>>("module2.Struct")),
std::make_tuple(2, "id", false, std::make_unique<Primitive>(ThriftPrimitiveType::THRIFT_I32_TYPE)),
};
for (const auto& f : module2_BigStruct_fields) {
::apache::thrift::metadata::ThriftField field;
field.id_ref() = std::get<0>(f);
field.name_ref() = std::get<1>(f);
field.is_optional_ref() = std::get<2>(f);
std::get<3>(f)->writeAndGenType(*field.type_ref(), metadata);
module2_BigStruct.fields_ref()->push_back(std::move(field));
}
return res.first->second;
}
} // namespace md
} // namespace detail
} // namespace thrift
} // namespace apache
| [
"nateweiler84@gmail.com"
] | nateweiler84@gmail.com |
53ba446c614cae7ddcce1e453d63efc1146ae226 | 42d86e8b07f45ca7a81e734cbb5813761e30eaf8 | /mk-livestatus-1.1.8/src/CustomVarsFilter.h | 370075ca28e8cc8018d10b77ac76d7f8935bc6da | [] | no_license | saz/mk-livestatus | 6dac69aa942c2afd2f5a94cac7b62619dd7e1a0f | f9252aba9494cd062fe2d8d3b57cfc72fee8cbde | refs/heads/master | 2016-09-06T13:33:29.928581 | 2011-02-07T12:14:53 | 2011-02-07T12:14:53 | 1,337,261 | 0 | 2 | null | null | null | null | UTF-8 | C++ | false | false | 1,867 | h | // +------------------------------------------------------------------+
// | ____ _ _ __ __ _ __ |
// | / ___| |__ ___ ___| | __ | \/ | |/ / |
// | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
// | | |___| | | | __/ (__| < | | | | . \ |
// | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
// | |
// | Copyright Mathias Kettner 2010 mk@mathias-kettner.de |
// +------------------------------------------------------------------+
//
// This file is part of Check_MK.
// The official homepage is at http://mathias-kettner.de/check_mk.
//
// check_mk 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 in version 2. check_mk is distributed
// in the hope that it will be useful, but WITHOUT ANY WARRANTY; with-
// out even the implied warranty of MERCHANTABILITY or FITNESS FOR A
// PARTICULAR PURPOSE. See the GNU General Public License for more de-
// ails. You should have received a copy of the GNU General Public
// License along with GNU Make; see the file COPYING. If not, write
// to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
// Boston, MA 02110-1301 USA.
#ifndef CustomVarsFilter_h
#define CustomVarsFilter_h
#include "config.h"
#include "CustomVarsColumn.h"
#include "Filter.h"
class CustomVarsFilter : public Filter
{
CustomVarsColumn *_column;
int _opid;
string _ref_text;
public:
CustomVarsFilter(CustomVarsColumn *column, int opid, char *value) :
_column(column), _opid(opid), _ref_text(value) {};
bool accepts(void *data);
};
#endif // CustomVarsFilter_h
| [
"me@saz.sh"
] | me@saz.sh |
2eb80c5c701f3914c22108f16ebeef91cadc32bd | ba0cbdae81c171bd4be7b12c0594de72bd6d625a | /MyToontown/Panda3D-1.9.0/include/depthTestAttrib.h | ab64479f26e64bafc8e0a9b03784aa042dc80661 | [
"BSD-3-Clause",
"BSD-2-Clause"
] | permissive | sweep41/Toontown-2016 | 65985f198fa32a832e762fa9c59e59606d6a40a3 | 7732fb2c27001264e6dd652c057b3dc41f9c8a7d | refs/heads/master | 2021-01-23T16:04:45.264205 | 2017-06-04T02:47:34 | 2017-06-04T02:47:34 | 93,279,679 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,406 | h | // Filename: depthTestAttrib.h
// Created by: drose (04Mar02)
//
////////////////////////////////////////////////////////////////////
//
// PANDA 3D SOFTWARE
// Copyright (c) Carnegie Mellon University. All rights reserved.
//
// All use of this software is subject to the terms of the revised BSD
// license. You should have received a copy of this license along
// with this source code in a file named "LICENSE."
//
////////////////////////////////////////////////////////////////////
#ifndef DEPTHTESTATTRIB_H
#define DEPTHTESTATTRIB_H
#include "pandabase.h"
#include "renderAttrib.h"
class FactoryParams;
////////////////////////////////////////////////////////////////////
// Class : DepthTestAttrib
// Description : Enables or disables writing to the depth buffer.
////////////////////////////////////////////////////////////////////
class EXPCL_PANDA_PGRAPH DepthTestAttrib : public RenderAttrib {
private:
INLINE DepthTestAttrib(PandaCompareFunc mode = M_less);
PUBLISHED:
static CPT(RenderAttrib) make(PandaCompareFunc mode);
static CPT(RenderAttrib) make_default();
INLINE PandaCompareFunc get_mode() const;
public:
virtual void output(ostream &out) const;
protected:
virtual int compare_to_impl(const RenderAttrib *other) const;
virtual size_t get_hash_impl() const;
private:
PandaCompareFunc _mode;
PUBLISHED:
static int get_class_slot() {
return _attrib_slot;
}
virtual int get_slot() const {
return get_class_slot();
}
public:
static void register_with_read_factory();
virtual void write_datagram(BamWriter *manager, Datagram &dg);
protected:
static TypedWritable *make_from_bam(const FactoryParams ¶ms);
void fillin(DatagramIterator &scan, BamReader *manager);
public:
static TypeHandle get_class_type() {
return _type_handle;
}
static void init_type() {
RenderAttrib::init_type();
register_type(_type_handle, "DepthTestAttrib",
RenderAttrib::get_class_type());
_attrib_slot = register_slot(_type_handle, 100, make_default);
}
virtual TypeHandle get_type() const {
return get_class_type();
}
virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
private:
static TypeHandle _type_handle;
static int _attrib_slot;
};
#include "depthTestAttrib.I"
#endif
| [
"sweep14@gmail.com"
] | sweep14@gmail.com |
448f2062f757cb6ccc83dda9c39246bd601036d5 | dd80a584130ef1a0333429ba76c1cee0eb40df73 | /external/chromium_org/third_party/WebKit/Source/core/inspector/InspectorWorkerAgent.cpp | c4b91911458c4dbb687daac3e51cc986868be271 | [
"GPL-1.0-or-later",
"LGPL-2.0-or-later",
"Apache-2.0",
"MIT",
"BSD-3-Clause",
"LGPL-2.0-only",
"BSD-2-Clause",
"LGPL-2.1-only"
] | permissive | karunmatharu/Android-4.4-Pay-by-Data | 466f4e169ede13c5835424c78e8c30ce58f885c1 | fcb778e92d4aad525ef7a995660580f948d40bc9 | refs/heads/master | 2021-03-24T13:33:01.721868 | 2017-02-18T17:48:49 | 2017-02-18T17:48:49 | 81,847,777 | 0 | 2 | MIT | 2020-03-09T00:02:12 | 2017-02-13T16:47:00 | null | UTF-8 | C++ | false | false | 8,379 | cpp | /*
* Copyright (C) 2011 Google Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following disclaimer
* in the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Google Inc. nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "config.h"
#include "core/inspector/InspectorWorkerAgent.h"
#include "InspectorFrontend.h"
#include "core/inspector/InspectorState.h"
#include "core/inspector/InstrumentingAgents.h"
#include "core/inspector/JSONParser.h"
#include "core/workers/WorkerGlobalScopeProxy.h"
#include "platform/JSONValues.h"
#include "platform/weborigin/KURL.h"
#include "wtf/PassOwnPtr.h"
#include "wtf/RefPtr.h"
namespace WebCore {
namespace WorkerAgentState {
static const char workerInspectionEnabled[] = "workerInspectionEnabled";
static const char autoconnectToWorkers[] = "autoconnectToWorkers";
};
class InspectorWorkerAgent::WorkerFrontendChannel : public WorkerGlobalScopeProxy::PageInspector {
WTF_MAKE_FAST_ALLOCATED;
public:
explicit WorkerFrontendChannel(InspectorFrontend* frontend, WorkerGlobalScopeProxy* proxy)
: m_frontend(frontend)
, m_proxy(proxy)
, m_id(s_nextId++)
, m_connected(false)
{
}
virtual ~WorkerFrontendChannel()
{
disconnectFromWorkerGlobalScope();
}
int id() const { return m_id; }
WorkerGlobalScopeProxy* proxy() const { return m_proxy; }
void connectToWorkerGlobalScope()
{
if (m_connected)
return;
m_connected = true;
m_proxy->connectToInspector(this);
}
void disconnectFromWorkerGlobalScope()
{
if (!m_connected)
return;
m_connected = false;
m_proxy->disconnectFromInspector();
}
private:
// WorkerGlobalScopeProxy::PageInspector implementation
virtual void dispatchMessageFromWorker(const String& message)
{
RefPtr<JSONValue> value = parseJSON(message);
if (!value)
return;
RefPtr<JSONObject> messageObject = value->asObject();
if (!messageObject)
return;
m_frontend->worker()->dispatchMessageFromWorker(m_id, messageObject);
}
InspectorFrontend* m_frontend;
WorkerGlobalScopeProxy* m_proxy;
int m_id;
bool m_connected;
static int s_nextId;
};
int InspectorWorkerAgent::WorkerFrontendChannel::s_nextId = 1;
PassOwnPtr<InspectorWorkerAgent> InspectorWorkerAgent::create(InstrumentingAgents* instrumentingAgents, InspectorCompositeState* inspectorState)
{
return adoptPtr(new InspectorWorkerAgent(instrumentingAgents, inspectorState));
}
InspectorWorkerAgent::InspectorWorkerAgent(InstrumentingAgents* instrumentingAgents, InspectorCompositeState* inspectorState)
: InspectorBaseAgent<InspectorWorkerAgent>("Worker", instrumentingAgents, inspectorState)
, m_inspectorFrontend(0)
{
m_instrumentingAgents->setInspectorWorkerAgent(this);
}
InspectorWorkerAgent::~InspectorWorkerAgent()
{
m_instrumentingAgents->setInspectorWorkerAgent(0);
}
void InspectorWorkerAgent::setFrontend(InspectorFrontend* frontend)
{
m_inspectorFrontend = frontend;
}
void InspectorWorkerAgent::restore()
{
if (m_state->getBoolean(WorkerAgentState::workerInspectionEnabled))
createWorkerFrontendChannelsForExistingWorkers();
}
void InspectorWorkerAgent::clearFrontend()
{
m_state->setBoolean(WorkerAgentState::autoconnectToWorkers, false);
disable(0);
m_inspectorFrontend = 0;
}
void InspectorWorkerAgent::enable(ErrorString*)
{
m_state->setBoolean(WorkerAgentState::workerInspectionEnabled, true);
if (!m_inspectorFrontend)
return;
createWorkerFrontendChannelsForExistingWorkers();
}
void InspectorWorkerAgent::disable(ErrorString*)
{
m_state->setBoolean(WorkerAgentState::workerInspectionEnabled, false);
if (!m_inspectorFrontend)
return;
destroyWorkerFrontendChannels();
}
void InspectorWorkerAgent::canInspectWorkers(ErrorString*, bool* result)
{
*result = true;
}
void InspectorWorkerAgent::connectToWorker(ErrorString* error, int workerId)
{
WorkerFrontendChannel* channel = m_idToChannel.get(workerId);
if (channel)
channel->connectToWorkerGlobalScope();
else
*error = "Worker is gone";
}
void InspectorWorkerAgent::disconnectFromWorker(ErrorString* error, int workerId)
{
WorkerFrontendChannel* channel = m_idToChannel.get(workerId);
if (channel)
channel->disconnectFromWorkerGlobalScope();
else
*error = "Worker is gone";
}
void InspectorWorkerAgent::sendMessageToWorker(ErrorString* error, int workerId, const RefPtr<JSONObject>& message)
{
WorkerFrontendChannel* channel = m_idToChannel.get(workerId);
if (channel)
channel->proxy()->sendMessageToInspector(message->toJSONString());
else
*error = "Worker is gone";
}
void InspectorWorkerAgent::setAutoconnectToWorkers(ErrorString*, bool value)
{
m_state->setBoolean(WorkerAgentState::autoconnectToWorkers, value);
}
bool InspectorWorkerAgent::shouldPauseDedicatedWorkerOnStart()
{
return m_state->getBoolean(WorkerAgentState::autoconnectToWorkers);
}
void InspectorWorkerAgent::didStartWorkerGlobalScope(WorkerGlobalScopeProxy* workerGlobalScopeProxy, const KURL& url)
{
m_dedicatedWorkers.set(workerGlobalScopeProxy, url.string());
if (m_inspectorFrontend && m_state->getBoolean(WorkerAgentState::workerInspectionEnabled))
createWorkerFrontendChannel(workerGlobalScopeProxy, url.string());
}
void InspectorWorkerAgent::workerGlobalScopeTerminated(WorkerGlobalScopeProxy* proxy)
{
m_dedicatedWorkers.remove(proxy);
for (WorkerChannels::iterator it = m_idToChannel.begin(); it != m_idToChannel.end(); ++it) {
if (proxy == it->value->proxy()) {
m_inspectorFrontend->worker()->workerTerminated(it->key);
delete it->value;
m_idToChannel.remove(it);
return;
}
}
}
void InspectorWorkerAgent::createWorkerFrontendChannelsForExistingWorkers()
{
for (DedicatedWorkers::iterator it = m_dedicatedWorkers.begin(); it != m_dedicatedWorkers.end(); ++it)
createWorkerFrontendChannel(it->key, it->value);
}
void InspectorWorkerAgent::destroyWorkerFrontendChannels()
{
for (WorkerChannels::iterator it = m_idToChannel.begin(); it != m_idToChannel.end(); ++it) {
it->value->disconnectFromWorkerGlobalScope();
delete it->value;
}
m_idToChannel.clear();
}
void InspectorWorkerAgent::createWorkerFrontendChannel(WorkerGlobalScopeProxy* workerGlobalScopeProxy, const String& url)
{
WorkerFrontendChannel* channel = new WorkerFrontendChannel(m_inspectorFrontend, workerGlobalScopeProxy);
m_idToChannel.set(channel->id(), channel);
ASSERT(m_inspectorFrontend);
bool autoconnectToWorkers = m_state->getBoolean(WorkerAgentState::autoconnectToWorkers);
if (autoconnectToWorkers)
channel->connectToWorkerGlobalScope();
m_inspectorFrontend->worker()->workerCreated(channel->id(), url, autoconnectToWorkers);
}
} // namespace WebCore
| [
"karun.matharu@gmail.com"
] | karun.matharu@gmail.com |
75446172a9be698a92db1f0ccd0ccbe82f40fa28 | 7957ca2964ac51be7f5499f64fa00b69baebc103 | /Algorithms/Partitioning_souvenirs/partition3.cpp | f00fa346bb779c1410c2fcae009763750578ccce | [] | no_license | Mohamed07/My_Loc_Repo | dc3375a4aa40aa35a6faebe49eeb8edaf85aa299 | 243f75705ed0070c31c1b2e1cf721ef62370b3c2 | refs/heads/master | 2021-06-04T04:36:04.466081 | 2020-03-29T18:50:55 | 2020-03-29T18:50:55 | 50,921,974 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 923 | cpp | #include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
using std::vector;
using std::max;
int partition3(vector<int> &A) {
if(A.size() == 1)
return 0;
int val4each = accumulate(A.begin(), A.end(), 0);
if(val4each % 3 != 0)
return 0;
val4each /= 3;
sort(A.begin(), A.end(), std::greater<int>());
vector<vector<int>> Wmat(A.size()+1, vector<int>(val4each+1, 0));
for(int row = 1; row <= A.size(); ++row)
{
for(int col = 1; col <= val4each; ++col)
{
if( col - A[row-1] >= 0)
{
Wmat[row][col] = max( Wmat[row-1][col - A[row-1]] + A[row-1]*1, Wmat[row-1][col] );
}
}
}
if(Wmat[A.size()][val4each] == val4each)
return 1;
else
return 0;
}
int main() {
int n;
std::cin >> n;
vector<int> A(n);
for (size_t i = 0; i < A.size(); ++i) {
std::cin >> A[i];
}
std::cout << partition3(A) << '\n';
}
| [
"mohamedyouseif07@gmail.com"
] | mohamedyouseif07@gmail.com |
180a5e8256c9c3c59c21ef703f7599d8c52f8ea3 | b159243e9a2afc0d31d7989b1e6658a86b61d3f2 | /sorting/heap_sorting.cpp | 5a02e899c3de5a6d10eb51fbd0d1fea23a9bed3d | [] | no_license | linuxmint17/data-struct | cfdd452216142b592b1f2dd3893ca5b2a1a22185 | b4b99d747653834d2e94aefb68c95e80cd36f131 | refs/heads/master | 2023-04-15T16:54:48.339484 | 2021-04-28T06:14:36 | 2021-04-28T06:14:36 | 362,099,015 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,063 | cpp | #include <iostream>
#include <random>
#include <vector>
namespace {
template <typename T>
void print_array(std::vector<T> &array)
{
for (auto it = array.begin(); it != array.end(); it++) {
std::cout << *it << '\t';
}
std::cout << '\n';
}
template <typename T>
void swap(T &a, T &b)
{
T tmp = a;
a = b;
b = tmp;
}
void siftup(std::vector<int> &heap, int value)
{
heap.push_back(value);
// pre index > 0 && heap(1, n - 1) ,前置条件成立
// post heap(1, n) 后之结果
int i = heap.size() - 1; // 浪费掉数组的第一个位置
int parent;
while (1) {
if (i == 1) {
break;
}
parent = i / 2;
if (heap[parent] <= heap[i]) {
break;
}
swap(heap[parent], heap[i]);
i = parent;
}
}
/* 使用数组定义满二叉树 */
/*
root = 1
value(i) = array[i]
leftchild(i) = 2 * i
righchild(i) = 2 * i + 1
parent(i) = i / 2
null(i) = (i < 1) or (i > n)
*/
void siftdown(std::vector<int> &heap)
{
// pre heap(2, n) && n >= 0
// post heap(1, n);
int heap_num = heap.size() - 1; // "浪费" 了数组的第一个元素
int i = 1;
int child;
while (1) {
// invariant: heap(1, n) except perhaps between i and its (0, 1 or 2) children */
child = 2 * i;
if (child > heap_num) {
break;
}
if (child + 1 <= heap_num) {
// child + 1 ( 2 * i + 1)is the right child of i;
if (heap[child + 1] < heap[child]) {
child++; // 把 child 设置位较小的child
}
}
// child is lesser than the child of i, 满足小顶堆的定义,break, 否则交换
if (heap[i] <= heap[child]) {
break;
}
swap(heap[child], heap[i]);
i = child;
}
}
}
int main()
{
std::vector<int> array = {-1, 12, 20, 15, 29, 23, 17, 22, 35, 40, 51, 19};
std::cout << std::endl;
print_array(array);
siftup(array, 13);
print_array(array);
std::vector<int> array2 = {-1, 18, 20, 15, 29, 23, 17, 22, 35, 40, 51, 19};
print_array(array2);
siftdown(array2);
print_array(array2);
return 0;
} | [
"2425768511@qq.com"
] | 2425768511@qq.com |
3f24ee1329dd53459961b34b5c58171d110f3f00 | 78a7d770731254bb547f9ea4165369383c226be1 | /tests/functional_tests/main.cpp | 85f1983b920211d6f18db92e598455810b5b1fa9 | [
"BSD-3-Clause",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | incognito-currency/incognito | 9dc18385ce6271c35c8ae17f2ac2b47f75ca8b9e | 2dd5d64a9af2fa46beb6ae6c2218d55c9481f7d7 | refs/heads/master | 2021-04-28T04:47:42.646353 | 2018-10-24T08:40:54 | 2018-10-24T08:40:54 | 128,604,772 | 5 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 5,932 | cpp | // Copyright (c) 2017-2018, The Monero Project
//
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification, are
// permitted provided that the following conditions are met:
//
// 1. Redistributions of source code must retain the above copyright notice, this list of
// conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright notice, this list
// of conditions and the following disclaimer in the documentation and/or other
// materials provided with the distribution.
//
// 3. Neither the name of the copyright holder nor the names of its contributors may be
// used to endorse or promote products derived from this software without specific
// prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
// THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
// THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Parts of this file are originally copyright (c) 2012-2013 The Cryptonote developers
#include <boost/program_options.hpp>
#include "include_base_utils.h"
#include "string_tools.h"
using namespace epee;
#include "common/command_line.h"
#include "common/util.h"
#include "transactions_flow_test.h"
namespace po = boost::program_options;
namespace
{
const command_line::arg_descriptor<bool> arg_test_transactions_flow = {"test_transactions_flow", ""};
const command_line::arg_descriptor<std::string> arg_working_folder = {"working-folder", "", "."};
const command_line::arg_descriptor<std::string> arg_source_wallet = {"source-wallet", "", "", true};
const command_line::arg_descriptor<std::string> arg_dest_wallet = {"dest-wallet", "", "", true};
const command_line::arg_descriptor<std::string> arg_daemon_addr_a = {"daemon-addr-a", "", "127.0.0.1:8080"};
const command_line::arg_descriptor<std::string> arg_daemon_addr_b = {"daemon-addr-b", "", "127.0.0.1:8082"};
const command_line::arg_descriptor<uint64_t> arg_transfer_amount = {"transfer_amount", "", 60000000000000};
const command_line::arg_descriptor<size_t> arg_mix_in_factor = {"mix-in-factor", "", 10};
const command_line::arg_descriptor<size_t> arg_tx_count = {"tx-count", "", 100};
const command_line::arg_descriptor<size_t> arg_tx_per_second = {"tx-per-second", "", 20};
const command_line::arg_descriptor<size_t> arg_test_repeat_count = {"test_repeat_count", "", 1};
}
int main(int argc, char* argv[])
{
TRY_ENTRY();
tools::on_startup();
string_tools::set_module_name_and_folder(argv[0]);
//set up logging options
mlog_configure(mlog_get_default_log_path("functional_tests.log"), true);
mlog_set_log_level(3);
po::options_description desc_options("Allowed options");
command_line::add_arg(desc_options, command_line::arg_help);
command_line::add_arg(desc_options, arg_test_transactions_flow);
command_line::add_arg(desc_options, arg_working_folder);
command_line::add_arg(desc_options, arg_source_wallet);
command_line::add_arg(desc_options, arg_dest_wallet);
command_line::add_arg(desc_options, arg_daemon_addr_a);
command_line::add_arg(desc_options, arg_daemon_addr_b);
command_line::add_arg(desc_options, arg_transfer_amount);
command_line::add_arg(desc_options, arg_mix_in_factor);
command_line::add_arg(desc_options, arg_tx_count);
command_line::add_arg(desc_options, arg_tx_per_second);
command_line::add_arg(desc_options, arg_test_repeat_count);
po::variables_map vm;
bool r = command_line::handle_error_helper(desc_options, [&]()
{
po::store(po::parse_command_line(argc, argv, desc_options), vm);
po::notify(vm);
return true;
});
if (!r)
return 1;
if (command_line::get_arg(vm, command_line::arg_help))
{
std::cout << desc_options << std::endl;
return 0;
}
if (command_line::get_arg(vm, arg_test_transactions_flow))
{
std::string working_folder = command_line::get_arg(vm, arg_working_folder);
std::string path_source_wallet, path_target_wallet;
if(command_line::has_arg(vm, arg_source_wallet))
path_source_wallet = command_line::get_arg(vm, arg_source_wallet);
if(command_line::has_arg(vm, arg_dest_wallet))
path_target_wallet = command_line::get_arg(vm, arg_dest_wallet);
std::string daemon_addr_a = command_line::get_arg(vm, arg_daemon_addr_a);
std::string daemon_addr_b = command_line::get_arg(vm, arg_daemon_addr_b);
uint64_t amount_to_transfer = command_line::get_arg(vm, arg_transfer_amount);
size_t mix_in_factor = command_line::get_arg(vm, arg_mix_in_factor);
size_t transactions_count = command_line::get_arg(vm, arg_tx_count);
size_t transactions_per_second = command_line::get_arg(vm, arg_tx_per_second);
size_t repeat_count = command_line::get_arg(vm, arg_test_repeat_count);
for(size_t i = 0; i != repeat_count; i++)
if(!transactions_flow_test(working_folder, path_source_wallet, path_target_wallet, daemon_addr_a, daemon_addr_b, amount_to_transfer, mix_in_factor, transactions_count, transactions_per_second))
break;
std::string s;
std::cin >> s;
return 1;
}
else
{
std::cout << desc_options << std::endl;
return 1;
}
CATCH_ENTRY_L0("main", 1);
return 0;
}
| [
"ihook98@hotmail.com"
] | ihook98@hotmail.com |
1eb015bf8014100c988684780a4297cc1bfa2d5f | 4ce59b31138592fd921acea8044a5cc770e269b0 | /final_project/src/transport_router.cpp | 178fd59dc1ce9f2e63ef94e609239c041b668590 | [] | no_license | VakhitK/Brown_Belt | c13c8bf86e63434e731b3971c7176f0ac52dda84 | 4a29e536e914972474ea1b3c425e4e485bfe2d2a | refs/heads/master | 2020-06-15T02:34:22.946931 | 2019-07-24T08:27:09 | 2019-07-24T08:27:09 | 195,184,924 | 1 | 7 | null | null | null | null | UTF-8 | C++ | false | false | 4,064 | cpp | #include "transport_router.h"
using namespace std;
TransportRouter::TransportRouter(const Descriptions::StopsDict& stops_dict,
const Descriptions::BusesDict& buses_dict,
const Json::Dict& routing_settings_json) :
routing_settings_(MakeRoutingSettings(routing_settings_json)) {
const size_t vertex_count = stops_dict.size() * 2;
vertices_info_.resize(vertex_count);
graph_ = BusGraph(vertex_count);
FillGraphWithStops(stops_dict);
FillGraphWithBuses(stops_dict, buses_dict);
router_ = std::make_unique<Router>(graph_);
}
TransportRouter::RoutingSettings TransportRouter::MakeRoutingSettings(
const Json::Dict& json) {
return {
json.at("bus_wait_time").AsInt(),
json.at("bus_velocity").AsDouble(),
};
}
void TransportRouter::FillGraphWithStops(
const Descriptions::StopsDict& stops_dict) {
Graph::VertexId vertex_id = 0;
for (const auto& [stop_name, _] : stops_dict) {
auto& vertex_ids = stops_vertex_ids_[stop_name];
vertex_ids.in = vertex_id++;
vertex_ids.out = vertex_id++;
vertices_info_[vertex_ids.in] = {stop_name};
vertices_info_[vertex_ids.out] = {stop_name};
edges_info_.push_back(WaitEdgeInfo{});
const Graph::EdgeId edge_id = graph_.AddEdge({
vertex_ids.out,
vertex_ids.in,
static_cast<double>(routing_settings_.bus_wait_time)
});
assert(edge_id == edges_info_.size() - 1);
}
assert(vertex_id == graph_.GetVertexCount());
}
void TransportRouter::FillGraphWithBuses(
const Descriptions::StopsDict& stops_dict,
const Descriptions::BusesDict& buses_dict) {
for (const auto& [_, bus_item] : buses_dict) {
const auto& bus = *bus_item;
const size_t stop_count = bus.stops.size();
if (stop_count <= 1) {
continue;
}
auto compute_distance_from = [&stops_dict, &bus](size_t lhs_idx) {
return Descriptions::ComputeStopsDistance(*stops_dict.at(bus.stops[lhs_idx]), *stops_dict.at(bus.stops[lhs_idx + 1]));
};
for (size_t start_stop_idx = 0; start_stop_idx + 1 < stop_count; ++start_stop_idx) {
const Graph::VertexId start_vertex = stops_vertex_ids_[bus.stops[start_stop_idx]].in;
int total_distance = 0;
for (size_t finish_stop_idx = start_stop_idx + 1; finish_stop_idx < stop_count; ++finish_stop_idx) {
total_distance += compute_distance_from(finish_stop_idx - 1);
edges_info_.push_back(BusEdgeInfo {
.bus_name = bus.name,
.span_count = finish_stop_idx - start_stop_idx,
});
const Graph::EdgeId edge_id = graph_.AddEdge( {
start_vertex,
stops_vertex_ids_[bus.stops[finish_stop_idx]].out,
total_distance * 1.0 / (routing_settings_.bus_velocity * 1000.0 / 60) // m / (km/h * 1000 / 60) = min
});
assert(edge_id == edges_info_.size() - 1);
}
}
}
}
optional<TransportRouter::RouteInfo> TransportRouter::FindRoute(
const string& stop_from, const string& stop_to) const {
const Graph::VertexId vertex_from = stops_vertex_ids_.at(stop_from).out;
const Graph::VertexId vertex_to = stops_vertex_ids_.at(stop_to).out;
const auto route = router_->BuildRoute(vertex_from, vertex_to);
if (!route) {
return nullopt;
}
RouteInfo route_info = { .total_time = route->weight };
route_info.items.reserve(route->edge_count);
for (size_t edge_idx = 0; edge_idx < route->edge_count; ++edge_idx) {
const Graph::EdgeId edge_id = router_->GetRouteEdge(route->id, edge_idx);
const auto& edge = graph_.GetEdge(edge_id);
const auto& edge_info = edges_info_[edge_id];
if (holds_alternative<BusEdgeInfo>(edge_info)) {
const BusEdgeInfo& bus_edge_info = get<BusEdgeInfo>(edge_info);
route_info.items.push_back(RouteInfo::BusItem { .bus_name =
bus_edge_info.bus_name, .time = edge.weight, .span_count =
bus_edge_info.span_count, });
} else {
const Graph::VertexId vertex_id = edge.from;
route_info.items.push_back(RouteInfo::WaitItem { .stop_name =
vertices_info_[vertex_id].stop_name, .time = edge.weight, });
}
}
// Releasing in destructor of some proxy object would be better,
// but we do not expect exceptions in normal workflow
router_->ReleaseRoute(route->id);
return route_info;
}
| [
"vakhitkalimullin@gmail.com"
] | vakhitkalimullin@gmail.com |
f21335e30efa284760a7762a544994d4e44c7249 | 758e144a4915e5a4a76699d284e64ef8c6382c01 | /VrAppFramework/Src/OVR_Geometry.cpp | 3522c353bccce67be72c17f0ecf5df9975f460bb | [
"LicenseRef-scancode-public-domain",
"MIT"
] | permissive | drewwebster/lovr-oculus-mobile | 32c9489e39a228d91765af91529385b310813c62 | 9c0dd9c44829b75bc088d4d014a77c57ef245417 | refs/heads/master | 2020-11-29T04:53:30.035460 | 2019-10-15T20:26:15 | 2019-10-15T20:26:15 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,218 | cpp | /************************************************************************************
Filename : OVR_Geometry.cpp
Content : Geometry.
Created : May, 2014
Authors : J.M.P. van Waveren
Copyright : Copyright (c) Facebook Technologies, LLC and its affiliates. All rights reserved.
*************************************************************************************/
#include <math.h>
#include <algorithm> // for min, max
#include "Kernel/OVR_Types.h"
#include "Kernel/OVR_Math.h"
namespace OVR
{
bool Intersect_RayBounds( const Vector3f & rayStart, const Vector3f & rayDir,
const Vector3f & mins, const Vector3f & maxs,
float & t0, float & t1 )
{
const float rcpDirX = ( fabsf( rayDir.x ) > MATH_FLOAT_SMALLEST_NON_DENORMAL ) ? ( 1.0f / rayDir.x ) : MATH_FLOAT_HUGE_NUMBER;
const float rcpDirY = ( fabsf( rayDir.y ) > MATH_FLOAT_SMALLEST_NON_DENORMAL ) ? ( 1.0f / rayDir.y ) : MATH_FLOAT_HUGE_NUMBER;
const float rcpDirZ = ( fabsf( rayDir.z ) > MATH_FLOAT_SMALLEST_NON_DENORMAL ) ? ( 1.0f / rayDir.z ) : MATH_FLOAT_HUGE_NUMBER;
const float sX = ( mins.x - rayStart.x ) * rcpDirX;
const float sY = ( mins.y - rayStart.y ) * rcpDirY;
const float sZ = ( mins.z - rayStart.z ) * rcpDirZ;
const float tX = ( maxs.x - rayStart.x ) * rcpDirX;
const float tY = ( maxs.y - rayStart.y ) * rcpDirY;
const float tZ = ( maxs.z - rayStart.z ) * rcpDirZ;
const float minX = std::min( sX, tX );
const float minY = std::min( sY, tY );
const float minZ = std::min( sZ, tZ );
const float maxX = std::max( sX, tX );
const float maxY = std::max( sY, tY );
const float maxZ = std::max( sZ, tZ );
t0 = std::max( minX, std::max( minY, minZ ) );
t1 = std::min( maxX, std::min( maxY, maxZ ) );
return ( t0 <= t1 );
}
bool Intersect_RayTriangle( const Vector3f & rayStart, const Vector3f & rayDir,
const Vector3f & v0, const Vector3f & v1, const Vector3f & v2,
float & t0, float & u, float & v )
{
OVR_ASSERT( rayDir.IsNormalized() );
const Vector3f edge1 = v1 - v0;
const Vector3f edge2 = v2 - v0;
const Vector3f tv = rayStart - v0;
const Vector3f pv = rayDir.Cross( edge2 );
const Vector3f qv = tv.Cross( edge1 );
const float det = edge1.Dot( pv );
// If the determinant is negative then the triangle is backfacing.
if ( det <= 0.0f )
{
return false;
}
// This code has been modified to only perform a floating-point
// division if the ray actually hits the triangle. If back facing
// triangles are not culled then the sign of 's' and 't' need to
// be flipped. This can be accomplished by multiplying the values
// with the determinant instead of the reciprocal determinant.
const float s = tv.Dot( pv );
const float t = rayDir.Dot( qv );
if ( s >= 0.0f && s <= det )
{
if ( t >= 0.0f && s + t <= det )
{
// If the determinant is almost zero then the ray lies in the triangle plane.
// This comparison is done last because it is usually rare for
// the ray to lay in the triangle plane.
if ( fabsf( det ) > MATH_FLOAT_SMALLEST_NON_DENORMAL )
{
const float rcpDet = 1.0f / det;
t0 = edge2.Dot( qv ) * rcpDet;
u = s * rcpDet;
v = t * rcpDet;
return true;
}
}
}
return false;
}
}
| [
"andi.m.mcclure@gmail.com"
] | andi.m.mcclure@gmail.com |
dafa34a49aab962d2d250907538d265a5a5fd108 | ac21ebfeddb4dbefc0db3365d2faf4b926842763 | /semGen.cpp | 80708ee1b95df582d0e1fce582fb12cc0ccc57ba | [] | no_license | benyammengesha/compiler-project | bd9bae8228aef8cf58c43f8b1952a46375933d12 | 880b9ae063699aa0efe43bd47a21edebd4cef23d | refs/heads/master | 2021-10-23T21:10:42.483738 | 2019-03-20T03:15:18 | 2019-03-20T03:15:18 | 107,356,577 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 8,925 | cpp | #prepared by Benyam Mengesha, Archana Patel, and Syltinsy Jenkins
#include "semGen.h"
#include <stdlib.h>
#include <iostream>
using namespace std;
symbols *symbolTable;
int numVars = 0;
int stackSize = 0;
static int varType;
symbols* lookup(char *name) {
symbols *s;
for (s = symbolTable; s != NULL; s = s->next) {
if (!strcmp(name, s->name)) return s;
}
return NULL;
}
void insert(char *name, int type, int variableNumber) {
symbols *s = new symbols(name, type, variableNumber);
s->next = symbolTable;
symbolTable = s;
}
void error(treenode *t) {
if (t == NULL) {
fprintf(stderr, "\t ln line no: \"%d\"\n", t->lineno, t->name);
fprintf(stderr, " error ");
abort();
}
}
int getlabel() {
static int label = 0;
return (++label);
}
int assignNumber() {
static int variableNumber = 0;
return (++variableNumber);
}
void semanticVariables(treenode *t){
switch (t->type)
{
case ProgType:
varType = OUT;
semanticVariables(t->children[0]);
varType = IN;
semanticVariables(t->children[1]);
varType = LOCAL;
semanticVariables(t->children[2]);
semanticVariables(t->children[3]);
break;
case IdentifierType:
t->variableNumber = assignNumber();
t->decl = (lookup(t->name) == NULL);
numVars++;
if (lookup(t->name) == NULL)
{
insert(t->name, varType, t->variableNumber);
}
else {
error(t);
fprintf(stdout, "\t ln line no: \"%d\"\n", t->lineno);
fprintf(stdout, "\t ERROR REDECLARED VARIABLE ", t->name);
/*
cout << endl;
cout << "\t ERROR PRODUCTION "<< endl;
*/
}
break;
case SpaceType:
semanticVariables(t->children[0]);
semanticVariables(t->children[1]);
break;
case EpsilonType:
break;
}
//Parses through the tree view for all top level variables
}
//semantic analyzer check for any error
void semanticProgram(treenode *t)
{
switch (t->type)
{
case IdentifierType:
if (lookup(t->name) == NULL)
{
error(t);
abort();
fprintf(stderr, "\t ln line no: \"%d\"\n", t->lineno);
fprintf(stderr, "\t ERROR - UNDECLARED VARIABLE NAME ", t->lineno);
}
else
{
symbols *s = lookup(t->name);
t->variableNumber = s->variableNumber;
stackSize++;
}
break;
case NumberType:
stackSize++;
break;
case AddType:
semanticProgram(t->children[0]);
semanticProgram(t->children[1]);
break;
case SubtractType:
t->label1 = getlabel();
semanticProgram(t->children[0]);
semanticProgram(t->children[1]);
break;
case MultiplyType:
semanticProgram(t->children[0]);
semanticProgram(t->children[1]);
break;
case DivideType:
semanticProgram(t->children[0]);
semanticProgram(t->children[1]);
break;
case ProgType:
stackSize = 0;
semanticProgram(t->children[3]);
break;
case GreaterThanType:
t->label1 = getlabel();
semanticProgram(t->children[0]);
t->label2 = getlabel();
semanticProgram(t->children[1]);
break;
case IfType:
t->label1 = getlabel();
t->label2 = getlabel();
semanticProgram(t->children[0]);
semanticProgram(t->children[1]);
semanticProgram(t->children[2]);
break;
case WhileType:
t->label1 = getlabel();
t->label2 = getlabel();
semanticProgram(t->children[0]);
semanticProgram(t->children[1]);
break;
case EpsilonType:
break;
case AssignmentType:
semanticProgram(t->children[0]);
semanticProgram(t->children[1]);
break;
case EqualsType:
t->label1 = getlabel();
t->label2 = getlabel();
semanticProgram(t->children[0]);
semanticProgram(t->children[1]);
break;
case EndStatementType:
semanticProgram(t->children[0]);
semanticProgram(t->children[1]);
break;
}
}
//Parses through the tree view for all operators
void codeGenerator(treenode *t)
{
switch (t->type)
{
fprintf(stdout, "inside cod gen=%d\n,t->type");
case ProgType:
fprintf(stdout, "; COSC 561 Simpl Compiler V1\n");
fprintf(stdout, ".class public %s\n", t->children[0]->name);
fprintf(stdout, ".super java/lang/Object\n");
fprintf(stdout, ".method public static main([Ljava/lang/String;)V\n");
codeGenerator(t->children[0]);
codeGenerator(t->children[1]);
codeGenerator(t->children[2]);
codeGenerator(t->children[3]);
fprintf(stdout, "\tiload %d\n", t->children[0]->variableNumber);
fprintf(stdout, "\tinvokestatic simpl/outputNum(I)V\n");
fprintf(stdout, "\treturn\n");
fprintf(stdout, ".limit stack %d\n", stackSize + 1);
fprintf(stdout, ".limit locals %d\n", numVars + 1);
fprintf(stdout, ".end method\n");
break;
case IdentifierType:
if (t->decl == true)
{
t->decl = false;
symbols *s = lookup(t->name);
switch (s->type)
{
case OUT:
fprintf(stdout, "\tldc \"%s\"\n", t->name);
fprintf(stdout, "\tinvokestatic simpl/registerIO(Ljava/lang/String;)V\n");
fprintf(stdout, "\tsipush 0\n");
fprintf(stdout, "\tistore %d\n", t->variableNumber);
break;
case IN:
fprintf(stdout, "\tldc \"%s\"\n", t->name);
fprintf(stdout, "\tinvokestatic simpl/inputNum(Ljava/lang/String;)I\n");
fprintf(stdout, "\tistore %d\n", t->variableNumber);
break;
case LOCAL:
fprintf(stdout, "\tsipush 0\n");
fprintf(stdout, "\tistore %d\n", t->variableNumber);
break;
}
}
else {
fprintf(stdout, "\tiload %d\n", t->variableNumber);
}
break;
case SpaceType:
codeGenerator(t->children[0]);
codeGenerator(t->children[1]);
break;
case EpsilonType:
break;
case EndStatementType://!
codeGenerator(t->children[0]);
codeGenerator(t->children[1]);
break;
case IfType:
codeGenerator(t->children[0]);
fprintf(stdout, "\tifeq L%d", t->label1);
fprintf(stdout, "\n");
codeGenerator(t->children[1]);
fprintf(stdout, "\tgoto L%d", t->label2); //**********************
fprintf(stdout, "\n");
fprintf(stdout, " L%d:", t->label1);// getlabel());
fprintf(stdout, "\n");
//cout << "\tgoto L" << getlabel() << endl;
//cout << "L" << getlabel() << endl;
codeGenerator(t->children[2]);
fprintf(stdout, " L%d:", t->label2);// getlabel());
fprintf(stdout, "\n");
//cout << "L" << getlabel() << endl;
break;
case WhileType:
fprintf(stdout, " L%d:", t->label1);
fprintf(stdout, "\n");
//cout << "L" << getlabel() << endl;
codeGenerator(t->children[0]);
fprintf(stdout, "\tifeq L%d", t->label2);
fprintf(stdout, "\n");
codeGenerator(t->children[1]);
fprintf(stdout, "\tgoto L%d", t->label1);
fprintf(stdout, "\n");
fprintf(stdout, " L%d:", t->label2);
fprintf(stdout, "\n");
//cout << "\tgoto L" << getlabel() << endl;
//cout << "L" << getlabel() << endl;
break;
case AssignmentType:
codeGenerator(t->children[1]);
fprintf(stdout, "\tistore %d\n", t->children[0]->variableNumber);
break;
case GreaterThanType:
codeGenerator(t->children[0]);
codeGenerator(t->children[1]);
fprintf(stdout, "\tif_icmpgt L%d", t->label1);
fprintf(stdout, "\n");
fprintf(stdout, "\tsipush 0\n");
fprintf(stdout, "\tgoto L%d", t->label2);
fprintf(stdout, "\n");
fprintf(stdout, " L%d:", t->label1);
fprintf(stdout, "\n");
//cout << "\tgoto L" << getlabel()<< endl;
//cout << "L" << getlabel()<< endl;
fprintf(stdout, "\tsipush 1\n");
fprintf(stdout, " L%d:", t->label2);
fprintf(stdout, "\n");
//cout << "L" << getlabel() << endl;
break;
case EqualsType:
codeGenerator(t->children[0]);
codeGenerator(t->children[1]);
fprintf(stdout, "\tif_icmpeq L%d", t->label1);
fprintf(stdout, "\n");
fprintf(stdout, "\tsipush 0\n");
fprintf(stdout, "\tgoto L%d", t->label2);
fprintf(stdout, "\n");
fprintf(stdout, " L%d:", t->label1);
fprintf(stdout, "\n");
//cout << "\tgoto L" << getlabel() << endl;
//cout << "L" << getlabel() << endl;
fprintf(stdout, "\tsipush 1\n");
fprintf(stdout, "\n");
fprintf(stdout, " L%d:", t->label2);
fprintf(stdout, "\n");
//cout << "L" << getlabel() << endl;
break;
case AddType:
codeGenerator(t->children[0]);
codeGenerator(t->children[1]);
fprintf(stdout, "\tiadd \n");
break;
case SubtractType:
codeGenerator(t->children[0]);
codeGenerator(t->children[1]);
fprintf(stdout, "\tisub \n");
fprintf(stdout, "\tdup \n");
fprintf(stdout, "\tifge \n", t->label1);
fprintf(stdout, "\tpop \n");
fprintf(stdout, "\tsipush 0\n");
fprintf(stdout, " L%d:", t->label1);
fprintf(stdout, "\n");
//cout << "L" << getlabel() << "\n";
break;
case MultiplyType:
codeGenerator(t->children[0]);
codeGenerator(t->children[1]);
fprintf(stdout, "\timul \n");
break;
case DivideType:
codeGenerator(t->children[0]);
codeGenerator(t->children[1]);
fprintf(stdout, "\tidiv \n");
break;
case NumberType:
fprintf(stdout, "\tsipush %s\n", t->name);
break;
}
}
| [
"noreply@github.com"
] | noreply@github.com |
6707e4fc7e5b4764feb010ad599692ef2efcbf00 | d5f07b8b1bc89dc20f855624b8c7956ea88596d1 | /src/GreenThread.hpp | d2cbf9c99cd13a1d1ce32864a262a0feecf3c45a | [
"MIT"
] | permissive | Fabio3rs/CppGreenThreadsStudy | f7c80d26fb49839bf3882946bfa27b0eb8fc2f01 | e77a0a089509f8b3035e24caef407393823098d3 | refs/heads/main | 2023-09-05T17:26:24.552065 | 2021-11-22T23:03:17 | 2021-11-22T23:03:17 | 428,066,778 | 0 | 0 | null | 2021-11-14T23:35:47 | 2021-11-14T23:34:38 | C++ | UTF-8 | C++ | false | false | 2,459 | hpp | #pragma once
#include <cstdint>
#include <cstdio>
#include <deque>
#include <functional>
#include <memory>
struct context;
class GreenThreadMgr;
class GreenThread {
friend GreenThreadMgr;
typedef std::function<int(GreenThreadMgr &, void *)> greenfn_t;
std::shared_ptr<context> ctx;
std::shared_ptr<uintptr_t[]> stack;
greenfn_t thrfn;
GreenThreadMgr *thrmanager;
void *argval;
bool to_delete;
void set_arg(void *arg);
void prepare_stack();
void *prepare_stack(size_t reserve);
static void call_wrapper [[noreturn]] (GreenThread >hread);
public:
auto get_manager() const { return thrmanager; }
GreenThread(greenfn_t fun, GreenThreadMgr *mgrhandle, void *arg);
GreenThread(GreenThreadMgr *mgrhandle);
};
class GreenThreadMgr {
std::deque<GreenThread> threads;
std::deque<GreenThread>::iterator current_it;
public:
GreenThread *get_current() const { return current_it.operator->(); }
size_t new_thread(GreenThread::greenfn_t fun, void *argval = nullptr);
template <typename rawfn_T, class... Types>
size_t new_thread_custom(rawfn_T fun, Types &&... args) {
using args_tuple_t = decltype(std::tuple{std::forward<Types>(args)...});
typedef struct
{
args_tuple_t argument_tuple;
rawfn_T thread_start_fn;
} GreenThreadData;
auto forward_args_lambda_wrapper = [](GreenThreadMgr &inst,
void *argsdata) {
GreenThreadData &oldthrdata = *reinterpret_cast<GreenThreadData *>(argsdata);
GreenThreadData fnargs = std::move(oldthrdata);
std::function thrfn{fnargs.thread_start_fn};
oldthrdata.~GreenThreadData();
std::apply(
[thrfn, &inst](auto &&... argsq) { thrfn(inst, argsq...); },
fnargs.argument_tuple);
return 0;
};
threads.push_back({forward_args_lambda_wrapper, this, nullptr});
auto &greenthrd = threads.back();
auto argsdata = new (greenthrd.prepare_stack(sizeof(GreenThreadData)))
GreenThreadData{std::tuple{std::forward<Types>(args)...}, fun};
greenthrd.set_arg(argsdata);
return threads.size();
}
void yield();
void end_current();
GreenThreadMgr();
~GreenThreadMgr() {
while (threads.size() > 1) {
yield();
}
}
};
| [
"fabio3rs@gmail.com"
] | fabio3rs@gmail.com |
3e373cce2c33d56b977add6021e7fbf8b10e4d34 | 60bb35226eaecbfec6187188dc2029205dbfbf58 | /src/convert/convert_yuy2torgb.cpp | eb52c12ac57164cca1e13192d2358e14bc087181 | [] | no_license | charygao/avisynth | 0527c53afa4c3ff59bbfffe19f41e65fce32da8d | 07b92b2ee5a3f2c8ee3d6fe236eb808b866ca094 | refs/heads/master | 2021-10-09T10:02:45.013859 | 2015-09-14T20:23:59 | 2015-09-14T20:23:59 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 13,474 | cpp | // Avisynth v2.5. Copyright 2002 Ben Rudiak-Gould et al.
// http://www.avisynth.org
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA, or visit
// http://www.gnu.org/copyleft/gpl.html .
//
// Linking Avisynth statically or dynamically with other modules is making a
// combined work based on Avisynth. Thus, the terms and conditions of the GNU
// General Public License cover the whole combination.
//
// As a special exception, the copyright holders of Avisynth give you
// permission to link Avisynth with independent modules that communicate with
// Avisynth solely through the interfaces defined in avisynth.h, regardless of the license
// terms of these independent modules, and to copy and distribute the
// resulting combined work under terms of your choice, provided that
// every copy of the combined work is accompanied by a complete copy of
// the source code of Avisynth (the version of Avisynth used to produce the
// combined work), being distributed under the terms of the GNU General
// Public License plus this exception. An independent module is a module
// which is not derived from or based on Avisynth, such as 3rd-party filters,
// import and export plugins, or graphical user interfaces.
// Convert_YUY2toRGB (c) 2015 by Ian Brabham
#include "stdafx.h"
#include "convert_yuy2torgb.h"
#define USE_DYNAMIC_COMPILER true
YUY2toRGBGenerator::YUY2toRGBGenerator() { }
YUY2toRGBGenerator::~YUY2toRGBGenerator() {
assembly.Free();
}
struct yuv2rgb_constants {
__int64 x0000_0000_0010_0010;
__int64 x0080_0080_0080_0080;
__int64 x00002000_00002000;
__int64 xFF000000_FF000000;
__int64 cy;
__int64 crv;
__int64 cgu_cgv;
__int64 cbu;
};
__declspec(align(64)) struct yuv2rgb_constants yuv2rgb_constants_rec601 = {
0x00000000000100010, // 16
0x00080008000800080, // 128
0x00000200000002000, // 8192 = (0.5)<<14
0x0FF000000FF000000, //
0x000004A8500004A85, // 19077 = (255./219.)<<14+0.5
0x03313000033130000, // 13075 = ((1-0.299)*255./112.)<<13+0.5
0x0E5FCF377E5FCF377, // -6660, -3209 = ((K-1)*K/0.587*255./112.)<<13-0.5, K=(0.299, 0.114)
0x00000408D0000408D // 16525 = ((1-0.114)*255./112.)<<13+0.5
};
__declspec(align(64)) struct yuv2rgb_constants yuv2rgb_constants_PC_601 = {
0x00000000000000000, // 0
0x00080008000800080, // 128
0x00000200000002000, // 8192 = (0.5)<<14
0x0FF000000FF000000, //
0x00000400000004000, // 16384 = (1.)<<14+0.5
0x02D0B00002D0B0000, // 11531 = ((1-0.299)*255./127.)<<13+0.5
0x0E90FF4F2E90FF4F2, // -5873, -2830 = (((K-1)*K/0.587)*255./127.)<<13-0.5, K=(0.299, 0.114)
0x0000038ED000038ED // 14573 = ((1-0.114)*255./127.)<<13+0.5
};
__declspec(align(64)) struct yuv2rgb_constants yuv2rgb_constants_rec709 = {
0x00000000000100010, // 16
0x00080008000800080, // 128
0x00000200000002000, // 8192 = (0.5)<<14
0x0FF000000FF000000, //
0x000004A8500004A85, // 19077 = (255./219.)<<14+0.5
0x0395E0000395E0000, // 14686 = ((1-0.2126)*255./112.)<<13+0.5
0x0EEF2F92DEEF2F92D, // -4366, -1747 = ((K-1)*K/0.7152*255./112.)<<13-0.5, K=(0.2126, 0.0722)
0x00000439900004399 // 17305 = ((1-0.0722)*255./112.)<<13+0.5
};
__declspec(align(64)) struct yuv2rgb_constants yuv2rgb_constants_PC_709 = {
0x00000000000000000, // 0
0x00080008000800080, // 128
0x00000200000002000, // 8192 = (0.5)<<14
0x0FF000000FF000000, //
0x00000400000004000, // 16384 = (1.)<<14+0.5
0x03298000032980000, // 12952 = ((1-0.2126)*255./127.)<<13+0.5
0x0F0F6F9FBF0F6F9FB, // -3850, -1541 = (((K-1)*K/0.7152)*255./127.)<<13-0.5, K=(0.2126, 0.0722)
0x000003B9D00003B9D // 15261 = ((1-0.0722)*255./127.)<<13+0.5
};
enum {
ofs_x0000_0000_0010_0010 = 0,
ofs_x0080_0080_0080_0080 = 8,
ofs_x00002000_00002000 = 16,
ofs_xFF000000_FF000000 = 24,
ofs_cy = 32,
ofs_crv = 40,
ofs_cgu_cgv = 48,
ofs_cbu = 56
};
// ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
void YUY2toRGBGenerator::Get_Y(Assembler &x86, MMREG mm_A, int uyvy) {
if (uyvy) {
x86.psrlw( mm_A, 8);
}
else {
x86.pand( mm_A, mm7);
}
}
void YUY2toRGBGenerator::Get_UV(Assembler &x86, MMREG mm_A, int uyvy) {
Get_Y(x86, mm_A, 1-uyvy);
}
void YUY2toRGBGenerator::InnerLoop(Assembler &x86, int uyvy, int rgb32, int no_next_pixel, bool Y_16) {
/*
;; This YUV422->RGB conversion code uses only four MMX registers per
;; source dword, so I convert two dwords in parallel. Lines corresponding
;; to the "second pipe" are indented an extra space. There's almost no
;; overlap, except at the end and in the three lines marked ***.
;; revised 4july, 2002 to properly set alpha in rgb32 to default "on" & other small memory optimizations
*/
// mm0 mm1 mm2 mm3 mm4 mm5 mm6 mm7
x86.movd( mm0, dword_ptr[esi]);
x86.pcmpeqw( mm7, mm7); // 0xFFFFFFFFFFFFFFFFi64
x86.movd( mm5, dword_ptr[esi+4]);
x86.psrlw( mm7, 8); // 0x00FF00FF00FF00FFi64
x86.movq( mm1, mm0);
Get_Y(x86, mm0, uyvy); // mm0 = __________Y1__Y0
x86.movq( mm4, mm5);
Get_UV(x86, mm1, uyvy); // mm1 = __________V0__U0
Get_Y(x86, mm4, uyvy); // mm4 = __________Y3__Y2
x86.movq( mm2, mm5); // *** avoid reload from [esi+4]
Get_UV(x86, mm5, uyvy); // mm5 = __________V2__U2
if (Y_16)
x86.psubw( mm0, qword_ptr[edx+ofs_x0000_0000_0010_0010]); // (Y-16)
x86.movd( mm6, dword_ptr[esi+8-4*(no_next_pixel)]);
Get_UV(x86, mm2, uyvy); // mm2 = __________V2__U2
if (Y_16)
x86.psubw( mm4, qword_ptr[edx+ofs_x0000_0000_0010_0010]); // (Y-16)
x86.paddw( mm2, mm1); // 2*UV1=UV0+UV2
Get_UV(x86, mm6, uyvy); // mm6 = __________V4__U4
x86.psubw( mm1, qword_ptr[edx+ofs_x0080_0080_0080_0080]); // (UV-128)
x86.paddw( mm6, mm5); // 2*UV3=UV2+UV4
x86.psllq( mm2, 32);
x86.psubw( mm5, qword_ptr[edx+ofs_x0080_0080_0080_0080]); // (UV-128)
x86.punpcklwd( mm0, mm2); // mm0 = ______Y1______Y0
x86.psllq( mm6, 32);
x86.pmaddwd( mm0, qword_ptr[edx+ofs_cy]); // (Y-16)*(255./219.)<<14
x86.punpcklwd( mm4, mm6);
x86.paddw( mm1, mm1); // 2*UV0=UV0+UV0
x86.pmaddwd( mm4, qword_ptr[edx+ofs_cy]);
x86.paddw( mm5, mm5); // 2*UV2=UV2+UV2
x86.paddw( mm1, mm2); // mm1 = __V1__U1__V0__U0 * 2
x86.paddd( mm0, qword_ptr[edx+ofs_x00002000_00002000]); // +=0.5<<14
x86.paddw( mm5, mm6); // mm5 = __V3__U3__V2__U2 * 2
x86.movq( mm2, mm1);
x86.paddd( mm4, qword_ptr[edx+ofs_x00002000_00002000]); // +=0.5<<14
x86.movq( mm3, mm1);
x86.movq( mm6, mm5);
x86.pmaddwd( mm1, qword_ptr[edx+ofs_crv]);
x86.movq( mm7, mm5);
x86.paddd( mm1, mm0);
x86.pmaddwd( mm5, qword_ptr[edx+ofs_crv]);
x86.psrad( mm1, 14); // mm1 = RRRRRRRRrrrrrrrr
x86.paddd( mm5, mm4);
x86.pmaddwd( mm2, qword_ptr[edx+ofs_cgu_cgv]);
x86.psrad( mm5, 14);
x86.paddd( mm2, mm0);
x86.pmaddwd( mm6, qword_ptr[edx+ofs_cgu_cgv]);
x86.psrad( mm2, 14); // mm2 = GGGGGGGGgggggggg
x86.paddd( mm6, mm4);
x86.pmaddwd( mm3, qword_ptr[edx+ofs_cbu]);
x86.psrad( mm6, 14);
x86.paddd( mm3, mm0);
x86.pmaddwd( mm7, qword_ptr[edx+ofs_cbu]);
x86.add( esi, 8);
x86.add( edi, 12+4*rgb32);
if (no_next_pixel == 0) {
x86.cmp( esi, ecx);
}
x86.psrad( mm3, 14); // mm3 = BBBBBBBBbbbbbbbb
x86.paddd( mm7, mm4);
x86.pxor( mm0, mm0);
x86.psrad( mm7, 14);
x86.packssdw( mm3, mm2); // mm3 = GGGGggggBBBBbbbb
x86.packssdw( mm7, mm6);
x86.packssdw( mm1, mm0); // mm1 = ________RRRRrrrr
x86.packssdw( mm5, mm0); // *** avoid pxor mm4, mm4
x86.movq( mm2, mm3);
x86.movq( mm6, mm7);
x86.punpcklwd( mm2, mm1); // mm2 = RRRRBBBBrrrrbbbb
x86.punpcklwd( mm6, mm5);
x86.punpckhwd( mm3, mm1); // mm3 = ____GGGG____gggg
x86.punpckhwd( mm7, mm5);
x86.movq( mm0, mm2);
x86.movq( mm4, mm6);
x86.punpcklwd( mm0, mm3); // mm0 = ____rrrrggggbbbb
x86.punpcklwd( mm4, mm7);
if (rgb32 == 0) { // rgb24
x86.psllq( mm0, 16);
x86.psllq( mm4, 16);
}
x86.punpckhwd( mm2, mm3); // mm2 = ____RRRRGGGGBBBB
x86.punpckhwd( mm6, mm7);
x86.packuswb( mm0, mm2); // mm0 = __RRGGBB__rrggbb <- ta dah!
x86.packuswb( mm4, mm6);
if (rgb32 != 0) { // rgb32
x86.por( mm0, qword_ptr[edx+ofs_xFF000000_FF000000]); // set alpha channels "on"
x86.por( mm4, qword_ptr[edx+ofs_xFF000000_FF000000]);
x86.movq( qword_ptr[edi-16], mm0); // store the quadwords independently
x86.movq( qword_ptr[edi-8], mm4);
}
else { // rgb24
x86.psrlq( mm0, 8); // pack the two quadwords into 12 bytes
x86.psllq( mm4, 8); // (note: the two shifts above leave
x86.movd( dword_ptr[edi-12], mm0); // mm0,4 = __RRGGBBrrggbb__)
x86.psrlq( mm0, 32);
x86.por( mm4, mm0);
x86.movd( dword_ptr[edi-8], mm4);
x86.psrlq( mm4, 32);
x86.movd( dword_ptr[edi-4], mm4);
}
}
// ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
// void __cdecl procname(
// [esp+ 4] const BYTE* src,
// [esp+ 8] BYTE* dst,
// [esp+12] const BYTE* src_end,
// [esp+16] int src_pitch,
// [esp+20] int row_size
// ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
void YUY2toRGBGenerator::YUV2RGB_PROC(Assembler &x86, int uyvy, int rgb32, int theMatrix) {
enum { // Argument offsets
src = 0,
dstp = 4,
src_end = 8,
src_pitch = 12,
row_size = 16,
};
bool Y_16;
x86.push( esi);
x86.push( edi);
x86.push( ebx);
x86.mov( eax, dword_ptr[ebp+src_pitch]);// src_pitch
x86.mov( esi, dword_ptr[ebp+src_end]); // src_end - read source bottom-up
x86.mov( edi, dword_ptr[ebp+dstp]); // dstp
x86.mov( ebx, dword_ptr[ebp+row_size]); // row_size
switch (theMatrix) {
case 1:
Y_16 = !!yuv2rgb_constants_rec709.x0000_0000_0010_0010;
x86.mov( edx, (int)&yuv2rgb_constants_rec709);
break;
case 3:
Y_16 = !!yuv2rgb_constants_PC_601.x0000_0000_0010_0010;
x86.mov( edx, (int)&yuv2rgb_constants_PC_601);
break;
case 7:
Y_16 = !!yuv2rgb_constants_PC_709.x0000_0000_0010_0010;
x86.mov( edx, (int)&yuv2rgb_constants_PC_709);
break;
default:
Y_16 = !!yuv2rgb_constants_rec601.x0000_0000_0010_0010;
x86.mov( edx, (int)&yuv2rgb_constants_rec601);
}
//loop0:
x86.align( 16);
x86.label( "loop0");
x86.sub( esi, eax);
x86.lea( ecx, dword_ptr[esi+ebx-8]);
//loop1:
x86.align( 16);
x86.label( "loop1");
InnerLoop(x86, uyvy, rgb32, 0, Y_16);
x86.jb( "loop1");
InnerLoop(x86, uyvy, rgb32, 1, Y_16);
x86.sub( esi, ebx);
x86.cmp( esi, dword_ptr[ebp+src]); // src
x86.ja( "loop0");
x86.emms();
x86.pop( ebx);
x86.pop( edi);
x86.pop( esi);
}
void YUY2toRGBGenerator::Generate(bool isRGB32, int theMatrix, IScriptEnvironment* env) {
Assembler x86; // This is the class that assembles the code.
x86.push( ebp);
x86.mov( ebp, dword_ptr[esp+4+4]); // Pointer to args list
YUV2RGB_PROC(x86, 0, (int)isRGB32, theMatrix);
x86.xor( eax, eax);
x86.pop( ebp);
x86.ret();
assembly = DynamicAssembledCode(x86, env, "mmx_YUY2toRGB Dynamic MMX code could not be compiled.");
}
| [
"ianb1957"
] | ianb1957 |
84be7b558689393bc8af46401357203fe6285e36 | 942aed97e96bfe3665bfe9a27366a970bb89424f | /src/zmq/zmqconfig.h | 14676ddc4cbf70b5e9563385fa758286acd40f6d | [
"MIT"
] | permissive | ygtars/industry | 8c4c4991bb2d65087783a15145351c354f26c06f | a3e65d5e78fdb5746c960472195e4b6f88fcab35 | refs/heads/master | 2020-04-06T14:31:05.669503 | 2018-11-14T14:29:53 | 2018-11-14T14:29:53 | 157,544,183 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 534 | h | // Copyright (c) 2015 The Bitcoin Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#ifndef BITCOIN_ZMQ_ZMQCONFIG_H
#define BITCOIN_ZMQ_ZMQCONFIG_H
#if defined(HAVE_CONFIG_H)
#include "config/IDY-config.h"
#endif
#include <stdarg.h>
#include <string>
#if ENABLE_ZMQ
#include <zmq.h>
#endif
#include "primitives/block.h"
#include "primitives/transaction.h"
void zmqError(const char *str);
#endif // BITCOIN_ZMQ_ZMQCONFIG_H
| [
"38437000+ygtars@users.noreply.github.com"
] | 38437000+ygtars@users.noreply.github.com |
53d3884bcffe0c24283e6dfc03ebdc054f011b0d | d9dccde0d6e412a13f3ea5ff54a4de528533d7ad | /cat-file.cpp | 345f20f48a8a4e20d2a6f4798980e0c43ece452d | [] | no_license | amrit161995/Version-Control-System | cbbb0c0b7d29da8b84f950155c2fb9294a337584 | 8bd74f976b3fbad20e2b3f12855a1f5d1df63d08 | refs/heads/master | 2020-04-15T05:30:52.044916 | 2018-12-01T00:37:43 | 2018-12-01T00:37:43 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,197 | cpp | #include<stdio.h>
#include<string>
#include <openssl/sha.h>
#include <unistd.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <vector>
#include<fstream>
#include<iostream>
#include<stdlib.h>
#include <ctime>
#include <bits/stdc++.h>
#include "cat-file.h"
#include "gitCommit.h"
#include "tree.h"
#include "gitAdd.h"
#include "generateSHA.h"
#include "indexCreate.h"
using namespace std;
void catfile(string hash){
string type="";
// cout<<"ad";
struct stat buf;
int flag=0;
if (stat(".mygit/info/objectsFile.txt", &buf) != -1)
{
vector <string> objectsvec;
// cout<<"hello";
std::ifstream in(".mygit/info/objectsFile.txt");
string str;
while (std::getline(in, str))
{
// Line contains string of length > 0 then save it in vector
if(str.size() > 0)
objectsvec.push_back(str);
}
for(int i=0;i<objectsvec.size();i++){
string line = objectsvec[i];
vector <string> tokens;
stringstream check1(line);
string intermediate;
while(getline(check1, intermediate, ' '))
{
tokens.push_back(intermediate);
}
if(hash == tokens[0])
type=tokens[1];
// parent = tokens[1];
}
in.close();
// cout<<type;
if(type == "blob"){
// serialize("7");
cout<<deserialize(hash);
}
if(type == "tree")
deserializeTree(hash);
if(type == "commit")
deserializeCommit(hash);
}
else{
cout<<"Does not exist"<<endl;
}
}
// int main(){
// string hash;
// cout<<"enter hash"<<endl;
// cin>>hash;
// catfile(hash);
// return 0;
// } | [
"amrit.kataria@students.iiit.ac.in"
] | amrit.kataria@students.iiit.ac.in |
55f2a3391d85f6e142887af4f5e72727b5a3b938 | 167c7506aab0e0f2d2de0994f986b846593286b1 | /cplusplus_base_library/Qt/boost/geometry/algorithms/for_each.hpp | 49d73cc6e942fb466074e2f8777145218f69af92 | [] | no_license | ngzHappy/bd2 | 78ee1755c8b83b8269e7f41bf72506bfd27564de | aacfc22aa1919b5ab5f5f4473375a1e8856dc213 | refs/heads/master | 2020-05-30T07:13:50.283590 | 2016-11-20T12:36:30 | 2016-11-20T12:36:30 | 69,462,962 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 9,799 | hpp | // Boost.Geometry (aka GGL, Generic Geometry Library)
// Copyright (c) 2007-2014 Barend Gehrels, Amsterdam, the Netherlands.
// Copyright (c) 2008-2014 Bruno Lalande, Paris, France.
// Copyright (c) 2009-2014 Mateusz Loskot, London, UK.
// Copyright (c) 2014 Adam Wulkiewicz, Lodz, Poland.
// This file was modified by Oracle on 2014.
// Modifications copyright (c) 2014, Oracle and/or its affiliates.
// Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
// Use, modification and distribution is subject to the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
#ifndef BOOST_GEOMETRY_ALGORITHMS_FOR_EACH_HPP
#define BOOST_GEOMETRY_ALGORITHMS_FOR_EACH_HPP
#include <algorithm>
#include <Qt/boost/range.hpp>
#include <Qt/boost/type_traits/is_const.hpp>
#include <Qt/boost/type_traits/remove_reference.hpp>
#include <Qt/boost/geometry/algorithms/detail/interior_iterator.hpp>
#include <Qt/boost/geometry/algorithms/not_implemented.hpp>
#include <Qt/boost/geometry/core/closure.hpp>
#include <Qt/boost/geometry/core/exterior_ring.hpp>
#include <Qt/boost/geometry/core/interior_rings.hpp>
#include <Qt/boost/geometry/core/point_type.hpp>
#include <Qt/boost/geometry/core/tag_cast.hpp>
#include <Qt/boost/geometry/core/tags.hpp>
#include <Qt/boost/geometry/geometries/concepts/check.hpp>
#include <Qt/boost/geometry/geometries/segment.hpp>
#include <Qt/boost/geometry/util/add_const_if_c.hpp>
#include <Qt/boost/geometry/util/range.hpp>
namespace boost { namespace geometry
{
#ifndef DOXYGEN_NO_DETAIL
namespace detail { namespace for_each
{
struct fe_point_per_point
{
template <typename Point, typename Functor>
static inline void apply(Point& point, Functor& f)
{
f(point);
}
};
struct fe_point_per_segment
{
template <typename Point, typename Functor>
static inline void apply(Point& , Functor& /*f*/)
{
// TODO: if non-const, we should extract the points from the segment
// and call the functor on those two points
}
};
struct fe_range_per_point
{
template <typename Range, typename Functor>
static inline void apply(Range& range, Functor& f)
{
// The previous implementation called the std library:
// return (std::for_each(boost::begin(range), boost::end(range), f));
// But that is not accepted for capturing lambda's.
// It needs to do it like that to return the state of Functor f (f is passed by value in std::for_each).
// So we now loop manually.
for (typename boost::range_iterator<Range>::type
it = boost::begin(range); it != boost::end(range); ++it)
{
f(*it);
}
}
};
template <closure_selector Closure>
struct fe_range_per_segment_with_closure
{
template <typename Range, typename Functor>
static inline void apply(Range& range, Functor& f)
{
typedef typename add_const_if_c
<
is_const<Range>::value,
typename point_type<Range>::type
>::type point_type;
typedef typename boost::range_iterator<Range>::type iterator_type;
iterator_type it = boost::begin(range);
iterator_type previous = it++;
while(it != boost::end(range))
{
model::referring_segment<point_type> s(*previous, *it);
f(s);
previous = it++;
}
}
};
template <>
struct fe_range_per_segment_with_closure<open>
{
template <typename Range, typename Functor>
static inline void apply(Range& range, Functor& f)
{
fe_range_per_segment_with_closure<closed>::apply(range, f);
model::referring_segment
<
typename add_const_if_c
<
is_const<Range>::value,
typename point_type<Range>::type
>::type
> s(range::back(range), range::front(range));
f(s);
}
};
struct fe_range_per_segment
{
template <typename Range, typename Functor>
static inline void apply(Range& range, Functor& f)
{
fe_range_per_segment_with_closure
<
closure<Range>::value
>::apply(range, f);
}
};
struct fe_polygon_per_point
{
template <typename Polygon, typename Functor>
static inline void apply(Polygon& poly, Functor& f)
{
fe_range_per_point::apply(exterior_ring(poly), f);
typename interior_return_type<Polygon>::type
rings = interior_rings(poly);
for (typename detail::interior_iterator<Polygon>::type
it = boost::begin(rings); it != boost::end(rings); ++it)
{
fe_range_per_point::apply(*it, f);
}
}
};
struct fe_polygon_per_segment
{
template <typename Polygon, typename Functor>
static inline void apply(Polygon& poly, Functor& f)
{
fe_range_per_segment::apply(exterior_ring(poly), f);
typename interior_return_type<Polygon>::type
rings = interior_rings(poly);
for (typename detail::interior_iterator<Polygon>::type
it = boost::begin(rings); it != boost::end(rings); ++it)
{
fe_range_per_segment::apply(*it, f);
}
}
};
// Implementation of multi, for both point and segment,
// just calling the single version.
template <typename Policy>
struct for_each_multi
{
template <typename MultiGeometry, typename Functor>
static inline void apply(MultiGeometry& multi, Functor& f)
{
for (typename boost::range_iterator<MultiGeometry>::type
it = boost::begin(multi); it != boost::end(multi); ++it)
{
Policy::apply(*it, f);
}
}
};
}} // namespace detail::for_each
#endif // DOXYGEN_NO_DETAIL
#ifndef DOXYGEN_NO_DISPATCH
namespace dispatch
{
template
<
typename Geometry,
typename Tag = typename tag_cast<typename tag<Geometry>::type, multi_tag>::type
>
struct for_each_point: not_implemented<Tag>
{};
template <typename Point>
struct for_each_point<Point, point_tag>
: detail::for_each::fe_point_per_point
{};
template <typename Linestring>
struct for_each_point<Linestring, linestring_tag>
: detail::for_each::fe_range_per_point
{};
template <typename Ring>
struct for_each_point<Ring, ring_tag>
: detail::for_each::fe_range_per_point
{};
template <typename Polygon>
struct for_each_point<Polygon, polygon_tag>
: detail::for_each::fe_polygon_per_point
{};
template
<
typename Geometry,
typename Tag = typename tag_cast<typename tag<Geometry>::type, multi_tag>::type
>
struct for_each_segment: not_implemented<Tag>
{};
template <typename Point>
struct for_each_segment<Point, point_tag>
: detail::for_each::fe_point_per_segment
{};
template <typename Linestring>
struct for_each_segment<Linestring, linestring_tag>
: detail::for_each::fe_range_per_segment
{};
template <typename Ring>
struct for_each_segment<Ring, ring_tag>
: detail::for_each::fe_range_per_segment
{};
template <typename Polygon>
struct for_each_segment<Polygon, polygon_tag>
: detail::for_each::fe_polygon_per_segment
{};
template <typename MultiGeometry>
struct for_each_point<MultiGeometry, multi_tag>
: detail::for_each::for_each_multi
<
// Specify the dispatch of the single-version as policy
for_each_point
<
typename add_const_if_c
<
is_const<MultiGeometry>::value,
typename boost::range_value<MultiGeometry>::type
>::type
>
>
{};
template <typename MultiGeometry>
struct for_each_segment<MultiGeometry, multi_tag>
: detail::for_each::for_each_multi
<
// Specify the dispatch of the single-version as policy
for_each_segment
<
typename add_const_if_c
<
is_const<MultiGeometry>::value,
typename boost::range_value<MultiGeometry>::type
>::type
>
>
{};
} // namespace dispatch
#endif // DOXYGEN_NO_DISPATCH
/*!
\brief \brf_for_each{point}
\details \det_for_each{point}
\ingroup for_each
\param geometry \param_geometry
\param f \par_for_each_f{point}
\tparam Geometry \tparam_geometry
\tparam Functor \tparam_functor
\qbk{[include reference/algorithms/for_each_point.qbk]}
\qbk{[heading Example]}
\qbk{[for_each_point] [for_each_point_output]}
\qbk{[for_each_point_const] [for_each_point_const_output]}
*/
template<typename Geometry, typename Functor>
inline Functor for_each_point(Geometry& geometry, Functor f)
{
concept::check<Geometry>();
dispatch::for_each_point<Geometry>::apply(geometry, f);
return f;
}
/*!
\brief \brf_for_each{segment}
\details \det_for_each{segment}
\ingroup for_each
\param geometry \param_geometry
\param f \par_for_each_f{segment}
\tparam Geometry \tparam_geometry
\tparam Functor \tparam_functor
\qbk{[include reference/algorithms/for_each_segment.qbk]}
\qbk{[heading Example]}
\qbk{[for_each_segment_const] [for_each_segment_const_output]}
*/
template<typename Geometry, typename Functor>
inline Functor for_each_segment(Geometry& geometry, Functor f)
{
concept::check<Geometry>();
dispatch::for_each_segment<Geometry>::apply(geometry, f);
return f;
}
}} // namespace boost::geometry
#endif // BOOST_GEOMETRY_ALGORITHMS_FOR_EACH_HPP
| [
"819869472@qq.com"
] | 819869472@qq.com |
c6ed9447cde55622648421c3be6c11828a930b4f | c69aa14f5ac5783862002fdfa6f20055f592e134 | /In Lab 4 - Task 3 (even odd)/In Lab 4 - Task 3/stdafx.cpp | 830a2fee7bb0203b64773a5ecadbc04d3595faa7 | [] | no_license | farhanwasif97/UET_Coursework | 02a028fc2e0f97ee7fafa174a0fb9551e36cdbe2 | 2ab525f49abf7e08cc39f895b4cdd2cb3147b55c | refs/heads/master | 2021-09-18T02:42:31.636562 | 2018-01-13T07:50:57 | 2018-01-13T07:50:57 | 115,248,452 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 296 | cpp | // stdafx.cpp : source file that includes just the standard includes
// In Lab 4 - Task 3.pch will be the pre-compiled header
// stdafx.obj will contain the pre-compiled type information
#include "stdafx.h"
// TODO: reference any additional headers you need in STDAFX.H
// and not in this file
| [
"farhanwasif1997@gmail.com"
] | farhanwasif1997@gmail.com |
92d0b717f48eef7d0c1c36ee92f40724d02d9b8d | b5e9ee331d96d9b5b43fe8653a96301af67cc95b | /opencv/src/examples/chapter1/pixel/main.cpp | 4277016bb813e27555e70618278ecd37911bca4d | [] | no_license | joonhwan/study | 531d3b0f3cb2c26dae9953f05a56a12305215f4a | e79490820e7c03bbfad58e7f9fd02a3f72783e67 | refs/heads/master | 2023-01-23T22:31:59.364783 | 2020-02-23T14:01:28 | 2020-02-23T14:01:28 | 4,001,896 | 9 | 2 | null | 2023-01-14T00:56:35 | 2012-04-12T06:19:31 | C++ | UHC | C++ | false | false | 2,409 | cpp | #include "image/WImageBuffer.h"
#include "image/WImageT.h"
#include "image/WImageProcessor.h"
#include "image/Vld.h"
#include "imagedir.h"
#include <QApplication>
#include <iostream>
#include <ipp.h>
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
typedef WImageBufferT<uchar,3> ImageBuffer;
void salt(ImageBuffer::Image image, int n)
{
cv::Mat mat = image.matrix();
QRect roi = image.roi();
for (int i = 0; i < n; ++i) {
int x = (qrand() % roi.width()) / 2;
int y = qrand() % roi.height();
// color
// NOTE : (y, x) 의 순서에 주의
mat.at< cv::Vec<ImageBuffer::DataType,3> >(y, x)[0] = 255;
mat.at< cv::Vec<ImageBuffer::DataType,3> >(y, x)[1] = 255;
mat.at< cv::Vec<ImageBuffer::DataType,3> >(y, x)[2] = 255;
}
}
int main(int argc, char** argv)
{
QApplication app(argc, argv);
QCoreApplication::setOrganizationName("joonhwan");
QCoreApplication::setOrganizationDomain("www.joonhwan.org");
QCoreApplication::setApplicationName("cvmattest");
cv::namedWindow("image");
cv::namedWindow("floatimage");
cv::namedWindow("timage");
cv::namedWindow("diffImage");
ImageBuffer image(IMAGE_DIR "castle.jpg");
cv::imshow("image", image);
cv::waitKey(0);
WImageBufferT<float,3> floatImage = image;
ImageBuffer timage = image; // keep original but not yet copy!
if (timage.isValid()) {
salt(timage, 2000);
}
ImageBuffer diffImage = image;
// WImageBufferT<uchar,3> colorImage = image;
ImageBuffer::Processor::absDiff(image.from(QPoint(50,50)), timage.from(QPoint(50,50)), diffImage.to(QRect(50,50,100,100)));
// ImageBuffer::Processor::absDiff(image, timage, diffImage);
// ImageBuffer::Processor::add(diffImage, 50, 1);
// QRect roi(50,50,100,100);
// cv::absdiff(image.from(roi), timage.from(roi), diffImage.to(roi));
// Wf::absDiff(image, timage, output);
cv::imshow("image", image);
cv::imshow("floatimage", image);
cv::imshow("timage", timage);
cv::imshow("diffImage", diffImage);
cv::waitKey(0);
cv::destroyAllWindows();
// IplImage* ii = cvLoadImage(IMAGE_DIR "castle.jpg");
// cv::flip(ii, ii, 1);
cv::Mat mat(100,100,CV_8U);
cv::Mat_<uchar> mp = mat;
// Ipp32f* p =0;
// // ippiAdd_32f_C1R(const Ipp32f* pSrc1, int src1Step, const Ipp32f* pSrc2, int src2Step, Ipp32f* pDst, int dstStep, IppiSize roiSize);
// IppiSize roiSize = {
// 100, 200
// };
// ippiAdd_32f_C1R(p, 0, p, 0, p, 0, roiSize);
// getchar();
return 0;//app.exec();
}
| [
"joonhwan.lee@gmail.com"
] | joonhwan.lee@gmail.com |
e2dad4c127ec8e069afc377b1644b8b87810c10c | 757739d7542a6586fb2d4dca8044f462e345ba92 | /bai1/tinhtong1/bangcuuchuong.cpp | 58a09b7f605babbf5b93b22b54e8194911258bcd | [] | no_license | nguyenducquyenKMA/bai-tap-kit-c17 | aff7c182a9e9858a9f487202493a690cb018b9d6 | 3fc5c9accea132dcd3a9f19a87a3c4445bf02121 | refs/heads/main | 2023-09-05T19:18:41.503964 | 2021-11-17T13:32:39 | 2021-11-17T13:32:39 | 429,050,289 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 145 | cpp | #include<stdio.h>
int main(){
int n,S;
scanf("%d",&n);
for(int i=1;i<=10;i++){
printf("%d x %d = %d\n",n,i,n*i);
}
}
| [
"nguyenducquyen2603@gmail.com"
] | nguyenducquyen2603@gmail.com |
c9d61ae5c2eb665cb9865a653566313a40af3d92 | e9d4022afb1f45ca699cf0dda806f7d935e7a9b0 | /include/odncrypto/sscipher_session_state.hpp | 709d0424f7215f45ed7ee050da35e15977590f1f | [
"MIT"
] | permissive | adelapie/abe-fame | e4ae54f69c601333cb8b899a35bbf1b2400a063d | 22eec20493306a87334b25aa7b6efcde25bc6bdb | refs/heads/master | 2021-09-23T06:28:35.235759 | 2018-09-20T14:44:55 | 2018-09-20T14:44:55 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,303 | hpp | //
// Created by abel walga on 07/05/2018.
//
#ifndef ODNCRYPTO_SSCIPHER_SESSION_STATE_HPP
#define ODNCRYPTO_SSCIPHER_SESSION_STATE_HPP
#include "sodium_import.hpp"
#include <string>
namespace odn {
namespace crypto {
using namespace ::std;
constexpr static size_t HEADER_SIZE = crypto_secretstream_xchacha20poly1305_HEADERBYTES;
constexpr static size_t CIPHER_SIZE = crypto_secretstream_xchacha20poly1305_ABYTES;
struct sscipher_session_state {
unsigned char header[HEADER_SIZE];
crypto_secretstream_xchacha20poly1305_state state;
/***********************************************
* * O/I operations
* *********************************************/
template<typename T>
friend T &serialize(T &, const sscipher_session_state &);
template<typename T>
friend T &deserialize(T &, sscipher_session_state &);
};
template<typename T>
T &serialize(T &ar, const sscipher_session_state &ssss) {
string header_str(&ssss.header[0], &ssss.header[0] + HEADER_SIZE);
ar.push(header_str);
return ar;
}
template<typename T>
T &deserialize(T &ar, sscipher_session_state &ssss) {
string header_str;
ar.pop(&header_str);
memcpy(ssss.header, header_str.c_str(), HEADER_SIZE);
return ar;
}
}// end namespace crypto
}// end namespace odn
#endif //ODNCRYPTO_SSCIPHER_SESSION_STATE_HPP
| [
"awalga@users.noreply.github.com"
] | awalga@users.noreply.github.com |
b98777dcd64a38bf16782b7c4659cfca59ac4f01 | 0a5058bff1961f6564c662224362995ee8fa3944 | /chromeos/printing/ppd_metadata_parser.cc | 556448050c80f659c33f0c8f8e2b3ece718a4930 | [
"BSD-3-Clause"
] | permissive | DongKai/chromium | d0208df711d2bad1e4324ca3b10a261c336758a0 | b7bb401aedab4fbe5af173a5baeaf91c8dbe726a | refs/heads/master | 2022-12-05T17:16:47.586163 | 2020-09-02T23:37:00 | 2020-09-02T23:37:00 | 292,435,006 | 0 | 0 | BSD-3-Clause | 2020-09-03T01:31:29 | 2020-09-03T01:31:28 | null | UTF-8 | C++ | false | false | 11,530 | cc | // Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chromeos/printing/ppd_metadata_parser.h"
#include <string>
#include <vector>
#include "base/containers/flat_map.h"
#include "base/json/json_reader.h"
#include "base/notreached.h"
#include "base/optional.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_piece.h"
#include "base/values.h"
namespace chromeos {
namespace {
// Attempts to
// 1. parse |input| as a Value having Type::DICTIONARY and
// 2. return Value of |key| having a given |target_type| from the same.
//
// Additionally,
// * this function never returns empty Value objects and
// * |target_type| must appear in the switch statement below.
base::Optional<base::Value> ParseJsonAndUnnestKey(
base::StringPiece input,
base::StringPiece key,
base::Value::Type target_type) {
base::Optional<base::Value> parsed = base::JSONReader::Read(input);
if (!parsed || !parsed->is_dict()) {
return base::nullopt;
}
base::Optional<base::Value> unnested = parsed->ExtractKey(key);
if (!unnested || unnested->type() != target_type) {
return base::nullopt;
}
bool unnested_is_empty = true;
switch (target_type) {
case base::Value::Type::LIST:
unnested_is_empty = unnested->GetList().empty();
break;
case base::Value::Type::DICTIONARY:
unnested_is_empty = unnested->DictEmpty();
break;
default:
NOTREACHED();
break;
}
if (unnested_is_empty) {
return base::nullopt;
}
return unnested;
}
// Returns a well-formed Restrictions struct from a dictionary |value|.
// A well-formed Restrictions struct has at least one member that
// for which calling base::Version::IsValid() will evaluate true.
base::Optional<PpdProvider::Restrictions> ParseRestrictionsFromValue(
const base::Value& value) {
auto min_as_double = value.FindDoubleKey("minMilestone");
auto max_as_double = value.FindDoubleKey("maxMilestone");
if (!min_as_double.has_value() && !max_as_double.has_value()) {
return base::nullopt;
}
// While we don't want to deliberately store trivial base::Version
// members into the Restrictions struct, take heed that a
// calling IsValid() on a default-constructed base::Version returns
// false.
PpdProvider::Restrictions restrictions;
bool restrictions_is_nontrivial = false;
if (min_as_double.has_value()) {
base::Version min_milestone =
base::Version(base::NumberToString(int{min_as_double.value()}));
if (min_milestone.IsValid()) {
restrictions.min_milestone = min_milestone;
restrictions_is_nontrivial = true;
}
}
if (max_as_double.has_value()) {
base::Version max_milestone =
base::Version(base::NumberToString(int{max_as_double.value()}));
if (max_milestone.IsValid()) {
restrictions.max_milestone = max_milestone;
restrictions_is_nontrivial = true;
}
}
if (restrictions_is_nontrivial) {
return restrictions;
}
return base::nullopt;
}
// Returns a ParsedPrinter from a leaf |value| from Printers metadata.
base::Optional<ParsedPrinter> ParsePrinterFromValue(const base::Value& value) {
const std::string* const effective_make_and_model =
value.FindStringKey("emm");
const std::string* const name = value.FindStringKey("name");
if (!effective_make_and_model || effective_make_and_model->empty() || !name ||
name->empty()) {
return base::nullopt;
}
ParsedPrinter printer;
printer.effective_make_and_model = *effective_make_and_model;
printer.user_visible_printer_name = *name;
const base::Value* const restrictions_value =
value.FindDictKey("restriction");
if (restrictions_value) {
printer.restrictions = ParseRestrictionsFromValue(*restrictions_value);
}
return printer;
}
// Returns a ParsedIndexLeaf from |value|.
base::Optional<ParsedIndexLeaf> ParsedIndexLeafFrom(const base::Value& value) {
if (!value.is_dict()) {
return base::nullopt;
}
ParsedIndexLeaf leaf;
const std::string* const ppd_basename = value.FindStringKey("name");
if (!ppd_basename) {
return base::nullopt;
}
leaf.ppd_basename = *ppd_basename;
const base::Value* const restrictions_value =
value.FindDictKey("restriction");
if (restrictions_value) {
leaf.restrictions = ParseRestrictionsFromValue(*restrictions_value);
}
return leaf;
}
// Returns a ParsedIndexValues from a |value| extracted from a forward
// index.
base::Optional<ParsedIndexValues> UnnestPpdMetadata(const base::Value& value) {
if (!value.is_dict()) {
return base::nullopt;
}
const base::Value* const ppd_metadata_list = value.FindListKey("ppdMetadata");
if (!ppd_metadata_list || ppd_metadata_list->GetList().size() == 0) {
return base::nullopt;
}
ParsedIndexValues parsed_index_values;
for (const base::Value& v : ppd_metadata_list->GetList()) {
base::Optional<ParsedIndexLeaf> parsed_index_leaf = ParsedIndexLeafFrom(v);
if (parsed_index_leaf.has_value()) {
parsed_index_values.values.push_back(parsed_index_leaf.value());
}
}
if (parsed_index_values.values.empty()) {
return base::nullopt;
}
return parsed_index_values;
}
} // namespace
ParsedPrinter::ParsedPrinter() = default;
ParsedPrinter::~ParsedPrinter() = default;
ParsedPrinter::ParsedPrinter(const ParsedPrinter&) = default;
ParsedPrinter& ParsedPrinter::operator=(const ParsedPrinter&) = default;
ParsedIndexLeaf::ParsedIndexLeaf() = default;
ParsedIndexLeaf::~ParsedIndexLeaf() = default;
ParsedIndexLeaf::ParsedIndexLeaf(const ParsedIndexLeaf&) = default;
ParsedIndexLeaf& ParsedIndexLeaf::operator=(const ParsedIndexLeaf&) = default;
ParsedIndexValues::ParsedIndexValues() = default;
ParsedIndexValues::~ParsedIndexValues() = default;
ParsedIndexValues::ParsedIndexValues(const ParsedIndexValues&) = default;
ParsedIndexValues& ParsedIndexValues::operator=(const ParsedIndexValues&) =
default;
base::Optional<std::vector<std::string>> ParseLocales(
base::StringPiece locales_json) {
const auto as_value =
ParseJsonAndUnnestKey(locales_json, "locales", base::Value::Type::LIST);
if (!as_value.has_value()) {
return base::nullopt;
}
std::vector<std::string> locales;
for (const auto& iter : as_value.value().GetList()) {
std::string locale;
if (!iter.GetAsString(&locale)) {
continue;
}
locales.push_back(locale);
}
if (locales.empty()) {
return base::nullopt;
}
return locales;
}
base::Optional<ParsedManufacturers> ParseManufacturers(
base::StringPiece manufacturers_json) {
const auto as_value = ParseJsonAndUnnestKey(manufacturers_json, "filesMap",
base::Value::Type::DICTIONARY);
if (!as_value.has_value()) {
return base::nullopt;
}
ParsedManufacturers manufacturers;
for (const auto& iter : as_value.value().DictItems()) {
std::string printers_metadata_basename;
if (!iter.second.GetAsString(&printers_metadata_basename)) {
continue;
}
manufacturers[iter.first] = printers_metadata_basename;
}
if (manufacturers.empty()) {
return base::nullopt;
}
return manufacturers;
}
base::Optional<ParsedIndex> ParseForwardIndex(
base::StringPiece forward_index_json) {
// Firstly, we unnest the dictionary keyed by "ppdIndex."
base::Optional<base::Value> ppd_index = ParseJsonAndUnnestKey(
forward_index_json, "ppdIndex", base::Value::Type::DICTIONARY);
if (!ppd_index || ppd_index->DictSize() == 0) {
return base::nullopt;
}
ParsedIndex parsed_index;
// Secondly, we iterate on the key-value pairs of the ppdIndex.
// This yields a list of leaf values (dictionaries).
for (const auto& kv : ppd_index->DictItems()) {
base::Optional<ParsedIndexValues> values = UnnestPpdMetadata(kv.second);
if (values.has_value()) {
parsed_index.insert_or_assign(kv.first, values.value());
}
}
if (parsed_index.empty()) {
return base::nullopt;
}
return parsed_index;
}
base::Optional<ParsedUsbIndex> ParseUsbIndex(base::StringPiece usb_index_json) {
base::Optional<base::Value> usb_index = ParseJsonAndUnnestKey(
usb_index_json, "usbIndex", base::Value::Type::DICTIONARY);
if (!usb_index || usb_index->DictSize() == 0) {
return base::nullopt;
}
ParsedUsbIndex parsed_usb_index;
for (const auto& kv : usb_index->DictItems()) {
int product_id;
if (!base::StringToInt(kv.first, &product_id)) {
continue;
}
const std::string* effective_make_and_model =
kv.second.FindStringKey("effectiveMakeAndModel");
if (!effective_make_and_model || effective_make_and_model->empty()) {
continue;
}
parsed_usb_index.insert_or_assign(product_id, *effective_make_and_model);
}
if (parsed_usb_index.empty()) {
return base::nullopt;
}
return parsed_usb_index;
}
base::Optional<ParsedUsbVendorIdMap> ParseUsbVendorIdMap(
base::StringPiece usb_vendor_id_map_json) {
base::Optional<base::Value> as_value = ParseJsonAndUnnestKey(
usb_vendor_id_map_json, "entries", base::Value::Type::LIST);
if (!as_value.has_value() || as_value->GetList().empty()) {
return base::nullopt;
}
ParsedUsbVendorIdMap usb_vendor_ids;
for (const auto& usb_vendor_description : as_value->GetList()) {
if (!usb_vendor_description.is_dict()) {
continue;
}
base::Optional<int> vendor_id =
usb_vendor_description.FindIntKey("vendorId");
const std::string* const vendor_name =
usb_vendor_description.FindStringKey("vendorName");
if (!vendor_id.has_value() || !vendor_name || vendor_name->empty()) {
continue;
}
usb_vendor_ids.insert_or_assign(vendor_id.value(), *vendor_name);
}
if (usb_vendor_ids.empty()) {
return base::nullopt;
}
return usb_vendor_ids;
}
base::Optional<ParsedPrinters> ParsePrinters(base::StringPiece printers_json) {
const auto as_value =
ParseJsonAndUnnestKey(printers_json, "printers", base::Value::Type::LIST);
if (!as_value.has_value()) {
return base::nullopt;
}
ParsedPrinters printers;
for (const auto& printer_value : as_value->GetList()) {
if (!printer_value.is_dict()) {
continue;
}
base::Optional<ParsedPrinter> printer =
ParsePrinterFromValue(printer_value);
if (!printer.has_value()) {
continue;
}
printers.push_back(printer.value());
}
if (printers.empty()) {
return base::nullopt;
}
return printers;
}
base::Optional<ParsedReverseIndex> ParseReverseIndex(
base::StringPiece reverse_index_json) {
const base::Optional<base::Value> makes_and_models = ParseJsonAndUnnestKey(
reverse_index_json, "reverseIndex", base::Value::Type::DICTIONARY);
if (!makes_and_models.has_value() || makes_and_models->DictSize() == 0) {
return base::nullopt;
}
ParsedReverseIndex parsed;
for (const auto& kv : makes_and_models->DictItems()) {
if (!kv.second.is_dict()) {
continue;
}
const std::string* manufacturer = kv.second.FindStringKey("manufacturer");
const std::string* model = kv.second.FindStringKey("model");
if (manufacturer && model && !manufacturer->empty() && !model->empty()) {
parsed.insert_or_assign(kv.first,
ReverseIndexLeaf{*manufacturer, *model});
}
}
if (parsed.empty()) {
return base::nullopt;
}
return parsed;
}
} // namespace chromeos
| [
"commit-bot@chromium.org"
] | commit-bot@chromium.org |
102b2c741d6787a8623ccbb0a1175954a10b7706 | 45974dc4f57752170d10289403ecd29e0c392e24 | /moveit_setup_assistant/src/widgets/configuration_files_widget.cpp | 96a7af98503b543f806604f27d265a2d80728643 | [
"BSD-3-Clause"
] | permissive | tzahroof/moveit | 1ae7a63e662c76e95356728bf94f8e313565dacb | 75b8306f8ed1da3374bca75ca5fb23bae7cbc7b7 | refs/heads/master | 2020-03-28T23:14:20.039106 | 2018-11-13T23:12:02 | 2018-11-13T23:12:02 | 149,282,289 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 52,714 | cpp | /*********************************************************************
* Software License Agreement (BSD License)
*
* Copyright (c) 2012, Willow Garage, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of Willow Garage nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*********************************************************************/
/* Author: Dave Coleman */
// Qt
#include <QVBoxLayout>
#include <QPushButton>
#include <QMessageBox>
#include <QApplication>
#include <QSplitter>
#include <QRegExp>
// ROS
#include "configuration_files_widget.h"
#include <srdfdom/model.h> // use their struct datastructures
#include <ros/ros.h>
// Boost
#include <boost/algorithm/string.hpp> // for trimming whitespace from user input
#include <boost/filesystem.hpp> // for creating folders/files
// Read write files
#include <iostream> // For writing yaml and launch files
#include <fstream>
namespace moveit_setup_assistant
{
// Boost file system
namespace fs = boost::filesystem;
const std::string SETUP_ASSISTANT_FILE = ".setup_assistant";
// ******************************************************************************************
// Outer User Interface for MoveIt Configuration Assistant
// ******************************************************************************************
ConfigurationFilesWidget::ConfigurationFilesWidget(QWidget* parent,
moveit_setup_assistant::MoveItConfigDataPtr config_data)
: SetupScreenWidget(parent), config_data_(config_data), has_generated_pkg_(false), first_focusGiven_(true)
{
// Basic widget container
QVBoxLayout* layout = new QVBoxLayout();
// Top Header Area ------------------------------------------------
HeaderWidget* header =
new HeaderWidget("Generate Configuration Files",
"Create or update the configuration files package needed to run your robot with MoveIt. Uncheck "
"files to disable them from being generated - this is useful if you have made custom changes to "
"them. Files in orange have been automatically detected as changed.",
this);
layout->addWidget(header);
// Path Widget ----------------------------------------------------
// Stack Path Dialog
stack_path_ = new LoadPathWidget("Configuration Package Save Path",
"Specify the desired directory for the MoveIt configuration package to be "
"generated. Overwriting an existing configuration package directory is acceptable. "
"Example: <i>/u/robot/ros/pr2_moveit_config</i>",
this, true); // is directory
layout->addWidget(stack_path_);
// Pass the package path from start screen to configuration files screen
stack_path_->setPath(config_data_->config_pkg_path_);
// Generated Files List -------------------------------------------
QLabel* generated_list = new QLabel("Files to be generated: (checked)", this);
layout->addWidget(generated_list);
QSplitter* splitter = new QSplitter(Qt::Horizontal, this);
splitter->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
// List Box
action_list_ = new QListWidget(this);
action_list_->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
connect(action_list_, SIGNAL(currentRowChanged(int)), this, SLOT(changeActionDesc(int)));
// Description
action_label_ = new QLabel(this);
action_label_->setFrameShape(QFrame::StyledPanel);
action_label_->setFrameShadow(QFrame::Raised);
action_label_->setLineWidth(1);
action_label_->setMidLineWidth(0);
action_label_->setWordWrap(true);
action_label_->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding);
action_label_->setMinimumWidth(100);
action_label_->setAlignment(Qt::AlignTop);
action_label_->setOpenExternalLinks(true); // open with web browser
// Add to splitter
splitter->addWidget(action_list_);
splitter->addWidget(action_label_);
// Add Layout
layout->addWidget(splitter);
// Progress bar and generate buttons ---------------------------------------------------
QHBoxLayout* hlayout1 = new QHBoxLayout();
// Progress Bar
progress_bar_ = new QProgressBar(this);
progress_bar_->setMaximum(100);
progress_bar_->setMinimum(0);
hlayout1->addWidget(progress_bar_);
// hlayout1->setContentsMargins( 20, 30, 20, 30 );
// Generate Package Button
btn_save_ = new QPushButton("&Generate Package", this);
// btn_save_->setMinimumWidth(180);
btn_save_->setMinimumHeight(40);
connect(btn_save_, SIGNAL(clicked()), this, SLOT(savePackage()));
hlayout1->addWidget(btn_save_);
// Add Layout
layout->addLayout(hlayout1);
// Bottom row --------------------------------------------------
QHBoxLayout* hlayout3 = new QHBoxLayout();
// Success label
success_label_ = new QLabel(this);
QFont success_label_font(QFont().defaultFamily(), 12, QFont::Bold);
success_label_->setFont(success_label_font);
success_label_->hide(); // only show once the files have been generated
success_label_->setText("Configuration package generated successfully!");
hlayout3->addWidget(success_label_);
hlayout3->setAlignment(success_label_, Qt::AlignRight);
// Exit button
QPushButton* btn_exit = new QPushButton("E&xit Setup Assistant", this);
btn_exit->setMinimumWidth(180);
connect(btn_exit, SIGNAL(clicked()), this, SLOT(exitSetupAssistant()));
hlayout3->addWidget(btn_exit);
hlayout3->setAlignment(btn_exit, Qt::AlignRight);
layout->addLayout(hlayout3);
// Finish Layout --------------------------------------------------
this->setLayout(layout);
}
// ******************************************************************************************
// Populate the 'Files to be generated' list
// ******************************************************************************************
bool ConfigurationFilesWidget::loadGenFiles()
{
GenerateFile file; // re-used
std::string template_path; // re-used
const std::string robot_name = config_data_->srdf_->robot_name_;
gen_files_.clear(); // reset vector
// Get template package location ----------------------------------------------------------------------
fs::path template_package_path = config_data_->setup_assistant_path_;
template_package_path /= "templates";
template_package_path /= "moveit_config_pkg_template";
config_data_->template_package_path_ = template_package_path.make_preferred().native().c_str();
if (!fs::is_directory(config_data_->template_package_path_))
{
QMessageBox::critical(
this, "Error Generating",
QString("Unable to find package template directory: ").append(config_data_->template_package_path_.c_str()));
return false;
}
// -------------------------------------------------------------------------------------------------------------------
// ROS PACKAGE FILES AND FOLDERS ----------------------------------------------------------------------------
// -------------------------------------------------------------------------------------------------------------------
// package.xml --------------------------------------------------------------------------------------
// Note: we call the file package.xml.template so that it isn't automatically indexed by rosprofile
// in the scenario where we want to disabled the setup_assistant by renaming its root package.xml
file.file_name_ = "package.xml";
file.rel_path_ = file.file_name_;
template_path = config_data_->appendPaths(config_data_->template_package_path_, "package.xml.template");
file.description_ = "Defines a ROS package";
file.gen_func_ = boost::bind(&ConfigurationFilesWidget::copyTemplate, this, template_path, _1);
file.write_on_changes = MoveItConfigData::AUTHOR_INFO;
gen_files_.push_back(file);
// CMakeLists.txt --------------------------------------------------------------------------------------
file.file_name_ = "CMakeLists.txt";
file.rel_path_ = file.file_name_;
template_path = config_data_->appendPaths(config_data_->template_package_path_, file.file_name_);
file.description_ = "CMake build system configuration file";
file.gen_func_ = boost::bind(&ConfigurationFilesWidget::copyTemplate, this, template_path, _1);
file.write_on_changes = 0;
gen_files_.push_back(file);
// -------------------------------------------------------------------------------------------------------------------
// CONIG FILES -------------------------------------------------------------------------------------------------------
// -------------------------------------------------------------------------------------------------------------------
std::string config_path = "config";
// config/ --------------------------------------------------------------------------------------
file.file_name_ = "config/";
file.rel_path_ = file.file_name_;
file.description_ = "Folder containing all MoveIt configuration files for your robot. This folder is required and "
"cannot be disabled.";
file.gen_func_ = boost::bind(&ConfigurationFilesWidget::createFolder, this, _1);
file.write_on_changes = 0;
gen_files_.push_back(file);
// robot.srdf ----------------------------------------------------------------------------------------------
file.file_name_ = config_data_->srdf_pkg_relative_path_.empty() ? config_data_->urdf_model_->getName() + ".srdf" :
config_data_->srdf_pkg_relative_path_;
file.rel_path_ = config_data_->srdf_pkg_relative_path_.empty() ?
config_data_->appendPaths(config_path, file.file_name_) :
config_data_->srdf_pkg_relative_path_;
file.description_ = "SRDF (<a href='http://www.ros.org/wiki/srdf'>Semantic Robot Description Format</a>) is a "
"representation of semantic information about robots. This format is intended to represent "
"information about the robot that is not in the URDF file, but it is useful for a variety of "
"applications. The intention is to include information that has a semantic aspect to it.";
file.gen_func_ = boost::bind(&srdf::SRDFWriter::writeSRDF, config_data_->srdf_, _1);
file.write_on_changes = MoveItConfigData::SRDF;
gen_files_.push_back(file);
// special step required so the generated .setup_assistant yaml has this value
config_data_->srdf_pkg_relative_path_ = file.rel_path_;
// ompl_planning.yaml --------------------------------------------------------------------------------------
file.file_name_ = "ompl_planning.yaml";
file.rel_path_ = config_data_->appendPaths(config_path, file.file_name_);
file.description_ = "Configures the OMPL (<a href='http://ompl.kavrakilab.org/'>Open Motion Planning Library</a>) "
"planning plugin. For every planning group defined in the SRDF, a number of planning "
"configurations are specified (under planner_configs). Additionally, default settings for the "
"state space to plan in for a particular group can be specified, such as the collision checking "
"resolution. Each planning configuration specified for a group must be defined under the "
"planner_configs tag. While defining a planner configuration, the only mandatory parameter is "
"'type', which is the name of the motion planner to be used. Any other planner-specific "
"parameters can be defined but are optional.";
file.gen_func_ = boost::bind(&MoveItConfigData::outputOMPLPlanningYAML, config_data_, _1);
file.write_on_changes = MoveItConfigData::GROUPS;
gen_files_.push_back(file);
// kinematics.yaml --------------------------------------------------------------------------------------
file.file_name_ = "kinematics.yaml";
file.rel_path_ = config_data_->appendPaths(config_path, file.file_name_);
file.description_ = "Specifies which kinematic solver plugin to use for each planning group in the SRDF, as well as "
"the kinematic solver search resolution.";
file.gen_func_ = boost::bind(&MoveItConfigData::outputKinematicsYAML, config_data_, _1);
file.write_on_changes = MoveItConfigData::GROUPS | MoveItConfigData::GROUP_KINEMATICS;
gen_files_.push_back(file);
// joint_limits.yaml --------------------------------------------------------------------------------------
file.file_name_ = "joint_limits.yaml";
file.rel_path_ = config_data_->appendPaths(config_path, file.file_name_);
file.description_ = "Contains additional information about joints that appear in your planning groups that is not "
"contained in the URDF, as well as allowing you to set maximum and minimum limits for velocity "
"and acceleration than those contained in your URDF. This information is used by our trajectory "
"filtering system to assign reasonable velocities and timing for the trajectory before it is "
"passed to the robots controllers.";
file.gen_func_ = boost::bind(&MoveItConfigData::outputJointLimitsYAML, config_data_, _1);
file.write_on_changes = 0; // Can they be changed?
gen_files_.push_back(file);
// fake_controllers.yaml --------------------------------------------------------------------------------------
file.file_name_ = "fake_controllers.yaml";
file.rel_path_ = config_data_->appendPaths(config_path, file.file_name_);
file.description_ = "Creates dummy configurations for controllers that correspond to defined groups. This is mostly "
"useful for testing.";
file.gen_func_ = boost::bind(&MoveItConfigData::outputFakeControllersYAML, config_data_, _1);
file.write_on_changes = MoveItConfigData::GROUPS;
gen_files_.push_back(file);
// ros_controllers.yaml --------------------------------------------------------------------------------------
file.file_name_ = "ros_controllers.yaml";
file.rel_path_ = config_data_->appendPaths(config_path, file.file_name_);
file.description_ = "Creates configurations for ros_controllers.";
file.gen_func_ = boost::bind(&MoveItConfigData::outputROSControllersYAML, config_data_, _1);
file.write_on_changes = MoveItConfigData::GROUPS;
gen_files_.push_back(file);
// -------------------------------------------------------------------------------------------------------------------
// LAUNCH FILES ------------------------------------------------------------------------------------------------------
// -------------------------------------------------------------------------------------------------------------------
std::string launch_path = "launch";
const std::string template_launch_path = config_data_->appendPaths(config_data_->template_package_path_, launch_path);
// launch/ --------------------------------------------------------------------------------------
file.file_name_ = "launch/";
file.rel_path_ = file.file_name_;
file.description_ = "Folder containing all MoveIt launch files for your robot. This folder is required and cannot be "
"disabled.";
file.gen_func_ = boost::bind(&ConfigurationFilesWidget::createFolder, this, _1);
file.write_on_changes = 0;
gen_files_.push_back(file);
// move_group.launch --------------------------------------------------------------------------------------
file.file_name_ = "move_group.launch";
file.rel_path_ = config_data_->appendPaths(launch_path, file.file_name_);
template_path = config_data_->appendPaths(template_launch_path, file.file_name_);
file.description_ = "Launches the move_group node that provides the MoveGroup action and other parameters <a "
"href='http://moveit.ros.org/doxygen/"
"classmoveit_1_1planning__interface_1_1MoveGroup.html#details'>MoveGroup action</a>";
file.gen_func_ = boost::bind(&ConfigurationFilesWidget::copyTemplate, this, template_path, _1);
file.write_on_changes = 0;
gen_files_.push_back(file);
// planning_context.launch --------------------------------------------------------------------------------------
file.file_name_ = "planning_context.launch";
file.rel_path_ = config_data_->appendPaths(launch_path, file.file_name_);
template_path = config_data_->appendPaths(template_launch_path, file.file_name_);
file.description_ = "Loads settings for the ROS parameter server, required for running MoveIt. This includes the "
"SRDF, joints_limits.yaml file, ompl_planning.yaml file, optionally the URDF, etc";
file.gen_func_ = boost::bind(&ConfigurationFilesWidget::copyTemplate, this, template_path, _1);
file.write_on_changes = 0;
gen_files_.push_back(file);
// moveit_rviz.launch --------------------------------------------------------------------------------------
file.file_name_ = "moveit_rviz.launch";
file.rel_path_ = config_data_->appendPaths(launch_path, file.file_name_);
template_path = config_data_->appendPaths(template_launch_path, file.file_name_);
file.description_ = "Visualize in Rviz the robot's planning groups running with interactive markers that allow goal "
"states to be set.";
file.gen_func_ = boost::bind(&ConfigurationFilesWidget::copyTemplate, this, template_path, _1);
file.write_on_changes = 0;
gen_files_.push_back(file);
// ompl_planning_pipeline.launch
// --------------------------------------------------------------------------------------
file.file_name_ = "ompl_planning_pipeline.launch.xml";
file.rel_path_ = config_data_->appendPaths(launch_path, file.file_name_);
template_path = config_data_->appendPaths(template_launch_path, file.file_name_);
file.description_ = "Intended to be included in other launch files that require the OMPL planning plugin. Defines "
"the proper plugin name on the parameter server and a default selection of planning request "
"adapters.";
file.gen_func_ = boost::bind(&ConfigurationFilesWidget::copyTemplate, this, template_path, _1);
file.write_on_changes = 0;
gen_files_.push_back(file);
// planning_pipeline.launch --------------------------------------------------------------------------------------
file.file_name_ = "planning_pipeline.launch.xml";
file.rel_path_ = config_data_->appendPaths(launch_path, file.file_name_);
template_path = config_data_->appendPaths(template_launch_path, file.file_name_);
file.description_ = "Helper launch file that can choose between different planning pipelines to be loaded.";
file.gen_func_ = boost::bind(&ConfigurationFilesWidget::copyTemplate, this, template_path, _1);
file.write_on_changes = 0;
gen_files_.push_back(file);
// warehouse_settings.launch --------------------------------------------------------------------------------------
file.file_name_ = "warehouse_settings.launch.xml";
file.rel_path_ = config_data_->appendPaths(launch_path, file.file_name_);
template_path = config_data_->appendPaths(template_launch_path, file.file_name_);
file.description_ = "Helper launch file that specifies default settings for MongoDB.";
file.gen_func_ = boost::bind(&ConfigurationFilesWidget::copyTemplate, this, template_path, _1);
file.write_on_changes = 0;
gen_files_.push_back(file);
// warehouse.launch --------------------------------------------------------------------------------------
file.file_name_ = "warehouse.launch";
file.rel_path_ = config_data_->appendPaths(launch_path, file.file_name_);
template_path = config_data_->appendPaths(template_launch_path, file.file_name_);
file.description_ = "Launch file for starting MongoDB.";
file.gen_func_ = boost::bind(&ConfigurationFilesWidget::copyTemplate, this, template_path, _1);
file.write_on_changes = 0;
gen_files_.push_back(file);
// default_warehouse_db.launch --------------------------------------------------------------------------------------
file.file_name_ = "default_warehouse_db.launch";
file.rel_path_ = config_data_->appendPaths(launch_path, file.file_name_);
template_path = config_data_->appendPaths(template_launch_path, file.file_name_);
file.description_ = "Launch file for starting the warehouse with a default MongoDB.";
file.gen_func_ = boost::bind(&ConfigurationFilesWidget::copyTemplate, this, template_path, _1);
file.write_on_changes = 0;
gen_files_.push_back(file);
// run_benchmark_ompl.launch --------------------------------------------------------------------------------------
file.file_name_ = "run_benchmark_ompl.launch";
file.rel_path_ = config_data_->appendPaths(launch_path, file.file_name_);
template_path = config_data_->appendPaths(template_launch_path, file.file_name_);
file.description_ = "Launch file for benchmarking OMPL planners";
file.gen_func_ = boost::bind(&ConfigurationFilesWidget::copyTemplate, this, template_path, _1);
file.write_on_changes = 0;
gen_files_.push_back(file);
// sensor_manager.launch --------------------------------------------------------------------------------------
file.file_name_ = "sensor_manager.launch.xml";
file.rel_path_ = config_data_->appendPaths(launch_path, file.file_name_);
template_path = config_data_->appendPaths(template_launch_path, file.file_name_);
file.description_ = "Helper launch file that can choose between different sensor managers to be loaded.";
file.gen_func_ = boost::bind(&ConfigurationFilesWidget::copyTemplate, this, template_path, _1);
file.write_on_changes = 0;
gen_files_.push_back(file);
// robot_moveit_controller_manager.launch ------------------------------------------------------------------
file.file_name_ = robot_name + "_moveit_controller_manager.launch.xml";
file.rel_path_ = config_data_->appendPaths(launch_path, file.file_name_);
template_path = config_data_->appendPaths(template_launch_path, "moveit_controller_manager.launch.xml");
file.description_ = "Placeholder for settings specific to the MoveIt controller manager implemented for you robot.";
file.gen_func_ = boost::bind(&ConfigurationFilesWidget::copyTemplate, this, template_path, _1);
file.write_on_changes = 0;
gen_files_.push_back(file);
// robot_moveit_sensor_manager.launch ------------------------------------------------------------------
file.file_name_ = robot_name + "_moveit_sensor_manager.launch.xml";
file.rel_path_ = config_data_->appendPaths(launch_path, file.file_name_);
template_path = config_data_->appendPaths(template_launch_path, "moveit_sensor_manager.launch.xml");
file.description_ = "Placeholder for settings specific to the MoveIt sensor manager implemented for you robot.";
file.gen_func_ = boost::bind(&ConfigurationFilesWidget::copyTemplate, this, template_path, _1);
file.write_on_changes = 0;
gen_files_.push_back(file);
// trajectory_execution.launch ------------------------------------------------------------------
file.file_name_ = "trajectory_execution.launch.xml";
file.rel_path_ = config_data_->appendPaths(launch_path, file.file_name_);
template_path = config_data_->appendPaths(template_launch_path, file.file_name_);
file.description_ = "Loads settings for the ROS parameter server required for executing trajectories using the "
"trajectory_execution_manager::TrajectoryExecutionManager.";
file.gen_func_ = boost::bind(&ConfigurationFilesWidget::copyTemplate, this, template_path, _1);
file.write_on_changes = 0;
gen_files_.push_back(
file); // trajectory_execution.launch ------------------------------------------------------------------
file.file_name_ = "fake_moveit_controller_manager.launch.xml";
file.rel_path_ = config_data_->appendPaths(launch_path, file.file_name_);
template_path = config_data_->appendPaths(template_launch_path, file.file_name_);
file.description_ = "Loads a fake controller plugin.";
file.gen_func_ = boost::bind(&ConfigurationFilesWidget::copyTemplate, this, template_path, _1);
file.write_on_changes = 0;
gen_files_.push_back(file);
// demo.launch ------------------------------------------------------------------
file.file_name_ = "demo.launch";
file.rel_path_ = config_data_->appendPaths(launch_path, file.file_name_);
template_path = config_data_->appendPaths(template_launch_path, file.file_name_);
file.description_ = "Run a demo of MoveIt.";
file.gen_func_ = boost::bind(&ConfigurationFilesWidget::copyTemplate, this, template_path, _1);
file.write_on_changes = 0;
gen_files_.push_back(file);
// joystick_control.launch ------------------------------------------------------------------
file.file_name_ = "joystick_control.launch";
file.rel_path_ = config_data_->appendPaths(launch_path, file.file_name_);
template_path = config_data_->appendPaths(template_launch_path, file.file_name_);
file.description_ = "Control the Rviz Motion Planning Plugin with a joystick";
file.gen_func_ = boost::bind(&ConfigurationFilesWidget::copyTemplate, this, template_path, _1);
file.write_on_changes = 0;
gen_files_.push_back(file);
// setup_assistant.launch ------------------------------------------------------------------
file.file_name_ = "setup_assistant.launch";
file.rel_path_ = config_data_->appendPaths(launch_path, file.file_name_);
template_path = config_data_->appendPaths(
template_launch_path, "edit_configuration_package.launch"); // named this so that this launch file is not mixed
// up with the SA's real launch file
file.description_ = "Launch file for easily re-starting the MoveIt Setup Assistant to edit this robot's generated "
"configuration package.";
file.gen_func_ = boost::bind(&ConfigurationFilesWidget::copyTemplate, this, template_path, _1);
file.write_on_changes = 0;
gen_files_.push_back(file);
// ros_controllers.launch ------------------------------------------------------------------
file.file_name_ = "ros_controllers.launch";
file.rel_path_ = config_data_->appendPaths(launch_path, file.file_name_);
template_path = config_data_->appendPaths(template_launch_path, "ros_controllers.launch");
file.description_ = "ros_controllers launch file";
file.gen_func_ = boost::bind(&ConfigurationFilesWidget::copyTemplate, this, template_path, _1);
file.write_on_changes = MoveItConfigData::GROUPS;
gen_files_.push_back(file);
// moveit.rviz ------------------------------------------------------------------
file.file_name_ = "moveit.rviz";
file.rel_path_ = config_data_->appendPaths(launch_path, file.file_name_);
template_path = config_data_->appendPaths(template_launch_path, "moveit.rviz");
file.description_ = "Configuration file for Rviz with the Motion Planning Plugin already setup. Used by passing "
"roslaunch moveit_rviz.launch config:=true";
file.gen_func_ = boost::bind(&ConfigurationFilesWidget::copyTemplate, this, template_path, _1);
file.write_on_changes = 0;
gen_files_.push_back(file);
// -------------------------------------------------------------------------------------------------------------------
// OTHER FILES -------------------------------------------------------------------------------------------------------
// -------------------------------------------------------------------------------------------------------------------
// .setup_assistant ------------------------------------------------------------------
file.file_name_ = SETUP_ASSISTANT_FILE;
file.rel_path_ = file.file_name_;
file.description_ = "MoveIt Setup Assistant's hidden settings file. You should not need to edit this file.";
file.gen_func_ = boost::bind(&MoveItConfigData::outputSetupAssistantFile, config_data_, _1);
file.write_on_changes = -1; // write on any changes
gen_files_.push_back(file);
return true;
}
// ******************************************************************************************
// Verify with user if certain screens have not been completed
// ******************************************************************************************
bool ConfigurationFilesWidget::checkDependencies()
{
QStringList dependencies;
bool requiredActions = false;
// Check that at least 1 planning group exists
if (!config_data_->srdf_->groups_.size())
{
dependencies << "No robot model planning groups have been created";
}
// Check that at least 1 link pair is disabled from collision checking
if (!config_data_->srdf_->disabled_collisions_.size())
{
dependencies << "No self-collisions have been disabled";
}
// Check that there is at least 1 end effector added
if (!config_data_->srdf_->end_effectors_.size())
{
dependencies << "No end effectors have been added";
}
// Check that there is at least 1 virtual joint added
if (!config_data_->srdf_->virtual_joints_.size())
{
dependencies << "No virtual joints have been added";
}
// Check that there is a author name
if (config_data_->author_name_.find_first_not_of(' ') == std::string::npos)
{
// There is no name or it consists of whitespaces only
dependencies << "<b>No author name added</b>";
requiredActions = true;
}
// Check that email information is filled
QRegExp mailRegex("\\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\\.[A-Z]{2,4}\\b");
mailRegex.setCaseSensitivity(Qt::CaseInsensitive);
mailRegex.setPatternSyntax(QRegExp::RegExp);
QString testEmail = QString::fromStdString(config_data_->author_email_);
if (!mailRegex.exactMatch(testEmail))
{
dependencies << "<b>No valid email address added</b>";
requiredActions = true;
}
// Display all accumumlated errors:
if (dependencies.size())
{
// Create a dependency message
QString dep_message;
if (!requiredActions)
{
dep_message = "Some setup steps have not been completed. None of the steps are required, but here is a reminder "
"of what was not filled in, just in case something was forgotten:<br /><ul>";
}
else
{
dep_message = "Some setup steps have not been completed. Please fix the required steps (printed in bold), "
"otherwise the setup cannot be completed:<br /><ul>";
}
for (int i = 0; i < dependencies.size(); ++i)
{
dep_message.append("<li>").append(dependencies.at(i)).append("</li>");
}
if (!requiredActions)
{
dep_message.append("</ul><br/>Press Ok to continue generating files.");
if (QMessageBox::question(this, "Incomplete MoveIt Setup Assistant Steps", dep_message,
QMessageBox::Ok | QMessageBox::Cancel) == QMessageBox::Cancel)
{
return false; // abort
}
}
else
{
QMessageBox::warning(this, "Incomplete MoveIt Setup Assistant Steps", dep_message);
return false;
}
}
return true;
}
// ******************************************************************************************
// A function for showing progress and user feedback about what happened
// ******************************************************************************************
void ConfigurationFilesWidget::updateProgress()
{
action_num_++;
// Calc percentage
progress_bar_->setValue(double(action_num_) / gen_files_.size() * 100);
// allow the progress bar to be shown
QApplication::processEvents();
}
// ******************************************************************************************
// Display the selected action in the desc box
// ******************************************************************************************
void ConfigurationFilesWidget::changeActionDesc(int id)
{
// Only allow event if list is not empty
if (id >= 0)
{
// Show the selected text
action_label_->setText(action_desc_.at(id));
}
}
// ******************************************************************************************
// Disable or enable item in gen_files_ array
// ******************************************************************************************
void ConfigurationFilesWidget::changeCheckedState(QListWidgetItem* item)
{
std::size_t index = item->data(Qt::UserRole).toUInt();
bool generate = (item->checkState() == Qt::Checked);
if (!generate && (gen_files_[index].write_on_changes & config_data_->changes))
{
QMessageBox::warning(this, "Package Generation", "You should generate this file to ensure your changes will take "
"effect.");
}
// Enable/disable file
gen_files_[index].generate_ = generate;
}
// ******************************************************************************************
// Called when setup assistant navigation switches to this screen
// ******************************************************************************************
void ConfigurationFilesWidget::focusGiven()
{
if (first_focusGiven_)
{
// only generate list once
first_focusGiven_ = false;
// Load this list of all files to be generated
loadGenFiles();
}
// Which files have been modified outside the Setup Assistant?
bool files_already_modified = checkGenFiles();
// disable reaction to checkbox changes
disconnect(action_list_, SIGNAL(itemChanged(QListWidgetItem*)), this, SLOT(changeCheckedState(QListWidgetItem*)));
// Show files in GUI
bool have_conflicting_changes = showGenFiles();
// react to manual changes only (not programmatic ones)
connect(action_list_, SIGNAL(itemChanged(QListWidgetItem*)), this, SLOT(changeCheckedState(QListWidgetItem*)));
// Allow list box to populate
QApplication::processEvents();
if (files_already_modified)
{
// Some were found to be modified
QString msg("Some files have been modified outside of the Setup Assistant (according to timestamp). "
"The Setup Assistant will not overwrite these changes by default because often changing configuration "
"files manually is necessary, "
"but we recommend you check the list and enable the checkbox next to files you would like to "
"overwrite. ");
if (have_conflicting_changes)
msg += "<br/><font color='red'>Attention:</font> Some files (<font color='red'>marked red</font>) are changed "
"both, externally and in Setup Assistant.";
QMessageBox::information(this, "Files Modified", msg);
}
}
// ******************************************************************************************
// Check the list of files to be generated for modification
// Returns true if files were detected as modified
// ******************************************************************************************
bool ConfigurationFilesWidget::checkGenFiles()
{
// Check if we are 'editing' a prev generated config pkg
if (config_data_->config_pkg_path_.empty())
return false; // this is a new package
// Check if we have the previous modification timestamp to compare agains
if (config_data_->config_pkg_generated_timestamp_ == 0)
return false; // this package has not been generated with a timestamp, backwards compatible.
static const std::time_t TIME_MOD_TOLERANCE = 10;
// Check all old file's modification time
bool found_modified = false;
for (int i = 0; i < gen_files_.size(); ++i)
{
GenerateFile* file = &gen_files_[i];
fs::path file_path = config_data_->appendPaths(config_data_->config_pkg_path_, file->rel_path_);
// Don't disable folders from being generated
if (fs::is_directory(file_path))
continue;
if (fs::is_regular_file(file_path))
{
std::time_t mod_time = fs::last_write_time(file_path);
// ROS_DEBUG_STREAM("File " << file->file_name_ << " file modified " << mod_time << " pkg modified " <<
// config_data_->config_pkg_generated_timestamp_);
if (mod_time > config_data_->config_pkg_generated_timestamp_ + TIME_MOD_TOLERANCE ||
mod_time < config_data_->config_pkg_generated_timestamp_ - TIME_MOD_TOLERANCE)
{
ROS_INFO_STREAM("Manual editing detected: not over-writing by default file " << file->file_name_);
if (file->write_on_changes & config_data_->changes)
ROS_WARN_STREAM("Editing in Setup Assistant conflicts with external editing of file " << file->file_name_);
file->generate_ = false; // do not overwrite by default
file->modified_ = true;
found_modified = true;
}
else
{
file->modified_ = false;
}
}
}
// Warn user if files have been modified outside Setup Assistant
return found_modified;
}
// ******************************************************************************************
// Show the list of files to be generated
// ******************************************************************************************
bool ConfigurationFilesWidget::showGenFiles()
{
bool have_conflicting_changes = false;
action_list_->clear();
// Display this list in the GUI
for (std::size_t i = 0; i < gen_files_.size(); ++i)
{
GenerateFile* file = &gen_files_[i];
// Create a formatted row
QListWidgetItem* item = new QListWidgetItem(QString(file->rel_path_.c_str()), action_list_, 0);
fs::path file_path = config_data_->appendPaths(config_data_->config_pkg_path_, file->rel_path_);
// Checkbox
item->setCheckState(file->generate_ ? Qt::Checked : Qt::Unchecked);
// externally modified?
if (file->modified_)
{
if (file->write_on_changes & config_data_->changes)
{
have_conflicting_changes = true;
item->setForeground(QBrush(QColor(255, 0, 0)));
}
else
item->setForeground(QBrush(QColor(255, 135, 0)));
}
// Don't allow folders to be disabled
if (fs::is_directory(file_path))
{
item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
}
// Link the gen_files_ index to this item
item->setData(Qt::UserRole, QVariant(static_cast<qulonglong>(i)));
// Add actions to list
action_list_->addItem(item);
action_desc_.append(QString(file->description_.c_str()));
}
// Select the first item in the list so that a description is visible
action_list_->setCurrentRow(0);
return have_conflicting_changes;
}
// ******************************************************************************************
// Save configuration click event
// ******************************************************************************************
void ConfigurationFilesWidget::savePackage()
{
// Feedback
success_label_->hide();
// Reset the progress bar counter and GUI stuff
action_num_ = 0;
progress_bar_->setValue(0);
if (!generatePackage())
{
ROS_ERROR_STREAM("Failed to generate entire configuration package");
return;
}
// Alert user it completed successfully --------------------------------------------------
progress_bar_->setValue(100);
success_label_->show();
has_generated_pkg_ = true;
}
// ******************************************************************************************
// Save package using default path
// ******************************************************************************************
bool ConfigurationFilesWidget::generatePackage()
{
// Get path name
std::string new_package_path = stack_path_->getPath();
// Check that a valid stack package name has been given
if (new_package_path.empty())
{
QMessageBox::warning(this, "Error Generating", "No package path provided. Please choose a directory location to "
"generate the MoveIt configuration files.");
return false;
}
// Check setup assist deps
if (!checkDependencies())
return false; // canceled
// Check that all groups have components
if (!noGroupsEmpty())
return false; // not ready
// Trim whitespace from user input
boost::trim(new_package_path);
// Get the package name ---------------------------------------------------------------------------------
new_package_name_ = getPackageName(new_package_path);
const std::string setup_assistant_file = config_data_->appendPaths(new_package_path, SETUP_ASSISTANT_FILE);
// Make sure old package is correct package type and verify over write
if (fs::is_directory(new_package_path) && !fs::is_empty(new_package_path))
{
// Check if the old package is a setup assistant package. If it is not, quit
if (!fs::is_regular_file(setup_assistant_file))
{
QMessageBox::warning(
this, "Incorrect Folder/Package",
QString("The chosen package location already exists but was not previously created using this MoveIt Setup "
"Assistant. "
"If this is a mistake, add the missing file: ")
.append(setup_assistant_file.c_str()));
return false;
}
// Confirm overwrite
if (QMessageBox::question(
this, "Confirm Package Update",
QString("Are you sure you want to overwrite this existing package with updated configurations?<br /><i>")
.append(new_package_path.c_str())
.append("</i>"),
QMessageBox::Ok | QMessageBox::Cancel) == QMessageBox::Cancel)
{
return false; // abort
}
}
else // this is a new package (but maybe the folder already exists)
{
// Create new directory ------------------------------------------------------------------
try
{
fs::create_directory(new_package_path) && !fs::is_directory(new_package_path);
}
catch (...)
{
QMessageBox::critical(this, "Error Generating Files",
QString("Unable to create directory ").append(new_package_path.c_str()));
return false;
}
}
// Begin to create files and folders ----------------------------------------------------------------------
std::string absolute_path;
for (int i = 0; i < gen_files_.size(); ++i)
{
GenerateFile* file = &gen_files_[i];
// Check if we should skip this file
if (!file->generate_)
{
continue;
}
// Create the absolute path
absolute_path = config_data_->appendPaths(new_package_path, file->rel_path_);
ROS_DEBUG_STREAM("Creating file " << absolute_path);
// Run the generate function
if (!file->gen_func_(absolute_path))
{
// Error occured
QMessageBox::critical(this, "Error Generating File", QString("Failed to generate folder or file: '")
.append(file->rel_path_.c_str())
.append("' at location:\n")
.append(absolute_path.c_str()));
return false;
}
updateProgress(); // Increment and update GUI
}
return true;
}
// ******************************************************************************************
// Quit the program because we are done
// ******************************************************************************************
void ConfigurationFilesWidget::exitSetupAssistant()
{
if (has_generated_pkg_ ||
QMessageBox::question(this, "Exit Setup Assistant",
QString("Are you sure you want to exit the MoveIt Setup Assistant?"),
QMessageBox::Ok | QMessageBox::Cancel) == QMessageBox::Ok)
{
QApplication::quit();
}
}
// ******************************************************************************************
// Get the last folder name in a directory path
// ******************************************************************************************
const std::string ConfigurationFilesWidget::getPackageName(std::string package_path)
{
// Remove end slash if there is one
if (!package_path.compare(package_path.size() - 1, 1, "/"))
{
package_path = package_path.substr(0, package_path.size() - 1);
}
// Get the last directory name
std::string package_name;
fs::path fs_package_path = package_path;
package_name = fs_package_path.filename().c_str();
// check for empty
if (package_name.empty())
package_name = "unknown";
return package_name;
}
// ******************************************************************************************
// Check that no group is empty (without links/joints/etc)
// ******************************************************************************************
bool ConfigurationFilesWidget::noGroupsEmpty()
{
// Loop through all groups
for (std::vector<srdf::Model::Group>::const_iterator group_it = config_data_->srdf_->groups_.begin();
group_it != config_data_->srdf_->groups_.end(); ++group_it)
{
// Whenever 1 of the 4 component types are found, stop checking this group
if (group_it->joints_.size())
continue;
if (group_it->links_.size())
continue;
if (group_it->chains_.size())
continue;
if (group_it->subgroups_.size())
continue;
// This group has no contents, bad
QMessageBox::warning(
this, "Empty Group",
QString("The planning group '")
.append(group_it->name_.c_str())
.append("' is empty and has no subcomponents associated with it (joints/links/chains/subgroups). You must "
"edit or remove this planning group before this configuration package can be saved."));
return false;
}
return true; // good
}
// ******************************************************************************************
// Load the strings that will be replaced in all templates
// ******************************************************************************************
void ConfigurationFilesWidget::loadTemplateStrings()
{
// Pair 1
addTemplateString("[GENERATED_PACKAGE_NAME]", new_package_name_);
// Pair 2
std::string urdf_location = config_data_->urdf_pkg_name_.empty() ? config_data_->urdf_path_ :
"$(find " + config_data_->urdf_pkg_name_ + ")/" +
config_data_->urdf_pkg_relative_path_;
addTemplateString("[URDF_LOCATION]", urdf_location);
// Pair 3
if (config_data_->urdf_from_xacro_)
addTemplateString("[URDF_LOAD_ATTRIBUTE]",
"command=\"xacro " + config_data_->xacro_args_ + " '" + urdf_location + "'\"");
else
addTemplateString("[URDF_LOAD_ATTRIBUTE]", "textfile=\"" + urdf_location + "\"");
// Pair 4
addTemplateString("[ROBOT_NAME]", config_data_->srdf_->robot_name_);
// Pair 5
addTemplateString("[ROBOT_ROOT_LINK]", config_data_->getRobotModel()->getRootLinkName());
// Pair 6
addTemplateString("[PLANNING_FRAME]", config_data_->getRobotModel()->getModelFrame());
// Pair 7
std::stringstream vjb;
for (std::size_t i = 0; i < config_data_->srdf_->virtual_joints_.size(); ++i)
{
const srdf::Model::VirtualJoint& vj = config_data_->srdf_->virtual_joints_[i];
if (vj.type_ != "fixed")
vjb << " <node pkg=\"tf\" type=\"static_transform_publisher\" name=\"virtual_joint_broadcaster_" << i
<< "\" args=\"0 0 0 0 0 0 " << vj.parent_frame_ << " " << vj.child_link_ << " 100\" />" << std::endl;
}
addTemplateString("[VIRTUAL_JOINT_BROADCASTER]", vjb.str());
// Pair 8 - Add dependencies to package.xml if the robot.urdf file is relative to a ROS package
if (config_data_->urdf_pkg_name_.empty())
{
addTemplateString("[OTHER_DEPENDENCIES", ""); // not relative to a ROS package
}
else
{
std::stringstream deps;
deps << "<build_depend>" << config_data_->urdf_pkg_name_ << "</build_depend>\n";
deps << " <run_depend>" << config_data_->urdf_pkg_name_ << "</run_depend>\n";
addTemplateString("[OTHER_DEPENDENCIES]", deps.str()); // not relative to a ROS package
}
addTemplateString("[AUTHOR_NAME]", config_data_->author_name_);
addTemplateString("[AUTHOR_EMAIL]", config_data_->author_email_);
}
// ******************************************************************************************
// Insert a string pair into the template_strings_ datastructure
// ******************************************************************************************
bool ConfigurationFilesWidget::addTemplateString(const std::string& key, const std::string& value)
{
template_strings_.push_back(std::pair<std::string, std::string>(key, value));
return true;
}
// ******************************************************************************************
// Copy a template from location <template_path> to location <output_path> and replace package name
// ******************************************************************************************
bool ConfigurationFilesWidget::copyTemplate(const std::string& template_path, const std::string& output_path)
{
// Check if template strings have been loaded yet
if (template_strings_.empty())
{
loadTemplateStrings();
}
// Error check file
if (!fs::is_regular_file(template_path))
{
ROS_ERROR_STREAM("Unable to find template file " << template_path);
return false;
}
// Load file
std::ifstream template_stream(template_path.c_str());
if (!template_stream.good()) // File not found
{
ROS_ERROR_STREAM("Unable to load file " << template_path);
return false;
}
// Load the file to a string using an efficient memory allocation technique
std::string template_string;
template_stream.seekg(0, std::ios::end);
template_string.reserve(template_stream.tellg());
template_stream.seekg(0, std::ios::beg);
template_string.assign((std::istreambuf_iterator<char>(template_stream)), std::istreambuf_iterator<char>());
template_stream.close();
// Replace keywords in string ------------------------------------------------------------
for (int i = 0; i < template_strings_.size(); ++i)
{
boost::replace_all(template_string, template_strings_[i].first, template_strings_[i].second);
}
// Save string to new location -----------------------------------------------------------
std::ofstream output_stream(output_path.c_str(), std::ios_base::trunc);
if (!output_stream.good())
{
ROS_ERROR_STREAM("Unable to open file for writing " << output_path);
return false;
}
output_stream << template_string.c_str();
output_stream.close();
return true; // file created successfully
}
// ******************************************************************************************
// Create a folder
// ******************************************************************************************
bool ConfigurationFilesWidget::createFolder(const std::string& output_path)
{
if (!fs::is_directory(output_path))
{
if (!fs::create_directory(output_path))
{
QMessageBox::critical(this, "Error Generating Files",
QString("Unable to create directory ").append(output_path.c_str()));
return false;
}
}
return true;
}
} // namespace
| [
"tzahroof@stanford.edu"
] | tzahroof@stanford.edu |
ced8c73f39020492697618071a5038aaca6b200b | aa0bb4989cb4c971b013b5309064eddae79bf595 | /189_RotateArray.cpp | ef93deb2e84326da2ae5ae4ff74cd5668027fe53 | [] | no_license | XTan-Smile/CodingExercise | 7420d878aa59d9463c7bdb174b2277e47a057f64 | 2e20066c02d9ea89d2275f558352052ac4deecf9 | HEAD | 2016-08-12T09:31:08.352802 | 2015-07-07T17:17:27 | 2015-07-07T17:17:27 | 36,634,530 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,149 | cpp | class Solution {
public:
void rotate(vector<int>& nums, int k) {
/*** 24ms ***/
int n = nums.size();
if (!n) return;
int step = k % n;
if (step) {
vector<int> temps;
// store the last n-k elements
for (int i = n-step; i < n; i++) {
temps.push_back(nums[i]);
}
// move the first k elements
for (int i = n-step-1, j = n-1; i >= 0; i--, j--) {
nums[j] = nums[i];
}
// move the stored elements
for (int i = 0; i < temps.size(); i++) {
nums[i] = temps[i];
}
}
/*** 72ms ***/
int n = nums.size();
if (!n) return;
int step = k % n;
vector<int>::iterator it = nums.begin();
while(step) {
int temp = nums.back();
nums.pop_back();
nums.emplace(it, temp);
step--;
}
/*** 24ms ***/
int n = nums.size();
if (!n) return;
int step = k % n;
if (step) {
vector<int> temps(step,0);
for (int i = step; i > 0; i--) {
temps[step-i] = nums[n-i];
}
temps.resize(n,0);
for (int i = 0; i < n-step; i++) {
temps[i+step] = nums[i];
}
nums = temps;
}
}
};
| [
"xiao.tan@duke.edu"
] | xiao.tan@duke.edu |
70ddecf9c5236ec202b10e8e14cbc8610533d420 | 801f7ed77fb05b1a19df738ad7903c3e3b302692 | /optimisationRefactoring/differentiatedCAD/occt-min-topo-src/src/MeshVS/MeshVS_MapIteratorOfMapOfTwoNodes.hxx | 6f8334c7177e91be60eff139b47129ac9d9dd52f | [] | no_license | salvAuri/optimisationRefactoring | 9507bdb837cabe10099d9481bb10a7e65331aa9d | e39e19da548cb5b9c0885753fe2e3a306632d2ba | refs/heads/master | 2021-01-20T03:47:54.825311 | 2017-04-27T11:31:24 | 2017-04-27T11:31:24 | 89,588,404 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 153 | hxx |
#ifndef MeshVS_MapIteratorOfMapOfTwoNodes_HeaderFile
#define MeshVS_MapIteratorOfMapOfTwoNodes_HeaderFile
#include <MeshVS_MapOfTwoNodes.hxx>
#endif
| [
"salvatore.auriemma@opencascade.com"
] | salvatore.auriemma@opencascade.com |
a940cadb33a18014e2e83be7ef7afe6da98c0c1c | 6d05ec88617d226a8d9cbcb3d1af863f58bda606 | /cpp/InheritVF/d_random.h | 566c40b94dd5d3f49af93534c157374c078b79ce | [] | no_license | jxn007008009/WSN_SYSTEM | 456d264f4f7556380e231da3564e8ca63d5f0c0c | f50343fccdaf4dba19ad2087583a5a305ba1ac67 | refs/heads/master | 2021-05-27T08:19:59.055476 | 2013-08-02T13:47:44 | 2013-08-02T13:47:44 | 295,070,327 | 1 | 0 | null | 2020-09-13T03:25:45 | 2020-09-13T03:25:44 | null | UTF-8 | C++ | false | false | 1,557 | h | #include <time.h>
#ifndef RANDOMNUM
#define RANDOMNUM
// generate random numbers
class randomNumber
{
public:
// initialize the random number generator
randomNumber(long s = 0);
// return a 32-bit random integer m, 1 <= m <= 2^31-2
long random();
// return a 32-bit random integer m, 0 <= m <= n-1,
// where n <= 2^31-1
long random(long n);
// return a real number x, 0 <= x < 1
double frandom();
private:
static const long A;
static const long M;
static const long Q;
static const long R;
long seed;
};
const long randomNumber::A = 48271;
const long randomNumber::M = 2147483647;
const long randomNumber::Q = M / A;
const long randomNumber::R = M % A;
randomNumber::randomNumber(long s)
{
if (s < 0)
s = 0;
if (s == 0)
{
// get time of day in seconds since 12:00 AM,
// January 1, 1970
long t_time = time(NULL);
// mix-up bits by squaring
t_time *= t_time;
// result can overflow. handle cases
// > 0, < 0, = 0
if (t_time > 0)
s = t_time ^ 0x5EECE66DL;
else if (t_time < 0)
s = (t_time & 0x7fffffff) ^ 0x5EECE66DL;
else
s = 0x5EECE66DL;
}
seed = s;
}
long randomNumber::random()
{
long tmpSeed = A * ( seed % Q ) - R * ( seed / Q );
if( tmpSeed >= 0 )
seed = tmpSeed;
else
seed = tmpSeed + M;
return seed;
}
long randomNumber::random(long n)
{
double fraction = double(random())/double(M);
return int(fraction * n);
}
double randomNumber::frandom()
{
return double(random())/double(M);
}
#endif | [
"244161716@qq.com"
] | 244161716@qq.com |
2bf71a7a7088c37731e6f7ecab948f7e5c36982a | a3397257311767947ac482db871c14ddd27f1d4e | /ISLAND/MyFramework/System/Camera/FollowCamera.cpp | e1976b7c63e5118be65b7e1beab856a30bd896df | [] | no_license | jheun66/ISLAND | 10813b414585e5abcbefe1cb452c34795a29039d | 54109db38de0473a3a32f8d9298f5c36ab2f6340 | refs/heads/main | 2023-01-14T13:40:07.010515 | 2020-11-12T05:46:32 | 2020-11-12T05:46:32 | 305,555,595 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,805 | cpp | #include "Framework.h"
FollowCamera::FollowCamera()
:distance(60), height(60), offset(0, 5, 0),
moveDamping(5), rotDamping(0), destPos(0, 0, 0), destRot(0),
rotY(0), rotSpeed(0.001f), zoomSpeed(0.1f),
target(nullptr)
{
}
FollowCamera::~FollowCamera()
{
}
void FollowCamera::Update()
{
if (target == nullptr)
return;
Move();
}
void FollowCamera::Move()
{
//Vector3 tempPos = Vector3(0, 0, -distance);
if (rotDamping > 0.0f)
{
if (target->rotation.y != destRot)
{
destRot = LERP(destRot, target->rotation.y, rotDamping * DELTA);
}
matRotation = XMMatrixRotationY(destRot);
}
else
{
MouseControl();
matRotation = XMMatrixRotationY(rotY);
}
forward = XMVector3TransformNormal(kForward, matRotation);
destPos = forward * -distance;
destPos += target->WorldPos();
destPos.y += height;
position = XMVectorLerp(position.data, destPos.data, moveDamping * DELTA);
Vector3 tempOffset = XMVector3TransformCoord(offset.data, matRotation);
matView = XMMatrixLookAtLH(position.data, (target->WorldPos() + tempOffset).data, up.data);
viewBuffer->Set(matView);
}
void FollowCamera::MouseControl()
{
if (KEY_PRESS(VK_RBUTTON))
{
Vector3 value = MOUSEPOS - oldPos;
rotY += value.x * rotSpeed;
}
oldPos = MOUSEPOS;
distance -= Control::Get()->GetWheel() * zoomSpeed;
height -= Control::Get()->GetWheel() * zoomSpeed;
}
void FollowCamera::PostRender()
{
Camera::PostRender();
ImGui::SliderFloat("CamDistance", &distance, -10, 100);
ImGui::SliderFloat("CamHeight", &height, 1, 100);
ImGui::SliderFloat("CamMoveDamping", &moveDamping, 0, 30);
ImGui::SliderFloat("CamRotDamping", &rotDamping, 0, 30);
ImGui::SliderFloat3("CamOffset", (float*)&offset, -20.0f, 20.0f);
}
| [
"jheun5@naver.com"
] | jheun5@naver.com |
ea09a105592d1d0e292ab055bc7721c11da041c8 | 9a184dde23113f9cec922719942ff54a0c4a671c | /priyankanadtoys.cpp | c17a7c0486856aae446401f2fb6b7cfad35da82d | [] | no_license | shivam2207/HackerRank-Solutions | 8f51ee93a42900097f669111a976b6e40a093a68 | 53da486405c5f97f86d34c9e6188dd28e0dc17b0 | refs/heads/master | 2020-03-08T00:43:40.898005 | 2018-04-02T21:09:05 | 2018-04-02T21:09:05 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 323 | cpp | #include <iostream>
#include <algorithm>
using namespace std;
int main()
{
int n,i;
cin >> n;
int array[n],count=0,weight;
for(i=0;i<n;i++)
{
cin >> array[i];
}
sort(array,array+n);
weight=-1;
for(i=0;i<n;i++)
{
if(array[i]>weight)
{
weight=array[i]+4;
count++;
}
}
cout<<count<<endl;
return 0;
} | [
"shivamkhare2207@gmail.com"
] | shivamkhare2207@gmail.com |
c20d079db0d6421bdd8a1cf3ebd93e9e8e553b49 | 5d3f49bfbb5c2cbf5b594753a40284559568ebfd | /include/eglplus/enums/surface_type_bit.hpp | 6265ec3ff0e2af981639e8880fa4a6d8ee7fa34d | [
"BSL-1.0"
] | permissive | highfidelity/oglplus | f28e41c20e2776b8bd9c0a87758fb6b9395ff649 | c5fb7cc21869cb9555cfa2a7e28ea6bc6491d11e | refs/heads/develop | 2021-01-16T18:57:37.366227 | 2015-04-08T18:35:37 | 2015-04-08T18:54:19 | 33,630,979 | 2 | 8 | null | 2015-04-08T20:38:33 | 2015-04-08T20:38:32 | null | UTF-8 | C++ | false | false | 912 | hpp | // File include/eglplus/enums/surface_type_bit.hpp
//
// Automatically generated file, DO NOT modify manually.
// Edit the source 'source/enums/eglplus/surface_type_bit.txt'
// or the 'source/enums/make_enum.py' script instead.
//
// Copyright 2010-2015 Matus Chochlik.
// Distributed under the Boost Software License, Version 1.0.
// See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt
//
#include <eglplus/enumerations.hpp>
namespace eglplus {
/// Enumeration SurfaceTypeBit
/**
* @ingroup eglplus_enumerations
*/
EGLPLUS_ENUM_CLASS_BEGIN(SurfaceTypeBit, EGLenum)
#include <eglplus/enums/surface_type_bit.ipp>
EGLPLUS_ENUM_CLASS_END(SurfaceTypeBit)
#if !EGLPLUS_NO_ENUM_VALUE_NAMES
#include <eglplus/enums/surface_type_bit_names.ipp>
#endif
#if !EGLPLUS_NO_ENUM_VALUE_RANGES
#include <eglplus/enums/surface_type_bit_range.ipp>
#endif
} // namespace eglplus
| [
"chochlik@gmail.com"
] | chochlik@gmail.com |
9adcc9cc1d2d150b6d7b31a54e74433b75892ee4 | 9108ccf1b9274d77cbef6a73b37d6c5c18df5ebb | /Follower.hpp | dafc85a3b4bcd08816dde5c1249c3ab9929109ff | [] | no_license | miketheofan/L5R | 62cdc3989b1b949c1484f86121e0436bff672b60 | 687692bf30cde6e2056f60f80363279086fc10d9 | refs/heads/master | 2023-03-25T12:24:27.808479 | 2021-03-20T12:01:11 | 2021-03-20T12:01:11 | 295,233,581 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 650 | hpp | #ifndef _FOLLOWER_HPP_
#define _FOLLOWER_HPP_
#include <iostream>
#include "Card.hpp"
class Follower : public GreenCard {
private:
bool isDead;
public:
void setisDead(bool);
bool getisDead(void);
};
class Footsoldier : public Follower {
public:
Footsoldier(std::string);
};
class Archer : public Follower {
public:
Archer(std::string);
};
class Cavalry : public Follower {
public:
Cavalry(std::string);
};
class Bushido : public Follower {
public:
Bushido(std::string);
};
class Sieger : public Follower {
public:
Sieger(std::string);
};
class Atakebune : public Follower {
public:
Atakebune(std::string);
};
#endif | [
"noreply@github.com"
] | noreply@github.com |
5b0b03f0f93220fb5fb4aa8a0a22764c24db2238 | ca54e57bd8db9c80209af0e045bbbe16065a51e3 | /plugins/CPUSensors/IntelCPUMonitor/IntelCPUMonitor.cpp | bc5f7800797c711f094f55bc111cc71fb631d4e8 | [] | no_license | sea87321/FakeSMC3_with_plugins | c7154b383b337e943663d80d40b1fc55674bc567 | 1c7874858d4024f4be2479f5637eb1ec96822b98 | refs/heads/master | 2022-02-25T10:06:58.735382 | 2019-10-01T12:45:31 | 2019-10-01T12:45:31 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 23,934 | cpp | /*
* IntelCPUMonitor.cpp
* HWSensors
*
* Created by Slice on 20.12.10.
* Copyright 2010 mozodojo. All rights reserved.
*
*/
#include "IntelCPUMonitor.h"
#include "FakeSMC.h"
#include "../../../utils/utils.h"
#define Debug FALSE
#define LogPrefix "IntelCPUMonitor: "
#define DebugLog(string, args...) do { if (Debug) { IOLog (LogPrefix "[Debug] " string "\n", ## args); } } while(0)
#define WarningLog(string, args...) do { IOLog (LogPrefix "[Warning] " string "\n", ## args); } while(0)
#define InfoLog(string, args...) do { IOLog (LogPrefix string "\n", ## args); } while(0)
static UInt8 GlobalThermalValue[MaxCpuCount];
static bool GlobalThermalValueIsObsolete[MaxCpuCount];
static PState GlobalState[MaxCpuCount];
static UInt64 GlobalState64; //it is for package
static UInt16 InitFlags[MaxCpuCount];
static UInt64 UCC[MaxCpuCount];
static UInt64 UCR[MaxCpuCount];
static UInt64 lastUCC[MaxCpuCount];
static UInt64 lastUCR[MaxCpuCount];
const UInt32 Kilo = 1000; //Slice
const UInt32 Mega = Kilo * 1000;
//const UInt32 Giga = Mega * 1000;
inline UInt32 BaseOperatingFreq(void) {
UInt64 msr = rdmsr64(MSR_PLATFORM_INFO);
return (msr & 0xFF00) >> 8;
}
inline UInt64 ReadUCC(void) {
UInt32 lo,hi;
rdpmc(0x40000001, lo, hi);
return ((UInt64)hi << 32 ) | lo;
}
inline UInt64 ReadUCR(void) {
UInt32 lo,hi;
rdpmc(0x40000002, lo, hi);
return ((UInt64)hi << 32 )| lo;
}
inline void initPMCCounters(UInt8 cpu) {
if (cpu < MaxCpuCount) {
if (!InitFlags[cpu]) {
wrmsr64(MSR_PERF_FIXED_CTR_CTRL, 0x222ll);
wrmsr64(MSR_PERF_GLOBAL_CTRL, 0x7ll << 32);
InitFlags[cpu]=true;
}
}
}
inline void IntelWaitForSts(void) {
UInt32 inline_timeout = 100000;
while (rdmsr64(MSR_IA32_PERF_STS) & (1 << 21)) {
if (!inline_timeout--) { break; }
}
}
void UCState(__unused void * magic) {
volatile UInt32 i = cpu_number();
if (i < MaxCpuCount) {
initPMCCounters(i);
lastUCC[i]=UCC[i];
lastUCR[i]=UCR[i];
UCC[i]=ReadUCC();
UCR[i]=ReadUCR();
}
}
void IntelState(__unused void * magic) {
volatile UInt32 i = cpu_number();
if (i < MaxCpuCount) {
UInt64 msr = rdmsr64(MSR_IA32_PERF_STS);
GlobalState[i].Control = msr & 0xFFFF;
GlobalState64 = msr;
}
}
void IntelThermal(__unused void * magic) {
volatile UInt32 i = cpu_number();
if (i < MaxCpuCount) {
UInt64 msr = rdmsr64(MSR_IA32_THERM_STATUS);
// UInt64 E2 = rdmsr64(0xE2); //Check for E2 lock
if (msr & 0x80000000) {
GlobalThermalValue[i] = (msr >> 16) & 0x7F;
/*
if (E2 & 0x8000) {
GlobalThermalValue[i] -= 50;
}
*/
GlobalThermalValueIsObsolete[i]=false;
}
}
}
void IntelState2(__unused void * magic) {
volatile UInt32 i = cpu_number() >> 1;
if (i < MaxCpuCount) {
UInt64 msr = rdmsr64(MSR_IA32_PERF_STS);
GlobalState[i].Control = msr & 0xFFFF;
GlobalState64 = msr;
}
}
void IntelThermal2(__unused void * magic) {
volatile UInt32 i = cpu_number() >> 1;
if (i < MaxCpuCount) {
UInt64 msr = rdmsr64(MSR_IA32_THERM_STATUS);
if (msr & 0x80000000) {
GlobalThermalValue[i] = (msr >> 16) & 0x7F;
GlobalThermalValueIsObsolete[i]=false;
}
}
}
// Power states!
enum {
kMyOnPowerState = 1
};
static IOPMPowerState myTwoStates[2] = {
{1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{1, kIOPMPowerOn, kIOPMPowerOn, kIOPMPowerOn, 0, 0, 0, 0, 0, 0, 0, 0}
};
#define super IOService
OSDefineMetaClassAndStructors(IntelCPUMonitor, IOService)
bool IntelCPUMonitor::init(OSDictionary *properties) {
DebugLog("Initialising...");
if (!super::init(properties)) {
return false;
}
return true;
}
IOService* IntelCPUMonitor::probe(IOService *provider, SInt32 *score)
{
// bool RPltSet = false;
DebugLog("Probing...");
if (super::probe(provider, score) != this) {
return 0;
}
InfoLog("Based on code by mercurysquad, superhai (C)2008. Turbostates measurement added by Navi");
// InfoLog("at probe 0xE2 = 0x%llx\n", rdmsr64(0xE2));
cpuid_update_generic_info();
if (strcmp(cpuid_info()->cpuid_vendor, CPUID_VID_INTEL) != 0) {
WarningLog("No Intel processor found, kext will not load");
return 0;
}
if (!(cpuid_info()->cpuid_features & CPUID_FEATURE_MSR)) {
WarningLog("Processor does not support Model Specific Registers, kext will not load");
return 0;
}
count = cpuid_info()->core_count;//cpuid_count_cores();
threads = cpuid_info()->thread_count;
//uint64_t msr = rdmsr64(MSR_CORE_THREAD_COUNT); //nehalem only
//uint64_t m2 = msr >> 32;
if (count == 0) {
WarningLog("CPUs not found, kext will not load");
return 0;
}
CpuFamily = cpuid_info()->cpuid_family;
CpuModel = cpuid_info()->cpuid_model;
CpuStepping = cpuid_info()->cpuid_stepping;
CpuMobile = false;
userTjmax = 0;
OSNumber* number = OSDynamicCast(OSNumber, getProperty("TjMax"));
if (number) {
// User defined Tjmax
userTjmax = number->unsigned32BitValue();
IOLog("User defined TjMax=%d\n", (int)userTjmax);
// snprintf(Platform, 4, "n");
// number->release();
}
/*
if (OSString* name = OSDynamicCast(OSString, getProperty("RPlt"))) {
snprintf(Platform, 4, "%s", name ? name->getCStringNoCopy() : "n");
if ((Platform[0] != 'n') && (Platform[0] != 'N')) {
RPltSet = true;
}
}
*/
// Calculating Tjmax
switch (CpuFamily) {
case 0x06: {
switch (CpuModel) {
case CPU_MODEL_PENTIUM_M:
case CPU_MODEL_CELERON:
tjmax[0] = 100;
CpuMobile = true;
/*
if (!RPltSet) {
snprintf(Platform, 4, "M70");
RPltSet = true;
}
*/
break;
case CPU_MODEL_YONAH:
tjmax[0] = 85;
if (rdmsr64(0x17) & (1<<28)) {
CpuMobile = true;
}
/*
if (!RPltSet) {
snprintf(Platform, 4, "K22");
RPltSet = true;
}
*/
break;
case CPU_MODEL_MEROM: // Intel Core (65nm)
if (rdmsr64(0x17) & (1<<28)) {
CpuMobile = true;
}
switch (CpuStepping) {
case 0x02: // G0
tjmax[0] = 80; //why 95?
//snprintf(Platform, 4, "M71");
break;
case 0x06: // B2
switch (count) {
case 2:
tjmax[0] = 80; break;
case 4:
tjmax[0] = 90; break;
default:
tjmax[0] = 85; break;
}
//tjmax[0] = 80;
break;
case 0x0B: // G0
tjmax[0] = 90; break;
case 0x0A:
case 0x0D: // M0
if (CpuMobile) {
tjmax[0] = 100;
} else {
tjmax[0] = 85;
}
break;
default:
tjmax[0] = 85; break;
}
/*
if (!RPltSet) {
snprintf(Platform, 4, "M75");
RPltSet = true;
}
*/
break;
case CPU_MODEL_PENRYN: // Intel Core (45nm)
// Mobile CPU ?
if (rdmsr64(0x17) & (1<<28)) { //mobile
CpuMobile = true;
tjmax[0] = 105;
/*
if (!RPltSet) {
snprintf(Platform, 4, "M82");
RPltSet = true;
}
*/
} else {
switch (CpuStepping) {
case 7:
tjmax[0] = 95;
break;
default:
tjmax[0] = 100;
break;
}
/*
if (!RPltSet) {
snprintf(Platform, 4, "K36");
RPltSet = true;
}
*/
}
break;
case CPU_MODEL_ATOM: // Intel Atom (45nm)
switch (CpuStepping) {
case 0x02: // C0
tjmax[0] = 100; break;
case 0x0A: // A0, B0
tjmax[0] = 100; break;
default:
tjmax[0] = 90; break;
}
/*
if (!RPltSet) {
snprintf(Platform, 4, "T9");
RPltSet = true;
}
*/
break;
case CPU_MODEL_NEHALEM:
case CPU_MODEL_FIELDS:
case CPU_MODEL_DALES:
case CPU_MODEL_DALES_32NM:
case CPU_MODEL_WESTMERE:
case CPU_MODEL_NEHALEM_EX:
case CPU_MODEL_WESTMERE_EX:
case CPU_MODEL_SANDY_BRIDGE:
case CPU_MODEL_IVY_BRIDGE:
case CPU_MODEL_JAKETOWN:
case CPU_MODEL_HASWELL:
case CPU_MODEL_HASWELL_MB:
case CPU_MODEL_HASWELL_ULT:
case CPU_MODEL_HASWELL_ULX:
case CPU_MODEL_HASWELL_U5:
case CPU_MODEL_IVY_BRIDGE_E5:
case CPU_MODEL_BROADWELL_HQ:
case CPU_MODEL_AIRMONT:
case CPU_MODEL_AVOTON:
case CPU_MODEL_SKYLAKE_U:
case CPU_MODEL_BROADWELL_E5:
case CPU_MODEL_BROADWELL_DE:
case CPU_MODEL_KNIGHT:
case CPU_MODEL_MOOREFIELD:
case CPU_MODEL_GOLDMONT:
case CPU_MODEL_ATOM_X3:
case CPU_MODEL_SKYLAKE_D:
case CPU_MODEL_SKYLAKE_X:
case CPU_MODEL_CANNONLAKE:
case CPU_MODEL_XEON_MILL:
case CPU_MODEL_KABYLAKE1:
case CPU_MODEL_KABYLAKE2: {
nehalemArch = true;
for (int i = 0; i < count; i++) {
tjmax[i] = (rdmsr64(MSR_IA32_TEMPERATURE_TARGET) >> 16) & 0xFF;
}
}
// snprintf(Platform, 4, "T9");
break;
default:
WarningLog("Unsupported Intel processor found ID=0x%02x, kext will not load", (unsigned int)CpuModel);
return 0;
}
}
break;
default:
WarningLog("Unknown Intel family processor found ID=0x%02x, kext will not load", (unsigned int)CpuFamily);
return 0;
}
SandyArch = (CpuModel == CPU_MODEL_SANDY_BRIDGE) ||
(CpuModel == CPU_MODEL_JAKETOWN) ||
/* (CpuModel == CPU_MODEL_HASWELL) ||
(CpuModel == CPU_MODEL_IVY_BRIDGE_E5) ||
(CpuModel == CPU_MODEL_HASWELL_MB) ||
(CpuModel == CPU_MODEL_HASWELL_ULT) ||
(CpuModel == CPU_MODEL_HASWELL_ULX) || */
(CpuModel >= CPU_MODEL_IVY_BRIDGE);
if (SandyArch) {
BaseFreqRatio = BaseOperatingFreq();
DebugLog("Base Ratio = %d", (unsigned int)BaseFreqRatio);
}
/*
if (!RPltSet) {
if (SandyArch) {
if (CpuMobile) {
snprintf(Platform, 4, "k90i");
} else {
snprintf(Platform, 4, "k62");
}
} else {
snprintf(Platform, 4, "T9");
}
RPltSet = true;
}
*/
if (userTjmax != 0) {
for (int i = 0; i < count; i++) {
tjmax[i] = userTjmax;
}
} else {
for (int i = 0; i < count; i++) {
if (!nehalemArch) {
tjmax[i] = tjmax[0];
}
}
}
for (int i = 0; i < count; i++) {
key[i] = (char*)IOMalloc(5);
if (i > 15) {
for (char c = 'G'; c <= 'Z'; c++) {
int l = (int)c - 55;
if (l == i) {
snprintf(key[i], 5, "TC%cD", c);
}
}
} else {
snprintf(key[i], 5, "TC%XD", i);
}
}
// InfoLog("Platform string %s", Platform);
return this;
}
bool IntelCPUMonitor::start(IOService * provider) {
IORegistryEntry * rootNode;
DebugLog("Starting...");
if (!super::start(provider)) { return false; }
// Join power management so that we can get a notification early during
// wakeup to re-sample our battery data. We don't actually power manage
// any devices.
PMinit();
registerPowerDriver(this, myTwoStates, 2);
provider->joinPMtree(this);
if (!(fakeSMC = waitForService(serviceMatching(kFakeSMCDeviceService)))) {
WarningLog("Can't locate fake SMC device, kext will not load");
return false;
}
InfoLog("CPU family 0x%x, model 0x%x, stepping 0x%x, cores %d, threads %d", cpuid_info()->cpuid_family, cpuid_info()->cpuid_model, cpuid_info()->cpuid_stepping, count, cpuid_info()->thread_count);
InfoLog("at start 0xE2 = 0x%llx\n", rdmsr64(0xE2));
rootNode = fromPath("/efi/platform", gIODTPlane);
if (rootNode) {
OSData *tmpNumber = OSDynamicCast(OSData, rootNode->getProperty("FSBFrequency"));
BusClock = *((UInt64*) tmpNumber->getBytesNoCopy());
FSBClock = BusClock << 2;
InfoLog("Using efi");
} else {
FSBClock = gPEClockFrequencyInfo.bus_frequency_max_hz;
BusClock = FSBClock >> 2;
InfoLog("Using bus_frequency_max_hz");
}
if (!SandyArch) {
BusClock = BusClock / Mega; // I Don't like this crap - i'll write mine
} else {
float v = (float)BusClock / (float)Mega;
BusClock = (int)(v < 0 ? (v - 0.5) : (v + 0.5));
}
FSBClock = FSBClock / Mega;
InfoLog("BusClock=%dMHz FSB=%dMHz", (int)(BusClock), (int)(FSBClock));
// InfoLog("Platform string %s", Platform);
if (!(WorkLoop = getWorkLoop())) { return false; }
if (!(TimerEventSource = IOTimerEventSource::timerEventSource(this,
OSMemberFunctionCast(IOTimerEventSource::Action,
this,
&IntelCPUMonitor::loopTimerEvent)))) {
return false;
}
if (kIOReturnSuccess != WorkLoop->addEventSource(TimerEventSource)) {
return false;
}
Activate();
if (!nehalemArch) {
InfoLog("CPU Tjmax %d", tjmax[0]);
} else {
for (int i = 0; i < count; i++) {
InfoLog("CPU%X Tjmax %d", i, tjmax[i]);
}
}
for (int i = 0; i < count; i++) {
if (kIOReturnSuccess != fakeSMC->callPlatformFunction(kFakeSMCAddKeyHandler,
false,
(void *)key[i],
(void *)"sp78",
(void *)2,
this)) {
WarningLog("Can't add key to fake SMC device, kext will not load");
return false;
}
char keyF[5];
if (i > 15) {
for (char c = 'G'; c <= 'Z'; c++) {
int l = (int)c - 55;
if (l == i) {
snprintf(keyF, 5, "FRC%c", c);
}
}
} else {
snprintf(keyF, 5, "FRC%X", i);
}
if (kIOReturnSuccess != fakeSMC->callPlatformFunction(kFakeSMCAddKeyHandler,
false,
(void *)keyF,
(void *)"freq",
(void *)2,
this)) {
WarningLog("Can't add Frequency key to fake SMC device");
}
if (!nehalemArch and !SandyArch) {
char keyM[5];
snprintf(keyM, 5, KEY_FORMAT_NON_APPLE_CPU_MULTIPLIER, i);
if (kIOReturnSuccess != fakeSMC->callPlatformFunction(kFakeSMCAddKeyHandler,
false,
(void *)keyM,
(void *)TYPE_UI16,
(void *)2,
this)) {
WarningLog("Can't add key to fake SMC device");
//return false;
}
}
if (!nehalemArch || SandyArch) { // Voltage is impossible for Nehalem
char keyV[5];
snprintf(keyV, 5, KEY_CPU_VOLTAGE);
if (kIOReturnSuccess != fakeSMC->callPlatformFunction(kFakeSMCAddKeyHandler,
false,
(void *)keyV,
(void *)"fp2e",
(void *)2,
this)) {
WarningLog("Can't add Voltage key to fake SMC device");
}
}
/* but Voltage is possible on SandyBridge!
* MSR_PERF_STATUS[47:32] * (float) 1/(2^13). //there is a mistake in Intel datasheet [37:32]
* MSR 00000198 0000-2764-0000-2800
*/
}
if (nehalemArch || SandyArch) {
if (kIOReturnSuccess != fakeSMC->callPlatformFunction(kFakeSMCAddKeyHandler, false, (void *)KEY_NON_APPLE_PACKAGE_MULTIPLIER, (void *)TYPE_UI16, (void *)2, this)) {
WarningLog("Can't add key to fake SMC device");
//return false;
}
}
/*
if (Platform[0] != 'n') {
if (kIOReturnSuccess != fakeSMC->callPlatformFunction(kFakeSMCAddKeyHandler, false, (void *)"RPlt", (void *)"ch8*", (void *)6, this)) {
WarningLog("Can't add Platform key to fake SMC device");
}
}
*/
return true;
}
void IntelCPUMonitor::stop(IOService* provider) {
DebugLog("Stoping...");
Deactivate();
if (kIOReturnSuccess != fakeSMC->callPlatformFunction(kFakeSMCRemoveKeyHandler, true, this, NULL, NULL, NULL)) {
WarningLog("Can't remove key handler");
IOSleep(500);
}
super::stop(provider);
}
void IntelCPUMonitor::free() {
DebugLog("Freeing...");
super::free ();
}
void IntelCPUMonitor::Activate(void) {
if (Active) { return; }
Active = true;
loopTimerEvent();
//InfoLog("Monitoring started");
}
void IntelCPUMonitor::Deactivate(void) {
if (!Active) { return; }
if (TimerEventSource)
TimerEventSource->cancelTimeout();
Active = false;
// InfoLog("Monitoring stopped");
}
IOReturn IntelCPUMonitor::callPlatformFunction(const OSSymbol *functionName,
bool waitForFunction,
void *param1,
void *param2,
void *param3,
void *param4) {
UInt64 magic = 0;
if (functionName->isEqualTo(kFakeSMCGetValueCallback)) {
const char* name = (const char*)param1;
void * data = param2;
//UInt32 size = (UInt64)param3;
//InfoLog("key %s is called", name);
if (name && data) {
UInt16 value=0;
int index;
switch (name[0]) {
case 'T':
index = name[2] >= 'A' ? name[2] - 65 : name[2] - 48;
if (index >= 0 && index < count) {
if (threads > count) {
mp_rendezvous_no_intrs(IntelThermal2, &magic);
} else {
mp_rendezvous_no_intrs(IntelThermal, &magic);
}
value = tjmax[index] - GlobalThermalValue[index];
} else {
//DebugLog("cpu index out of bounds");
return kIOReturnBadArgument;
}
break;
case 'M':
if (strcasecmp(name, KEY_NON_APPLE_PACKAGE_MULTIPLIER) == 0) {
value = GlobalState[0].Control;
if (SandyArch) {
value = (value >> 8) * 10;
} else if (nehalemArch) {
value = value * 10;
} else {
value=0;
}
bcopy(&value, data, 2);
return kIOReturnSuccess;
} else {
index = name[2] >= 'A' ? name[2] - 65 : name[2] - 48;
if (index >= 0 && index < count) {
value = GlobalState[index].Control;
float mult = float(((value >> 8) & 0x1f)) + 0.5f * float((value >> 14) & 1);
value = mult * 10.0f;
} else {
return kIOReturnBadArgument;
}
}
break;
case 'F':
if ((name[1] != 'R') || (name[2] != 'C')) {
return kIOReturnBadArgument;
}
index = name[3] >= 'A' ? name[3] - 65 : name[3] - 48;
if (index >= 0 && index < count) {
value = swap_value(Frequency[index]);
//InfoLog("Frequency = %d", value);
//InfoLog("GlobalState: FID=%x VID=%x", GlobalState[index].FID, GlobalState[index].FID);
}
break;
case 'V':
value = encode_fp2e(Voltage);
break;
case 'R':
if ((name[1] != 'P') || (name[2] != 'l') || (name[3] != 't')) {
return kIOReturnBadArgument;
}
bcopy(Platform, data, 4);
return kIOReturnSuccess;
default:
return kIOReturnBadArgument;
}
bcopy(&value, data, 2);
return kIOReturnSuccess;
}
//DebugLog("bad argument key name or data");
return kIOReturnBadArgument;
}
return super::callPlatformFunction(functionName, waitForFunction, param1, param2, param3, param4);
}
IOReturn IntelCPUMonitor::loopTimerEvent(void) {
//Please, don't remove this timer! If frequency is read in OnKeyRead function, then the CPU is loaded by smcK-Stat-i and
//goes to a higher P-State in this moment, displays high frequency and switches back to low frequency.
UInt32 magic = 0;
if (LoopLock) {
return kIOReturnTimeout;
}
LoopLock = true;
if (SandyArch) {
mp_rendezvous_no_intrs(UCState, &magic);
IOSleep(2);
mp_rendezvous_no_intrs(UCState, &magic);
}
// State Readout
if (threads > count) {
mp_rendezvous_no_intrs(IntelState2, &magic);
} else {
mp_rendezvous_no_intrs(IntelState, &magic);
}
for (UInt32 i = 0; i < count; i++) {
Frequency[i] = IntelGetFrequency(i);
if (SandyArch) {
//value in millivolts
Voltage = GlobalState64 >> 35;
} else if (!nehalemArch) {
Voltage = IntelGetVoltage(GlobalState[i].VID);
} else {
Voltage = 1000;
}
}
LoopLock = false;
TimerEventSource->setTimeoutMS(1000);
return kIOReturnSuccess;
}
UInt32 IntelCPUMonitor::IntelGetFrequency(UInt8 cpu_id)
{
UInt32 multiplier, frequency=0;
UInt8 fid = 0;
if (SandyArch) {
fid = GlobalState[cpu_id].FID;
UInt64 deltaUCC = lastUCC[cpu_id] > UCC[cpu_id] ? 0xFFFFFFFFFFFFFFFFll - lastUCC[cpu_id] + UCC[cpu_id] : UCC[cpu_id] - lastUCC[cpu_id];
UInt64 deltaUCR = lastUCR[cpu_id] > UCR[cpu_id] ? 0xFFFFFFFFFFFFFFFFll - lastUCR[cpu_id] + UCR[cpu_id] : UCR[cpu_id] - lastUCR[cpu_id];
if (deltaUCR > 0) {
float num = (float)deltaUCC*BaseFreqRatio / (float)deltaUCR;
int n = (int)(num < 0 ? (num - 0.5) : (num + 0.5));
return (UInt32)BusClock * n;
}
}
if (!nehalemArch) {
fid = GlobalState[cpu_id].FID;
multiplier = fid & 0x1f; // = 0x08
int half = (fid & 0x40)?1:0; // = 0x01
int dfsb = (fid & 0x80)?1:0; // = 0x00
UInt32 fsb = (UInt32)BusClock >> dfsb;
UInt32 halffsb = (UInt32)BusClock >> 1; // = 200
frequency = (multiplier * fsb); // = 3200
return (frequency + (half * halffsb)); // = 3200 + 200 = 3400
} else {
if (!SandyArch) {
fid = GlobalState[cpu_id].VID;
}
multiplier = fid & 0x3f;
frequency = (multiplier * (UInt32)BusClock);
return (frequency);
}
}
UInt32 IntelCPUMonitor::IntelGetVoltage(UInt16 vid) { //no nehalem
switch (CpuModel) {
case CPU_MODEL_PENTIUM_M:
case CPU_MODEL_CELERON:
return 700 + ((vid & 0x3F) << 4);
break;
case CPU_MODEL_YONAH:
return (1425 + ((vid & 0x3F) * 25)) >> 1;
break;
case CPU_MODEL_MEROM: //Conroe?!
return (1650 + ((vid & 0x3F) * 25)) >> 1;
break;
case CPU_MODEL_PENRYN:
case CPU_MODEL_ATOM:
//vid=0x22 (~vid& 0x3F)=0x1d=29 ret=1137
return (1500 - (((~vid & 0x3F) * 25) >> 1));
break;
default:
return 0;
break;
}
return 0;
}
IOReturn IntelCPUMonitor::setPowerState(unsigned long which,IOService *whom) {
if (kMyOnPowerState == which) {
// Init PMC Fixed Counters once more
DebugLog( "awaken, resetting counters");
bzero(UCC, sizeof(UCC));
bzero(lastUCC, sizeof(lastUCC));
bzero(UCR, sizeof(UCR));
bzero(lastUCR, sizeof(lastUCR));
bzero(InitFlags, sizeof(InitFlags));
}
return IOPMAckImplied;
}
| [
"isakov-sl@bk.ru"
] | isakov-sl@bk.ru |
ac5c11e0eb092130c9cae4c70170cc9c282b069b | fafce52a38479e8391173f58d76896afcba07847 | /uppbox/uppweb/gsoc.tpp/mentor2014$en-us.tpp | 3686b0a0e60c3550e101f448043e26c067622dc2 | [
"LicenseRef-scancode-other-permissive"
] | permissive | Sly14/upp-mirror | 253acac2ec86ad3a3f825679a871391810631e61 | ed9bc6028a6eed422b7daa21139a5e7cbb5f1fb7 | refs/heads/master | 2020-05-17T08:25:56.142366 | 2015-08-24T18:08:09 | 2015-08-24T18:08:09 | 41,750,819 | 2 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 1,890 | tpp | topic "GSoC 2014. Mentor page";
[ $$0,0#00000000000000000000000000000000:Default]
[b117;*+117 $$1,0#27457433418004101424360058862402:Caption]
[{_}%EN-US
[s1;#b0; [R^topic`:`/`/uppweb`/gsoc`/gsoc2014`$en`-us^6 GSoC 2014][R6 .
Mentor page]&]
[s1;#b0; &]
[ {{10000f0;g0;^t/25b4/25 [s0;# [*+117 Introduction]]}}&]
[s1;#b0;2 &]
[s1;#b0; [*2 If you want to be a mentor, read these links and ask in
][*^http`:`/`/www`.ultimatepp`.org`/forum^2 Forum][*2 to be included
in the list, indicating also in which ][*^topic`:`/`/uppweb`/gsoc`/ideas2014`$en`-us^2 i
deas][*2 you would like to be a mentor.]&]
[s0;#2 &]
[s0;# [2 If you are a ][^topic`:`/`/uppweb`/gsoc`/student2014`$en`-us^2 student][2 ,
you can read the mentor list and contact the mentors with skills
that match with your ideas.]&]
[s0;2 &]
[s0;2%- &]
[ {{10000f0;g0;^t/25b4/25 [s0;# [*+117 Advices for mentors]]}}&]
[s0;2%- &]
[s0;i150;O0;%- [^http`:`/`/en`.flossmanuals`.net`/gsocmentoring`/^2 GSoC
Mentors Guide]&]
[s0;^http`:`/`/people`.gnome`.org`/`~federico`/docs`/summer`-of`-code`-mentoring`-howto`/index`.html^2 &]
[s0;2%- &]
[ {{10000f0;g0;^t/25b4/25 [s0;# [*+117 Mentor List]]}}&]
[s1;#b0;2 &]
[s1;#b0; [*2 Here is the mentors list and their skills related with
U`+`+ project and applications:]&]
[s0; &]
[s0; [*^http`:`/`/www`.ultimatepp`.org`/forum`/index`.php`?t`=usrinfo`&id`=647`&^2 Jan
Dolinár][2 : Project building and packaging (TheIDE or external),
Physics, Skylark.]&]
[s0; [*^http`:`/`/www`.ultimatepp`.org`/forum`/index`.php`?t`=usrinfo`&id`=3`&^2 Mirek
Fidler][2 : U`+`+ founder and main developer.]&]
[s0; [*^http`:`/`/www`.ultimatepp`.org`/forum`/index`.php`?t`=usrinfo`&id`=648`&^2 Kold
o Ramirez][2 : Engineering, Process Control, Image processing.]&]
[s0;2 &]
[s0;> [^topic`:`/`/uppweb`/gsoc`/gsoc2014`$en`-us^+75 Return to GSoC
2014 Home page]&]
[s0; ]] | [
"koldo@05275033-79c2-2956-22f4-0a99e774df92"
] | koldo@05275033-79c2-2956-22f4-0a99e774df92 |
6e1b7c97be3a84b16301ce25393529285d60401d | 60e4d2a874fe3c57da4c151f6dd09311d85a8bab | /src/DiffusionOperators/DiffusionOperator.cpp | 97bad0eb6f18459740d7d9705e0a588564c86557 | [] | no_license | mchanthagithub/finite-volume | 09866c146ce8fd8c3cb2d13638dd7e665e29baeb | d6d7935ec6398b840bd2d40418240898d93f15a0 | refs/heads/master | 2020-03-13T19:00:39.021801 | 2018-05-16T18:05:15 | 2018-05-16T18:05:15 | 131,245,865 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 71 | cpp | //
// Created by maytee on 4/29/18.
//
#include "DiffusionOperator.h"
| [
"mchantha@mit.edu"
] | mchantha@mit.edu |
c99dc01dbfd735ddcbf1701c9f3a83b4e9fdede2 | 935927010571e2f820e70cead9a1fd471d88ea16 | /Online Judge/Codeforces/Practice/2300/Destorying_Roads.cpp | 799493baa282370b85dbbac4fe0bbb2d720e2f7b | [] | no_license | muhammadhasan01/cp | ebb0869b94c2a2ab9487861bd15a8e62083193ef | 3b0152b9621c81190dd1a96dde0eb80bff284268 | refs/heads/master | 2023-05-30T07:18:02.094877 | 2023-05-21T22:03:57 | 2023-05-21T22:03:57 | 196,739,005 | 6 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,275 | cpp | #include <bits/stdc++.h>
using namespace std;
const int N = 5e3 + 5;
int n, m;
int dp[N][N];
vector<int> g[N];
int s[3], t[3], l[3];
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin >> n >> m;
for (int i = 1; i <= m; i++) {
int u, v;
cin >> u >> v;
g[u].push_back(v);
g[v].push_back(u);
}
for (int i = 1; i <= n; i++) {
queue<int> q;
q.push(i);
dp[i][i] = 1;
while (!q.empty()) {
int u = q.front();
q.pop();
for (auto v : g[u]) {
if (dp[i][v] == 0) {
dp[i][v] = 1 + dp[i][u];
q.push(v);
}
}
}
}
for (int i = 1; i <= 2; i++) {
cin >> s[i] >> t[i] >> l[i];
}
int ans = m + 1;
for (int it = 0; it < 2; it++) {
swap(s[1], t[1]);
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= n; j++) {
int p1 = dp[s[1]][i] + dp[i][j] + dp[j][t[1]] - 3;
int p2 = dp[s[2]][i] + dp[i][j] + dp[j][t[2]] - 3;
if (p1 <= l[1] && p2 <= l[2]) {
ans = min(ans, p1 + p2 - dp[i][j] + 1);
}
}
}
}
if (dp[s[1]][t[1]] - 1 <= l[1] && dp[s[2]][t[2]] - 1 <= l[2]) {
ans = min(ans, dp[s[1]][t[1]] + dp[s[2]][t[2]] - 2);
}
cout << (ans > m ? -1 : m - ans) << '\n';
return 0;
}
| [
"39514247+muhammadhasan01@users.noreply.github.com"
] | 39514247+muhammadhasan01@users.noreply.github.com |
e96bbd811d47a4d6d07b5486170e32edb2b5e12f | c32ee8ade268240a8064e9b8efdbebfbaa46ddfa | /Libraries/m2sdk/CryptoPP/Integer.h | 71a1469528758ea0f1703b848aecd7ef5c379526 | [] | no_license | hopk1nz/maf2mp | 6f65bd4f8114fdeb42f9407a4d158ad97f8d1789 | 814cab57dc713d9ff791dfb2a2abeb6af0e2f5a8 | refs/heads/master | 2021-03-12T23:56:24.336057 | 2015-08-22T13:53:10 | 2015-08-22T13:53:10 | 41,209,355 | 19 | 21 | null | 2015-08-31T05:28:13 | 2015-08-22T13:56:04 | C++ | UTF-8 | C++ | false | false | 1,043 | h | // auto-generated file (rttidump-exporter by h0pk1nz)
#pragma once
#include <CryptoPP/InitializeInteger.h>
#include <CryptoPP/ASN1Object.h>
#include <CryptoPP/Exception.h>
namespace CryptoPP
{
/** CryptoPP::Integer (VTable=0x01EB2538) */
class Integer : public InitializeInteger, public ASN1Object
{
public:
/** CryptoPP::Integer::RandomNumberNotFound (VTable=0x01EB41F0) */
class RandomNumberNotFound : public CryptoPP::Exception
{
public:
virtual void vfn_0001_2E4E28A2() = 0;
virtual void vfn_0002_2E4E28A2() = 0;
virtual void vfn_0003_2E4E28A2() = 0;
};
/** CryptoPP::Integer::DivideByZero (VTable=0x01EB2650) */
class DivideByZero : public CryptoPP::Exception
{
public:
virtual void vfn_0001_F110066B() = 0;
virtual void vfn_0002_F110066B() = 0;
virtual void vfn_0003_F110066B() = 0;
};
virtual void vfn_0001_B26AB9D4() = 0;
virtual void vfn_0002_B26AB9D4() = 0;
virtual void vfn_0003_B26AB9D4() = 0;
virtual void vfn_0004_B26AB9D4() = 0;
virtual void vfn_0005_B26AB9D4() = 0;
};
} // namespace CryptoPP
| [
"hopk1nz@gmail.com"
] | hopk1nz@gmail.com |
8934e66a3a9f359ff24998640fc0142b5f14b129 | 9160c709af725dcdde2829b02c7e15adc6ace73c | /include/resample.hpp | d407ad0581fb8ca1d1f2078fb08e8a19d1ef3d16 | [] | no_license | ishine/smartcore | 46a9555d4302ff8da0088d450dc848fe78ca17dc | 45bea89146c6faa20717884b21768c8b7b382413 | refs/heads/master | 2020-04-26T22:53:20.093389 | 2018-12-17T22:16:21 | 2018-12-17T22:16:21 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,833 | hpp | #ifndef SMARTCORE_RESAMPLE_H
#define SMARTCORE_RESAMPLE_H
#include <audio_buffer.hpp>
#include <memory>
#include <vector>
namespace score {
class ReSampler {
public:
/**
* @brief The Quality enum describes the different Re-Sampler operation modes
* in terms of output quality.
*/
enum class Quality {
HighQuality = 0,
MediumQuality = 1,
LowQuality = 4,
};
/**
* @brief Creates a re sampler with the given configuration
* @param channels Number of channels
* @param quality Quality of the re-sampling process.
* @param input_rate Input sampling rate in Hz.
* @param output_rate Output sampling rate in Hz.
*/
ReSampler(std::uint8_t channels, std::uint32_t input_rate, std::uint32_t output_rate, Quality quality);
/**
* @brief Default destructor
*/
~ReSampler();
/**
* @brief Re-initializes the re-sampler, clearing all state
*/
void reset();
/**
* @brief Returns the current ratio.
* @return Current ratio (output sample rate / input sample rate).
*/
float ratio() const;
/**
* @brief Returns the current algorithm quality
* @return Quality of the algorithm.
*/
Quality quality() const;
/**
* @brief Performs a Re-Sampling filter in an audio frame.
*
* @param input Buffer storing the input audio samples.
* @param output Buffer storing the output audio samples.
*/
void process(const AudioBuffer& input, AudioBuffer& output);
private:
struct Pimpl;
std::unique_ptr<Pimpl> pimpl_;
};
}
#endif //SMARTCORE_RESAMPLE_H
| [
"mohabouje@gmail.com"
] | mohabouje@gmail.com |
0c5a47e7a2c116d80bc112f2f22aa17cdb9741b0 | 6ac9408142c6c275f599a86eb78dc37ed72e05a2 | /VipManage_Final/VipManage_Final.cpp | 273e4255ccbd1a6858ac65a37829c70d7f47f5e6 | [] | no_license | thxu/MFC_ManageVip | 81bff993e22b6f838215ae837cc14ff54a7ec92d | 2879113ea9981e75534400a9ff4da154680b99e7 | refs/heads/master | 2020-05-17T23:29:11.649143 | 2014-12-27T08:19:22 | 2014-12-27T08:19:22 | null | 0 | 0 | null | null | null | null | GB18030 | C++ | false | false | 5,192 | cpp | // VipManage_Final.cpp : Defines the class behaviors for the application.
//
#include "stdafx.h"
#include "VipManage_Final.h"
#include "MainFrm.h"
#include "ChildFrm.h"
#include "VipManage_FinalDoc.h"
#include "VipManage_FinalView.h"
#include "SpliterView.h"
#include "SpliterTreeView.h"
#include "SpliterManageView.h"
#include "SpliterDoc.h"
#include "SpliterDetailsView.h"
#include "SpliterChildFrame.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CVipManage_FinalApp
BEGIN_MESSAGE_MAP(CVipManage_FinalApp, CWinApp)
//{{AFX_MSG_MAP(CVipManage_FinalApp)
ON_COMMAND(ID_APP_ABOUT, OnAppAbout)
// NOTE - the ClassWizard will add and remove mapping macros here.
// DO NOT EDIT what you see in these blocks of generated code!
//}}AFX_MSG_MAP
// Standard file based document commands
ON_COMMAND(ID_FILE_NEW, CWinApp::OnFileNew)
ON_COMMAND(ID_FILE_OPEN, CWinApp::OnFileOpen)
// Standard print setup command
ON_COMMAND(ID_FILE_PRINT_SETUP, CWinApp::OnFilePrintSetup)
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CVipManage_FinalApp construction
CVipManage_FinalApp::CVipManage_FinalApp()
{
// TODO: add construction code here,
// Place all significant initialization in InitInstance
}
/////////////////////////////////////////////////////////////////////////////
// The one and only CVipManage_FinalApp object
CVipManage_FinalApp theApp;
/////////////////////////////////////////////////////////////////////////////
// CVipManage_FinalApp initialization
BOOL CVipManage_FinalApp::InitInstance()
{
AfxEnableControlContainer();
// Standard initialization
// If you are not using these features and wish to reduce the size
// of your final executable, you should remove from the following
// the specific initialization routines you do not need.
#ifdef _AFXDLL
Enable3dControls(); // Call this when using MFC in a shared DLL
#else
Enable3dControlsStatic(); // Call this when linking to MFC statically
#endif
// Change the registry key under which our settings are stored.
// TODO: You should modify this string to be something appropriate
// such as the name of your company or organization.
SetRegistryKey(_T("Local AppWizard-Generated Applications"));
LoadStdProfileSettings(); // Load standard INI file options (including MRU)
// Register the application's document templates. Document templates
// serve as the connection between documents, frame windows and views.
CMultiDocTemplate* pDocTemplate;
pDocTemplate = new CMultiDocTemplate(
IDR_VIPMANTYPE,
RUNTIME_CLASS(CVipManage_FinalDoc),
RUNTIME_CLASS(CChildFrame), // custom MDI child frame
RUNTIME_CLASS(CVipManage_FinalView));
AddDocTemplate(pDocTemplate);
pSpliterDocTemplate=new CMultiDocTemplate(
IDR_VIPMANTYPE,
RUNTIME_CLASS(CSpliterDoc),
RUNTIME_CLASS(CSpliterChildFrame), // custom MDI child frame
RUNTIME_CLASS(CSpliterView));
AddDocTemplate(pSpliterDocTemplate);
// create main MDI Frame window
CMainFrame* pMainFrame = new CMainFrame;
if (!pMainFrame->LoadFrame(IDR_MAINFRAME))
return FALSE;
m_pMainWnd = pMainFrame;
// Parse command line for standard shell commands, DDE, file open
CCommandLineInfo cmdInfo;
ParseCommandLine(cmdInfo);
cmdInfo.m_nShellCommand = CCommandLineInfo::FileNothing;/*不显示第一个窗口*/
// Dispatch commands specified on the command line
if (!ProcessShellCommand(cmdInfo))
return FALSE;
// The main window has been initialized, so show and update it.
pMainFrame->ShowWindow(m_nCmdShow);
pMainFrame->UpdateWindow();
CVipManage_FinalApp* myApp=(CVipManage_FinalApp*)AfxGetApp();
CDocument* myDoc= myApp->pSpliterDocTemplate->CreateNewDocument();
CFrameWnd* myFrame= myApp->pSpliterDocTemplate->CreateNewFrame(myDoc,NULL);
if (myFrame == NULL)
return FALSE;
myApp->pSpliterDocTemplate->InitialUpdateFrame(myFrame,NULL,TRUE);
return TRUE;
}
/////////////////////////////////////////////////////////////////////////////
// CAboutDlg dialog used for App About
class CAboutDlg : public CDialog
{
public:
CAboutDlg();
// Dialog Data
//{{AFX_DATA(CAboutDlg)
enum { IDD = IDD_ABOUTBOX };
//}}AFX_DATA
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CAboutDlg)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
//{{AFX_MSG(CAboutDlg)
// No message handlers
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
//{{AFX_DATA_INIT(CAboutDlg)
//}}AFX_DATA_INIT
}
void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CAboutDlg)
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
//{{AFX_MSG_MAP(CAboutDlg)
// No message handlers
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
// App command to run the dialog
void CVipManage_FinalApp::OnAppAbout()
{
CAboutDlg aboutDlg;
aboutDlg.DoModal();
}
/////////////////////////////////////////////////////////////////////////////
// CVipManage_FinalApp message handlers
| [
"729468926@qq.com"
] | 729468926@qq.com |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.