blob_id stringlengths 40 40 | directory_id stringlengths 40 40 | path stringlengths 3 264 | content_id stringlengths 40 40 | detected_licenses listlengths 0 85 | license_type stringclasses 2
values | repo_name stringlengths 5 140 | snapshot_id stringlengths 40 40 | revision_id stringlengths 40 40 | branch_name stringclasses 905
values | visit_date timestamp[us]date 2015-08-09 11:21:18 2023-09-06 10:45:07 | revision_date timestamp[us]date 1997-09-14 05:04:47 2023-09-17 19:19:19 | committer_date timestamp[us]date 1997-09-14 05:04:47 2023-09-06 06:22:19 | github_id int64 3.89k 681M ⌀ | star_events_count int64 0 209k | fork_events_count int64 0 110k | gha_license_id stringclasses 22
values | gha_event_created_at timestamp[us]date 2012-06-07 00:51:45 2023-09-14 21:58:39 ⌀ | gha_created_at timestamp[us]date 2008-03-27 23:40:48 2023-08-21 23:17:38 ⌀ | gha_language stringclasses 141
values | src_encoding stringclasses 34
values | language stringclasses 1
value | is_vendor bool 1
class | is_generated bool 2
classes | length_bytes int64 3 10.4M | extension stringclasses 115
values | content stringlengths 3 10.4M | authors listlengths 1 1 | author_id stringlengths 0 158 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
ccfd1d134a2cd2b703141b190c0e7a2d386ab576 | 67cf5d1d7ea62ca9e7b35c42c042efcf1c77ff36 | /mapimg101/projRowCol.h | 6d223b8b2468c99ca202a23428d65410d06ffeb7 | [] | no_license | bpass/cegis | d3c84d2d29a084105b4c207391ddc6ace0cdf398 | 6c849e41974b8ff844f78e260de26d644c956afb | refs/heads/master | 2020-04-03T18:57:58.102939 | 2013-04-24T22:07:54 | 2013-04-24T22:07:54 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,277 | h | // $Id: projRowCol.h,v 1.3 2005/01/11 17:11:28 jtrent Exp $
//Copyright 2003 United States Geological Survey
//Released under GPL with mapimg copyright 2003 USGS
/////////////////////////////////////////////////////////
// Class for separating and returing rows and columns //
// //
// Created by: J. Trent - 07/2003 //
/////////////////////////////////////////////////////////
#ifndef PROJROWCOL_H
#define PROJROWCOL_H
#include <qstring.h>
class projRowCol
{
public:
static int projectionRow( const QString rowcolInfo )
{ return projectionRowCol( rowcolInfo, 0 ); }
static int projectionCol( const QString rowcolInfo )
{ return projectionRowCol( rowcolInfo, 1 ); }
private:
static int projectionRowCol( const QString rowcolInfo, int element = -1 )
{
int breakPoint = rowcolInfo.find( ' ', 0, false );
if( element == -1 || breakPoint == -1 ) return -1;
else if( element == 0 ) return rowcolInfo.left( breakPoint ).toInt();
else if( element == 1 ) return rowcolInfo.right( rowcolInfo.length() - breakPoint ).toInt();
else return -1;
}
};
#endif
| [
"jtrent"
] | jtrent |
175911ee544f99b4f10e347d457e22e3a40685d6 | 6c996ca5146bd307a062f38819acec16d710656f | /workspace/iw8/code_source/src/iwmem/gamelog/iwmem_dump_hierarchy.cpp | fea3a6974a1765cd2c1a7520ee158c66539d7021 | [] | no_license | Omn1z/OpenIW8 | d46f095d4d743d1d8657f7e396e6d3cf944aa562 | 6c01a9548e4d5f7e1185369a62846f2c6f8304ba | refs/heads/main | 2023-08-15T22:43:01.627895 | 2021-10-10T20:44:57 | 2021-10-10T20:44:57 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 7,237 | cpp | /*
==============
IWMemDumpHierarchyData::TruncateStackName
==============
*/
void __fastcall IWMemDumpHierarchyData::TruncateStackName(IWMemDumpHierarchyData *this, const int len)
{
?TruncateStackName@IWMemDumpHierarchyData@@QEAAXH@Z(this, len);
}
/*
==============
IWMem_Dump_Hierarchy_RecurseProfileTree
==============
*/
unsigned __int64 __fastcall IWMem_Dump_Hierarchy_RecurseProfileTree(IWMemDumpHierarchyData *data, const IWMemAllocator *r_allocator, const IWMemProfileNode *r_node, const int depth)
{
return ?IWMem_Dump_Hierarchy_RecurseProfileTree@@YA_KAEAUIWMemDumpHierarchyData@@AEBVIWMemAllocator@@AEBVIWMemProfileNode@@H@Z(data, r_allocator, r_node, depth);
}
/*
==============
IWMem_Dump_Hierarchy_Recurse
==============
*/
unsigned __int64 __fastcall IWMem_Dump_Hierarchy_Recurse(IWMemDumpHierarchyData *data, const IWMemAllocator *r_allocator)
{
return ?IWMem_Dump_Hierarchy_Recurse@@YA_KAEAUIWMemDumpHierarchyData@@AEBVIWMemAllocator@@@Z(data, r_allocator);
}
/*
==============
IWMem_Dump_Hierarchy_All
==============
*/
void IWMem_Dump_Hierarchy_All(void)
{
?IWMem_Dump_Hierarchy_All@@YAXXZ();
}
/*
==============
IWMemDumpHierarchyData::AddStackName
==============
*/
void __fastcall IWMemDumpHierarchyData::AddStackName(IWMemDumpHierarchyData *this, const char *const str)
{
?AddStackName@IWMemDumpHierarchyData@@QEAAXQEBD@Z(this, str);
}
/*
==============
IWMemDumpHierarchyData::AddStackName
==============
*/
void IWMemDumpHierarchyData::AddStackName(IWMemDumpHierarchyData *this, const char *const str)
{
__int64 v3;
__int64 stackNameLen;
v3 = -1i64;
do
++v3;
while ( str[v3] );
stackNameLen = this->stackNameLen;
if ( 512 - stackNameLen > (unsigned __int64)((int)v3 + 2) )
{
if ( (int)stackNameLen > 0 )
{
this->stackName[stackNameLen] = 44;
LODWORD(stackNameLen) = ++this->stackNameLen;
}
Core_strcpy(&this->stackName[(int)stackNameLen], 512i64 - (int)stackNameLen, str);
this->stackNameLen += v3;
}
}
/*
==============
IWMem_Dump_Hierarchy_All
==============
*/
void IWMem_Dump_Hierarchy_All(void)
{
IWMemDumpHierarchyData data;
data.stackName[0] = 0;
data.stackNameLen = 0;
data.numAllocators = IWMem_AllocatorManager_GetSortedAllocatorList(data.allocators, 0x180u);
if ( data.numAllocators )
IWMem_Dump_Hierarchy_Recurse(&data, data.allocators[0]);
}
/*
==============
IWMem_Dump_Hierarchy_Recurse
==============
*/
unsigned __int64 IWMem_Dump_Hierarchy_Recurse(IWMemDumpHierarchyData *data, const IWMemAllocator *r_allocator)
{
unsigned __int64 v4;
__int64 stackNameLen;
unsigned int i;
const IWMemAllocator **v7;
unsigned __int64 CommitSize;
unsigned __int64 v9;
const IWMemProfileNode *SizeTree;
unsigned __int64 v11;
bool v12;
const char *v13;
v4 = 0i64;
IWMemDumpHierarchyData::AddStackName(data, r_allocator->m_name);
stackNameLen = data->stackNameLen;
for ( i = 0; i < data->numAllocators; ++i )
{
v7 = &data->allocators[i];
if ( IWMemAllocator::GetParentAllocator((IWMemAllocator *)*v7) == r_allocator )
{
v4 += IWMem_Dump_Hierarchy_Recurse(data, *v7);
if ( (unsigned int)stackNameLen > 0x200 && CoreAssert_Handler("c:\\workspace\\iw8\\code_source\\src\\iwmem\\gamelog\\iwmem_dump_hierarchy.cpp", 68, ASSERT_TYPE_ASSERT, "(len <= sizeof( stackName ))", (const char *)&queryFormat, "len <= sizeof( stackName )") )
__debugbreak();
data->stackNameLen = stackNameLen;
data->stackName[stackNameLen] = 0;
}
}
CommitSize = IWMemAllocator::GetCommitSize((IWMemAllocator *)r_allocator);
v9 = CommitSize;
if ( CommitSize )
{
if ( v4 )
{
v12 = v4 <= CommitSize;
if ( v4 >= CommitSize )
goto LABEL_22;
v13 = "%s,commit slop,%zu\n";
if ( r_allocator->m_type != 4 )
v13 = "%s,unknown slop,%zu\n";
IWMem_Printf(v13, data->stackName, CommitSize - v4);
}
else if ( r_allocator->m_type != Count )
{
SizeTree = IWMemDumpSizeTree::CreateSizeTree(&data->sizeTree, r_allocator);
if ( SizeTree && IWMemAllocator::UseTableLogging((IWMemAllocator *)r_allocator) )
{
v11 = IWMem_Dump_Hierarchy_RecurseProfileTree(data, r_allocator, SizeTree, 0);
IWMemDumpHierarchyData::TruncateStackName(data, stackNameLen);
if ( v11 != v9 && CoreAssert_Handler("c:\\workspace\\iw8\\code_source\\src\\iwmem\\gamelog\\iwmem_dump_hierarchy.cpp", 154, ASSERT_TYPE_ASSERT, "(childProfileUsage == totalUsedSize)", (const char *)&queryFormat, "childProfileUsage == totalUsedSize") )
__debugbreak();
}
else
{
IWMem_Printf("%s,%zu\n", data->stackName, v9);
}
}
}
v12 = v4 <= v9;
LABEL_22:
if ( !v12 )
return v4;
return v9;
}
/*
==============
IWMem_Dump_Hierarchy_RecurseProfileTree
==============
*/
__int64 IWMem_Dump_Hierarchy_RecurseProfileTree(IWMemDumpHierarchyData *data, const IWMemAllocator *r_allocator, const IWMemProfileNode *r_node, const int depth)
{
__int64 v4;
const IWMemProfileNode *v8;
__int64 v9;
__int64 stackNameLen;
const IWMemProfileNode *mp_first_child;
__int64 v12;
IWMemDumpSizeTree::SizeEntry result;
char dest[256];
v4 = 0i64;
v8 = r_node;
if ( depth > 0 )
{
IWMemProfileNode::GetSanitizedName((IWMemProfileNode *)r_node, dest, 256);
v9 = -1i64;
do
++v9;
while ( dest[v9] );
stackNameLen = data->stackNameLen;
if ( 512 - stackNameLen > (unsigned __int64)((int)v9 + 2) )
{
if ( (int)stackNameLen > 0 )
{
data->stackName[stackNameLen] = 44;
LODWORD(stackNameLen) = ++data->stackNameLen;
}
Core_strcpy(&data->stackName[(int)stackNameLen], 512i64 - (int)stackNameLen, dest);
data->stackNameLen += v9;
}
}
mp_first_child = (const IWMemProfileNode *)v8->mp_first_child;
v12 = data->stackNameLen;
if ( mp_first_child )
{
do
{
v4 += IWMem_Dump_Hierarchy_RecurseProfileTree(data, r_allocator, mp_first_child, depth + 1);
if ( (unsigned int)v12 > 0x200 && CoreAssert_Handler("c:\\workspace\\iw8\\code_source\\src\\iwmem\\gamelog\\iwmem_dump_hierarchy.cpp", 68, ASSERT_TYPE_ASSERT, "(len <= sizeof( stackName ))", (const char *)&queryFormat, "len <= sizeof( stackName )") )
__debugbreak();
data->stackNameLen = v12;
data->stackName[v12] = 0;
mp_first_child = (const IWMemProfileNode *)mp_first_child->mp_next_sibling;
}
while ( mp_first_child );
v8 = r_node;
}
IWMemDumpSizeTree::GetSizeEntry(&data->sizeTree, &result, v8);
if ( result.size )
{
v4 += result.size;
IWMem_Printf("%s,%zu\n", data->stackName, result.size);
}
return v4;
}
/*
==============
IWMemDumpHierarchyData::TruncateStackName
==============
*/
void IWMemDumpHierarchyData::TruncateStackName(IWMemDumpHierarchyData *this, const int len)
{
__int64 v2;
v2 = len;
if ( (unsigned int)len > 0x200 && CoreAssert_Handler("c:\\workspace\\iw8\\code_source\\src\\iwmem\\gamelog\\iwmem_dump_hierarchy.cpp", 68, ASSERT_TYPE_ASSERT, "(len <= sizeof( stackName ))", (const char *)&queryFormat, "len <= sizeof( stackName )") )
__debugbreak();
this->stackNameLen = v2;
this->stackName[v2] = 0;
}
| [
"zkitx@zkitx.jp"
] | zkitx@zkitx.jp |
179b48487d20bfde87546251603d7f8ac2a4e36b | 8f608437957f7c9eb03f0ee00457e10282059ec8 | /UVa/102.cpp | 2db33d70dd0732e6b5b550da5211ce296e91c905 | [] | no_license | npkhang99/Competitive-Programming | 0ddf3cfcfc13825f7fadaf5b53fdef16ca77522f | 1a5e3799e5855996aa56688680765511b0de7281 | refs/heads/master | 2023-06-28T15:17:44.489901 | 2021-07-30T05:31:15 | 2021-07-30T05:31:15 | 66,803,586 | 4 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 683 | cpp | #include <stdio.h>
#include <string>
using namespace std;
int b1, b2, b3, g1, g2, g3, c1, c2, c3;
int main(){
while(scanf("%d%d%d%d%d%d%d%d%d\n",&b1,&g1,&c1,&b2,&g2,&c2,&b3,&g3,&c3)!=EOF){
int ans = b2+b3+c1+c3+g1+g2;
string st = "BCG";
if (ans>b2+b3+g1+g3+c1+c2) ans = b2+b3+g1+g3+c1+c2, st = "BGC";
if (ans>c2+c3+b1+b3+g1+g2) ans = c2+c3+b1+b3+g1+g2, st = "CBG";
if (ans>c2+c3+g1+g3+b1+b2) ans = c2+c3+g1+g3+b1+b2, st = "CGB";
if (ans>g2+g3+b1+b3+c1+c2) ans = g2+g3+b1+b3+c1+c2, st = "GBC";
if (ans>g2+g3+c1+c3+b1+b2) ans = g2+g3+c1+c3+b1+b2, st = "GCB";
printf("%s %d\n",st.c_str(),ans);
}
return 0;
}
| [
"curoa99@gmail.com"
] | curoa99@gmail.com |
6a009d34e570d770f3a965963c6eedb1c2e2b404 | 5521a03064928d63cc199e8034e4ea76264f76da | /fboss/cli/fboss2/commands/show/fabric/CmdShowFabric.h | 599fe790fe1fb7e17f297a68312e586a0db64f19 | [
"BSD-3-Clause",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | facebook/fboss | df190fd304e0bf5bfe4b00af29f36b55fa00efad | 81e02db57903b4369200eec7ef22d882da93c311 | refs/heads/main | 2023-09-01T18:21:22.565059 | 2023-09-01T15:53:39 | 2023-09-01T15:53:39 | 31,927,407 | 925 | 353 | NOASSERTION | 2023-09-14T05:44:49 | 2015-03-09T23:04:15 | C++ | UTF-8 | C++ | false | false | 5,619 | h | /*
* Copyright (c) 2004-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
*/
#pragma once
#include <re2/re2.h>
#include <string>
#include <unordered_set>
#include "fboss/agent/if/gen-cpp2/ctrl_types.h"
#include "fboss/cli/fboss2/CmdHandler.h"
#include "fboss/cli/fboss2/commands/show/fabric/gen-cpp2/model_types.h"
#include "fboss/cli/fboss2/utils/CmdUtils.h"
#include "fboss/cli/fboss2/utils/Table.h"
#include "folly/container/Access.h"
namespace facebook::fboss {
using utils::Table;
struct CmdShowFabricTraits : public BaseCommandTraits {
static constexpr utils::ObjectArgTypeId ObjectArgTypeId =
utils::ObjectArgTypeId::OBJECT_ARG_TYPE_ID_NONE;
using ObjectArgType = std::monostate;
using RetType = cli::ShowFabricModel;
static constexpr bool ALLOW_FILTERING = true;
static constexpr bool ALLOW_AGGREGATION = true;
};
class CmdShowFabric : public CmdHandler<CmdShowFabric, CmdShowFabricTraits> {
public:
using RetType = CmdShowFabricTraits::RetType;
RetType queryClient(const HostInfo& hostInfo) {
std::map<std::string, FabricEndpoint> entries;
auto client =
utils::createClient<apache::thrift::Client<FbossCtrl>>(hostInfo);
client->sync_getFabricReachability(entries);
return createModel(entries);
}
inline void udpateNametoIdString(std::string& name, int64_t value) {
auto idToString =
value == -1 ? "(-)" : folly::to<std::string>("(", value, ")");
name += idToString;
}
void printOutput(const RetType& model, std::ostream& out = std::cout) {
Table table;
table.setHeader({
"Local Port",
"Peer Switch (Id)",
"Exp Peer Switch (Id)",
"Peer Port (Id)",
"Exp Peer Port (Id)",
});
for (auto const& entry : model.get_fabricEntries()) {
std::string remoteSwitchNameId =
utils::removeFbDomains(*entry.remoteSwitchName());
udpateNametoIdString(remoteSwitchNameId, *entry.remoteSwitchId());
std::string expectedRemoteSwitchNameId =
utils::removeFbDomains(*entry.expectedRemoteSwitchName());
udpateNametoIdString(
expectedRemoteSwitchNameId, *entry.expectedRemoteSwitchId());
std::string remotePortNameId = *entry.remotePortName();
udpateNametoIdString(remotePortNameId, *entry.remotePortId());
std::string expectedRemotePortNameId = *entry.expectedRemotePortName();
udpateNametoIdString(
expectedRemotePortNameId, *entry.expectedRemotePortId());
table.addRow({
*entry.localPort(),
Table::StyledCell(
remoteSwitchNameId,
get_NeighborStyle(
remoteSwitchNameId, expectedRemoteSwitchNameId)),
expectedRemoteSwitchNameId,
Table::StyledCell(
remotePortNameId,
get_NeighborStyle(remotePortNameId, expectedRemotePortNameId)),
expectedRemotePortNameId,
});
}
out << table << std::endl;
}
Table::Style get_NeighborStyle(
const std::string& actualId,
const std::string& expectedId) {
if (actualId == expectedId) {
return Table::Style::GOOD;
}
return Table::Style::ERROR;
}
RetType createModel(std::map<std::string, FabricEndpoint> fabricEntries) {
RetType model;
const std::string kUnavail;
const std::string kUnattached = "NOT_ATTACHED";
for (const auto& entry : fabricEntries) {
cli::FabricEntry fabricDetails;
fabricDetails.localPort() = entry.first;
auto endpoint = entry.second;
// if endpoint is not attached and no expected neighbor configured, skip
// the endpoint
if (!*endpoint.isAttached() &&
(!endpoint.expectedSwitchName().has_value())) {
continue;
}
// hw endpoint
if (!*endpoint.isAttached()) {
fabricDetails.remotePortName() = kUnattached;
fabricDetails.remoteSwitchName() = kUnattached;
} else {
fabricDetails.remotePortName() =
endpoint.portName() ? *endpoint.portName() : kUnavail;
fabricDetails.remoteSwitchName() =
endpoint.switchName() ? *endpoint.switchName() : kUnavail;
}
fabricDetails.remoteSwitchId() = *endpoint.switchId();
fabricDetails.remotePortId() = *endpoint.portId();
// expected endpoint per cfg
fabricDetails.expectedRemoteSwitchId() =
endpoint.expectedSwitchId().has_value() ? *endpoint.expectedSwitchId()
: -1;
fabricDetails.expectedRemotePortId() =
endpoint.expectedPortId().has_value() ? *endpoint.expectedPortId()
: -1;
fabricDetails.expectedRemotePortName() =
endpoint.expectedPortName().has_value() ? *endpoint.expectedPortName()
: kUnavail;
fabricDetails.expectedRemoteSwitchName() =
endpoint.expectedSwitchName().has_value()
? *endpoint.expectedSwitchName()
: kUnavail;
model.fabricEntries()->push_back(fabricDetails);
}
std::sort(
model.fabricEntries()->begin(),
model.fabricEntries()->end(),
[](cli::FabricEntry& a, cli::FabricEntry b) {
return utils::comparePortName(a.get_localPort(), b.get_localPort());
});
return model;
}
};
} // namespace facebook::fboss
| [
"facebook-github-bot@users.noreply.github.com"
] | facebook-github-bot@users.noreply.github.com |
35e93f1478315a3926900a30f2bc04d224c4d0a5 | e5e19ad22cd0312a00268de18fc1d529d2a41aad | /CSGOFullv2/TE_EffectDispatch.cpp | 522ab49505c93de2a65308ffb62a52b427be3621 | [] | no_license | xTR0JAN/Mutiny-CSGO | 3056bdf8b56ca55d516883ce30ca63d5176d31b0 | f096d80055fea5475832b135c477456c69f30ae2 | refs/heads/main | 2023-07-31T20:47:13.994512 | 2021-09-30T02:27:45 | 2021-09-30T02:27:45 | 411,896,773 | 2 | 2 | null | null | null | null | UTF-8 | C++ | false | false | 687 | cpp | #include "TE_EffectDispatch.h"
#include "VTHook.h"
#include "SpawnBlood.h"
#include "VMProtectDefs.h"
TE_EffectDispatch_PostDataUpdateFn oTE_EffectDispatch_PostDataUpdate;
void __fastcall Hooks::TE_EffectDispatch_PostDataUpdate(C_TEEffectDispatch* thisptr, void* edx, DataUpdateType_t updateType)
{
VMP_BEGINMUTILATION("EFDPDU")
if (!DisableAllChk.Checked)
{
//decimal
//4 = csblood
//34 = Impact
switch (thisptr->m_EffectData.m_iEffectName)
{
case 4:
OnSpawnBlood(thisptr, updateType);
return;
default:
oTE_EffectDispatch_PostDataUpdate(thisptr, updateType);
return;
}
}
else
{
oTE_EffectDispatch_PostDataUpdate(thisptr, updateType);
}
VMP_END
} | [
"91642397+xTR0JAN@users.noreply.github.com"
] | 91642397+xTR0JAN@users.noreply.github.com |
35c421d1c7a6fafae2fcf39bcc665f6d31614236 | adec2460d6c440ceca87c319645bea27aff23c67 | /Calculator/main.cpp | 255b992200843a20a26aa6477bf2d7f96f5274b6 | [] | no_license | Trompowsky/Calculator | 88bea261f24561d0e23630483e1bf110ac57fdee | af1830ef8fa60531ad6ec1ecd8643502ecbd859c | refs/heads/master | 2020-12-24T18:41:31.170378 | 2016-04-22T00:33:21 | 2016-04-22T00:33:21 | 56,814,010 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,097 | cpp | #include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <stdexcept>
#include "Expression.h"
#include "PrintVect.h"
#include "Exp.h"
#include "Constant.h"
#include "Addition.h"
#include "Subtraction.h"
#include "Multiplication.h"
#include "Division.h"
using namespace std;
int main()
{
string User;
string prntnum;
string prntop;
std::vector<string> strVector;
cout << "Enter your expression: ";
cin >> User;
Expression a(User);
while (!a.Emp()){
prntnum = a.printnum();
strVector.push_back(prntnum);
if (!a.Emp()){
prntop = a.printop();
strVector.push_back(prntop);
}
}
PrintVect b(strVector);
//cout << b.Bracketing() << endl;
for (vector<string>::iterator it = strVector.begin(); it != strVector.end(); ++it) {
//cout << (*it) << endl;
}
double value;
double val;
istringstream iss(strVector[0]);
iss >> value;
istringstream is(strVector[2]);
is >> val;
vector <string>::iterator it2 = strVector.begin();
string num = *it2++;
Exp * LHS = new Exp(new Constant(num));
//cout << LHS->Print() << endl;
int i = 0;
while(2*i+1<strVector.size()){
string op = *it2++;
string num1 = *it2++;
Exp * Number = new Exp(new Constant(num1));
if (op == "+"){
Exp * temp = new Exp(new Addition(), LHS, Number);
//cout << "Calc> " << LHS->Print() << "=" << LHS->Eval() << endl;
LHS = temp;
}
if (op == "-"){
Exp * temp = new Exp(new Subtraction(), LHS, Number);
//cout << "Calc> " << LHS->Print() << "=" << LHS->Eval() << endl;
LHS = temp;
}
if (op == "/"){
Exp * temp = new Exp(new Division(), LHS, Number);
//cout << "Calc> " << LHS->Print() << "=" << LHS->Eval() << endl;
LHS = temp;
}
if (op == "*"){
Exp * temp = new Exp(new Multiplication(), LHS, Number);
//cout << "Calc> " << LHS->Print() << "=" << LHS->Eval() << endl;
LHS = temp;
}
/*
if (op!= "*", "-", "+", "/"){
throw domain_error("Unexpected input - expected an operator");
}*/
//cout << i << "\t" << 2*i+1 << "\t" << strVector.size() << endl;
// Exp * temp = new Exp(op, LHS, Number);
//LHS = temp;
i++;
if (2*i+1==strVector.size()){
if (op == "+"){
Exp * temp = new Exp(new Addition(), LHS, Number);
cout << "Calc> " << LHS->Print() << "=" << LHS->Eval() << endl;
LHS = temp;
}
if (op == "-"){
Exp * temp = new Exp(new Subtraction(), LHS, Number);
cout << "Calc> " << LHS->Print() << "=" << LHS->Eval() << endl;
LHS = temp;
}
if (op == "/"){
Exp * temp = new Exp(new Division(), LHS, Number);
cout << "Calc> " << LHS->Print() << "=" << LHS->Eval() << endl;
LHS = temp;
}
if (op == "*"){
Exp * temp = new Exp(new Multiplication(), LHS, Number);
cout << "Calc> " << LHS->Print() << "=" << LHS->Eval() << endl;
LHS = temp;
}
}
}
}
/*
while(not the end of the vector){
op = *it++;
if it's safe:
num *it++;
exp * temp = new Exp(op, LHS, Num)
LHS = Temp
}
Exp * e = new Exp (new Constant ("1"));
cout << "test e=" << e->Print() << "=" << e->Eval() << endl;
Exp * f = new Exp (new Division(), new Exp (new Constant ("1")), new Exp(new Constant ("5")));
cout << "test f=" << f->Print() << "=" << f->Eval() << endl;
Exp q(new Subtraction(), e, f);
cout << "test q=" << q.Print() << "=" << q.Eval() << endl;
}
/*
for(unsigned int i=0;i<strVector.size()-1;i+=2){
istringstream is(strVector[i+2]);
is >> val;
if (strVector[i+1] == "+"){
value = value+val;
}
}
cout << value << endl;
*/
// now value has the double value or 0.0
| [
"ali.gh.abdulla@gmail.com"
] | ali.gh.abdulla@gmail.com |
1fdcc87d28c14d3dc9f2e1d63a1c81fd8380c413 | f960679826f74e3a932b57aad3e7a10d856957cf | /cpp/lib_exercise/lib/src/logger.h | a3f703b8598d1f370b1e2309ef25e44c213e417e | [] | no_license | nkaje/code | 6f1f5ee5191a55a28a0ec809920cdf6d701831a5 | b693f1f2e6794043c22eb35104dd1c5ee6358562 | refs/heads/master | 2022-11-09T09:33:51.789985 | 2022-10-26T15:36:24 | 2022-10-26T15:36:24 | 128,422,471 | 0 | 0 | null | 2022-10-26T15:36:25 | 2018-04-06T17:02:33 | C | UTF-8 | C++ | false | false | 519 | h | #ifdef __cplusplus
extern "C" {
#endif // __cplusplus
#include <iostream>
#include <stdarg.h>
#define UINT_TEST 0
enum LogLevel {
LOG_DEBUG = 0,
LOG_INFO,
LOG_WARN,
LOG_ERR,
LOG_MAX,
};
class Logger {
private:
enum LogLevel m_level;
public:
Logger(enum LogLevel level) { m_level = level; };
Logger() { m_level = LOG_DEBUG; };
~Logger() { m_level = LOG_MAX; };
int Log(enum LogLevel level, const char *format, ...);
};
#ifdef __cplusplus
}
#endif
| [
"Naveen.Kaje@amd.com"
] | Naveen.Kaje@amd.com |
7d6ac6ba0797e1a2b66d431c833b0e2294a351a8 | 1e524dd151bb5f8546280ec0e0aeaeae3d471570 | /warmgui/DataDispatcher.h | 61089509c0fd2460d4c2e0b010fcff3dea608832 | [] | no_license | cnsuhao/warmgui | 68e8a698b9068b67cbb6efe4b0651144ba7ffc17 | 5d198d1680ffe61a3f48175c84942823033ccfcb | refs/heads/master | 2021-05-27T00:06:25.959310 | 2013-07-11T14:25:01 | 2013-07-11T14:25:01 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,656 | h | #ifndef __interface_data_dispatcher_h__
#define __interface_data_dispatcher_h__
#define MSG_EXIT_DISPATCHER 0x0FFFFFF
namespace WARMGUI {
class WARMGUI_API IDataDispatcher : public Poco::Runnable
{
public:
IDataDispatcher(const char* name);
virtual ~IDataDispatcher(void);
Poco::Thread::TID GetThreadId() {
for(;;) {
if (!_tid)
Poco::Thread::sleep(100);
else
return _tid;
}
}
inline void reg_data_container(IDataContainer* dc)
{
# ifdef _DEBUG
TCHAR name1[MAX_PATH], name2[MAX_PATH];
CChineseCodeLib::Gb2312ToUnicode(name1, MAX_PATH, dc->getName());
CChineseCodeLib::Gb2312ToUnicode(name2, MAX_PATH, _name);
MYTRACE(L"contanier %s regestered to dispatcher %s\n", name1, name2);
# endif
_dcs.push_back(dc);
}
inline void reg_calculator(ICalculator* cal) {_cals.push_back(cal);}
//inline void remove_dc(IDataContainer* dc);
//inline void clear_dc();
//inline bool SetDataContainer(CWarmguiConfig* config);
//inline bool RegisterCanvasToContainer(IDataCanvas* canvas, int container_no);
virtual void SetConfig(CWarmguiConfig* config, const char* cnf_pos)
{_config = config; strcpy_s(_cnf_pos, MAX_PATH, cnf_pos);}
virtual void start() {
if (_stop)
_thread.start(*(this));
}
virtual void run() {
if (!init()) return;
_tid = Poco::Thread::currentTid();
_stop = 0;
go();
}
virtual void go() = 0;
virtual void stop() = 0;
virtual bool init() {return true;}
bool isme(const char* nemas)
{ return (0 != strstr(nemas, _name)); }
HwndArray& get_hwnd_array() {return _hwnd_array;}
void register_hwnd(HWND hwnd) { _hwnd_array.push_back(hwnd); }
void remove_hwnd(HWND hwnd) {
for (HwndConstIter iter = _hwnd_array.begin(); iter != _hwnd_array.end(); iter++) {
if ((*iter) == hwnd) {
_hwnd_array.erase(iter);
break;
}
}
}
protected:
DWORD _tid;
DCArray _dcs;
CalculatorArray _cals;
CWarmguiConfig* _config;
char _cnf_pos[MAX_PATH];
Poco::Thread _thread;
int _stop;
HwndArray _hwnd_array;
public:
char _name[MAX_PATH];
};
EXPORT_STL_VECTOR(WARMGUI_API, IDataDispatcher*)
typedef std::vector<IDataDispatcher*> DispatcherArray;
typedef DispatcherArray::iterator DispatcherIter;
typedef DispatcherArray::const_iterator DispatcherConstIter;
class WARMGUI_API CDispatchers: public DispatcherArray
{
public:
CDispatchers() {}
~CDispatchers() { ReleaseAll(); }
IDataDispatcher* getDispatcher(const char* name){
for (DispatcherConstIter iter = begin(); iter != end(); iter++) {
if (!strcmp((*iter)->_name, name))
return (*iter);
}
return (0);
}
void ReleaseAll()
{
for (DispatcherConstIter iter = begin(); iter != end(); iter++)
delete (*iter);
clear();
}
};
class WARMGUI_API IDataDispatcherCreator
{
public:
IDataDispatcherCreator() : _config(0) {}
~IDataDispatcherCreator(){}
void SetConfigure(CWarmguiConfig* config) { _config = config; }
virtual IDataDispatcher* CreateDispathcer(const char* conf_pos) = 0;
protected:
CWarmguiConfig* _config;
};
} //namespace WARMGUI
#endif //__interface_data_dispatcher_h__
| [
"stoneguo@126.com"
] | stoneguo@126.com |
ff8fa471fdcb5a072a2d3254d4afeeeca54bc0be | 50a39705630ca72a2bdb5af1c57f23f68fa06e76 | /2D/src/Pyromania/2011_11_6/Game.H | 81fb80ab53384da8cfc6d9601cc694e1559fd87b | [
"MIT"
] | permissive | Squareys/pyromania | ea5459f169329aff124ea155c56511a3e558e5db | 88cbc4f3474e8407c3be09df497dd4be47a587ba | refs/heads/master | 2020-03-20T23:21:46.477463 | 2018-06-28T10:06:09 | 2018-06-28T10:06:09 | 137,842,919 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 332 | h | #ifndef GAME_H
#define GAME_H
#include <allegro.h>
#include "Util.h"
#include "FrameCounter.h"
#include "World.h"
class Game {
public:
void play();
World* world;
Player* player;
#ifndef SERVER
int fps; //Frames per second;
void Draw();
void update();
void load_images();
#endif
Game();
};
#endif
| [
"squareys@googlemail.com"
] | squareys@googlemail.com |
543e88805a779137518f56710c9b542d5d7c0df2 | a310626b8b6ec3ef013efdda0e60eec26940b752 | /WeChat/WeChat/ChatData.h | e207a8e7f78782d6aabb045deabed64f5b77f40e | [] | no_license | lvan100/wechat | 1849395257da16a8adc86e0181820df8e890ffef | 6f96ebfcde8f4207180a338bee5e907a49d46d27 | refs/heads/master | 2021-01-22T09:41:31.056174 | 2016-12-11T14:24:59 | 2016-12-11T14:24:59 | 76,079,144 | 0 | 1 | null | null | null | null | GB18030 | C++ | false | false | 9,088 | h | #pragma once
#include <assert.h>
/**
* 聊天气泡
*/
class ChatBubble {
public:
const int horizon_left = 14;
const int horizon_center = 16;
const int horizon_right = 7;
const int vertical_top = 28;
const int vertical_center = 7;
const int vertical_bottom = 7;
// 九宫格切图原理示意图:
//
// horizon_left | horizon_center | horizon_right
// |—————————|——————————|——————————|
// | | | |
// vertical_top | 1 | 2 | 3 |
// | | | |
// ———————————|——————————|————————————
// | | | |
// vertical_center | 4 | 5 | 6 |
// | | | |
// ———————————|——————————|————————————
// | | | |
// vertical_bottom | 7 | 8 | 9 |
// | | | |
// |—————————|——————————|——————————|
// | |
public:
void LoadImage(CString imgPath) {
if (m_bubble.IsNull()) {
m_bubble.Load(imgPath);
}
}
void Draw(CDC* pDC, CRect rect) {
if (m_brush_left.GetSafeHandle() == NULL) { // 制作 4 的画刷
CImage img;
img.Create(horizon_left, vertical_center, 32);
m_bubble.BitBlt(img.GetDC(), 0, 0, img.GetWidth(), img.GetHeight(), 0, vertical_top, SRCCOPY);
img.ReleaseDC();
m_brush_left.CreatePatternBrush(CBitmap::FromHandle(img.Detach()));
}
if (m_brush_top.GetSafeHandle() == NULL) { // 制作 2 的画刷
CImage img;
img.Create(horizon_center, vertical_top, 32);
m_bubble.BitBlt(img.GetDC(), 0, 0, img.GetWidth(), img.GetHeight(), horizon_left, 0, SRCCOPY);
img.ReleaseDC();
m_brush_top.CreatePatternBrush(CBitmap::FromHandle(img.Detach()));
}
if (m_brush_right.GetSafeHandle() == NULL) { // 制作 6 的画刷
CImage img;
img.Create(horizon_right, vertical_center, 32);
m_bubble.BitBlt(img.GetDC(), 0, 0, img.GetWidth(), img.GetHeight(), horizon_left + horizon_center, vertical_top, SRCCOPY);
img.ReleaseDC();
m_brush_right.CreatePatternBrush(CBitmap::FromHandle(img.Detach()));
}
if (m_brush_bottom.GetSafeHandle() == NULL) { // 制作 8 的画刷
CImage img;
img.Create(horizon_center, vertical_bottom, 32);
m_bubble.BitBlt(img.GetDC(), 0, 0, img.GetWidth(), img.GetHeight(), horizon_left, vertical_top + vertical_center, SRCCOPY);
img.ReleaseDC();
m_brush_bottom.CreatePatternBrush(CBitmap::FromHandle(img.Detach()));
}
if (m_brush_center.GetSafeHandle() == NULL) { // 制作 5 的画刷
CImage img;
img.Create(horizon_center, vertical_center, 32);
m_bubble.BitBlt(img.GetDC(), 0, 0, img.GetWidth(), img.GetHeight(), horizon_left, vertical_top, SRCCOPY);
img.ReleaseDC();
m_brush_center.CreatePatternBrush(CBitmap::FromHandle(img.Detach()));
}
// 绘制 1 区图像
m_bubble.BitBlt(pDC->GetSafeHdc(), rect.left, rect.top, horizon_left, vertical_top, 0, 0, SRCCOPY);
// 绘制 7 区图像
m_bubble.BitBlt(pDC->GetSafeHdc(), rect.left, rect.bottom - vertical_bottom, horizon_left, vertical_bottom, 0, vertical_top + vertical_center, SRCCOPY);
// 绘制 3 区图像
m_bubble.BitBlt(pDC->GetSafeHdc(), rect.right - horizon_right, rect.top, horizon_right, vertical_top, horizon_left + horizon_center, 0, SRCCOPY);
// 绘制 9 区图像
m_bubble.BitBlt(pDC->GetSafeHdc(), rect.right - horizon_right, rect.bottom - vertical_bottom, horizon_right, vertical_bottom, horizon_left + horizon_center, vertical_top + vertical_center, SRCCOPY);
CPoint oldPoint = pDC->GetBrushOrg();
// 绘制 4 区图像
pDC->SetBrushOrg(rect.left, rect.top + vertical_top);
pDC->FillRect(CRect(rect.left, rect.top + vertical_top, rect.left + horizon_left, rect.bottom - vertical_bottom), &m_brush_left);
// 绘制 6 区图像
pDC->SetBrushOrg(rect.right - horizon_right, rect.top + vertical_top);
pDC->FillRect(CRect(rect.right - horizon_right, rect.top + vertical_top, rect.right, rect.bottom - vertical_bottom), &m_brush_right);
// 绘制 2 区图像
pDC->SetBrushOrg(rect.left + horizon_left, rect.top);
pDC->FillRect(CRect(rect.left + horizon_left, rect.top, rect.right - horizon_right, rect.top + vertical_top), &m_brush_top);
// 绘制 8 区图像
pDC->SetBrushOrg(rect.left + horizon_left, rect.bottom - vertical_bottom);
pDC->FillRect(CRect(rect.left + horizon_left, rect.bottom - vertical_bottom, rect.right - horizon_right, rect.bottom), &m_brush_bottom);
// 绘制 5 区图像
pDC->SetBrushOrg(rect.left + horizon_left, rect.top + vertical_top);
pDC->FillRect(CRect(rect.left + horizon_left, rect.top + vertical_top, rect.right - horizon_right, rect.bottom - vertical_bottom), &m_brush_center);
pDC->SetBrushOrg(oldPoint);
}
protected:
CImage m_bubble;
CBrush m_brush_left;
CBrush m_brush_right;
CBrush m_brush_top;
CBrush m_brush_bottom;
CBrush m_brush_center;
};
extern ChatBubble theChatBubble;
extern ChatBubble theChatHoverBubble;
#define MAX_CHAT_WIDTH 500
#define HEAD_WIDTH 100
#define MARGIN_LEFT 12
#define MARGIN_RIGHT 6
#define MARGIN_TOP 12
#define MARGIN_BOTTOM 12
extern int newId();
class ChatData {
public:
ChatData() : haveSize(false), m_pressed(false) {
m_id.Format(L"%d", newId());
}
virtual ~ChatData() {}
public:
/**
* 绘制聊天内容
*/
int Draw(CDC* pDC, int offsetY, CPoint ptHover) {
assert(haveSize);
CRect rect;
rect.left = 0;
rect.right = HEAD_WIDTH;
rect.top = offsetY + MARGIN_TOP / 2;
rect.bottom = offsetY + m_size.cy - MARGIN_BOTTOM / 2;
pDC->DrawText(m_id, rect, DT_LEFT | DT_TOP);
rect.left = HEAD_WIDTH;
rect.right = m_size.cx + HEAD_WIDTH + MARGIN_LEFT + MARGIN_RIGHT;
if (m_pressed || rect.PtInRect(ptHover)) {
theChatHoverBubble.Draw(pDC, rect);
} else {
theChatBubble.Draw(pDC, rect);
}
rect.left = HEAD_WIDTH + MARGIN_LEFT;
rect.right = m_size.cx + HEAD_WIDTH + MARGIN_LEFT;
rect.top = offsetY + MARGIN_TOP;
rect.bottom = offsetY + m_size.cy - MARGIN_BOTTOM;
DrawChatData(pDC, rect);
return m_size.cy;
}
/**
* 计算显示区域的大小
*/
int CalcSize(CDC* pDC) {
if (haveSize) {
return m_size.cy;
}
haveSize = true;
m_size = CalcChatDataSize(pDC);
m_size.cy += MARGIN_TOP + MARGIN_BOTTOM;
return m_size.cy;
}
/**
* 获取显示区域的高度
*/
int GetHeight() {
assert(haveSize);
return m_size.cy;
}
/**
* 设置鼠标按下状态
*/
void SetPressed(bool pressed) {
m_pressed = pressed;
}
/**
* 测试鼠标是否击中
*/
bool HitTest(int offsetY, CPoint point) {
CRect rect;
rect.top = offsetY + MARGIN_TOP / 2;
rect.bottom = offsetY + m_size.cy - MARGIN_BOTTOM / 2;
rect.left = HEAD_WIDTH;
rect.right = m_size.cx + HEAD_WIDTH + MARGIN_LEFT + MARGIN_RIGHT;
return rect.PtInRect(point) ? true : false;
}
protected:
/**
* 绘制聊天数据
*/
virtual void DrawChatData(CDC* pDC, CRect rect) = 0;
/**
* 计算聊天数据的显示区域
*/
virtual CSize CalcChatDataSize(CDC* pDC) = 0;
protected:
/**
* 鼠标按下状态
*/
bool m_pressed;
/**
* 是否计算过显示区域
*/
bool haveSize;
/**
* 显示区域的大小
*/
CSize m_size;
/**
* 消息的ID
*/
CString m_id;
};
/**
* 文字聊天消息
*/
class TextChatData : public ChatData
{
public:
TextChatData(CString str) : text(str) {
}
protected:
virtual void DrawChatData(CDC* pDC, CRect rect) override {
pDC->SetBkMode(TRANSPARENT);
pDC->DrawText(text, rect, DT_LEFT | DT_TOP | DT_WORDBREAK);
}
virtual CSize CalcChatDataSize(CDC* pDC) override {
CRect rect(0, 0, MAX_CHAT_WIDTH, MAXINT);
pDC->DrawText(text, rect, DT_LEFT | DT_TOP | DT_CALCRECT | DT_WORDBREAK);
return rect.Size();
}
protected:
CString text;
};
/**
* 图片聊天消息
*/
class ImageChatData : public ChatData
{
public:
ImageChatData(CImage& img) : image(img) {
}
virtual void DrawChatData(CDC* pDC, CRect rect) override {
rect.right = m_img_size.cx + HEAD_WIDTH + MARGIN_LEFT;
image.Draw(pDC->GetSafeHdc(), rect);
}
virtual CSize CalcChatDataSize(CDC* pDC) override {
m_img_size.cx = min(image.GetWidth(), MAX_CHAT_WIDTH);
m_img_size.cy = m_img_size.cx * image.GetHeight() / image.GetWidth();
return m_img_size;
}
protected:
CImage image;
/**
* 图像的显示大小
*/
CSize m_img_size;
}; | [
"lvan100@yeah.net"
] | lvan100@yeah.net |
b9975992bf0c9a670655989bfdc64c07eb6d0e94 | 38023cd4647618cd7a02f52a558ba349dd869977 | /common/food.h | d696475314976022b21fc5460e9142e0759571b8 | [] | no_license | DrewMartin/GP-Ants | 92e93e3a62f4379d8f5a99c4b31c10e03243237a | 1d754c1320355c3ce8bd7362a1d82620657f736c | refs/heads/master | 2021-01-02T22:58:34.871324 | 2013-04-03T23:25:21 | 2013-04-03T23:25:21 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 506 | h | #ifndef FOOD_H
#define FOOD_H
#include "entity.h"
#include <QGraphicsEllipseItem>
class Food : public Entity
{
public:
Food(QPoint &location, int quantity);
virtual ~Food();
int getFoodLeft();
bool takeFood();
bool hasFood();
virtual QGraphicsItem *getGraphicsItem();
virtual void reset();
private:
void redraw();
const int initialQuantity;
int quantity;
QColor color;
QGraphicsEllipseItem *ellipse;
};
#endif // FOOD_H
| [
"dmartin@benbria.ca"
] | dmartin@benbria.ca |
e3e149946939fbb64aaf1fc0a03465fbd33d2723 | a87497f645bf61a573e60b0b4341fea1d4a8372a | /src/Collection.cpp | 6a096a8ae5d7b8b6fb3b45e4dd6d81ac66fe961f | [] | no_license | pareddy113/Collections | cca49c53e9e1c032f6e6501344b5ec351a378b00 | 346bc969fff46f03be801c29ac100154f1119492 | refs/heads/master | 2021-01-20T06:22:29.957521 | 2017-05-15T20:17:15 | 2017-05-15T20:17:15 | 89,868,654 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,483 | cpp | /*
* Collection.cpp
*
* Created on: Apr 23, 2017
* Author: Avinash
*/
#include "Collection.h"
#include "Array.h"
#include "BST.h"
Collection::Collection(){ //default constructor
size_=0;
cout<<"Collection constructor called"<<endl;
}
Collection::Collection(const Collection& col){ //copy constructor
size_=col.size_;
cout<<"Collection copy constructor called"<<endl;
}
Collection& Collection::operator=(const Collection& col){ //assignment operator
size_=col.size_;
cout<<"Collection = constructor called"<<endl;
}
bool Collection::treeContains( node *root,int item ) { //to check if BST contains the given node
if ( root == NULL ) { //if root=Null, return false
return false;
}
else if ( item == root->value) {
return true;
}
else if ( item < root->value ) { //if less, move to the left sub tree
return treeContains( root->left, item );
}
else { //if more, move to the right sub tree
return treeContains( root->right, item );
}
}
void Collection::treeMap( node *t) { //BST map functionality
if(t == NULL)
return;
treeMap(t->left);
t->value;
treeMap(t->right);
}
bool Collection::contains(int a){ //Contains funtion implemented in the superclass
BST* b1;
cout<<"Array contains function entered"<<endl;
cout<<"Search element: "<< a << endl;
if(Array* a1=dynamic_cast <Array*> (this)){ //checks if the receiver is Array, if not raise null pointer
for(int i=0;i<a1->len_;i++){ //if its array, check if the array contains the element
if (a1->array[i]==a){
cout<<"Array contains: true"<<endl;
return true;
}
}
return false;
}
else{ //goes into this condition if the above if raises a null pointer
cout<<"Map contains function entered"<<endl;
b1=dynamic_cast<BST*>(this); //dynamic cast the receiver to BST
cout<<"BST contains: 0-False | 1-True :"<<treeContains(b1->root,a)<<endl;
}
}
Collection& Collection::map(int (*fun)(int)){ //Map functionality
Collection* col;
BST* bst;
cout<<"Array Map function entered"<<endl;
if(Array* a1=dynamic_cast<Array*>(this)){ //checks if the receiver is Array, if not raise null pointer
for(int i=0;i<a1->len_;i++){ //if its array, implement map
a1->array[i]=fun(a1->array[i]);
}
return *a1;
}
else{
cout<<"BST Map function entered"<<endl;
bst=dynamic_cast<BST*>(this); //goes into this condition if the above if raises a null pointer
treeMap(bst->root);
return *bst;
}
}
| [
"avi.reddy001@gmail.com"
] | avi.reddy001@gmail.com |
b19538c8250257168e5a6c5cac6ac60692ee74d0 | 39ab815dfdbab9628ede8ec3b4aedb5da3fd456a | /aql/benchmark/lib_44/class_2.cpp | 409af5b857ed610b5a5f5f391877c8a0178d2508 | [
"MIT"
] | permissive | menify/sandbox | c03b1bf24c1527b47eb473f1acc433f17bfb1d4f | 32166c71044f0d5b414335b2b6559adc571f568c | refs/heads/master | 2016-09-05T21:46:53.369065 | 2015-04-20T06:35:27 | 2015-04-20T06:35:27 | 25,891,580 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 311 | cpp | #include "class_2.h"
#include "class_3.h"
#include "class_7.h"
#include "class_4.h"
#include "class_9.h"
#include "class_1.h"
#include <lib_41/class_3.h>
#include <lib_37/class_6.h>
#include <lib_21/class_9.h>
#include <lib_43/class_1.h>
#include <lib_3/class_5.h>
class_2::class_2() {}
class_2::~class_2() {}
| [
"menify@a28edc5c-ec3e-0410-a3da-1b30b3a8704b"
] | menify@a28edc5c-ec3e-0410-a3da-1b30b3a8704b |
fd02f32dbfb38e4618b4c8e8c507cb2aac34a712 | d8446827771cd79eb13242d21b0ca103035c467d | /rush00/Lists/ListEnemy.hpp | 3ebf6595bd2b0c7391eaedd7ae714ddba2064c9f | [] | no_license | vuslysty/piscineCPP | e3ef3aabbef053eca29e1fad0695eeda85bc00c2 | 91a583ed4a0352c904fa485202752f8105230520 | refs/heads/master | 2020-06-20T19:16:15.561261 | 2019-07-16T15:51:59 | 2019-07-16T15:51:59 | 197,219,556 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 678 | hpp | //
// Created by Vladyslav USLYSTYI on 2019-06-30.
//
#ifndef RUSH00_LISTENEMY_HPP
#define RUSH00_LISTENEMY_HPP
#include "../Enemy.hpp"
class Enemy;
class ListEnemy
{
Enemy *_enemy;
ListEnemy *_next;
ListEnemy *_prev;
public:
ListEnemy();
ListEnemy(Enemy *Enemy);
ListEnemy(ListEnemy const &src);
ListEnemy &operator=(ListEnemy const &rhs);
~ListEnemy();
static void push(ListEnemy **list, Enemy* Enemy);
static void delEnemy(ListEnemy **list, ListEnemy **elem);
ListEnemy *getNext() const;
Enemy *getEnemy() const;
static void delList(ListEnemy **list);
bool existAtCoord(int x, int y, ListEnemy **orig);
};
#endif //RUSH00_LISTENEMY_HPP
| [
"vuslysty@e2r11p11.unit.ua"
] | vuslysty@e2r11p11.unit.ua |
b1f22504bea780887803242a393adad17f05cfbc | 01b3369a69be4d56ff0426e980f5a3f5f3085472 | /source/4.2_Spot_Light/RenderingGame.h | 1f5f2c4b1b56b3eaec8431f72548dc0c1a8f95e9 | [
"MIT"
] | permissive | ssshammi/real-time-3d-rendering-with-directx-and-hlsl | e853bc3c8f0a53afc082cb3120aba0b678d0528e | 05a05c5c26784dafa9a89747276f385252951f2f | refs/heads/master | 2023-04-13T23:16:01.282462 | 2020-07-01T14:49:07 | 2020-07-01T14:49:07 | 363,071,604 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,266 | h | #pragma once
#include <windows.h>
#include <functional>
#include "Game.h"
namespace Library
{
class KeyboardComponent;
class MouseComponent;
class GamePadComponent;
class FpsComponent;
class Grid;
}
namespace Rendering
{
class SpotLightDemo;
class RenderingGame final : public Library::Game
{
public:
RenderingGame(std::function<void*()> getWindowCallback, std::function<void(SIZE&)> getRenderTargetSizeCallback);
virtual void Initialize() override;
virtual void Update(const Library::GameTime& gameTime) override;
virtual void Draw(const Library::GameTime& gameTime) override;
virtual void Shutdown() override;
void Exit();
private:
inline static const DirectX::XMVECTORF32 BackgroundColor{ DirectX::Colors::CornflowerBlue };
void UpdateAmbientLightIntensity(const Library::GameTime& gameTime);
void UpdateSpotLight(const Library::GameTime& gameTime);
void UpdateSpecularLight(const Library::GameTime& gameTime);
std::shared_ptr<Library::KeyboardComponent> mKeyboard;
std::shared_ptr<Library::MouseComponent> mMouse;
std::shared_ptr<Library::GamePadComponent> mGamePad;
std::shared_ptr<Library::FpsComponent> mFpsComponent;
std::shared_ptr<Library::Grid> mGrid;
std::shared_ptr<SpotLightDemo> mSpotLightDemo;
};
} | [
"paul.varcholik@ucf.edu"
] | paul.varcholik@ucf.edu |
eef374f316a16a1557f5214e853b4bbfaf9521f0 | 64140e2d9f7ec9dda817bb65db159cb1b5b62d7f | /tetattds/source/garbage.h | c1014f4a0f825e2716a3cadc6dc4f171aa7922f9 | [] | no_license | Flare183/tetattds | fa168809c01a25777d7da8e2efee58abea64daf7 | 024480f2c72c72f385c321d0d0f3add0fe46cc7f | refs/heads/master | 2021-12-04T11:15:55.406897 | 2015-03-16T09:03:17 | 2015-03-16T09:03:17 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 879 | h | #pragma once
enum GarbageType
{
GARBAGE_COMBO,
GARBAGE_CHAIN,
GARBAGE_EVIL
};
#include "baseblock.h"
class GarbageBlock;
#define GARBAGE_GRAPHIC_DISABLED (-1)
/**
* One block of garbage
*/
class Garbage : public BaseBlock
{
public:
Garbage(GarbageType type, BlockType blockType, GarbageBlock * gb);
~Garbage();
virtual void Drop();
virtual void Land();
virtual void Hover(int delay);
virtual void Pop(int num, int total, int nextGraph);
virtual void Tick();
void SetGraphic(int newGraphic);
GarbageBlock* GetGB() const { return gb; }
BaseBlock* CreateBlock();
virtual void ChangeState(BlockState newState);
inline bool IsOtherGarbageType(BaseBlock *block) const {
return block->GetType() ==
(type == BLC_GARBAGE ? BLC_EVILGARBAGE : BLC_GARBAGE);
}
private:
const BlockType blockType;
GarbageBlock* gb;
int nextGraphic;
bool bWantToDrop;
};
| [
"sten.larsson@gmail.com"
] | sten.larsson@gmail.com |
aee473aaf058cb033d0aaf373e1dd2bbc1fc8eb9 | a62342d6359a88b0aee911e549a4973fa38de9ea | /0.6.0.3/Internal/SDK/BTTask_FindHusbandryAnimal_functions.cpp | 25b336c7dbcf11d52c7b9f1531852595b581ace9 | [] | no_license | zanzo420/Medieval-Dynasty-SDK | d020ad634328ee8ee612ba4bd7e36b36dab740ce | d720e49ae1505e087790b2743506921afb28fc18 | refs/heads/main | 2023-06-20T03:00:17.986041 | 2021-07-15T04:51:34 | 2021-07-15T04:51:34 | 386,165,085 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,981 | cpp | // Name: Medieval Dynasty, Version: 0.6.0.3
#include "../pch.h"
/*!!DEFINE!!*/
/*!!HELPER_DEF!!*/
/*!!HELPER_INC!!*/
#ifdef _MSC_VER
#pragma pack(push, 0x01)
#endif
namespace CG
{
//---------------------------------------------------------------------------
// Functions
//---------------------------------------------------------------------------
// Function BTTask_FindHusbandryAnimal.BTTask_FindHusbandryAnimal_C.OnFail_629F0A244365D0611B575788700ED6CE
// (BlueprintCallable, BlueprintEvent)
// Parameters:
// TEnumAsByte<AIModule_EPathFollowingResult> MovementResult (BlueprintVisible, BlueprintReadOnly, Parm, ZeroConstructor, IsPlainOldData, NoDestructor, HasGetValueTypeHash)
void UBTTask_FindHusbandryAnimal_C::OnFail_629F0A244365D0611B575788700ED6CE(TEnumAsByte<AIModule_EPathFollowingResult> MovementResult)
{
static auto fn = UObject::FindObject<UFunction>("Function BTTask_FindHusbandryAnimal.BTTask_FindHusbandryAnimal_C.OnFail_629F0A244365D0611B575788700ED6CE");
UBTTask_FindHusbandryAnimal_C_OnFail_629F0A244365D0611B575788700ED6CE_Params params;
params.MovementResult = MovementResult;
auto flags = fn->FunctionFlags;
UObject::ProcessEvent(fn, ¶ms);
fn->FunctionFlags = flags;
}
// Function BTTask_FindHusbandryAnimal.BTTask_FindHusbandryAnimal_C.OnSuccess_629F0A244365D0611B575788700ED6CE
// (BlueprintCallable, BlueprintEvent)
// Parameters:
// TEnumAsByte<AIModule_EPathFollowingResult> MovementResult (BlueprintVisible, BlueprintReadOnly, Parm, ZeroConstructor, IsPlainOldData, NoDestructor, HasGetValueTypeHash)
void UBTTask_FindHusbandryAnimal_C::OnSuccess_629F0A244365D0611B575788700ED6CE(TEnumAsByte<AIModule_EPathFollowingResult> MovementResult)
{
static auto fn = UObject::FindObject<UFunction>("Function BTTask_FindHusbandryAnimal.BTTask_FindHusbandryAnimal_C.OnSuccess_629F0A244365D0611B575788700ED6CE");
UBTTask_FindHusbandryAnimal_C_OnSuccess_629F0A244365D0611B575788700ED6CE_Params params;
params.MovementResult = MovementResult;
auto flags = fn->FunctionFlags;
UObject::ProcessEvent(fn, ¶ms);
fn->FunctionFlags = flags;
}
// Function BTTask_FindHusbandryAnimal.BTTask_FindHusbandryAnimal_C.ReceiveExecuteAI
// (Event, Protected, BlueprintEvent)
// Parameters:
// class AAIController* OwnerController (BlueprintVisible, BlueprintReadOnly, Parm, ZeroConstructor, IsPlainOldData, NoDestructor, HasGetValueTypeHash)
// class APawn* ControlledPawn (BlueprintVisible, BlueprintReadOnly, Parm, ZeroConstructor, IsPlainOldData, NoDestructor, HasGetValueTypeHash)
void UBTTask_FindHusbandryAnimal_C::ReceiveExecuteAI(class AAIController* OwnerController, class APawn* ControlledPawn)
{
static auto fn = UObject::FindObject<UFunction>("Function BTTask_FindHusbandryAnimal.BTTask_FindHusbandryAnimal_C.ReceiveExecuteAI");
UBTTask_FindHusbandryAnimal_C_ReceiveExecuteAI_Params params;
params.OwnerController = OwnerController;
params.ControlledPawn = ControlledPawn;
auto flags = fn->FunctionFlags;
UObject::ProcessEvent(fn, ¶ms);
fn->FunctionFlags = flags;
}
// Function BTTask_FindHusbandryAnimal.BTTask_FindHusbandryAnimal_C.ExecuteUbergraph_BTTask_FindHusbandryAnimal
// (Final)
// Parameters:
// int EntryPoint (BlueprintVisible, BlueprintReadOnly, Parm, ZeroConstructor, IsPlainOldData, NoDestructor, HasGetValueTypeHash)
void UBTTask_FindHusbandryAnimal_C::ExecuteUbergraph_BTTask_FindHusbandryAnimal(int EntryPoint)
{
static auto fn = UObject::FindObject<UFunction>("Function BTTask_FindHusbandryAnimal.BTTask_FindHusbandryAnimal_C.ExecuteUbergraph_BTTask_FindHusbandryAnimal");
UBTTask_FindHusbandryAnimal_C_ExecuteUbergraph_BTTask_FindHusbandryAnimal_Params params;
params.EntryPoint = EntryPoint;
auto flags = fn->FunctionFlags;
UObject::ProcessEvent(fn, ¶ms);
fn->FunctionFlags = flags;
}
}
#ifdef _MSC_VER
#pragma pack(pop)
#endif
| [
"zp2kshield@gmail.com"
] | zp2kshield@gmail.com |
6b05ab93b252e638d4e6f9b6aa8bd9e5750fedd1 | 6f5300f7ce0137b59b08fd597ada679c1efc9c8e | /Loadpe/Loadpe/stdafx.cpp | 105b138ba5a3b0bcf3e7662ad51747aeb62db208 | [] | no_license | warren-126/LoadPE | 71eba1358eb8c72708e880b043818fd590953d50 | b5cdfc89ef1256faf68c4c8cc6920656987d43a7 | refs/heads/master | 2021-06-09T11:49:55.970113 | 2016-12-07T01:42:12 | 2016-12-07T01:42:12 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 293 | cpp | // stdafx.cpp : source file that includes just the standard includes
// Loadpe.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
| [
"lakshmi.desai84@yahoo.com"
] | lakshmi.desai84@yahoo.com |
7eb6db4d6ccf9baa1f2bbad8572c7d4f213bf73a | d6e9f5ab0689d4edd1d9da90985d6bf02dc1b708 | /CodeForces/520B.cpp | 33ba6af6653fd3c41f5da12e64adbda771a12dc2 | [] | no_license | Dhruvik-Chevli/Code | 30af2133f7f55404bf47a1bf87b372aa93461ba2 | 615a599c1e5e6406f50c316cebe357cc86486a6f | refs/heads/master | 2022-12-21T03:00:29.650021 | 2020-09-24T21:21:23 | 2020-09-24T21:21:23 | 260,184,858 | 6 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,266 | cpp | #include <iostream>
#include<vector>
#include<algorithm>
#include<utility>
#include<string>
#include<unordered_set>
#include<stack>
#include<queue>
#include<unordered_map>
using namespace std;
typedef long long int ll;
#define EPS 1e-9
#define pb push_back
#define FOR(i, a, b) for(ll i = a; i < b; i++)
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
ll bfs(ll n, ll m)
{
ll k=max(n,m);
vector<ll>dist(2*k+1,-1);
//cout<<k<<endl;
dist[n]=0;
queue<ll>q;
q.push(n);
vector<bool>visited(2*k+1,false);
visited[n]=true;
while(!(q.empty()))
{
ll k=q.front();
q.pop();
//cout<<k<<endl;
if(k==m)
{
break;
}
if(k*2<2*m and visited[2*k]==false)
{
dist[k*2]=dist[k]+1;
visited[2*k]=true;
q.push(2*k);
}
if(k-1>0 and visited[k-1]==false)
{
dist[k-1]=dist[k]+1;
visited[k-1]=true;
q.push(k-1);
}
}
return dist[m];
}
int main()
{
std::ios_base::sync_with_stdio(false);
cin.tie(NULL);
ll n,m;
cin>>n>>m;
// ll k=max(n,m);
// vector<ll>dist(k+1,-1);
// dist[n]=0;
cout<<bfs(n,m)<<endl;
return 0;
} | [
"dhruvik.chevli@gmail.com"
] | dhruvik.chevli@gmail.com |
5e9d3290d395241d482ba64f22a7206e74d0a03c | bc6c37cf0469c6b2778707b76227558b3a040718 | /codeforces/codeforce-313A-Ilya_and_Bank_Account.cpp | 27128170f4d473703595095cedcbd9e8a86ad2bf | [] | no_license | zeroplusone/AlgorithmPractice | 241530a5c989f6321543f7bd07a393c405cdf2e6 | 7fe9182d943bc2066f7fd31cc05096be79dc12cb | refs/heads/master | 2022-01-28T21:57:04.393943 | 2022-01-26T13:46:43 | 2022-01-26T13:46:43 | 84,074,414 | 2 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 358 | cpp | #include<iostream>
#include<cstdio>
#include<cstdlib>
using namespace std;
int main()
{
int n;
int i,len,j,ans,tmp;
while(scanf("%d",&n)!=EOF)
{
if(n>=0) printf("%d\n",n);
else
{
n*=-1;
len=(n%100)/10;
tmp=(n/100)*10+n%10;
ans=n/10;
ans=ans>tmp?tmp:ans;
ans*=-1;
printf("%d\n",ans);
}
}
return 0;
} | [
"a711186@gmail.com"
] | a711186@gmail.com |
0ca62b5b5ec7b00b2cbad9a703239af383fde363 | 0cb85cd0c88a9b9f0cca4472742c2bf9febef2d8 | /Mail/Filters/Antispam/html_parser/html_def.cpp | f0e0ced45c53420612c3949c17e281fd07990fdf | [] | no_license | seth1002/antivirus-1 | 9dfbadc68e16e51f141ac8b3bb283c1d25792572 | 3752a3b20e1a8390f0889f6192ee6b851e99e8a4 | refs/heads/master | 2020-07-15T00:30:19.131934 | 2016-07-21T13:59:11 | 2016-07-21T13:59:11 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,796 | cpp | // $Id: html_def.cpp,v 1.3 2000/04/20 13:52:59 slavikb Exp $
//
#include "htmparse.h"
html_elt_def __html_elt_def[] = {
#define DEF_HTML_ELEMENT(N,F,C) { #N, F, C },
#define DEF_HTML_ELEMENT_EX(N,L,F,C) { L, F, C },
#include "htmltags.tab"
#undef DEF_HTML_ELEMENT
};
const int HTML_ELT_COUNT = sizeof(__html_elt_def)/sizeof(__html_elt_def[0]);
int html_find_tag( const char *name )
{
int lb = 0;
int hb = HTML_ELT_COUNT;
while( hb>lb ) {
int i = (hb+lb)/2;
int st = strcmp( name, __html_elt_def[i].tag );
if( st==0 ) return i;
if( st<0 ) hb = i; else lb = i+1;
}
return -1;
}
html_elt_def *html_find_element( const char *name )
{
int idx = html_find_tag( name );
if( idx<0 ) return NULL;
return &__html_elt_def[idx];
}
html_elt_def *html_get_element( int idx )
{
if( idx<0 || idx>=sizeof(__html_elt_def)/sizeof(__html_elt_def[0]) ) return NULL;
return &__html_elt_def[idx];
}
const char CA_UPR = 'A'-'a';
static bool normalize_copy_tag_a( const char *s, char *d )
{
for( ; *s!=0; ++s,++d ) {
char c = *s;
if( c & ~0x7F ) return false;
if( c>='a' && c<='z' ) *d = c+CA_UPR; else *d = c;
}
*d = 0;
return true;
}
static bool normalize_copy_tag_w( const wchar_t *s, char *d )
{
for( ; *s!=0; ++s,++d ) {
wchar_t wc = *s;
if( wc & ~0x7F ) return false;
char c = (char)wc;
if( c>='a' && c<='z' ) *d = c+CA_UPR; else *d = c;
}
*d = 0;
return true;
}
int html_find_tag_i( const char *name )
{
int blen = (strlen(name)+1)*sizeof(char);
char *nbuf = (char *)alloca( blen );
if( !normalize_copy_tag_a( name, nbuf ) ) return -1;
return html_find_tag( nbuf );
}
html_elt_def *html_find_element_i( const char *name )
{
int idx = html_find_tag_i( name );
if( idx<0 ) return NULL;
return &__html_elt_def[idx];
}
int html_find_tag_w( const wchar_t *wname )
{
const wchar_t *pw = wname;
while( *pw!=0 ) ++pw;
int blen = (pw-wname+1);
char *nbuf = (char *)alloca( blen );
if( !normalize_copy_tag_w( wname, nbuf ) ) return -1;
return html_find_tag( nbuf );
}
html_elt_def *html_find_element_w( const wchar_t *wname )
{
int idx = html_find_tag_w( wname );
if( idx<0 ) return NULL;
return &__html_elt_def[idx];
}
html_elt_def_dynamic::html_elt_def_dynamic()
{
tag = NULL;
cflags = HTML_EF_DYNAMIC;
cmodel = 0;
}
void html_elt_def::duplicate()
{
if( (cflags & HTML_EF_DYNAMIC)!=0 ) {
// WARNING: unsafe operation (reinterpret_cast)
html_elt_def_dynamic *ddef = (html_elt_def_dynamic *)this;
ddef->duplicate();
}
}
void html_elt_def::release()
{
if( (cflags & HTML_EF_DYNAMIC)!=0 ) {
// WARNING: unsafe operation (reinterpret_cast)
html_elt_def_dynamic *ddef = (html_elt_def_dynamic *)this;
ddef->release();
}
}
| [
"idrez.mochamad@gmail.com"
] | idrez.mochamad@gmail.com |
a65fd1e9de2e7dab17b76975df980f098b41a2c9 | 9d317a24cc02906eeb09fd60f26b22cace34a096 | /JSTrader/JSTraderGUI/ReadOnlyDelegate.h | 854ad9cd67ec97bb0584e4dfa1e1363891b8d583 | [] | no_license | qbjstone/trader | 2efbbfa86ed5d25117627c1a5d737ac0dce7fda6 | fb34a134c8eb0d3d98181fb41762d5828c88f32f | refs/heads/master | 2021-06-06T08:01:39.924092 | 2020-11-21T05:33:03 | 2020-11-21T05:33:03 | 159,979,561 | 0 | 0 | null | 2021-05-10T10:36:09 | 2018-12-01T19:26:45 | C++ | UTF-8 | C++ | false | false | 320 | h | #ifndef READONLYDELEGATE_H
#define READONLYDELEGATE_H
#include <qstyleditemdelegate.h>
class ReadOnlyDelegate : public QStyledItemDelegate
{
Q_OBJECT
public:
ReadOnlyDelegate(QObject *parent = 0);
QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option,
const QModelIndex &index) const;
};
#endif | [
"kangseung@163.com"
] | kangseung@163.com |
8667b61003369cc45c6bd628812db84073e84e20 | e1cff5da7a03a50f4bb3a1e12b7c712de58dd4a6 | /Array/Arrays_leftRotaion.cpp | 8f8e86b0320b3014578ec0a4645e5499c77b5f5f | [] | no_license | beastmaster064/Interview-Preparation-Kit_Hackerrank | 4fe164d0539d4ffae22d3b8350e641bf822bf7be | f26557744da5d398ee5a5c9fae8a50e83e269e9f | refs/heads/master | 2021-05-20T11:18:52.437080 | 2020-04-02T00:41:49 | 2020-04-02T00:41:49 | 252,272,126 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,841 | cpp | #include <bits/stdc++.h>
using namespace std;
vector<string> split_string(string);
// Complete the rotLeft function below.
vector<int> rotLeft(vector<int> a, int d) {
int i,j,n=a.size(),temp;
for(i=0;i<d;i++){
j=0;
temp=a[j];
while(j<n-1)
{
a[j]=a[j+1];
j++;
}
a[n-1]=temp;
}
return a;
}
int main()
{
ofstream fout(getenv("OUTPUT_PATH"));
string nd_temp;
getline(cin, nd_temp);
vector<string> nd = split_string(nd_temp);
int n = stoi(nd[0]);
int d = stoi(nd[1]);
string a_temp_temp;
getline(cin, a_temp_temp);
vector<string> a_temp = split_string(a_temp_temp);
vector<int> a(n);
for (int i = 0; i < n; i++) {
int a_item = stoi(a_temp[i]);
a[i] = a_item;
}
vector<int> result = rotLeft(a, d);
for (int i = 0; i < result.size(); i++) {
fout << result[i];
if (i != result.size() - 1) {
fout << " ";
}
}
fout << "\n";
fout.close();
return 0;
}
vector<string> split_string(string input_string) {
string::iterator new_end = unique(input_string.begin(), input_string.end(), [] (const char &x, const char &y) {
return x == y and x == ' ';
});
input_string.erase(new_end, input_string.end());
while (input_string[input_string.length() - 1] == ' ') {
input_string.pop_back();
}
vector<string> splits;
char delimiter = ' ';
size_t i = 0;
size_t pos = input_string.find(delimiter);
while (pos != string::npos) {
splits.push_back(input_string.substr(i, pos - i));
i = pos + 1;
pos = input_string.find(delimiter, i);
}
splits.push_back(input_string.substr(i, min(pos, input_string.length()) - i + 1));
return splits;
}
| [
"tharunyuvi05@gmail.com"
] | tharunyuvi05@gmail.com |
052cf8b7910cf499d41cb5444685735e43581da2 | 267bb6c0aaf057083a12e744aa50fbd2735b42d8 | /src/libtsduck/tsSocketAddress.cpp | dbc3ee60569d4e2d61640e9b1efafca36c01fe72 | [
"BSD-2-Clause",
"WTFPL",
"LicenseRef-scancode-public-domain"
] | permissive | yrpark99/tsduck | 0c163410306a085248dba8490ee0faeae8a5a862 | 2929092e42c5c7eec95a119af91cc09ffdde2028 | refs/heads/master | 2020-04-06T10:20:44.113519 | 2019-10-15T06:27:13 | 2019-10-15T06:27:13 | 157,377,153 | 0 | 0 | NOASSERTION | 2018-11-13T12:30:58 | 2018-11-13T12:30:58 | null | UTF-8 | C++ | false | false | 4,836 | cpp | //----------------------------------------------------------------------------
//
// TSDuck - The MPEG Transport Stream Toolkit
// Copyright (c) 2005-2018, Thierry Lelegard
// 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.
//
// 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.
//
//----------------------------------------------------------------------------
//
// IP v4 address class
//
//----------------------------------------------------------------------------
#include "tsSocketAddress.h"
TSDUCK_SOURCE;
//----------------------------------------------------------------------------
// Constructors
//----------------------------------------------------------------------------
ts::SocketAddress::SocketAddress(const ::sockaddr& s) :
IPAddress(s),
_port(AnyPort)
{
if (s.sa_family == AF_INET) {
assert(sizeof(::sockaddr) >= sizeof(::sockaddr_in));
const ::sockaddr_in* sp = reinterpret_cast<const ::sockaddr_in*>(&s);
_port = ntohs(sp->sin_port);
}
}
ts::SocketAddress::SocketAddress(const ::sockaddr_in& s) :
IPAddress(s),
_port(s.sin_family == AF_INET ? ntohs(s.sin_port) : AnyPort)
{
}
//----------------------------------------------------------------------------
// Decode a string "addr[:port]" or "[addr:]port".
// Addr can also be a hostname which is resolved.
// Return true on success, false on error.
//----------------------------------------------------------------------------
bool ts::SocketAddress::resolve(const UString& name, Report& report)
{
// Clear address & port
clear();
// Locate last colon in string
UString::size_type colon = name.rfind(u":");
if (colon == NPOS) {
// No colon in string, can be an address alone or a port alone.
if (name.toInteger(_port)) {
// This is an integer, this is a port alone.
return true;
}
else {
// Not a valid integer, this is an address alone
_port = AnyPort;
return IPAddress::resolve(name, report);
}
}
// If there is something after the colon, this must be a port number
if (colon < name.length() - 1 && !name.substr(colon + 1).toInteger(_port)) {
report.error(u"invalid port value in \"%s\"", {name});
return false;
}
// If there is something before the colon, this must be an address.
// Try to decode name as IP address or resolve it as DNS host name.
return colon == 0 || IPAddress::resolve(name.substr(0, colon), report);
}
//----------------------------------------------------------------------------
// Check if this address "matches" another one.
//----------------------------------------------------------------------------
bool ts::SocketAddress::match(const SocketAddress& other) const
{
return IPAddress::match(other) && (_port == AnyPort || other._port == AnyPort || _port == other._port);
}
//----------------------------------------------------------------------------
// Convert to a string object
//----------------------------------------------------------------------------
ts::UString ts::SocketAddress::toString() const
{
return IPAddress::toString() + (_port == AnyPort ? u"" : UString::Format(u":%d", {_port}));
}
//----------------------------------------------------------------------------
// Comparison "less than" operator.
//----------------------------------------------------------------------------
bool ts::SocketAddress::operator<(const SocketAddress& other) const
{
return address() < other.address() || (address() == other.address() && _port < other._port);
}
| [
"thierry@lelegard.fr"
] | thierry@lelegard.fr |
3ee4e2e602a6e6a83c271755da71ebc454e10b95 | e8e4433fe7362e5daa206c85ecfed928eb2efb50 | /interface/PFIsolation.h | 549b38d0b535e7d902fcd8c5745a2bfc919ec6c6 | [] | no_license | h2gglobe/UserCode | 7857f11a44af8164c77fa91a5ab5474fe07c54c4 | 4c10127a07e6ac51362ff5f390e6487a56773bfc | refs/heads/master | 2021-01-25T04:08:47.013808 | 2013-05-30T19:54:21 | 2013-05-30T19:54:21 | 10,404,611 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 994 | h | #ifndef __PFIsolation__
#define __PFIsolation__
#include "DataFormats/EgammaCandidates/interface/GsfElectron.h"
#include "DataFormats/ParticleFlowCandidate/interface/PFCandidate.h"
#include "DataFormats/ParticleFlowCandidate/interface/PFCandidateFwd.h"
#include "DataFormats/ParticleFlowCandidate/interface/PileUpPFCandidate.h"
#include "DataFormats/ParticleFlowCandidate/interface/PileUpPFCandidateFwd.h"
#include <vector>
bool vetoPFParticle(const reco::PFCandidate&, std::vector<reco::PFCandidate::ParticleType>);
float pfHcalIso(const reco::GsfElectron&, const reco::PFCandidateCollection*, float, float, std::vector<reco::PFCandidate::ParticleType>);
float pfEcalIso(const reco::GsfElectron&, const reco::PFCandidateCollection*, float, float, std::vector<reco::PFCandidate::ParticleType>);
float pfTkIso(const reco::GsfElectron&, edm::Handle<reco::PFCandidateCollection>, edm::Handle<reco::PFCandidateCollection>, float, float, std::vector<reco::PFCandidate::ParticleType>);
#endif
| [
""
] | |
aa0ff3ebe0a20de5a16c93c6cd038b89ba1ea915 | e14e0593215f79b479189ee7570fe05ce3534123 | /source/Search.h | 4363faaa530c8e1ad82c6408e465d50e830f8937 | [
"MIT"
] | permissive | kracejic/runningDict | fdd0fe72527c488d0c296420a3dd79336eb068a4 | 541221eb1dadf1885b349baaea49ee2c6146a2fc | refs/heads/master | 2020-12-12T12:53:54.723113 | 2017-02-20T19:56:47 | 2017-02-20T19:56:47 | 54,825,162 | 1 | 0 | null | 2017-05-20T02:15:59 | 2016-03-27T11:24:11 | CSS | UTF-8 | C++ | false | false | 315 | h | #pragma once
#include <algorithm>
#include <cstdio>
#include <future>
#include <iostream>
#include <stdio.h>
#include <string>
#include <vector>
#include "Dict.h"
#include "Worker.h"
workerResult _search(std::vector<Dict>& dicts, int numthreads,
const std::vector<std::string>& words, bool verbose = false);
| [
"kracejic@gmail.com"
] | kracejic@gmail.com |
977d1dfc5c7a199bb68292a868fa0e8241b7e9d8 | bb5258ea8c1f8cbcc247b92971cd926264479002 | /ds4/code/4_core/thread/thread_safe.h | d1bb3510539f2b94a8885556f66491a107653fe4 | [
"MIT"
] | permissive | demonsaw/Code | 16fa41f07600e83f16713a657ac8fffa0b6b7f9b | b036d455e9e034d7fd178e63d5e992242d62989a | refs/heads/master | 2021-11-07T21:37:03.738542 | 2021-10-26T03:47:14 | 2021-10-26T03:47:14 | 98,356,418 | 134 | 19 | MIT | 2019-01-06T03:20:12 | 2017-07-25T22:50:36 | C++ | UTF-8 | C++ | false | false | 7,338 | h | //
// The MIT License(MIT)
//
// Copyright(c) 2014 Demonsaw LLC
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
#ifndef _EJA_THREAD_SAFE_H_
#define _EJA_THREAD_SAFE_H_
#include <memory>
#include <mutex>
#include "system/type.h"
#include "thread/thread_proxy.h"
namespace eja
{
// Macro
#define thread_lock(obj) const auto proxy ## obj = obj->get_proxy()
#define __lock(obj) { const auto proxy ## obj = obj->get_proxy()
#define __unlock() }
template <typename T, class M = std::mutex>
class thread_safe : public T
{
make_factory(thread_safe);
public:
using mutex_type = M;
using proxy_type = thread_proxy<thread_safe, mutex_type>;
protected:
mutex_type m_mutex;
public:
thread_safe() { }
thread_safe(const thread_safe& safe) : T(safe) { }
thread_safe(const T& t) : T(t) { }
// Operator
thread_safe& operator=(const thread_safe& safe)
{
if (this != &safe)
T::operator=(safe);
return *this;
}
thread_safe& operator=(const T& t)
{
if (this != &t)
T::operator=(t);
return *this;
}
const thread_safe* operator->() const { return this; }
thread_safe* operator->() { return this; }
const thread_safe& operator*() const { return *this; }
thread_safe& operator*() { return *this; }
// Get
const proxy_type get_proxy() const { return proxy_type(*this, m_mutex); }
proxy_type get_proxy() { return proxy_type(*this, m_mutex); }
// Static
static ptr create(const T& t) { return std::make_shared<thread_safe>(t); }
static ptr create(const std::shared_ptr<T> t) { return std::make_shared<thread_safe>(*t); }
};
template <typename T, typename U, class M = std::mutex>
class thread_safe_ex : public T, public U
{
make_factory(thread_safe_ex);
public:
using mutex_type = M;
using proxy_type = thread_proxy<thread_safe_ex, mutex_type>;
protected:
mutex_type m_mutex;
public:
thread_safe_ex() { }
thread_safe_ex(const thread_safe_ex& safe) : T(safe), U(safe) { }
thread_safe_ex(const T& t) : T(t) { }
thread_safe_ex(const U& u) : U(u) { }
// Operator
thread_safe_ex& operator=(const thread_safe_ex& safe)
{
if (this != &safe)
{
T::operator=(safe);
U::operator=(safe);
}
return *this;
}
thread_safe_ex& operator=(const T& t)
{
if (this != &t)
T::operator=(t);
return *this;
}
thread_safe_ex& operator=(const U& u)
{
if (this != &u)
U::operator=(u);
return *this;
}
const thread_safe_ex* operator->() const { return this; }
thread_safe_ex* operator->() { return this; }
const thread_safe_ex& operator*() const { return *this; }
thread_safe_ex& operator*() { return *this; }
// Interface
virtual void clear() override
{
T::clear();
U::clear();
}
// Get
const proxy_type get_proxy() const { return proxy_type(*this, m_mutex); }
proxy_type get_proxy() { return proxy_type(*this, m_mutex); }
// Static
static ptr create(const T& t) { return std::make_shared<thread_safe_ex>(t); }
static ptr create(const std::shared_ptr<T> t) { return std::make_shared<thread_safe_ex>(*t); }
static ptr create(const U& u) { return std::make_shared<thread_safe_ex>(u); }
static ptr create(const std::shared_ptr<U> u) { return std::make_shared<thread_safe_ex>(*u); }
};
/////////////////////////////////////////////////////////////////////////////
//
//
//
/////////////////////////////////////////////////////////////////////////////
#define make_thread_safe_type(T, ...) \
class T final : public thread_safe<__VA_ARGS__> \
{ \
make_factory(T); \
\
public: \
T() { } \
T(const T& t) : thread_safe(t) { } \
T(const __VA_ARGS__& u) : thread_safe(u) { } \
\
T& operator=(const __VA_ARGS__& u) \
{ \
thread_safe::operator=(u); \
\
return *this; \
} \
\
T& operator=(const T& t) \
{ \
if (this != &t) \
thread_safe::operator=(t); \
\
return *this; \
} \
\
static ptr create(const __VA_ARGS__& v) { return std::make_shared<T>(v); } \
static ptr create(const std::shared_ptr<__VA_ARGS__>& v) { return std::make_shared<T>(*v); } \
}
#define make_thread_safe_type_ex(T, U, ...) \
class T final : public thread_safe_ex<U, __VA_ARGS__> \
{ \
make_factory(T); \
\
public: \
T() { } \
T(const T& t) : thread_safe_ex(t) { } \
T(const U& u) : thread_safe_ex(u) { } \
T(const __VA_ARGS__& v) : thread_safe_ex(v) { } \
\
T& operator=(const T& t) \
{ \
if (this != &t) \
thread_safe_ex::operator=(t); \
\
return *this; \
} \
\
T& operator=(const U& u) \
{ \
if (this != &u) \
thread_safe_ex::operator=(u); \
\
return *this; \
} \
\
T& operator=(const __VA_ARGS__& v) \
{ \
if (this != &v) \
thread_safe_ex::operator=(v); \
\
return *this; \
} \
\
static ptr create(const U& u) { return std::make_shared<T>(u); } \
static ptr create(const std::shared_ptr<U> u) { return std::make_shared<T>(*u); } \
static ptr create(const __VA_ARGS__& v) { return std::make_shared<T>(v); } \
static ptr create(const std::shared_ptr<__VA_ARGS__>& v) { return std::make_shared<T>(*v); } \
}
}
#endif
| [
"eric@codesiren.com"
] | eric@codesiren.com |
3ee3505eb0bde3dcaaf36399fc49de78bdc9983b | 9008c69d81f91224e2dcb4faaa87a73af2923bdf | /GAME5/GAME5/MeleeJob.cpp | af4abca373c7e2ab5d12dbd59cfca32051c92402 | [] | no_license | qwer87511/OOP-Homework | 84c5d0b4ae9ca7beb7c6cf43ad49ce1289829254 | b26e0c159735f27488e7abca25d46ce624188827 | refs/heads/master | 2020-03-19T01:18:12.701354 | 2018-06-02T14:52:39 | 2018-06-02T14:52:39 | 135,535,985 | 0 | 0 | null | null | null | null | BIG5 | C++ | false | false | 653 | cpp | #include "MeleeJob.h"
#include "RemoteJob.h"
#include "Character.h"
MeleeJob::MeleeJob(string name, int extraStr, int extraDex, int extraCon) : Job(name, extraStr, extraDex, extraCon)
{
JobType jobType = MELEE;
}
// 回傳職業型態名稱
string MeleeJob::GetJobTypeName()
{
return "近距離攻擊系";
}
// 是否克制敵人職業
bool MeleeJob::IsCounter(Job* enemyJob)
{
return dynamic_cast<RemoteJob*>(enemyJob) != nullptr;
}
// 回傳職業對敵人的傷害加成
int MeleeJob::GetDamage(Character* enemy)
{
if (IsCounter(enemy->GetJob()))
return this->GetExtraStr() + 2;
else
return this->GetExtraStr();
} | [
"qwer87511@gmail.com"
] | qwer87511@gmail.com |
5d542cc4c313a9dcf15bce83b1798846cebacba6 | 71182ec9f7cd783dd3b5ab17b8e7fe67868d3241 | /Recursion/lec_01.cpp | bf851969cd3a87b4dd7f79065440ef9ad62170ad | [] | no_license | aman-5757/levelUp__ | 1079498e30ec439ef92157521b90b37f533ba778 | 245a3f3491f38770c51bfa3137cd06393e1d50bf | refs/heads/master | 2022-12-31T13:13:12.124489 | 2020-09-28T17:56:44 | 2020-09-28T17:56:44 | 290,859,270 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 675 | cpp | #include<iostream>
#include<vector>
using namespace std;
void printInc(int a, int b){
if(a==b+1) return;
cout<<a<<" ";
printInc(a+1,b);
}
int fact(int n){
return n<=1 ? 1 : fact(n-1)*n;
}
int minimum(vector<int > & arr, int i){
if(i == arr.size()-1) return arr[i];
return min(arr[i],minimum(arr,i+1));
}
bool find(vector<int > & arr, int i, int data){
if(i == arr.size()) return false;
if(arr[i] == data) return data;
return find(arr, i+1,data);
}
int main(){
// printInc(0,7);
// cout<<fact(5);
vector<int > arr = {2,7,5,1,6,-19,21,3,5,8};
// cout<<minimum(arr,0);
cout<<find(arr,0, 221);
return 0;
} | [
"aman4863@gmail.com"
] | aman4863@gmail.com |
dbafa7ac7d34fbefd948451b39fc14de2960859c | 694d527c723cde3cc229e0789250da4fe752e8ff | /src/consensus/params.h | e6cd0a4c0315fdbbb0f0eaabbb97dd27d3b9d986 | [] | no_license | maodoutech/my-bitcoin | 71c731e2e4e585879a6eca16ab2d12dd377ddb26 | d161eb085aa1296bdddc8c02810abea0c4b1c59b | refs/heads/master | 2021-04-15T08:48:25.489437 | 2018-06-05T02:46:24 | 2018-06-05T02:46:24 | 126,755,336 | 2 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 1,844 | h | #ifndef BITCOIN_CONSENSUS_PARAMS_H
#define BITCOIN_CONSENSUS_PARAMS_H
#include "uint256.h"
#include <map>
#include <string>
namespace Consensus {
enum DeploymentPos
{
DEPLOYMENT_TESTDUMMY,
DEPLOYMENT_CSV, // Deployment of BIP68, BIP112, and BIP113.
MAX_VERSION_BITS_DEPLOYMENTS
};
/**
* Struct for each individual consensus rule change using BIP9.
*/
struct BIP9Deployment {
/** Bit position to select the particular bit in nVersion. */
int bit;
/** Start MedianTime for version bits miner confirmation. Can be a date in the past */
int64_t nStartTime;
/** Timeout/expiry MedianTime for the deployment attempt. */
int64_t nTimeout;
};
/**
* Parameters that influence chain consensus.
*/
struct Params {
uint256 hashGenesisBlock;
int nSubsidyHalvingInterval;
/** Used to check majorities for block version upgrade */
int nMajorityEnforceBlockUpgrade;
int nMajorityRejectBlockOutdated;
int nMajorityWindow;
/** Block height and hash at which BIP34 becomes active */
int BIP34Height;
uint256 BIP34Hash;
/**
* Minimum blocks including miner confirmation of the total of 2016 blocks in a retargetting period,
* (nPowTargetTimespan / nPowTargetSpacing) which is also used for BIP9 deployments.
* Examples: 1916 for 95%, 1512 for testchains.
*/
uint32_t nRuleChangeActivationThreshold;
uint32_t nMinerConfirmationWindow;
BIP9Deployment vDeployments[MAX_VERSION_BITS_DEPLOYMENTS];
/** Proof of work parameters */
uint256 powLimit;
bool fPowAllowMinDifficultyBlocks;
bool fPowNoRetargeting;
int64_t nPowTargetSpacing;
int64_t nPowTargetTimespan;
int64_t DifficultyAdjustmentInterval() const { return nPowTargetTimespan / nPowTargetSpacing; }
};
} // namespace Consensus
#endif // BITCOIN_CONSENSUS_PARAMS_H
| [
"jack_zsl@163.com"
] | jack_zsl@163.com |
2f5947a464307be0715d7c3a4aa95fefa27b68ef | d4f86d76bc29a504d82624a2982f5f188991c084 | /Win32Project1/mesh/sphere.h | 80396971dd6d2f21cf5910661b78eb7f05a6a14a | [] | no_license | Graphics-Physics-Libraries/Tiny3D | 6e674809887c04109ec4016657abf1c0aa925ec1 | 4f6172069eadddb5d65edfa43a699820f0e54f63 | refs/heads/master | 2020-07-14T17:41:14.575037 | 2019-04-17T10:27:12 | 2019-04-17T10:27:12 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 317 | h | /*
* sphere.h
*
* Created on: 2017-4-2
* Author: a
*/
#ifndef SPHERE_H_
#define SPHERE_H_
#include "mesh.h"
class Sphere: public Mesh {
private:
int longitude,latitude;
virtual void initFaces();
public:
Sphere(int m,int n);
Sphere(const Sphere& rhs);
virtual ~Sphere();
};
#endif /* SPHERE_H_ */
| [
"zxx43@hotmail.com"
] | zxx43@hotmail.com |
7f28dd9a67a1d8a0fd1b30364ceb226c4206a50f | 6b2a8dd202fdce77c971c412717e305e1caaac51 | /solutions_2705486_0/C++/marwanpp/C.cpp | 38466245df992258142b632bc9afe19f4f2db62c | [] | no_license | alexandraback/datacollection | 0bc67a9ace00abbc843f4912562f3a064992e0e9 | 076a7bc7693f3abf07bfdbdac838cb4ef65ccfcf | refs/heads/master | 2021-01-24T18:27:24.417992 | 2017-05-23T09:23:38 | 2017-05-23T09:23:38 | 84,313,442 | 2 | 4 | null | null | null | null | UTF-8 | C++ | false | false | 1,937 | cpp | /*
* C.cpp
*
* Created on: May 4, 2013
* Author: Marwan
*/
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstring>
#include <sstream>
#include <complex>
#include <iomanip>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <list>
#include <bitset>
#include <climits>
#include <set>
#include <map>
#include <fstream>
using namespace std;
const int oo = (int)1e9;
const double PI = 2 * acos(0.0);
const double eps = 1e-9;
#define MP make_pair
#define SZ(x) (int)x.size()
int dcmp (double a, double b){
return (fabs(a-b) <= eps) ? 0 : (( a < b ) ? -1 : 1) ;
}
typedef long long ll;
typedef pair<int,int> pii;
vector <vector <string> > dic ;
void ReadDic () {
ifstream file ;
file.open("garbled_email_dictionary.txt");
dic.clear() ;
dic.resize(11) ;
string s ;
while (file >> s)
dic[SZ(s)].push_back(s) ;
}
string s ;
int min_Cost (int idx, int sz) {
vector <string> & vs = dic[sz] ;
int res = sz ;
for (int i=0 ; i < SZ(vs) ; i++) {
int cnt = 0 ;
for (int j=0 ; j < sz ; j++)
cnt += (s[idx+j] != vs[i][j]) ;
res = min (res, cnt) ;
}
return res ;
}
int mem[50] ;
int calc (int idx) {
if (idx > SZ(s))
return oo ;
if (idx == SZ(s))
return 0 ;
int & r = mem[idx];
if (r != -1)
return r ;
r = oo ;
for (int sz = 1; sz < SZ(dic); sz++)
r = min (r, calc (idx+sz) + min_Cost(idx, sz)) ;
return r ;
}
int main (){
ReadDic();
#ifndef ONLINE_JUDGE
freopen ("in.in", "rt", stdin);
// freopen ("input.txt", "rt", stdin);
// freopen ("output.txt", "wt", stdout);
#endif
int T ;
cin >> T ;
for (int t = 0; t < T ; t++){
cout << "Case #" << t+1 << ": " ;
cin >> s ;
memset (mem, -1, sizeof mem);
cout << calc (0) << endl ;
}
return 0;
}
| [
"eewestman@gmail.com"
] | eewestman@gmail.com |
a5ad22d148bc82a474bf055d05e20b6a10fd9695 | 48298469e7d828ab1aa54a419701c23afeeadce1 | /Server/Team/Team.cpp | 9a10ca52313a49ce3f8d97c5715a0ce3348ced56 | [] | no_license | brock7/TianLong | c39fccb3fd2aa0ad42c9c4183d67a843ab2ce9c2 | 8142f9ccb118e76a5cd0a8b168bcf25e58e0be8b | refs/heads/master | 2021-01-10T14:19:19.850859 | 2016-02-20T13:58:55 | 2016-02-20T13:58:55 | 52,155,393 | 5 | 3 | null | null | null | null | GB18030 | C++ | false | false | 5,688 | cpp | #include "stdafx.h"
/********************************************************************************
* 文件名: Team.cpp
* 全路径: d:\Prj\Server\Server\Team\Team.cpp
* 创建时间: 2005 年 11 月 4 日 9:25
*
* 功能说明: 队伍
* 修改记录:
*********************************************************************************/
#include "Team.h"
#include "Obj_Human.h"
// 入队
VOID TeamInfo::AddMember( const TEAMMEMBER* pMember )
{
__ENTER_FUNCTION
if( m_MemberCount>=MAX_TEAM_MEMBER )
{
Assert(FALSE);
return;
}
m_aMember[m_MemberCount++] = *pMember;
if( pMember->m_SceneID == m_MySceneID
&& pMember->m_GUID != m_MyGUID // 自己不需要加入同场景队友
)
{
AddSceneMember(pMember->m_ObjID);
}
__LEAVE_FUNCTION
}
// 出队
VOID TeamInfo::DelMember( GUID_t guid )
{
__ENTER_FUNCTION
BOOL bFind = FALSE;
ObjID_t oid;
INT i;
for( i=0; i<m_MemberCount; ++i )
{
if( m_aMember[i].m_GUID == guid )
{
bFind = TRUE;
oid = m_aMember[i].m_ObjID;
break;
}
}
if( bFind )
{
for(;i<m_MemberCount-1; ++i )
{
m_aMember[i] = m_aMember[i+1];
}
m_MemberCount --;
DelSceneMember(oid);
return;
}
return;
__LEAVE_FUNCTION
}
// 任命队长
VOID TeamInfo::Appoint( GUID_t guid )
{
__ENTER_FUNCTION
TEAMMEMBER LM;
BOOL flag = FALSE;
INT i;
for( i=0; i<m_MemberCount; i++ )
{
if( m_aMember[i].m_GUID == guid )
{
LM = m_aMember[i];
flag = TRUE;
break;
}
}
if ( flag )
{
for( ; i>0; --i )
{
m_aMember[i] = m_aMember[i-1];
}
m_aMember[LEADER_ID] = LM;
}
__LEAVE_FUNCTION
}
// 队员开始切换场景
VOID TeamInfo::StartChangeScene( GUID_t guid )
{
__ENTER_FUNCTION
for( INT i=0; i<m_MemberCount; ++i )
{
if( m_aMember[i].m_GUID == guid )
{
if( guid == m_MyGUID )
{ // 自己换场景的情况
m_SceneMemberCount = 0;
m_MySceneID = INVALID_ID;
}
else if( m_aMember[i].m_SceneID == m_MySceneID )
{ // 别人离开场景的情况
DelSceneMember( m_aMember[i].m_ObjID );
}
m_aMember[i].m_SceneID = INVALID_ID;
break;
}
}
EraseFollowedMemberPointer( guid );
__LEAVE_FUNCTION
}
// 队员进入新场景
VOID TeamInfo::EnterScene( GUID_t guid, SceneID_t SceneID, ObjID_t oid )
{
__ENTER_FUNCTION
if ( SceneID == INVALID_ID )
{
Assert(FALSE);
return;
}
if( guid == m_MyGUID )
{ // 自己进入
for( INT i=0; i<m_MemberCount; i++ )
{
if ( m_aMember[i].m_GUID == guid )
{ // 不能 break,因为还要过滤所有同场景玩家
m_aMember[i].m_SceneID = SceneID;
m_aMember[i].m_ObjID = oid;
break;
}
//else if ( m_aMember[i].m_SceneID == SceneID )
//{ // 如果同场景,加入同场景玩家
// AddSceneMember( m_aMember[i].m_ObjID );
//}
}
}
else
{ // 别人进入
for( INT i=0; i<m_MemberCount; i++ )
{
if( m_aMember[i].m_GUID == guid )
{
m_aMember[i].m_SceneID = SceneID;
m_aMember[i].m_ObjID = oid;
if( SceneID == m_MySceneID )
{
AddSceneMember( oid );
}
break;
}
}
}
__LEAVE_FUNCTION
}
// 队友断线
VOID TeamInfo::MemberOffLine( GUID_t guid )
{
__ENTER_FUNCTION
for( INT i=0; i<m_MemberCount; ++i )
{
if( m_aMember[i].m_GUID == guid )
{
if( m_aMember[i].m_SceneID == m_MySceneID )
{
DelSceneMember( m_aMember[i].m_ObjID );
}
m_aMember[i].m_SceneID = INVALID_ID;
break;
}
}
EraseFollowedMemberPointer( guid );
__LEAVE_FUNCTION
}
// 增加一个跟随队员
VOID TeamInfo::AddFollowedMember( const _FOLLOWEDMEMBER& FollowedMember )
{
__ENTER_FUNCTION
GUID_t guid = FollowedMember.m_GUID;
for( INT i=0; i<GetFollowedMembersCount(); ++i )
{
if ( guid == m_FollowedMembers[i].m_GUID )
{ // 更新指针
m_FollowedMembers[i].m_pHuman = FollowedMember.m_pHuman;
return;
}
}
m_FollowedMembers[m_nFollowedMembersCount].m_GUID = guid;
m_FollowedMembers[m_nFollowedMembersCount].m_pHuman = FollowedMember.m_pHuman;
++m_nFollowedMembersCount;
__LEAVE_FUNCTION
}
// 移出某个跟随队员
VOID TeamInfo::DelFollowedMember( GUID_t guid )
{
__ENTER_FUNCTION
for( INT i=0; i<GetFollowedMembersCount(); ++i )
{
if ( guid == m_FollowedMembers[i].m_GUID )
{
for( INT j=i; j<GetFollowedMembersCount()-1; ++j )
{
m_FollowedMembers[j].m_GUID = m_FollowedMembers[j+1].m_GUID;
m_FollowedMembers[j].m_pHuman = m_FollowedMembers[j+1].m_pHuman;
}
m_FollowedMembers[--m_nFollowedMembersCount].CleanUp();
return;
}
}
__LEAVE_FUNCTION
}
// 得到自己跟随的队友
// 返回队列里自己前面最后一个不为空的队友
const Obj_Human* TeamInfo::GetMyGuide() const
{
Obj_Human* pGuide = NULL;
for( INT i=0; i<m_nFollowedMembersCount; ++i )
{
if ( m_FollowedMembers[i].m_pHuman == NULL )
{ // 切换场景
continue;
}
if ( m_FollowedMembers[i].m_GUID == m_MyGUID )
{
break;
}
if( m_FollowedMembers[i].m_pHuman->__IsTeamLeader() )
{// 跟随队长
pGuide = m_FollowedMembers[i].m_pHuman;
}
else
{//跟随处于行走状态的队员
if( m_FollowedMembers[i].m_pHuman->GetCharacterLogic() == CHARACTER_LOGIC_MOVE )
{
pGuide = m_FollowedMembers[i].m_pHuman;
}
}
}
return pGuide;
}
// 得到跟随自己的队友
// 返回队列里自己后面第一个不为空的队友
const Obj_Human* TeamInfo::GetGuideMe() const
{
Obj_Human* pGuide = NULL;
BOOL bFindMe = FALSE;
for( INT i=0; i<m_nFollowedMembersCount; ++i )
{
if ( m_FollowedMembers[i].m_pHuman == NULL )
{ // 切换场景
continue;
}
if( bFindMe )
{
pGuide = m_FollowedMembers[i].m_pHuman;
break;
}
if ( m_FollowedMembers[i].m_GUID == m_MyGUID )
{
bFindMe = TRUE;
}
}
return pGuide;
}
| [
"xiaowave@gmail.com"
] | xiaowave@gmail.com |
23987decf678fe2a1a6cd38cff0ffc41c93ab69f | a1091ad42e6a07b6fbb6fe876feb03547a8da1eb | /MITK-superbuild/MITK-build/Plugins/org.mitk.gui.qt.application/src/moc_QmitkUndoAction.cpp | 7b0ec9b8f7ac4e92f9576ffe37732da6f37e2b74 | [] | no_license | Sotatek-TuyenLuu/DP2 | bc61866fe5d388dd11209f4d02744df073ec114f | a48dd0a41c788981009c5ddd034b0e21644c8077 | refs/heads/master | 2020-03-10T04:59:52.461184 | 2018-04-12T07:19:27 | 2018-04-12T07:19:27 | 129,206,578 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,371 | cpp | /****************************************************************************
** Meta object code from reading C++ file 'QmitkUndoAction.h'
**
** Created by: The Qt Meta Object Compiler version 67 (Qt 5.4.2)
**
** WARNING! All changes made in this file will be lost!
*****************************************************************************/
#include "src/QmitkUndoAction.h"
#include <QtCore/qbytearray.h>
#include <QtCore/qmetatype.h>
#if !defined(Q_MOC_OUTPUT_REVISION)
#error "The header file 'QmitkUndoAction.h' doesn't include <QObject>."
#elif Q_MOC_OUTPUT_REVISION != 67
#error "This file was generated using the moc from 5.4.2. It"
#error "cannot be used with the include files from this version of Qt."
#error "(The moc has changed too much.)"
#endif
QT_BEGIN_MOC_NAMESPACE
struct qt_meta_stringdata_QmitkUndoAction_t {
QByteArrayData data[3];
char stringdata[21];
};
#define QT_MOC_LITERAL(idx, ofs, len) \
Q_STATIC_BYTE_ARRAY_DATA_HEADER_INITIALIZER_WITH_OFFSET(len, \
qptrdiff(offsetof(qt_meta_stringdata_QmitkUndoAction_t, stringdata) + ofs \
- idx * sizeof(QByteArrayData)) \
)
static const qt_meta_stringdata_QmitkUndoAction_t qt_meta_stringdata_QmitkUndoAction = {
{
QT_MOC_LITERAL(0, 0, 15), // "QmitkUndoAction"
QT_MOC_LITERAL(1, 16, 3), // "Run"
QT_MOC_LITERAL(2, 20, 0) // ""
},
"QmitkUndoAction\0Run\0"
};
#undef QT_MOC_LITERAL
static const uint qt_meta_data_QmitkUndoAction[] = {
// content:
7, // revision
0, // classname
0, 0, // classinfo
1, 14, // methods
0, 0, // properties
0, 0, // enums/sets
0, 0, // constructors
0, // flags
0, // signalCount
// slots: name, argc, parameters, tag, flags
1, 0, 19, 2, 0x09 /* Protected */,
// slots: parameters
QMetaType::Void,
0 // eod
};
void QmitkUndoAction::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id, void **_a)
{
if (_c == QMetaObject::InvokeMetaMethod) {
QmitkUndoAction *_t = static_cast<QmitkUndoAction *>(_o);
switch (_id) {
case 0: _t->Run(); break;
default: ;
}
}
Q_UNUSED(_a);
}
const QMetaObject QmitkUndoAction::staticMetaObject = {
{ &QAction::staticMetaObject, qt_meta_stringdata_QmitkUndoAction.data,
qt_meta_data_QmitkUndoAction, qt_static_metacall, Q_NULLPTR, Q_NULLPTR}
};
const QMetaObject *QmitkUndoAction::metaObject() const
{
return QObject::d_ptr->metaObject ? QObject::d_ptr->dynamicMetaObject() : &staticMetaObject;
}
void *QmitkUndoAction::qt_metacast(const char *_clname)
{
if (!_clname) return Q_NULLPTR;
if (!strcmp(_clname, qt_meta_stringdata_QmitkUndoAction.stringdata))
return static_cast<void*>(const_cast< QmitkUndoAction*>(this));
return QAction::qt_metacast(_clname);
}
int QmitkUndoAction::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
_id = QAction::qt_metacall(_c, _id, _a);
if (_id < 0)
return _id;
if (_c == QMetaObject::InvokeMetaMethod) {
if (_id < 1)
qt_static_metacall(this, _c, _id, _a);
_id -= 1;
} else if (_c == QMetaObject::RegisterMethodArgumentMetaType) {
if (_id < 1)
*reinterpret_cast<int*>(_a[0]) = -1;
_id -= 1;
}
return _id;
}
QT_END_MOC_NAMESPACE
| [
"tuyen.luu@sotatek.com"
] | tuyen.luu@sotatek.com |
9cac8d346fa27d12ed032c16f450cdeb9676d827 | 1095cfe2e29ddf4e4c5e12d713bd12f45c9b6f7d | /ext/systemc/src/sysc/utils/sc_vector.cpp | e42fba02e1f2b8dd2c7c3003708e2711226b5f16 | [
"BSD-3-Clause",
"LicenseRef-scancode-proprietary-license",
"LGPL-2.0-or-later",
"MIT",
"Apache-2.0"
] | permissive | gem5/gem5 | 9ec715ae036c2e08807b5919f114e1d38d189bce | 48a40cf2f5182a82de360b7efa497d82e06b1631 | refs/heads/stable | 2023-09-03T15:56:25.819189 | 2023-08-31T05:53:03 | 2023-08-31T05:53:03 | 27,425,638 | 1,185 | 1,177 | BSD-3-Clause | 2023-09-14T08:29:31 | 2014-12-02T09:46:00 | C++ | UTF-8 | C++ | false | false | 5,005 | cpp | /*****************************************************************************
Licensed to Accellera Systems Initiative Inc. (Accellera) under one or
more contributor license agreements. See the NOTICE file distributed
with this work for additional information regarding copyright ownership.
Accellera licenses this file to you 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.
*****************************************************************************/
/*****************************************************************************
sc_vector.cpp - A vector of named (SystemC) objects (modules, ports, channels)
Original Author: Philipp A. Hartmann, OFFIS
CHANGE LOG AT END OF FILE
*****************************************************************************/
#include "sc_vector.h"
#include "sysc/utils/sc_hash.h"
#include "sysc/utils/sc_list.h"
#include "sysc/utils/sc_utils_ids.h"
#include "sysc/kernel/sc_simcontext.h"
#include "sysc/kernel/sc_object_manager.h"
#include <sstream>
namespace sc_core {
sc_vector_base::sc_vector_base()
: sc_object( sc_gen_unique_name("vector") )
, vec_()
, objs_vec_()
{}
std::vector< sc_object* > const &
sc_vector_base::get_elements() const
{
if( !objs_vec_ )
objs_vec_ = new std::vector< sc_object* >;
if( objs_vec_->size() || !size() )
return *objs_vec_;
objs_vec_->reserve( size() );
for( const_iterator it=begin(); it != end(); ++it )
if( sc_object* obj = object_cast(*it) )
objs_vec_->push_back( obj );
return *objs_vec_;
}
sc_object*
sc_vector_base::implicit_cast( ... ) const
{
SC_REPORT_ERROR( SC_ID_VECTOR_NONOBJECT_ELEMENTS_, name() );
return NULL;
}
void
sc_vector_base::check_index( size_type i ) const
{
if( i>=size() )
{
std::stringstream str;
str << name()
<< "[" << i << "] >= size() = " << size();
SC_REPORT_ERROR( SC_ID_OUT_OF_BOUNDS_, str.str().c_str() );
}
}
bool
sc_vector_base::check_init( size_type n ) const
{
if ( !n )
return false;
if( size() ) // already filled
{
std::stringstream str;
str << name()
<< ", size=" << size()
<< ", requested size=" << n;
SC_REPORT_ERROR( SC_ID_VECTOR_INIT_CALLED_TWICE_
, str.str().c_str() );
return false;
}
sc_simcontext* simc = simcontext();
sc_assert( simc == sc_get_curr_simcontext() );
sc_object* parent_p = simc->active_object();
if( parent_p != get_parent_object() )
{
std::stringstream str;
str << name() << ": expected "
<< ( get_parent_object()
? get_parent_object()->name() : "<top-level>" )
<< ", got "
<< ( parent_p ? parent_p->name() : "<top-level>" );
SC_REPORT_ERROR( SC_ID_VECTOR_INIT_INVALID_CONTEXT_
, str.str().c_str() );
return false;
}
return true;
}
void
sc_vector_base::report_empty_bind( const char* kind_, bool dst_empty_ ) const
{
std::stringstream str;
str << "target `" << name() << "' "
<< "(" << kind_ << ") ";
if( !size() ) {
str << "not initialised yet";
} else if ( dst_empty_ ) {
str << "empty range given";
} else {
str << "empty destination range given";
}
SC_REPORT_WARNING( SC_ID_VECTOR_BIND_EMPTY_, str.str().c_str() );
}
std::string
sc_vector_base::make_name( const char* prefix, size_type /* idx */ )
{
// TODO: How to handle name clashes due to interleaved vector
// creation and init()?
// sc_vector< foo > v1, v2;
// v1.name() == "vector", v2.name() == "vector_0"
// v1.init( 1 ); -> v1[0].name() == "vector_0" -> clash
return sc_gen_unique_name( prefix );
}
} // namespace sc_core
// $Log: sc_vector.cpp,v $
// Revision 1.6 2011/08/26 20:46:20 acg
// Andy Goodrich: moved the modification log to the end of the file to
// eliminate source line number skew when check-ins are done.
//
// Revision 1.5 2011/04/01 22:35:19 acg
// Andy Goodrich: spelling fix.
//
// Revision 1.4 2011/03/28 13:03:09 acg
// Andy Goodrich: Philipp's latest update.
//
// Revision 1.3 2011/03/23 16:16:28 acg
// Philipp A. Hartmann: rebase implementation on void*
// - supports virtual inheritance from sc_object again
// - build up get_elements result on demand
// - still requires element type to be derived from sc_object
//
// Revision 1.2 2011/02/14 17:54:25 acg
// Andy Goodrich: Philipp's addition of early bind checks.
//
// Revision 1.1 2011/02/13 21:54:14 acg
// Andy Goodrich: turn on embedding of cvs log records.
// Taf!
| [
"jungma@eit.uni-kl.de"
] | jungma@eit.uni-kl.de |
729ed4a2dcf17a2fec4387729515ed6b29ad040a | d31ed4f3bd9a9d24ff388749c056a0ea6255a76c | /src/platform/window_manager/gl_interface_base.cc | 7a1b2eb62e31599835ce8060d107acd2d333e92a | [
"BSD-3-Clause"
] | permissive | Escapist70/chromiumos | c840e15a4320765acba08e13f20ecc9ec9d108ad | 380301ef6831c966b1389bffe0cd51fcccfcd612 | refs/heads/master | 2021-01-18T12:34:27.303926 | 2010-02-26T21:10:11 | 2010-02-26T21:10:11 | 20,645,371 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,020 | cc | // Copyright (c) 2010 The Chromium OS 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 "window_manager/gl_interface_base.h"
#include <string>
#include <vector>
namespace window_manager {
void GLInterfaceBase::ParseExtensionString(std::vector<std::string>* out,
const char* extensions) {
std::string ext(extensions);
for (std::string::size_type pos = 0; pos != std::string::npos;) {
std::string::size_type last_pos = ext.find_first_of(" ", pos);
out->push_back(ext.substr(pos, last_pos - pos));
pos = ext.find_first_not_of(" ", last_pos);
}
}
bool GLInterfaceBase::HasExtension(const std::vector<std::string>& extensions,
const char* extension) {
for (std::vector<std::string>::const_iterator i = extensions.begin();
i != extensions.end(); ++i) {
if (*i == extension)
return true;
}
return false;
}
}
| [
"kwaters@chromium.org"
] | kwaters@chromium.org |
6a3296f5018b1c92ae55b780c523ca20989400d4 | cb27f51f09b5560b072517e27fdb4313eb04dda0 | /UVA/TaxQuotes.cpp | ab8b39de30e4d909ef6b6b5ac08f65cecd39413f | [
"MIT"
] | permissive | sourav025/coding-algodatastructures | cdc5f796f93567acfdcbb698ec6248347df20e75 | 987932fe0b995c61fc40d1b5a7da18dce8492752 | refs/heads/master | 2022-10-14T02:01:39.275038 | 2020-06-07T06:47:26 | 2020-06-07T06:47:26 | 270,210,442 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 287 | cpp | #include<stdio.h>
#include<string.h>
char ch;
int main()
{
long long i;
while(scanf("%c",&ch)==1)
{
if(ch=='"'){
i++;
if(i%2==1) printf("``");
else if (i%2==0) printf("''");}
else printf("%c",ch);
}
return 0;
}
| [
"sourav.sub25@gmail.com"
] | sourav.sub25@gmail.com |
4ef9e781a926e8565b6712ebe90caf801f38c1f2 | da23117a8fa694addf725194061976ba00cc0ffb | /src/netmessagemaker.h | 2aa7bdf7eed1adda46c8f51308e7e73e7a1dbb2a | [
"MIT"
] | permissive | CrystalizeCity/XaitenCoin | 997d4ed2cb15196cb8ae92ff2e5e9a908550f0e5 | 2f8fa4651d7470b5c589cf502632416e6403ff54 | refs/heads/master | 2023-02-03T12:29:15.651159 | 2020-12-23T06:40:48 | 2020-12-23T06:40:48 | 323,791,184 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,083 | h | // Copyright (c) 2009-2010 Satoshi Nakamoto
// Copyright (c) 2009-2017 The Bitcoin Core developers
// Copyright (c) 2020 The XaitenCoin Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#ifndef BITCOIN_NETMESSAGEMAKER_H
#define BITCOIN_NETMESSAGEMAKER_H
#include <net.h>
#include <serialize.h>
class CNetMsgMaker
{
public:
explicit CNetMsgMaker(int nVersionIn) : nVersion(nVersionIn){}
template <typename... Args>
CSerializedNetMsg Make(int nFlags, std::string sCommand, Args&&... args) const
{
CSerializedNetMsg msg;
msg.command = std::move(sCommand);
CVectorWriter{ SER_NETWORK, nFlags | nVersion, msg.data, 0, std::forward<Args>(args)... };
return msg;
}
template <typename... Args>
CSerializedNetMsg Make(std::string sCommand, Args&&... args) const
{
return Make(0, std::move(sCommand), std::forward<Args>(args)...);
}
private:
const int nVersion;
};
#endif // BITCOIN_NETMESSAGEMAKER_H
| [
"aaron.cai@xaiten.com"
] | aaron.cai@xaiten.com |
6e3e0bc40073681061fb717d10de5577a408e4ca | d6f4058a09be961913842938a03490d2d8f2de5e | /assign3_q2_b.cpp | 01ee2a9256560475df7984ff279d93c36f5d0749 | [] | no_license | rohitchouhan07/CPP | a54703d3e652614406f02523a5e3341d8b4ac4e1 | 3c1997970e21ecd3996866646501b85553ddfa7b | refs/heads/master | 2020-07-04T18:55:00.590534 | 2016-12-02T09:21:47 | 2016-12-02T09:21:47 | 74,149,324 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 238 | cpp | #include <iostream>
using namespace std;
int main()
{
int x,i,p=1;
cout<<"Enter the Number whose factorial is to be found"<<endl;
cin>>x;
i=x;
while (i>0){
p=p*i;
i--;
}
cout<<"The factorial of "<<x<<" is "<<p<<endl;
return 0;
}
| [
"rohitchouhan07@gmail.com"
] | rohitchouhan07@gmail.com |
b957e6d8b97a9bfeb8dc0ca948965bc146a147ca | c5897bbc7dc6a2bb0af0695939cebd38317eb6c1 | /src/gausspoint/gausspoints.h | 144e18da930f18000d87a3b7907d52ed90774446 | [
"MIT"
] | permissive | BelalAmin/sparselizard | f5c89e9abcb42997e3eb457dec2f80fd505ce7a3 | 3950ddf2e10ae7630ef968da823e24a04d0361f0 | refs/heads/master | 2020-06-25T22:27:44.635081 | 2019-07-28T13:23:46 | 2019-07-28T13:23:46 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,209 | h | // sparselizard - Copyright (C) 2017- A. Halbach
//
// See the LICENSE file for license information. Please report all
// bugs and problems to <alexandre.halbach at gmail.com>.
#ifndef GAUSSPOINTS_H
#define GAUSSPOINTS_H
#include <iostream>
#include <vector>
#include <iomanip>
#include "gppoint.h"
#include "gpline.h"
#include "gptriangle.h"
#include "gpquadrangle.h"
#include "gptetrahedron.h"
#include "gphexahedron.h"
#include "gpprism.h"
#include "gppyramid.h"
class gausspoints
{
private:
int myelementtypenumber;
int myintegrationorder;
std::vector<double> mycoordinates;
std::vector<double> myweights;
public:
gausspoints(int elementtypenumber, int integrationorder);
// 'getcoordinates' returns a vector containing the reference
// element coordinates of the Gauss points in the format
// [kigp1 etagp1 phigp1 kigp2 ...].
std::vector<double> getcoordinates(void) { return mycoordinates; };
std::vector<double> getweights(void) { return myweights; };
int count(void) { return myweights.size(); };
void print(void);
};
#endif
| [
"alexandre.halbach@gmail.com"
] | alexandre.halbach@gmail.com |
974cf2fcf2608cb371f6244322b961317aaeea87 | 119ba245bea18df8d27b84ee06e152b35c707da1 | /unreal/branches/robots/qrgui/interpreters/robots/details/robotImplementations/sensorImplementations/nullSensorImplementation.cpp | 443afd49a2f1a210316f29083207ce36cbd78dee | [] | no_license | nfrey/qreal | 05cd4f9b9d3193531eb68ff238d8a447babcb3d2 | 71641e6c5f8dc87eef9ec3a01cabfb9dd7b0e164 | refs/heads/master | 2020-04-06T06:43:41.910531 | 2011-05-30T19:30:09 | 2011-05-30T19:30:09 | 1,634,768 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 491 | cpp | #include "nullSensorImplementation.h"
using namespace qReal::interpreters::robots;
using namespace details::robotImplementations::sensorImplementations;
NullSensorImplementation::NullSensorImplementation(inputPort::InputPortEnum const &port)
: AbstractSensorImplementation(port)
{
mActiveWaitingTimer.setInterval(100);
connect(&mActiveWaitingTimer, SIGNAL(timeout()), this, SLOT(timerTimeout()));
}
void NullSensorImplementation::read()
{
mActiveWaitingTimer.start();
}
| [
"ololo@ololo.org"
] | ololo@ololo.org |
cb28cf073e3fa00434f292c06a1b702f8b243c60 | 307641f2c4fd6e59f0a3a8d946d81e3b8e6e44a9 | /src/EtabliDAlchimiste.h | 5985de5631ee764e8561882634163080a8d2e873 | [] | no_license | asdlei99/PatateQuest | 9a2407723b9f99c39a05b487e5147c15104b669b | 9a226e063b8928d11048d799d17483586938e995 | refs/heads/master | 2020-08-21T11:35:15.478229 | 2016-08-06T14:44:05 | 2016-08-06T14:44:05 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 188 | h | #pragma once
#include "Entity.h"
class EtabliDAlchimiste final : public Entity
{
public:
EtabliDAlchimiste(const Point& position = {0, 0}, Direction direction = Direction::Front);
};
| [
"daivuk@gmail.com"
] | daivuk@gmail.com |
5070f706384f1b4397829538cd91c827d6f1755f | 80fda55e349f79ded19ab5176c90c99ec3e1c272 | /contests/abc/15/150/a.cpp | b9a629b963fb69c55296ff1ff13ca5c58547af5b | [] | no_license | naoto0804/atcoder_practice | 6b161e36eb25ba26ac715caee99364c2bf9fc95f | 0416b8f45bd36e4ea307a13e3860e40cd7b9f94b | refs/heads/master | 2021-07-19T21:42:10.946063 | 2021-07-05T01:33:31 | 2021-07-05T01:33:31 | 250,864,437 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 867 | cpp | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG
/**
* For DEBUG
* https://github.com/ta7uw/cpp-pyprint
*/
#include "cpp-pyprint/pyprint.h"
#endif
void Main() {
ll K, X; cin >> K >> X;
string ans = (500 * K >= X) ? "Yes" : "No";
cout << ans << endl;
}
int main() {
cin.tie(nullptr);
ios::sync_with_stdio(false);
cout << fixed << setprecision(15);
Main();
return 0;
}
| [
"kingfisher0804@gmail.com"
] | kingfisher0804@gmail.com |
67f356f638b688cb8fb343646df4aa1b35624b51 | e5cb73f25dde3e5c0ac63d7dafae8918cc4b8784 | /Lecture-3/Pattern.cpp | 22e4d93359ce6298c72746dedaa6bee2db2496c1 | [] | no_license | Aryanmehta21/CPP_YT | a60c5cab907f4bb9f185ae547829eeabd30f984a | fe45221bfe89262b679c0e52175aa5dab4b64eb5 | refs/heads/main | 2022-12-30T20:07:53.898934 | 2020-10-17T14:22:11 | 2020-10-17T14:22:11 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 584 | cpp | // Pattern
#include <iostream>
using namespace std;
int main(){
int n,i,no;
cin>>n;
int row = 1;
while(row<=n){
// 1. print spaces n-row times
i = 1;
while(i<=n-row){
cout<<' ';
i = i+1;
}
// 2. print increasing numbers starting from row, do this task row times
i = 1,no=row;
while(i<=row){
cout<<no;
no = no+1;
i = i +1;
}
// 3. print decresing numbers starting from 2*row-2, do this task (row-1)times
i = 1,no=2*row-2;
while(i<=row-1){
cout<<no;
no = no-1;
i = i +1;
}
row = row+1;
cout<<endl;
}
cout<<endl;
return 0;
} | [
"kartik.mathur10@gmail.com"
] | kartik.mathur10@gmail.com |
b7374a3456b9888a754450f1778e7add721ffcfd | f3e394c27d222b025579886a7e6d005021d3517b | /EntityRenderer.cpp | 28f505919ebcc7416fa233b722b120cec61e8328 | [] | no_license | JosteinE/TheGatherer | f82c858338faba75251596eab01a7b497c6e1c86 | b72dcde7aeff216dcb45ae3e2a0d24150050892b | refs/heads/master | 2022-06-08T23:22:47.385247 | 2020-04-01T10:33:02 | 2020-04-01T10:33:02 | 233,863,527 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,026 | cpp | #include "EntityRenderer.h"
#include "Entity.h"
#include "CircleShapeComponent.h"
#include "RectangleShapeComponent.h"
#include "SpriteComponent.h"
#include "HUDComponent.h"
#include "GeneralDataComponent.h"
EntityRenderer::EntityRenderer()
{
}
EntityRenderer::~EntityRenderer()
{
}
void EntityRenderer::setLightPosition(sf::Shader * shader, Entity * inEntity)
{
shader->setUniform("lightPos", inEntity->mGeneralDataComponent->position.toSf());
}
void EntityRenderer::drawEntity(sf::RenderTarget & target, sf::Shader * shader, Entity * inEntity)
{
if (inEntity->mCircleShapeComponent != nullptr)
target.draw(*inEntity->mCircleShapeComponent->mShape, shader);
if (inEntity->mRectangleShapeComponent != nullptr)
target.draw(*inEntity->mRectangleShapeComponent->mShape, shader);
if (inEntity->mSpriteComponent != nullptr)
target.draw(*inEntity->mSpriteComponent->mSprite, shader);
if (inEntity->mHUDComponent != nullptr)
for (HUDComponent* hudComp : *inEntity->mHUDComponent)
target.draw(hudComp->mText);
}
| [
"Josteineri@hotmail.com"
] | Josteineri@hotmail.com |
fe9c8ea582566b147fd6f5f910ce8953869a2d1e | f508c2957117084a2a6c3691afca7a7865e1193f | /ShapeBrush/src/ofApp.cpp | 119204d06de2add59acb79d1f42d0dc5880e312a | [] | no_license | mr-z-ro/openframeworks | 573a7afb6ef5398d3a507ca0602ee0960067cc5f | 88264d224f06959b9af34a56608c51df5fabced7 | refs/heads/master | 2020-05-20T10:31:30.628588 | 2019-05-08T04:19:20 | 2019-05-08T04:19:20 | 185,527,263 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,990 | cpp | #include "ofApp.h"
//--------------------------------------------------------------
void ofApp::setup(){
ofSetBackgroundAuto(false);
ofSetBackgroundColor(0);
ofSetFrameRate(60);
ofEnableAlphaBlending();
}
//--------------------------------------------------------------
void ofApp::update(){
}
//--------------------------------------------------------------
void ofApp::draw(){
if (ofGetMousePressed(OF_MOUSE_BUTTON_LEFT)) {
// Rectangle Brush
// ofSetRectMode(OF_RECTMODE_CENTER);
//
// int numRecs = 10;
// for (int i=0; i<numRecs; i++) {
// ofSetColor(ofRandom(50, 255));
// float width = ofRandom(5, 20);
// float height = ofRandom(5, 20);
// float distance = ofRandom(30);
// float angle = ofRandom(ofDegToRad(360.0));
// float xOffset = distance * cos(angle);
// float yOffset = distance * sin(angle);
// ofDrawRectangle(ofGetMouseX()+xOffset, ofGetMouseY()+yOffset, width, height);
// }
// Circle Brush
// int maxRadius = 30;
// int radiusStepSize = 1;
// int alpha = 3;
// int maxOffsetDistance = 100;
// for (int r=maxRadius; r>0; r-=radiusStepSize) {
// float angle = ofRandom(ofDegToRad(360.0));
// float distance = ofRandom(maxOffsetDistance);
// float xOffset = distance * cos(angle);
// float yOffset = distance * sin(angle);
// ofColor myBlue(0, 103, 255, alpha);
// ofColor myGreen(0, 255, 103, alpha);
// ofColor inBetween = myBlue.getLerped(myGreen, ofRandom(1.0));
// ofSetColor(inBetween);
// ofDrawCircle(ofGetMouseX()+xOffset, ofGetMouseY()+yOffset, r);
// }
// Line Brush
// int numLines = 30;
// int minRadius = 25;
// int maxRadius = 125;
// for (int i=0; i<numLines; i++) {
// float angle = ofRandom(ofDegToRad(360.0));
// float distance = ofRandom(minRadius, maxRadius);
// float xOffset = cos(angle) * distance;
// float yOffset = sin(angle) * distance;
// float alpha = ofMap(distance, minRadius, maxRadius, 50, 0); // Make shorter lines more opaque
// ofSetColor(255, alpha);
// ofDrawLine(ofGetMouseX(), ofGetMouseY(), ofGetMouseX()+xOffset, ofGetMouseY()+yOffset);
// }
// Triangle Brush
int numTriangles = 10;
int minOffset = 5;
int maxOffset = 40;
int alpha = 50;
for (int t=0; t<numTriangles; t++) {
float offsetDistance = ofRandom(minOffset, maxOffset);
ofVec2f mousePos(ofGetMouseX(), ofGetMouseY());
ofVec2f p1(0, 3);
ofVec2f p2(30, 0);
ofVec2f p3(0, -3);
float rotation = ofRandom(360);
p1.rotate(rotation);
p2.rotate(rotation);
p3.rotate(rotation);
ofVec2f triangleOffset(offsetDistance, 0.0);
triangleOffset.rotate(rotation);
p1 += mousePos + triangleOffset;
p2 += mousePos + triangleOffset;
p3 += mousePos + triangleOffset;
ofColor myBlue(0, 103, 255, alpha);
ofColor myGreen(0, 255, 103, alpha);
ofColor inBetween = myBlue.getLerped(myGreen, ofRandom(1.0));
ofSetColor(inBetween);
ofDrawTriangle(p1, p2, p3);
}
}
if (ofGetMousePressed(OF_MOUSE_BUTTON_RIGHT)) {
ofBackground(0);
}
}
//--------------------------------------------------------------
void ofApp::keyPressed(int key){
if (key == 's') {
ofSaveScreen("ofScreenshot_" + ofGetTimestampString() + ".png");
}
}
//--------------------------------------------------------------
void ofApp::keyReleased(int key){
}
//--------------------------------------------------------------
void ofApp::mouseMoved(int x, int y ){
}
//--------------------------------------------------------------
void ofApp::mouseDragged(int x, int y, int button){
}
//--------------------------------------------------------------
void ofApp::mousePressed(int x, int y, int button){
}
//--------------------------------------------------------------
void ofApp::mouseReleased(int x, int y, int button){
}
//--------------------------------------------------------------
void ofApp::mouseEntered(int x, int y){
}
//--------------------------------------------------------------
void ofApp::mouseExited(int x, int y){
}
//--------------------------------------------------------------
void ofApp::windowResized(int w, int h){
}
//--------------------------------------------------------------
void ofApp::gotMessage(ofMessage msg){
}
//--------------------------------------------------------------
void ofApp::dragEvent(ofDragInfo dragInfo){
}
| [
"msgrasser@gmail.com"
] | msgrasser@gmail.com |
7ba3679f34217d32dd2b06e870a62ecc6a921617 | 073d693d3369e41a29f842c0b153241e47e1b2ac | /src/moneysupply.h | d5452ba0e458fcbb6d0652bf46887bd867fd65ce | [
"MIT"
] | permissive | robervem/sbercoin | 2a7984a7d77a63c51957e9b8b6df6bc759925d2e | ba61e50fab7e3b15e39a9cbe3a7adf08cab96d39 | refs/heads/main | 2023-02-09T21:16:56.425759 | 2021-01-07T20:09:19 | 2021-01-07T20:09:19 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 849 | h | // Copyright (c) 2020 The SBER developers
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or https://www.opensource.org/licenses/mit-license.php.
#ifndef SBER_MONEYSUPPLY_H
#define SBER_MONEYSUPPLY_H
#include "amount.h"
#include "sync.h"
/*
* Class used to cache the sum of utxo's values
*/
class CMoneySupply {
private:
mutable RecursiveMutex cs;
CAmount nSupply;
// height of the chain when the supply was last updated
int64_t nHeight;
public:
CMoneySupply(): nSupply(0), nHeight(0) {}
void Update(const CAmount& _nSupply, int _nHeight)
{
LOCK(cs);
nSupply = _nSupply;
nHeight = _nHeight;
}
CAmount Get() const { LOCK(cs); return nSupply; }
int64_t GetCacheHeight() const { LOCK(cs); return nHeight; }
};
#endif // SBER_MONEYSUPPLY_H
| [
"k.arya2946@gmail.com"
] | k.arya2946@gmail.com |
958b6503c885ea489de2d3f05bf8863f718175d2 | d7ef1300dc1b4d6174788605bf2f19ece12a1708 | /other/old_scripts/scripts/testyo.cxx | 544c5b18db7347b97f87c4043dcc6e78ec88db12 | [] | no_license | libov/zeus | 388a2d49eb83f098c06008cb23b6ab42ae42e0e5 | a0ca857ede59c74cace29924503d78670e10fe7b | refs/heads/master | 2021-01-01T05:51:48.516178 | 2014-12-03T09:14:02 | 2014-12-03T09:14:02 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 169 | cxx | int main()
{
//TF1 *fpol=new TF1("fpol","pol0",0.99,4);
TF1 *fpol=new TF1("fpol","landau(0)",0.99,10);
fpol->SetParameters(100,5,1);
fpol->Draw("pl");
return 0;
}
| [
"libov@mail.desy.de"
] | libov@mail.desy.de |
1fb2191f0be19fd102b3b06f1b2ae69ddc07b76f | 32a6f8ed1a7747854e0414f1ddbfe5cb26e2bdc4 | /1355B.cpp | bbac445a402a5eb3358013313ec655afa0ae378a | [] | no_license | VenkatSBitra/codeforcesproblemset | f38f7822b106248ec8cd399309b831af5f7611ae | fe8af9a5dc3fb14584c0b8ff0d1a844005494ac0 | refs/heads/master | 2022-07-28T01:55:04.811823 | 2020-05-18T14:59:29 | 2020-05-18T14:59:29 | 264,941,604 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 517 | cpp | #include <bits/stdc++.h>
using namespace std;
int main(){
int n; cin >> n;
while(n--){
int k; cin >> k;
vector<int> v;
for(int i = 0; i < k; i++){
int t; cin >> t;
v.push_back(t);
}
sort(v.begin(), v.end());
int i = 0, grp = 0, cs = 0;
while(i < v.size()){
cs++;
if(v[i] <= cs){
grp++;
cs = 0;
}
i++;
}
cout << grp << endl;
}
} | [
"venkat.suprabath@iiitb.org"
] | venkat.suprabath@iiitb.org |
2efeb1db6ffa2be2cf747ecd9474b3cc379bcb4b | 4fe6b129a2f415b22f1c8752169b56daf8551e23 | /Aligner/TiltFlatnessTestPage2.h | 6923cb9995c41a03c940511750c6a65813def2b7 | [] | no_license | Kingarne/Aligner308MK3 | 1821d6ce9a8cd6d3e6def31bb43cd0c37b43fe1e | 04adc7e1ca1e97e2b4165c626dd73f095ad77c93 | refs/heads/master | 2023-08-31T05:48:52.441714 | 2023-08-21T13:14:32 | 2023-08-21T13:14:32 | 207,835,311 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 905 | h | // $Id: TiltFlatnessTestPage2.h,v 1.1 2009/10/14 08:09:25 riar Exp $
//
// Copyright (C) Shill Reglerteknik AB 2002
#pragma once
#include "resource.h"
class CTiltFlatnessTestWizard ;
class CTiltFlatnessTestPage2 : public CPropertyPage
{
friend class CTiltFlatnessTestWizard;
friend class CTiltFlatnessTestPage1;
friend class CTiltFlatnessTestPage3;
DECLARE_DYNAMIC(CTiltFlatnessTestPage2)
private:
CTiltFlatnessTestWizard* m_pParent;
CString m_MsgCaption;
CString m_Text;
public:
CTiltFlatnessTestPage2();
virtual ~CTiltFlatnessTestPage2();
// Dialog Data
enum { IDD = IDD_TILT_FLATNESS_TEST_PAGE_2 };
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
BOOL OnInitDialog();
BOOL OnSetActive();
BOOL OnQueryCancel();
LRESULT OnWizardBack();
LRESULT OnWizardNext();
void OnReset();
void InitMeasureParam();
DECLARE_MESSAGE_MAP()
};
| [
"riar@now.se"
] | riar@now.se |
c2ed6af50f334917ca56e9a1e847e9be76041d29 | 54f352a242a8ad6ff5516703e91da61e08d9a9e6 | /Source Codes/CodeJamData/17/04/18.cpp | e11f88adc1fd7910efe51f0a99edd9c08ab53c79 | [] | no_license | Kawser-nerd/CLCDSA | 5cbd8a4c3f65173e4e8e0d7ed845574c4770c3eb | aee32551795763b54acb26856ab239370cac4e75 | refs/heads/master | 2022-02-09T11:08:56.588303 | 2022-01-26T18:53:40 | 2022-01-26T18:53:40 | 211,783,197 | 23 | 9 | null | null | null | null | UTF-8 | C++ | false | false | 2,880 | cpp | #include <iostream>
#include <iomanip>
#include <string>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <ctime>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <utility>
#include <complex>
using namespace std;
typedef long long ll;
typedef double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef complex<ll> pt;
bool maze_rc[1<<7][1<<7];
bool maze_diag[1<<7][1<<7];
bool modified[1<<7][1<<7];
bool done_r[1<<8];
bool done_c[1<<8];
bool done_dp[1<<8];
bool done_dm[1<<8];
int offset = (1<<7);
int main(){
int tt; cin >> tt;
for (int zz = 1; zz <= tt; zz++){
int n, m; cin >> n >> m;
memset(maze_rc, false, sizeof(maze_rc));
memset(maze_diag, false, sizeof(maze_diag));
memset(modified, false, sizeof(modified));
memset(done_r, false, sizeof(done_r));
memset(done_c, false, sizeof(done_c));
memset(done_dp, false, sizeof(done_dp));
memset(done_dm, false, sizeof(done_dm));
int score = 0;
int mod_cnt = 0;
for (int i = 0; i < m; i++){
char c; int r,s;
cin >> c >> r >> s;
if (c == 'o' || c == 'x'){
maze_rc[r][s] = true;
done_r[r] = true;
done_c[s] = true;
score++;
}
if (c == 'o' || c == '+'){
maze_diag[r][s] = true;
done_dp[r+s] = true;
done_dm[r-s+offset] = true;
score++;
}
}
for (int i = 1; i <= n; i++){
if (done_r[i]) continue;
for (int j = 1; j <= n; j++){
if (!done_c[j]){
maze_rc[i][j] = true;
done_r[i] = true;
done_c[j] = true;
if (!modified[i][j]) mod_cnt++;
modified[i][j] = true;
score++;
break;
}
}
}
for (int i = 2; i <= 2*n; i++){
if (done_dp[i]) continue;
int ma;
if (i <= n+1) ma = i-2;
else ma = 2*n-i;
for (int j = ma; j >= 0; j-=2){
if (!done_dm[offset+j]){
int r = (i+j)/2;
int s = (i-j)/2;
maze_diag[r][s] = true;
done_dp[i] = true;
done_dm[offset+j] = true;
if (!modified[r][s]) mod_cnt++;
modified[r][s] = true;
score++;
break;
}
else if (!done_dm[offset-j]){
int r = (i-j)/2;
int s = (i+j)/2;
maze_diag[r][s] = true;
done_dp[i] = true;
done_dm[offset-j] = true;
if (!modified[r][s]) mod_cnt++;
modified[r][s] = true;
score++;
break;
}
}
}
cout << "Case #" << zz << ": " << score << " " << mod_cnt << endl;
for (int i = 1; i <= n; i++)
for (int j = 1; j <= n; j++)
if (modified[i][j]){
if (maze_rc[i][j] && maze_diag[i][j]) cout << 'o';
else if (maze_rc[i][j]) cout << 'x';
else if (maze_diag[i][j]) cout << '+';
cout << " " << i << " " << j << endl;
}
}
return 0;
}
| [
"kwnafi@yahoo.com"
] | kwnafi@yahoo.com |
b119d3da37ce1539b133f7046e66307ed9ce1b11 | df6d96ba17dc9765770f587a1e04d9880925b2f8 | /src/mntMatMxN.cpp | a27fbc7bcb587afd9de0f9f335b6db32c9dba9b6 | [
"0BSD"
] | permissive | pletzer/mint | 300c7e460453afba3fae4ccc8d04e12bf48341d3 | 50c2c66bce5e09cf14f9f244da67ab4be84fbe5b | refs/heads/master | 2023-08-08T08:38:20.361042 | 2023-07-31T07:18:37 | 2023-07-31T07:18:37 | 130,304,591 | 6 | 4 | 0BSD | 2023-07-31T07:18:38 | 2018-04-20T03:36:44 | C++ | UTF-8 | C++ | false | false | 3,005 | cpp | #include <mntMatMxN.h>
template<std::size_t M, std::size_t K, std::size_t N, class T>
MatMxN<M, N, T> dot(const MatMxN<M, K, T> &a, const MatMxN<K, N, T> &b) {
MatMxN<M, N, T> res( static_cast<T>(0) );
for (std::size_t j = 0; j < N; ++j) {
for (std::size_t i = 0; i < M; ++i) {
for (std::size_t k = 0; k < K; ++k) {
res(i, j) += a(i, k) * b(k, j);
}
}
}
return res;
}
template<std::size_t M, std::size_t N, class T>
VecN<M, T> dot(const MatMxN<M, N, T> &a, const VecN<N, T> &b) {
VecN<M, T> res( static_cast<T>(0) );
for (std::size_t i = 0; i < M; ++i) {
for (std::size_t j = 0; j < N; ++j) {
res[i] += a(i, j) * b[j];
}
}
return res;
}
template<std::size_t M, std::size_t N, class T>
VecN<N, T> dot(const VecN<M, T> &b, const MatMxN<M, N, T> &a) {
VecN<N, T> res( static_cast<T>(0) );
for (std::size_t j = 0; j < N; ++j) {
for (std::size_t i = 0; i < M; ++i) {
res[j] += b[i] * a(i, j);
}
}
return res;
}
template<std::size_t M, std::size_t N, class T>
MatMxN<N, M, T> transpose(const MatMxN<M, N, T> &a) {
MatMxN<N, M, T> res;
for (std::size_t j = 0; j < N; ++j) {
for (std::size_t i = 0; i < M; ++i) {
res(j, i) = a(i, j);
}
}
return res;
}
// template instantiations
template class MatMxN<2, 2, double>;
template class MatMxN<2, 3, double>;
template class MatMxN<3, 2, double>;
template class MatMxN<3, 3, double>;
template VecN<2, double> dot(const MatMxN<2, 2, double> &a, const VecN<2, double> &b);
template VecN<2, double> dot(const MatMxN<2, 3, double> &a, const VecN<3, double> &b);
template VecN<3, double> dot(const MatMxN<3, 2, double> &a, const VecN<2, double> &b);
template VecN<3, double> dot(const MatMxN<3, 3, double> &a, const VecN<3, double> &b);
template VecN<2, double> dot(const VecN<2, double> &a, const MatMxN<2, 2, double> &b);
template VecN<3, double> dot(const VecN<2, double> &a, const MatMxN<2, 3, double> &b);
template VecN<2, double> dot(const VecN<3, double> &a, const MatMxN<3, 2, double> &b);
template VecN<3, double> dot(const VecN<3, double> &a, const MatMxN<3, 3, double> &b);
template MatMxN<2, 2, double> dot(const MatMxN<2, 2, double> &a, const MatMxN<2, 2, double> &b);
template MatMxN<2, 2, double> dot(const MatMxN<2, 3, double> &a, const MatMxN<3, 2, double> &b);
template MatMxN<2, 3, double> dot(const MatMxN<2, 2, double> &a, const MatMxN<2, 3, double> &b);
template MatMxN<2, 3, double> dot(const MatMxN<2, 3, double> &a, const MatMxN<3, 3, double> &b);
template MatMxN<3, 3, double> dot(const MatMxN<3, 3, double> &a, const MatMxN<3, 3, double> &b);
template MatMxN<2, 2, double> transpose(const MatMxN<2, 2, double> &a);
template MatMxN<3, 2, double> transpose(const MatMxN<2, 3, double> &a);
template MatMxN<2, 3, double> transpose(const MatMxN<3, 2, double> &a);
template MatMxN<3, 3, double> transpose(const MatMxN<3, 3, double> &a);
| [
"alexander@gokliya.net"
] | alexander@gokliya.net |
af6fb0071f5ad75ea34675c9640e58a801eb5dfa | df3e2ff866d92846a0a566a62ba21ac0643bbd31 | /Server/userlist.h | 7d28c514a55b7dcc2c9725df8789299f3b8d49a0 | [] | no_license | Psychim/Group5Pro | 49073ee69f396d8bb9f66eae8332ceb549c18954 | 083756def17165ac196dc167399b137ae841f3da | refs/heads/master | 2020-04-18T21:01:41.247025 | 2018-03-17T13:58:59 | 2018-03-17T13:58:59 | 67,047,574 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 486 | h | #ifndef USERLIST_H
#define USERLIST_H
#include <QObject>
#include<QList>
#include "user.h"
class UserList : public QObject
{
Q_OBJECT
public:
explicit UserList(QObject *parent = 0);
User * searchByID(int ID);
User * searchByIP(QString);
bool insertByID(User *);
User * removeAt(int);
User * removeByID(int);
bool isEmpty();
int size();
User * operator[] (int);
private:
QList<User *> users;
signals:
public slots:
};
#endif // USERLIST_H
| [
"604315924@qq.com"
] | 604315924@qq.com |
02d1ccaa751c1a1d27a4fa1c9bee9a9e58ccefeb | ac4324b6ee390eadec5c487d5dbdc7964aad3909 | /mpi_mmul_test/CreateMatrix.cc | e0793ea2d2f63e6f4cb2e7c9938697a6f8e8ae61 | [] | no_license | UPPMAX/benchmark-codes | e97f30a365ca0339f6af92f02f3253da9f5a1b78 | 18aa3d7a4e111ad0833a308e703616f7c6a3f34b | refs/heads/master | 2021-01-13T09:38:14.707602 | 2016-11-28T16:50:33 | 2016-11-28T16:50:33 | 72,021,673 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,514 | cc | #include "CreateMatrix.h"
#include "CreateMatrixFromIds.h"
#include "MatrixElementValues.h"
#include <cmath>
CHT_TASK_TYPE_IMPLEMENTATION((CreateMatrix));
cht::ID CreateMatrix::execute(CInt const & matSize,
CInt const & baseIdx1,
CInt const & baseIdx2,
CInt const & matType) {
int n = matSize;
if(n <= CMatrix::BLOCK_SIZE) {
// Lowest level
CMatrix* A = new CMatrix();
A->n = n;
A->elements.resize(n*n);
for(int i = 0; i < n; i++)
for(int j = 0; j < n; j++) {
int idx1 = baseIdx1 + i;
int idx2 = baseIdx2 + j;
A->elements[i*matSize+j] = matElementFunc(matType, idx1, idx2);
}
return registerChunk(A, cht::persistent);
}
else {
// Not lowest level
if(matSize % 2 != 0)
throw std::runtime_error("Error in CreateMatrix::execute: matSize not divisible by 2.");
int nHalf = matSize / 2;
cht::ChunkID cid_nHalf = registerChunk( new CInt(nHalf) );
cht::ID childTaskIDs[4];
for(int i1 = 0; i1 < 2; i1++) {
cht::ChunkID cid_baseIdx_i1 = registerChunk( new CInt(baseIdx1+i1*nHalf) );
for(int i2 = 0; i2 < 2; i2++) {
cht::ChunkID cid_baseIdx_i2 = registerChunk( new CInt(baseIdx2+i2*nHalf) );
childTaskIDs[i1*2+i2] = registerTask<CreateMatrix>(cid_nHalf, cid_baseIdx_i1, cid_baseIdx_i2, getInputChunkID(matType));
}
}
return registerTask<CreateMatrixFromIds>(getInputChunkID(matSize), childTaskIDs[0], childTaskIDs[1], childTaskIDs[2], childTaskIDs[3], cht::persistent);
}
} // end execute
| [
"eliasrudberg@gmail.com"
] | eliasrudberg@gmail.com |
60958da4d195512042e7cf60790e83d4fe3264f3 | d87e36e4bc70788eac1474607185ce79838d5358 | /week-02/day-2/11/11.cpp | 68367d609601c548facac04223015f84823b7530 | [] | no_license | greenfox-zerda-sparta/korompaidani | 0e5a3a580658a35c3245da3046bb86544a8b842f | ead60c4d18dd0feba9a0e49758dffdba8ffa3bda | refs/heads/master | 2021-01-12T18:15:09.459661 | 2017-03-31T09:41:51 | 2017-03-31T09:41:51 | 71,350,705 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 273 | cpp | #include <iostream>
#include <string>
using namespace std;
string enda (string e){
return e+"a";
}
int main() {
string k = "kuty";
// write a function that gets a string as an input
// and appends an 'a' character to its end
cout << enda(k);
return 0;
}
| [
"korompaidani@gmail.com"
] | korompaidani@gmail.com |
02bf7128e6e33495a37b1c7aba14fa79e2c514c6 | 7024b8eb4554ec04b2b0860d979cfa30b95c4096 | /dependencies/include/newton/customJoints/NewtonCustomJoint.cpp | a17c1db328b2e80b550de98a4126ec024ca35609 | [] | no_license | BigEvilCorporation/symmetry | 9e189385c4f16d875c3b85c0c1e7a156893d5cd5 | cc7fa534482cf60c52af86c2b3477091962036a2 | refs/heads/master | 2020-11-26T02:10:37.964057 | 2019-12-19T15:38:51 | 2019-12-19T15:38:51 | 228,932,800 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,422 | cpp | //********************************************************************
// Newton Game dynamics
// copyright 2000-2004
// By Julio Jerez
// VC: 6.0
// simple demo list vector class with iterators
//********************************************************************
// NewtonCustomJoint.cpp: implementation of the NewtonCustomJoint class.
//
//////////////////////////////////////////////////////////////////////
#include "CustomJointLibraryStdAfx.h"
#include "NewtonCustomJoint.h"
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
NewtonCustomJoint::NewtonCustomJoint ()
{
}
NewtonCustomJoint::NewtonCustomJoint (
int maxDOF,
const NewtonBody* body0,
const NewtonBody* body1)
{
Init (maxDOF, body0, body1);
}
NewtonCustomJoint::~NewtonCustomJoint()
{
//_ASSERTE (m_joint);
//if the joint has user data it means the application is destroy the joint
if (NewtonJointGetUserData (m_joint)) {
// set the joint call to NULL to prevent infinite recursion
NewtonJointSetDestructor (m_joint, NULL);
// destroy this joint
NewtonDestroyJoint(m_world, m_joint);
}
}
void NewtonCustomJoint::Init (int maxDOF, const NewtonBody* body0, const NewtonBody* body1)
{
m_rtti = 0;
m_joint = NULL;
m_body0 = body0;
m_body1 = body1;
m_maxDox = maxDOF;
m_world = NewtonBodyGetWorld (body0);
m_joint = NewtonConstraintCreateUserJoint (m_world, maxDOF, SubmitConstrainst, GetInfo, m_body0, m_body1);
NewtonJointSetUserData (m_joint, this);
NewtonJointSetDestructor (m_joint, Destructor);
}
int NewtonCustomJoint::GetJointID () const
{
return m_rtti;
}
void NewtonCustomJoint::SetJointID (int rtti)
{
m_rtti = rtti;
}
const NewtonBody* NewtonCustomJoint::GetBody0 () const
{
return m_body0;
}
const NewtonBody* NewtonCustomJoint::GetBody1 () const
{
return m_body1;
}
void NewtonCustomJoint::Destructor (const NewtonJoint* me)
{
NewtonCustomJoint* joint;
// get the pointer to the joint class
joint = (NewtonCustomJoint*) NewtonJointGetUserData (me);
// set the joint call to NULL to prevent infinite recursion
NewtonJointSetDestructor (me, NULL);
NewtonJointSetUserData (me, NULL);
// delete the joint class
delete joint;
}
void NewtonCustomJoint::SubmitConstrainst (const NewtonJoint* me, dFloat timestep, int threadIndex)
{
NewtonCustomJoint* joint;
// get the pointer to the joint class
joint = (NewtonCustomJoint*) NewtonJointGetUserData (me);
joint->SubmitConstrainst(timestep, threadIndex);
}
void NewtonCustomJoint::GetInfo (const NewtonJoint* me, NewtonJointRecord* info)
{
NewtonCustomJoint* joint;
// get the pointer to the joint class
joint = (NewtonCustomJoint*) NewtonJointGetUserData (me);
joint->GetInfo(info);
}
void NewtonCustomJoint::CalculateLocalMatrix (const dMatrix& pinsAndPivotFrame, dMatrix& localMatrix0, dMatrix& localMatrix1) const
{
// _ASSERTE (0);
dMatrix matrix0;
// Get the global matrices of each rigid body.
NewtonBodyGetMatrix(m_body0, &matrix0[0][0]);
dMatrix matrix1 (GetIdentityMatrix());
if (m_body1) {
NewtonBodyGetMatrix(m_body1, &matrix1[0][0]);
}
// create a global matrix at the pivot point with front vector aligned to the pin vector
// dMatrix pinAndPivotMatrix (dgGrammSchmidt(dir)); //
// pinAndPivotMatrix.m_posit = pivot;
// pinAndPivotMatrix.m_posit.m_w = 1.0f;
_ASSERTE (pinsAndPivotFrame.SanityCheck());
// calculate the relative matrix of the pin and pivot on each body
localMatrix0 = pinsAndPivotFrame * matrix0.Inverse();
localMatrix1 = pinsAndPivotFrame * matrix1.Inverse();
}
void NewtonCustomJoint::CalculateGlobalMatrix (const dMatrix& localMatrix0, const dMatrix& localMatrix1, dMatrix& matrix0, dMatrix& matrix1) const
{
dMatrix body0Matrix;
// Get the global matrices of each rigid body.
NewtonBodyGetMatrix(m_body0, &body0Matrix[0][0]);
dMatrix body1Matrix (GetIdentityMatrix());
if (m_body1) {
NewtonBodyGetMatrix(m_body1, &body1Matrix[0][0]);
}
matrix0 = localMatrix0 * body0Matrix;
matrix1 = localMatrix1 * body1Matrix;
}
void NewtonCustomJoint::GetInfo (NewtonJointRecord* info) const
{
_ASSERTE (0);
}
void NewtonCustomJoint::SetBodiesCollisionState (int state)
{
NewtonJointSetCollisionState (m_joint, state);
}
int NewtonCustomJoint::GetBodiesCollisionState () const
{
return NewtonJointGetCollisionState (m_joint);
} | [
"mattphillips@mail.com"
] | mattphillips@mail.com |
98472540701cb79ffdd465a5704b3b920895b4a7 | f75c62b9227f8459e2807fde3279b2a5e56e6e64 | /CHr41/cpm210/4.5/p | 1325c15b4cd05c67d2e627d070a701018b37f4bf | [] | no_license | kohoman/mstAdvComp.sp21 | a718a930d693030e0abf05f451cdee50a6fca5f0 | 30307c3ff3c3e1e2c1dabf611e550f2c426d5d8d | refs/heads/main | 2023-04-22T08:27:11.181441 | 2021-05-03T19:57:22 | 2021-05-03T19:57:22 | 338,087,447 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 5,873 | /*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: 5.0 |
| \\ / A nd | Web: www.OpenFOAM.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class volScalarField;
location "4.5";
object p;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensions [0 2 -2 0 0 0 0];
internalField nonuniform List<scalar>
400
(
2.93144e-08
-6.9111e-05
-0.000123584
-0.000287924
-0.000179888
-0.000555322
-0.00159171
-0.00284623
-0.00397662
-0.00484019
-0.00535129
-0.00545921
-0.00508351
-0.00414722
-0.00253412
-0.000198044
0.00280843
0.00611836
0.00867232
0.00956817
3.4017e-05
-2.95924e-05
-8.2775e-05
-0.000257566
-0.000698914
-0.00147156
-0.0025479
-0.00364962
-0.00467825
-0.00545125
-0.00591449
-0.00601072
-0.00570777
-0.00492646
-0.00356733
-0.00155977
0.00109962
0.00422416
0.00707808
0.00855603
0.000149619
4.01844e-05
-0.000242294
-0.000787317
-0.00163443
-0.0027111
-0.00384174
-0.00493612
-0.00588775
-0.00654802
-0.00691223
-0.00695731
-0.00666344
-0.00600453
-0.00494889
-0.0034267
-0.00136206
0.00124665
0.00411342
0.00596694
0.000263691
1.32201e-06
-0.000631899
-0.00162922
-0.00282822
-0.00407595
-0.00522424
-0.00617692
-0.00688299
-0.00736246
-0.00761389
-0.00762374
-0.00738172
-0.00687226
-0.00607664
-0.00496884
-0.00347944
-0.0015024
0.000899779
0.00273538
6.22231e-05
-0.000383384
-0.00133703
-0.0026598
-0.00401916
-0.00525404
-0.006263
-0.00704295
-0.00760722
-0.007993
-0.00819565
-0.00820615
-0.00800649
-0.00759502
-0.00697458
-0.0061496
-0.00509131
-0.00367846
-0.00198502
-0.000281628
-0.000550946
-0.00111119
-0.00226654
-0.00367944
-0.0050298
-0.00614916
-0.00700534
-0.00766591
-0.00815501
-0.00850104
-0.00869109
-0.00871303
-0.00854952
-0.00820509
-0.00769861
-0.00705544
-0.0062976
-0.00530313
-0.00419857
-0.00277354
-0.00147178
-0.00205269
-0.00323637
-0.00458222
-0.00583146
-0.00681492
-0.00755856
-0.00814717
-0.00860092
-0.00893731
-0.00913516
-0.00917263
-0.00903405
-0.00873171
-0.00829718
-0.00776452
-0.00720884
-0.00648296
-0.00583696
-0.00468689
-0.00243512
-0.00297998
-0.0040915
-0.00531513
-0.00644316
-0.00730824
-0.00797941
-0.00852999
-0.00897941
-0.00933742
-0.00956937
-0.009639
-0.00953479
-0.00926345
-0.0088688
-0.0083856
-0.00794784
-0.00736043
-0.00700726
-0.00609668
-0.00321599
-0.00371582
-0.00473697
-0.0058536
-0.0068784
-0.00765729
-0.00828927
-0.0088318
-0.00931001
-0.00973335
-0.0100446
-0.0101778
-0.010121
-0.00986665
-0.00947376
-0.00896897
-0.00857015
-0.00801664
-0.00783856
-0.00707855
-0.00373896
-0.00418318
-0.00512794
-0.00617583
-0.00713479
-0.00786889
-0.00849475
-0.00905838
-0.00959855
-0.0101265
-0.0105538
-0.0107737
-0.0107553
-0.0104891
-0.0100578
-0.00946029
-0.00906101
-0.00843059
-0.00840275
-0.00767248
-0.00396564
-0.00439207
-0.00526624
-0.00628054
-0.00720118
-0.00794095
-0.00858884
-0.00919389
-0.00980513
-0.0104271
-0.0109441
-0.0112291
-0.0112085
-0.0109111
-0.0104312
-0.00970847
-0.00932687
-0.00849923
-0.00872154
-0.00785127
-0.0039019
-0.00433334
-0.00516606
-0.0061589
-0.00708732
-0.00785407
-0.00853471
-0.00918517
-0.00984484
-0.0105081
-0.0110517
-0.011337
-0.0113103
-0.0109811
-0.0104501
-0.0096476
-0.00922743
-0.00820381
-0.00872334
-0.00757198
-0.00363763
-0.00409415
-0.00488626
-0.00582666
-0.0067783
-0.00757904
-0.00829729
-0.00898223
-0.00966356
-0.0103278
-0.0108578
-0.0111228
-0.0110721
-0.0107051
-0.0101183
-0.0092685
-0.00871731
-0.0076065
-0.00831493
-0.00679973
-0.00332789
-0.00375309
-0.00445644
-0.0052948
-0.00624409
-0.00708715
-0.00785155
-0.00856859
-0.00925454
-0.0098901
-0.0103827
-0.0106165
-0.0105363
-0.0101271
-0.00948399
-0.00858506
-0.00786364
-0.00676528
-0.00748039
-0.00558754
-0.00319082
-0.00346048
-0.0039552
-0.00461463
-0.00547155
-0.00635963
-0.00719249
-0.00795971
-0.00866003
-0.00927208
-0.00972567
-0.00991966
-0.00979988
-0.0093388
-0.00862551
-0.00765208
-0.00676452
-0.00572187
-0.00631972
-0.00401328
-0.0032406
-0.00325899
-0.00340095
-0.00379169
-0.00449161
-0.00539671
-0.00631812
-0.00717247
-0.0079251
-0.00854633
-0.00897859
-0.00913673
-0.00897144
-0.00845084
-0.00764933
-0.00658016
-0.00554887
-0.00455005
-0.00492151
-0.00209546
-0.0032093
-0.00301098
-0.00274365
-0.00281955
-0.00335973
-0.00425709
-0.0052673
-0.00623781
-0.00708611
-0.00776103
-0.00821044
-0.00836322
-0.00817112
-0.00759461
-0.00669705
-0.00551966
-0.00436141
-0.00331052
-0.0032756
0.000326794
-0.00303776
-0.0025945
-0.00195164
-0.00171894
-0.00214561
-0.00304506
-0.00413888
-0.00521669
-0.00616976
-0.00692356
-0.00741811
-0.00759024
-0.00740441
-0.00683355
-0.00589937
-0.00465371
-0.00330751
-0.00199224
-0.000966078
0.00466283
-0.00268411
-0.00212141
-0.00120999
-0.000816549
-0.00119778
-0.00208982
-0.00324256
-0.00441345
-0.00546818
-0.00629869
-0.00685731
-0.00708311
-0.00693968
-0.00638986
-0.00544175
-0.00413353
-0.0025324
-0.000237133
0.00446061
0.0165352
-0.00432839
-0.001541
-0.000342023
-0.000154927
-0.000554089
-0.00146343
-0.00265365
-0.0039148
-0.00504699
-0.00594272
-0.0065522
-0.00683381
-0.00675897
-0.00627675
-0.00528364
-0.00373061
-0.00103422
0.00485031
0.0178416
0.0395564
)
;
boundaryField
{
movingWall
{
type zeroGradient;
}
fixedWalls
{
type zeroGradient;
}
frontAndBack
{
type empty;
}
}
// ************************************************************************* //
| [
"khoman@mst.edu"
] | khoman@mst.edu | |
e2e529ff7202539eeb1a3820e28f5ad6314d45e7 | 330f658cc781589558072549fb1268370974c63c | /Animation.cpp | 905b0379b1e13bdf236adda444f90f2d7b56f081 | [] | no_license | DYGames/SkillOlympic_Medieval | 07c10cc1d5c52b4d0b88969b96c3e10265ac51aa | 63f91e54238cc66389526ae0cb0ede631d306468 | refs/heads/master | 2021-01-17T14:21:20.640863 | 2017-03-06T14:58:46 | 2017-03-06T14:58:46 | 84,085,860 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 819 | cpp | #include "DXUT.h"
#include "Sprite.h"
#include "Animation.h"
void Animation::initAnimation(Sprite* t, float d, bool l, bool e)
{
_target = t;
_delay = 0;
_maxdelay = d;
_loop = l;
_erase = e;
_run = true;
_endfunc = nullptr;
}
void Animation::addClips(std::wstring str)
{
_clips.push_back(TextureMng::getInstance()->getTexture(str));
}
void Animation::removeClipAll()
{
_delay = 0;
_idx = 0;
_clips.clear();
}
void Animation::update()
{
if (_clips.size() == 0)
return;
_delay += Time::dt;
if (_delay >= _maxdelay)
{
_delay = 0;
_idx++;
if (_idx >= _clips.size())
{
if (_loop)
_idx = 0;
else
{
if (_endfunc)
_endfunc();
if (_erase)
_target->removeChild(_target);
else
_run = false;
return;
}
}
_target->_texture = _clips.at(_idx);
}
} | [
"dygames@naver.com"
] | dygames@naver.com |
46004671fb1219ec6d33e361f9e9fedd13a87b8b | f825c3dd8eee453bcc94039b47f8f4b7173fc9f0 | /lm/sri_test.cc | e697d7225cac58103a3e52019fc2b892387efeae | [] | no_license | lacozhang/pinyin2word | 693b0fc6adc2e320bc1aa5a5564e2cc524dedc94 | 87b111246a9f757f8e8e9ade30ce727d7faaaec2 | refs/heads/master | 2020-07-02T00:11:23.589930 | 2012-12-16T05:58:33 | 2012-12-16T05:58:33 | 4,535,442 | 5 | 4 | null | null | null | null | UTF-8 | C++ | false | false | 1,791 | cc | #include "lm/sri.hh"
#include <stdlib.h>
#define BOOST_TEST_MODULE SRITest
#include <boost/test/unit_test.hpp>
namespace lm {
namespace sri {
namespace {
#define StartTest(word, ngram, score) \
ret = model.FullScore( \
state, \
model.GetVocabulary().Index(word), \
out);\
BOOST_CHECK_CLOSE(score, ret.prob, 0.001); \
BOOST_CHECK_EQUAL(static_cast<unsigned int>(ngram), ret.ngram_length); \
BOOST_CHECK_EQUAL(std::min<unsigned char>(ngram, 5 - 1), out.valid_length_);
#define AppendTest(word, ngram, score) \
StartTest(word, ngram, score) \
state = out;
template <class M> void Starters(M &model) {
FullScoreReturn ret;
Model::State state(model.BeginSentenceState());
Model::State out;
StartTest("looking", 2, -0.4846522);
// , probability plus <s> backoff
StartTest(",", 1, -1.383514 + -0.4149733);
// <unk> probability plus <s> backoff
StartTest("this_is_not_found", 0, -1.995635 + -0.4149733);
}
template <class M> void Continuation(M &model) {
FullScoreReturn ret;
Model::State state(model.BeginSentenceState());
Model::State out;
AppendTest("looking", 2, -0.484652);
AppendTest("on", 3, -0.348837);
AppendTest("a", 4, -0.0155266);
AppendTest("little", 5, -0.00306122);
State preserve = state;
AppendTest("the", 1, -4.04005);
AppendTest("biarritz", 1, -1.9889);
AppendTest("not_found", 0, -2.29666);
AppendTest("more", 1, -1.20632);
AppendTest(".", 2, -0.51363);
AppendTest("</s>", 3, -0.0191651);
state = preserve;
AppendTest("more", 5, -0.00181395);
AppendTest("loin", 5, -0.0432557);
}
BOOST_AUTO_TEST_CASE(starters) { Model m("test.arpa", 5); Starters(m); }
BOOST_AUTO_TEST_CASE(continuation) { Model m("test.arpa", 5); Continuation(m); }
} // namespace
} // namespace sri
} // namespace lm
| [
"lacozhang@gmail.com"
] | lacozhang@gmail.com |
b8f06ddf99c99b5c619672cd1701e6dd52f468b3 | 6d5f2e99ae89e6c59bdafed707f5a5db673dec23 | /src/xmlToSql/xmlToSqliteHandler.h | 545f932672dffb19925db400d5d7bca85a78ee9a | [
"MIT"
] | permissive | bencabrera/grawitas | b633ae1dbbbb3da8a37b61b2cb48c493d7c299d2 | 8eda68846ed283afe70d56d68375525a1140de70 | refs/heads/master | 2022-03-27T08:27:16.948509 | 2018-01-19T09:48:37 | 2018-01-19T09:48:37 | 81,924,748 | 7 | 7 | MIT | 2022-01-25T18:14:46 | 2017-02-14T08:49:49 | C++ | UTF-8 | C++ | false | false | 815 | h | #pragma once
#include <functional>
#include <set>
#include "../../libs/wiki_xml_dump_xerces/src/handlers/abstractWikiPageHandler.hpp"
#include "../output/formats.h"
#include <sqlite3.h>
#include "../talkPageParser/models.h"
namespace Grawitas {
class XmlToSqliteHandler : public WikiXmlDumpXerces::AbstractWikiPageHandler {
public:
XmlToSqliteHandler(sqlite3* db);
void HandleArticle(const WikiXmlDumpXerces::WikiPageData&);
std::function<void(const std::string&)> status_callbacks;
void insert_comment(const Grawitas::Comment& comment, const std::string& article_title);
std::map<std::string, std::size_t> article_map;
std::map<std::string, std::size_t> user_map;
private:
sqlite3* sqlite_db;
std::size_t i_user;
std::size_t i_article;
std::size_t i_comment;
};
}
| [
"benny@bcabrera.de"
] | benny@bcabrera.de |
5b36fba0fbfe933a49b5e10460dcbb8c6acfd4fa | 5b2633f93fabf3fd69e93fcd4c6f726208677342 | /client.h | 602e1568ca29aaa18ed78269e3c1071c496688fd | [] | no_license | chenditc/hackathon_2014 | d035ab506c531a2298d25dfdf805ed3d825c8138 | c589af763d99172062e77f819bffc820f6420560 | refs/heads/master | 2020-04-28T11:16:12.280261 | 2014-10-18T16:23:41 | 2014-10-18T16:23:41 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 816 | h | #include <random>
#include <string>
#include "game_io/game_io.h"
#include "game_io/json_response.h"
#include "game_io/move_request.h"
#include "game_io/take_space_response.h"
#include "game_io/wait_response.h"
#include "game_io/greeting.h"
#include "game_io/game_result.h"
using namespace std;
class client : public game_player {
public:
client() : random_wait(0,1) {}
virtual void error(error_msg*);
virtual move_response* move(move_request*);
virtual void server_greeting(greeting*);
virtual void move_received(move_result*);
virtual void hand_done(move_result*);
virtual void game_over(game_result*);
private:
default_random_engine random_generator;
uniform_int_distribution<int> random_wait;
};
struct GameError : exception {};
| [
"chenditc@umich.edu"
] | chenditc@umich.edu |
6f45d08a44bf565efeb662f8b00085c8e1737b9a | c239ffbaba19ffe14f5512ebd6f31d06c49873d3 | /Interfaces/LocoBufferEsp32/fwIoTT/lib/IoTT_LocoNetButtons/src/IoTT_LocoNetButtons.h | 9f977656e21a854c2a701c79d1a9daa320d58b78 | [
"MIT"
] | permissive | danielvilas/DigitalTrains | 67d84284ea7ab3dd93b5e6413fe6e96b1a6468d9 | edc5f99ed52c5683a023a1b5e349247640218dd9 | refs/heads/master | 2023-09-05T02:55:52.371906 | 2023-08-25T12:19:23 | 2023-08-25T12:19:23 | 170,680,519 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,759 | h | #ifndef IoTT_LocoNetButtons_h
#define IoTT_LocoNetButtons_h
#include <Arduino.h>
#include <ArduinoJson.h>
#include <IoTT_ButtonTypeDef.h>
#include <IoTT_DigitraxBuffers.h>
class IoTT_LocoNetButtonList;
class IoTT_LocoNetButtons;
class IoTT_BtnHandler;
class IoTT_BtnHandlerCmd
{
public: //
IoTT_BtnHandlerCmd();
~IoTT_BtnHandlerCmd();
void loadButtonCfgJSON(JsonObject thisObj);
void executeBtnEvent();
IoTT_BtnHandler * parentObj = NULL;
// private:
outputType targetType; //switch, input, button, signal, analog, power, analoginp
uint16_t targetAddr; //address for target type
public:
uint8_t cmdType; //value parameter
uint8_t cmdValue; //value parameter
uint16_t execDelay; //time in ms to wait before sending next command
};
class IoTT_BtnHandler
{
public:
IoTT_BtnHandler();
~IoTT_BtnHandler();
void loadButtonCfgJSON(JsonObject thisObj);
// uint8_t getEventType();
void processBtnEvent();
uint16_t getCondAddr(uint8_t addrIndex = 0);
int16_t getCondAddrIndex(uint16_t ofAddr); //index if found, -1 if not there
IoTT_LocoNetButtons * parentObj = NULL;
IoTT_BtnHandlerCmd * getCmdByIndex(uint16_t thisCmd);
IoTT_BtnHandlerCmd * getCmdByTypeAddr(uint8_t cmdType, uint16_t cmdAddr);
uint8_t numCmds = 0;
private:
// uint8_t eventType = noevent;
uint16_t * btnCondAddr = NULL;
uint16_t btnCondAddrLen = 0;
// uint8_t currEvent = 0;
IoTT_BtnHandlerCmd ** cmdList = NULL;
};
class IoTT_LocoNetButtons
{
public:
IoTT_LocoNetButtons();
~IoTT_LocoNetButtons();
void loadButtonCfgJSON(JsonObject thisObj);
void processBtnEvent(uint8_t inputValue);
void processSimpleEvent(uint8_t inputValue);
void processBlockDetEvent(uint8_t inputValue);
void processDynEvent(uint8_t inputValue);
void processSignalEvent(uint8_t inputValue);
void processAnalogEvent(uint16_t inputValue);
void processAnalogScaler(uint16_t inputValue);
void processTransponderEvent(uint16_t inputValue);
void processPowerEvent(uint16_t inputValue);
uint16_t getBtnAddr(uint8_t index);
int8_t hasBtnAddr(uint16_t thisAddr);
sourceType getEventSource();
sourceType hasEventSource(sourceType thisSource);
bool getEnableStatus();
int16_t getCondDataIndex(uint16_t ofData);
uint8_t getLastRecEvent();
uint8_t getLastComplEvent();
IoTT_LocoNetButtonList * parentObj = NULL;
private:
uint8_t lastRecButtonEvent; //last event received
uint8_t lastComplButtonEvent; //last event that was executed. If successful, those two are identical
enableType enableInput = ent_alwayson;
uint16_t enableAddr = 0;
uint8_t enableStatus = 0;
sourceType eventInput = evt_nosource;
uint16_t * btnAddrList = NULL;
uint8_t btnAddrListLen = 0;
uint16_t * condDataList = NULL;
uint8_t condDataListLen = 0;
uint8_t eventTypeListLen = 0;
IoTT_BtnHandler ** eventTypeList = NULL;
uint8_t lastEvent = 0xFF;
};
typedef struct
{
IoTT_BtnHandlerCmd * nextCommand = NULL;
uint32_t execTime = 0;
bool tbd = false; //to be done. if true, we need to send, otherwise, it can be overwritten
} cmdPtr;
#define cmdBufferLen 50
typedef struct
{
cmdPtr cmdOutBuffer[cmdBufferLen];
// uint8_t readPtr = 0;
// uint8_t writePtr = 0;
} cmdBuffer;
class IoTT_LocoNetButtonList
{
public:
IoTT_LocoNetButtonList();
~IoTT_LocoNetButtonList();
void processBtnEvent(sourceType inputEvent, uint16_t btnAddr, uint16_t eventValue);
void loadButtonCfgJSON(DynamicJsonDocument doc, bool resetList = true);
void loadButtonCfgJSONObj(JsonObject doc, bool resetList = true);
void processButtonHandler();
void addCmdToBuffer(IoTT_BtnHandlerCmd * newCmd);
IoTT_LocoNetButtons * getButtonByAddress(uint16_t btnAddr);
uint16_t getButtonIndexByAddress(sourceType inputEvent, uint16_t btnAddr, uint16_t startIndex = 0);
private:
void freeObjects();
IoTT_LocoNetButtons ** btnList = NULL;
uint16_t numBtnHandler = 0;
public:
cmdBuffer outBuffer;
};
//these are the execute functions. Provide a function with this name and parameter in your application and it will be called when a command must be sent to LocoNet
extern void sendSwitchCommand(uint8_t opCode, uint16_t swiNr, uint8_t swiTargetPos, uint8_t coilStatus) __attribute__ ((weak)); //switch
extern void sendSignalCommand(uint16_t signalNr, uint8_t signalAspect) __attribute__ ((weak)); //signal
extern void sendPowerCommand(uint8_t cmdType, uint8_t pwrStatus) __attribute__ ((weak)); //power
extern void sendBlockDetectorCommand(uint16_t bdNr, uint8_t bdStatus) __attribute__ ((weak)); //block detector
extern void sendAnalogCommand(uint16_t btnNr, uint16_t analogVal) __attribute__ ((weak)); //analog value
extern void sendButtonCommand(uint16_t btnNr, uint8_t btnEvent) __attribute__ ((weak)); //button command
#endif
| [
"dvilas@eead.csic.es"
] | dvilas@eead.csic.es |
81be6fd055c05fbb7f8cf568fe903a8025e31232 | 07d87c10a265921c1a031d432b556e6a70357651 | /source/hydra_next/source/application/hydra_imgui.hpp | fabf7140c4e9683b1aabd5a2cbec5a4b50b134a9 | [
"Zlib"
] | permissive | JorenJoestar/DataDrivenRendering | 09fa4fd5b312e8c6c2ccead3404d031d8cd00ef0 | b9078ea3d2d63d1c2cbc6f9ed655e49e23747969 | refs/heads/master | 2021-12-23T23:24:50.828997 | 2021-12-20T17:27:21 | 2021-12-20T17:27:21 | 194,456,496 | 229 | 18 | null | null | null | null | UTF-8 | C++ | false | false | 3,946 | hpp | #pragma once
//
// Hydra ImGUI - v0.15
//
// ImGUI wrapper using Hydra Graphics.
//
// Source code : https://www.github.com/jorenjoestar/
//
// Created : 2019/09/16, 19.23
//
// 0.15 (2021/11/10): + Finished fully functional bindless support, using instance id to retrieve texture in the bindless texture.
// 0.14 (2021/11/10): + Added custom ImGui styles.
// 0.13 (2021/10/28): + Added initial support for bindless rendering.
// 0.12 (2021/10/27): + Added support for Vertex and Index offsets in ImGui rendering.
// 0.11 (2021/10/21): + Changed ImGuiService to use Renderer instead of GpuDevice.
// 0.10 (2020/01/21): + Added resize method. Internally destroys resource lists provoking a rebind the frame after.
// 0.09 (2020/12/28): + Fixed scissor clipping.
// 0.08 (2020/12/20): + Added AppLog widget copied from ImGui demo.
// 0.07 (2020/09/16): + Updates for Vulkan gfx device. + Using glsl programs for Vulkan as well. + Fixed rgba/rgba32 color conversion. + Fixed scissor to be upper for Vulkan.
// 0.06 (2020/09/15): + Update resource list and layouts to new hydra_graphics interface.
// 0.05 (2020/03/25): + Added Path Dialog.
// 0.04 (2020/03/20): + Added File Dialog. + Moved everything to be under hydra namespace.
// 0.03 (2020/03/12): + Embedded SpirV shaders.
// 0.02 (2020/03/10): + Embedded GLSL shaders and handwritten code to remove dependency on compiler. Code cleanup.
// 0.01 (2019/09/16): + Initial implementation.
#include <stdint.h>
#include "kernel/service.hpp"
struct ImDrawData;
namespace hydra {
namespace gfx {
struct Device;
struct CommandBuffer;
struct TextureHandle;
struct Renderer;
} // namespace graphics
//
//
enum ImGuiStyles {
Default = 0,
GreenBlue,
DarkRed,
DarkGold
}; // enum ImGuiStyles
//
//
struct ImGuiService : public Service {
hy_declare_service( ImGuiService );
void init( void* configuration ) override;
void shutdown() override;
void new_frame( void* window_handle );
void render( hydra::gfx::Renderer* renderer, hydra::gfx::CommandBuffer& commands );
// Removes the Texture from the Cache and destroy the associated Resource List.
void remove_cached_texture( hydra::gfx::TextureHandle& texture );
//void imgui_on_resize( hydra::gfx::Device& gpu, uint32_t width, uint32_t height );
void set_style( ImGuiStyles style );
hydra::gfx::Renderer* gfx;
static constexpr cstring k_name = "hydra_imgui_service";
}; // ImGuiService
// File Dialog /////////////////////////////////////////////////////////
/*bool imgui_file_dialog_open( const char* button_name, const char* path, const char* extension );
const char* imgui_file_dialog_get_filename();
bool imgui_path_dialog_open( const char* button_name, const char* path );
const char* imgui_path_dialog_get_path();*/
// Application Log /////////////////////////////////////////////////////
void imgui_log_init();
void imgui_log_shutdown();
void imgui_log_draw();
// FPS graph ///////////////////////////////////////////////////
void imgui_fps_init();
void imgui_fps_shutdown();
void imgui_fps_add( f32 dt );
void imgui_fps_draw();
} // namespace hydra | [
"gsassone7@gmail.com"
] | gsassone7@gmail.com |
8922814b0e09a2c10bfd224b35727adfaf2f6959 | eda2b66cd014e529bcaa4440d79b5109422ceb99 | /Battleship/Temp/il2cppOutput/il2cppOutput/mscorlib_System_Collections_Generic_Dictionary_2_K2988270486.h | 8e1f946e67466475d355694355f837885359aa4a | [] | no_license | jrbyam/CS372Battleship | a8b9cf491e5fdea6d466a7f5693feed70a348dfb | cb186e0a5777fc4d8879923f8cec4b5d83dac19e | refs/heads/master | 2021-01-10T09:24:55.403518 | 2016-03-11T22:29:00 | 2016-03-11T22:29:00 | 51,184,324 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,302 | h | #pragma once
#include "il2cpp-config.h"
#ifndef _MSC_VER
# include <alloca.h>
#else
# include <malloc.h>
#endif
#include <stdint.h>
// System.Collections.Generic.Dictionary`2<System.Type,System.Int32>
struct Dictionary_2_t664995206;
#include "mscorlib_System_Object837106420.h"
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// System.Collections.Generic.Dictionary`2/KeyCollection<System.Type,System.Int32>
struct KeyCollection_t2988270486 : public Il2CppObject
{
public:
// System.Collections.Generic.Dictionary`2<TKey,TValue> System.Collections.Generic.Dictionary`2/KeyCollection::dictionary
Dictionary_2_t664995206 * ___dictionary_0;
public:
inline static int32_t get_offset_of_dictionary_0() { return static_cast<int32_t>(offsetof(KeyCollection_t2988270486, ___dictionary_0)); }
inline Dictionary_2_t664995206 * get_dictionary_0() const { return ___dictionary_0; }
inline Dictionary_2_t664995206 ** get_address_of_dictionary_0() { return &___dictionary_0; }
inline void set_dictionary_0(Dictionary_2_t664995206 * value)
{
___dictionary_0 = value;
Il2CppCodeGenWriteBarrier(&___dictionary_0, value);
}
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
| [
"jrbyam@Brock.local"
] | jrbyam@Brock.local |
ccf88912ec3eec3287167e2fb07915421d0844d4 | 2fac67f8d9a53484bc2f1f1e4810bb01fc529361 | /Implement Stack using Queues.cpp | 90f3ef4e67b58b30d144886955abec768f3f27cf | [] | no_license | Zruzhuo/C_Practice | 19610e01ae09b4d4bf4c56142056be6d0285edaf | edd0e482066ae1ac04466fbea19ababf3e4da063 | refs/heads/master | 2021-07-05T08:29:39.838647 | 2020-09-22T14:28:23 | 2020-09-22T14:28:23 | 185,733,298 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 810 | cpp | class MyStack {
public:
queue<int> q1, q2;
/** Initialize your data structure here. */
MyStack() {}
/** Push element x onto stack. */
void push(int x) {
while (!q2.empty()) {
q1.push(q2.front());
q2.pop();
}
q2.push(x);
while (!q1.empty()) {
q2.push(q1.front());
q1.pop();
}
}
/** Removes the element on top of the stack and returns that element. */
int pop() {
int a = q2.front();
q2.pop();
return a;
}
/** Get the top element. */
int top() {
return q2.front();
}
/** Returns whether the stack is empty. */
bool empty() {
return q2.empty();
}
};
/**
* Your MyStack object will be instantiated and called as such:
* MyStack* obj = new MyStack();
* obj->push(x);
* int param_2 = obj->pop();
* int param_3 = obj->top();
* bool param_4 = obj->empty();
*/ | [
"1197736628@qq.com"
] | 1197736628@qq.com |
aa20ff978059180073b2341197d0d669546371da | 8e62c3eb35302aaa79e4a602ddfbb93489e09660 | /tests/ut/cpp/pre_activate/ascend/ir_fusion/square_sum_fusion_test.cc | 2dd858a0fcac328b63fc454b3a511c5149d41aa5 | [
"Apache-2.0",
"IJG",
"Zlib",
"LGPL-2.1-only",
"MIT",
"BSD-3-Clause",
"BSD-3-Clause-Open-MPI",
"GPL-2.0-only",
"BSL-1.0",
"MPL-2.0",
"MPL-2.0-no-copyleft-exception",
"LicenseRef-scancode-proprietary-license",
"LicenseRef-scancode-public-domain",
"AGPL-3.0-only",
"LicenseRef-scancode-unkno... | permissive | ythlml/mindspore | a7faa28fa401372c73798c6b0ad186fa10386b09 | 028ae212624164044cfaa84f347fc502cb7fcb0f | refs/heads/master | 2022-09-09T20:28:34.554927 | 2020-05-24T06:19:23 | 2020-05-24T06:19:23 | 266,301,148 | 7 | 0 | Apache-2.0 | 2020-05-23T09:09:49 | 2020-05-23T09:09:48 | null | UTF-8 | C++ | false | false | 2,844 | cc | /**
* Copyright 2020 Huawei Technologies Co., Ltd
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "common/backend_common_test.h"
#include "common/py_func_graph_fetcher.h"
#include "pre_activate/common/optimizer.h"
#include "pre_activate/ascend/ir_fusion/square_sum_fusion.h"
#include "debug/anf_ir_dump.h"
namespace mindspore {
namespace opt {
class TestHWOptimizeSquareSumFusion : public BackendCommon {
public:
TestHWOptimizeSquareSumFusion() : get_py_fun_("gtest_input.pre_activate.square_sum_fusion", true) {}
~TestHWOptimizeSquareSumFusion() override = default;
UT::PyFuncGraphFetcher get_py_fun_;
};
TEST_F(TestHWOptimizeSquareSumFusion, test_square_sumv1_fusion) {
FuncGraphPtr g = get_py_fun_.CallAndParseRet("test_square_sum_fusion", "before1");
std::vector<int> shp{1, 1, 1, 1};
auto x_abstract = std::make_shared<abstract::AbstractTensor>(kFloat32, shp);
AbstractBasePtrList args_spec_list;
for (size_t i = 0; i < 1; ++i) {
args_spec_list.push_back(x_abstract);
}
auto fg = GetKernelGraph(g, args_spec_list);
auto optimizer = std::make_shared<opt::GraphOptimizer>();
auto pm = std::make_shared<opt::PassManager>();
pm->AddPass(std::make_shared<opt::SquareSumFusion>());
optimizer->AddPassManager(pm);
FuncGraphPtr new_graph = optimizer->Optimize(fg);
FuncGraphPtr g_after = get_py_fun_.CallAndParseRet("test_square_sum_fusion", "after1");
EXPECT_TRUE(CheckEqualGraph(g_after, new_graph));
}
TEST_F(TestHWOptimizeSquareSumFusion, test_square_sumv2_fusion) {
FuncGraphPtr g = get_py_fun_.CallAndParseRet("test_square_sum_fusion", "before2");
std::vector<int> shp{1, 1, 1, 1};
auto x_abstract = std::make_shared<abstract::AbstractTensor>(kFloat32, shp);
AbstractBasePtrList args_spec_list;
for (size_t i = 0; i < 1; ++i) {
args_spec_list.push_back(x_abstract);
}
auto fg = GetKernelGraph(g, args_spec_list);
auto optimizer = std::make_shared<opt::GraphOptimizer>();
auto pm = std::make_shared<opt::PassManager>();
pm->AddPass(std::make_shared<opt::SquareSumFusion>());
optimizer->AddPassManager(pm);
FuncGraphPtr new_graph = optimizer->Optimize(fg);
FuncGraphPtr g_after = get_py_fun_.CallAndParseRet("test_square_sum_fusion", "after2");
EXPECT_TRUE(CheckEqualGraph(g_after, new_graph));
}
} // namespace opt
} // namespace mindspore
| [
"leon.wanghui@huawei.com"
] | leon.wanghui@huawei.com |
0a338c841ca2d578ecc8b0bd4d0e1ffe6d200aa9 | 92673d60154f2fd1fb3e39c70cd7377d53135650 | /llvm/4.0.1/include/polly/ScopBuilder.h | 8dc9677c87bc441a822f244ea90491238b08e325 | [
"NCSA"
] | permissive | EnjoyLifeFund/macSierra-cellars | 3cc4684387ef854dd0dfd26caacb8bf92f268b11 | fc71057183db092410408b5dba42729191ee034e | refs/heads/master | 2021-06-23T12:30:40.182743 | 2017-09-05T04:57:00 | 2017-09-05T04:57:00 | 84,413,038 | 1 | 2 | null | null | null | null | UTF-8 | C++ | false | false | 10,392 | h | //===- polly/ScopBuilder.h -------------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// Create a polyhedral description for a static control flow region.
//
// The pass creates a polyhedral description of the Scops detected by the SCoP
// detection derived from their LLVM-IR code.
//
//===----------------------------------------------------------------------===//
#ifndef POLLY_SCOP_BUILDER_H
#define POLLY_SCOP_BUILDER_H
#include "polly/ScopInfo.h"
namespace polly {
/// Build the Polly IR (Scop and ScopStmt) on a Region.
class ScopBuilder {
//===-------------------------------------------------------------------===//
ScopBuilder(const ScopBuilder &) = delete;
const ScopBuilder &operator=(const ScopBuilder &) = delete;
/// The AliasAnalysis to build AliasSetTracker.
AliasAnalysis &AA;
/// Target data for element size computing.
const DataLayout &DL;
/// DominatorTree to reason about guaranteed execution.
DominatorTree &DT;
/// LoopInfo for information about loops.
LoopInfo &LI;
/// Valid Regions for Scop
ScopDetection &SD;
/// The ScalarEvolution to help building Scop.
ScalarEvolution &SE;
/// Set of instructions that might read any memory location.
SmallVector<Instruction *, 16> GlobalReads;
/// Set of all accessed array base pointers.
SmallSetVector<Value *, 16> ArrayBasePointers;
// The Scop
std::unique_ptr<Scop> scop;
// Build the SCoP for Region @p R.
void buildScop(Region &R);
/// Try to build a multi-dimensional fixed sized MemoryAccess from the
/// Load/Store instruction.
///
/// @param Inst The Load/Store instruction that access the memory
/// @param L The parent loop of the instruction
///
/// @returns True if the access could be built, False otherwise.
bool buildAccessMultiDimFixed(MemAccInst Inst, Loop *L);
/// Try to build a multi-dimensional parameteric sized MemoryAccess.
/// from the Load/Store instruction.
///
/// @param Inst The Load/Store instruction that access the memory
/// @param L The parent loop of the instruction
///
/// @returns True if the access could be built, False otherwise.
bool buildAccessMultiDimParam(MemAccInst Inst, Loop *L);
/// Try to build a MemoryAccess for a memory intrinsic.
///
/// @param Inst The instruction that access the memory
/// @param L The parent loop of the instruction
///
/// @returns True if the access could be built, False otherwise.
bool buildAccessMemIntrinsic(MemAccInst Inst, Loop *L);
/// Try to build a MemoryAccess for a call instruction.
///
/// @param Inst The call instruction that access the memory
/// @param L The parent loop of the instruction
///
/// @returns True if the access could be built, False otherwise.
bool buildAccessCallInst(MemAccInst Inst, Loop *L);
/// Build a single-dimensional parametric sized MemoryAccess
/// from the Load/Store instruction.
///
/// @param Inst The Load/Store instruction that access the memory
/// @param L The parent loop of the instruction
void buildAccessSingleDim(MemAccInst Inst, Loop *L);
/// Build an instance of MemoryAccess from the Load/Store instruction.
///
/// @param Inst The Load/Store instruction that access the memory
/// @param L The parent loop of the instruction
void buildMemoryAccess(MemAccInst Inst, Loop *L);
/// Analyze and extract the cross-BB scalar dependences (or, dataflow
/// dependencies) of an instruction.
///
/// @param Inst The instruction to be analyzed.
void buildScalarDependences(Instruction *Inst);
/// Build the escaping dependences for @p Inst.
///
/// Search for uses of the llvm::Value defined by @p Inst that are not
/// within the SCoP. If there is such use, add a SCALAR WRITE such that
/// it is available after the SCoP as escaping value.
///
/// @param Inst The instruction to be analyzed.
void buildEscapingDependences(Instruction *Inst);
/// Create MemoryAccesses for the given PHI node in the given region.
///
/// @param PHI The PHI node to be handled
/// @param NonAffineSubRegion The non affine sub-region @p PHI is in.
/// @param IsExitBlock Flag to indicate that @p PHI is in the exit BB.
void buildPHIAccesses(PHINode *PHI, Region *NonAffineSubRegion,
bool IsExitBlock = false);
/// Build the access functions for the subregion @p SR.
///
/// @param SR A subregion of @p R.
/// @param InsnToMemAcc The Instruction to MemoryAccess mapping.
void buildAccessFunctions(Region &SR);
/// Create ScopStmt for all BBs and non-affine subregions of @p SR.
///
/// @param SR A subregion of @p R.
///
/// Some of the statments might be optimized away later when they do not
/// access any memory and thus have no effect.
void buildStmts(Region &SR);
/// Build the access functions for the basic block @p BB.
///
/// @param BB A basic block in @p R.
/// @param NonAffineSubRegion The non affine sub-region @p BB is in.
/// @param IsExitBlock Flag to indicate that @p BB is in the exit BB.
void buildAccessFunctions(BasicBlock &BB,
Region *NonAffineSubRegion = nullptr,
bool IsExitBlock = false);
/// Create a new MemoryAccess object and add it to #AccFuncMap.
///
/// @param BB The block where the access takes place.
/// @param Inst The instruction doing the access. It is not necessarily
/// inside @p BB.
/// @param AccType The kind of access.
/// @param BaseAddress The accessed array's base address.
/// @param ElemType The type of the accessed array elements.
/// @param Affine Whether all subscripts are affine expressions.
/// @param AccessValue Value read or written.
/// @param Subscripts Access subscripts per dimension.
/// @param Sizes The array dimension's sizes.
/// @param Kind The kind of memory accessed.
///
/// @return The created MemoryAccess, or nullptr if the access is not within
/// the SCoP.
MemoryAccess *addMemoryAccess(BasicBlock *BB, Instruction *Inst,
MemoryAccess::AccessType AccType,
Value *BaseAddress, Type *ElemType, bool Affine,
Value *AccessValue,
ArrayRef<const SCEV *> Subscripts,
ArrayRef<const SCEV *> Sizes,
ScopArrayInfo::MemoryKind Kind);
/// Create a MemoryAccess that represents either a LoadInst or
/// StoreInst.
///
/// @param MemAccInst The LoadInst or StoreInst.
/// @param AccType The kind of access.
/// @param BaseAddress The accessed array's base address.
/// @param ElemType The type of the accessed array elements.
/// @param IsAffine Whether all subscripts are affine expressions.
/// @param Subscripts Access subscripts per dimension.
/// @param Sizes The array dimension's sizes.
/// @param AccessValue Value read or written.
///
/// @see ScopArrayInfo::MemoryKind
void addArrayAccess(MemAccInst MemAccInst, MemoryAccess::AccessType AccType,
Value *BaseAddress, Type *ElemType, bool IsAffine,
ArrayRef<const SCEV *> Subscripts,
ArrayRef<const SCEV *> Sizes, Value *AccessValue);
/// Create a MemoryAccess for writing an llvm::Instruction.
///
/// The access will be created at the position of @p Inst.
///
/// @param Inst The instruction to be written.
///
/// @see ensureValueRead()
/// @see ScopArrayInfo::MemoryKind
void ensureValueWrite(Instruction *Inst);
/// Ensure an llvm::Value is available in the BB's statement, creating a
/// MemoryAccess for reloading it if necessary.
///
/// @param V The value expected to be loaded.
/// @param UserBB Where to reload the value.
///
/// @see ensureValueStore()
/// @see ScopArrayInfo::MemoryKind
void ensureValueRead(Value *V, BasicBlock *UserBB);
/// Create a write MemoryAccess for the incoming block of a phi node.
///
/// Each of the incoming blocks write their incoming value to be picked in the
/// phi's block.
///
/// @param PHI PHINode under consideration.
/// @param IncomingBlock Some predecessor block.
/// @param IncomingValue @p PHI's value when coming from @p IncomingBlock.
/// @param IsExitBlock When true, uses the .s2a alloca instead of the
/// .phiops one. Required for values escaping through a
/// PHINode in the SCoP region's exit block.
/// @see addPHIReadAccess()
/// @see ScopArrayInfo::MemoryKind
void ensurePHIWrite(PHINode *PHI, BasicBlock *IncomingBlock,
Value *IncomingValue, bool IsExitBlock);
/// Create a MemoryAccess for reading the value of a phi.
///
/// The modeling assumes that all incoming blocks write their incoming value
/// to the same location. Thus, this access will read the incoming block's
/// value as instructed by this @p PHI.
///
/// @param PHI PHINode under consideration; the READ access will be added
/// here.
///
/// @see ensurePHIWrite()
/// @see ScopArrayInfo::MemoryKind
void addPHIReadAccess(PHINode *PHI);
public:
explicit ScopBuilder(Region *R, AliasAnalysis &AA, const DataLayout &DL,
DominatorTree &DT, LoopInfo &LI, ScopDetection &SD,
ScalarEvolution &SE);
~ScopBuilder() {}
/// Try to build the Polly IR of static control part on the current
/// SESE-Region.
///
/// @return Give up the ownership of the scop object or static control part
/// for the region
std::unique_ptr<Scop> getScop() { return std::move(scop); }
};
} // end namespace polly
namespace llvm {
class PassRegistry;
void initializeScopInfoRegionPassPass(llvm::PassRegistry &);
void initializeScopInfoWrapperPassPass(llvm::PassRegistry &);
} // namespace llvm
#endif
| [
"dojo@dojos-MacBook-Pro.local"
] | dojo@dojos-MacBook-Pro.local |
460ec2f93c38390af4f8c6d069736a1332c301df | 77db07bb26f690b700ef8808152f1bbbcd2f5bda | /include/nanikanizer/dropout_expression.hpp | 4f9bc34ab0f3bda0b8caae830c63025fc9e9ee7d | [
"BSD-3-Clause",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | kbinani/nanikanizer | 167170f5e63bb6f0123093c1303142e343858139 | de109279485fbb03e2198a36f44f731ac8cc5224 | refs/heads/master | 2020-04-01T18:02:21.649310 | 2016-08-19T07:35:51 | 2016-08-19T07:35:51 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,371 | hpp | #pragma once
#include "expression.hpp"
#include "expression_node.hpp"
namespace nnk
{
template <class T>
class dropout_expression_node : public expression_node<T>
{
private:
typedef expression_node<T> base_type;
public:
typedef typename base_type::scalar_type scalar_type;
typedef typename base_type::tensor_type tensor_type;
typedef typename base_type::node_pointer node_pointer;
dropout_expression_node(const node_pointer& base, scalar_type ratio, const std::shared_ptr<bool>& train)
: base_(base)
, ratio_(ratio)
, train_(train)
{
BOOST_ASSERT(train);
}
virtual bool is_branch() override
{
return true;
}
virtual void forward() override
{
if (this->output().size() != base_->output().size())
this->output().resize(base_->output().size());
if (*train_)
{
if (filter_.size() != base_->output().size())
filter_.resize(base_->output().size());
std::uniform_real<> random;
for (std::size_t i = 0; i < filter_.size(); ++i)
filter_.set(i, ratio_ < random(generator_));
for (std::size_t i = 0; i < base_->output().size(); ++i)
{
if (filter_.test(i))
this->output()[i] = base_->output()[i];
else
this->output()[i] = static_cast<scalar_type>(0.0);
}
}
else
{
for (std::size_t i = 0; i < base_->output().size(); ++i)
this->output()[i] = base_->output()[i] * ratio_;
}
}
virtual void backward() override
{
if (*train_)
{
BOOST_ASSERT(filter_.size() == this->output_grad().size());
for (std::size_t i = 0; i < this->output_grad().size(); ++i)
{
if (filter_.test(i))
base_->output_grad()[i] += this->output_grad()[i];
}
}
else
{
for (std::size_t i = 0; i < this->output_grad().size(); ++i)
base_->output_grad()[i] += this->output_grad()[i] * ratio_;
}
}
virtual void enumerate_children(const std::function<void(expression_node_base*)>& callback) override
{
callback(base_.get());
}
private:
node_pointer base_;
scalar_type ratio_;
std::shared_ptr<bool> train_;
std::mt19937 generator_;
boost::dynamic_bitset<> filter_;
};
template <class T>
expression<T> dropout(const expression<T>& base, T ratio, const std::shared_ptr<bool>& train)
{
return expression<T>(std::make_shared<dropout_expression_node<T>>(base.root(), ratio, train));
}
}
| [
"pn.suzuki.kojiro@gmail.com"
] | pn.suzuki.kojiro@gmail.com |
dce2a4b7b7b82cb149123394b290481b8d2f5abc | a046e12a19e5d0e03e5688edd4ac26e3abeffff8 | /include/Calculator.hpp | 92d074d2b7e7173b7879db922a571b51ee5dafc8 | [] | no_license | qschwagle/Simple-Calculator | 55d1e38081edc732441dbc042ba4fec964d79965 | 280de01efdd8aee7f8b2cd2d4b0d95c6e21df916 | refs/heads/master | 2023-03-20T21:26:27.466982 | 2021-03-17T19:19:24 | 2021-03-17T19:19:24 | 295,261,214 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 370 | hpp | #pragma once
#include<string>
#include<vector>
#include<memory>
#include "Token.hpp"
class Calculator {
public:
Calculator()=default;
Calculator& operator=(const Calculator&)=delete;
Calculator(const Calculator&)=delete;
std::string evaluate(std::string expression);
private:
};
double evaluate(std::vector<std::unique_ptr<Token>>& list, int& pos);
| [
"qschwagle@gmail.com"
] | qschwagle@gmail.com |
02ddf35c89c65069261516476dec1848def5e6e4 | bf72d932e92eb7253f1cbb6285e931811ce86580 | /ch5/revision/errors.cpp | d5b84ef7ced03338e8820f45836baebfa726497f | [] | no_license | Wujfeng/Programado-Principoj-kaj-Praktikado | 16f25d5c2e4375f1c508cf2419c2a290d4dd26db | 59c1cc5a84622239d817ac916173a524b98bb7cf | refs/heads/master | 2021-05-07T22:04:06.960565 | 2016-12-01T02:01:05 | 2016-12-01T02:01:05 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 721 | cpp | // errors.cpp: practice how to find and handle errors.
// verdastelo; 0.1
// "std_lib_facilities.h" is a library written by Bjarne Stroustrup for
// use with his book "Programming Principles and Practice Using C++."
#include "std_lib_facilities.h"
class Bad_area{};
int area (int length, int width) {
if (length <= 0 || width <= 0) throw Bad_area();
return length * width;
}
int main()
try {
cout << "Enter length (l) and width (w). " << endl;
int l = 0; int w = 0;
cout << "length: ";
cin >> l;
cout << "width: ";
cin >> w;
int area1 = area(l, w);
cout << "area is " << area1 << endl;
return 0;
}
catch (Bad_area) {
cout << "Either length or width is either negative or zero." << endl;
}
| [
"verda_stelo@hotmail.com"
] | verda_stelo@hotmail.com |
e956dbc34c30957b1633c2aa6900e36e806853e9 | 12aad6ffc62101c91dfe72d9c5edf3881a5c7249 | /GraphicsTest/Game2dGraphicdoth/GameOverState.h | 592cbeaed64fdc1eb3c40ed9e8fc3f693ad9cd2d | [] | no_license | trongcongdn/MyProject | 8be325f901c6702315dd734a712081970a596bdc | 043f9163fd697cec60344b3c700191af1c6cb996 | refs/heads/master | 2021-01-19T11:09:06.126602 | 2017-04-11T13:41:10 | 2017-04-11T13:41:10 | 87,933,210 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 127 | h | #pragma once
#include "State.h"
class GameOverState :
public State
{
public:
GameOverState();
virtual ~GameOverState();
};
| [
"nguyentrongcong.13i3@gmail.com"
] | nguyentrongcong.13i3@gmail.com |
178599d8995e22548eb0e6679dd9ca3f0c9bc38e | 0064d4b6f3908b2989a7965e49afa3f4bf65d095 | /leetcode+牛客/非相邻的地块种花问题.cpp | 7bff40bd59f2409d610b190dc7542777c38e765f | [] | no_license | MyHiHi/myLeetcode | d7a5c1c3a3a30ba517183f97369ed6c95e90cae3 | ca36041af7f73d91c95cdbe9599ac5ec15a1243c | refs/heads/master | 2021-05-20T08:29:37.017725 | 2020-05-03T05:17:05 | 2020-05-03T05:17:05 | 252,196,933 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,351 | cpp | /*
@File : 非相邻的地块种花问题.cpp
@Time : 2020/03/22 09:59:23
@Author : Zhang tao
@Version : 1.0
@Desc : 非相邻的地块种花问题.cpp
*/
/*
假设你有一个很长的花坛,一部分地块种植了花,另一部分却没有。可是,花卉不能种植在相邻的地块上,它们会争夺水源,两者都会死去。
给定一个花坛(表示为一个数组包含0和1,其中0表示没种植花,1表示种植了花),和一个数 n 。能否在不打破种植规则的情况下种入 n 朵花?能则返回True,不能则返回False。
示例 1:
输入: flowerbed = [1,0,0,0,1], n = 1
输出: True
示例 2:
输入: flowerbed = [1,0,0,0,1], n = 2
输出: False
*/
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
class Solution
{
public:
// 最左边和最后添加0
bool canPlaceFlowers(vector<int> &flowerbed, int n)
{
flowerbed.insert(flowerbed.begin(), 0);
flowerbed.push_back(0);
int le = flowerbed.size(), i = 0;
while (n > 0 && i + 2 < le)
{
if (flowerbed[i] == 0 && flowerbed[i + 1] == 0 && flowerbed[i + 2] == 0)
{
flowerbed[i + 1] = 1;
n--;
}
i++;
}
if (n == 0)
return true;
return false;
}
};
int main()
{
return 0;
}
| [
"909535692@qq.com"
] | 909535692@qq.com |
545a584e6342e90a4088ce202ef1995ff5dca01e | 76c0d4608b7d7b7efd00744e904e51865394e64f | /STL/员工分组.cpp | d764f4894fc3b31f8177dbb267cadfbe9d5a012b | [] | no_license | ThreshKing/ubuntu-vscode | 695f224718753f525d69c26880c4bc975af4dcc7 | ea667d88b5eed2408cbe31b5be7f61b72843e630 | refs/heads/master | 2023-02-24T04:17:37.978572 | 2021-02-02T03:02:33 | 2021-02-02T03:02:33 | 330,846,016 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,166 | cpp | #include<iostream>
#include<vector>
#include<map>
#include<string>
#include<ctime>
using namespace std;
#define CEHUA 0
#define MEISHU 1
#define YANFA 2
class Worker
{
public:
string m_Name;
int m_Salary;
};
void createWorker(vector<Worker> &v)
{
string nameSeed = "ABCDEFGHIJ";
for(int i=0; i<10; i++)
{
Worker worker;
worker.m_Name = "员工";
worker.m_Name += nameSeed[i];
worker.m_Salary = rand() % 10000 + 10000; //10000~19999
v.push_back(worker);
}
}
void setGroup(vector<Worker>&v, multimap<int, Worker>&m)
{
for(vector<Worker>::iterator it = v.begin(); it != v.end(); it++)
{
//产生随机部门编号
int deptId = rand() % 3; // 0 1 2
m.insert(make_pair(deptId, *it));
}
}
void showWorkerByGroup(multimap<int, Worker>&m)
{
cout << "策划部门: " << endl;
multimap<int, Worker>::iterator pos = m.find(CEHUA);
int count = m.count(CEHUA);
int index = 0;
for(; pos != m.end() && index < count; pos++, index++)
{
cout << "姓名: " << pos->second.m_Name << "工资: " << pos->second.m_Salary << endl;
}
cout << "--------------------------------------------" << endl;
cout << "美术部门: " << endl;
pos = m.find(MEISHU);
count = m.count(MEISHU);
index = 0;
for(; pos != m.end() && index < count; pos++, index++)
{
cout << "姓名: " << pos->second.m_Name << "工资: " << pos->second.m_Salary << endl;
}
cout << "--------------------------------------------" << endl;
cout << "研发部门: " << endl;
pos = m.find(YANFA);
count = m.count(YANFA);
index = 0;
for(; pos != m.end() && index < count; pos++, index++)
{
cout << "姓名: " << pos->second.m_Name << "工资: " << pos->second.m_Salary << endl;
}
}
int main()
{
srand((unsigned int)time(NULL));
//1、创建员工
vector<Worker> vWorker;
createWorker(vWorker);
//2、员工分组
multimap<int, Worker> mWorker;
setGroup(vWorker,mWorker);
//3、分组显示员工
showWorkerByGroup(mWorker);
return 0;
} | [
"547151291@qq.com"
] | 547151291@qq.com |
1ee1268241fdb6765fca7c421af7f568ce24433e | b7f3edb5b7c62174bed808079c3b21fb9ea51d52 | /base/test/reached_code_profiler_android.cc | cfedc6b37a8de6f9bc3a518214a74c1fda6d7f3b | [
"BSD-3-Clause"
] | permissive | otcshare/chromium-src | 26a7372773b53b236784c51677c566dc0ad839e4 | 64bee65c921db7e78e25d08f1e98da2668b57be5 | refs/heads/webml | 2023-03-21T03:20:15.377034 | 2020-11-16T01:40:14 | 2020-11-16T01:40:14 | 209,262,645 | 18 | 21 | BSD-3-Clause | 2023-03-23T06:20:07 | 2019-09-18T08:52:07 | null | UTF-8 | C++ | false | false | 798 | cc | // Copyright 2019 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 "base/android/jni_android.h"
#include "base/android/reached_code_profiler.h"
#include "base/test/test_support_jni_headers/ReachedCodeProfiler_jni.h"
// This file provides functions to query the state of the reached code profiler
// from Java. It's used only for tests.
namespace base {
namespace android {
static jboolean JNI_ReachedCodeProfiler_IsReachedCodeProfilerEnabled(
JNIEnv* env) {
return IsReachedCodeProfilerEnabled();
}
static jboolean JNI_ReachedCodeProfiler_IsReachedCodeProfilerSupported(
JNIEnv* env) {
return IsReachedCodeProfilerSupported();
}
} // namespace android
} // namespace base
| [
"commit-bot@chromium.org"
] | commit-bot@chromium.org |
feef0d1b79fd45bd63fb3e0199c2c23796c76a2d | d2e27b839614d8b23022ab12dd1c116845b2912b | /Mahatta/Source/Game/Interval.cpp | a3f3eb94a89c112b2bb4c1e46fdeb667ea29dce3 | [] | no_license | Crogarox/Mahatta | c734acd3c4779036d4232c18c98012d4eaab926e | 039a708f9cbde426a146d8b9e6bfb14ba72abb83 | refs/heads/master | 2021-12-18T00:12:26.527787 | 2012-10-03T07:09:42 | 2012-10-03T07:09:42 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 877 | cpp | #include "game_sequence.h"
namespace Sequence
{
/// @brief Clears the selection
void Interval::Clear (void)
{
mCount = 0;
}
/// @brief Removes the interval from the range
void Interval::Remove (void)
{
delete this;
}
/// @brief Gets the starting position and select count
/// @param where [out] If non-empty, the starting position
/// @return Count of selected items
Uint Interval::Get (Uint & where)
{
if (0 == mCount) return 0;
where = mWhere;
return mCount;
}
/// @brief Makes a selection
/// @param where Index from which to begin selection
/// @param count Count of items to select
/// @return Count of items selected
Uint Interval::Set (Uint where, Uint count)
{
if (!mOwner->IsItemValid(where, true)) return 0;
mWhere = where;
mCount = mOwner->Trim(where, count);
return mCount;
}
} | [
"david.dionisio@lanternla.com"
] | david.dionisio@lanternla.com |
a066f69779b0746fb824e47634934017275d7ed6 | 846a7668ac964632bdb6db639ab381be11c13b77 | /android/hardware/qcom/display/sdm845/sdm/include/core/display_interface.h | 524141ec78cdacf77d44c7926b34b95edade5faa | [] | no_license | BPI-SINOVOIP/BPI-A64-Android8 | f2900965e96fd6f2a28ced68af668a858b15ebe1 | 744c72c133b9bf5d2e9efe0ab33e01e6e51d5743 | refs/heads/master | 2023-05-21T08:02:23.364495 | 2020-07-15T11:27:51 | 2020-07-15T11:27:51 | 143,945,191 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 24,252 | h | /*
* Copyright (c) 2014 - 2017, The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted
* provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice, this list of
* conditions and the following disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of The Linux Foundation 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 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NON-INFRINGEMENT 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.
*/
/*! @file display_interface.h
@brief Interface file for display device which represents a physical panel or an output buffer
where contents can be rendered.
@details Display device is used to send layer buffers for composition and get them rendered onto
the target device. Each display device represents a unique display target which may be either a
physical panel or an output buffer..
*/
#ifndef __DISPLAY_INTERFACE_H__
#define __DISPLAY_INTERFACE_H__
#include <stdint.h>
#include <string>
#include <vector>
#include <utility>
#include "layer_stack.h"
#include "sdm_types.h"
namespace sdm {
typedef std::vector<std::pair<std::string, std::string>> AttrVal;
/*! @brief This enum represents display device types where contents can be rendered.
@sa CoreInterface::CreateDisplay
@sa CoreInterface::IsDisplaySupported
*/
enum DisplayType {
kPrimary, //!< Main physical display which is attached to the handheld device.
kHDMI, //!< HDMI physical display which is generally detachable.
kVirtual, //!< Contents would be rendered into the output buffer provided by the client
//!< e.g. wireless display.
kDisplayMax,
};
/*! @brief This enum represents states of a display device.
@sa DisplayInterface::GetDisplayState
@sa DisplayInterface::SetDisplayState
*/
enum DisplayState {
kStateOff, //!< Display is OFF. Contents are not rendered in this state. Client will not
//!< receive VSync events in this state. This is default state as well.
kStateOn, //!< Display is ON. Contents are rendered in this state.
kStateDoze, //!< Display is ON and it is configured in a low power state.
kStateDozeSuspend,
//!< Display is ON in a low power state and continue showing its current
//!< contents indefinitely until the mode changes.
kStateStandby, //!< Display is OFF. Client will continue to receive VSync events in this state
//!< if VSync is enabled. Contents are not rendered in this state.
};
/*! @brief This enum represents flags to override detail enhancer parameters.
@sa DisplayInterface::SetDetailEnhancerData
*/
enum DetailEnhancerOverrideFlags {
kOverrideDEEnable = 0x1, // Specifies to enable detail enhancer
kOverrideDESharpen1 = 0x2, // Specifies user defined Sharpening/smooth for noise
kOverrideDESharpen2 = 0x4, // Specifies user defined Sharpening/smooth for signal
kOverrideDEClip = 0x8, // Specifies user defined DE clip shift
kOverrideDELimit = 0x10, // Specifies user defined DE limit value
kOverrideDEThrQuiet = 0x20, // Specifies user defined DE quiet threshold
kOverrideDEThrDieout = 0x40, // Specifies user defined DE dieout threshold
kOverrideDEThrLow = 0x80, // Specifies user defined DE low threshold
kOverrideDEThrHigh = 0x100, // Specifies user defined DE high threshold
kOverrideDEFilterConfig = 0x200, // Specifies user defined scaling filter config
kOverrideDEMax = 0xFFFFFFFF,
};
/*! @brief This enum represents Y/RGB scaling filter configuration.
@sa DisplayInterface::SetDetailEnhancerData
*/
enum ScalingFilterConfig {
kFilterEdgeDirected,
kFilterCircular,
kFilterSeparable,
kFilterBilinear,
kFilterMax,
};
/*! @brief This enum represents the quality level of the content.
@sa DisplayInterface::SetDetailEnhancerData
*/
enum ContentQuality {
kContentQualityUnknown, // Default: high artifact and noise
kContentQualityLow, // Low quality content, high artifact and noise,
kContentQualityMedium, // Medium quality, medium artifact and noise,
kContentQualityHigh, // High quality content, low artifact and noise
kContentQualityMax,
};
/*! @brief This enum represents the display port.
@sa DisplayInterface::GetDisplayPort
*/
enum DisplayPort {
kPortDefault,
kPortDSI, // Display is connected to DSI port.
kPortDTV, // Display is connected to DTV port
kPortWriteBack, // Display is connected to writeback port
kPortLVDS, // Display is connected to LVDS port
kPortEDP, // Display is connected to EDP port
kPortDP, // Display is connected to DP port.
};
/*! @brief This structure defines configuration for fixed properties of a display device.
@sa DisplayInterface::GetConfig
@sa DisplayInterface::SetConfig
*/
struct DisplayConfigFixedInfo {
bool underscan = false; //!< If display support CE underscan.
bool secure = false; //!< If this display is capable of handling secure content.
bool is_cmdmode = false; //!< If panel is command mode panel.
bool hdr_supported = false; //!< if HDR is enabled
uint32_t max_luminance = 0; //!< From Panel's peak luminance
uint32_t average_luminance = 0; //!< From Panel's average luminance
uint32_t min_luminance = 0; //!< From Panel's blackness level
};
/*! @brief This structure defines configuration for variable properties of a display device.
@sa DisplayInterface::GetConfig
@sa DisplayInterface::SetConfig
*/
struct DisplayConfigVariableInfo {
uint32_t x_pixels = 0; //!< Total number of pixels in X-direction on the display panel.
uint32_t y_pixels = 0; //!< Total number of pixels in Y-direction on the display panel.
float x_dpi = 0.0f; //!< Dots per inch in X-direction.
float y_dpi = 0.0f; //!< Dots per inch in Y-direction.
uint32_t fps = 0; //!< Frame rate per second.
uint32_t vsync_period_ns = 0; //!< VSync period in nanoseconds.
bool is_yuv = false; //!< If the display output is in YUV format.
};
/*! @brief Event data associated with VSync event.
@sa DisplayEventHandler::VSync
*/
struct DisplayEventVSync {
int64_t timestamp = 0; //!< System monotonic clock timestamp in nanoseconds.
};
/*! @brief The structure defines the user input for detail enhancer module.
@sa DisplayInterface::SetDetailEnhancerData
*/
struct DisplayDetailEnhancerData {
uint32_t override_flags = 0; // flags to specify which data to be set.
uint16_t enable = 0; // Detail enchancer enable
int16_t sharpen_level1 = 0; // Sharpening/smooth strenght for noise
int16_t sharpen_level2 = 0; // Sharpening/smooth strenght for signal
uint16_t clip = 0; // DE clip shift
uint16_t limit = 0; // DE limit value
uint16_t thr_quiet = 0; // DE quiet threshold
uint16_t thr_dieout = 0; // DE dieout threshold
uint16_t thr_low = 0; // DE low threshold
uint16_t thr_high = 0; // DE high threshold
int32_t sharp_factor = 50; // sharp_factor specifies sharpness/smoothness level,
// range -100..100 positive for sharpness and negative for
// smoothness
ContentQuality quality_level = kContentQualityUnknown;
// Specifies context quality level
ScalingFilterConfig filter_config = kFilterEdgeDirected;
// Y/RGB filter configuration
};
/*! @brief Display device event handler implemented by the client.
@details This class declares prototype for display device event handler methods which must be
implemented by the client. Display device will use these methods to notify events to the client.
Client must post heavy-weight event handling to a separate thread and unblock display manager
thread instantly.
@sa CoreInterface::CreateDisplay
*/
class DisplayEventHandler {
public:
/*! @brief Event handler for VSync event.
@details This event is dispatched on every vertical synchronization. The event is disabled by
default.
@param[in] vsync \link DisplayEventVSync \endlink
@return \link DisplayError \endlink
@sa DisplayInterface::GetDisplayState
@sa DisplayInterface::SetDisplayState
*/
virtual DisplayError VSync(const DisplayEventVSync &vsync) = 0;
/*! @brief Event handler for Refresh event.
@details This event is dispatched to trigger a screen refresh. Client must call Prepare() and
Commit() in response to it from a separate thread. There is no data associated with this
event.
@return \link DisplayError \endlink
@sa DisplayInterface::Prepare
@sa DisplayInterface::Commit
*/
virtual DisplayError Refresh() = 0;
/*! @brief Event handler for CEC messages.
@details This event is dispatched to send CEC messages to the CEC HAL.
@param[in] message message to be sent
@return \link DisplayError \endlink
*/
virtual DisplayError CECMessage(char *message) = 0;
protected:
virtual ~DisplayEventHandler() { }
};
struct PPDisplayAPIPayload;
struct PPPendingParams;
/*! @brief Display device interface.
@details This class defines display device interface. It contains methods which client shall use
to configure or submit layers for composition on the display device. This interface is created
during display device creation and remains valid until destroyed.
@sa CoreInterface::CreateDisplay
@sa CoreInterface::DestroyDisplay
*/
class DisplayInterface {
public:
/*! @brief Method to determine hardware capability to compose layers associated with given frame.
@details Client shall send all layers associated with a frame targeted for current display
using this method and check the layers which can be handled completely in display manager.
Client shall mark composition type for one of the layer as kCompositionGPUTarget; the GPU
composed output would be rendered at the specified layer if some of the layers are not handled
by SDM.
Display manager will set each layer as kCompositionGPU or kCompositionSDE upon return. Client
shall render all the layers marked as kCompositionGPU using GPU.
This method can be called multiple times but only last call prevails. This method must be
followed by Commit().
@param[inout] layer_stack \link LayerStack \endlink
@return \link DisplayError \endlink
@sa Commit
*/
virtual DisplayError Prepare(LayerStack *layer_stack) = 0;
/*! @brief Method to commit layers of a frame submitted in a former call to Prepare().
@details Client shall call this method to submit layers for final composition. The composed
output would be displayed on the panel or written in output buffer.
Client must ensure that layer stack is same as previous call to Prepare.
This method shall be called only once for each frame.
In the event of an error as well, this call will cause any fences returned in the previous call
to Commit() to eventually become signaled, so the client's wait on fences can be released to
prevent deadlocks.
@param[in] layer_stack \link LayerStack \endlink
@return \link DisplayError \endlink
@sa Prepare
*/
virtual DisplayError Commit(LayerStack *layer_stack) = 0;
/*! @brief Method to flush any pending buffers/fences submitted previously via Commit() call.
@details Client shall call this method to request the Display manager to release all buffers and
respective fences currently in use. This operation may result in a blank display on the panel
until a new frame is submitted for composition.
@return \link DisplayError \endlink
@sa Prepare
@sa Commit
*/
virtual DisplayError Flush() = 0;
/*! @brief Method to get current state of the display device.
@param[out] state \link DisplayState \endlink
@return \link DisplayError \endlink
@sa SetDisplayState
*/
virtual DisplayError GetDisplayState(DisplayState *state) = 0;
/*! @brief Method to get number of configurations(variable properties) supported on the display
device.
@param[out] count Number of modes supported; mode index starts with 0.
@return \link DisplayError \endlink
*/
virtual DisplayError GetNumVariableInfoConfigs(uint32_t *count) = 0;
/*! @brief Method to get configuration for fixed properties of the display device.
@param[out] fixed_info \link DisplayConfigFixedInfo \endlink
@return \link DisplayError \endlink
*/
virtual DisplayError GetConfig(DisplayConfigFixedInfo *fixed_info) = 0;
/*! @brief Method to get configuration for variable properties of the display device.
@param[in] index index of the mode
@param[out] variable_info \link DisplayConfigVariableInfo \endlink
@return \link DisplayError \endlink
*/
virtual DisplayError GetConfig(uint32_t index, DisplayConfigVariableInfo *variable_info) = 0;
/*! @brief Method to get index of active configuration of the display device.
@param[out] index index of the mode corresponding to variable properties.
@return \link DisplayError \endlink
*/
virtual DisplayError GetActiveConfig(uint32_t *index) = 0;
/*! @brief Method to get VSync event state. Default event state is disabled.
@param[out] enabled vsync state
@return \link DisplayError \endlink
*/
virtual DisplayError GetVSyncState(bool *enabled) = 0;
/*! @brief Method to set current state of the display device.
@param[in] state \link DisplayState \endlink
@return \link DisplayError \endlink
@sa SetDisplayState
*/
virtual DisplayError SetDisplayState(DisplayState state) = 0;
/*! @brief Method to set active configuration for variable properties of the display device.
@param[in] variable_info \link DisplayConfigVariableInfo \endlink
@return \link DisplayError \endlink
*/
virtual DisplayError SetActiveConfig(DisplayConfigVariableInfo *variable_info) = 0;
/*! @brief Method to set active configuration for variable properties of the display device.
@param[in] index index of the mode corresponding to variable properties.
@return \link DisplayError \endlink
*/
virtual DisplayError SetActiveConfig(uint32_t index) = 0;
/*! @brief Method to set VSync event state. Default event state is disabled.
@param[out] enabled vsync state
@return \link DisplayError \endlink
*/
virtual DisplayError SetVSyncState(bool enable) = 0;
/*! @brief Method to set idle timeout value. Idle fallback is disabled with timeout value 0.
@param[in] active_ms value in milliseconds.
@return \link void \endlink
*/
virtual void SetIdleTimeoutMs(uint32_t active_ms) = 0;
/*! @brief Method to set maximum number of mixer stages for each display.
@param[in] max_mixer_stages maximum number of mixer stages.
@return \link DisplayError \endlink
*/
virtual DisplayError SetMaxMixerStages(uint32_t max_mixer_stages) = 0;
/*! @brief Method to control partial update feature for each display.
@param[in] enable partial update feature control flag
@param[out] pending whether the operation is completed or pending for completion
@return \link DisplayError \endlink
*/
virtual DisplayError ControlPartialUpdate(bool enable, uint32_t *pending) = 0;
/*! @brief Method to disable partial update for at least 1 frame.
@return \link DisplayError \endlink
*/
virtual DisplayError DisablePartialUpdateOneFrame() = 0;
/*! @brief Method to set the mode of the primary display.
@param[in] mode the new display mode.
@return \link DisplayError \endlink
*/
virtual DisplayError SetDisplayMode(uint32_t mode) = 0;
/*! @brief Method to get the min and max refresh rate of a display.
@param[out] min and max refresh rate.
@return \link DisplayError \endlink
*/
virtual DisplayError GetRefreshRateRange(uint32_t *min_refresh_rate,
uint32_t *max_refresh_rate) = 0;
/*! @brief Method to set the refresh rate of a display.
@param[in] refresh_rate new refresh rate of the display.
@param[in] final_rate indicates whether refresh rate is final rate or can be changed by sdm
@return \link DisplayError \endlink
*/
virtual DisplayError SetRefreshRate(uint32_t refresh_rate, bool final_rate) = 0;
/*! @brief Method to query whether scanning is support for the HDMI display.
@return \link DisplayError \endlink
*/
virtual bool IsUnderscanSupported() = 0;
/*! @brief Method to set brightness of the primary display.
@param[in] level the new backlight level.
@return \link DisplayError \endlink
*/
virtual DisplayError SetPanelBrightness(int level) = 0;
/*! @brief Method to cache brightness of the primary display.
@param[in] level the new backlight level.
@return \link DisplayError \endlink
*/
virtual DisplayError CachePanelBrightness(int level) = 0;
/*! @brief Method to notify display about change in min HDCP encryption level.
@param[in] min_enc_level minimum encryption level value.
@return \link DisplayError \endlink
*/
virtual DisplayError OnMinHdcpEncryptionLevelChange(uint32_t min_enc_level) = 0;
/*! @brief Method to route display API requests to color service.
@param[in] in_payload \link PPDisplayAPIPayload \endlink
@param[out] out_payload \link PPDisplayPayload \endlink
@param[out] pending_action \link PPPendingParams \endlink
@return \link DisplayError \endlink
*/
virtual DisplayError ColorSVCRequestRoute(const PPDisplayAPIPayload &in_payload,
PPDisplayAPIPayload *out_payload,
PPPendingParams *pending_action) = 0;
/*! @brief Method to request the number of color modes supported.
@param[out] mode_count Number of modes
@return \link DisplayError \endlink
*/
virtual DisplayError GetColorModeCount(uint32_t *mode_count) = 0;
/*! @brief Method to request the information of supported color modes.
@param[inout] mode_count Number of updated modes
@param[out] vector of mode strings
@return \link DisplayError \endlink
*/
virtual DisplayError GetColorModes(uint32_t *mode_count,
std::vector<std::string> *color_modes) = 0;
/*! @brief Method to request the attributes of color mode.
@param[in] mode name
@param[out] vector of mode attributes
@return \link DisplayError \endlink
*/
virtual DisplayError GetColorModeAttr(const std::string &color_mode,
AttrVal *attr_map) = 0;
/*! @brief Method to set the color mode
@param[in] mode_name Mode name which needs to be set
@return \link DisplayError \endlink
*/
virtual DisplayError SetColorMode(const std::string &color_mode) = 0;
/*! @brief Method to set the color mode by ID. This method is used for debugging only.
@param[in] mode_name Mode ID which needs to be set
@return \link DisplayError \endlink
*/
virtual DisplayError SetColorModeById(int32_t color_mode_id) = 0;
/*! @brief Method to set the color transform
@param[in] length Mode name which needs to be set
@param[in] color_transform 4x4 Matrix for color transform
@return \link DisplayError \endlink
*/
virtual DisplayError SetColorTransform(const uint32_t length, const double *color_transform) = 0;
/*! @brief Method to get the default color mode.
@param[out] default mode name
@return \link DisplayError \endlink
*/
virtual DisplayError GetDefaultColorMode(std::string *color_mode) = 0;
/*! @brief Method to request applying default display mode.
@return \link DisplayError \endlink
*/
virtual DisplayError ApplyDefaultDisplayMode() = 0;
/*! @brief Method to set the position of the hw cursor.
@param[in] x \link x position \endlink
@param[in] y \link y position \endlink
@return \link DisplayError \endlink
*/
virtual DisplayError SetCursorPosition(int x, int y) = 0;
/*! @brief Method to get the brightness level of the display
@param[out] level brightness level
@return \link DisplayError \endlink
*/
virtual DisplayError GetPanelBrightness(int *level) = 0;
/*! @brief Method to set layer mixer resolution.
@param[in] width layer mixer width
@param[in] height layer mixer height
@return \link DisplayError \endlink
*/
virtual DisplayError SetMixerResolution(uint32_t width, uint32_t height) = 0;
/*! @brief Method to get layer mixer resolution.
@param[out] width layer mixer width
@param[out] height layer mixer height
@return \link DisplayError \endlink
*/
virtual DisplayError GetMixerResolution(uint32_t *width, uint32_t *height) = 0;
/*! @brief Method to set frame buffer configuration.
@param[in] variable_info \link DisplayConfigVariableInfo \endlink
@return \link DisplayError \endlink
*/
virtual DisplayError SetFrameBufferConfig(const DisplayConfigVariableInfo &variable_info) = 0;
/*! @brief Method to get frame buffer configuration.
@param[out] variable_info \link DisplayConfigVariableInfo \endlink
@return \link DisplayError \endlink
*/
virtual DisplayError GetFrameBufferConfig(DisplayConfigVariableInfo *variable_info) = 0;
/*! @brief Method to set detail enhancement data.
@param[in] de_data \link DisplayDetailEnhancerData \endlink
@return \link DisplayError \endlink
*/
virtual DisplayError SetDetailEnhancerData(const DisplayDetailEnhancerData &de_data) = 0;
/*! @brief Method to get display port information.
@param[out] port \link DisplayPort \endlink
@return \link DisplayError \endlink
*/
virtual DisplayError GetDisplayPort(DisplayPort *port) = 0;
/*! @brief Method to query whether it is Primrary device.
@return true if this interface is primary.
*/
virtual bool IsPrimaryDisplay() = 0;
/*! @brief Method to toggle composition types handling by SDM.
@details Client shall call this method to request SDM to enable/disable a specific type of
layer composition. If client disables a composition type, SDM will not handle any of the layer
composition using the disabled method in a draw cycle. On lack of resources to handle all
layers using other enabled composition methods, Prepare() will return an error.
Request to toggle composition type is applied from subsequent draw cycles.
Default state of all defined composition types is enabled.
@param[in] composition_type \link LayerComposition \endlink
@param[in] enable \link enable composition type \endlink
@return \link DisplayError \endlink
@sa Prepare
*/
virtual DisplayError SetCompositionState(LayerComposition composition_type, bool enable) = 0;
protected:
virtual ~DisplayInterface() { }
};
} // namespace sdm
#endif // __DISPLAY_INTERFACE_H__
| [
"mingxin.android@gmail.com"
] | mingxin.android@gmail.com |
e07b5abe66a20e80b1511d3ed4be361d4e5bf2ff | f84344c4f667804f27e559a1e92b28b00a8a22e9 | /Database Implementation/C++/ibtree/tree/PLI/PLI.h | 98b26890378de626c2b61ff9ad4c73fed23241ec | [] | no_license | TonHai1111/DB_Implementation | 27f79f0858767ba8ced4d460d1e9f7481968ae8b | 5a1057f2b178bc9b3337cbbfb585c5af496f47d9 | refs/heads/main | 2023-06-15T21:24:16.175190 | 2021-05-07T20:34:46 | 2021-05-07T20:34:46 | 354,896,195 | 0 | 0 | null | 2021-05-07T20:34:46 | 2021-04-05T16:20:32 | Python | UTF-8 | C++ | false | false | 1,076 | h | #ifndef PLI_h
#define PLI_h
#include "Types/PLIDataType.h"
#include "../tools/Operations.h"
#include "../PLITypes/Constants.h"
#include "../tools/StringFunctions.h"
#include <iostream>
#include <string>
#include <sstream>
#include <fstream>
#include <vector>
class PLI
{
public:
clusteredData * clustered;
overflowData overflow = overflowData();
int indexC = 0;
int countC = 0;
int countO = 0;
std::string database = "PLIdata.dat";
std::string metadata = "PLImeta.dat";
long offset = 0;
std::ofstream outFile;
PLI();
~PLI();
void setFile(std::string databaseFile, std::string metadataFile);
void OpenDatabase();
void CloseDatabase();
//#############<Insert>##############
int insertTuple(const float & key, const std::string & data);
int insertTupleOverflow(const float & key, const std::string & data);
//#############<Search>##############
int searchBucketIDs(std::vector<std::streampos>& _output, Interval _interval);
int searchTuples(std::vector<long> & _output, Interval _interval);
void writeMetaData();
void readMetaData();
};
#endif
| [
"tonthatdaihai@gmail.com"
] | tonthatdaihai@gmail.com |
a8a50201ac8da126e1e53496caa33beac48d8ce7 | 749be0e5c746296fa5069c99b62509edafeb0b58 | /ListOfInt/ListOfInt.h | 41bf9773dbc655a2d688d67674bc8f5ad5bc9a4c | [] | no_license | cniel/cpp_projects | 80b92e5ffe10c251e54e32d874395f4c182341a2 | ca46dcf2ef226e9ff634cadc936c93eb235ea0e0 | refs/heads/master | 2021-01-23T20:44:23.829154 | 2014-06-01T14:20:05 | 2014-06-01T14:20:05 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 477 | h | #ifndef LISTOFINT_H
#define LISTOFINT_H
#include <iostream>
using namespace std;
class ListOfInt
{
private:
struct item{
int num;
item* next;
};
item* _first;
item* _last;
int _size;
public:
ListOfInt();
~ListOfInt();
void Append(int num);
void Unshift(int num);
void Pop();
void Shift();
item* RemoveFirst(int num);
void RemoveAll(int num);
bool IsEmpty();
void Display();
int GetSize();
};
#endif | [
"niel.clement@gmail.com"
] | niel.clement@gmail.com |
a76d434a7e5d664a89e235b894d2d7792b3e3714 | 31dec155a9e069adfcf209238677b49d23bf1694 | /libraries/Statistic/examples/Average/Average.ino | 90e755a1d78a815a546d72b0fe31e9b1d5ef3671 | [
"MIT"
] | permissive | jantje/Arduino | 75a35cfb2e2ce7a1a78ba545ac30ac8c752d1aa8 | cd40e51b4eb9f8947aa58f278f61c9121d711fb0 | refs/heads/master | 2021-12-03T11:16:44.274410 | 2021-07-11T13:37:02 | 2021-07-11T13:37:02 | 382,966,519 | 0 | 0 | MIT | 2021-07-04T23:21:23 | 2021-07-04T23:21:22 | null | UTF-8 | C++ | false | false | 1,334 | ino | //
// FILE: Average.ino
// AUTHOR: Rob dot Tillaart at gmail dot com
// VERSION: 0.4
// PURPOSE: Sample sketch for statistic library Arduino
//
#include "Statistic.h"
Statistic myStats;
uint32_t start;
uint32_t stop;
void setup(void)
{
Serial.begin(115200);
Serial.println(__FILE__);
Serial.print("Demo Statistics lib ");
Serial.println(STATISTIC_LIB_VERSION);
myStats.clear(); //explicitly start clean
start = millis();
}
void loop(void)
{
long rn = random(0, 9999);
myStats.add(rn / 100.0 + 1);
if (myStats.count() == 10000)
{
stop = millis();
Serial.print(" Count: ");
Serial.println(myStats.count());
Serial.print(" Min: ");
Serial.println(myStats.minimum(), 4);
Serial.print(" Max: ");
Serial.println(myStats.maximum(), 4);
Serial.print(" Average: ");
Serial.println(myStats.average(), 4);
Serial.print(" variance: ");
Serial.println(myStats.variance(), 4);
Serial.print(" pop stdev: ");
Serial.println(myStats.pop_stdev(), 4);
Serial.print(" unbias stdev: ");
Serial.println(myStats.unbiased_stdev(), 4);
Serial.print(" time(ms): ");
Serial.println(stop - start);
Serial.println("=====================================");
myStats.clear();
delay(1000);
start = millis();
}
} | [
"rob.tillaart@gmail.com"
] | rob.tillaart@gmail.com |
9f7ed61680148f1c8aecd6686b2aaff7ae5be3d7 | 084c3fd59ae20cc9f4ee77f839b8b4c4f920266d | /kattis/perfectpowers.cpp | ffcb3fbbfc8900cf20b5898fd950f71828a5f85f | [] | no_license | dawidjaja/competitive-programming | 24d06c73d6ddbc931f1a2fe1bc2766f4e401bbf4 | a8c52ad8bfe8ac6908b3666abc3026da7ea8f27d | refs/heads/master | 2021-06-17T20:22:21.309523 | 2021-03-17T09:19:45 | 2021-03-17T09:19:45 | 149,089,446 | 0 | 0 | null | 2019-10-14T15:26:49 | 2018-09-17T07:57:52 | C++ | UTF-8 | C++ | false | false | 642 | cpp | #include<bits/stdc++.h>
using namespace std;
long long n;
int main() {
while (scanf("%lld", &n) && n) {
vector<long long> factors;
for (long long i = 2; i * i <= abs(n); i++) {
long long cnt = 0;
while (n % i == 0) {
cnt++;
n /= i;
}
factors.push_back(cnt);
}
if (abs(n) != 1)
factors.push_back(1);
long long cur = 0;
for (long long factor: factors)
cur = __gcd(cur, factor);
while (n < 0 && cur % 2 == 0)
cur /= 2;
printf("%lld\n", cur ? : 1LL);
}
}
| [
"dalfred2000@gmail.com"
] | dalfred2000@gmail.com |
a10f06304a9b9b02797f3078c010fb5ee4c26f1d | 69c4f6088a11bdaf787dc22c85e494e593a11914 | /webrtc/modules/audio_processing/aec3/aec_state.cc | df56c3a433f793c2597eee8ef89583db953185d9 | [
"BSD-3-Clause",
"LicenseRef-scancode-google-patent-license-webrtc"
] | permissive | xuanniao/pulseaudio-webrtc-audio-processing | 902854e7822a339dbc5e9d29ebce44ec31055f8b | e31340c243f034e26e1e876f3f32fc842f5e5b5b | refs/heads/master | 2022-05-10T06:54:44.936642 | 2021-10-19T22:33:06 | 2021-10-20T15:16:19 | 248,706,924 | 0 | 0 | BSD-3-Clause | 2020-03-20T08:41:09 | 2020-03-20T08:41:09 | null | UTF-8 | C++ | false | false | 18,800 | cc | /*
* Copyright (c) 2017 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
#include "modules/audio_processing/aec3/aec_state.h"
#include <math.h>
#include <algorithm>
#include <numeric>
#include <vector>
#include "absl/types/optional.h"
#include "api/array_view.h"
#include "modules/audio_processing/aec3/aec3_common.h"
#include "modules/audio_processing/logging/apm_data_dumper.h"
#include "rtc_base/atomic_ops.h"
#include "rtc_base/checks.h"
#include "system_wrappers/include/field_trial.h"
namespace webrtc {
namespace {
bool DeactivateInitialStateResetAtEchoPathChange() {
return field_trial::IsEnabled(
"WebRTC-Aec3DeactivateInitialStateResetKillSwitch");
}
bool FullResetAtEchoPathChange() {
return !field_trial::IsEnabled("WebRTC-Aec3AecStateFullResetKillSwitch");
}
bool SubtractorAnalyzerResetAtEchoPathChange() {
return !field_trial::IsEnabled(
"WebRTC-Aec3AecStateSubtractorAnalyzerResetKillSwitch");
}
void ComputeAvgRenderReverb(
const SpectrumBuffer& spectrum_buffer,
int delay_blocks,
float reverb_decay,
ReverbModel* reverb_model,
rtc::ArrayView<float, kFftLengthBy2Plus1> reverb_power_spectrum) {
RTC_DCHECK(reverb_model);
const size_t num_render_channels = spectrum_buffer.buffer[0].size();
int idx_at_delay =
spectrum_buffer.OffsetIndex(spectrum_buffer.read, delay_blocks);
int idx_past = spectrum_buffer.IncIndex(idx_at_delay);
std::array<float, kFftLengthBy2Plus1> X2_data;
rtc::ArrayView<const float> X2;
if (num_render_channels > 1) {
auto average_channels =
[](size_t num_render_channels,
rtc::ArrayView<const std::array<float, kFftLengthBy2Plus1>>
spectrum_band_0,
rtc::ArrayView<float, kFftLengthBy2Plus1> render_power) {
std::fill(render_power.begin(), render_power.end(), 0.f);
for (size_t ch = 0; ch < num_render_channels; ++ch) {
for (size_t k = 0; k < kFftLengthBy2Plus1; ++k) {
render_power[k] += spectrum_band_0[ch][k];
}
}
const float normalizer = 1.f / num_render_channels;
for (size_t k = 0; k < kFftLengthBy2Plus1; ++k) {
render_power[k] *= normalizer;
}
};
average_channels(num_render_channels, spectrum_buffer.buffer[idx_past],
X2_data);
reverb_model->UpdateReverbNoFreqShaping(
X2_data, /*power_spectrum_scaling=*/1.0f, reverb_decay);
average_channels(num_render_channels, spectrum_buffer.buffer[idx_at_delay],
X2_data);
X2 = X2_data;
} else {
reverb_model->UpdateReverbNoFreqShaping(
spectrum_buffer.buffer[idx_past][/*channel=*/0],
/*power_spectrum_scaling=*/1.0f, reverb_decay);
X2 = spectrum_buffer.buffer[idx_at_delay][/*channel=*/0];
}
rtc::ArrayView<const float, kFftLengthBy2Plus1> reverb_power =
reverb_model->reverb();
for (size_t k = 0; k < X2.size(); ++k) {
reverb_power_spectrum[k] = X2[k] + reverb_power[k];
}
}
} // namespace
int AecState::instance_count_ = 0;
void AecState::GetResidualEchoScaling(
rtc::ArrayView<float> residual_scaling) const {
bool filter_has_had_time_to_converge;
if (config_.filter.conservative_initial_phase) {
filter_has_had_time_to_converge =
strong_not_saturated_render_blocks_ >= 1.5f * kNumBlocksPerSecond;
} else {
filter_has_had_time_to_converge =
strong_not_saturated_render_blocks_ >= 0.8f * kNumBlocksPerSecond;
}
echo_audibility_.GetResidualEchoScaling(filter_has_had_time_to_converge,
residual_scaling);
}
absl::optional<float> AecState::ErleUncertainty() const {
if (SaturatedEcho()) {
return 1.f;
}
return absl::nullopt;
}
AecState::AecState(const EchoCanceller3Config& config,
size_t num_capture_channels)
: data_dumper_(
new ApmDataDumper(rtc::AtomicOps::Increment(&instance_count_))),
config_(config),
num_capture_channels_(num_capture_channels),
deactivate_initial_state_reset_at_echo_path_change_(
DeactivateInitialStateResetAtEchoPathChange()),
full_reset_at_echo_path_change_(FullResetAtEchoPathChange()),
subtractor_analyzer_reset_at_echo_path_change_(
SubtractorAnalyzerResetAtEchoPathChange()),
initial_state_(config_),
delay_state_(config_, num_capture_channels_),
transparent_state_(TransparentMode::Create(config_)),
filter_quality_state_(config_, num_capture_channels_),
erl_estimator_(2 * kNumBlocksPerSecond),
erle_estimator_(2 * kNumBlocksPerSecond, config_, num_capture_channels_),
filter_analyzer_(config_, num_capture_channels_),
echo_audibility_(
config_.echo_audibility.use_stationarity_properties_at_init),
reverb_model_estimator_(config_, num_capture_channels_),
subtractor_output_analyzer_(num_capture_channels_) {}
AecState::~AecState() = default;
void AecState::HandleEchoPathChange(
const EchoPathVariability& echo_path_variability) {
const auto full_reset = [&]() {
filter_analyzer_.Reset();
capture_signal_saturation_ = false;
strong_not_saturated_render_blocks_ = 0;
blocks_with_active_render_ = 0;
if (!deactivate_initial_state_reset_at_echo_path_change_) {
initial_state_.Reset();
}
if (transparent_state_) {
transparent_state_->Reset();
}
erle_estimator_.Reset(true);
erl_estimator_.Reset();
filter_quality_state_.Reset();
};
// TODO(peah): Refine the reset scheme according to the type of gain and
// delay adjustment.
if (full_reset_at_echo_path_change_ &&
echo_path_variability.delay_change !=
EchoPathVariability::DelayAdjustment::kNone) {
full_reset();
} else if (echo_path_variability.gain_change) {
erle_estimator_.Reset(false);
}
if (subtractor_analyzer_reset_at_echo_path_change_) {
subtractor_output_analyzer_.HandleEchoPathChange();
}
}
void AecState::Update(
const absl::optional<DelayEstimate>& external_delay,
rtc::ArrayView<const std::vector<std::array<float, kFftLengthBy2Plus1>>>
adaptive_filter_frequency_responses,
rtc::ArrayView<const std::vector<float>> adaptive_filter_impulse_responses,
const RenderBuffer& render_buffer,
rtc::ArrayView<const std::array<float, kFftLengthBy2Plus1>> E2_refined,
rtc::ArrayView<const std::array<float, kFftLengthBy2Plus1>> Y2,
rtc::ArrayView<const SubtractorOutput> subtractor_output) {
RTC_DCHECK_EQ(num_capture_channels_, Y2.size());
RTC_DCHECK_EQ(num_capture_channels_, subtractor_output.size());
RTC_DCHECK_EQ(num_capture_channels_,
adaptive_filter_frequency_responses.size());
RTC_DCHECK_EQ(num_capture_channels_,
adaptive_filter_impulse_responses.size());
// Analyze the filter outputs and filters.
bool any_filter_converged;
bool all_filters_diverged;
subtractor_output_analyzer_.Update(subtractor_output, &any_filter_converged,
&all_filters_diverged);
bool any_filter_consistent;
float max_echo_path_gain;
filter_analyzer_.Update(adaptive_filter_impulse_responses, render_buffer,
&any_filter_consistent, &max_echo_path_gain);
// Estimate the direct path delay of the filter.
if (config_.filter.use_linear_filter) {
delay_state_.Update(filter_analyzer_.FilterDelaysBlocks(), external_delay,
strong_not_saturated_render_blocks_);
}
const std::vector<std::vector<float>>& aligned_render_block =
render_buffer.Block(-delay_state_.MinDirectPathFilterDelay())[0];
// Update render counters.
bool active_render = false;
for (size_t ch = 0; ch < aligned_render_block.size(); ++ch) {
const float render_energy = std::inner_product(
aligned_render_block[ch].begin(), aligned_render_block[ch].end(),
aligned_render_block[ch].begin(), 0.f);
if (render_energy > (config_.render_levels.active_render_limit *
config_.render_levels.active_render_limit) *
kFftLengthBy2) {
active_render = true;
break;
}
}
blocks_with_active_render_ += active_render ? 1 : 0;
strong_not_saturated_render_blocks_ +=
active_render && !SaturatedCapture() ? 1 : 0;
std::array<float, kFftLengthBy2Plus1> avg_render_spectrum_with_reverb;
ComputeAvgRenderReverb(render_buffer.GetSpectrumBuffer(),
delay_state_.MinDirectPathFilterDelay(), ReverbDecay(),
&avg_render_reverb_, avg_render_spectrum_with_reverb);
if (config_.echo_audibility.use_stationarity_properties) {
// Update the echo audibility evaluator.
echo_audibility_.Update(render_buffer, avg_render_reverb_.reverb(),
delay_state_.MinDirectPathFilterDelay(),
delay_state_.ExternalDelayReported());
}
// Update the ERL and ERLE measures.
if (initial_state_.TransitionTriggered()) {
erle_estimator_.Reset(false);
}
erle_estimator_.Update(render_buffer, adaptive_filter_frequency_responses,
avg_render_spectrum_with_reverb, Y2, E2_refined,
subtractor_output_analyzer_.ConvergedFilters());
erl_estimator_.Update(
subtractor_output_analyzer_.ConvergedFilters(),
render_buffer.Spectrum(delay_state_.MinDirectPathFilterDelay()), Y2);
// Detect and flag echo saturation.
if (config_.ep_strength.echo_can_saturate) {
saturation_detector_.Update(aligned_render_block, SaturatedCapture(),
UsableLinearEstimate(), subtractor_output,
max_echo_path_gain);
} else {
RTC_DCHECK(!saturation_detector_.SaturatedEcho());
}
// Update the decision on whether to use the initial state parameter set.
initial_state_.Update(active_render, SaturatedCapture());
// Detect whether the transparent mode should be activated.
if (transparent_state_) {
transparent_state_->Update(delay_state_.MinDirectPathFilterDelay(),
any_filter_consistent, any_filter_converged,
all_filters_diverged, active_render,
SaturatedCapture());
}
// Analyze the quality of the filter.
filter_quality_state_.Update(active_render, TransparentModeActive(),
SaturatedCapture(), external_delay,
any_filter_converged);
// Update the reverb estimate.
const bool stationary_block =
config_.echo_audibility.use_stationarity_properties &&
echo_audibility_.IsBlockStationary();
reverb_model_estimator_.Update(
filter_analyzer_.GetAdjustedFilters(),
adaptive_filter_frequency_responses,
erle_estimator_.GetInstLinearQualityEstimates(),
delay_state_.DirectPathFilterDelays(),
filter_quality_state_.UsableLinearFilterOutputs(), stationary_block);
erle_estimator_.Dump(data_dumper_);
reverb_model_estimator_.Dump(data_dumper_.get());
data_dumper_->DumpRaw("aec3_active_render", active_render);
data_dumper_->DumpRaw("aec3_erl", Erl());
data_dumper_->DumpRaw("aec3_erl_time_domain", ErlTimeDomain());
data_dumper_->DumpRaw("aec3_erle", Erle()[0]);
data_dumper_->DumpRaw("aec3_usable_linear_estimate", UsableLinearEstimate());
data_dumper_->DumpRaw("aec3_transparent_mode", TransparentModeActive());
data_dumper_->DumpRaw("aec3_filter_delay",
filter_analyzer_.MinFilterDelayBlocks());
data_dumper_->DumpRaw("aec3_any_filter_consistent", any_filter_consistent);
data_dumper_->DumpRaw("aec3_initial_state",
initial_state_.InitialStateActive());
data_dumper_->DumpRaw("aec3_capture_saturation", SaturatedCapture());
data_dumper_->DumpRaw("aec3_echo_saturation", SaturatedEcho());
data_dumper_->DumpRaw("aec3_any_filter_converged", any_filter_converged);
data_dumper_->DumpRaw("aec3_all_filters_diverged", all_filters_diverged);
data_dumper_->DumpRaw("aec3_external_delay_avaliable",
external_delay ? 1 : 0);
data_dumper_->DumpRaw("aec3_filter_tail_freq_resp_est",
GetReverbFrequencyResponse());
}
AecState::InitialState::InitialState(const EchoCanceller3Config& config)
: conservative_initial_phase_(config.filter.conservative_initial_phase),
initial_state_seconds_(config.filter.initial_state_seconds) {
Reset();
}
void AecState::InitialState::InitialState::Reset() {
initial_state_ = true;
strong_not_saturated_render_blocks_ = 0;
}
void AecState::InitialState::InitialState::Update(bool active_render,
bool saturated_capture) {
strong_not_saturated_render_blocks_ +=
active_render && !saturated_capture ? 1 : 0;
// Flag whether the initial state is still active.
bool prev_initial_state = initial_state_;
if (conservative_initial_phase_) {
initial_state_ =
strong_not_saturated_render_blocks_ < 5 * kNumBlocksPerSecond;
} else {
initial_state_ = strong_not_saturated_render_blocks_ <
initial_state_seconds_ * kNumBlocksPerSecond;
}
// Flag whether the transition from the initial state has started.
transition_triggered_ = !initial_state_ && prev_initial_state;
}
AecState::FilterDelay::FilterDelay(const EchoCanceller3Config& config,
size_t num_capture_channels)
: delay_headroom_blocks_(config.delay.delay_headroom_samples / kBlockSize),
filter_delays_blocks_(num_capture_channels, delay_headroom_blocks_),
min_filter_delay_(delay_headroom_blocks_) {}
void AecState::FilterDelay::Update(
rtc::ArrayView<const int> analyzer_filter_delay_estimates_blocks,
const absl::optional<DelayEstimate>& external_delay,
size_t blocks_with_proper_filter_adaptation) {
// Update the delay based on the external delay.
if (external_delay &&
(!external_delay_ || external_delay_->delay != external_delay->delay)) {
external_delay_ = external_delay;
external_delay_reported_ = true;
}
// Override the estimated delay if it is not certain that the filter has had
// time to converge.
const bool delay_estimator_may_not_have_converged =
blocks_with_proper_filter_adaptation < 2 * kNumBlocksPerSecond;
if (delay_estimator_may_not_have_converged && external_delay_) {
const int delay_guess = delay_headroom_blocks_;
std::fill(filter_delays_blocks_.begin(), filter_delays_blocks_.end(),
delay_guess);
} else {
RTC_DCHECK_EQ(filter_delays_blocks_.size(),
analyzer_filter_delay_estimates_blocks.size());
std::copy(analyzer_filter_delay_estimates_blocks.begin(),
analyzer_filter_delay_estimates_blocks.end(),
filter_delays_blocks_.begin());
}
min_filter_delay_ = *std::min_element(filter_delays_blocks_.begin(),
filter_delays_blocks_.end());
}
AecState::FilteringQualityAnalyzer::FilteringQualityAnalyzer(
const EchoCanceller3Config& config,
size_t num_capture_channels)
: use_linear_filter_(config.filter.use_linear_filter),
usable_linear_filter_estimates_(num_capture_channels, false) {}
void AecState::FilteringQualityAnalyzer::Reset() {
std::fill(usable_linear_filter_estimates_.begin(),
usable_linear_filter_estimates_.end(), false);
overall_usable_linear_estimates_ = false;
filter_update_blocks_since_reset_ = 0;
}
void AecState::FilteringQualityAnalyzer::Update(
bool active_render,
bool transparent_mode,
bool saturated_capture,
const absl::optional<DelayEstimate>& external_delay,
bool any_filter_converged) {
// Update blocks counter.
const bool filter_update = active_render && !saturated_capture;
filter_update_blocks_since_reset_ += filter_update ? 1 : 0;
filter_update_blocks_since_start_ += filter_update ? 1 : 0;
// Store convergence flag when observed.
convergence_seen_ = convergence_seen_ || any_filter_converged;
// Verify requirements for achieving a decent filter. The requirements for
// filter adaptation at call startup are more restrictive than after an
// in-call reset.
const bool sufficient_data_to_converge_at_startup =
filter_update_blocks_since_start_ > kNumBlocksPerSecond * 0.4f;
const bool sufficient_data_to_converge_at_reset =
sufficient_data_to_converge_at_startup &&
filter_update_blocks_since_reset_ > kNumBlocksPerSecond * 0.2f;
// The linear filter can only be used if it has had time to converge.
overall_usable_linear_estimates_ = sufficient_data_to_converge_at_startup &&
sufficient_data_to_converge_at_reset;
// The linear filter can only be used if an external delay or convergence have
// been identified
overall_usable_linear_estimates_ =
overall_usable_linear_estimates_ && (external_delay || convergence_seen_);
// If transparent mode is on, deactivate usign the linear filter.
overall_usable_linear_estimates_ =
overall_usable_linear_estimates_ && !transparent_mode;
if (use_linear_filter_) {
std::fill(usable_linear_filter_estimates_.begin(),
usable_linear_filter_estimates_.end(),
overall_usable_linear_estimates_);
}
}
void AecState::SaturationDetector::Update(
rtc::ArrayView<const std::vector<float>> x,
bool saturated_capture,
bool usable_linear_estimate,
rtc::ArrayView<const SubtractorOutput> subtractor_output,
float echo_path_gain) {
saturated_echo_ = false;
if (!saturated_capture) {
return;
}
if (usable_linear_estimate) {
constexpr float kSaturationThreshold = 20000.f;
for (size_t ch = 0; ch < subtractor_output.size(); ++ch) {
saturated_echo_ =
saturated_echo_ ||
(subtractor_output[ch].s_refined_max_abs > kSaturationThreshold ||
subtractor_output[ch].s_coarse_max_abs > kSaturationThreshold);
}
} else {
float max_sample = 0.f;
for (auto& channel : x) {
for (float sample : channel) {
max_sample = std::max(max_sample, fabsf(sample));
}
}
const float kMargin = 10.f;
float peak_echo_amplitude = max_sample * echo_path_gain * kMargin;
saturated_echo_ = saturated_echo_ || peak_echo_amplitude > 32000;
}
}
} // namespace webrtc
| [
"arun@asymptotic.io"
] | arun@asymptotic.io |
d26ae67d159e9cfbfce0f4006bd598103394441b | 4412b800c9acded952501d43e0ae79074a7085fc | /include/dtc/statgrab/statgrab.hpp | 7f97ca4cf69fad9224d70d089db77b9551d49010 | [
"MIT"
] | permissive | dimahuang/DtCraft | 65641dafaef9d0554aa0fa2b700cc810333db520 | 80cc9e1195adc0026107814243401a1fc47b5be2 | refs/heads/master | 2020-11-24T10:02:49.986469 | 2019-05-04T20:33:50 | 2019-05-04T20:33:50 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 7,828 | hpp | /******************************************************************************
* *
* Copyright (c) 2018, Tsung-Wei Huang, Chun-Xun Lin and Martin D. F. Wong, *
* University of Illinois at Urbana-Champaign (UIUC), IL, USA. *
* *
* All Rights Reserved. *
* *
* This program is free software. You can redistribute and/or modify *
* it in accordance with the terms of the accompanying license agreement. *
* See LICENSE in the top-level directory for details. *
* *
******************************************************************************/
#ifndef DTC_STATGRAB_STATGRAB_HPP_
#define DTC_STATGRAB_STATGRAB_HPP_
#include <dtc/utility/singleton.hpp>
#include <dtc/headerdef.hpp>
namespace dtc {
class Statgrab : public EnableSingletonFromThis <Statgrab> {
friend class EnableSingletonFromThis<Statgrab>;
public:
struct LoadInfo {
double min1;
double min5;
double min15;
};
uintmax_t num_cpus() const;
uintmax_t memory_limit_in_bytes() const;
uintmax_t space_limit_in_bytes() const;
LoadInfo cpu_load_avg() const;
};
/*// Class: Statgrab
class Statgrab : public EnableSingletonFromThis <Statgrab> {
public:
friend class EnableSingletonFromThis<Statgrab>;
// Function: os_name, os_nodename, os_version, os_release, os_machine,
// num_max_cpus, num_cpus
//
// Query the static information of the host, including OS info and cpu info.
//
// @return: return the statistics.
//
inline void update_os_info();
inline auto os_name();
inline auto os_release();
inline auto os_version();
inline auto os_hostname();
inline auto os_bitwidth();
inline auto num_max_cpus();
inline auto num_cpus();
// Function: cpuloadavg_min1, cpuloadavg_min5, cpuloadavg_min15
//
// Query the cpuload information. Flushing the status must be called through update_cpuloadavg.
//
// @return: return the cpu load
//
inline void update_cpuloadavg();
inline auto cpuloadavg_min1();
inline auto cpuloadavg_min5();
inline auto cpuloadavg_min15();
std::tuple<double, double, double> loadavg() const noexcept;
// Memory info.
//
// Query the memory statistics.
// - total : the total memory in the system
// - used : all memory currently in use/reserved by running process and OS
// - free : total - used
// - buffer: memory reserved by OS to alloc as buffers when process need them
// - cached: recently used files being stored in ram
//
// used - (buffer + cached) is the amount of memory being actually used
// free + (buffer + cached) is the amount of memory being actually free
//
inline void update_mem_info();
inline auto mem_total();
inline auto mem_free();
inline auto mem_cached();
inline auto mem_used();
// Swap info.
inline void update_swap_info();
inline auto swap_total();
inline auto swap_used();
inline auto swap_free();
// Page info.
inline void update_page_info();
inline void update_page_diff_info();
inline auto num_pageins();
inline auto num_pageouts();
inline auto num_pageins_diff();
inline auto num_pageouts_diff();
// Update all info.
inline void update_all();
private:
// Constructor/Destructor.
inline Statgrab();
inline ~Statgrab();
// Thunk pointers which we use to access the system information.
decltype(sg_get_host_info(nullptr)) _host_info;
decltype(sg_get_load_stats(nullptr)) _load_info;
decltype(sg_get_mem_stats(nullptr)) _mem_info;
decltype(sg_get_swap_stats(nullptr)) _swap_info;
decltype(sg_get_page_stats(nullptr)) _page_info;
decltype(sg_get_page_stats_diff(nullptr)) _page_diff_info;
};
// Constructor.
inline Statgrab::Statgrab(){
sg_init(1);
update_all();
}
// Destructor
inline Statgrab::~Statgrab(){
sg_shutdown();
}
//-------------------- OS information -------------------------------
// Function: os_name
inline auto Statgrab::os_name() {
return _host_info->os_name;
}
// Function: os_release
inline auto Statgrab::os_release() {
return _host_info->os_release;
}
// Function: os_version
inline auto Statgrab::os_version() {
return _host_info->os_version;
}
// Function: hostname
inline auto Statgrab::os_hostname() {
return _host_info->hostname;
}
// Function: bitwidth
inline auto Statgrab::os_bitwidth() {
return _host_info->bitwidth;
}
// Function: num_cpus
inline auto Statgrab::num_cpus() {
return _host_info->ncpus;
}
// Function: num_max_cpus
inline auto Statgrab::num_max_cpus() {
return _host_info->maxcpus;
}
//------------- CPU Average loading information --------------------
// Function: cpuloadavg_min1
inline auto Statgrab::cpuloadavg_min1(){
return _load_info->min1;
}
// Function: cpuloadavg_min5
inline auto Statgrab::cpuloadavg_min5(){
return _load_info->min5;
}
// Function: cpuloadavg_min15
inline auto Statgrab::cpuloadavg_min15(){
return _load_info->min15;
}
//---------------- Memory information -------------------------------
// Function: mem_total
inline auto Statgrab::mem_total(){
return _mem_info->total;
}
// Function: mem_free
inline auto Statgrab::mem_free(){
return _mem_info->free;
}
// Function: mem_cached
inline auto Statgrab::mem_cached(){
return _mem_info->cache;
}
// Function: mem_used
inline auto Statgrab::mem_used(){
return _mem_info->used;
}
//---------------- SWAP information -------------------------------
// Function: swap_total
inline auto Statgrab::swap_total(){
return _swap_info->total;
}
// Function: swap_used
inline auto Statgrab::swap_used(){
return _swap_info->used;
}
// Function: swap_free
inline auto Statgrab::swap_free(){
return _swap_info->free;
}
//---------------- Page information -------------------------------
// Function: num_pageins_diff
inline auto Statgrab::num_pageins_diff(){
return _page_diff_info->pages_pagein;
}
// Function: num_pageouts_diff
inline auto Statgrab::num_pageouts_diff(){
return _page_diff_info->pages_pageout;
}
// Function: num_pageins
inline auto Statgrab::num_pageins(){
return _page_info->pages_pagein;
}
// Function: num_pageouts
inline auto Statgrab::num_pageouts(){
return _page_info->pages_pageout;
}
//-----------------------------------------------------------------
// Procedure: _udate_all
inline void Statgrab::update_all() {
update_os_info();
update_cpuloadavg();
update_mem_info();
update_swap_info();
update_page_info();
update_page_diff_info();
}
// Procedure: update_os_info
inline void Statgrab::update_os_info() {
_host_info = sg_get_host_info(nullptr);
}
// Procedure: update_cpuloadavg
// Update average CPU loading in 1 min, 5 mins, 15 mins
inline void Statgrab::update_cpuloadavg() {
_load_info = sg_get_load_stats(nullptr);
}
// Procedure: update_mem_info
// Update the mem information.
inline void Statgrab::update_mem_info() {
_mem_info = sg_get_mem_stats(nullptr);
}
// Procedure: update_swap_info
// Update the swap information.
inline void Statgrab::update_swap_info() {
_swap_info = sg_get_swap_stats(nullptr);
}
// Procedure: update_page_info
// Update the page information.
inline void Statgrab::update_page_info() {
_page_info = sg_get_page_stats(nullptr);
}
// Procedure: update_page_diff_info
// Update the page information.
inline void Statgrab::update_page_diff_info() {
_page_diff_info = sg_get_page_stats_diff(nullptr);
}*/
}; // End of namespace dtc. --------------------------------------------------------------
#endif
| [
"twh760812@gmail.com"
] | twh760812@gmail.com |
d8a3856abfc4894ff514afe14eaecbca2620f0c7 | 8cd58282fb6cc8326e4f5d468d6b94a4c50d7527 | /LibBase/ggBehaviorBlocking.h | bb6694b28bba0d8b1afe6f6ff73b9e3ded7e637e | [] | no_license | TheGoofy/ggCircleFinder | bbbf7202b498ec907b8e551bd782627c58743299 | fe7a031d7ebbea64aa2c67991bfe4fabb8988dd7 | refs/heads/master | 2020-03-22T14:49:20.754057 | 2019-12-28T14:33:31 | 2019-12-28T14:33:31 | 140,208,141 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 342 | h | #ifndef GGBEHAVIORBLOCKING_H
#define GGBEHAVIORBLOCKING_H
// 1) include system
// 2) include own project-related (sort by component dependency)
#include "LibBase/ggBehaviorT.h"
// 3) forward declarations
class ggBehaviorBlockingTemplate;
typedef ggBehaviorT<ggBehaviorBlockingTemplate> ggBehaviorBlocking;
#endif // GGBEHAVIORBLOCKING_H
| [
"cla@gmx.ch"
] | cla@gmx.ch |
908f8d64bcb3b78a89b03a97000c23033636c2a9 | 573b7f2b79b6fb8b21b40985f7639bc003b60f7e | /SDK/RadialCenterVehicle_parameters.h | 8fa262f81bc1be10a233db840c9a5be5c2ec484f | [] | no_license | AlexzDK/SquadSDK2021 | 8d4c29486922fed3ba8451680d823a04a7b7fc44 | cdce732ad4713b6d7f668f8b9c39e160035efb34 | refs/heads/main | 2023-02-21T02:52:15.634663 | 2021-01-23T23:28:57 | 2021-01-23T23:28:57 | 332,328,796 | 4 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 6,664 | h | #pragma once
// Name: Squad, Version: 13-01-2021
#ifdef _MSC_VER
#pragma pack(push, 0x01)
#endif
/*!!HELPER_DEF!!*/
/*!!DEFINE!!*/
namespace UFT
{
//---------------------------------------------------------------------------
// Parameters
//---------------------------------------------------------------------------
// Function RadialCenterVehicle.RadialCenterVehicle_C.HelicopterAltitudeCheck
struct URadialCenterVehicle_C_HelicopterAltitudeCheck_Params
{
bool AltitudeValid; // (Parm, OutParm, ZeroConstructor, IsPlainOldData, NoDestructor)
};
// Function RadialCenterVehicle.RadialCenterVehicle_C.Is Soldier Alive
struct URadialCenterVehicle_C_Is_Soldier_Alive_Params
{
bool Alive; // (Parm, OutParm, ZeroConstructor, IsPlainOldData, NoDestructor)
};
// Function RadialCenterVehicle.RadialCenterVehicle_C.Get Widget Text
struct URadialCenterVehicle_C_Get_Widget_Text_Params
{
class USQRadialButton* Button; // (BlueprintVisible, BlueprintReadOnly, Parm, ZeroConstructor, InstancedReference, IsPlainOldData, NoDestructor, HasGetValueTypeHash)
struct FText DisplayText; // (Parm, OutParm)
};
// Function RadialCenterVehicle.RadialCenterVehicle_C.Get Action Text
struct URadialCenterVehicle_C_Get_Action_Text_Params
{
struct FText ReturnValue; // (Parm, OutParm, ReturnParm)
};
// Function RadialCenterVehicle.RadialCenterVehicle_C.Validate FOB
struct URadialCenterVehicle_C_Validate_FOB_Params
{
bool Valid; // (Parm, OutParm, ZeroConstructor, IsPlainOldData, NoDestructor)
};
// Function RadialCenterVehicle.RadialCenterVehicle_C.Validate Transaction
struct URadialCenterVehicle_C_Validate_Transaction_Params
{
bool Valid; // (Parm, OutParm, ZeroConstructor, IsPlainOldData, NoDestructor)
bool Con_Valid; // (Parm, OutParm, ZeroConstructor, IsPlainOldData, NoDestructor)
bool Ammo_Valid; // (Parm, OutParm, ZeroConstructor, IsPlainOldData, NoDestructor)
bool Is_Loading; // (Parm, OutParm, ZeroConstructor, IsPlainOldData, NoDestructor)
bool Zone_has_Points; // (Parm, OutParm, ZeroConstructor, IsPlainOldData, NoDestructor)
};
// Function RadialCenterVehicle.RadialCenterVehicle_C.Is Action Ammo
struct URadialCenterVehicle_C_Is_Action_Ammo_Params
{
bool Is_Ammo_Action; // (Parm, OutParm, ZeroConstructor, IsPlainOldData, NoDestructor)
};
// Function RadialCenterVehicle.RadialCenterVehicle_C.Vehicle Denied
struct URadialCenterVehicle_C_Vehicle_Denied_Params
{
bool ReturnValue; // (Parm, OutParm, ZeroConstructor, ReturnParm, IsPlainOldData, NoDestructor)
};
// Function RadialCenterVehicle.RadialCenterVehicle_C.Vehicle Speed Check
struct URadialCenterVehicle_C_Vehicle_Speed_Check_Params
{
bool Speed_Is_Valid; // (Parm, OutParm, ZeroConstructor, IsPlainOldData, NoDestructor)
};
// Function RadialCenterVehicle.RadialCenterVehicle_C.Get_Text_SupplyStatus
struct URadialCenterVehicle_C_Get_Text_SupplyStatus_Params
{
struct FText ReturnValue; // (Parm, OutParm, ReturnParm)
};
// Function RadialCenterVehicle.RadialCenterVehicle_C.SetTimerActivation
struct URadialCenterVehicle_C_SetTimerActivation_Params
{
bool Active; // (BlueprintVisible, BlueprintReadOnly, Parm, ZeroConstructor, IsPlainOldData, NoDestructor)
};
// Function RadialCenterVehicle.RadialCenterVehicle_C.SetTimerProgress
struct URadialCenterVehicle_C_SetTimerProgress_Params
{
float RemainingTimePct; // (BlueprintVisible, BlueprintReadOnly, Parm, ZeroConstructor, IsPlainOldData, NoDestructor, HasGetValueTypeHash)
};
// Function RadialCenterVehicle.RadialCenterVehicle_C.Get_Background_ColorAndOpacity_1
struct URadialCenterVehicle_C_Get_Background_ColorAndOpacity_1_Params
{
struct FLinearColor ReturnValue; // (Parm, OutParm, ZeroConstructor, ReturnParm, IsPlainOldData, NoDestructor, HasGetValueTypeHash)
};
// Function RadialCenterVehicle.RadialCenterVehicle_C.OnHoverBegin
struct URadialCenterVehicle_C_OnHoverBegin_Params
{
};
// Function RadialCenterVehicle.RadialCenterVehicle_C.Tick
struct URadialCenterVehicle_C_Tick_Params
{
struct FGeometry MyGeometry; // (BlueprintVisible, BlueprintReadOnly, Parm, IsPlainOldData, NoDestructor)
float InDeltaTime; // (BlueprintVisible, BlueprintReadOnly, Parm, ZeroConstructor, IsPlainOldData, NoDestructor, HasGetValueTypeHash)
};
// Function RadialCenterVehicle.RadialCenterVehicle_C.OnHoverEnd
struct URadialCenterVehicle_C_OnHoverEnd_Params
{
};
// Function RadialCenterVehicle.RadialCenterVehicle_C.Construct
struct URadialCenterVehicle_C_Construct_Params
{
};
// Function RadialCenterVehicle.RadialCenterVehicle_C.ExecuteUbergraph_RadialCenterVehicle
struct URadialCenterVehicle_C_ExecuteUbergraph_RadialCenterVehicle_Params
{
int EntryPoint; // (BlueprintVisible, BlueprintReadOnly, Parm, ZeroConstructor, IsPlainOldData, NoDestructor, HasGetValueTypeHash)
};
}
#ifdef _MSC_VER
#pragma pack(pop)
#endif
| [
"39485681+AlexzDK@users.noreply.github.com"
] | 39485681+AlexzDK@users.noreply.github.com |
fb2c808afde1517aa36fc9f5ec267945ffc8a150 | 0edd94c818463a78931bf726824fee9047e494ed | /server.cpp | 7a5c804fa65e206034b62af3ec0e3a6192b48ce1 | [] | no_license | poprygun/cpp-app | c218de5c0284ab293aa8288aac95b54d8aff6522 | af5fc0e8405944c4828caf0dabecfeb20ff08ee0 | refs/heads/master | 2023-01-24T15:16:09.102371 | 2020-12-01T19:18:10 | 2020-12-01T19:18:10 | 315,657,940 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,733 | cpp | #include <sys/socket.h> // For socket functions
#include <netinet/in.h> // For sockaddr_in
#include <cstdlib> // For exit() and EXIT_FAILURE
#include <iostream> // For cout
#include <unistd.h> // For read
int main() {
// Create a socket (IPv4, TCP)
int sockfd = socket(AF_INET, SOCK_STREAM, 0);
if (sockfd == -1) {
std::cout << "Failed to create socket. errno: " << errno << std::endl;
exit(EXIT_FAILURE);
}
// Listen to port 9999 on any address
sockaddr_in sockaddr;
sockaddr.sin_family = AF_INET;
sockaddr.sin_addr.s_addr = INADDR_ANY;
sockaddr.sin_port = htons(9999); // htons is necessary to convert a number to
// network byte order
if (bind(sockfd, (struct sockaddr*)&sockaddr, sizeof(sockaddr)) < 0) {
std::cout << "Failed to bind to port 9999. errno: " << errno << std::endl;
exit(EXIT_FAILURE);
}
// Start listening. Hold at most 10 connections in the queue
if (listen(sockfd, 10) < 0) {
std::cout << "Failed to listen on socket. errno: " << errno << std::endl;
exit(EXIT_FAILURE);
}
// Grab a connection from the queue
auto addrlen = sizeof(sockaddr);
int connection = accept(sockfd, (struct sockaddr*)&sockaddr, (socklen_t*)&addrlen);
if (connection < 0) {
std::cout << "Failed to grab connection. errno: " << errno << std::endl;
exit(EXIT_FAILURE);
}
// Read from the connection
char buffer[100];
auto bytesRead = read(connection, buffer, 100);
std::cout << "The message was: " << buffer;
// Send a message to the connection
std::string response = "Good talking to you\n";
send(connection, response.c_str(), response.size(), 0);
// Close the connections
close(connection);
close(sockfd);
} | [
"poprygun@hotmail.com"
] | poprygun@hotmail.com |
4e2ef26e6ef15c39c238ab09a4d5fbf6766e2ae8 | 7859b6b4f7f2024bfaace1423d062f069711c8a0 | /opt/ir_high_opt.cpp | 1e2321745ee12fdf0844056f838be4b93d9684bb | [
"BSD-3-Clause",
"LicenseRef-scancode-generic-cla"
] | permissive | onecoolx/xoc | 751f0b28dacbd7e358afbeb679b9335ac9dbc7bb | 1af5e48f4e2967d33cf7aa0359ed526d4920e6a6 | refs/heads/master | 2023-01-07T19:33:04.033188 | 2023-01-04T09:59:20 | 2023-01-04T09:59:20 | 40,281,588 | 0 | 0 | null | 2018-02-07T06:08:22 | 2015-08-06T03:10:27 | C++ | UTF-8 | C++ | false | false | 5,545 | cpp | /*@
XOC Release License
Copyright (c) 2013-2014, Alibaba Group, All rights reserved.
compiler@aliexpress.com
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of the Su Zhenyu 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 "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.
author: Su Zhenyu
@*/
#include "cominc.h"
#include "comopt.h"
namespace xoc {
void Region::HighProcessImpl(OptCtx & oc)
{
if (g_do_cfg) {
ASSERT0(g_cst_bb_list);
getPassMgr()->checkValidAndRecompute(&oc, PASS_CFG, PASS_UNDEF);
//Remove empty bb when cfg rebuilted because
//rebuilding cfg may generate redundant empty bb.
//It disturbs the computation of entry and exit.
CfgOptCtx ctx(oc);
getCFG()->removeEmptyBB(ctx);
//Compute exit bb while cfg rebuilt.
getCFG()->computeExitList();
ASSERT0(getCFG()->verify());
bool org = g_do_cfg_remove_unreach_bb;
//Unreachable BB have to removed before RPO computation.
g_do_cfg_remove_unreach_bb = true;
getCFG()->performMiscOpt(oc);
g_do_cfg_remove_unreach_bb = org;
//Build DOM after CFG be optimized.
getPassMgr()->checkValidAndRecompute(&oc, PASS_DOM, PASS_UNDEF);
//Infer pointer arith need loopinfo.
getPassMgr()->checkValidAndRecompute(&oc, PASS_LOOP_INFO, PASS_UNDEF);
}
if (g_do_prssa) {
ASSERT0(getPassMgr());
PRSSAMgr * ssamgr = (PRSSAMgr*)getPassMgr()->registerPass(
PASS_PRSSA_MGR);
ASSERT0(ssamgr);
if (!ssamgr->is_valid()) {
ssamgr->construction(oc);
}
oc.setInvalidPRDU();
xoc::destructClassicDUChain(this, oc);
}
if (g_infer_type) {
getPassMgr()->registerPass(PASS_INFER_TYPE)->perform(oc);
}
doBasicAnalysis(oc);
if (g_do_expr_tab) {
ASSERT0(g_cst_bb_list);
getPassMgr()->checkValidAndRecompute(&oc, PASS_EXPR_TAB, PASS_UNDEF);
}
if (g_do_cdg) {
ASSERT0(g_cst_bb_list);
getPassMgr()->checkValidAndRecompute(&oc, PASS_CDG, PASS_UNDEF);
}
if (g_opt_level == OPT_LEVEL0) {
return;
}
//Regenerate high level IR, and do high level optimizations.
//For now, we cannot or not very easy construct High Level Control IR,
//(IF,DO_LOOP,...) via analysing CFG.
// e.g:if (i > j) { //BB1
// ...
// } else {
// return 2; //S1
// }
// BB1 does not have a ipdom, so we can not find the indispensible 3 parts:
// True body, False body, and the Sibling node.
//
//SOLUTION: We can scan IF stmt first, in order to mark
//start stmt and end stmt of IF.
//
////AbsNode * an = getAnalysisInstrument()->getCfsMgr()->
//// construct_abstract_cfs();
////Polyhedra optimization.
////IR_POLY * poly = newPoly();
////if (poly->construct_poly(an)) {
//// poly->perform_poly_trans();
////}
////delete poly;
}
//Perform high-level optimizaitions.
//Basis step to do:
// 1. Build control flow graph.
// 2. Compute POINT-TO info.
// 3. Compute DEF-USE info.
// 4. Compute Lived Expression info.
//
//Optimizations to be performed:
// 1. Auto Parallel
// 2. Loop interchange
// 3. Loop reverese(may be a little helpful)
// 4. Loop tiling
// 5. Loop fusion
// 6. Loop unrolling
bool Region::HighProcess(OptCtx & oc)
{
note(this, "\n\n==== Region:%s HIGHEST LEVEL FARMAT ====\n\n",
getRegionName());
SimpCtx simp(&oc);
if (g_do_cfs_opt) {
CfsOpt co(this);
co.perform(simp);
ASSERT0(verifyIRList(getIRList(), nullptr, this));
}
if (g_build_cfs) {
ASSERT0(getPassMgr());
SIMP_is_record_cfs(&simp) = true;
CfsMgr * cfsmgr = (CfsMgr*)getPassMgr()->registerPass(PASS_CFS_MGR);
ASSERT0(cfsmgr);
SIMP_cfs_mgr(&simp) = cfsmgr;
}
simp.setSimpCFS();
setIRList(getIRSimp()->simplifyStmtList(getIRList(), &simp));
ASSERT0(verifySimp(getIRList(), simp));
ASSERT0(verifyIRList(getIRList(), nullptr, this));
if (g_cst_bb_list) {
constructBBList();
ASSERT0(verifyIRandBB(getBBList(), this));
}
HighProcessImpl(oc);
return true;
}
} //namespace xoc
| [
"steven.known@gmail.com"
] | steven.known@gmail.com |
cd79e0d8c8d38155ac6a71ef8308750f08541818 | 3eadfd659ece486d71e8a97a6ec8a2366f3ccdc7 | /APD_Tema4_2012/Tema4.cpp | 3beb5d38afbfdcc863ef65256b2de6d09833455c | [] | no_license | andreeabican/Andreea | 739c5eb9c3e9270f40e4cf3fb69f64bc5f962313 | 246b7cb0f0d28a2fadb890c217713035e6274846 | refs/heads/master | 2021-01-19T00:23:05.248955 | 2016-01-24T19:02:10 | 2016-01-24T19:02:10 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 12,394 | cpp | #include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <fstream>
#include <string>
#include <unistd.h>
#include "mpi.h"
using namespace std;
void afisareTabela(int* tabela, int n, int rank) {
int i;
cout << "Pentru nodul " << rank << ":\n";
for (i = 0; i < n; i++) {
cout << i << " - " << tabela[i] << "\n";
}
}
//verifica daca vectorul contine aceasta valoare
int contine(int* vector, int valoare, int n) {
int i;
for (i = 0; i < n; i++) {
if (vector[i] == valoare)
return 1;
}
return 0;
}
int allone(int* vector, int n) {
int i;
for (i = 0; i < n; i++) {
if (vector[i] != 1)
return 0;
}
return 1;
}
int main(int argc, char *argv[])
{
int noTasks, rank, sursa;
char* dest;
string mesaj;
int recv, sync = 0;
int tag = 0, tag1 = 1, tag2 = 2, tag3 = 3, i, j;
MPI_Status status;
MPI_Init(&argc, &argv);
MPI_Comm_size(MPI_COMM_WORLD, &noTasks);
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
//citeste linia corespunzatoare din fisier, pentru a afla ce vecini are
//in tabela de rutare, pe pozitia i valoarea j, semnifica: daca vrei sa ajungi la i, trimite mai departe la j
char* b = new char[2]; // il folosim atunci cand verificam daca trebuie sa facem broadcast
b[0] ='B';
b[1] = '\0';
int* tabela = new int[noTasks];
MPI_Request request;
string line;
ifstream myfile, mesaje;
myfile.open(argv[1]);
int nrLinie = 0, nrVecini = 0;
char* pch;
char* vecini = new char[noTasks];
int *dinCiclu = new int[noTasks];
int k = 0, parinte, nrElemCiclu = 0;
//citirea liniei corespunzatoare din fisier
if (myfile.is_open()) {
getline(myfile, line);
while (nrLinie != rank) {
getline(myfile, line);
nrLinie++;
}
char* a = new char[line.size() + 1];
a[line.size()] = 0;
memcpy(a, line.c_str(), line.size());
pch = strtok(a, " :");
//cout << "rank:" << rank << "\n";
pch =strtok(NULL, " :");
while (pch != NULL) {
//cout << pch << "\n";
int vecin = atoi(pch);
//cout << "vecin " << vecin << "\n";
vecini[nrVecini] = vecin;
nrVecini++;
pch =strtok(NULL, " :");
}
myfile.close();
//daca este radacina arborelui, atunci trimite primul mesaj de sondaj
if (rank == 0) {
int* tabela1 = new int[noTasks];
int parinte1;
for (i = 0; i < noTasks; i++) {
tabela[i] = -1;
}
tabela[rank] = rank;
int sondaj = 0;
for (i = 0; i < nrVecini; i++) {
MPI_Send(&sondaj, 1, MPI_INT, vecini[i], tag, MPI_COMM_WORLD);
}
for (i = 0; i < nrVecini; i++) {
MPI_Recv(tabela1, noTasks, MPI_INT, vecini[i], tag1, MPI_COMM_WORLD, &status);
parinte1 = status.MPI_SOURCE;
//cout << "nodul 0 a primit ecou de la nodul " << parinte1 << "\n";
if (tabela1[0] != -2) {
tabela[parinte1] = parinte1;
for (j = 0; j < noTasks; j++) {
if (tabela1[j] != rank) {
tabela[j] = parinte1;
}
}
}
else {
//cout << "A primit o tabela invalida de la nodul " << parinte1;
}
}
//afisareTabela(tabela, noTasks, rank);
}
else {
//int *dinCiclu = new int[noTasks];
//int k = 0, parinte, nrElemCiclu = 0;
int flag = 0, recv1;
//primeste mesajul de tip sondaj(primul sondaj primit este singurul care conteaza)
MPI_Recv(&recv,1,MPI_INT,MPI_ANY_SOURCE,tag,MPI_COMM_WORLD,&status);
parinte = status.MPI_SOURCE;
//actualizeaza tabela de rutare - oricare ar fi destinatia, next hop este parintele
for (i = 0; i < noTasks; i++) {
tabela[i] = parinte;
}
tabela[rank] = rank;
//trimie sondajul mai departe
for (i = 0; i < nrVecini; i++) {
if (vecini[i] != parinte) {
k++;
//cout << "k este " << k << "\n";
MPI_Send(&recv, 1, MPI_INT, vecini[i], tag, MPI_COMM_WORLD);
}
}
int index = -1;
int count = 1;
MPI_Request requests[nrVecini]; //sau nrVecini - 1
for (i = 0; i < nrVecini; i++) {
//if (vecini[i] != parinte) {
//flag = 0;
//daca mai primeste mesaje de tip sondaj de la alti vecini
MPI_Irecv(&recv1, 1, MPI_INT, vecini[i], tag, MPI_COMM_WORLD, &requests[i]);
sleep(2);
MPI_Testany(i+1, requests, &index, &flag, &status);
//cout << "FLAGUL " << flag << "\n";
if (index != MPI_UNDEFINED) {
//cout << "A trecut de mpi_Testany si are flagul " << flag << " si parintele " << status.MPI_SOURCE << " index " << index << "\n";
int* tabela1 = new int[noTasks];
for (j = 0; j < noTasks; j++) {
tabela1[j] = -2;
}
//cout << "----------------------- am intrat aici -------------------------\n";
int parinteaux = status.MPI_SOURCE;
//retinem nodurile care au trimis mesaje de sondaj duplicat
dinCiclu[nrElemCiclu] = parinteaux;
nrElemCiclu++;
//trimite un mesaj de tip ecou, nul
//cout << "===== Nodul " << rank << " A trimis ecou invalid catre nodul " << parinteaux << " ==========\n";
MPI_Send(tabela1, noTasks, MPI_INT, parinteaux, tag1, MPI_COMM_WORLD);
}
//}
}
//daca nu este frunza, asteapta mesaje de tip ecou
if (k != 0) {
int* tabela1 = new int[noTasks];
int parinte1;
MPI_Status status1;
for (i = 0; i < nrVecini; i++) {
if (vecini[i] != parinte) {
//cout << "rankul: " << rank << " asteapta mesaje de tip ecou\n";
MPI_Recv(tabela1, noTasks, MPI_INT, vecini[i], tag1, MPI_COMM_WORLD, &status);
//cout << "rankul: " << rank << " a primit mesaj de tip ecou\n";
parinte1 = status.MPI_SOURCE;
//actualizeaza tabela
if (tabela1[0] != -2) {
tabela[parinte1] = parinte1;
//daca tabela anterioara nu trimitea catre acest nod pentru destinatia respectiva, atunci nodul acesta trebuie sa trimita catre nodul de la care a primit tabela acum, pentru acea destinatie - cam incurcat, dar ideea e simpla
for (j = 0; j < noTasks; j++) {
if (tabela1[j] != rank) {
tabela[j] = parinte1;
}
}
}
else {
//cout << "A primit o tabela care nu este valida de la nodul " << parinte1 << "\n";
}
}
}
//trimite tabela mai departe, catre parinte
MPI_Send(tabela, noTasks, MPI_INT, parinte, tag1, MPI_COMM_WORLD);
}
else
//daca am ajuns la o frunza(nu mai are alti vecini in afara de parinte)
if (k == 0) {
//incepem sa trimitem mesaje de tip ecou
MPI_Send(tabela, noTasks, MPI_INT, parinte, tag1, MPI_COMM_WORLD);
//cout << "frunza " << rank << " a trimis un ecou\n";
}
//afisareTabela(tabela, noTasks, rank);
}
afisareTabela(tabela, noTasks, rank);
}
//==========================================================================
//=============== Etapa 2 - se trimit mesaje intre noduri ==================
//==========================================================================
mesaje.open(argv[2]);
if (mesaje.is_open()) {
char* a;
getline(mesaje, line);
a = new char[line.size() + 1];
a[line.size()] = 0;
memcpy(a, line.c_str(), line.size());
int n = atoi(a);
free(a);
//fiecare proces citeste fiecare linie din fisier si daca sursa este egala cu rankul procesului, se incepe procesul de trimitere a mesajului
for ( i = 0; i < n; i++) {
getline(mesaje, line);
a = new char[line.size() + 1];
a[line.size()] = 0;
memcpy(a, line.c_str(), line.size());
pch = strtok(a, " ");
sursa = atoi(pch);
//cout << "sursa: " << sursa << "\n";
if (sursa == rank) {
//citim destinatia si mesajul pe care trebuie sa il trimitem
pch = strtok(NULL, " ");
dest = pch;
//======================================== Broadcast ==================================
if (strcmp(dest, b) == 0) {
for (j = 0; j < nrVecini; j++) {
int size = line.size() + 1;
char* msg = new char[size];
msg[size-1] = 0;
memcpy(msg, line.c_str(), size);
cout << "Trimitem: " << line << "\n";
MPI_Send(msg, size, MPI_CHAR, vecini[j], tag2, MPI_COMM_WORLD);
}
//trimite mesaje catre toti vecinii
cout << "Nodul " << rank << " trimite mesaj de broadcast\n";
}
//====================================== Mesaj normal ===============================
else {
//trimite mesajul cu destinatia citita din fisier
int destinatie = atoi(dest);
size_t found;
//vom determina cu ajutorul tabelei de rutare care este next-hop si trimitem catre acesta
int size = line.size() + 1;
char* msg = new char[size];
msg[size-1] = 0;
memcpy(msg, line.c_str(), size);
cout << " Nodul " << rank << " trimite: " << line << " catre nodul " << destinatie << " Next-hop: " << tabela[destinatie] << "\n";
MPI_Send(msg, size, MPI_CHAR, tabela[destinatie], tag2, MPI_COMM_WORLD);
free(msg);
}
}
}
}
mesaje.close();
//trebuie sa stergem vecinii care fac parte din cicluri
/*for (i = 0; i < nrElemCiclu; i++) {
cout << dinCiclu[i] << ", ";
}
cout << endl;*/
int ind = 0;
int* newVecini = new int[nrVecini - nrElemCiclu];
for (i = 0; i < nrVecini; i++) {
if (!contine(dinCiclu, vecini[i], nrElemCiclu)) {
newVecini[ind] = vecini[i];
ind++;
}
}
for (i = 0; i < ind; i++) {
vecini[i] = newVecini[i];
}
nrVecini = ind;
//dupa ce a trimis toate mesajele, trimite un mesaj de broadcast, care anunta toate procesele ca a terminat de trimis
//trimitem catre toti vecinii un mesaj care contine rankul nostru. Se termina atunci cand ajungem la frunze.
for (i = 0; i < nrVecini; i++) {
char exit[50] = "exit ";
char nr[33];
sprintf(nr, "%d", rank);
strcat(exit, nr);
int size = strlen(exit) + 1;
MPI_Send(exit, size, MPI_CHAR, vecini[i], tag2, MPI_COMM_WORLD);
}
//indiferent daca procesul trimite sau nu mesaje, acesta trebuie sa astepte mesaje
//in continutul mesajului vom avea destinatia si mesajul(deci trimitem linia pe care o citim, din care stergem sursa)
char primit[200];
char primit1[200];
char exit[50] = "exit";
int terminare, desti, source, deTerminat = nrVecini - 1, terminat = 0;
char *d, *s;
int* terminate = new int[noTasks];
for (i = 0; i < noTasks; i++) {
terminate[i] = 0;
}
terminate[rank] = 1;
int flag = 0, count;
while (!allone(terminate, noTasks)) {
MPI_Recv(primit, 200, MPI_CHAR, MPI_ANY_SOURCE, tag2, MPI_COMM_WORLD, &status);
//a primit un mesaj
MPI_Get_count(&status, MPI_CHAR, &count);
memcpy(primit1, primit, count);
s = strtok(primit1, " ");
if (strcmp(s, exit) == 0) {
//am primit mesaj de terminare
//determinam rankul care a terminat
char* r = strtok(NULL, " ");
int ran = atoi(r);
terminate[ran] = 1;
for (i = 0; i < nrVecini; i++) {
if (vecini[i] != status.MPI_SOURCE) {
//trimite mai departe mesajul de terminare
MPI_Send(primit, count, MPI_CHAR, vecini[i], tag2, MPI_COMM_WORLD);
}
}
}
else {
d = strtok(NULL, " ");
if (strcmp(d, b) == 0) {
cout << "\n<<<<<<<<<<<<<<<<<<<<<< rank " << rank << " a primit mesajul de broadcast >>>>>>>>>>>>\n\n";
for (i = 0; i < nrVecini; i++) {
if (vecini[i] != status.MPI_SOURCE) {
//trimite mai departe mesajul de terminare
MPI_Send(primit, count, MPI_CHAR, vecini[i], tag2, MPI_COMM_WORLD);
}
}
}
else {
desti = atoi(d);
source = atoi(s);
cout << "procesul " << rank << " a primit de la " << status.MPI_SOURCE << " mesajul: " << primit << " cu destinatia " << desti << "(expeditorul mesajului este: " << source << " NEXT-HOP: " << tabela[desti] << ")\n";
//daca aceasta este destinatia, ne oprim aici, altfel trimitem mesajul mai departe
if (rank != desti) {
MPI_Send(primit, count, MPI_CHAR, tabela[desti], tag2, MPI_COMM_WORLD);
}
else {
cout << "\n!!!!rank: " << rank << " mesajul " << primit << " a ajuns la destinatie!!!!\n\n";
}
}
}
}
//=============================================================================================================
//========================================= Etapa 3 ===========================================================
//=============================================================================================================
/*char vot[70];
if (rank == 0) {
for (i = 0; i < )
MPI_Recv(vot, 50, MPI_CHAR, MPI_ANY_SOURCE, tag2, MPI_COMM_WORLD, &status);
}*/
MPI_Finalize();
return 0;
}
| [
"simonaandreea.badoiu@gmail.com"
] | simonaandreea.badoiu@gmail.com |
33e097170f37b3a12c119202d2c41cdce37be72f | 19865cda31b2a42fbb17ac4105e4a422a83342f6 | /BOJ/01000/1987_알파벳.cpp | 9ceeba7e17621c48c51031d360a6904e30a5c555 | [] | no_license | warmwhiten/PS | 0f19c3742b09ee966196fc4e25f4fd58070a0eb2 | a2a1d8952e6cb4f65cc0fede35d730a80af617ff | refs/heads/master | 2023-02-08T15:55:06.389594 | 2020-12-28T06:57:40 | 2020-12-28T06:57:40 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 898 | cpp | #include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define FUP(i, a, b) for(int i = a; i <= b; i++)
#define FDOWN(i, a, b) for(int i = a; i >= b; i--)
#define MS(a, b) memset(a, b, sizeof(a))
#define ALL(v) v.begin(), v.end()
int dy[4] = { -1, 1, 0, 0 };
int dx[4] = { 0, 0, 1, -1 };
int N, M;
char arr[20][20];
bool visited[26];
int answer = 1;
void DFS(int y, int x, int cnt)
{
answer = max(cnt, answer);
visited[arr[y][x] - 'A'] = true;
FUP(i, 0, 3)
{
int ny = y + dy[i];
int nx = x + dx[i];
if (ny < 0 || nx < 0 || ny >= N || nx >= M || visited[arr[ny][nx] - 'A']) continue;
DFS(ny, nx, cnt + 1);
}
visited[arr[y][x] - 'A'] = false;
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin >> N >> M;
FUP(i, 0, N - 1)
FUP(j, 0, M - 1)
cin >> arr[i][j];
MS(visited, false);
DFS(0, 0, 1);
cout << answer;
return 0;
} | [
"gyuho965@gmail.com"
] | gyuho965@gmail.com |
dc8ae971874e95e3ec6ae9ccfbf3b1efdc2b6c94 | b06126d225c3fd72aacd5635e11df9047f71dc0b | /Engine/Source/Core/Texture/TNearestPixelTex2D.h | 21454c3c59678ff41800a986d1373bc8239bec28 | [
"MIT"
] | permissive | MarvinChung/Photon-v2 | 80deaa52c723f0a34bb1d84e829b251012b2626c | a42761797f5364525e5686cd7fe2eff6f5b04ddf | refs/heads/master | 2020-04-03T20:43:08.028086 | 2019-01-25T20:31:11 | 2019-01-25T20:31:11 | 155,555,269 | 1 | 0 | MIT | 2018-10-31T12:39:52 | 2018-10-31T12:39:51 | null | UTF-8 | C++ | false | false | 1,045 | h | #pragma once
#include "Core/Texture/TPixelTex2D.h"
#include "Core/Texture/SampleLocation.h"
#include "Math/math.h"
namespace ph
{
template<typename T, std::size_t N>
class TNearestPixelTex2D final : public TPixelTex2D<T, N>
{
public:
using TPixelTex2D<T, N>::TPixelTex2D;
virtual ~TNearestPixelTex2D() override = default;
virtual inline void sample(
const SampleLocation& sampleLocation,
TTexPixel<T, N>* const out_value) const override
{
const uint32 w = this->getWidthPx();
const uint32 h = this->getHeightPx();
PH_ASSERT(w != 0 && h != 0);
// normalize uv first to avoid overflowing xy after multiplying
// width and height
float64 normU, normV;
this->normalizeUV(sampleLocation.uvw().x, sampleLocation.uvw().y,
&normU, &normV);
// calculate pixel index and handle potential overflow
uint32 x = static_cast<uint32>(normU * w);
uint32 y = static_cast<uint32>(normV * h);
x = x < w ? x : w - 1;
y = y < h ? y : h - 1;
this->getPixel(x, y, out_value);
}
};
}// end namespace ph | [
"b01502051@ntu.edu.tw"
] | b01502051@ntu.edu.tw |
73a6fc36d1924177831c4f452f99e7a3a6aa0d77 | fd626ef9b6fe25d66bdcd3b12fceab5ae335c685 | /Player.h | 92028a732106b9dae4a5ed504a2355f8f0d20be5 | [] | no_license | tdemchuk/AIChess | 555fe0ef0fb184fb2ff3e2a4110cb78e4ef0acc0 | 1ac8016e9cc0091459603780796a94280e256933 | refs/heads/master | 2022-04-26T06:18:29.055206 | 2022-04-12T20:47:41 | 2022-04-12T20:47:41 | 220,375,058 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 988 | h | #ifndef PLAYER_H
#define PLAYER_H
#include "Color.h"
#include "Piece.h"
#include "Gameboard.h"
#include "GameState.h"
#include <vector>
/*
Player Class
*/
class Player
{
public:
Player() = delete;
Player(Color team);
~Player();
const Color team() const; // Return the team this player is on
std::string teamStr() const; // Returns a string decsribing which team this player is on [color string]
Piece* create(Piece::Type type, glm::vec2 pos, Gameboard& board); // Create a piece as owned by this Player and place on the given gameboard
std::vector<Piece*>& getOwned(); // Returns reference to the list of pieces this player owns
void capture(Piece* piece); // Adds a piece to the list of pieces this player has captured
std::vector<Piece*>& getCaptured(); // Returns reference to the list of pieces this player has captured
private:
const Color m_team;
std::vector<Piece*> m_owned;
std::vector<Piece*> m_captured;
};
#endif | [
"td16qg@brocku.ca"
] | td16qg@brocku.ca |
96ea4e0307853e2493e5599404a684eab555d053 | 75791b7f138acb94a1c9a34fb721de8ef71b6d5d | /fon9/InnDbfRoom.hpp | 5b6cdbfa61bf4bd120b89acfa26d9674ff56d3c1 | [
"Apache-2.0"
] | permissive | yuan0105/libfon9 | 2418467e34cbe797ad6a7bc42aaf30ad3535ce8f | e4b7da9cb04181c36fc15305409a04772b774fd8 | refs/heads/master | 2022-12-30T02:45:55.775354 | 2020-09-21T07:25:36 | 2020-09-21T07:25:36 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,552 | hpp | /// \file fon9/InnDbfRoom.hpp
///
/// ```
/// InnDbfRoom format: _____________________
/// / Bitv format \.
/// +-- 4bytes --+- 1 byte -+- 4bytes -+-----------+-----------+------------+
/// | BlockCount | RoomType | DataSize | TableId | SyncKey | Payload |
/// +------------+----------+----------+-----------+-----------+------------+
/// \______ InnFile RoomHeader ______/ \_ InnDbf RoomHeader _/
///
///
/// Sync data format:
/// ________________________________
/// / Bitv format \.
/// +----------+-----------+-----------+------------+
/// | RoomType | TableName | SyncKey | Payload |
/// +----------+-----------+-----------+------------+
/// \_ Same as InnDbfRoom _/
///
///
/// Payload:
/// 由 TableHandler 處理, 通常會加上 Version, 然後接著資料.
/// InnDbfRoomType::RowData: 儲存一筆完整資料.
/// InnDbfRoomType::RowDeleted: 通常僅儲存資料的Key, 用來判斷後續同步資料的新舊.
/// ```
///
/// \author fonwinz@gmail.com
#ifndef __fon9_InnDbfRoom_hpp__
#define __fon9_InnDbfRoom_hpp__
#include "fon9/InnSyncKey.hpp"
#include "fon9/InnFile.hpp"
#include "fon9/intrusive_ref_counter.hpp"
#include "fon9/buffer/BufferList.hpp"
namespace fon9 {
using InnDbfTableId = uint32_t;
class fon9_API InnDbf;
using InnDbfSP = intrusive_ptr<InnDbf>;
class fon9_API InnDbfTableLink;
using InnDbfTableLinkSP = intrusive_ptr<InnDbfTableLink>;
class fon9_API InnDbfTableHandler;
//--------------------------------------------------------------------------//
enum class InnDbfRoomType : InnRoomType {
/// Room 裡面儲存的是一般的資料.
RowData = 0x10,
/// Room 裡面儲存的是一個被刪除的 RowKey.
/// 用來避免收到舊的同步資料時, 被刪掉的舊資料又復活了.
RowDeleted = 0x11,
};
enum class InnDbfRoomNote : InnFile::RoomKey::NoteT {
NoPending,
NeedsSync,
FromSyncer,
};
fon9_WARN_DISABLE_PADDING;
/// \ingroup Inn
class InnDbfRoom : public intrusive_ref_counter<InnDbfRoom> {
fon9_NON_COPY_NON_MOVE(InnDbfRoom);
InnDbfRoomNote PendingRoomNote_{InnDbfRoomNote::NoPending};
InnDbfRoomType PendingRoomType_;
BufferList PendingWrite_;
InnFile::RoomKey RoomKey_;
InnSyncKey SyncKey_;
friend class InnDbf;
friend class InnDbfTableLink;
friend class InnDbfRoomKey;
InnDbfRoom() = default;
InnDbfRoom(InnFile::RoomKey&& roomKey)
: RoomKey_{std::move(roomKey)} {
}
InnDbfRoom(InnFile::RoomKey&& roomKey, const InnSyncKey& syncKey)
: RoomKey_{std::move(roomKey)}
, SyncKey_{syncKey} {
}
};
using InnDbfRoomSP = intrusive_ptr<InnDbfRoom>;
fon9_WARN_POP;
/// \ingroup Inn
class InnDbfRoomKey {
fon9_NON_COPYABLE(InnDbfRoomKey);
friend class InnDbf;
InnDbfRoomSP RoomSP_;
InnDbfRoomKey(InnDbfRoomSP&& room) : RoomSP_{std::move(room)} {
}
public:
InnDbfRoomKey() = default;
InnDbfRoomKey(InnDbfRoomKey&&) = default;
InnDbfRoomKey& operator=(InnDbfRoomKey&&) = default;
explicit operator bool() const {
return this->RoomSP_.get() != nullptr;
}
void swap(InnDbfRoomKey& rhs) {
this->RoomSP_.swap(rhs.RoomSP_);
}
InnDbfRoomType GetRoomType() const {
return static_cast<InnDbfRoomType >(this->RoomSP_->RoomKey_.GetPendingRoomType());
}
const InnSyncKey& GetSyncKey() const {
return this->RoomSP_->SyncKey_;
}
};
} // namespaces
#endif//__fon9_InnDbfRoom_hpp__
| [
"fonwinz@gmail.com"
] | fonwinz@gmail.com |
c123c57e48ce6fba76a03f14845859bfdcca7df6 | a06a9ae73af6690fabb1f7ec99298018dd549bb7 | /_Library/_Include/boost/units/physical_dimensions/angular_velocity.hpp | 41c85f230698f9eb5483558870805dfdaa3b5395 | [] | no_license | longstl/mus12 | f76de65cca55e675392eac162dcc961531980f9f | 9e1be111f505ac23695f7675fb9cefbd6fa876e9 | refs/heads/master | 2021-05-18T08:20:40.821655 | 2020-03-29T17:38:13 | 2020-03-29T17:38:13 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,278 | hpp | ////////////////////////////////////////////////////////////////////////////////
// angular_velocity.hpp
// Boost.Units - A C++ library for zero-overhead dimensional analysis and
// unit/quantity manipulation and conversion
//
// Copyright (C) 2003-2008 Matthias Christian Schabel
// Copyright (C) 2008 Steven Watanabe
//
// 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)
#ifndef BOOST_UNITS_ANGULAR_VELOCITY_DERIVED_DIMENSION_HPP
#define BOOST_UNITS_ANGULAR_VELOCITY_DERIVED_DIMENSION_HPP
#include <boost/units/derived_dimension.hpp>
#include <boost/units/physical_dimensions/plane_angle.hpp>
#include <boost/units/physical_dimensions/time.hpp>
namespace boost {
namespace units {
/// derived dimension for angular velocity : T^-1 QP
typedef derived_dimension<time_base_dimension,-1,
plane_angle_base_dimension,1>::type angular_velocity_dimension;
} // namespace units
} // namespace boost
#endif // BOOST_UNITS_ANGULAR_VELOCITY_DERIVED_DIMENSION_HPP
/////////////////////////////////////////////////
// vnDev.Games - Trong.LIVE - DAO VAN TRONG //
////////////////////////////////////////////////////////////////////////////////
| [
"adm.fael.hs@gmail.com"
] | adm.fael.hs@gmail.com |
964c731ab4f2b230e12e4cabec95cc5f2e899b80 | cb7b5aa09f79f0df90adb9d82d7d5ca00c59605f | /Wall_of_Death.ino | 36e64060fd2583bd7267ffe072886f27d2723231 | [] | no_license | DonFalma/WallOfDeath | c781c6f20b3a4fdf71a3eb5d042f90b0e3aad1af | e66219aa75ac4933c1f9b13bb9958e784a014308 | refs/heads/master | 2016-09-06T06:54:27.619478 | 2014-11-01T05:36:13 | 2014-11-01T05:36:13 | 25,685,745 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,274 | ino | // PINs
const int cNumberOfLeds = 8;
const int cLed[] = {2,3,4,5,6,7,8,9};
const int cTrigger = A0;
const int cEcho = A1;
// Grenzwerte
const unsigned int cHoldDuration = 500; // LEDs bleiben 500ms an
const unsigned int cDurationMax = 1176; // ca. 200mm
unsigned int duration_min = cDurationMax - 1;
unsigned long start_time = 0;
byte hold_led = 0;
// Messwerte
const unsigned int cBufferSize = 3; // Für die Glättung der Eingangsmesswerte
unsigned int buffer_[cBufferSize];
byte buffer_ptr_ = 0;
unsigned int duration = 0; // Dauer des Impulses vom Ultraschallsensor
void setup()
{
// initialize serial output
Serial.begin(115200);
Serial.println("");
pinMode(cTrigger,OUTPUT);
pinMode(cEcho,INPUT);
digitalWrite(cTrigger, HIGH);
for(int i = 0; i < cNumberOfLeds; i++)
{
pinMode(cLed[i],OUTPUT);
}
}
void loop()
{
// Ultaschallsensor einlesen
digitalWrite(cTrigger, LOW);
duration = pulseIn(cEcho, HIGH);
digitalWrite(cTrigger, HIGH);
if ((duration < duration_min) && (duration > 250))
{
duration_min = duration;
}
// Messwert begrenzen
duration = constrain(duration, duration_min, cDurationMax);
// Messwert glätten
buffer_[buffer_ptr_] = duration;
buffer_ptr_++;
buffer_ptr_ %= cBufferSize;
duration = 0;
for (byte i = 0; i < cBufferSize; i++)
{
duration += buffer_[i];
}
duration /= cBufferSize;
// Wieviele LEDs müssen leuchten
unsigned int value = map(duration, cDurationMax, duration_min + 20, 0, cNumberOfLeds);
// Hold berechnen
if (value >= hold_led)
{
hold_led = value;
start_time = millis();
}
if ((start_time + cHoldDuration) < millis())
{
hold_led = 0;
}
// Infos auf die serielle Schnittstelle schreiben
Serial.print("Duration: ");
Serial.print(duration);
Serial.print(" \tDuration Min: ");
Serial.print(duration_min);
Serial.print(" \tDuration Max: ");
Serial.print(cDurationMax);
Serial.print(" \tstart_time: ");
Serial.print(start_time);
Serial.print(" \thold_led: ");
Serial.print(hold_led);
Serial.print("\t LED: ");
Serial.println(value);
// LEDs ansteuern
for (int i = 0; i < cNumberOfLeds; i++)
{
digitalWrite(cLed[i], hold_led > i);
}
// Pause bis zur nächsten Messung
delay(100);
}
| [
"github.20.donfalma@spamgourmet.com"
] | github.20.donfalma@spamgourmet.com |
572865291ca1a79be8d0bb5b20d9c08478653923 | 0eff74b05b60098333ad66cf801bdd93becc9ea4 | /second/download/git/gumtree/git_repos_function_2798_git-2.2.3.cpp | e9e2e788219c1db21a5415cd41bd4a73ce056cc9 | [] | no_license | niuxu18/logTracker-old | 97543445ea7e414ed40bdc681239365d33418975 | f2b060f13a0295387fe02187543db124916eb446 | refs/heads/master | 2021-09-13T21:39:37.686481 | 2017-12-11T03:36:34 | 2017-12-11T03:36:34 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 354 | cpp | char *sha1_to_hex(const unsigned char *sha1)
{
static int bufno;
static char hexbuffer[4][50];
static const char hex[] = "0123456789abcdef";
char *buffer = hexbuffer[3 & ++bufno], *buf = buffer;
int i;
for (i = 0; i < 20; i++) {
unsigned int val = *sha1++;
*buf++ = hex[val >> 4];
*buf++ = hex[val & 0xf];
}
*buf = '\0';
return buffer;
} | [
"993273596@qq.com"
] | 993273596@qq.com |
6bbe4207a0c19c988e029e51b5787122b8bb2c43 | 8be981f0e66a6d50d367986bb0fe788b17165a58 | /Week_1/examples/Chapter_1/1_3_인스턴스와 입출력 흐름/1_3_3/main.cpp | 11ec651c279df2d3a0181d1acf72a573a212b5b1 | [] | no_license | JeongJiAn/Hacker_Study_OOP | 16cd7c4c66b42697201fc0b7c7bf1206850388ee | ef545c50ec8ade1392d1f1c1ecd62ed44947478f | refs/heads/master | 2023-07-17T01:51:26.046305 | 2021-08-22T07:04:24 | 2021-08-22T07:04:24 | 379,502,114 | 0 | 0 | null | null | null | null | UHC | C++ | false | false | 534 | cpp | #include <iostream>
#include <string>
#include <cstdio>
int main() {
int n_age;
std::cout << "나이를 입력하세요: " << std::endl;
std::cin >> n_age;
char szJob[32];
std::cout << "직업을 입력하세요: " << std::endl;
std::cin >> szJob;
std::string str_name;
std::cout << "이름을 입력하세요: " << std::endl;
std::cin >> str_name;
std::cout << "당신의 이름은 " << str_name << "이고, " << "나이는 " << n_age << "살이며, " << "직업은 " << szJob << "입니다." << std::endl;
return 0;
} | [
"devjian0219@gmail.com"
] | devjian0219@gmail.com |
8d89ace54ce318d94fd828849e5a75230bd747c8 | f315e2cd8780325d797ac23b080b0e3da071d3bd | /code/code 2.0/gameBoard.cpp | b7aa56522c959843440b18fb7d069dcc0ad281e3 | [] | no_license | tgibbons95/FinalProject | 2d7e4b9a7ddb4b5d71e90fcba043d28ebd83b1ad | 56b513e3cd72b812f1574836fc1850aa3bbe24d5 | refs/heads/master | 2020-12-24T08:40:16.971321 | 2016-12-10T01:00:06 | 2016-12-10T01:00:06 | 73,329,922 | 1 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 6,600 | cpp | #include "headers/gameBoard.h"
gameBoard::gameBoard() {
fullBoard = false;
gameFinished = false;
int i;
for (i = 0; i < 7; i++) {
boardColumn current; //create empty column
board.push_back(current); //push 7 empty columns to intialize
}
numPlayers = 1;
playerColor = 'R';
}
gameBoard::~gameBoard() {
//deallocate
}
bool gameBoard::checkFull() {
for (int i = 0; i < 7; i++) {
if (!board[i].checkFull()) //if column found not full exit
return false;
}
return true; //if all column full, board is full return true
}
void gameBoard::displayBoard() {
int r, c;
system(ERASE); //system dependent and can remove but looks nice
cout << " +---+---+---+---+---+---+---+\n";
for (r = 0; r < 6; r++) {
cout << " |";
for (c = 0; c < 7; c++) {
cout << " " << symbol(board[c].column[5 - r].value) << " |";
}
cout << "\n"
<< " +---+---+---+---+---+---+---+\n";
}
cout << " 1 2 3 4 5 6 7\n"; //print column nums
//cout << "\n It is Player"
}
char gameBoard::symbol(int i) {
switch (i) {
case 0:
return ' ';
case 1:
return playerColor;
case 2:
if (playerColor == 'R')
return 'B';
else
return 'R';
case 3:
if (playerColor == 'R')
return 'B';
else
return 'R';
}
return ('?');
}
void gameBoard::makeMove(int player, int column) {
if (column >= 1 && column <= 7) { //error check column choice
int c = column - 1; //indices (r,c)
int r = board[c].length; //num of pieces in column
if (board[c].checkFull() == false) { //error check for full column
board[c].column[r].value = player; //change that one space
board[c].length++; //one more piece added
gameOver(r, c); //check for game over
if (numPlayers == 2) //display board for next player
displayBoard();
else if (player == CPU)
displayBoard();
else if (gameFinished) //but display if game is over and cpu doesn't have to go
displayBoard();
//else no need to display for cpu
}
else
cout << "\nColumn is full";
}
else
cout << "\nColumn must be 1-7";
}
void gameBoard::gameOver(int row, int col) {
//four across
if (across(row, col))
gameFinished = true;
//four down(no need to check up)
else if (down(row, col))
gameFinished = true;
//four diagonal positive slope
else if (posDiagonal(row, col))
gameFinished = true;
//four diagonal negative slope
else if (negDiagonal(row, col))
gameFinished = true;
//Tie game
else if (checkFull()) {
gameOverMessage = "\nIt's a draw!\n";
gameFinished = true;
}
//otherwise
else
gameFinished = false;
}
bool gameBoard::across(int row, int col) {
//which player to look for win
int player = board[col].column[row].value;
//what area to check for win
int columnRangeLow = (col - 3 >= 0) ? col - 3 : 0;
int columnRangeHigh = (col + 3 <= 6) ? col + 3 : 6;
int count = 0; //how many in a row
int x = 0; //bump indicesi
while (col + x <= columnRangeHigh && board[col + x].column[row].value == player) {
count++; //count piece and pieces to right
x++;
}
x = 1; //start one over to not double count move
while (col - x >= columnRangeLow && board[col - x].column[row].value == player) {
count++; //count pieces to left
x++;
}
if (count >= 4) {
if (player != 3) {
gameOverMessage = "\nPlayer ";
stringstream ss; //sequence converts num to string
ss << player;
gameOverMessage += ss.str();
}
else
gameOverMessage = "CPU"; //for player=3 that is not actual player
gameOverMessage += " wins!\n";
return true;
}
return false;
}
bool gameBoard::down(int row, int col) {
//which player to look for win
int player = board[col].column[row].value;
//what area to check for win
int rowRangeLow = (row - 3 >= 0) ? row - 3 : 0;
int rowRangeHigh = (row + 3 <= 5) ? row + 3 : 5;
int count = 0; //how many in a column
int x = 0; //bump indices
while (row - x >= rowRangeLow && board[col].column[row - x].value == player) {
count++; //count pieces down
x++;
}
if (count >= 4) {
if (player != 3) {
gameOverMessage = "\nPlayer ";
stringstream ss; //sequence converts num to string
ss << player;
gameOverMessage += ss.str();
}
else
gameOverMessage = "CPU"; //for player=3 that is not actual player
gameOverMessage += " wins!\n";
return true;
}
return false;
}
bool gameBoard::posDiagonal(int row, int col) {
//which player to look for win
int player = board[col].column[row].value;
//what area to check for win
int columnRangeLow = (col - 3 >= 0) ? col - 3 : 0;
int columnRangeHigh = (col + 3 <= 6) ? col + 3 : 6;
int rowRangeLow = (row - 3 >= 0) ? row - 3 : 0;
int rowRangeHigh = (row + 3 <= 5) ? row + 3 : 5;
int count = 0; //how many in a row
int x = 0; //bump indices
while (row + x <= rowRangeHigh && col + x <= columnRangeHigh && board[col + x].column[row + x].value == player) {
count++; //count piece and pieces to right
x++;
}
x = 1; //start one over to not double count move
while (row - x >= rowRangeLow && col - x >= columnRangeLow && board[col - x].column[row - x].value == player) {
count++; //count pieces to left
x++;
}
//cout << count;
if (count >= 4) {
if (player != 3) {
gameOverMessage = "\nPlayer ";
stringstream ss; //sequence converts num to string
ss << player;
gameOverMessage += ss.str();
}
else
gameOverMessage = "CPU"; //for player=3 that is not actual player
gameOverMessage += " wins!\n";
return true;
}
return false;
}
bool gameBoard::negDiagonal(int row, int col) {
//which player to look for win
int player = board[col].column[row].value;
//what area to check for win
int columnRangeLow = (col - 3 >= 0) ? col - 3 : 0;
int columnRangeHigh = (col + 3 <= 6) ? col + 3 : 6;
int rowRangeLow = (row - 3 >= 0) ? row - 3 : 0;
int rowRangeHigh = (row + 3 <= 5) ? row + 3 : 5;
int count = 0; //how many in a row
int x = 0; //bump indices
while (row + x <= rowRangeHigh && col - x >= columnRangeLow && board[col - x].column[row + x].value == player) {
count++; //count piece and pieces to right
x++;
}
x = 1; //start one over to not double count move
while (row - x >= rowRangeLow && col + x <= columnRangeHigh && board[col + x].column[row - x].value == player) {
count++; //count pieces to left
x++;
}
//cout << count;
if (count >= 4) {
if (player != 3) {
gameOverMessage = "\nPlayer ";
stringstream ss; //sequence converts num to string
ss << player;
gameOverMessage += ss.str();
}
else
gameOverMessage = "CPU"; //for player=3 that is not actual player
gameOverMessage += " wins!\n";
return true;
}
return false;
} | [
"luk3r0ck5@gmail.com"
] | luk3r0ck5@gmail.com |
adad62cedce23440e1b869f35b7fcb079476c27f | a8597563c1349d1ff2820cfc528d3d8d05b74bc7 | /SupportPackage/EAIOEAWebKit/local/include/EAIO/internal/EAIOEARefCount.h | cb2c4d223955a8739777c45c3cdd86a484736b69 | [] | no_license | lentinic/EAWebKit | 68f8288b96d3b629f0466e94287ece37820a322d | 132ee635f9cd4cfce92ad4da823c83d54b95e993 | refs/heads/master | 2021-01-15T22:09:35.942573 | 2011-06-28T16:41:01 | 2011-06-28T16:41:01 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,545 | h | /*
Copyright (C) 2009 Electronic Arts, 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:
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 Electronic Arts, Inc. ("EA") 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 ELECTRONIC ARTS AND ITS 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 ELECTRONIC ARTS OR ITS 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.
*/
///////////////////////////////////////////////////////////////////////////////
// EARefCount.h
//
// Copyright (c) 2007, Electronic Arts Inc. All rights reserved.
// Written by Paul Pedriana.
//
// Implements basic reference counting functionality.
//
// This file was copied from Foundation/EARefCount.h
///////////////////////////////////////////////////////////////////////////////
#ifndef EAIO_EAREFCOUNT_H
#define EAIO_EAREFCOUNT_H
/// namespace EA
/// The standard Electronic Arts namespace
namespace EA
{
template <typename T>
class EAIOAutoRefCount
{
public:
typedef T element_type;
T* mpObject;
public:
EAIOAutoRefCount()
: mpObject(NULL) {}
EAIOAutoRefCount(T* pObject)
: mpObject(pObject)
{
if(mpObject)
mpObject->AddRef();
}
EAIOAutoRefCount(const EAIOAutoRefCount& rhs)
: mpObject(rhs.mpObject)
{
if(mpObject)
mpObject->AddRef();
}
~EAIOAutoRefCount()
{
if(mpObject)
mpObject->Release();
}
EAIOAutoRefCount& operator=(const EAIOAutoRefCount& source)
{
return operator=(source.mpObject);
}
EAIOAutoRefCount& operator=(T* pObject)
{
if(pObject != mpObject)
{
T* const pTemp = mpObject;
if(pObject)
pObject->AddRef();
mpObject = pObject;
if(pTemp)
pTemp->Release();
}
return *this;
}
T& operator *() const
{
return *mpObject;
}
T* operator ->() const
{
return mpObject;
}
operator T*() const
{
return mpObject;
}
}; // class EAIOAutoRefCount
} // namespace EA
#endif // Header include guard
| [
"nanashi4129@gmail.com"
] | nanashi4129@gmail.com |
41b62c3add838df07755a3f6cccc3addcf01dd9b | 9f26a69452c93275be06697def0f40e7d9636946 | /tests/InitialSketches/advertise.ino | cf739c16855730c64642c58a7f3c9cccd9831758 | [] | no_license | BankingofThings/BoT-ESP32-SDK | e3e0927347b0907811d7cfefb6abd060a4271df2 | 7aa61bfe88b053ce3537370644667875718d19d6 | refs/heads/master | 2021-06-28T06:20:29.404388 | 2020-02-13T15:41:46 | 2020-02-13T15:41:46 | 166,825,403 | 0 | 0 | null | 2020-06-08T08:35:03 | 2019-01-21T14:13:26 | C++ | UTF-8 | C++ | false | false | 2,857 | ino | /*
Based on Neil Kolban example for IDF: https://github.com/nkolban/esp32-snippets/blob/master/cpp_utils/tests/BLE%20Tests/SampleServer.cpp
Ported to Arduino ESP32 by Evandro Copercini
*/
#include <BLEDevice.h>
#include <BLEUtils.h>
#include <BLEServer.h>
// See the following for generating UUIDs:
// https://www.uuidgenerator.net/
//preserve this ORDER!!!!!
#define SERVICE_UUID "729BE9C4-3C61-4EFB-884F-B310B6FFFFD1"
#define DEVICE_CHARACTERISTIC_UUID "CAD1B513-2DA4-4609-9908-234C6D1B2A9C"
#define DEVICE_INFO_CHARACTERISTIC_UUID "CD1B3A04-FA33-41AA-A25B-8BEB2D3BEF4E"
#define DEVICE_NETWORK_CHARACTERISTIC_UUID "C42639DC-270D-4690-A8B3-6BA661C6C899"
#define CONFIGURE_CHARACTERISTIC_UUID "32BEAA1B-D20B-47AC-9385-B243B8071DE4"
void startBLE(){
Serial.println("Starting BLE work!");
BLEDevice::init("botf1");
BLEServer *pServer = BLEDevice::createServer();
//this is to show in the list
BLEService *pService = pServer->createService(SERVICE_UUID);
BLECharacteristic *pDeviceCharacteristic = pService->createCharacteristic(
DEVICE_CHARACTERISTIC_UUID,
BLECharacteristic::PROPERTY_READ
);
std::string val;
val="{";
val=val+"\"deviceID\":\""+deviceID+"\"";
val=val+",\"makerID\":\""+makerID+"\"";
val=val+",\"publicKey\":\""+publicKey+"\"";
val=val+"}";
Serial.println("Set characteristic:" + String(DEVICE_CHARACTERISTIC_UUID) + " to:" + String(val.c_str()));
pDeviceCharacteristic->setValue(val);
//
BLECharacteristic *pDeviceInfoCharacteristic = pService->createCharacteristic(
DEVICE_INFO_CHARACTERISTIC_UUID,
BLECharacteristic::PROPERTY_READ
);
pDeviceInfoCharacteristic->setValue("{}");
BLECharacteristic *pNetworkharacteristic = pService->createCharacteristic(
DEVICE_NETWORK_CHARACTERISTIC_UUID,
BLECharacteristic::PROPERTY_READ
);
pNetworkharacteristic->setValue("{}");
BLECharacteristic *pConfigureCharacteristic = pService->createCharacteristic(
CONFIGURE_CHARACTERISTIC_UUID,
BLECharacteristic::PROPERTY_READ |
BLECharacteristic::PROPERTY_WRITE
);
pConfigureCharacteristic->setValue("{}");
pService->start();
// Start advertising
pServer->getAdvertising()->addServiceUUID(pService->getUUID());
pServer->getAdvertising()->start();
Serial.println("Characteristic defined! Now you can read it in your phone!");
delay(1000);
}
| [
"damian@bankingofthings.io"
] | damian@bankingofthings.io |
c9b949fa63fd1849fe714dd0c44547c7f448e9ef | 3044f89c4a284ceebef54a9e7ef1fb6b69231c63 | /feathergui/fgDropdown.cpp | bdba7ce8c32d53479ba070aebaba11896b6e7836 | [
"Apache-2.0"
] | permissive | ILikePizza555/feathergui | 79c597fcbca0c19b4f54b5b7ed2ddc15e914ea0d | 8357e47512455b5b38e9b778eab97f81e7663e91 | refs/heads/master | 2021-06-23T04:47:31.184573 | 2017-08-31T10:17:27 | 2017-08-31T10:17:27 | 105,095,736 | 0 | 0 | null | 2017-09-28T03:01:57 | 2017-09-28T03:01:57 | null | WINDOWS-1252 | C++ | false | false | 6,311 | cpp | // Copyright ©2017 Black Sphere Studios
// For conditions of distribution and use, see copyright notice in "feathergui.h"
#include "fgDropdown.h"
#include "feathercpp.h"
void fgDropdown_Init(fgDropdown* BSS_RESTRICT self, fgElement* BSS_RESTRICT parent, fgElement* BSS_RESTRICT next, const char* name, fgFlag flags, const fgTransform* transform, fgMsgType units)
{
bss::memsubset<fgDropdown, fgControl>(self, 0);
fgElement_InternalSetup(*self, parent, next, name, flags, transform, units, (fgDestroy)&fgDropdown_Destroy, (fgMessage)&fgDropdown_Message);
}
void fgDropdown_Destroy(fgDropdown* self)
{
fgBox_Destroy(&self->box);
self->control->message = (fgMessage)fgControl_Message;
fgControl_Destroy(&self->control);
}
void fgDropdown_Draw(fgElement* self, const AbsRect* area, const fgDrawAuxData* data, fgElement*)
{
fgDropdown* parent = (fgDropdown*)self->parent;
AbsRect cache;
fgElement* target = fgElement_GetChildUnderMouse(self, parent->mouse.x, parent->mouse.y, &cache);
fgroot_instance->backend.fgPushClipRect(&cache, data);
if(parent->selected)
{
AbsRect r;
ResolveRectCache(parent->selected, &r, &cache, (parent->selected->flags & FGELEMENT_BACKGROUND) ? 0 : &self->padding);
fgSnapAbsRect(r, self->flags);
fgroot_instance->backend.fgDrawAsset(0, &CRect_EMPTY, parent->select.color, 0, 0.0f, &r, 0.0f, &AbsVec_EMPTY, FGRESOURCE_RECT, data);
}
if(target != 0)
{
AbsRect r;
ResolveRectCache(target, &r, &cache, (target->flags & FGELEMENT_BACKGROUND) ? 0 : &self->padding);
fgSnapAbsRect(r, self->flags);
fgroot_instance->backend.fgDrawAsset(0, &CRect_EMPTY, parent->hover.color, 0, 0.0f, &r, 0.0f, &AbsVec_EMPTY, FGRESOURCE_RECT, data);
}
fgroot_instance->backend.fgPopClipRect(data);
}
size_t fgDropdownBox_Message(fgBox* self, const FG_Msg* msg)
{
fgDropdown* parent = (fgDropdown*)self->scroll->parent;
switch(msg->type)
{
case FG_MOUSEMOVE:
case FG_MOUSEOFF:
case FG_MOUSEON:
fgUpdateMouseState(&parent->mouse, msg);
break;
case FG_MOUSEDOWN:
fgUpdateMouseState(&parent->mouse, msg);
assert(parent != 0);
if(parent->dropflag > 0 && !MsgHitElement(msg, *self))
{
_sendmsg<FG_NEUTRAL>(*parent);
self->scroll->SetFlag(FGELEMENT_HIDDEN, true);
fgClearTopmost(*self);
}
break;
case FG_MOUSEUP:
fgUpdateMouseState(&parent->mouse, msg);
assert(parent != 0);
{
AbsRect cache;
fgElement* target = MsgHitElement(msg, *self) ? fgElement_GetChildUnderMouse(*self, msg->x, msg->y, &cache) : 0;
if(target)
{
if(parent->selected)
fgSetFlagStyle(parent->selected, "selected", false);
parent->selected = target;
fgSetFlagStyle(target, "selected", true);
parent->dropflag = 1;
}
if(parent->dropflag > 0)
{
_sendmsg<FG_NEUTRAL>(*parent);
self->scroll->SetFlag(FGELEMENT_HIDDEN, true);
fgClearTopmost(*self);
}
}
if(parent->dropflag <= 0)
parent->dropflag = 1;
break;
case FG_REMOVECHILD:
if(parent && msg->e == parent->selected)
parent->selected = 0;
break;
}
return fgBox_Message(self, msg);
}
size_t fgDropdown_Message(fgDropdown* self, const FG_Msg* msg)
{
switch(msg->type)
{
case FG_CONSTRUCT:
{
fgTransform TF_BOX = { { 0, 0, 0, 1, 0, 1, 0, 1 }, 0, { 0, 0, 0, 0 } };
fgBox_Init(&self->box, *self, 0, "Dropdown$box", FGELEMENT_BACKGROUND | FGELEMENT_HIDDEN | FGELEMENT_NOCLIP | FGELEMENT_EXPANDY | FGBOX_TILEY | FGFLAGS_INTERNAL, &TF_BOX, 0);
self->box.fndraw = &fgDropdown_Draw;
self->box->message = (fgMessage)&fgDropdownBox_Message;
self->selected = 0;
self->dropflag = 0;
self->hover.color = 0x99999999;
break;
}
case FG_CLONE:
if(msg->e)
{
fgDropdown* hold = reinterpret_cast<fgDropdown*>(msg->e);
hold->selected = 0;
hold->hover = self->hover;
hold->select = self->select;
hold->dropflag = self->dropflag;
bss::bssFill(self->mouse, 0);
fgControl_Message(&self->control, msg);
self->box->Clone(hold->box);
_sendmsg<FG_ADDCHILD, fgElement*>(msg->e, hold->box);
}
return sizeof(fgDropdown);
case FG_MOUSEDOWN:
self->dropflag = -1;
self->box->SetFlag(FGELEMENT_HIDDEN, false);
fgSetTopmost(self->box);
return (*self->box->message)(self->box, msg);
case FG_DRAW:
fgControl_Message(&self->control, msg); // Render things normally first
if(self->selected) // Then, yank the selected item out of our box child and render it manually, if it exists
{
AbsRect* area = (AbsRect*)msg->p;
AbsRect out;
ResolveRect(self->selected, &out);
FABS dx = out.right - out.left;
FABS dy = out.bottom - out.top;
out.left = (((area->right - area->left) - dx) * 0.5f) + area->left;
out.top = (((area->bottom - area->top) - dy) * 0.5f) + area->top;
out.right = out.left + dx;
out.bottom = out.top + dy;
_sendmsg<FG_DRAW, void*, size_t>(self->selected, &out, msg->u2);
}
return FG_ACCEPT;
case FG_REMOVECHILD:
if(msg->e == self->selected)
self->selected = 0;
case FG_ADDCHILD:
case FG_REORDERCHILD:
if(msg->e->flags & FGELEMENT_BACKGROUND)
break;
return (*self->box->message)(self->box, msg);
case FG_GETCOLOR:
switch(msg->subtype)
{
case FGSETCOLOR_MAIN:
case FGSETCOLOR_HOVER:
return self->hover.color;
case FGSETCOLOR_SELECT:
return self->select.color;
}
break;
case FG_SETCOLOR:
switch(msg->subtype)
{
case FGSETCOLOR_MAIN:
case FGSETCOLOR_HOVER:
self->hover.color = (uint32_t)msg->i;
return FG_ACCEPT;
case FGSETCOLOR_SELECT:
self->select.color = (uint32_t)msg->i;
return FG_ACCEPT;
}
break;
case FG_CLEAR:
case FG_SETDIM:
case FG_GETDIM:
return (*self->box->message)(self->box, msg);
case FG_GETSELECTEDITEM:
return (size_t)self->selected;
case FG_MOUSEON:
_sendmsg<FG_HOVER>(*self);
break;
case FG_MOUSEOFF:
if(self->dropflag < 0)
_sendmsg<FG_ACTIVE>(*self);
else
_sendmsg<FG_NEUTRAL>(*self);
break;
case FG_GETCLASSNAME:
return (size_t)"Dropdown";
}
return fgControl_Message(&self->control, msg);
} | [
"erikm@blackspherestudios.com"
] | erikm@blackspherestudios.com |
2a16f817a74fe42b0465a986cafdfa181debfbbd | 37b30edf9f643225fdf697b11fd70f3531842d5f | /third_party/blink/renderer/core/page/scrolling/text_fragment_handler.cc | eca0dec6587cae5988558144ef814640981d51b2 | [
"BSD-3-Clause",
"LGPL-2.0-or-later",
"LicenseRef-scancode-warranty-disclaimer",
"LGPL-2.1-only",
"GPL-1.0-or-later",
"GPL-2.0-only",
"LGPL-2.0-only",
"BSD-2-Clause",
"LicenseRef-scancode-other-copyleft",
"Apache-2.0",
"MIT"
] | permissive | pauladams8/chromium | 448a531f6db6015cd1f48e7d8bfcc4ec5243b775 | bc6d983842a7798f4508ae5fb17627d1ecd5f684 | refs/heads/main | 2023-08-05T11:01:20.812453 | 2021-09-17T16:13:54 | 2021-09-17T16:13:54 | 407,628,666 | 1 | 0 | BSD-3-Clause | 2021-09-17T17:35:31 | 2021-09-17T17:35:30 | null | UTF-8 | C++ | false | false | 9,816 | cc | // 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.
#include "third_party/blink/renderer/core/page/scrolling/text_fragment_handler.h"
#include "base/metrics/histogram_functions.h"
#include "base/strings/strcat.h"
#include "components/shared_highlighting/core/common/disabled_sites.h"
#include "components/shared_highlighting/core/common/shared_highlighting_features.h"
#include "third_party/blink/public/common/browser_interface_broker_proxy.h"
#include "third_party/blink/renderer/core/editing/markers/document_marker.h"
#include "third_party/blink/renderer/core/editing/markers/document_marker_controller.h"
#include "third_party/blink/renderer/core/editing/position_with_affinity.h"
#include "third_party/blink/renderer/core/editing/range_in_flat_tree.h"
#include "third_party/blink/renderer/core/editing/selection_editor.h"
#include "third_party/blink/renderer/core/editing/visible_units.h"
#include "third_party/blink/renderer/core/frame/local_frame.h"
#include "third_party/blink/renderer/core/page/scrolling/text_fragment_anchor.h"
namespace {
bool PreemptiveGenerationEnabled() {
return base::FeatureList::IsEnabled(
shared_highlighting::kPreemptiveLinkToTextGeneration);
}
} // namespace
namespace blink {
TextFragmentHandler::TextFragmentHandler(LocalFrame* main_frame)
: text_fragment_selector_generator_(
MakeGarbageCollected<TextFragmentSelectorGenerator>(main_frame)) {}
void TextFragmentHandler::BindTextFragmentReceiver(
mojo::PendingReceiver<mojom::blink::TextFragmentReceiver> producer) {
selector_producer_.reset();
selector_producer_.Bind(
std::move(producer),
text_fragment_selector_generator_->GetFrame()->GetTaskRunner(
blink::TaskType::kInternalDefault));
}
void TextFragmentHandler::Cancel() {
GetTextFragmentSelectorGenerator()->Reset();
}
void TextFragmentHandler::RequestSelector(RequestSelectorCallback callback) {
DCHECK(shared_highlighting::ShouldOfferLinkToText(
GetFrame()->GetDocument()->Url()));
DCHECK(!GetFrame()->Selection().SelectedText().IsEmpty());
if (PreemptiveGenerationEnabled()) {
GetTextFragmentSelectorGenerator()->RecordSelectorStateUma();
selector_requested_before_ready_ =
!preemptive_generation_result_.has_value();
response_callback_ = std::move(callback);
// If preemptive link generation is enabled, the generator would have
// already been invoked when the selection was updated in
// StartPreemptiveGenerationIfNeeded. If that generation finished simply
// respond with the result. Otherwise, the response callback is stored so
// that we reply on completion.
if (!selector_requested_before_ready_.value())
InvokeReplyCallback(preemptive_generation_result_.value());
} else {
DCHECK(!preemptive_generation_result_.has_value());
DCHECK(!response_callback_);
response_callback_ = std::move(callback);
StartGeneratingForCurrentSelection();
}
}
void TextFragmentHandler::GetExistingSelectors(
GetExistingSelectorsCallback callback) {
Vector<String> text_fragment_selectors;
TextFragmentAnchor* anchor = GetTextFragmentAnchor();
if (!anchor) {
std::move(callback).Run(Vector<String>());
return;
}
for (auto& finder : anchor->TextFragmentFinders()) {
if (finder->FirstMatch()) {
text_fragment_selectors.push_back(finder->GetSelector().ToString());
}
}
std::move(callback).Run(text_fragment_selectors);
}
void TextFragmentHandler::RemoveFragments() {
DCHECK(
base::FeatureList::IsEnabled(shared_highlighting::kSharedHighlightingV2));
GetTextFragmentSelectorGenerator()
->GetFrame()
->View()
->DismissFragmentAnchor();
}
// static
bool TextFragmentHandler::IsOverTextFragment(HitTestResult result) {
if (!result.InnerNode() || !result.InnerNodeFrame()) {
return false;
}
// Tree should be clean before accessing the position.
// |HitTestResult::GetPosition| calls |PositionForPoint()| which requires
// |kPrePaintClean|.
DCHECK_GE(result.InnerNodeFrame()->GetDocument()->Lifecycle().GetState(),
DocumentLifecycle::kPrePaintClean);
DocumentMarkerController& marker_controller =
result.InnerNodeFrame()->GetDocument()->Markers();
PositionWithAffinity pos_with_affinity = result.GetPosition();
const Position marker_position = pos_with_affinity.GetPosition();
auto markers = marker_controller.MarkersAroundPosition(
ToPositionInFlatTree(marker_position),
DocumentMarker::MarkerTypes::TextFragment());
return !markers.IsEmpty();
}
void TextFragmentHandler::ExtractTextFragmentsMatches(
ExtractTextFragmentsMatchesCallback callback) {
DCHECK(
base::FeatureList::IsEnabled(shared_highlighting::kSharedHighlightingV2));
Vector<String> text_fragment_matches;
TextFragmentAnchor* anchor = GetTextFragmentAnchor();
if (!anchor) {
std::move(callback).Run(Vector<String>());
return;
}
for (auto& finder : anchor->TextFragmentFinders()) {
if (finder->FirstMatch()) {
text_fragment_matches.push_back(
PlainText(finder->FirstMatch()->ToEphemeralRange()));
}
}
std::move(callback).Run(text_fragment_matches);
}
void TextFragmentHandler::ExtractFirstFragmentRect(
ExtractFirstFragmentRectCallback callback) {
DCHECK(
base::FeatureList::IsEnabled(shared_highlighting::kSharedHighlightingV2));
IntRect rect_in_viewport;
TextFragmentAnchor* anchor = GetTextFragmentAnchor();
if (!anchor || anchor->TextFragmentFinders().size() <= 0) {
std::move(callback).Run(gfx::Rect());
return;
}
for (auto& finder : anchor->TextFragmentFinders()) {
if (finder->FirstMatch() == nullptr) {
continue;
}
PhysicalRect bounding_box(
ComputeTextRect(finder->FirstMatch()->ToEphemeralRange()));
rect_in_viewport =
GetFrame()->View()->FrameToViewport(EnclosingIntRect(bounding_box));
break;
}
std::move(callback).Run(gfx::Rect(rect_in_viewport));
}
void TextFragmentHandler::DidFinishSelectorGeneration(
const TextFragmentSelector& selector) {
DCHECK(!preemptive_generation_result_.has_value());
if (response_callback_) {
InvokeReplyCallback(selector);
} else {
// If we don't have a callback yet, it's because we started generating
// preemptively. We'll store the result so that when the selector actually
// is requested we can simply use the stored result.
DCHECK(PreemptiveGenerationEnabled());
preemptive_generation_result_.emplace(selector);
}
}
void TextFragmentHandler::StartGeneratingForCurrentSelection() {
if (GetFrame()->Selection().SelectedText().IsEmpty())
return;
VisibleSelectionInFlatTree selection =
GetFrame()->Selection().ComputeVisibleSelectionInFlatTree();
EphemeralRangeInFlatTree selection_range(selection.Start(), selection.End());
RangeInFlatTree* current_selection_range =
MakeGarbageCollected<RangeInFlatTree>(selection_range.StartPosition(),
selection_range.EndPosition());
GetTextFragmentSelectorGenerator()->Generate(
*current_selection_range,
WTF::Bind(&TextFragmentHandler::DidFinishSelectorGeneration,
WrapWeakPersistent(this)));
}
void TextFragmentHandler::RecordPreemptiveGenerationMetrics(
const TextFragmentSelector& selector) {
DCHECK(PreemptiveGenerationEnabled());
DCHECK(selector_requested_before_ready_.has_value());
bool success =
selector.Type() != TextFragmentSelector::SelectorType::kInvalid;
std::string uma_prefix = "SharedHighlights.LinkGenerated";
if (selector_requested_before_ready_.value()) {
uma_prefix = base::StrCat({uma_prefix, ".RequestedBeforeReady"});
} else {
uma_prefix = base::StrCat({uma_prefix, ".RequestedAfterReady"});
}
base::UmaHistogramBoolean(uma_prefix, success);
if (!success) {
absl::optional<shared_highlighting::LinkGenerationError> optional_error =
GetTextFragmentSelectorGenerator()->GetError();
shared_highlighting::LinkGenerationError error =
optional_error.has_value()
? optional_error.value()
: shared_highlighting::LinkGenerationError::kUnknown;
base::UmaHistogramEnumeration(
"SharedHighlights.LinkGenerated.Error.Requested", error);
}
}
void TextFragmentHandler::StartPreemptiveGenerationIfNeeded() {
if (PreemptiveGenerationEnabled() &&
shared_highlighting::ShouldOfferLinkToText(
GetFrame()->GetDocument()->Url())) {
preemptive_generation_result_.reset();
StartGeneratingForCurrentSelection();
}
}
void TextFragmentHandler::Trace(Visitor* visitor) const {
visitor->Trace(text_fragment_selector_generator_);
visitor->Trace(selector_producer_);
}
void TextFragmentHandler::DidDetachDocumentOrFrame() {
// Clear out any state in the generator and cancel pending tasks so they
// don't run after frame detachment.
GetTextFragmentSelectorGenerator()->Reset();
}
void TextFragmentHandler::InvokeReplyCallback(
const TextFragmentSelector& selector) {
if (PreemptiveGenerationEnabled())
RecordPreemptiveGenerationMetrics(selector);
DCHECK(response_callback_);
std::move(response_callback_).Run(selector.ToString());
}
TextFragmentAnchor* TextFragmentHandler::GetTextFragmentAnchor() {
FragmentAnchor* fragmentAnchor = GetTextFragmentSelectorGenerator()
->GetFrame()
->View()
->GetFragmentAnchor();
if (!fragmentAnchor || !fragmentAnchor->IsTextFragmentAnchor()) {
return nullptr;
}
return static_cast<TextFragmentAnchor*>(fragmentAnchor);
}
} // namespace blink
| [
"chromium-scoped@luci-project-accounts.iam.gserviceaccount.com"
] | chromium-scoped@luci-project-accounts.iam.gserviceaccount.com |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.