blob_id stringlengths 40 40 | directory_id stringlengths 40 40 | path stringlengths 4 201 | content_id stringlengths 40 40 | detected_licenses listlengths 0 85 | license_type stringclasses 2 values | repo_name stringlengths 7 100 | snapshot_id stringlengths 40 40 | revision_id stringlengths 40 40 | branch_name stringclasses 260 values | visit_date timestamp[us] | revision_date timestamp[us] | committer_date timestamp[us] | github_id int64 11.4k 681M ⌀ | star_events_count int64 0 209k | fork_events_count int64 0 110k | gha_license_id stringclasses 17 values | gha_event_created_at timestamp[us] | gha_created_at timestamp[us] | gha_language stringclasses 80 values | src_encoding stringclasses 28 values | language stringclasses 1 value | is_vendor bool 1 class | is_generated bool 2 classes | length_bytes int64 8 9.86M | extension stringclasses 52 values | content stringlengths 8 9.86M | authors listlengths 1 1 | author stringlengths 0 119 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
b47bfc638315fe44e005a685ce6f44d39c1bb009 | d2edb8966319d7bd8fc809aa05c4d69b281fe9e2 | /LXEngine/LXQueryTransform.cpp | c45727e7249b1c4b2a4b87f602add3b3bf5c3a15 | [] | no_license | rodrigobmg/Seetron | 58239161016d8af3bae5ded5957ddced6e7a09bb | 8675f8793d707809657530c6b9388d797e106e0b | refs/heads/master | 2020-04-26T02:05:07.995826 | 2019-02-22T02:24:00 | 2019-02-22T02:24:00 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 6,778 | cpp | //------------------------------------------------------------------------------------------------------
//
// This is a part of Seetron Engine
//
// Copyright (c) 2018 Nicolas Arques. All rights reserved.
//
//------------------------------------------------------------------------------------------------------
#include "StdAfx.h"
#include "LXQueryTransform.h"
#include "LXQueryManager.h"
#include "LXProject.h"
#include "LXPropertyManager.h"
#include "LXCore.h"
#include "LXCommandManager.h"
#include "LXActorCamera.h"
#include "LXLogger.h"
#include "LXAxis.h"
#include "LXActorLine.h"
#include "LXAnchor.h"
#include "LXViewState.h"
#include "LXViewport.h"
#include "LXMemory.h" // --- Must be the last included ---
LXQueryTransform::LXQueryTransform() :
_StartPosition(0.f, 0.f),
_EndPosition(0.f, 0.f),
_IsMouseMove(false)
{
}
LXQueryTransform::~LXQueryTransform(void)
{
}
void LXQueryTransform::OnLButtonDown(uint64 nFlags, LXPoint pntWnd, LXActor* Actor)
{
CHK(Actor);
if (!Actor)
return;
_PickedWT = GetCore().GetViewport()->WorldTransformation;
_StartPosition = vec2f((float)pntWnd.x, (float)pntWnd.y);
if (LXActorLine* pLine = dynamic_cast<LXActorLine*>(Actor))
{
int segmentID = pLine->GetPickedID();
#if LX_ANCHOR
LXAnchor* pAnchor0 = pLine->GetAnchor(segmentID);
LXAnchor* pAnchor1;
if (segmentID == pLine->GetAnchorCount() - 1) // Loop
pAnchor1 = pLine->GetAnchor(0);
else
pAnchor1 = pLine->GetAnchor(segmentID + 1);
_listActors.push_back((LXActor*)pAnchor0);
_listActors.push_back((LXActor*)pAnchor1);
#endif
}
else
_listActors.push_back(Actor);
_bIsActive = true;
_IsMouseMove = false;
}
/*virtual*/
void LXQueryTransform::OnMouseMove(uint64 nFlags, LXPoint pntWnd)
{
CHK(_bIsActive);
_IsMouseMove = true;
_EndPosition = vec2f((float)pntWnd.x, (float)pntWnd.y);
vec2f mouseChange = _EndPosition - _StartPosition;
float lenght = mouseChange.Length();
if (mouseChange.Length() > 1.f)
{
vec3f vPickedPoint;
// Axis
LXAxis axis;
_PickedWT = GetCore().GetViewport()->WorldTransformation;
float xScale = _PickedWT.Width() / GetCore().GetViewport()->GetWidth();
float yScale = _PickedWT.Height() / GetCore().GetViewport()->GetHeight();
_PickedWT.GetPickAxis(axis, _EndPosition.x * xScale, _EndPosition.y * yScale);
for (auto It = _listActors.begin(); It != _listActors.end(); It++)
{
LXActor* pMesh = *It;
switch (_constraint)
{
case EConstraint::None: // ScreenSpace Dragging
{
// LXAxis plane;
// plane.SetOrigin(m_vPickedPoint);
//
//
// LXActorCamera* pCamera = GetCore().GetProject()->GetActiveView()->GetCamera();
// CHK(pCamera);
// if (pCamera)
// plane.SetVector(pCamera->GetViewVector());
//
// axis.IntersectPlane(plane, &vPickedPoint);
// vec3f v2 = vPickedPoint - m_vPickedPoint;
// matWCS.ParentToLocalVector(v2);
//
// LXMatrix matLocalTrs;
// matLocalTrs.SetOrigin(v2);
// matLCS = matLCS * matLocalTrs;
}
break;
case EConstraint::Local_X:
case EConstraint::Local_Y:
case EConstraint::Local_Z:
{
LXAxis v;
v.SetOrigin(_PickedPoint);
if (_constraint == EConstraint::Local_X)
v.SetVector(pMesh->GetVx());
else if (_constraint == EConstraint::Local_Y)
v.SetVector(pMesh->GetVy());
else if (_constraint == EConstraint::Local_Z)
v.SetVector(pMesh->GetVz());
vec3f p0;
axis.Distance(v, &p0, &vPickedPoint);
vec3f v2 = vPickedPoint - _PickedPoint;
vec3f NewPosition = pMesh->GetPosition() + v2;
pMesh->SetPosition(NewPosition);
}
break;
case EConstraint::Local_XY:
case EConstraint::Local_XZ:
case EConstraint::Local_YZ:
{
LXAxis plane;
plane.SetOrigin(_PickedPoint);
if (_constraint == EConstraint::Local_XY)
plane.SetVector(pMesh->GetVz());
else if (_constraint == EConstraint::Local_XZ)
plane.SetVector(pMesh->GetVy());
else if (_constraint == EConstraint::Local_YZ)
plane.SetVector(pMesh->GetVx());
axis.IntersectPlane(plane, &vPickedPoint);
vec3f v2 = vPickedPoint - _PickedPoint;
vec3f NewPosition = pMesh->GetPosition() + v2;
pMesh->SetPosition(NewPosition);
}
break;
case EConstraint::Local_Rotate_X:
case EConstraint::Local_Rotate_Y:
case EConstraint::Local_Rotate_Z:
{
vec3f vo = pMesh->GetPosition();
//vo.z = _PickedPoint.z;
LXAxis plane;
plane.SetOrigin(vo/*_PickedPoint*/);
if (_constraint == EConstraint::Local_Rotate_Z)
plane.SetVector(pMesh->GetVz());
else if (_constraint == EConstraint::Local_Rotate_Y)
plane.SetVector(pMesh->GetVy());
else if (_constraint == EConstraint::Local_Rotate_X)
plane.SetVector(pMesh->GetVx());
if (axis.IntersectPlane(plane, &vPickedPoint))
{
vec3f va = _PickedPoint - vo;
vec3f vb = vPickedPoint - vo;
va.Normalize();
vb.Normalize();
float ca = CosAngle(va, vb);
if (ca > 1.0)
{
int foo = 0;
}
ca = Clamp(ca, -1.f, 1.f);
float a = acosf(ca);
CHK(IsValid(a));
vec3f cp = CrossProduct(va, vb);
if (DotProduct(plane.GetVector(), cp) > 0.f)
{
a = -a;
}
a = LX_RADTODEG(a);
vec3f NewRotation;
if (_constraint == EConstraint::Local_Rotate_Z)
NewRotation = pMesh->GetRotation() + vec3f(0.f, 0.f, a);
else if (_constraint == EConstraint::Local_Rotate_Y)
NewRotation = pMesh->GetRotation() + vec3f(0.f, -a, 0.f);
else if (_constraint == EConstraint::Local_Rotate_X)
NewRotation = pMesh->GetRotation() + vec3f(a, 0.f, 0.f);
pMesh->SetRotation(NewRotation);
}
}
break;
default:CHK(0);
}
// if (pMesh->GetCID() & LX_NODETYPE_ANCHOR)
// {
// LXAnchor* pAnchor = (LXAnchor*)pMesh;
// pAnchor->GetOwner()->OnAnchorMove(pAnchor, matLCS);
// }
// else
// {
// LXPropertyVec3f* pProperty = dynamic_cast<LXPropertyVec3f*>(pMesh->GetProperty(LXPropertyID::POSITION));
// CHK(pProperty);
// GetCore().GetCommandManager().PreviewChangeProperty(pProperty, matLCS.GetOrigin());
// }
}
_PickedPoint = vPickedPoint;
}
}
/*virtual*/
void LXQueryTransform::OnLButtonUp(uint64 nFlags, LXPoint pntWnd)
{
if (_listActors.size())
{
for (auto It = _listActors.begin(); It != _listActors.end(); It++)
{
LXActor* Actor = *It;
if (Actor->GetCID() & LX_NODETYPE_ANCHOR)
{
#if LX_ANCHOR
LXAnchor* pAnchor = (LXAnchor*)Actor;
pAnchor->GetOwner()->OnAnchorReleased(pAnchor);
#endif
}
else
{
LXPropertyVec3f* pProperty = dynamic_cast<LXPropertyVec3f*>(Actor->GetProperty(LXPropertyID::POSITION));
CHK(pProperty);
GetCore().GetCommandManager().ChangeProperty(pProperty);
}
}
}
_listActors.clear();
_bIsActive = false;
}
| [
"nicolas.arques@gmail.com"
] | nicolas.arques@gmail.com |
25cc5aa8e408158dcd99b01674841370314388fd | da5a910b3e7e2020dd499b6e8b47868c6eb89747 | /bday.cpp | b077985080cdc1f6cb94827de8295814cfb15af1 | [] | no_license | adni03/DSA-Program-Files | 862513f30490dab5fa76bae943e2177ae7c678bc | e9ddecbc50859b6abd35e801d6b8cee65b44ebed | refs/heads/master | 2020-05-25T01:56:52.929175 | 2019-05-20T04:21:09 | 2019-05-20T04:28:15 | 187,566,587 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 557 | cpp | #include<iostream>
using namespace std;
int birthdayCakeCandles(long a, long b[]);
int main()
{
long x, y[100000], i=0;
cin>>x;
for(i=0; i<x; i++)
{
cin>>y[i];
}
cout<<birthdayCakeCandles(x,y);
return 0;
}
int birthdayCakeCandles(long a, long b[])
{
int i=0, j=0, dummy, cnt=0;
dummy = b[0];
for(i=0; i<a; i++)
{
if(b[i] > dummy)
dummy = b[i];
else
continue;
}
for(i=0; i<a; i++)
{
if(dummy == b[i])
cnt++;
}
return cnt;
}
| [
"adityanittala03@gmail.com"
] | adityanittala03@gmail.com |
599ab746258bb646a39d2562dd91cab5cde793ca | 68f704d3f12f0622335a8b7d5066f3bca6999167 | /03_Red_belt_begin_2020-08-15/Week_1/Prog_07_Deque_via_two_vectors/deque_via_two_vectors.cpp | a8f2279c897728b42e16eb418e0b83548e752b79 | [] | no_license | AVKouzbar/Coursera_Belts | 910f33ae0da815f6a1235575119f958e2678dd3c | 1df0439d3c6cb48ec44a983dd830cd9109edb7c8 | refs/heads/master | 2023-01-02T12:41:01.940936 | 2020-11-02T17:45:41 | 2020-11-02T17:45:41 | 309,447,093 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,317 | cpp | #include <iostream>
#include <vector>
//#include "test_runner.h"
#include <string>
using namespace std;
#define THROW_EXCEPTION \
if (index >= front_.size() + back_.size()) { \
throw out_of_range("Index is out of range"); \
}
#define GET_INDEX \
if (index < front_.size()) { \
return front_[front_.size() - 1 - index]; \
} \
return back_[index - front_.size()];
#define FRONT \
return front_.empty() ? back_.front() : front_.back();
#define BACK \
return back_.empty() ? front_.front() : back_.back();
template <typename T>
class Deque {
public:
Deque() {}
bool Empty() const {
return front_.empty() && back_.empty();
}
size_t Size() const {
return front_.size() + back_.size();
}
T& At(const size_t& index) {
THROW_EXCEPTION
GET_INDEX
}
const T& At(size_t index) const {
THROW_EXCEPTION
GET_INDEX
}
T& operator[](size_t index) {
GET_INDEX
}
const T& operator[](size_t index) const {
GET_INDEX
}
T& Front() {
FRONT
}
const T& Front() const {
FRONT
}
T& Back() {
BACK
}
const T& Back() const {
BACK
}
void PushFront(const T& value) {
front_.push_back(value);
}
void PushBack(const T& value) {
back_.push_back(value);
}
private:
vector<T> front_;
vector<T> back_;
};
| [
"avkouzbar.dev@gmail.com"
] | avkouzbar.dev@gmail.com |
3d3d76d2edaaa2fb4191fc7b6d02510b55ef84ee | 887b19aaff44a6578918fce2a20c40d5aff20619 | /Plugins/Wwise/Source/AkAudio/Private/AkWaapiBlueprints/AkWaapiCalls.cpp | b48183f746d9b1ee355e336234272f0e8225a508 | [] | no_license | TheAmazingZigZag/Camp | 1931aea7bb9145784a8fb6b269f7d1c7fd878e37 | d26761c7df04c67d6e60eb250fdee1f505b1deb4 | refs/heads/master | 2023-04-15T14:22:40.466740 | 2021-04-23T20:15:45 | 2021-04-23T20:15:45 | 360,970,303 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 5,598 | cpp | /********************************************************************************
The content of the files in this repository include portions of the AUDIOKINETIC
Wwise Technology released in source code form as part of the SDK package.
Commercial License Usage
Licensees holding valid commercial licenses to the AUDIOKINETIC Wwise Technology
may use these files in accordance with the end user license agreement provided
with the software or, alternatively, in accordance with the terms contained in a
written agreement between you and Audiokinetic Inc.
Copyright (c) 2021 Audiokinetic Inc.
********************************************************************************/
/*=============================================================================
AkWaapiCalls.cpp:
=============================================================================*/
#include "AkWaapiBlueprints/AkWaapiCalls.h"
#include "AkAudioDevice.h"
#include "AkWaapiBlueprints/AkWaapiCalls.h"
#include "AkWaapiBlueprints/AkWaapiUriCustomization.h"
#include "AkWaapiBlueprints/AkWaapiFieldNamesCustomization.h"
#include "EngineUtils.h"
#include "Model.h"
#include "UObject/UObjectIterator.h"
#include "Engine/GameEngine.h"
#include "Async/Async.h"
#include "Core/Public/Modules/ModuleManager.h"
DEFINE_LOG_CATEGORY(LogAkWaapiCalls);
/*-----------------------------------------------------------------------------
AkWaapiCalls.
-----------------------------------------------------------------------------*/
UAkWaapiCalls::UAkWaapiCalls(const class FObjectInitializer& ObjectInitializer)
: Super(ObjectInitializer)
{
#if WITH_EDITOR
// Property initialization
FPropertyEditorModule& PropertyModule = FModuleManager::GetModuleChecked<FPropertyEditorModule>("PropertyEditor");
PropertyModule.RegisterCustomPropertyTypeLayout("AkWaapiUri", FOnGetPropertyTypeCustomizationInstance::CreateStatic(&FAkWaapiUriCustomization::MakeInstance));
PropertyModule.RegisterCustomPropertyTypeLayout("AkWaapiFieldNames", FOnGetPropertyTypeCustomizationInstance::CreateStatic(&FAkWaapiFieldNamesCustomization::MakeInstance));
PropertyModule.NotifyCustomizationModuleChanged();
#endif
}
void UAkWaapiCalls::SetSubscriptionID(const FAkWaapiSubscriptionId& Subscription, int id)
{
Subscription.SubscriptionId = (uint64_t)id;
}
int UAkWaapiCalls::GetSubscriptionID(const FAkWaapiSubscriptionId& Subscription)
{
return Subscription.SubscriptionId;
}
bool UAkWaapiCalls::RegisterWaapiProjectLoadedCallback(const FOnWaapiProjectLoaded& Callback)
{
if (auto waapiClient = FAkWaapiClient::Get())
{
waapiClient->OnProjectLoaded.AddLambda([Callback]() { Callback.ExecuteIfBound(); });
return true;
}
return false;
}
bool UAkWaapiCalls::RegisterWaapiConnectionLostCallback(const FOnWaapiConnectionLost& Callback)
{
if (auto waapiClient = FAkWaapiClient::Get())
{
waapiClient->OnConnectionLost.AddLambda([Callback]()
{
Callback.ExecuteIfBound();
});
return true;
}
return false;
}
FAKWaapiJsonObject UAkWaapiCalls::CallWaapi(const FAkWaapiUri& WaapiUri, const FAKWaapiJsonObject& WaapiArgs, const FAKWaapiJsonObject& WaapiOptions)
{
FAKWaapiJsonObject outJsonResult = FAKWaapiJsonObject();
// Connect to Wwise Authoring on localhost.
if (auto waapiClient = FAkWaapiClient::Get())
{
// Request data from Wwise using WAAPI
if (!waapiClient->Call(TCHAR_TO_ANSI(*WaapiUri.Uri), WaapiArgs.WaapiJsonObj.ToSharedRef(), WaapiOptions.WaapiJsonObj.ToSharedRef(), outJsonResult.WaapiJsonObj))
{
UE_LOG(LogAkWaapiCalls, Log, TEXT("Call Failed"));
}
}
else
{
UE_LOG(LogAkWaapiCalls, Log, TEXT("Unable to connect to localhost"));
}
return outJsonResult;
}
FAKWaapiJsonObject UAkWaapiCalls::SubscribeToWaapi(const FAkWaapiUri& WaapiUri, const FAKWaapiJsonObject& WaapiOptions, const FOnEventCallback& CallBack, FAkWaapiSubscriptionId& SubscriptionId, bool& SubscriptionDone)
{
FAKWaapiJsonObject outJsonResult = FAKWaapiJsonObject();
// Connect to Wwise Authoring on localhost.
if (auto waapiClient = FAkWaapiClient::Get())
{
auto wampEventCallback = WampEventCallback::CreateLambda([CallBack](uint64_t id, TSharedPtr<FJsonObject> in_UEJsonObject)
{
AsyncTask(ENamedThreads::GameThread,[CallBack,id,in_UEJsonObject]
{
FAKWaapiJsonObject outWaapiObj = FAKWaapiJsonObject();
outWaapiObj.WaapiJsonObj = in_UEJsonObject;
CallBack.ExecuteIfBound(id, outWaapiObj);
});
});
// Subscribe to action notifications.
SubscriptionDone = waapiClient->Subscribe(TCHAR_TO_ANSI(*WaapiUri.Uri), WaapiOptions.WaapiJsonObj.ToSharedRef(), wampEventCallback, SubscriptionId.SubscriptionId, outJsonResult.WaapiJsonObj);
}
return outJsonResult;
}
FAKWaapiJsonObject UAkWaapiCalls::Unsubscribe(const FAkWaapiSubscriptionId& SubscriptionId, bool& UnsubscriptionDone)
{
FAKWaapiJsonObject outJsonResult = FAKWaapiJsonObject();
// Connect to Wwise Authoring on localhost.
if (auto waapiClient = FAkWaapiClient::Get())
{
// Subscribe to action notifications.
UnsubscriptionDone = waapiClient->Unsubscribe(SubscriptionId.SubscriptionId, outJsonResult.WaapiJsonObj);
}
return outJsonResult;
}
FString UAkWaapiCalls::Conv_FAkWaapiSubscriptionIdToString(const FAkWaapiSubscriptionId& INAkWaapiSubscriptionId)
{
return FString::Printf(TEXT("%u"), INAkWaapiSubscriptionId.SubscriptionId);
}
FText UAkWaapiCalls::Conv_FAkWaapiSubscriptionIdToText(const FAkWaapiSubscriptionId& INAkWaapiSubscriptionId)
{
return FText::FromString(*Conv_FAkWaapiSubscriptionIdToString(INAkWaapiSubscriptionId));
} | [
"maxmen30@icloud.com"
] | maxmen30@icloud.com |
6bc9f59ac18d325b092e3bbffc08e585aaf6a117 | 2735f3e823e075311c2a0660f01815c6917ba3c4 | /src/kit/Coroutine.cpp | 518cd42d47769daf2e48db4c49d5af360355e9e2 | [
"MIT"
] | permissive | kitschpatrol/Cinder-Kit | 1de27ad6e6089c34b8a7fc1f2122613ac363c497 | 184fbb15d9c9d254f3db2cfc1d3bddfa878249a8 | refs/heads/master | 2020-12-29T01:23:45.793441 | 2017-06-24T19:53:14 | 2017-06-24T19:53:14 | 49,783,017 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,133 | cpp | #include "Coroutine.h"
#include "cinder/Log.h"
#include <thread>
namespace kit {
// This is thrown when the outer thread stop():s the coroutine.
struct AbortException {};
static std::atomic<unsigned> s_cr_counter{0};
// ----------------------------------------------------------------------------
// Trick for allowing forward-declaration of std::thread.
class Coroutine::Thread : public std::thread {
public:
using std::thread::thread;
};
// ----------------------------------------------------------------------------
Coroutine::Coroutine(const char *debug_name_base, std::function<void(InnerControl &ic)> fun) {
_debug_name = std::string(debug_name_base) + " " + std::to_string(s_cr_counter++);
CI_LOG_F(1, "%s: Coroutine starting", _debug_name.c_str());
_mutex.lock();
_inner = std::make_unique<InnerControl>(*this);
_thread = std::make_unique<Thread>([this, fun] {
loguru::set_thread_name(_debug_name.c_str());
ERROR_CONTEXT("Coroutine", _debug_name.c_str());
CI_LOG_F(1, "%s: Coroutine thread starting up", _debug_name.c_str());
_mutex.lock();
CHECK_F(!_control_is_outer);
try {
fun(*_inner);
} catch (AbortException &) {
CI_LOG_F(1, "%s: AbortException caught", _debug_name.c_str());
} catch (std::exception &e) {
LOG_F(ERROR, "%s: Exception caught from Coroutine: %s", _debug_name.c_str(), e.what());
} catch (...) {
LOG_F(ERROR, "%s: Unknown exception caught from Coroutine", _debug_name.c_str());
}
_is_done = true;
_control_is_outer = true;
_mutex.unlock();
_cond.notify_one();
CI_LOG_F(1, "%s: Coroutine thread shutting down", _debug_name.c_str());
});
CHECK_NOTNULL_F(_inner);
}
Coroutine::~Coroutine() {
stop();
CHECK_F(!_thread);
CI_LOG_F(1, "%s: Coroutine destroyed", _debug_name.c_str());
}
void Coroutine::stop() {
if (_thread) {
if (!_is_done) {
LOG_F(1, "Aborting coroutine '%s'...", _debug_name.c_str());
_abort = true;
while (!_is_done) {
_inner->poll(0);
}
}
_thread->join();
CHECK_F(_is_done);
_thread = nullptr;
}
}
// Returns 'true' on done
bool Coroutine::poll(double dt) {
CHECK_NOTNULL_F(_inner);
if (!_is_done) {
_inner->poll(dt);
}
return _is_done;
}
// ----------------------------------------------------------------------------
void InnerControl::wait_sec(double s) {
auto target_time = _time + s;
wait_for([=]() { return target_time <= _time; });
}
void InnerControl::yield() {
CHECK_EQ_F(_cr._control_is_outer.load(), false);
_cr._control_is_outer = true;
_cr._mutex.unlock();
_cr._cond.notify_one();
// Let the outher thread do it's buisness. Wait for it to return to us:
std::unique_lock<std::mutex> lock(_cr._mutex);
_cr._cond.wait(lock, [=] { return !_cr._control_is_outer; });
lock.release();
CHECK_EQ_F(_cr._control_is_outer.load(), false);
if (_cr._abort) {
CI_LOG_F(1, "%s: throwing AbortException", _cr._debug_name.c_str());
throw AbortException();
}
}
// Called from Outer:
void InnerControl::poll(double dt) {
CHECK_EQ_F(_cr._control_is_outer.load(), true);
_cr._control_is_outer = false;
_cr._mutex.unlock();
_cr._cond.notify_one();
// Let the inner thread do it's buisness. Wait for it to return to us:
std::unique_lock<std::mutex> lock(_cr._mutex);
_cr._cond.wait(lock, [=] { return !!_cr._control_is_outer; });
lock.release();
CHECK_EQ_F(_cr._control_is_outer.load(), true);
_time += dt;
}
// ----------------------------------------------------------------------------
void CoroutineSet::clear() {
_list.clear();
}
std::shared_ptr<Coroutine> CoroutineSet::start(const char *debug_name, std::function<void(InnerControl &ic)> fun) {
auto cr_ptr = std::make_shared<Coroutine>(debug_name, std::move(fun));
_list.push_back(cr_ptr);
return cr_ptr;
}
bool CoroutineSet::erase(std::shared_ptr<Coroutine> cr) {
auto it = std::find(begin(_list), end(_list), cr);
if (it != _list.end()) {
_list.erase(it);
return true;
} else {
return false;
}
}
void CoroutineSet::poll(double dt) {
for (auto it = begin(_list); it != end(_list);) {
if ((*it)->poll(dt)) {
it = _list.erase(it);
} else {
++it;
}
}
}
} // namespace kit
| [
"eric@ericmika.com"
] | eric@ericmika.com |
b19a86b23da974f4f42e15f2fe73a66888fad075 | 784801d74668737635093d96c9a7079ac46224e4 | /src/wireframebox.h | 0506714859df07e9a80e37cb693870535ee4f642 | [] | no_license | tom-uchida/SPBR_Brightness-Adjustment-Divide | d1da4a76571c5e5f1da0fbb8ebb10625538533a8 | acac55196a3434bbe62729238bd5e6afa3521ac7 | refs/heads/main | 2023-03-01T09:30:54.416021 | 2021-02-12T12:07:06 | 2021-02-12T12:07:06 | 337,066,923 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,282 | h | //////////////////////////
///// wireframebox.h /////
//////////////////////////
#if !defined SSM__WIREFRAME_H_INCLUDE
#define SSM__WIREFRAME_H_INCLUDE
#include <iostream>
#include <kvs/Type>
#include <kvs/ValueArray>
#include <kvs/PointObject>
#include <kvs/Bounds>
#include <kvs/LineObject>
#include <kvs/glut/Application>
#include <kvs/glut/Screen>
#include <kvs/LineRenderer>
inline kvs::LineObject* WireframeBox ( const kvs::Vector3d& min = kvs::Vector3d( -1.0, -1.0, -1.0),
const kvs::Vector3d& max = kvs::Vector3d( +1.0, +1.0, +1.0) )
{
// coords
kvs::Real32 coords[24] = {
(kvs::Real32)min.x(), (kvs::Real32)min.y(), (kvs::Real32)min.z(), // v0
(kvs::Real32)max.x(), (kvs::Real32)min.y(), (kvs::Real32)min.z(), // v1
(kvs::Real32)max.x(), (kvs::Real32)max.y(), (kvs::Real32)min.z(), // v2
(kvs::Real32)min.x(), (kvs::Real32)max.y(), (kvs::Real32)min.z(), // v3
(kvs::Real32)min.x(), (kvs::Real32)min.y(), (kvs::Real32)max.z(), // v4
(kvs::Real32)max.x(), (kvs::Real32)min.y(), (kvs::Real32)max.z(), // v5
(kvs::Real32)max.x(), (kvs::Real32)max.y(), (kvs::Real32)max.z(), // v6
(kvs::Real32)min.x(), (kvs::Real32)max.y(), (kvs::Real32)max.z() // v7
};
// lines
kvs::UInt32 connects [24] = {
0, 1, // bottom
1, 2,
2, 3,
3, 0,
4, 5, // top
5, 6,
6, 7,
7, 4,
0, 4, // side
1, 5,
2, 6,
3, 7
};
// colors
kvs::UInt8 colors [36] = {
255, 0, 0, // bottom
255, 0, 0,
255, 0, 0,
255, 0, 0,
0, 0, 255, // top
0, 0, 255,
0, 0, 255,
0, 0, 255,
0, 255, 0, // side
0, 255, 0,
0, 255, 0,
0, 255, 0
};
// width
kvs::Real32 width = 1.0 ;
// Create a bounding box as LineObject
//KVS2
kvs::LineObject* wireframe_box = new kvs::LineObject();
wireframe_box->setCoords ( kvs::ValueArray<kvs::Real32>( coords , 24 ) );
wireframe_box->setConnections( kvs::ValueArray<kvs::UInt32>( connects, 24 ) );
wireframe_box->setColors ( kvs::ValueArray<kvs::UInt8> ( colors , 36 ) );
wireframe_box->setSize ( width );
wireframe_box->setLineType ( kvs::LineObject::Segment );
wireframe_box->setColorType ( kvs::LineObject::LineColor );
// update min and max coords
wireframe_box->updateMinMaxCoords();
// end
return wireframe_box ;
}
#endif
| [
"tomomasa.is.0930@gmail.com"
] | tomomasa.is.0930@gmail.com |
48126ef069b35c2aebf16664962d57ac9cc2de89 | 5a63bd6870346aa6593233b990303e743cdb8861 | /SDK/CustomMeshComponent_classes.h | 780cec6a2b6d355ca32102d5a0bc4911179a2c2e | [] | no_license | zH4x-SDK/zBlazingSails-SDK | dc486c4893a8aa14f760bdeff51cea11ff1838b5 | 5e6d42df14ac57fb934ec0dabbca88d495db46dd | refs/heads/main | 2023-07-10T12:34:06.824910 | 2021-08-27T13:42:23 | 2021-08-27T13:42:23 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 936 | h | #pragma once
// Name: BS, Version: 1.536.0
#ifdef _MSC_VER
#pragma pack(push, 0x8)
#endif
namespace SDK
{
//---------------------------------------------------------------------------
// Classes
//---------------------------------------------------------------------------
// Class CustomMeshComponent.CustomMeshComponent
// 0x0010 (0x0590 - 0x0580)
class UCustomMeshComponent : public UMeshComponent
{
public:
unsigned char UnknownData00[0x10]; // 0x0580(0x0010) MISSED OFFSET
static UClass* StaticClass()
{
static auto ptr = UObject::FindClass("Class CustomMeshComponent.CustomMeshComponent");
return ptr;
}
bool SetCustomMeshTriangles(TArray<struct FCustomMeshTriangle> Triangles);
void ClearCustomMeshTriangles();
void AddCustomMeshTriangles(TArray<struct FCustomMeshTriangle> Triangles);
};
}
#ifdef _MSC_VER
#pragma pack(pop)
#endif
| [
"zp2kshield@gmail.com"
] | zp2kshield@gmail.com |
15e99279e3a0af0b467cfd1a4f88b898a605b960 | c0d45cf41e013cadc64148a5eacbcd3624ad6bfc | /main.cpp | b7f46eec4badc13147ddbd675c144cd5703ce614 | [
"MIT"
] | permissive | Ji-Yuhang/CovertUTF8 | 4ef6a62ee57311ba362965adcce81fee138ee13f | 23f554ecab90579899c23cfbafd37c17b6e83c78 | refs/heads/master | 2021-01-18T13:54:05.743805 | 2017-10-14T07:31:57 | 2017-10-14T07:31:57 | 26,514,879 | 3 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 176 | cpp | #include "widget.hxx"
#include <QApplication>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
Widget w;
w.showNormal();
return a.exec();
}
| [
"yuhang.silence@gmail.com"
] | yuhang.silence@gmail.com |
36756cc3be7b921bce525b84b2d272593dee15a5 | 92e67b30497ffd29d3400e88aa553bbd12518fe9 | /assignment2/part6/Re=110/97.7/p | e2a686c46d148904a7d8437e6e1cf2e6daada8cd | [] | no_license | henryrossiter/OpenFOAM | 8b89de8feb4d4c7f9ad4894b2ef550508792ce5c | c54b80dbf0548b34760b4fdc0dc4fb2facfdf657 | refs/heads/master | 2022-11-18T10:05:15.963117 | 2020-06-28T15:24:54 | 2020-06-28T15:24:54 | 241,991,470 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 22,297 | /*--------------------------------*- C++ -*----------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Version: 7
\\/ M anipulation |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class volScalarField;
location "97.7";
object p;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensions [0 2 -2 0 0 0 0];
internalField nonuniform List<scalar>
2000
(
0.00666414
0.00673582
0.00686984
0.00703743
0.00721635
0.00739241
0.00755582
0.00770149
0.00782788
0.00792422
0.00669045
0.00680028
0.00694851
0.00712993
0.00732212
0.0075108
0.00768561
0.00784123
0.00797774
0.00807051
0.00669762
0.00685289
0.00701569
0.00720965
0.00741261
0.00761058
0.00779318
0.00795489
0.00809593
0.008187
0.00668973
0.00689592
0.00707323
0.00727765
0.00748782
0.00769055
0.00787598
0.00803898
0.00818126
0.00826715
0.00667287
0.00693339
0.00712396
0.00733574
0.00754853
0.00775037
0.00793245
0.00809045
0.00822815
0.00830424
0.00665469
0.00696981
0.00717127
0.00738638
0.00759639
0.00779089
0.00796258
0.00810832
0.00823401
0.00829438
0.00664374
0.00701011
0.00721902
0.00743265
0.00763396
0.00781433
0.00796834
0.00809428
0.00819994
0.00823776
0.00664915
0.00705962
0.00727149
0.00747825
0.00766481
0.00782452
0.00795407
0.00805347
0.00813219
0.00814127
0.00668024
0.00712383
0.00733328
0.00752744
0.00769345
0.00782685
0.00792683
0.00799572
0.00804554
0.00802306
0.00674598
0.00720823
0.00740929
0.007585
0.00772507
0.00782756
0.00789479
0.00793291
0.00795959
0.00792014
0.00802533
0.00866449
0.00930474
0.0104487
0.0116815
0.0132054
0.0141788
0.0157762
0.0155454
0.0167894
0.00810844
0.00869967
0.00916902
0.0101453
0.0112371
0.0126405
0.0135367
0.0149992
0.014906
0.0159569
0.00815007
0.00871888
0.00903704
0.00985195
0.01081
0.0121008
0.0129231
0.0142943
0.0142675
0.015189
0.00814511
0.00871062
0.00890546
0.00956895
0.0104005
0.0115859
0.0123426
0.0136399
0.0136378
0.0144945
0.0080921
0.00866386
0.00876887
0.00929551
0.0100091
0.0110963
0.0117943
0.0130259
0.0130423
0.0138734
0.00799404
0.00857103
0.00862013
0.00902967
0.00963577
0.0106308
0.011274
0.0124413
0.0124774
0.0133075
0.00785923
0.00842988
0.0084521
0.00876847
0.00928025
0.0101906
0.0107859
0.0118978
0.011965
0.0128027
0.00769427
0.00823324
0.00825374
0.00850779
0.00894074
0.00976821
0.010314
0.0113611
0.0114606
0.0123346
0.00748792
0.00796885
0.00800382
0.00823337
0.0086252
0.00939022
0.00990369
0.0108981
0.0110381
0.0119322
0.00733216
0.00776303
0.00779447
0.00796502
0.00828868
0.00897039
0.00943709
0.0103473
0.0105564
0.011534
0.0078897
0.00830558
0.00853917
0.00866517
0.0087498
0.00905292
0.00934313
0.00997316
0.0101391
0.010804
0.00627833
0.00667048
0.00702066
0.00733259
0.00761862
0.00799526
0.00832805
0.00884183
0.00897101
0.00936255
0.00510547
0.00546511
0.00579084
0.00606825
0.00632778
0.00668799
0.007026
0.00749631
0.00761376
0.00789809
0.0038888
0.0042476
0.00462247
0.00493632
0.00519417
0.00550776
0.00579982
0.00620325
0.00630061
0.00653064
0.00274146
0.00306595
0.00347069
0.00384392
0.00415222
0.00445795
0.00471343
0.0050462
0.00512057
0.00530942
0.00173825
0.0020178
0.00241408
0.00281608
0.00317023
0.00349635
0.00374915
0.00403555
0.00409184
0.00423397
0.000919344
0.00115234
0.00151744
0.00190833
0.00226493
0.00258927
0.00283626
0.00309211
0.00314321
0.00325595
0.000306756
0.00049153
0.000807146
0.00115976
0.00148504
0.00177796
0.00199954
0.00221981
0.00225539
0.0023315
-1.70349e-05
7.22787e-05
0.000311913
0.000582613
0.000822046
0.0010323
0.00118491
0.00134975
0.00136539
0.00141643
-0.000540376
-0.000267552
-3.69486e-05
0.000147809
0.000281074
0.000386488
0.000445165
0.00052288
0.000496019
0.000491947
0.00739571
0.0060747
0.00494824
0.00377116
0.00267249
0.00170559
0.000917587
0.000306166
1.08819e-05
-0.000509536
0.00713401
0.00587403
0.00475802
0.00361282
0.00255842
0.00163324
0.000883124
0.000299684
2.35356e-05
-0.000431742
0.00687931
0.0056912
0.00458563
0.00347405
0.00245895
0.00157426
0.000859181
0.000306514
4.20554e-05
-0.000340341
0.00668246
0.00556598
0.00446864
0.00338764
0.0024062
0.00155217
0.000863494
0.000333671
7.11862e-05
-0.00025692
0.00654457
0.0054836
0.00439379
0.00333956
0.00238599
0.00155767
0.00088967
0.000376591
0.00010926
-0.000182157
0.00646876
0.00544021
0.00435711
0.00332396
0.00239324
0.00158568
0.000933161
0.000431429
0.000153915
-0.000115258
0.00646292
0.00543382
0.00435695
0.00333878
0.00242573
0.00163365
0.000991356
0.000495482
0.00020318
-5.63033e-05
0.00651271
0.00546172
0.00439011
0.00338078
0.00248037
0.00169868
0.00106157
0.000566284
0.000255358
-5.0515e-06
0.00661004
0.0055206
0.00445257
0.00344629
0.00255369
0.00177766
0.00114106
0.000641595
0.000309026
3.9237e-05
0.00674514
0.0056063
0.00453967
0.00353153
0.00264221
0.00186759
0.0012273
0.000719532
0.000363067
7.75095e-05
0.00690621
0.00571263
0.00464562
0.00363213
0.00274217
0.00196551
0.00131795
0.000798532
0.000416626
0.000110661
0.00708454
0.00583484
0.00476602
0.00374501
0.00285084
0.00206925
0.00141133
0.000877563
0.000469201
0.000139504
0.00727465
0.00597084
0.00489825
0.00386864
0.00296663
0.0021776
0.00150649
0.000956114
0.00052062
0.000164843
0.00747126
0.00611884
0.00503959
0.00400148
0.00308814
0.00228948
0.00160274
0.00103391
0.000570862
0.000187339
0.00766985
0.00627793
0.00518778
0.0041423
0.00321431
0.00240414
0.00169965
0.00111085
0.000620014
0.000207523
0.00786619
0.00644767
0.00534088
0.00428984
0.00334433
0.00252094
0.00179695
0.00118693
0.000668217
0.000225821
0.00805402
0.00662627
0.00549649
0.00444236
0.00347728
0.00263921
0.00189443
0.0012622
0.000715642
0.000242606
0.00822942
0.00681686
0.00565701
0.00460139
0.00361468
0.00275999
0.00199291
0.00133729
0.000762732
0.000258261
0.00840706
0.00704415
0.00583888
0.00477776
0.0037645
0.00288843
0.00209566
0.0014141
0.000810392
0.000272884
0.00852034
0.00726333
0.00601575
0.00494789
0.00391232
0.00301334
0.0021959
0.00148835
0.000856537
0.000285234
0.00807707
0.00729373
0.00618565
0.00516581
0.00415108
0.00323152
0.0023869
0.00163515
0.000952411
0.000316164
0.00804202
0.00724867
0.00617115
0.00521407
0.00423294
0.00334149
0.00250064
0.00173828
0.00102516
0.000344882
0.00822619
0.00740732
0.00631869
0.00537642
0.00439089
0.00349515
0.0026342
0.00184763
0.00110044
0.000377945
0.00862815
0.0076896
0.00654865
0.00558244
0.00457132
0.00365684
0.00276773
0.00195549
0.0011776
0.000416641
0.00923508
0.00811035
0.00688088
0.00584942
0.00479049
0.00383791
0.00291109
0.00206924
0.00126158
0.000461993
0.00998988
0.00865133
0.00730994
0.00617699
0.00505125
0.00404142
0.00306882
0.00219095
0.00135099
0.000508763
0.0108008
0.00925322
0.00779245
0.00653956
0.00533782
0.00425916
0.00323709
0.00231527
0.00143454
0.00054304
0.0115577
0.00982766
0.00825517
0.0068868
0.0056131
0.00446767
0.00339884
0.0024274
0.00149682
0.000554146
0.0121477
0.0102777
0.00861726
0.00715974
0.00583094
0.00463409
0.00352817
0.00251123
0.00153247
0.000546878
0.0124723
0.0105232
0.00881433
0.00730883
0.00595118
0.00472716
0.00360115
0.00255602
0.00154606
0.000535877
0.00890191
0.00886328
0.00910664
0.00958079
0.0102554
0.0110754
0.0119646
0.0128148
0.0134971
0.0138812
0.00901117
0.0090967
0.00942534
0.00997868
0.0107213
0.0115961
0.0125283
0.0134099
0.014113
0.01451
0.00899801
0.00922612
0.00967147
0.0103357
0.0111789
0.0121421
0.013143
0.0140661
0.0147851
0.0151872
0.00902881
0.00936904
0.00991066
0.0106718
0.0116065
0.0126583
0.013739
0.0147229
0.0154787
0.0159005
0.00909802
0.00955561
0.0101883
0.0110371
0.0120526
0.0131834
0.0143394
0.0153882
0.0161913
0.0166419
0.0091777
0.0097641
0.0105003
0.0114425
0.0125414
0.0137493
0.0149755
0.0160846
0.0169329
0.0174114
0.0092665
0.00998342
0.0108351
0.0118788
0.0130691
0.0143596
0.0156568
0.016823
0.0177116
0.0182129
0.00937131
0.0102159
0.0111903
0.0123397
0.0136277
0.0150066
0.016379
0.0176029
0.0185294
0.0190493
0.00949578
0.010464
0.0115674
0.0128237
0.0142134
0.0156849
0.0171365
0.0184206
0.0193857
0.019922
0.00964129
0.0107264
0.011966
0.0133295
0.0148247
0.0163918
0.0179265
0.0192736
0.0202797
0.0208314
0.00980915
0.0109997
0.0123835
0.0138539
0.0154594
0.0171256
0.0187477
0.020161
0.0212111
0.0217779
0.00999777
0.0112795
0.0128156
0.0143916
0.0161131
0.0178826
0.0195981
0.0210818
0.0221802
0.0227624
0.0102
0.011563
0.0132548
0.0149377
0.016781
0.0186597
0.0204753
0.0220361
0.0231874
0.0237864
0.0104016
0.0118511
0.0136893
0.0154869
0.0174557
0.0194521
0.021374
0.0230276
0.0242344
0.0248536
0.010568
0.0121518
0.0141111
0.0160363
0.0181341
0.0202571
0.0222947
0.0240458
0.0253167
0.0259614
0.0107143
0.0124374
0.0145125
0.0165728
0.0188061
0.0210663
0.023231
0.0250867
0.026432
0.0271087
0.0108245
0.0126999
0.0148859
0.0170873
0.0194646
0.021874
0.024179
0.0261508
0.0275806
0.0282969
0.010875
0.012937
0.0152233
0.0175709
0.0200986
0.0226687
0.025128
0.0272315
0.0287589
0.0295253
0.0108425
0.0131406
0.0155211
0.0180256
0.0207169
0.0234627
0.0260894
0.0283364
0.029971
0.0307982
0.0106799
0.0132667
0.0157333
0.0183834
0.0212354
0.0241689
0.0269907
0.0294182
0.0311936
0.0321059
0.011238
0.0145239
0.0172957
0.0202506
0.0233755
0.0265769
0.02966
0.0323383
0.034325
0.0353827
0.0143159
0.0175241
0.0205053
0.0239352
0.0275603
0.0312671
0.0348039
0.0378436
0.0400736
0.0412437
0.0177713
0.0211377
0.0244502
0.0283949
0.0325302
0.0367544
0.0407207
0.0440708
0.046493
0.047766
0.0214698
0.0251918
0.0290271
0.0335586
0.0382372
0.0429864
0.0473408
0.0509335
0.053461
0.0547303
0.0254159
0.0295971
0.0340404
0.0391949
0.0444405
0.0497084
0.0544026
0.0581738
0.0607418
0.0620455
0.029699
0.0343456
0.0394462
0.0452429
0.0510767
0.0568648
0.0618708
0.0657509
0.0681771
0.0691301
0.0338657
0.0390849
0.0448043
0.0511797
0.0575717
0.063831
0.0691152
0.0730572
0.0752245
0.0761047
0.0381331
0.0436786
0.0499977
0.0569801
0.0639766
0.0707571
0.0764591
0.0806344
0.0823389
0.0811268
0.0402598
0.046595
0.0534914
0.0609817
0.0684368
0.0755789
0.0814622
0.085617
0.0861429
0.0876661
0.0436207
0.0500247
0.0573369
0.0652855
0.0734247
0.0812968
0.088483
0.0945496
0.0962688
0.0793207
0.0102471
0.0132512
0.0163755
0.0198003
0.0233045
0.0274258
0.0309309
0.0353505
0.0368317
0.0401228
0.00988032
0.0130382
0.0160964
0.0194813
0.0228421
0.0268355
0.030083
0.0344044
0.0356256
0.0388617
0.00969956
0.0130159
0.0160532
0.0193929
0.0226868
0.0265119
0.0295741
0.0336192
0.0347434
0.0377343
0.0094983
0.0128705
0.0158769
0.0191489
0.0223906
0.0260622
0.0290123
0.0327698
0.0339619
0.0365822
0.00928551
0.012644
0.0156085
0.0188073
0.0219759
0.0254886
0.028395
0.0318547
0.0331908
0.0354334
0.00907683
0.0123929
0.0153233
0.0184581
0.0215512
0.0249174
0.0277672
0.0309783
0.0324207
0.0343519
0.0088705
0.0121279
0.0150371
0.0181216
0.0211522
0.0243973
0.0271729
0.0301917
0.0316824
0.0333723
0.00866698
0.0118516
0.0147487
0.0177944
0.0207761
0.0239266
0.0266298
0.029496
0.031006
0.032505
0.00847085
0.0115714
0.0144627
0.0174795
0.0204226
0.0235003
0.0261421
0.0288819
0.030398
0.0317609
0.00828692
0.0112952
0.014187
0.0171854
0.0200989
0.0231218
0.0257142
0.0283469
0.0298634
0.0311347
0.00811886
0.01103
0.0139292
0.0169199
0.0198143
0.0227974
0.0253523
0.0278945
0.0294088
0.0306167
0.00796355
0.0107772
0.0136922
0.0166857
0.0195736
0.0225313
0.0250617
0.0275286
0.0290393
0.0301997
0.00781271
0.0105365
0.0134759
0.0164833
0.019379
0.0223263
0.024846
0.0272516
0.0287573
0.029883
0.00765844
0.0103105
0.0132803
0.0163136
0.0192317
0.0221843
0.0247072
0.0270648
0.0285618
0.0296669
0.00749114
0.0101009
0.0131042
0.0161766
0.0191318
0.022106
0.0246463
0.026969
0.0284515
0.029558
0.00729876
0.00990626
0.0129437
0.0160702
0.0190776
0.0220903
0.0246625
0.0269636
0.0284172
0.0295596
0.00706938
0.0097212
0.012793
0.0159901
0.0190662
0.0221353
0.0247565
0.0270513
0.0284609
0.029688
0.00679067
0.0095371
0.0126456
0.0159295
0.0190907
0.022233
0.0249208
0.0272245
0.0285514
0.0299476
0.00641665
0.00932237
0.0124898
0.0158845
0.0191545
0.0223931
0.0251702
0.0275052
0.0287324
0.0303675
0.00598983
0.00905455
0.0122887
0.0158017
0.0191923
0.022541
0.0254325
0.0278266
0.0288813
0.030925
0.00689576
0.010097
0.0132269
0.0167842
0.0203451
0.0238261
0.0268501
0.0293537
0.0302386
0.0326684
0.00866672
0.0121447
0.0155565
0.0194753
0.02341
0.0272581
0.0306342
0.0334598
0.0346484
0.0367675
0.0113175
0.0150928
0.0188795
0.0232781
0.0276934
0.0320612
0.0359284
0.0391285
0.0408724
0.0427202
0.014608
0.0187469
0.0229904
0.0279841
0.033054
0.0381705
0.042788
0.0466921
0.0494449
0.0516575
0.0180941
0.0226632
0.0274786
0.0332054
0.0391244
0.0452613
0.0510219
0.056243
0.0606896
0.0646515
0.0217481
0.0267129
0.0322184
0.0387989
0.0457714
0.0532506
0.060726
0.068432
0.0765396
0.085116
0.0245465
0.0300926
0.0363581
0.0438516
0.0521006
0.06137
0.071381
0.0832547
0.0982267
0.11729
0.0278337
0.0338818
0.0409528
0.0494413
0.0591452
0.0706739
0.0843689
0.103316
0.131886
0.172832
0.0284526
0.0345663
0.0418944
0.0509423
0.06214
0.0767461
0.0968003
0.127711
0.179365
0.260427
0.0309128
0.0382298
0.0471154
0.0584347
0.0733818
0.0939295
0.123888
0.172086
0.25715
0.390175
0.00697393
0.008635
0.0108085
0.0135357
0.0162715
0.0195549
0.0217084
0.024841
0.025319
0.0272467
0.00687772
0.00856335
0.01066
0.013261
0.0157938
0.0188939
0.0208062
0.0238311
0.0241841
0.026165
0.00690525
0.00854942
0.0105734
0.0130779
0.0154941
0.0183992
0.0201478
0.0229822
0.0231577
0.0253457
0.00700395
0.00853663
0.0104269
0.0127923
0.0150735
0.0177954
0.0194165
0.0220739
0.022079
0.0242947
0.00713475
0.00852698
0.0102525
0.0124567
0.0145727
0.0171077
0.0185937
0.0211067
0.0209569
0.0230325
0.00728518
0.00852606
0.0100774
0.0121166
0.0140683
0.0164142
0.0177552
0.0201454
0.019856
0.0217412
0.00744682
0.00853546
0.00991024
0.0117663
0.0135853
0.0157429
0.0169488
0.0192279
0.0188212
0.0205513
0.00761063
0.00855555
0.00974957
0.0114206
0.013103
0.0150869
0.0161915
0.0183528
0.0178663
0.0194947
0.00776753
0.0085858
0.00959475
0.0110859
0.0126188
0.0144289
0.0154955
0.0174937
0.0169945
0.0185431
0.00790867
0.00862373
0.00944626
0.0107621
0.0121427
0.0137996
0.0148348
0.0166263
0.0162171
0.0176519
0.00685562
0.00731872
0.00750493
0.00765628
0.00776526
0.00783245
0.00786329
0.00786713
0.00786731
0.00783639
0.00702259
0.00746294
0.00762617
0.00774686
0.00781981
0.00784749
0.00783711
0.00779861
0.00775342
0.00767606
0.00724966
0.00764389
0.00777705
0.00786178
0.00789493
0.00788041
0.00782668
0.00774427
0.00765433
0.00753299
0.00753967
0.00786479
0.00796149
0.00800573
0.00799626
0.00793819
0.00784087
0.0077154
0.00758252
0.00742123
0.00789375
0.00812783
0.00818222
0.00818207
0.00812796
0.0080259
0.00788581
0.00771868
0.00754389
0.00734974
0.00830974
0.00843297
0.00843992
0.00839218
0.00829208
0.00814626
0.00796469
0.00775695
0.00753836
0.00733378
0.00878199
0.0087774
0.00873277
0.00863497
0.00848816
0.00829928
0.00807791
0.00783499
0.00758657
0.00732197
0.0093017
0.0091552
0.00905629
0.00890667
0.008713
0.00848228
0.00822345
0.00794742
0.00766715
0.00736704
0.00985362
0.0095595
0.00940311
0.00920076
0.00896074
0.00868993
0.00839634
0.0080899
0.00778026
0.00745521
0.0104176
0.00997572
0.00976225
0.00950783
0.00922302
0.00891448
0.00858916
0.00825555
0.00792044
0.00757644
0.0109635
0.0103851
0.0101195
0.00981618
0.00948964
0.00914667
0.00879311
0.00843591
0.00807974
0.00772218
0.0114989
0.0107838
0.010466
0.0101157
0.00975033
0.0093765
0.00899859
0.00862179
0.0082493
0.00788362
0.0119973
0.0111526
0.0107863
0.0103933
0.00999387
0.00959395
0.00919633
0.00880438
0.00842053
0.00805237
0.012435
0.0114741
0.0110659
0.0106368
0.0102094
0.00978929
0.00937741
0.00897528
0.00858527
0.00822047
0.0127928
0.011733
0.0112914
0.0108345
0.0103871
0.00995373
0.0095338
0.00912693
0.00873607
0.00838073
0.0130539
0.0119155
0.0114511
0.0109767
0.0105184
0.0100799
0.00965881
0.00925301
0.0088665
0.00852668
0.0132044
0.0120102
0.0115354
0.0110555
0.0105968
0.0101621
0.00974759
0.009349
0.00897151
0.00865212
0.0132341
0.0120087
0.0115373
0.0110653
0.010618
0.0101971
0.00979758
0.00941271
0.00904678
0.00874843
0.013137
0.0119058
0.0114527
0.0110032
0.0105802
0.0101838
0.00980789
0.00944165
0.00908296
0.00879757
0.0129114
0.0117002
0.0112805
0.010869
0.0104843
0.0101247
0.00978255
0.00944105
0.00908763
0.0088059
0.0125588
0.0113932
0.0110219
0.010664
0.0103328
0.0100264
0.00974016
0.00946667
0.00921631
0.0090716
0.0120783
0.0109874
0.0106795
0.0103896
0.0101243
0.00988105
0.00965652
0.0094492
0.00927379
0.00917723
0.0114839
0.0104927
0.0102603
0.0100496
0.00985951
0.00968548
0.00952463
0.00937824
0.00925836
0.00918317
0.0107917
0.00992148
0.00977342
0.00965073
0.00954333
0.00944436
0.0093516
0.00926835
0.00920431
0.00916371
0.0100197
0.00928791
0.00923017
0.00920197
0.0091834
0.00916504
0.00914539
0.00912927
0.00912464
0.0091304
0.00918832
0.00860834
0.008644
0.00871425
0.00878898
0.00885576
0.00891362
0.00896836
0.00902683
0.00908612
0.00831988
0.00790039
0.00802958
0.00819963
0.0083702
0.00852537
0.00866423
0.0087932
0.00891866
0.00903776
0.00743665
0.00718167
0.00740187
0.00767049
0.00793741
0.00818273
0.00840503
0.00861094
0.00880686
0.00899158
0.00656074
0.00646879
0.00677527
0.00713879
0.00750048
0.00783604
0.00814299
0.00842762
0.00869652
0.00895151
0.00572185
0.00578109
0.00616491
0.00661644
0.00706875
0.00749269
0.00788399
0.00824798
0.00859121
0.00891976
0.00496271
0.00514753
0.00559051
0.00611786
0.00665272
0.00716034
0.00763361
0.00807599
0.00849329
0.00889694
0.00424042
0.00455174
0.00504847
0.00564502
0.0062556
0.00684193
0.00739398
0.00791286
0.00840254
0.0088806
0.0035785
0.0040084
0.00455174
0.00520551
0.00588307
0.00654133
0.00716722
0.00775922
0.00831792
0.00886533
0.00299321
0.00352848
0.00410734
0.00480627
0.00553971
0.00626114
0.00695427
0.00761446
0.00823779
0.00884462
0.00249052
0.00311632
0.00371938
0.0044509
0.00522828
0.006003
0.00675552
0.00747723
0.00815869
0.00882694
0.00207256
0.0027733
0.00339008
0.00414156
0.00495047
0.00576775
0.00657095
0.00734709
0.0080791
0.00879577
0.00173924
0.00249902
0.00311995
0.00387921
0.00470711
0.00555576
0.00640042
0.00722368
0.00799822
0.00874917
0.00148817
0.00229137
0.00290792
0.00366361
0.00449821
0.00536696
0.00624395
0.00710813
0.00791936
0.00868901
0.00131507
0.00214685
0.00275166
0.00349345
0.00432296
0.00520072
0.00610129
0.0070026
0.00785238
0.00862862
0.00121459
0.00206105
0.00264782
0.00336653
0.00417977
0.00505543
0.00597005
0.0069041
0.00780797
0.00860755
0.00117913
0.00202798
0.00259151
0.00327911
0.00406563
0.00492886
0.0058514
0.00682937
0.00788968
0.00897411
0.00119312
0.002038
0.00257646
0.00322731
0.00397654
0.00481109
0.00571629
0.00668305
0.00773702
0.00880313
0.00125676
0.00208918
0.00259997
0.00320893
0.00391106
0.00470087
0.00556604
0.00649176
0.00749186
0.00849712
0.0013648
0.00217659
0.00265798
0.00322194
0.00387067
0.00460586
0.00541986
0.00629892
0.00725117
0.00820708
0.00150977
0.00229437
0.00274597
0.00326415
0.00385671
0.0045322
0.00528884
0.0061165
0.00702034
0.00793203
0.00168462
0.00243711
0.00285953
0.00333293
0.00386907
0.00448256
0.00517759
0.00594813
0.00679782
0.00766506
0.00188294
0.00259984
0.00299435
0.00342523
0.00390654
0.00445787
0.00508905
0.00579838
0.00658892
0.00740933
0.00209891
0.00277786
0.00314614
0.00353756
0.00396706
0.00445787
0.0050249
0.00567077
0.00639855
0.00716911
0.00232742
0.0029669
0.00331071
0.00366615
0.00404776
0.00448108
0.00498524
0.00556691
0.0062295
0.00694741
0.00256539
0.00316475
0.00348549
0.00380824
0.00414606
0.00452557
0.00496915
0.00548708
0.00608315
0.00674607
0.00281162
0.00337194
0.00367105
0.003964
0.00426186
0.00459127
0.00497687
0.00543205
0.00596073
0.00656603
0.00305506
0.00357748
0.00385677
0.00412348
0.0043862
0.00467056
0.00500244
0.00539763
0.00585959
0.00640458
0.00329619
0.0037821
0.00404281
0.00428602
0.00451766
0.00476152
0.00504377
0.00538188
0.00577811
0.00625942
0.00353479
0.00398529
0.00422821
0.00445003
0.004654
0.00486153
0.00509816
0.00538225
0.00571404
0.00612807
0.0037703
0.00418603
0.00441157
0.0046136
0.00479283
0.00496785
0.00516278
0.00539604
0.00566492
0.00600773
0.0040027
0.00438375
0.00459207
0.0047755
0.00493241
0.00507839
0.00523545
0.00542121
0.00562883
0.00589564
0.00423246
0.0045784
0.00476955
0.00493531
0.00507199
0.0051921
0.00531512
0.00545718
0.00560584
0.00579077
0.00446023
0.00477026
0.00494438
0.00509348
0.00521198
0.00530933
0.00540221
0.00550502
0.00559811
0.00569283
0.00468646
0.0049597
0.00511738
0.00525144
0.00535455
0.00543322
0.0055008
0.00556896
0.00560837
0.00559432
0.00491101
0.0051469
0.00528946
0.0054112
0.00550382
0.00557217
0.00562743
0.00568012
0.00569934
0.00560275
0.00513347
0.00533183
0.00546106
0.00557387
0.00566216
0.00573223
0.00579994
0.00589592
0.00608122
0.0064016
0.00535449
0.00551438
0.00563182
0.00573864
0.00582618
0.00590022
0.00597574
0.00608045
0.00626823
0.00654939
0.00556966
0.00569286
0.00580059
0.00590415
0.0059934
0.00607185
0.00615116
0.00625221
0.00641081
0.00662218
0.00577509
0.00586543
0.00596591
0.00606897
0.00616262
0.00624758
0.00633207
0.00643189
0.00657114
0.0067402
0.00596873
0.00602867
0.00612597
0.00623132
0.00633198
0.00642573
0.0065172
0.0066175
0.00674261
0.00688369
0.00614479
0.00618249
0.00627842
0.00638903
0.0064991
0.00660363
0.00670378
0.00680636
0.00692157
0.00704351
0.00630015
0.00632398
0.00642163
0.00653986
0.00666144
0.00677855
0.0068892
0.0069966
0.00710689
0.00721649
0.00643215
0.00645129
0.00655368
0.00668177
0.00681649
0.00694766
0.00707052
0.00718534
0.00729535
0.00739757
0.00653866
0.0065633
0.00667313
0.00681285
0.00696192
0.00710806
0.00724432
0.00736865
0.00748221
0.00758047
0.00661719
0.00665875
0.00677887
0.00693163
0.00709579
0.00725703
0.00740711
0.00754212
0.00766182
0.00775836
)
;
boundaryField
{
inlet
{
type zeroGradient;
}
outlet
{
type fixedValue;
value uniform 0;
}
cylinder
{
type zeroGradient;
}
top
{
type symmetryPlane;
}
bottom
{
type symmetryPlane;
}
defaultFaces
{
type empty;
}
}
// ************************************************************************* //
| [
"henry.rossiter@utexas.edu"
] | henry.rossiter@utexas.edu | |
b239912c67de903bbc1578ac6d1232b2a01e14a4 | ab90a6a4f7bb63d2d19eba4644e4910ccafbfcbe | /pub/1051.cpp | a8311169d9484896f111b07f96ec2e788e20ee0e | [
"MIT"
] | permissive | BashuMiddleSchool/Bashu_OnlineJudge_Code | cf35625b5dcb2d53044581f57f1ff50221b33d2a | 4707a271e6658158a1910b0e6e27c75f96841aca | refs/heads/main | 2023-04-22T08:12:41.235203 | 2021-05-02T15:22:25 | 2021-05-02T15:22:25 | 363,435,161 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 263 | cpp | #include<iostream>
using namespace std;
int main()
{
int n,k;
cin>>n>>k;
double s=n,p=200;
int i=1;
while((s<p)&&(i<21)) {
s+=n;
p*=(1+(double)k/100);
i++;
}
if(i>20) cout<<"Impossible"<<endl;
else cout<<i<<endl;
return 0;
} | [
"60656888+ELEVENStudio-Main@users.noreply.github.com"
] | 60656888+ELEVENStudio-Main@users.noreply.github.com |
14e0a68596865f9f9a63f00654a69057ee3549bf | a30d09985c3bbe308db025eb5358f375e9906e69 | /src/ros_cyton_pkg/include/base/cytonGripperHandler.h | c5e4f5460db38cf718f88adeb94176bf9797293f | [] | no_license | shelderzhang/ros_cyton_gamma | d86bb61bb6796aa8c49d61031fe23065d2bbb80d | fbadcc333518ea0522368be9bdb3e36d0c828dbf | refs/heads/master | 2021-01-18T10:21:13.524783 | 2014-09-05T21:04:16 | 2014-09-05T21:04:16 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,847 | h | #ifndef cyton_GripperHandler_H_
#define cyton_GripperHandler_H_
// Copyright (c) 2011 Energid Technologies. All rights reserved. ////
//
// Filename: cytonGripperHandler.h
//
// Description: Cyton-specific control for gripper. Currently supports
// upto 2 grippers.
//
/////////////////////////////////////////////////////////////////////////
#include <foundCore/ecTypes.h>
#include <QtCore/QObject>
namespace cyton
{
class BaseIO;
class GripperHandler : public QObject
{
Q_OBJECT
public:
GripperHandler
(
QObject* parent,
BaseIO* plugin
);
/// Retrieve gripper value
EcReal getGripperValue
(
const EcU32 index = 0
);
/// Aligns gripper values to simulation.
void syncToSimulation
(
);
public Q_SLOTS:
void gripper1Open() { moveGripper(0, -1); } ///< Keymap slot to open gripper 1
void gripper1Close(){ moveGripper(0, 1); } ///< Keymap slot to close gripper 1
void gripper2Open() { moveGripper(1, -1); } ///< Keymap slot to open gripper 2
void gripper2Close(){ moveGripper(1, 1); } ///< Keymap slot to close gripper 2
protected:
EcBoolean moveGripper
(
const EcU32 index,
const EcInt32 direction
);
struct GripperStruct
{
EcU32 linkIndex; ///< Link index tied to gripper
EcU32 eeIndex; ///< EE index tied to gripper
EcReal value; ///< Current gripper value
EcReal minValue; ///< Minimum gripper value
EcReal maxValue; ///< Maximum gripper value
EcReal increment; ///< Step size for gripper movement
};
typedef std::vector<GripperStruct> GripperVector;
GripperVector m_vGrippers; ///< Currently configured grippers
BaseIO* m_pPlugin; ///< Owning plugin for API support
};
} // namespace cyton
#endif // cyton_GripperHandler_H_
| [
"nasa@nasa-intern1.(none)"
] | nasa@nasa-intern1.(none) |
001f301c0d211c8e62cd1190788b3a441b94a30f | 47fd8c098546c51169928099054dd7a3955ce10a | /src/qppcad/ws_atoms_list_render_billboards.cpp | 90c4dd9290a566f3b2d66802f2292fa1968228f4 | [
"MIT"
] | permissive | whtuGitHub/qppcad | d185315ee0b135af1c5cdcda9d8e6bc51440c64d | 1d961af4ad12116be633da5f2d5b374f7e0078c9 | refs/heads/master | 2020-04-08T19:22:35.993408 | 2018-11-29T09:50:17 | 2018-11-29T09:50:17 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,822 | cpp | #include <qppcad/ws_atoms_list_render_billboards.hpp>
#include <qppcad/app_state.hpp>
namespace qpp {
namespace cad {
void ws_atoms_list_render_billboards::render(ws_atoms_list_t &al) {
// std::cout << "fhfg" << std::endl;
app_state_t* astate = app_state_t::get_inst();
astate->zup_quad->begin_render_batch();
astate->bs_sphere_program->begin_shader_program();
astate->bs_sphere_program->set_u(sp_u_name::m_proj, astate->camera->m_mat_proj.data());
//(GL_CULL_FACE);
vector3<float> color(0.0, 0.0, 1.0);
float dr_rad = 0.4f;
auto cached_last_atom_type = -1;
Eigen::Transform<float, 3, Eigen::Affine> t;
matrix4<float> mat_model_view;
astate->default_program->set_u(sp_u_name::f_specular_intensity, &al.m_shading_specular_power);
float draw_specular = al.m_draw_specular;
astate->default_program->set_u(sp_u_name::f_specular_alpha, &draw_specular);
for (uint32_t i = 0; i < al.m_geom->nat(); i++) {
if (cached_last_atom_type != al.m_geom->type(i)) {
auto ap_idx = ptable::number_by_symbol(al.m_geom->atom(i));
if (ap_idx) {
dr_rad = ptable::get_inst()->arecs[*ap_idx - 1].aRadius *
al.m_atom_scale_factor * 2.0f;
color = ptable::get_inst()->arecs[*ap_idx - 1].aColorJmol;
}
astate->bs_sphere_program->set_u(sp_u_name::v_color, color.data());
astate->bs_sphere_program->set_u(sp_u_name::f_scale, &dr_rad);
cached_last_atom_type = al.m_geom->type(i);
}
t = Eigen::Transform<float, 3, Eigen::Affine>::Identity();
// t.prerotate(matrix3<float>::Identity());
// t.prescale(vector3<float>(dr_rad, dr_rad, dr_rad));
t.pretranslate(al.m_geom->pos(i)+al.m_pos);
mat_model_view = astate->camera->m_mat_view * t.matrix();
astate->bs_sphere_program->set_u(sp_u_name::m_model_view, mat_model_view.data());
astate->zup_quad->render_batch();
}
astate->bs_sphere_program->end_shader_program();
astate->zup_quad->end_render_batch();
//glEnable(GL_CULL_FACE);
}
void ws_atoms_list_render_billboards::render_atom (ws_atoms_list_t &al, const uint32_t at_num,
const index &at_index) {
}
void ws_atoms_list_render_billboards::render_bond (ws_atoms_list_t &al,
const uint32_t at_num1,
const index &at_index1,
const uint32_t at_num2,
const index &at_index2) {
}
}
}
| [
"brodiaga38@gmail.com"
] | brodiaga38@gmail.com |
65c21ac1220fb981f41aab0a3a1d389cfde7f475 | a1809f8abdb7d0d5bbf847b076df207400e7b08a | /Simpsons Hit&Run/game/libs/sim/simcommon/simstateflexible.cpp | e0e8565ac5fd1db7824dd184f5f2e6bdd2419050 | [] | no_license | RolphWoggom/shr.tar | 556cca3ff89fff3ff46a77b32a16bebca85acabf | 147796d55e69f490fb001f8cbdb9bf7de9e556ad | refs/heads/master | 2023-07-03T19:15:13.649803 | 2021-08-27T22:24:13 | 2021-08-27T22:24:13 | 400,380,551 | 8 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 10,062 | cpp | /*
#include "simcommon/simstateflexible.hpp"
#include <simcommon/simmath.hpp>
#include "simcommon/dline2.hpp"
#include "simcollision/collisionobject.hpp"
//#include "simflexible/flexibleobject.hpp"
//#include "simflexible/particlesystemsolver.hpp"
//#include "simflexible/particlesystxd.hpp"
#include "p3d/utility.hpp"
using namespace RadicalMathLibrary;
namespace sim
{
SimStateFlexible* SimStateFlexible::CreateSimStateFlexible(tUID inUid, SimStateAttributes inAttrib, tEntityStore* inStore)
{
// a SimStateFlexible without simulated object doesn't make send
if (!(inAttrib & SimStateAttribute_Simulated || inAttrib == SimStateAttribute_Default))
return NULL;
CollisionObject* collObj = NULL;
FlexibleObject * flexObj = NULL;
if (inAttrib & SimStateAttribute_Collision || inAttrib == SimStateAttribute_Default)
{
if (inStore)
collObj = p3d::find<CollisionObject>(inStore, inUid);
else
collObj = p3d::find<CollisionObject>(inUid);
if (!collObj && inAttrib != SimStateAttribute_Default)
{
return NULL;
}
if (collObj && collObj->GetNumJoint() == 0)
{
return NULL;
}
if (collObj && collObj->GetSimState())
{
return NULL; // can't clone
}
}
if (inStore)
flexObj = p3d::find<FlexibleObject>(inStore, inUid);
else
flexObj = p3d::find<FlexibleObject>(inUid);
if (!flexObj)
{
return NULL;
}
if (flexObj->GetSimState())
{
return NULL; // can't clone
}
SimStateFlexible* simState = new SimStateFlexible();
if (simState == NULL )
{
return NULL;
}
else
{
flexObj->SetSimState(simState);
simState->SetSimulatedObject(flexObj);
if (collObj)
{
collObj->SetSimState(simState);
simState->SetCollisionObject(collObj);
collObj->Update();
simState->mSphereRadius = 2.0f * collObj->GetCollisionVolume()->mSphereRadius;
// temporarilly to make sure that simobject and collobject have same physics properties
// this will be fixed when the real loaders will be created
if (collObj)
{
collObj->SetPhysicsProperties(flexObj->GetPhysicsProperties());
}
}
}
return simState;
}
SimStateFlexible* SimStateFlexible::CreateSimStateFlexible(const char* inName, SimStateAttributes inAttrib, tEntityStore* inStore)
{
return CreateSimStateFlexible(tEntity::MakeUID(inName), inAttrib, inStore);
}
SimStateFlexible* SimStateFlexible::CreateManSimStateFlexible(int m, int n, float size, int inType)
{
//eLargeStepSolver, eSemiImplicitSolver1D, eSemiImplicitSolver2D
eParticleSystemSolverType solverType = eLargeStepSolver;
// create the particle system
ParticleSystem *psyst = NULL;
float sphereRadius = 0;
if( m==0 && n==0 )
{
return NULL;
}
else if ( m!=0 && n!=0 )
{
if( inType == 1 )
solverType = eLargeStepSolver;
else if( inType == 2 )
solverType = eSemiImplicitSolver2D;
else if( inType == 3 )
solverType = eKinematicSolver;
else
{
rAssert(0);
solverType = eSemiImplicitSolver2D;
}
psyst = new ParticleSystem2D(m,n,size);
psyst->SetParticleSystemSolver(solverType);
sphereRadius = Sqrt(Sqr(m*size)+Sqr(n*size));
}
else if (m==0)
{
if( inType == 1 )
solverType = eLargeStepSolver;
else if( inType == 2 )
solverType = eSemiImplicitSolver1D;
else if( inType == 3 )
solverType = eKinematicSolver;
else
{
rAssert(0);
solverType = eSemiImplicitSolver1D;
}
psyst = new ParticleSystem1D( n, size);
psyst->SetParticleSystemSolver(solverType);//eSemiImplicitSolver1D, eSemiImplicitSolver2D
sphereRadius = n*size;
}
else
{
if( inType == 1 )
solverType = eLargeStepSolver;
else if( inType == 2 )
solverType = eSemiImplicitSolver1D;
else if( inType == 3 )
solverType = eKinematicSolver;
else
{
rAssert(0);
solverType = eSemiImplicitSolver1D;
}
psyst = new ParticleSystem1D( m, size);
psyst->SetParticleSystemSolver(solverType);//eSemiImplicitSolver1D, eSemiImplicitSolver2D
sphereRadius = m*size;
}
psyst->BuildConditions();
// static tUID MakeUID(const char *s);
// create the flexible object
FlexibleObject* flexObj = new FlexibleObject(PhysicsProperties::DefaultPhysicsProperties(), psyst);
// create the simstate
SimStateFlexible* simState = new SimStateFlexible();
simState->mSphereRadius = 2.0f * sphereRadius;
flexObj->SetSimState(simState);
simState->SetSimulatedObject(flexObj);
// create the collision object and the collision volume
float volumescale = 0.25f;
rmt::Vector zeropos(0, 0, 0);
CollisionVolume * bbox = new BBoxVolume;
for (int i=0; i<flexObj->mPsyst->mNbp; i++)
{
CollisionVolume * sphere = new SphereVolume(zeropos, flexObj->mPsyst->mDeli*volumescale);
sphere->SetObjRefIndex(i);
bbox->AddSubVolume(sphere);
}
char name[128];
sprintf( name, "flexible %s", (solverType == eLargeStepSolver)?"LStep":"SemiI");
CollisionObject* collObj = new CollisionObject(bbox);
collObj->SetName(name);
collObj->SetNumJoint(flexObj->mPsyst->mNbp);
collObj->SetSimState(simState);
simState->SetCollisionObject(collObj);
collObj->Update();
if (flexObj && collObj)
{
collObj->SetPhysicsProperties(flexObj->GetPhysicsProperties());
}
return simState;
}
//
//
//
rmt::Matrix sTmpMatrix;
SimStateFlexible::SimStateFlexible(SimControlEnum inControl)
: SimState(inControl),
mSphereRadius(0)
{
sTmpMatrix.Identity();
}
SimStateFlexible::~SimStateFlexible()
{
}
void SimStateFlexible::SetTransform(const rmt::Matrix& inTransform, float dt)
{
mObjectMoving = !SameMatrix(mTransform, inTransform);
if (mObjectMoving)
{
rAssert (Fabs(mScale - ComputeScaleFromMatrix(inTransform))/mScale < MILLI_EPS);
if (dt != 0)
{
// must set the velocities for collision purposes.
ExtractVelocityFromMatrix(mTransform, inTransform, mScale, dt, mVelocityState);
}
else
{
ResetVelocities();
// object relocation: the safe next step scheme for collision detection doesn't apply anymore
if (mCollisionObject)
{
mCollisionObject->Relocated();
}
((FlexibleObject*) mSimulatedObject)->SynchronizeParticleSystem();
}
}
else
{
ResetVelocities();
}
if (mCollisionObject && (mObjectMoving || ((FlexibleObject*) mSimulatedObject)->IsActivated()))
{
MoveCollisionObject(mTransform, inTransform);
}
mTransform = inTransform;
if (mSimulatedObject)
mApproxSpeedMagnitude = ((FlexibleObject*)mSimulatedObject)->mPsyst->GetMaxSpeed();
}
const rmt::Matrix& SimStateFlexible::GetTransform(int inIndex) const
{
// we don't have a matrix for each particle.
// this method is dangerous to use since the dame temp matrix might be used
// more than once in the same equation... the alternative is to allocate an array of matrix
// with a size = nb of particle.
if (inIndex >= 0)
{
sTmpMatrix.Row(3) = ((FlexibleObject*) mSimulatedObject)->ParticlePosition(inIndex);
return sTmpMatrix;
}
else
return SimState::GetTransform();
}
const rmt::Vector& SimStateFlexible::GetPosition(int inIndex) const
{
if (inIndex >= 0)
{
return ((FlexibleObject*) mSimulatedObject)->ParticlePosition(inIndex);
}
else
return SimState::GetPosition();
}
void SimStateFlexible::GetVelocity(const rmt::Vector& inPosition, rmt::Vector& oVelocity, int inIndex)
{
if (inIndex >= 0)
{
oVelocity = GetFlexibleObject()->ParticleVelocity(inIndex);
}
else
SimState::GetVelocity(inPosition, oVelocity);
}
void SimStateFlexible::SetHasMoved(bool in_hasMoved)
{
SimState::SetHasMoved(in_hasMoved);
if (in_hasMoved && GetCollisionObject())
{
float volSphereRadius = GetCollisionObject()->GetCollisionVolume()->mSphereRadius;
if ( volSphereRadius < mSphereRadius )
{
GetCollisionObject()->GetCollisionVolume()->mSphereRadius = mSphereRadius;
GetCollisionObject()->GetCollisionVolume()->mBoxSize.Set(mSphereRadius, mSphereRadius, mSphereRadius);
}
}
}
void SimStateFlexible::DebugDisplay(int debugIndex)
{
DrawLineToggler toggler;
SimState::DebugDisplay(debugIndex);
if(GetFlexibleObject())
GetFlexibleObject()->DebugDisplay();
tColour colour(0, 255, 0);
static float speedScale = 10.0f;
if ( debugIndex & 1 )
{
for (int i=0; i<mSimulatedObject->GetNumSubObj(); i++)
{
Vector speed = GetFlexibleObject()->ParticleVelocity(i);
speed.ScaleAdd(GetFlexibleObject()->ParticlePosition(i), speedScale, speed);
dStreamLine(GetFlexibleObject()->ParticlePosition(i), speed, colour, colour);
}
}
}
} // sim
*/ | [
"81568815+RolphWoggom@users.noreply.github.com"
] | 81568815+RolphWoggom@users.noreply.github.com |
fc6babfeccc32397cff039388533e3b59caa7d7e | 2c09f1251c3022f19fd19c99a9d48da916361255 | /Features/Rage/Backtrack.cpp | 78422ad35fc673de31c4077110ca37c1a6456a76 | [] | no_license | prvdn/1337.club | 26db060500954a498ccde3f8c682d7cbaa34eda6 | e2259b544b4fc62b8b9fed8d4eef67ef9fa88f56 | refs/heads/main | 2023-08-05T04:37:56.464391 | 2021-09-20T14:51:50 | 2021-09-20T14:51:50 | 407,899,067 | 0 | 0 | null | 2021-09-18T15:35:24 | 2021-09-18T15:35:23 | null | UTF-8 | C++ | false | false | 8,103 | cpp |
#include "../../Hooks/hooks.h"
#include "../Features.h"
bool animation::is_valid(float range = .2f, float max_unlag = .2f)
{
if (!interfaces.engine->GetNetChannelInfo() || !valid)
return false;
const auto correct = std::clamp(interfaces.engine->GetNetChannelInfo()->GetLatency(FLOW_INCOMING)
+ interfaces.engine->GetNetChannelInfo()->GetLatency(FLOW_OUTGOING)
+ g_Ragebot->LerpTime(), 0.f, max_unlag);
float curtime = csgo->local->isAlive() ? TICKS_TO_TIME(csgo->fixed_tickbase) : interfaces.global_vars->curtime;
return fabsf(correct - (curtime - sim_time)) < range && correct < 1.f;
}
animation::animation(IBasePlayer* player)
{
const auto weapon = player->GetWeapon();
safepoints = false;
this->player = player;
index = player->GetIndex();
dormant = player->IsDormant();
velocity = player->GetVelocity();
origin = player->GetOrigin();
abs_origin = player->GetAbsOrigin();
obb_mins = player->GetMins();
obb_maxs = player->GetMaxs();
std::memcpy(layers, player->GetAnimOverlays(), sizeof(CAnimationLayer) * 13);
poses = player->m_flPoseParameter();
anim_state = player->GetPlayerAnimState();
sim_time = player->GetSimulationTime();
interp_time = 0.f;
priority = -1;
came_from_dormant = -1;
last_shot_time = weapon ? weapon->GetLastShotTime() : 0.f;
duck = player->GetDuckAmount();
lby = player->GetLBY();
eye_angles = player->GetEyeAngles();
abs_ang = player->GetAbsAngles();
flags = player->GetFlags();
eflags = player->GetEFlags();
effects = player->GetEffects();
land_time = 0.0f;
is_landed = false;
land_in_cycle = false;
didshot = false;
valid = true;
}
animation::animation(IBasePlayer* player, Vector last_reliable_angle) : animation(player)
{
this->last_reliable_angle = last_reliable_angle;
}
void animation::restore(IBasePlayer* player) const
{
player->GetVelocity() = velocity;
player->GetFlagsPtr() = flags;
player->GetEFlags() = eflags;
player->GetDuckAmount() = duck;
std::memcpy(player->GetAnimOverlays(), layers, sizeof(CAnimationLayer) * 13);
player->GetLBY() = lby;
player->GetOrigin() = origin;
player->SetAbsOrigin(abs_origin);
}
void animation::apply(IBasePlayer* player) const
{
player->SetPoseParameter(poses);
player->GetVelocity() = velocity;
player->GetFlagsPtr() = flags;
player->GetEFlags() = eflags;
player->GetDuckAmount() = duck;
std::memcpy(player->GetAnimOverlays(), layers, sizeof(CAnimationLayer) * 13);
player->GetLBY() = lby;
player->GetOrigin() = origin;
player->SetAbsOrigin(abs_origin);
if (player->GetPlayerAnimState())
player->SetAnimState(anim_state);
}
void CAnimationFix::UpdatePlayers()
{
if (!interfaces.engine->IsInGame())
return;
const auto local = csgo->local;
// erase outdated entries
for (auto it = animation_infos.begin(); it != animation_infos.end();) {
auto player = reinterpret_cast<IBasePlayer*>(interfaces.ent_list->GetClientEntityFromHandle(it->first));
if (!player || player != it->second->player || !player->isAlive()
|| !local)
{
if (player)
player->GetClientSideAnims() = true;
it = animation_infos.erase(it);
}
else
it = next(it);
}
if (!local)
{
for (auto i = 1; i <= interfaces.engine->GetMaxClients(); ++i) {
const auto entity = interfaces.ent_list->GetClientEntity(i);
if (entity && entity->IsPlayer())
entity->GetClientSideAnims() = true;
}
}
for (auto i = 1; i <= interfaces.engine->GetMaxClients(); ++i) {
const auto entity = interfaces.ent_list->GetClientEntity(i);
if (!entity || !entity->IsPlayer())
continue;
if (!entity->isAlive())
continue;
if (entity->IsDormant()) {
csgo->CameFromDormant[entity->EntIndex()] = -1;
continue;
}
if (entity == local)
continue;
if (entity != local && entity->GetTeam() == local->GetTeam()) {
csgo->EnableBones = entity->GetClientSideAnims() = true;
continue;
}
if (animation_infos.find(entity->GetRefEHandle()) == animation_infos.end())
animation_infos.insert_or_assign(entity->GetRefEHandle(), new animation_info(entity, {}));
}
// run post update
for (auto& info : animation_infos)
{
auto& _animation = info.second;
const auto player = _animation->player;
for (auto it = _animation->frames.rbegin(); it != _animation->frames.rend();) {
if (!it->is_valid(0.2f + TICKS_TO_TIME(17)))
it = decltype(it) {
info.second->frames.erase(next(it).base())
};
else
it = next(it);
}
if (g_Resolver->Do(_animation->player)) {
if (auto state = player->GetPlayerAnimState(); state != nullptr)
state->m_abs_yaw = g_Resolver->ResolverInfo[player->EntIndex()].ResolvedAngle;
}
else {
if (auto state = player->GetPlayerAnimState(); state != nullptr)
g_Resolver->ResolverInfo[player->EntIndex()].ResolvedAngle = state->m_abs_yaw;
}
// have we already seen this update?
if (player->GetSimulationTime() != player->CameFromDormantTime()) {
if (player->GetSimulationTime() <= player->GetOldSimulationTime())
continue;
}
// reset animstate
if (_animation->last_spawn_time != player->GetSpawnTime())
{
const auto state = player->GetPlayerAnimState();
if (state)
player->ResetAnimationState(state);
_animation->last_spawn_time = player->GetSpawnTime();
}
// grab previous
animation* previous = nullptr;
if (!_animation->frames.empty() && !_animation->frames.front().dormant
&& TIME_TO_TICKS(player->GetSimulationTime() - _animation->frames.front().sim_time) <= 17)
previous = &_animation->frames.front();
// store server record
auto& record = _animation->frames.emplace_front(player, info.second->last_reliable_angle);
animation* backup = new animation(player);
backup->apply(player);
record.build_inversed_bones(player);
record.build_unresolved_bones(player);
_animation->UpdateAnims(&record, previous);
record.build_server_bones(player);
backup->restore(player);
delete backup;
}
}
CAnimationFix::animation_info* CAnimationFix::get_animation_info(IBasePlayer* player)
{
auto info = animation_infos.find(player->GetRefEHandle());
if (info == animation_infos.end())
return nullptr;
return info->second;
}
bool animation::is_valid_extended()
{
return is_valid();
}
animation* CAnimationFix::get_latest_animation(IBasePlayer* player)
{
const auto info = animation_infos.find(player->GetRefEHandle());
if (info == animation_infos.end() || info->second->frames.empty())
return nullptr;
for (auto it = info->second->frames.begin(); it != info->second->frames.end(); it = next(it)) {
if ((it)->is_valid_extended()) {
return &*it;
}
}
return nullptr;
}
std::vector<animation*> CAnimationFix::get_valid_animations(IBasePlayer* player)
{
const auto info = animation_infos.find(player->GetRefEHandle());
std::vector<animation*> ret = {};
if (info == animation_infos.end() || info->second->frames.empty())
return ret;
Vector last_origin = Vector(0, 0, 0);
for (auto it = info->second->frames.begin(); it != info->second->frames.end(); it = next(it)) {
if ((it)->is_valid_extended()) {
float diff = 0.f;
if (it != info->second->frames.begin() && last_origin != Vector(0, 0, 0)) {
diff = it->origin.DistTo(last_origin);
}
if (diff > 25.f || it->eye_angles.x <= 25.f)
ret.emplace_back(&*it);
last_origin = it->origin;
}
}
return ret;
}
animation* CAnimationFix::get_oldest_animation(IBasePlayer* player)
{
const auto info = animation_infos.find(player->GetRefEHandle());
if (info == animation_infos.end() || info->second->frames.empty())
return nullptr;
for (auto it = info->second->frames.rbegin(); it != info->second->frames.rend(); it = next(it)) {
if ((it)->is_valid_extended()) {
return &*it;
}
}
return nullptr;
}
animation* CAnimationFix::get_latest_firing_animation(IBasePlayer* player)
{
const auto info = animation_infos.find(player->GetRefEHandle());
if (info == animation_infos.end() || info->second->frames.empty())
return nullptr;
for (auto it = info->second->frames.begin(); it != info->second->frames.end(); it = next(it))
if ((it)->is_valid_extended() && (it)->didshot)
return &*it;
return nullptr;
} | [
"rxvan@rxvan.wtf"
] | rxvan@rxvan.wtf |
5ce9c07944bc596b75fbe3964fe2457e0fdf7b3f | c436fc304da315ed7cfa4129faaba14d165a246e | /foundation/src/zxing/core/src/textcodec/Big5TextEncoder.h | d43158494415517fb2065d4fd9c56e71226483b8 | [] | no_license | wjbwstone/wstone | dae656ffff30616d85293bcc356ab7ab7cebd5ba | 25da4de6900e6cc34a96a3882f1307b7a9bbf8b0 | refs/heads/main | 2023-02-17T16:44:50.679974 | 2021-01-20T05:53:24 | 2021-01-20T05:53:24 | 330,961,566 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,759 | h | #pragma once
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtCore module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL21$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see http://www.qt.io/terms-conditions. For further
** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 or version 3 as published by the Free
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
** following information to ensure the GNU Lesser General Public License
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** As a special exception, The Qt Company gives you certain additional
** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#include <string>
class Big5TextEncoder
{
public:
static void EncodeBig5(const std::wstring& str, std::string& bytes);
};
| [
"junbo.wen@enmotech.com"
] | junbo.wen@enmotech.com |
ff738028942048ab01c6888bbc3ae3659fb4be07 | c0c44b30d6a9fd5896fd3dce703c98764c0c447f | /cpp/Targets/MapLib/WindowsMobile/src/DxSurf.cpp | 83a427ab70de8666b03ea49dddabddcb14d73fb4 | [
"BSD-3-Clause"
] | permissive | wayfinder/Wayfinder-CppCore-v2 | 59d703b3a9fdf4a67f9b75fbbf4474933aeda7bf | f1d41905bf7523351bc0a1a6b08d04b06c533bd4 | refs/heads/master | 2020-05-19T15:54:41.035880 | 2010-06-29T11:56:03 | 2010-06-29T11:56:03 | 744,294 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 13,374 | cpp | /*
Copyright (c) 1999 - 2010, Vodafone Group Services Ltd
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 Vodafone Group Services Ltd nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#undef WIN32_NO_OLE
#include "DxDraw.h"
#include <ddraw.h>
#include <memory.h>
#include <memory>
#include "DxSurf.h"
//#define TIMINGS
DxSurf::DxSurf(){
m_can_be_released = true;
m_dd_surf = 0;
m_locked = false;
m_ptr = 0;
m_dc = 0;
m_y_shift = 0;
m_x_shift = 0;
}
//==============================================================================
void DxSurf::setSurf(IDirectDrawSurface *a_dd_surf, bool a_can_be_released){
// assume setting unlocked surface !!
m_dc = 0;
m_ptr = 0;
m_locked = false;
m_dd_surf = a_dd_surf;
m_can_be_released = a_can_be_released;
if (a_dd_surf){
RECT rect;
getSurfaceRect(a_dd_surf, rect);
m_size.cx = rect.right;
m_size.cy = rect.bottom;
}
}
//==============================================================================
bool DxSurf::doBlit( DxSurf& src, int xpos, int ypos, bool keysrc){
ASSERT((!m_locked) && src.m_dd_surf && (!src.m_locked));
if (m_locked || (!src.m_dd_surf) || src.m_locked || (!m_dd_surf)) return false;
// if (!m_enabled) return false;
#ifdef TIMINGS
DWORD starttime = GetTickCount();
#endif
RECT srcRect;
if ( getSurfaceRect(src.m_dd_surf, srcRect) ){
if (m_y_shift) ypos += m_y_shift;
if (m_x_shift) xpos += m_x_shift;
RECT destRect = {xpos, ypos, xpos + srcRect.right, ypos + srcRect.bottom };
// fix destination rect
if ( fixDestSrcRect(destRect, srcRect) ){
// setup flags
DWORD flags = DDBLT_WAITNOTBUSY;
if (keysrc) flags |= DDBLT_KEYSRC;
// Blit!
bool retval = false;
if (m_dd_surf){
retval = m_dd_surf->Blt( &destRect, src.m_dd_surf, &srcRect, flags, 0 ) == DD_OK;
}
#ifdef TIMINGS
DWORD endtime = GetTickCount();
FILE *bltfile = fopen("/blttime.txt", "ab");
if (bltfile){
fprintf(bltfile, "image %dx%d blitted to %dx%d in %d ms (keysrc %d)\n",
srcRect.right, srcRect.bottom,
destRect.right, destRect.bottom,
endtime - starttime,
keysrc);
fclose(bltfile);
}
#endif
return retval;
}
}
return false;
}
//==============================================================================
bool DxSurf::getSurfaceRect(IDirectDrawSurface *a_surface, RECT & a_rect){
// get source sufrace size
if (!a_surface) return false;
DDSURFACEDESC ddsd = { sizeof( DDSURFACEDESC ), 0 };
if (a_surface->GetSurfaceDesc( &ddsd ) != DD_OK ) return false;
a_rect.top = 0;
a_rect.left = 0;
a_rect.right = ddsd.dwWidth;
a_rect.bottom = ddsd.dwHeight;
return true;
}
//==============================================================================
// fix source rect to fit destination by clipping it's parts
bool DxSurf::fixDestSrcRect(RECT & a_destrect, RECT & a_srcrect){
if (!m_dd_surf) return false;
if (a_destrect.top < 0){
a_srcrect.top -= a_destrect.top;
a_destrect.top = 0;
}
if (a_destrect.left < 0){
a_srcrect.left -= a_destrect.left;
a_destrect.left = 0;
}
if (a_destrect.right > m_size.cx){
a_srcrect.right -= a_destrect.right - m_size.cx;
a_destrect.right = m_size.cx;
}
if (a_destrect.bottom > m_size.cy){
a_srcrect.bottom -= a_destrect.bottom - m_size.cy;
a_destrect.bottom = m_size.cy;
}
return true;
}
//==============================================================================
bool DxSurf::doAlphaBlit(DxSurf& src, int xpos, int ypos, int trans){
ASSERT((!m_locked) && src.m_dd_surf && (!src.m_locked));
if (m_locked || (!src.m_dd_surf) || src.m_locked || (!m_dd_surf)) return false;
// if (!m_enabled) return false;
#ifdef TIMINGS
DWORD starttime = GetTickCount();
#endif
RECT srcRect;
if (getSurfaceRect(src.m_dd_surf, srcRect)){
// prepare DDALPHABLTFX structure
DDALPHABLTFX ddfx = {0};
ddfx.dwSize = sizeof( DDALPHABLTFX);
ddfx.ddargbScaleFactors.alpha = trans; // trans from args
ddfx.ddargbScaleFactors.red = 255;
ddfx.ddargbScaleFactors.green = 255;
ddfx.ddargbScaleFactors.blue = 255;
if (m_y_shift) ypos += m_y_shift;
if (m_x_shift) xpos += m_x_shift;
// Calc rects
RECT destRect = { xpos, ypos, xpos + srcRect.right, ypos + srcRect.bottom };
if (fixDestSrcRect(destRect, srcRect)){
bool retval = false;
if (m_dd_surf){
retval = m_dd_surf->AlphaBlt(&destRect, src.m_dd_surf, &srcRect, DDBLT_WAITNOTBUSY, &ddfx) == DD_OK;
}
#ifdef TIMINGS
DWORD endtime = GetTickCount();
FILE *bltfile = fopen("/blttime.txt", "ab");
if (bltfile){
fprintf(bltfile, "image %dx%d alphablitted to %dx%d in %d ms (trans: %d)\n",
srcRect.right, srcRect.bottom,
destRect.right, destRect.bottom,
endtime - starttime, trans);
fclose(bltfile);
}
#endif
return retval;
}
}
return true;
}
//==============================================================================
bool DxSurf::doStretchBlit(DxSurf& src, int xpos, int ypos , int xsize, int ysize, bool keysrc){
ASSERT((!m_locked) && src.m_dd_surf && (!src.m_locked));
if (m_locked || (!src.m_dd_surf) || src.m_locked || (!m_dd_surf)) return false;
// if ( !m_enabled) return false;
#ifdef TIMINGS
DWORD starttime = GetTickCount();
#endif
RECT srcRect;
if (getSurfaceRect(src.m_dd_surf, srcRect)){
if (m_y_shift) ypos += m_y_shift;
if (m_x_shift) xpos += m_x_shift;
RECT destRect = {xpos, ypos, xpos+xsize, ypos+ysize };
// fix destination rect
if (fixDestSrcRect(destRect, srcRect)){
// setup flags
DWORD flags = DDBLT_WAITNOTBUSY;
if (keysrc) flags |= DDBLT_KEYSRC;
// Blit!
bool retval = false;
if (m_dd_surf){
retval = m_dd_surf->Blt( &destRect, src.m_dd_surf, &srcRect, flags, 0 );
}
#ifdef TIMINGS
DWORD endtime = GetTickCount();
FILE *bltfile = fopen("/blttime.txt", "ab");
if (bltfile){
fprintf(bltfile, "image %dx%d stretchblitted to %dx%d in %d ms (keysrc %d)\n",
srcRect.right, srcRect.bottom,
destRect.right, destRect.bottom,
endtime - starttime, keysrc);
fclose(bltfile);
}
#endif
return retval;
}
}
return true;
}
//==============================================================================
void DxSurf::Release(){
ASSERT(m_can_be_released); // if not releaseable - will not be released!!!
if (m_dd_surf && m_can_be_released){
unlock();
m_dd_surf->Release();
m_dd_surf = 0;
}
}
//==============================================================================
void *DxSurf::lock(){
if (! m_dd_surf) return 0;
if (m_locked){
if( m_ptr) return m_ptr;
// if already locked, but not for direct access - fail
return 0;
}
DDSURFACEDESC ddsd = {0};
ddsd.dwSize = sizeof( DDSURFACEDESC );
// Lock primary surface
if ( m_dd_surf->Lock( NULL, &ddsd, DDLOCK_WAITNOTBUSY, NULL ) == DD_OK ){
m_locked = true;
// Get pointer to video memory
// TODO: redo this!
m_ptr = ddsd.lpSurface;
m_pitch = ddsd.lPitch;
return m_ptr;
}
return 0;
}
//==============================================================================
int DxSurf::pitch(){
return m_pitch;
}
//==============================================================================
void DxSurf::unlock(){
if (m_dd_surf && m_locked){
if (m_ptr){
m_dd_surf->Unlock(NULL);
m_ptr = 0;
}else if(m_dc){
m_dd_surf->ReleaseDC(m_dc);
m_dc = 0;
}
m_locked = false;
}
}
//==============================================================================
HDC DxSurf::dc(){
if (! m_dd_surf) return 0;
if (m_locked){
if( m_dc) return m_dc;
// if already locked, but not for gdi access - fail
return 0;
}
DDSURFACEDESC ddsd = {0};
ddsd.dwSize = sizeof( DDSURFACEDESC );
// Lock primary surface
HDC hdc = {0};
if ( m_dd_surf->GetDC(&hdc) == DD_OK ){
m_locked = true;
// Get pointer to video memory
m_dc = hdc;
return m_dc;
}
return 0;
}
//==============================================================================
bool DxSurf::clear(COLORREF color){
ASSERT(!m_locked);
if((!m_locked)
&& m_dd_surf){
DDBLTFX ddbltfx = {0};
ddbltfx.dwSize = sizeof DDBLTFX;
ddbltfx.dwFillColor = fixColor(color);
return m_dd_surf->Blt( 0, 0, 0, DDBLT_COLORFILL | DDBLT_WAITNOTBUSY, &ddbltfx ) == DD_OK;
}
return false;
}
//==============================================================================
bool DxSurf::fill(COLORREF color, int x, int y, int sizex, int sizey){
ASSERT(!m_locked);
if((!m_locked)
&& m_dd_surf){
DDBLTFX ddbltfx = {0};
ddbltfx.dwSize = sizeof DDBLTFX;
ddbltfx.dwFillColor = fixColor(color);
RECT target_rect = {x, y, x + sizex, y + sizey};
return m_dd_surf->Blt( &target_rect, 0, 0, DDBLT_COLORFILL | DDBLT_WAITNOTBUSY, &ddbltfx ) == DD_OK;
}
return false;
}
//==============================================================================
int DxSurf::BlitShiftY(int new_shift){
if (new_shift != INVALID_SHIFT) m_y_shift = new_shift;
return m_y_shift;
}
//==============================================================================
int DxSurf::BlitShiftX(int new_shift){
if (new_shift != INVALID_SHIFT) m_x_shift = new_shift;
return m_x_shift;
}
//==============================================================================
DxSurf::~DxSurf(){
if (m_can_be_released){
Release();
}
}
//==============================================================================
DWORD DxSurf::fixColor(DWORD color){
ASSERT(m_dd_surf); // don't sure this can every happen
if (!m_dd_surf) return 0;
int b = (color & 0xff0000) >> 16,
g = (color & 0xff00) >> 8,
r = (color & 0xff);
DDPIXELFORMAT pf;
ZeroMemory(&pf,sizeof(pf));
pf.dwSize=sizeof(pf);
HRESULT res = m_dd_surf->GetPixelFormat(&pf);
ASSERT(res == DD_OK);
if ( res != DD_OK ) return 0;
return colorToMask(r, pf.dwRBitMask)
| colorToMask(b, pf.dwBBitMask)
| colorToMask(g, pf.dwGBitMask);
}
//==============================================================================
// assume color expressed in 8 bit value
DWORD DxSurf::colorToMask(DWORD color, DWORD mask){
int maskstart = 32;
// 0x80000000 is 10000000000000000000000000000000 in bits
int masktester = 0x80000000;
for (int a = 0; a < 32; ++a){
if (mask & masktester){
maskstart -= a;
break;
}
masktester >>= 1;
}
int shift = (maskstart - 8);
if (shift > 0){
return (color << shift) & mask;
}else{
return (color >> (-shift)) & mask;
}
}
//==============================================================================
// eof
| [
"hlars@sema-ovpn-morpheus.itinerary.com"
] | hlars@sema-ovpn-morpheus.itinerary.com |
4bd3e6d74ce6dad9b40a4ad1ecd4267dc91dd97e | bf4c1d99d8f77da435800f47d8c8ba8a042764a3 | /CheckingAccount.cpp | a227641b45945af9fca6665756dfad743f10fffb | [] | no_license | khalshatti/Bank-Statment-Calculator | 91ea3de79d08fca25886967d6a0c6bff9d877bbb | 03137ecfb2a174b300f7c2acacceb4037d9d17f6 | refs/heads/master | 2020-12-20T22:55:46.247634 | 2020-01-25T21:42:09 | 2020-01-25T21:42:09 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 777 | cpp | #include "Account.h"
#include "CheckingAccount.h"
//Constructor
CheckingAccount::CheckingAccount(double balance,double f):Account(balance)//calling account constructor to initialize finalbalance
{
fee=f;
}
//Redefining debit and credit methods
bool CheckingAccount::debit(double withdraw)
{
bool deducted = Account::debit(withdraw); //calling parent class method
if(deducted == 1)//if amount was less than balance that means it is deducted, only then deducted fee
{
FinalBalance-=fee;
return 1;
}
else
return 0; //else dont do anything
}
double CheckingAccount::credit(double amount)
{
Account::credit(amount-fee);//calling parent class method with deducted fee
return FinalBalance;///add final balance to current balance
}
| [
"noreply@github.com"
] | noreply@github.com |
3ea9a899df4757dcf73d837e88cf0d0938ffbd78 | 92be41ee77c7562b130ef48e1dac30f3e7306e35 | /WomxnDevelopUbisoftDemo/Game/Vfx.h | 8050bf8d019981239bc62d7f24d5d3a25a73e71a | [] | no_license | sysfce2/ubiwmxn-game | c60ba103d19dbfbd02b97ab60f558d2595a1c19c | df13779fdfb461a6e397c30835efa0b481714ae0 | refs/heads/master | 2023-05-07T15:11:19.449465 | 2021-05-02T16:21:38 | 2021-05-02T16:21:38 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,040 | h | #pragma once
class VFX : public sf::Drawable, public Animation
{
static sf::Texture* m_pTextureAtlas;
struct AllAnims {
struct AnimType EmptyFrame;
struct AnimType DemiCircularActivation;
struct AnimType DustJump;
struct AnimType Reborn;
struct AnimType Death;
struct AnimType Fire;
struct AnimType HitPurple;
struct AnimType HitCyan;
struct AnimType DustTrail;
};
public:
enum class AnimName {
EmptyFrame, DemiCircularActivation,
DustJump, Reborn, Death, Fire,
HitPurple, HitCyan, DustTrail
};
VFX();
VFX(const sf::Vector2f position, bool animate_once);
~VFX() {};
// Atlas texture
static const sf::Texture* GetTextureAtlas() { return m_pTextureAtlas; }
static void SetTextureAtlas(sf::Texture* _Tex) { m_pTextureAtlas = _Tex; }
// initialisation data for animation
void InitAnimType();
// set position rot scale , move sprite also
void setSpriteParameters(sf::Vector2f position, float rot, sf::Vector2f scale);
// Update Methods
void Update(float deltaTime, sf::Vector2f position, float rot, sf::Vector2f scale, AnimName vname, bool sidex);
void Update(float deltaTime, AnimName vname, bool sidex);
void Update(float deltaTime); // main: all anim parameters are set keep, playing it
void draw(sf::RenderTarget& target, sf::RenderStates states) const override;
// Animation
void Play(AnimName anim_name, float deltaTime);
void setFrameTexture(AnimName anim_name, float deltaTime);
// Direction
void SetFacingDirection(float speedx);
void setDirection(bool sidex) { a_direction = sidex; }
inline bool isPlaying() const { return a_isPlaying; } // not playing and empty frame
inline bool isDone() const { return a_done_anim; } // done with animation
// current animation
void resetCurrentAnim(AnimName anim_name);
void setCurrentAnim(AnimName anim_name) { a_current_anim = anim_name; }
// anim to_string
inline AnimName getCurrentAnim() const { return a_current_anim; }
inline const std::string getCurrentAnimName() { return m_dictvfxs[a_current_anim].name; }
// Moving VFX
void setPosition(BoxCollideable* element) {
m_Position = element->GetCenter();
m_Sprite.setPosition(m_Position);
}
inline void setPosition(sf::Vector2f newpos) {
m_Position = newpos;
m_Sprite.setPosition(m_Position);
}
sf::Vector2f getPosition() const { return m_Position; }
// Parameters Settings
void setParamVFX(AnimName anim);
void setParamVFX(sf::Vector2f position);
void setParamVFX(AnimName anim, sf::Vector2f position);
void setParamVFX(AnimName anim, sf::Vector2f pos, bool right_oriented);
// true = animated once over the object life time
void setOneTimeAnim(bool onetime) { a_one_time_anim = onetime; }
bool getOneTimeAnim() const { return a_one_time_anim; }
private:
sf::Sprite m_Sprite;
sf::Vector2f m_Size;
sf::Vector2f m_Position;
float m_Rotation;
sf::Vector2f m_Scale;
// animation
AnimName a_current_anim{ AnimName::EmptyFrame };
std::map< VFX::AnimName, AnimType > m_dictvfxs;
AllAnims m_vfxs;
}; | [
"cesaria77550@gmail.com"
] | cesaria77550@gmail.com |
2c487ee043bd5e71f10e6d54cd3d69ef19683144 | dad93009779688c786e2fb5e2c107a9fccbf1fbb | /device/main.cpp | 815dfb910639bb4f7320c064df2ea6a2fad1332c | [] | no_license | jcwrightson/iot-led | 52595f211a4e036fac8a4ad6283f65daa09556c5 | e7ebf8aa749ab21cbe0df07413dbcf251e89d4ad | refs/heads/main | 2023-03-04T13:04:46.492029 | 2021-02-15T22:16:12 | 2021-02-15T22:16:12 | 337,851,095 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,669 | cpp | #include <Arduino.h>
#include <ESP8266WiFi.h>
#include <ESP8266HTTPClient.h>
#include <iostream>
#include "ArduinoJson.h"
#define PIN 12
const char *API_KEY = "xxxxxxx";
const char *URL = "https://xxxxxxxxxx.eu-west-1.amazonaws.com/Prod/latest/morse";
const char *FINGER_PRINT = "SHA1 Finger Print";
const int POLL_INTERVAL = 50000;
const char *SSID = "your-ssid";
const char *WL_PASSWORD = "your-password";
HTTPClient https;
void connect_to_wifi()
{
WiFi.begin(SSID, WL_PASSWORD);
Serial.print("Connecting to wifi");
while (WiFi.status() != WL_CONNECTED)
{
delay(500);
Serial.print(".");
}
Serial.println();
Serial.print("Connected, IP address: ");
Serial.println(WiFi.localIP());
}
void setup()
{
Serial.begin(9600);
connect_to_wifi();
pinMode(PIN, OUTPUT);
digitalWrite(PIN, 0); // When using LED_BUILTIN "HIGH" is off and "LOW" is on?
}
void loop()
{
https.begin(URL, FINGER_PRINT);
https.addHeader("x-api-key", API_KEY);
int code = https.GET();
String response = https.getString();
StaticJsonDocument<1264> doc;
deserializeJson(doc, response);
Serial.println(code);
JsonArray m = doc.as<JsonArray>();
for (JsonVariant i : m)
{
int state = i;
int p = 100;
Serial.print(i.as<int>());
if (i == 2)
{
digitalWrite(PIN, 0);
delay(500);
}
else
{
digitalWrite(PIN, 1);
delay(i == 0 ? p : 300);
digitalWrite(PIN, 0);
delay(p);
}
}
digitalWrite(PIN, 0);
https.end();
delay(POLL_INTERVAL);
} | [
"jcwrightson@gmail.com"
] | jcwrightson@gmail.com |
16ca8c761caeffec3fb15090317b0938d585e77f | 9875a2fa5cdf0e679e430d4ece18090e2af20efe | /gesamt_src/rvapi/rvapi_tab.cpp | dbfbb4de1cbfe45573eaa5c0c4debccc9b070082 | [] | no_license | krab1k/gesamt_distance | 9de0142138fd8e5b1e6e05e47d14b3bc918d44e5 | 94616c394a7e9a2ac5576958c62740444d853e6d | refs/heads/master | 2022-02-03T08:42:54.603456 | 2022-01-21T16:06:12 | 2022-01-21T16:06:12 | 171,859,804 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 1,936 | cpp | //
// =================================================================
//
// 06.03.14 <-- Date of Last Modification.
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// -----------------------------------------------------------------
//
// **** Module : rvapi_tab <implementation>
// ~~~~~~~~~
// **** Project : HTML5-based presentation system
// ~~~~~~~~~
// **** Classes : rvapi::Tab - API Tab class
// ~~~~~~~~~
//
// (C) E. Krissinel 2013-2014
//
// =================================================================
//
#include "rvapi_tab.h"
rvapi::Tab::Tab ( const char *tabId, const char * tabName )
: Node(tabId) {
initTab();
name = tabName;
}
rvapi::Tab::Tab() : Node() {
initTab();
}
rvapi::Tab::~Tab() {
freeTab();
}
void rvapi::Tab::initTab() {
createOpened = true;
}
void rvapi::Tab::freeTab() {}
void rvapi::Tab::write ( std::ofstream & s ) {
swrite ( s,name );
swrite ( s,createOpened );
Node::write ( s );
}
void rvapi::Tab::read ( std::ifstream & s ) {
freeTab();
sread ( s,name );
sread ( s,createOpened );
Node::read ( s );
}
void rvapi::Tab::flush_html ( std::string & outDir,
std::string & task ) {
if (wasCreated()) {
if (beforeId.empty())
task.append ( add_tab_key key_del + nodeId() + key_del + name );
else task.append ( insert_tab_key key_del + beforeId + key_del +
nodeId() + key_del + name );
if (createOpened) task.append ( key_del " true" key_ter );
else task.append ( key_del " false" key_ter );
}
Node::flush_html ( outDir,task );
}
void rvapi::Tab::make_xmli2_content ( std::string & tag,
std::string & content ) {
tag = "tab";
content = "<name>" + name + "</name>\n" +
"<open>" + bool2str(createOpened) + "</open>\n";
}
| [
"tom@krab1k.net"
] | tom@krab1k.net |
aace655eaa34d42ead8f5d573c044acd95847ecd | c270382bd999387b8435146e64109b953f053be9 | /DirectComposition/Sample01_Initialization/framework.h | b65b5fde2888b041b120d36404dffc2c90f5bea1 | [] | no_license | aurora01/Learning | d042df7bcca5980dca27aa7f19ecc026044e62fa | 2baf1c46d9e3f57f603b6df37a1c5d2400de8bc0 | refs/heads/master | 2020-09-30T05:22:30.141994 | 2019-12-11T23:28:44 | 2019-12-11T23:28:44 | 227,214,156 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 603 | h | // header.h : include file for standard system include files,
// or project specific include files
//
#pragma once
#include "targetver.h"
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
// Windows Header Files
#include <windows.h>
// C RunTime Header Files
#include <stdlib.h>
#include <malloc.h>
#include <memory.h>
#include <tchar.h>
#include <math.h>
#include <dcomp.h> // DirectComposition Header Files
#include <d3d11.h> // Direct3D Header Files
#include <wrl.h>
using namespace Microsoft::WRL;
#include "resource.h"
| [
"alexsu@microsoft.com"
] | alexsu@microsoft.com |
8234302ea3e6e1e88a1e6f7501d6b0db026cac01 | 2d6717b239422ed0a5626ef4a8975ea725ab4f58 | /endoneuro-Rpi/src/main.cpp | 94198814622b2810d6059c996efe874a3523dbe3 | [] | no_license | miosee/EndoNeuro-firmwares | 1626347d69a4cdce64f7aca5f4ca3afe41509d7c | aac48b50896de1d295e0aacf30fdce28874ab203 | refs/heads/main | 2023-05-13T17:16:51.174801 | 2021-01-14T07:39:31 | 2021-01-14T07:39:31 | 321,915,550 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,147 | cpp | // Import library
#include "collection/acquisition.h"
#include "collection/acquisitionFiles.h"
#include "collection/transfer.h"
#include "collection/video.h"
#include "collection/lockingQueue.h"
#include "collection/utils.h"
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/mount.h>
#include <syslog.h>
#include <thread>
#include <unistd.h>
//#include "libs/Spi.h"
using namespace std;
LockingQueue acqQueue;
Acquisition acq;
AcquisitionFiles acqFiles;
Transfer transfer;
void acqTask(LockingQueue *queue) {
acq.start(queue);
}
void acqFilesTask(LockingQueue *queue) {
acqFiles.start(queue);
}
void transferTask() {
transfer.start();
}
int main() {
cout << "Main PID : " << getpid() << endl;
setlogmask(LOG_UPTO(LOG_NOTICE));
openlog("Endoneuro", LOG_CONS | LOG_PID | LOG_NDELAY, LOG_LOCAL1);
const char* src = "//10.0.0.2/raspberry3";
const char* trgt = "/home/pi/Documents/DataShare/";
const char* type = "cifs"; // Type of mounted hdd
const unsigned long mntflags = 0;
const char* opts = "user=pi,pass=raspberry,file_mode=0777,dir_mode=0777,noserverino,nounix"; // Params to mount cifs HDD
int result = mount(src, trgt, type, mntflags, opts);
if (result == 0) {
cout << "Mount created at " << trgt << endl;
} else {
cout << "Error : Failed to mount " << src << endl;
cout << "Reason: " << strerror(errno) << " [" << errno << "]\n";
umount(trgt); // Umount HDD
return -1; // Exit app
}
cout << "Starting app.." << endl;
syslog(LOG_NOTICE, "Starting Endoneuro");
// Start thread
thread acqThread(acqTask, &acqQueue);
thread acqFilesThread(acqFilesTask, &acqQueue);
//thread transThread(transferTask);
lockPrintln("Press a key to end the acquisition.");
//char c;
getchar();
acq.shutdown();
acqThread.join(); // join the thread to wait its end before continuing
acqFiles.shutdown();
acqFilesThread.join();
//transfer.shutdown();
//transThread.join();
umount2(trgt, MNT_FORCE); // Umount HDD
return 0;
}
| [
"mosee@ulb.ac.be"
] | mosee@ulb.ac.be |
b1098edb3d2c307f2539d821d075c02274c60ea0 | 4bcc9806152542ab43fc2cf47c499424f200896c | /tensorflow/c/tf_shape.cc | a715544a13f8f4273a7d53e123c676edee323d1e | [
"Apache-2.0",
"LicenseRef-scancode-generic-cla",
"BSD-2-Clause"
] | permissive | tensorflow/tensorflow | 906276dbafcc70a941026aa5dc50425ef71ee282 | a7f3934a67900720af3d3b15389551483bee50b8 | refs/heads/master | 2023-08-25T04:24:41.611870 | 2023-08-25T04:06:24 | 2023-08-25T04:14:08 | 45,717,250 | 208,740 | 109,943 | Apache-2.0 | 2023-09-14T20:55:50 | 2015-11-07T01:19:20 | C++ | UTF-8 | C++ | false | false | 1,226 | cc | /* Copyright 2019 The TensorFlow Authors. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
==============================================================================*/
#include "tensorflow/c/tf_shape.h"
#include <stdint.h>
#include "tensorflow/c/tf_shape_internal.h"
#include "tensorflow/core/framework/tensor_shape.h"
extern "C" {
TF_Shape* TF_NewShape() {
return tensorflow::wrap(new tensorflow::PartialTensorShape());
}
int TF_ShapeDims(const TF_Shape* shape) {
return tensorflow::unwrap(shape)->dims();
}
int64_t TF_ShapeDimSize(const TF_Shape* shape, int d) {
return tensorflow::unwrap(shape)->dim_size(d);
}
void TF_DeleteShape(TF_Shape* shape) { delete tensorflow::unwrap(shape); }
} // end extern "C"
| [
"gardener@tensorflow.org"
] | gardener@tensorflow.org |
0b92a898db95d2d1bd7251e4cec34d7e9cad0b35 | 4796201922a9925a930c1f47f9eaf2a2a4ed0a17 | /particalArray.cpp | f242df55b23634cbbda093bcba892e25765a47e7 | [] | no_license | jeongmoon417/Algorithm | 4b11137c3223564d36414aebf0fc183811ccf4f8 | c0101aba60a8376fc5db6178c82e56b632de0423 | refs/heads/master | 2021-01-19T20:03:30.433824 | 2017-06-12T00:49:58 | 2017-06-12T00:49:58 | 88,479,848 | 0 | 0 | null | null | null | null | UHC | C++ | false | false | 1,619 | cpp | /**************************************************************
* 부분 배열
*
* N개의 자연수로 이루어진 수열과 자연수 S가 주어졌을 때,
* 합이 S보다 같거나 큰 수열의 부분배열(subarray) 중
* 크기를 구하는 문제
*
* (예제 입력)
* 수열 : 5, 1, 3, 5, 10, 7, 4, 9, 2, 8
* S : 15
*
* (출력)
* 2 (10, 7)
*
* ***********************************************************/
#include <cstdio>
#include <iostream>
using namespace std;
int main(int argc, char** argv) {
freopen("sample_input.txt", "r", stdin);
setbuf(stdout, NULL);
int T;
int test_case;
scanf("%d", &T);
/*각 테스트 케이스에 대해서*/
for(test_case = 1; test_case <=T; test_case++) {
int N, S, i;
int max_value=0;
int max_index=0;
int answer=0;
scanf("%d %d", &N, &S);
int *ary = new int[N];
for (i=0; i<N; i++) {
scanf("%d", ary+i);
//최대값과 그 인덱스
if (ary[i] > max_value) {
max_value = ary[i];
max_index = i;
}
}
int start_index, end_index;
for (i=0; i<N; i++) {
//최대값을 포함하는 1 ~ N 개의 배열들
start_index = max(0, max_index - i);
end_index = min(N, max_index + i);
int j, k, w;
k=end_index-i;
for (j=start_index; j<=k; j++) {
int sum=0;
//합 구하기
for (w=0; w<i+1; w++) {
sum += ary[j+w];
}
//합이 S보다 작다면 빠져나간다
if (sum > S) {
answer = i+1;
break;
}
}
if (answer > 0) {
break;
}
}
printf("#testcase%d\n", test_case);
printf("%d\n", answer);
}
return 0;
}
| [
"noreply@github.com"
] | noreply@github.com |
c9e11b6bd10160af98bf0e06785c0dcb8607a3da | e25b7bb3fd43f763f4e5dcb09cdda35b9a3f30a0 | /gpu/command_buffer/client/raster_interface.h | 706e5efea69bc713e2541e45481342921ecf8b64 | [
"BSD-3-Clause"
] | permissive | trustcrypto/chromium | 281ff06e944b1ff7da7a5005e41173ccc78eb2cd | 6e3be4ab657ddd91505753ab67801efcf8541367 | refs/heads/master | 2023-03-08T03:58:49.920358 | 2018-12-26T20:55:44 | 2018-12-26T20:55:44 | 163,217,833 | 1 | 0 | NOASSERTION | 2018-12-26T21:07:41 | 2018-12-26T21:07:40 | null | UTF-8 | C++ | false | false | 2,654 | h | // Copyright (c) 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef GPU_COMMAND_BUFFER_CLIENT_RASTER_INTERFACE_H_
#define GPU_COMMAND_BUFFER_CLIENT_RASTER_INTERFACE_H_
#include <GLES2/gl2.h>
#include "base/compiler_specific.h"
#include "base/containers/span.h"
#include "components/viz/common/resources/resource_format.h"
#include "gpu/command_buffer/common/sync_token.h"
namespace cc {
class DisplayItemList;
class ImageProvider;
struct RasterColorSpace;
} // namespace cc
namespace gfx {
class ColorSpace;
class Rect;
class Size;
class Vector2dF;
enum class BufferUsage;
} // namespace gfx
extern "C" typedef struct _ClientBuffer* ClientBuffer;
extern "C" typedef struct _GLColorSpace* GLColorSpace;
namespace gpu {
namespace raster {
enum RasterTexStorageFlags { kNone = 0, kOverlay = (1 << 0) };
class RasterInterface {
public:
RasterInterface() {}
virtual ~RasterInterface() {}
// OOP-Raster
virtual void BeginRasterCHROMIUM(
GLuint sk_color,
GLuint msaa_sample_count,
GLboolean can_use_lcd_text,
const cc::RasterColorSpace& raster_color_space,
const GLbyte* mailbox) = 0;
virtual void RasterCHROMIUM(const cc::DisplayItemList* list,
cc::ImageProvider* provider,
const gfx::Size& content_size,
const gfx::Rect& full_raster_rect,
const gfx::Rect& playback_rect,
const gfx::Vector2dF& post_translate,
GLfloat post_scale,
bool requires_clear) = 0;
// Schedules a hardware-accelerated image decode and a sync token that's
// released when the image decode is complete. If the decode could not be
// scheduled, an empty sync token is returned.
virtual SyncToken ScheduleImageDecode(
base::span<const uint8_t> encoded_data,
const gfx::Size& output_size,
uint32_t transfer_cache_entry_id,
const gfx::ColorSpace& target_color_space,
bool needs_mips) = 0;
// Raster via GrContext.
virtual void BeginGpuRaster() = 0;
virtual void EndGpuRaster() = 0;
// Include the auto-generated part of this class. We split this because
// it means we can easily edit the non-auto generated parts right here in
// this file instead of having to edit some template or the code generator.
#include "gpu/command_buffer/client/raster_interface_autogen.h"
};
} // namespace raster
} // namespace gpu
#endif // GPU_COMMAND_BUFFER_CLIENT_RASTER_INTERFACE_H_
| [
"commit-bot@chromium.org"
] | commit-bot@chromium.org |
f1f22dd62252989f290bff50bc1554ac1a6cd89f | 5f90ef28a8f2bba24289481e3c53d6b107799cd3 | /src/sound.cpp | 11497d17066dfbd8dd5df6ae9d305c1b6e41fdc8 | [] | no_license | CyborgSummoners/Summoner-Wars | 18d4c09d21631ebfcdae9e1d470ce6e4d2132930 | e61a96284c3e7faf0ca24d89ea5d9d019e57dd8c | refs/heads/master | 2020-05-30T16:57:05.071888 | 2013-02-01T11:13:16 | 2013-02-01T11:13:16 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 997 | cpp | #include "sound.hpp"
#include <string>
namespace sum
{
void startthread(std::string fname) {
sf::Thread Thread1(&(Sound::PlaySound),&fname);
Thread1.Launch();
}
void Sound::update(const ServerMessage &message)
{
std::string fname;
std::cout << "ohai from sound" << std::endl;
switch(message.type)
{
case ServerMessage::death:
startthread("resources/asta_la_vista.wav");
break;
case ServerMessage::move:
startthread("resources/step.wav");
break;
default:
break;
}
}
void Sound::PlaySound(void* data)
{
std::string* filename = static_cast<std::string*>(data);
sf::SoundBuffer Buffer;
if (!Buffer.LoadFromFile(*filename))
return;
sf::Sound Sound(Buffer);
Sound.Play();
while (Sound.GetStatus() == sf::Sound::Playing)
{
}
}
} | [
"bence@bence-ThinkPad-R61e.(none)"
] | bence@bence-ThinkPad-R61e.(none) |
5f506299d268035d2f9b845d409ac09fe869b5e6 | 0f80c089749acf4fcb5fc77440b1973d9e2b1749 | /Development/Plugin/Warcraft3/yd_lua_engine/lua_engine/class_array.h | c60e9497eaf20447e59ba96af59bd1eff70bee35 | [
"Apache-2.0"
] | permissive | Whimsyduke/YDWE | 12582e5865fed973c5b3edd0aa7608ac46aec725 | f74d79a8de5fa683012944b13b5f444bcbbc7b77 | refs/heads/master | 2020-03-22T11:33:53.460497 | 2018-07-12T14:07:04 | 2018-07-12T14:07:04 | 139,979,771 | 0 | 0 | Apache-2.0 | 2018-07-06T12:06:09 | 2018-07-06T12:06:09 | null | UTF-8 | C++ | false | false | 221 | h | #pragma once
#include <lua.hpp>
#include <base/warcraft3/jass.h>
namespace base { namespace warcraft3 { namespace lua_engine {
void jarray_make_mt(lua_State* L);
int jarray_create(lua_State* L, uintptr_t value);
}}}
| [
"actboy168@gmail.com"
] | actboy168@gmail.com |
1c751b9bbbb1438029c74ccb43f2a8119cbf0741 | fcca4e9e7591ec8edca5b81bfa7f32a647cb5a61 | /Project1/Project1/syntax.h | db5a6a500205629292f4564d3573f5fba303e9f7 | [] | no_license | Melina-Zh/project_compiler | 0dabeb7b33b62735325286168890f4544f6415d7 | e253607f6ffcd8042914161ad1eb0e8ae542bad5 | refs/heads/master | 2020-04-13T19:22:56.081232 | 2018-12-28T15:54:00 | 2018-12-28T15:54:00 | 163,400,899 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 430 | h | #pragma once
#include<iostream>
#include<fstream>
#include<map>
#include<vector>
using namespace std;
class TableEntry;
class FuncTableEntry;
class VarTableEntry;
class ConstTableEntry;
void syn_main();
FuncTableEntry* get_func(string name);
VarTableEntry* search_global_var(string name);
extern map<string, VarTableEntry*> vartable;
extern map<string, FuncTableEntry*> functable;
extern map<string, ConstTableEntry*> consttable; | [
"zhynzm_85@126.com"
] | zhynzm_85@126.com |
0fc674f1d76a381c7ac32fd1e4aeb02246f3f7a1 | c04d4dc09e6d1b0862fb2b3d7f9de7ec19633a1f | /Source/Plot/Basic/PlotDataSpanImpl.cpp | 351aa8c07f4c8c66148a3b9ae1a731f9ae4d41f9 | [
"MIT"
] | permissive | Ben20013/CChart | 6d4e7eb46ea37e870b27e702b0bde68acf8661da | 436b97ca803d6c911d954437b1674b2537577654 | refs/heads/master | 2023-07-11T16:31:06.821801 | 2020-10-08T13:16:09 | 2020-10-08T13:16:09 | null | 0 | 0 | null | null | null | null | GB18030 | C++ | false | false | 1,529 | cpp | /*============================================================================*/
/* */
/* C O P Y R I G H T */
/* */
/* (C) Copyright 2019 by */
/* Yang Guojun */
/* All Rights Reserved */
/* */
/* The author assumes no responsibility for the use or reliability of */
/* his software. */
/* */
/*============================================================================*/
////////////////////////////////////////////////////////////////////////////////
// 版权申明 //
// 版权所有(C)2006-2019,杨国君 //
// 保留全部权利 //
////////////////////////////////////////////////////////////////////////////////
/* ############################################################################################################################## */
| [
"baita00@hotmail.com"
] | baita00@hotmail.com |
30ad638fe0c4bd4edcb8fa87456be2fff9a2d886 | 6b40e9dccf2edc767c44df3acd9b626fcd586b4d | /NT/base/fs/hsm/rms/server/rmsclien.h | a17f10ceed3a727c88fdb5175a436bd624df032f | [] | no_license | jjzhang166/WinNT5_src_20201004 | 712894fcf94fb82c49e5cd09d719da00740e0436 | b2db264153b80fbb91ef5fc9f57b387e223dbfc2 | refs/heads/Win2K3 | 2023-08-12T01:31:59.670176 | 2021-10-14T15:14:37 | 2021-10-14T15:14:37 | 586,134,273 | 1 | 0 | null | 2023-01-07T03:47:45 | 2023-01-07T03:47:44 | null | WINDOWS-1252 | C++ | false | false | 3,894 | h | /*++
© 1998 Seagate Software, Inc. All rights reserved
Module Name:
RmsClien.h
Abstract:
Declaration of the CRmsClient class
Author:
Brian Dodd [brian] 15-Nov-1996
Revision History:
--*/
#ifndef _RMSCLIEN_
#define _RMSCLIEN_
#include "resource.h" // resource symbols
#include "RmsObjct.h" // CRmsComObject
/*++
Class Name:
CRmsClient
Class Description:
A CRmsClient represents information about a registerered
Rms client application.
--*/
class CRmsClient :
public CComDualImpl<IRmsClient, &IID_IRmsClient, &LIBID_RMSLib>,
public CRmsComObject,
public CWsbObject, // inherits CComObjectRoot
public CComCoClass<CRmsClient,&CLSID_CRmsClient>
{
public:
CRmsClient() {}
BEGIN_COM_MAP(CRmsClient)
COM_INTERFACE_ENTRY2(IDispatch, IRmsClient)
COM_INTERFACE_ENTRY(IRmsClient)
COM_INTERFACE_ENTRY(IRmsComObject)
COM_INTERFACE_ENTRY(ISupportErrorInfo)
COM_INTERFACE_ENTRY2(IPersist, IPersistStream)
COM_INTERFACE_ENTRY(IPersistStream)
COM_INTERFACE_ENTRY(IWsbCollectable)
COM_INTERFACE_ENTRY(IWsbPersistStream)
COM_INTERFACE_ENTRY(IWsbTestable)
END_COM_MAP()
DECLARE_REGISTRY_RESOURCEID(IDR_RmsClient)
// CComObjectRoot
public:
STDMETHOD(FinalConstruct)(void);
// IPersist
public:
STDMETHOD(GetClassID)(CLSID *pClsid);
// IPersistStream
public:
STDMETHOD(GetSizeMax)(ULARGE_INTEGER* pSize);
STDMETHOD(Load)(IStream* pStream);
STDMETHOD(Save)(IStream* pStream, BOOL clearDirty);
// IWsbCollectable
public:
STDMETHOD(CompareTo)(IUnknown* pCollectable, SHORT* pResult);
WSB_FROM_CWSBOBJECT;
// IWsbTestable
public:
STDMETHOD(Test)(USHORT *pPassed, USHORT *pFailed);
// IRmsClient
public:
STDMETHOD(GetOwnerClassId)(CLSID *pClassId);
STDMETHOD(SetOwnerClassId)(CLSID classId);
STDMETHOD( GetName )( BSTR *pName );
STDMETHOD( SetName )( BSTR name );
STDMETHOD( GetPassword )( BSTR *pName );
STDMETHOD( SetPassword )( BSTR name );
STDMETHOD(GetInfo)(UCHAR *pInfo, SHORT *pSize);
STDMETHOD(SetInfo)(UCHAR *pInfo, SHORT size);
STDMETHOD(GetVerifierClass)(CLSID *pClassId);
STDMETHOD(SetVerifierClass)(CLSID classId);
STDMETHOD(GetPortalClass)(CLSID *pClassId);
STDMETHOD(SetPortalClass)(CLSID classId);
private:
enum { // Class specific constants:
//
Version = 1, // Class version, this should be
// incremented each time the
// the class definition changes.
MaxInfo = 128, // Size of the application specific
// infomation buffer. Currently
// fixed in size.
}; //
CLSID m_ownerClassId; // The Class ID for the client application.
CWsbBstrPtr m_password; // Client password.
SHORT m_sizeofInfo; // The size of valid data in the application
// specific information buffer.
UCHAR m_info[MaxInfo]; // Application specific information.
CLSID m_verifierClass; // The interface to the on-media
// ID verification function.
CLSID m_portalClass; // The interface to a site specific import
// and export storage location
// specification dialog.
};
#endif // _RMSCLIEN_
| [
"seta7D5@protonmail.com"
] | seta7D5@protonmail.com |
36ebfe46f1819f6faccb49fe7340f9caac48cfb9 | 69bd91a3934e4c1dfbe285a12981522197aa0c92 | /hdu/1089.cpp | d4c740c31c467bf20e988771951531c93ac2978e | [] | no_license | rosekc/acm | 447204a2d681f8af71f3ece11cc28390e23f0914 | 96da51d35f7623cce69a4aee7f95c920b505fe04 | refs/heads/master | 2020-05-27T15:34:54.320308 | 2018-08-10T12:28:52 | 2018-08-10T12:28:52 | 82,563,274 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 142 | cpp | #include <iostream>
using namespace std;
int main()
{
int a, b;
while( cin >> a >> b )
{
cout << a + b << endl;
}
}
| [
"rose-kc@hotmail.com"
] | rose-kc@hotmail.com |
c796bc172bcbbae7f32e410f00ac5b8d6671ea56 | 60db84d8cb6a58bdb3fb8df8db954d9d66024137 | /android-cpp-sdk/platforms/android-4/java/security/InvalidAlgorithmParameterException.hpp | ffdb6c95e4be984a2432b25673812b47d7a518d4 | [
"BSL-1.0"
] | permissive | tpurtell/android-cpp-sdk | ba853335b3a5bd7e2b5c56dcb5a5be848da6550c | 8313bb88332c5476645d5850fe5fdee8998c2415 | refs/heads/master | 2021-01-10T20:46:37.322718 | 2012-07-17T22:06:16 | 2012-07-17T22:06:16 | 37,555,992 | 5 | 4 | null | null | null | null | UTF-8 | C++ | false | false | 6,178 | hpp | /*================================================================================
code generated by: java2cpp
author: Zoran Angelov, mailto://baldzar@gmail.com
class: java.security.InvalidAlgorithmParameterException
================================================================================*/
#ifndef J2CPP_INCLUDE_IMPLEMENTATION
#ifndef J2CPP_JAVA_SECURITY_INVALIDALGORITHMPARAMETEREXCEPTION_HPP_DECL
#define J2CPP_JAVA_SECURITY_INVALIDALGORITHMPARAMETEREXCEPTION_HPP_DECL
namespace j2cpp { namespace java { namespace io { class Serializable; } } }
namespace j2cpp { namespace java { namespace security { class GeneralSecurityException; } } }
namespace j2cpp { namespace java { namespace lang { class String; } } }
namespace j2cpp { namespace java { namespace lang { class Throwable; } } }
namespace j2cpp { namespace java { namespace lang { class Exception; } } }
namespace j2cpp { namespace java { namespace lang { class Object; } } }
#include <java/io/Serializable.hpp>
#include <java/lang/Exception.hpp>
#include <java/lang/Object.hpp>
#include <java/lang/String.hpp>
#include <java/lang/Throwable.hpp>
#include <java/security/GeneralSecurityException.hpp>
namespace j2cpp {
namespace java { namespace security {
class InvalidAlgorithmParameterException;
class InvalidAlgorithmParameterException
: public object<InvalidAlgorithmParameterException>
{
public:
J2CPP_DECLARE_CLASS
J2CPP_DECLARE_METHOD(0)
J2CPP_DECLARE_METHOD(1)
J2CPP_DECLARE_METHOD(2)
J2CPP_DECLARE_METHOD(3)
explicit InvalidAlgorithmParameterException(jobject jobj)
: object<InvalidAlgorithmParameterException>(jobj)
{
}
operator local_ref<java::io::Serializable>() const;
operator local_ref<java::security::GeneralSecurityException>() const;
operator local_ref<java::lang::Throwable>() const;
operator local_ref<java::lang::Exception>() const;
operator local_ref<java::lang::Object>() const;
InvalidAlgorithmParameterException(local_ref< java::lang::String > const&);
InvalidAlgorithmParameterException();
InvalidAlgorithmParameterException(local_ref< java::lang::String > const&, local_ref< java::lang::Throwable > const&);
InvalidAlgorithmParameterException(local_ref< java::lang::Throwable > const&);
}; //class InvalidAlgorithmParameterException
} //namespace security
} //namespace java
} //namespace j2cpp
#endif //J2CPP_JAVA_SECURITY_INVALIDALGORITHMPARAMETEREXCEPTION_HPP_DECL
#else //J2CPP_INCLUDE_IMPLEMENTATION
#ifndef J2CPP_JAVA_SECURITY_INVALIDALGORITHMPARAMETEREXCEPTION_HPP_IMPL
#define J2CPP_JAVA_SECURITY_INVALIDALGORITHMPARAMETEREXCEPTION_HPP_IMPL
namespace j2cpp {
java::security::InvalidAlgorithmParameterException::operator local_ref<java::io::Serializable>() const
{
return local_ref<java::io::Serializable>(get_jobject());
}
java::security::InvalidAlgorithmParameterException::operator local_ref<java::security::GeneralSecurityException>() const
{
return local_ref<java::security::GeneralSecurityException>(get_jobject());
}
java::security::InvalidAlgorithmParameterException::operator local_ref<java::lang::Throwable>() const
{
return local_ref<java::lang::Throwable>(get_jobject());
}
java::security::InvalidAlgorithmParameterException::operator local_ref<java::lang::Exception>() const
{
return local_ref<java::lang::Exception>(get_jobject());
}
java::security::InvalidAlgorithmParameterException::operator local_ref<java::lang::Object>() const
{
return local_ref<java::lang::Object>(get_jobject());
}
java::security::InvalidAlgorithmParameterException::InvalidAlgorithmParameterException(local_ref< java::lang::String > const &a0)
: object<java::security::InvalidAlgorithmParameterException>(
call_new_object<
java::security::InvalidAlgorithmParameterException::J2CPP_CLASS_NAME,
java::security::InvalidAlgorithmParameterException::J2CPP_METHOD_NAME(0),
java::security::InvalidAlgorithmParameterException::J2CPP_METHOD_SIGNATURE(0)
>(a0)
)
{
}
java::security::InvalidAlgorithmParameterException::InvalidAlgorithmParameterException()
: object<java::security::InvalidAlgorithmParameterException>(
call_new_object<
java::security::InvalidAlgorithmParameterException::J2CPP_CLASS_NAME,
java::security::InvalidAlgorithmParameterException::J2CPP_METHOD_NAME(1),
java::security::InvalidAlgorithmParameterException::J2CPP_METHOD_SIGNATURE(1)
>()
)
{
}
java::security::InvalidAlgorithmParameterException::InvalidAlgorithmParameterException(local_ref< java::lang::String > const &a0, local_ref< java::lang::Throwable > const &a1)
: object<java::security::InvalidAlgorithmParameterException>(
call_new_object<
java::security::InvalidAlgorithmParameterException::J2CPP_CLASS_NAME,
java::security::InvalidAlgorithmParameterException::J2CPP_METHOD_NAME(2),
java::security::InvalidAlgorithmParameterException::J2CPP_METHOD_SIGNATURE(2)
>(a0, a1)
)
{
}
java::security::InvalidAlgorithmParameterException::InvalidAlgorithmParameterException(local_ref< java::lang::Throwable > const &a0)
: object<java::security::InvalidAlgorithmParameterException>(
call_new_object<
java::security::InvalidAlgorithmParameterException::J2CPP_CLASS_NAME,
java::security::InvalidAlgorithmParameterException::J2CPP_METHOD_NAME(3),
java::security::InvalidAlgorithmParameterException::J2CPP_METHOD_SIGNATURE(3)
>(a0)
)
{
}
J2CPP_DEFINE_CLASS(java::security::InvalidAlgorithmParameterException,"java/security/InvalidAlgorithmParameterException")
J2CPP_DEFINE_METHOD(java::security::InvalidAlgorithmParameterException,0,"<init>","(Ljava/lang/String;)V")
J2CPP_DEFINE_METHOD(java::security::InvalidAlgorithmParameterException,1,"<init>","()V")
J2CPP_DEFINE_METHOD(java::security::InvalidAlgorithmParameterException,2,"<init>","(Ljava/lang/String;Ljava/lang/Throwable;)V")
J2CPP_DEFINE_METHOD(java::security::InvalidAlgorithmParameterException,3,"<init>","(Ljava/lang/Throwable;)V")
} //namespace j2cpp
#endif //J2CPP_JAVA_SECURITY_INVALIDALGORITHMPARAMETEREXCEPTION_HPP_IMPL
#endif //J2CPP_INCLUDE_IMPLEMENTATION
| [
"baldzar@gmail.com"
] | baldzar@gmail.com |
aed8ebc65ecbfee18cd08e634b3e4730ba3480bf | 2d6a5c8a8c314a913c7d6770b363affa164c023b | /ufora/core/serialization/IFileDescriptorProtocol.hpp | c36dc32c06d10ba67a7e1d36367e2e6672b39cc7 | [
"dtoa",
"MIT",
"BSD-3-Clause",
"BSL-1.0",
"Apache-2.0",
"LicenseRef-scancode-public-domain",
"CC0-1.0"
] | permissive | AntHar/ufora | 36a314c1f9482dcbc9d1f18f4d12fea756d111fb | 3c2d558d3df0dca5524e6df52b923866825563e7 | refs/heads/master | 2021-01-17T13:02:13.050845 | 2016-01-04T19:26:25 | 2016-01-04T19:26:25 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,600 | hpp | /***************************************************************************
Copyright 2015 Ufora Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
****************************************************************************/
#pragma once
#include <vector>
#include <deque>
#include "../Common.hppml"
#include "../Clock.hpp"
#include "../Logging.hpp"
#include "IProtocol.hpp"
#include <stdio.h>
/******************
A Protocol object that writes directly to a file descriptor.
If 'alignment' is nonzero, writes are aligned to 'alignment' byte boundaries
and the file is padded with zeros. this allows us to write using O_DIRECT.
******************/
class IFileDescriptorProtocol : public IProtocol {
IFileDescriptorProtocol(const IFileDescriptorProtocol& in);
IFileDescriptorProtocol& operator=(const IFileDescriptorProtocol& in);
public:
enum class CloseOnDestroy { True, False };
IFileDescriptorProtocol(
int fd,
size_t alignment,
size_t bufsize,
CloseOnDestroy closeOnDestroy = CloseOnDestroy::False
) :
mFD(fd),
mPosition(0),
mCloseOnDestroy(closeOnDestroy),
mAlignment(alignment),
mBufferSize(bufsize),
mBufferBytesUsed(0),
mBufferBytesConsumed(0),
mBufPtr(0)
{
lassert(mBufferSize % mAlignment == 0);
mBufferHolder.resize(mAlignment * 2 + mBufferSize);
uword_t bufptr = (uword_t)&mBufferHolder[0];
//make sure that the buffer is aligned to the alignment as well
if (bufptr % mAlignment)
bufptr += mAlignment - bufptr % mAlignment;
mBufPtr = (char*)bufptr;
}
~IFileDescriptorProtocol()
{
if (mCloseOnDestroy == CloseOnDestroy::True)
close(mFD);
}
uword_t position(void)
{
return mPosition;
}
uword_t read(uword_t inByteCount, void *inData, bool inBlock)
{
if (inByteCount == 0)
return 0;
char* dataTarget = (char*)inData;
uword_t bytesRead = 0;
while (inByteCount > 0)
{
if (mBufferBytesConsumed + inByteCount < mBufferBytesUsed)
{
memcpy(dataTarget, mBufPtr + mBufferBytesConsumed, inByteCount);
mBufferBytesConsumed += inByteCount;
mPosition += inByteCount;
bytesRead += inByteCount;
inByteCount = 0;
}
else
{
long bytesToFinishBuffer = mBufferBytesUsed - mBufferBytesConsumed;
if (bytesToFinishBuffer > 0)
{
memcpy(dataTarget, mBufPtr + mBufferBytesConsumed, bytesToFinishBuffer);
mBufferBytesConsumed += bytesToFinishBuffer;
dataTarget += bytesToFinishBuffer;
inByteCount -= bytesToFinishBuffer;
mPosition += bytesToFinishBuffer;
bytesRead += bytesToFinishBuffer;
}
if (inByteCount > 0)
{
refillBuffer_();
if (mBufferBytesUsed == 0)
return bytesRead;
}
}
}
return bytesRead;
}
private:
void refillBuffer_()
{
mBufferBytesUsed = ::read(mFD, mBufPtr, mBufferSize);
mBufferBytesConsumed = 0;
}
int64_t mPosition;
int mFD;
CloseOnDestroy mCloseOnDestroy;
size_t mBufferBytesUsed;
std::vector<char> mBufferHolder;
char* mBufPtr;
size_t mAlignment;
size_t mBufferSize;
size_t mBufferBytesConsumed;
};
| [
"braxton.mckee@gmail.com"
] | braxton.mckee@gmail.com |
2a415e3cb8e2b25bdd557665ca5e2632306f3ceb | 8c66d1fe6ecde6f66f3eaf5b5db220da3930c7ab | /codeforces/1114/A.cpp | e097c69426b4d724a884d2bd1346b3f362b7b22a | [] | no_license | Hasanul-Bari/codeforces | 0af70eda9dee3e7ddefc63560538e986dda0c141 | 1a074980ccdc2cd97a0a6a85f1f89da0343407b3 | refs/heads/master | 2023-06-03T07:52:28.584598 | 2021-04-12T14:39:00 | 2021-06-17T18:08:03 | 334,670,088 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,042 | cpp | #include<bits/stdc++.h>
using namespace std;
int main()
{
int a,b,c,x,y,z,c1=0,c2=0,c3=0;
cin>>x>>y>>z>>a>>b>>c;
if(x<=a)
{
c1=1;
}
else
c1=0;
a=a-x;
if(y<=(a+b))
{
if(y>=a)
{
y=y-a;
a=0;
}
else
{
a=a-y;
y=0;
}
y=y-a;
if(y>0)
{
if(y>=b)
{
y=y-b;
b=0;
}
else
{
b=b-y;
y=0;
}
y=y-b;
}
//cout<<"y= "<<y<<endl;
if(y>0)
c2=0;
else
c2=1;
}
else
c2=0;
if(z<=(a+b+c))
c3=1;
else
c3=0;
//cout<<c1<<" "<<c2<<" "<<c3<<endl;
if(c1==1 && c2==1 && c3==1)
cout<<"YES"<<endl;
else
cout<<"NO"<<endl;
return 0;
}
| [
"hasanul.bari.hasan96@gmail.com"
] | hasanul.bari.hasan96@gmail.com |
df6a1f49951edd72ec4af1fb547db5e70eadce93 | 4aa085345ba4a154d51b23969cabfd00e906eda5 | /c++/inline_operations.cpp | e9e4c7503031027cae5f2f20d1ca48888d369801 | [] | no_license | abhishekxix/Programs | f2f807c84daa550333d9abec64e01d0d41e2dc2a | cf3c98bef6558df3ffa7839eb9258b30c6cdade9 | refs/heads/main | 2023-03-09T18:45:11.728929 | 2021-02-26T15:15:36 | 2021-02-26T15:22:24 | 341,647,945 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,123 | cpp | #include <iostream>
typedef struct {
int operand1;
int operand2;
} operands;
inline int sum(operands op) {
return op.operand1 + op.operand2;
}
inline int difference(operands op) {
return op.operand1 - op.operand2;
}
inline int product(operands op) {
return op.operand1 * op.operand2;
}
inline int division(operands op) {
return op.operand1 / op.operand2;
}
inline int modulo_division(operands op) {
return op.operand1 % op.operand2;
}
int main() {
operands op;
std::cout << "Enter the first operand -> ";
std::cin >> op.operand1;
std::cout << "Enter the second operand -> ";
std::cin >> op.operand2;
std::cout << op.operand1 << " + " << op.operand2 << " = " << sum(op) << '\n'
<< op.operand1 << " - " << op.operand2 << " = " << difference(op) << '\n'
<< op.operand1 << " * " << op.operand2 << " = " << product(op) << '\n'
<< op.operand1 << " / " << op.operand2 << " = " << division(op) << '\n'
<< op.operand1 << " % " << op.operand2 << " = " << modulo_division(op) << std::endl;
return 0;
} | [
"abhisheksinghxix@gmail.com"
] | abhisheksinghxix@gmail.com |
99be670a83472e4a4171e1aa2a6d4e257e9a2fa1 | 5460bad1bd452e1dcf2d72823f444b8201fd93a8 | /Engine/Utility/Code/VIBuffer.h | 6f9c048c243eb0ef16e5e6a7b0c9443f7fed034e | [] | no_license | beckchul/DirectX9_3D | 0fb74780f1dbec77fb4c69943c3de3367ff09eed | fa2ff73cc84d6c08baf68e982f7ef5daaebad4d7 | refs/heads/master | 2022-11-16T01:16:15.703260 | 2020-07-13T14:56:41 | 2020-07-13T14:56:41 | 279,331,434 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,097 | h | /*!
* \file VIBuffer.h
* \date 2015/04/04 22:28
*
* \author Administrator
* Contact: user@company.com
*
* \brief
*
* TODO: long description
*
* \note
*/
#ifndef VIBuffer_h__
#define VIBuffer_h__
#include "Resources.h"
BEGIN(Engine)
class ENGINE_DLL CVIBuffer
: public CResources
{
public:
enum BUFFERTYPE {BUFFER_RCTEX, BUFFER_TERRAIN, BUFFER_CUBETEX, BUFFER_CUBECOL};
public:
explicit CVIBuffer(LPDIRECT3DDEVICE9 pDevice);
explicit CVIBuffer(const CVIBuffer& rhs);
virtual ~CVIBuffer(void);
public:
virtual CResources* CloneResource(void) PURE;
void GetVtxInfo(void* pVtxInfo);
public:
void SetVtxInfo(void* pVtxInfo);
void SetIdxInfo(void* pIdxInfo, const DWORD* pTriCnt);
void SetBoxColor(DWORD dwColor);
public:
virtual HRESULT CreateBuffer(void);
virtual DWORD Release(void);
public:
void Render(const D3DXMATRIX* pmatWorld);
protected:
LPDIRECT3DVERTEXBUFFER9 m_pVB;
DWORD m_dwVtxSize;
DWORD m_dwVtxCnt;
DWORD m_dwVtxFVF;
LPDIRECT3DINDEXBUFFER9 m_pIB;
DWORD m_dwIdxSize;
DWORD m_dwTriCnt;
D3DFORMAT m_IdxFmt;
};
END
#endif // VIBuffer_h__ | [
"qorcjf7409@naver.com"
] | qorcjf7409@naver.com |
f2f943e1e7c19a7756497db5a3792858c3793ea7 | 90484252cbc7ef7ae9588a070c0671c93dfb2c03 | /Solutions/Problem_Statement_41_Solution.c++ | 48fc23046d4d9ede29368e9c8859b2a96db77d40 | [
"MIT"
] | permissive | MayureeS/Hacktoberfest_Moz_Cummins | c7fbad20e46f6759976caa4eb8b959a9928d28d9 | e1af9cd7ae46f8f77f67699891911af547eee67a | refs/heads/main | 2023-08-14T12:41:47.648232 | 2021-10-13T18:03:02 | 2021-10-13T18:03:02 | 413,756,352 | 0 | 0 | MIT | 2021-10-05T09:40:04 | 2021-10-05T09:40:02 | null | UTF-8 | C++ | false | false | 1,487 |
/*Given N non-negative integers a1,a2....a where each represents a point at coordinate (i,ai). N vertical lines are drawn such that the two
endpoints of line i are at(i,ai) and (i,0). Find the two lines, which together with the x-axis form a container, such that it contains the most
water*/
#include<iostream>
#include<limits.h>
using namespace std;
void max_Area() //Function to compute maximum area
{
int n;
cout<<"Enter the size of the array."<<endl;
cin>>n; //Accepting the array size from the user, n=array size.
int a[n];
cout<<"Enter the elements of the array"<<endl;
for(int i=0;i<n;i++) // Accepting the array elements from the user
{
cin>>a[i];
}
int l=0,r=n-1,h_min=0,area=INT_MIN;
while(l<r)
{
h_min=min(a[l],a[r]);
area=max(area,(r-l)*h_min);
if(h_min==a[l])
l++;
else
r--;
}
cout<<" Output: "<<area<<endl; /*Printing the maximum area of the container containing
maximum water*/
}
int main()
{
max_Area(); //Calling the function max_Area().
return 0;
}
| [
"noreply@github.com"
] | noreply@github.com | |
2650a5c102c6a42cc510632ef739ac9bc6fdad98 | a39d032b5c2ed8c15e15c0d8986e541597b4cb5f | /Pcap++/src/PcapRemoteDeviceList.cpp | a1d333c4fee05dee8af1ecfc71e8ccb9058606d3 | [
"Unlicense"
] | permissive | MohamadMansouri/Conan | c2a9c611fef4ffb1c8ddbf49a474438cdc10fa2f | 7409ffa58be02bd72d026f3eebb712ad2551e291 | refs/heads/master | 2020-03-19T22:43:44.335002 | 2019-01-05T10:24:47 | 2019-01-05T10:24:47 | 136,979,534 | 3 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 6,830 | cpp | #if defined(WIN32) || defined(WINx64)
#define LOG_MODULE PcapLogModuleRemoteDevice
#include "PcapRemoteDeviceList.h"
#include "Logger.h"
#include "IpUtils.h"
#include <ws2tcpip.h>
namespace pcpp
{
PcapRemoteDeviceList* PcapRemoteDeviceList::getRemoteDeviceList(IPAddress* ipAddress, uint16_t port)
{
return PcapRemoteDeviceList::getRemoteDeviceList(ipAddress, port, NULL);
}
PcapRemoteDeviceList* PcapRemoteDeviceList::getRemoteDeviceList(IPAddress* ipAddress, uint16_t port, PcapRemoteAuthentication* remoteAuth)
{
if (ipAddress == NULL || !ipAddress->isValid())
{
LOG_ERROR("IP address is NULL or not valid");
return NULL;
}
char portAsCharArr[6];
sprintf(portAsCharArr, "%d", port);
LOG_DEBUG("Searching remote devices on IP: %s and port: %d", ipAddress->toString().c_str(), port);
char remoteCaptureString[PCAP_BUF_SIZE];
char errbuf[PCAP_ERRBUF_SIZE];
if (pcap_createsrcstr(remoteCaptureString, PCAP_SRC_IFREMOTE, ipAddress->toString().c_str(), portAsCharArr, NULL, errbuf) != 0)
{
LOG_ERROR("Error in creating the remote connection string. Error was: %s", errbuf);
return NULL;
}
LOG_DEBUG("Remote capture string: %s", remoteCaptureString);
pcap_rmtauth* pRmAuth = NULL;
pcap_rmtauth rmAuth;
if (remoteAuth != NULL)
{
LOG_DEBUG("Authentication requested. Username: %s, Password: %s", remoteAuth->userName.c_str(), remoteAuth->password.c_str());
rmAuth = remoteAuth->getPcapRmAuth();
pRmAuth = &rmAuth;
}
pcap_if_t* interfaceList;
char errorBuf[PCAP_ERRBUF_SIZE];
if (pcap_findalldevs_ex(remoteCaptureString, pRmAuth, &interfaceList, errorBuf) < 0)
{
LOG_ERROR("Error retrieving device on remote machine. Error string is: %s", errorBuf);
return NULL;
}
PcapRemoteDeviceList* resultList = new PcapRemoteDeviceList();
resultList->setRemoteMachineIpAddress(ipAddress);
resultList->setRemoteMachinePort(port);
resultList->setRemoteAuthentication(remoteAuth);
pcap_if_t* currInterface = interfaceList;
while (currInterface != NULL)
{
PcapRemoteDevice* pNewRemoteDevice = new PcapRemoteDevice(currInterface, resultList->m_RemoteAuthentication,
resultList->getRemoteMachineIpAddress(), resultList->getRemoteMachinePort());
resultList->m_RemoteDeviceList.push_back(pNewRemoteDevice);
currInterface = currInterface->next;
}
pcap_freealldevs(interfaceList);
return resultList;
}
PcapRemoteDevice* PcapRemoteDeviceList::getRemoteDeviceByIP(const char* ipAddrAsString)
{
IPAddress::Ptr_t apAddr = IPAddress::fromString(ipAddrAsString);
if (!apAddr->isValid())
{
LOG_ERROR("IP address illegal");
return NULL;
}
PcapRemoteDevice* result = getRemoteDeviceByIP(apAddr.get());
return result;
}
PcapRemoteDevice* PcapRemoteDeviceList::getRemoteDeviceByIP(IPAddress* ipAddr)
{
if (ipAddr->getType() == IPAddress::IPv4AddressType)
{
IPv4Address* ip4Addr = static_cast<IPv4Address*>(ipAddr);
return getRemoteDeviceByIP(*ip4Addr);
}
else //IPAddress::IPv6AddressType
{
IPv6Address* ip6Addr = static_cast<IPv6Address*>(ipAddr);
return getRemoteDeviceByIP(*ip6Addr);
}
}
PcapRemoteDevice* PcapRemoteDeviceList::getRemoteDeviceByIP(IPv4Address ip4Addr)
{
LOG_DEBUG("Searching all remote devices in list...");
for(RemoteDeviceListIterator devIter = m_RemoteDeviceList.begin(); devIter != m_RemoteDeviceList.end(); devIter++)
{
LOG_DEBUG("Searching device '%s'. Searching all addresses...", (*devIter)->m_Name);
for(std::vector<pcap_addr_t>::iterator addrIter = (*devIter)->m_Addresses.begin(); addrIter != (*devIter)->m_Addresses.end(); addrIter++)
{
if (LoggerPP::getInstance().isDebugEnabled(PcapLogModuleRemoteDevice) && addrIter->addr != NULL)
{
char addrAsString[INET6_ADDRSTRLEN];
sockaddr2string(addrIter->addr, addrAsString);
LOG_DEBUG("Searching address %s", addrAsString);
}
in_addr* currAddr = sockaddr2in_addr(addrIter->addr);
if (currAddr == NULL)
{
LOG_DEBUG("Address is NULL");
continue;
}
if (currAddr->s_addr == ip4Addr.toInAddr()->s_addr)
{
LOG_DEBUG("Found matched address!");
return (*devIter);
}
}
}
return NULL;
}
PcapRemoteDevice* PcapRemoteDeviceList::getRemoteDeviceByIP(IPv6Address ip6Addr)
{
LOG_DEBUG("Searching all remote devices in list...");
for(RemoteDeviceListIterator devIter = m_RemoteDeviceList.begin(); devIter != m_RemoteDeviceList.end(); devIter++)
{
LOG_DEBUG("Searching device '%s'. Searching all addresses...", (*devIter)->m_Name);
for(std::vector<pcap_addr_t>::iterator addrIter = (*devIter)->m_Addresses.begin(); addrIter != (*devIter)->m_Addresses.end(); addrIter++)
{
if (LoggerPP::getInstance().isDebugEnabled(PcapLogModuleRemoteDevice) && addrIter->addr != NULL)
{
char addrAsString[INET6_ADDRSTRLEN];
sockaddr2string(addrIter->addr, addrAsString);
LOG_DEBUG("Searching address %s", addrAsString);
}
in6_addr* currAddr = sockaddr2in6_addr(addrIter->addr);
if (currAddr == NULL)
{
LOG_DEBUG("Address is NULL");
continue;
}
uint8_t* addrAsArr; size_t addrLen;
ip6Addr.copyTo(&addrAsArr, addrLen);
if (memcmp(currAddr, addrAsArr, sizeof(struct in6_addr)) == 0)
{
LOG_DEBUG("Found matched address!");
return (*devIter);
}
delete [] addrAsArr;
}
}
return NULL;
}
void PcapRemoteDeviceList::setRemoteMachineIpAddress(const IPAddress* ipAddress)
{
if (ipAddress == NULL)
{
LOG_ERROR("Trying to set a NULL IP address to PcapRemoteDeviceList");
return;
}
if (m_RemoteMachineIpAddress != NULL)
delete m_RemoteMachineIpAddress;
if (ipAddress->getType() == IPAddress::IPv4AddressType)
{
m_RemoteMachineIpAddress = new IPv4Address(ipAddress->toString());
}
else //IPAddress::IPv6AddressType
{
m_RemoteMachineIpAddress = new IPv6Address(ipAddress->toString());
}
}
void PcapRemoteDeviceList::setRemoteMachinePort(uint16_t port)
{
m_RemoteMachinePort = port;
}
void PcapRemoteDeviceList::setRemoteAuthentication(const PcapRemoteAuthentication* remoteAuth)
{
if (remoteAuth != NULL)
m_RemoteAuthentication = new PcapRemoteAuthentication(*remoteAuth);
else
{
if (m_RemoteAuthentication != NULL)
delete m_RemoteAuthentication;
m_RemoteAuthentication = NULL;
}
}
PcapRemoteDeviceList::~PcapRemoteDeviceList()
{
while (m_RemoteDeviceList.size() > 0)
{
RemoteDeviceListIterator devIter = m_RemoteDeviceList.begin();
delete (*devIter);
m_RemoteDeviceList.erase(devIter);
}
if (m_RemoteMachineIpAddress != NULL)
{
delete m_RemoteMachineIpAddress;
}
if (m_RemoteAuthentication != NULL)
{
delete m_RemoteAuthentication;
}
}
} // namespace pcpp
#endif // WIN32 || WINx64
| [
"mansorum@eurecom.fr"
] | mansorum@eurecom.fr |
41aacfd08f1ce7b23cb791d179f1931ad92a50bd | 39100b66c5359c5fa7ce2dc3e0bba754f70d73f7 | /RodrigoZwetsch/Lista 3/RodrigoZwetsch_Lis_3_Ex_1/RodrigoZwetsch_Lis_3_Ex_1/Pessoa.h | 3d8779f17f1df7d71b0350fa925da5bdfda5b8a6 | [] | no_license | raphaellc/AlgEDCPP | 74db9cf0b2a27239c7b44b585e436637aa522151 | f37fca39d16aa8b11572603ba173e7bc2e0e870a | refs/heads/master | 2020-03-25T21:11:30.969638 | 2018-11-29T14:24:06 | 2018-11-29T14:24:06 | 144,163,894 | 0 | 0 | null | 2018-12-11T22:08:25 | 2018-08-09T14:28:14 | C++ | UTF-8 | C++ | false | false | 165 | h | #pragma once
#include <iostream>
#include <string>
using namespace std;
class Pessoa
{
public:
Pessoa();
~Pessoa();
int idade;
string nome;
};
| [
"noreply@github.com"
] | noreply@github.com |
f86525f6a58b13a815e015e19045a431669c75bf | 0b5e1a89958350970acf464baa12a35480b5ad45 | /CS 162/Week 6/Lab 6/list.hpp | b2434157f83236a42ab1325d6fa3928b1dc2b820 | [] | no_license | mister-f/OSU | d9c0a242488b0a4c4a9edbfb75a4387b78092669 | b6c8779d0b83924f27d948df3c74a51918644c18 | refs/heads/master | 2020-03-09T05:31:32.236849 | 2018-04-08T08:18:03 | 2018-04-08T08:18:03 | 128,615,982 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 740 | hpp | /**************************************
* Program Name: list.hpp
* Name: Andrew Funk
* Date: 11-04-17
* Description: list.hpp is the class specification file for the
* List class. It describes the member variables
* and the member functions.
*************************************/
#ifndef LIST_HPP
#define LIST_HPP
#include <fstream>
#include <iostream>
#include <string>
#include <vector>
#include "node.hpp"
#include "getValidInput.hpp"
#include "menu.hpp"
class List
{
private:
Node* head;
Node* tail;
public:
List();
void addHead(int);
void addTail(int);
void deleteHead();
void deleteTail();
void printReverse();
void printForward();
void listMenu();
void fileInput();
~List();
};
#endif
| [
"funkand@oregonstate.edu"
] | funkand@oregonstate.edu |
4d2e0cbcce5133f041e90c01fcd3b90eaf92b8ed | 5272454ea3d0a76d2b5172495a4daa95b71197ca | /project_wly2_lua_client/frameworks/runtime-src/Classes/Foxair/shared_ptr.h | 2df01f4051d68bcdd33ea76fb5777122ee8c9b7e | [] | no_license | qwe811077wr/-111111 | a56190f9a88422a9ae5e9331052d526fb1ab1d02 | 2270db0984a6455cf3b0f33b553fb80d97d91da8 | refs/heads/master | 2022-12-26T18:42:05.432015 | 2019-12-07T12:41:41 | 2019-12-07T12:41:41 | 248,710,529 | 0 | 3 | null | 2022-12-16T22:23:48 | 2020-03-20T08:59:11 | Lua | UTF-8 | C++ | false | false | 1,731 | h | #ifndef __FOXAIR_SHARED_PTR_H__
#define __FOXAIR_SHARED_PTR_H__
#include <algorithm>
#include "atomic.h"
namespace Foxair {
template<typename T> class SharedPtr {
private:
typedef SharedPtr<T> type_this;
typedef void (*ptr_deletor)(T*);
public:
explicit SharedPtr(T* p = 0, ptr_deletor pd = __DELETOR)
:m_px(p)
,m_deletor(pd) {
m_pn = new int(1);
}
SharedPtr(const SharedPtr<T> &sp)
:m_px(sp.m_px)
,m_pn(sp.m_pn)
,m_deletor(sp.m_deletor) {
atomicIncrement(m_pn);
}
SharedPtr<T>& operator=(const SharedPtr<T> &sp) {
reset();
delete m_pn;
m_px = sp.m_px;
m_pn = sp.m_pn;
m_deletor = sp.m_deletor;
atomicIncrement(m_pn);
return *this;
}
T* get() const {
return m_px;
}
T& operator *() {
return *m_px;
}
T* operator ->() {
return m_px;
}
T* operator ->() const {
return m_px;
}
bool operator !=(const SharedPtr<T> &sp) {
return m_px != sp.get();
}
operator bool() {
return m_px;
}
bool operator !() {
return !m_px;
}
void reset(T* p = 0, ptr_deletor pd = __DELETOR) {
type_this(p, pd).swap(*this);
}
void swap(SharedPtr<T> &sp) {
std::swap(m_px, sp.m_px);
std::swap(m_pn, sp.m_pn);
std::swap(m_deletor, sp.m_deletor);
}
~SharedPtr() {
if (atomicDecrement(m_pn) <= 0) {
if (m_px) {
m_deletor(m_px);
}
delete m_pn;
}
}
private:
static void __DELETOR(T* px) {
delete px;
}
private:
T* m_px;
int *m_pn;
ptr_deletor m_deletor;
};
}
#endif
| [
"939139677@qq.com"
] | 939139677@qq.com |
f3eeef4c1dbf606575ae22480cc0df4c5d7e348a | c6f070781cabbc930c811948f37bd889413ecfcf | /Argo Project/Client/Argo Project/HelpScreen.cpp | fc54eb41722183c7995532507bfa04a43e703a2b | [] | no_license | itcgames/ARGO_2018_19_G | 4740d44b30728947682612d1f10de902ad5b3d31 | 829b9502b27710725603a535f052afd9d7d10a0e | refs/heads/master | 2020-04-20T19:55:00.652461 | 2019-02-28T13:11:03 | 2019-02-28T13:11:03 | 169,062,119 | 0 | 0 | null | 2019-02-28T11:26:14 | 2019-02-04T10:31:23 | C++ | UTF-8 | C++ | false | false | 3,115 | cpp | #include "HelpScreen.h"
HelpScreen::HelpScreen(SDL_Renderer* renderer)
{
initialise(renderer);
}
HelpScreen::~HelpScreen()
{
}
void HelpScreen::initialise(SDL_Renderer* renderer)
{
mousePos = new SDL_Point();
SDL_Surface* mainMenuSurface = IMG_Load("Resources/MainMenuBTN.png");
SDL_Surface* backgroundSurface = IMG_Load("ASSETS/MainmenuBackground.png");
SDL_Surface* helpScene1 = IMG_Load("ASSETS/helpscreen1.png");
SDL_Surface* helpScene2 = IMG_Load("ASSETS/helpscreen2.png");
SDL_Surface* helpScene3 = IMG_Load("ASSETS/helpscreen3.png");
SDL_Surface* helpScene4 = IMG_Load("ASSETS/helpscreen4.png");
SDL_Surface* helpScene5 = IMG_Load("ASSETS/helpscreen5.png");
SDL_Surface* helpScene6 = IMG_Load("ASSETS/helpscreen6.png");
SDL_Surface* helpScene7 = IMG_Load("ASSETS/helpscreen7.png");
m_MainMenuButtonTxt = SDL_CreateTextureFromSurface(renderer, mainMenuSurface);
m_backgroundTxt = SDL_CreateTextureFromSurface(renderer, backgroundSurface);
SDL_Texture* helpTxt = SDL_CreateTextureFromSurface(renderer, helpScene1);
m_helpTextures.push_back(helpTxt);
helpTxt = SDL_CreateTextureFromSurface(renderer, helpScene2);
m_helpTextures.push_back(helpTxt);
helpTxt = SDL_CreateTextureFromSurface(renderer, helpScene3);
m_helpTextures.push_back(helpTxt);
helpTxt = SDL_CreateTextureFromSurface(renderer, helpScene4);
m_helpTextures.push_back(helpTxt);
helpTxt = SDL_CreateTextureFromSurface(renderer, helpScene5);
m_helpTextures.push_back(helpTxt);
helpTxt = SDL_CreateTextureFromSurface(renderer, helpScene6);
m_helpTextures.push_back(helpTxt);
helpTxt = SDL_CreateTextureFromSurface(renderer, helpScene7);
m_helpTextures.push_back(helpTxt);
m_mainMenuButtonPos = new SDL_Rect();
m_mainMenuButtonPos->x = 1600; m_mainMenuButtonPos->y = 680;
m_mainMenuButtonPos->w = 200; m_mainMenuButtonPos->h = 200;
m_backgroundPos = new SDL_Rect();
m_backgroundPos->x = 0; m_backgroundPos->y = 0;
m_backgroundPos->w = 1920; m_backgroundPos->h = 1080;
helpTxtPos = new SDL_Rect();
helpTxtPos->x = 0; helpTxtPos->y = 0;
helpTxtPos->w = 1200; helpTxtPos->h = 800;
m_index = 0;
}
void HelpScreen::update(GameState* gamestate, SDL_Renderer* renderer)
{
while (SDL_PollEvent(&m_event))
{
if(m_event.type == SDL_MOUSEBUTTONDOWN)
{
switch (m_event.type)
{
case SDL_MOUSEBUTTONDOWN:
{
SDL_GetMouseState(&mousePos->x, &mousePos->y);
if (SDL_PointInRect(mousePos, m_mainMenuButtonPos))
{
initialise(renderer);
*gamestate = GameState::MainMenu;
}
break;
}
}
}
else if (m_event.type == SDL_KEYDOWN)
{
switch (m_event.key.keysym.sym)
{
case SDLK_RIGHT:
{
m_index++;
if (m_index > 6)
{
m_index = 0;
}
break;
}
case SDLK_LEFT:
{
m_index--;
if (m_index < 0)
{
m_index = 6;
}
break;
}
}
}
}
}
void HelpScreen::render(SDL_Renderer *renderer)
{
SDL_RenderCopy(renderer, m_backgroundTxt, NULL, m_backgroundPos);
SDL_RenderCopy(renderer, m_helpTextures[m_index], NULL, helpTxtPos);
SDL_RenderCopy(renderer, m_MainMenuButtonTxt, NULL, m_mainMenuButtonPos);
} | [
"c00205321@itcarlow.ie"
] | c00205321@itcarlow.ie |
1c1b1569074da0503ec5b12dbf3f8a6f0d23f33b | e102ae5c7e2f630b9f2cc20233322b0228df78e0 | /Algorithms/Sorting/insertionsort1.cxx | 8e9bfbac67034639ecec11be10ce33405308b569 | [
"MIT"
] | permissive | will-crawford/HackerRank | f664cbc2b3ee853a0c2820470384e8ef0fb85357 | 74965480ee6a51603eb320e5982b0943fdaf1302 | refs/heads/master | 2021-05-03T21:26:01.973241 | 2019-08-13T11:57:44 | 2020-03-01T05:24:58 | 120,383,436 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 680 | cxx | #include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
inline ostream &operator<< (ostream &os, vector<int> &v) {
auto i = begin(v), j = end(v);
if ( i != j ) {
os << *i;
while ( ++i != j )
os << ' ' << *i;
}
return os;
}
void insertionSort ( vector<int> &a ) {
auto i = end(a); int insertee = *--i, tmp;
while ( i != begin(a) && ( tmp = i[-1] ) > insertee ) { *i-- = tmp; cout << a << endl; }
*i = insertee; cout << a;
}
int main() {
int Size; cin >> Size;
vector<int> Arr (Size); for ( int &i : Arr ) cin >> i;
insertionSort (Arr);
return 0;
}
| [
"billcrawford1970@googlemail.com"
] | billcrawford1970@googlemail.com |
421fc0c4bfa2347d573a560d3bbb0e517c0fceb6 | 600df3590cce1fe49b9a96e9ca5b5242884a2a70 | /third_party/WebKit/Source/modules/speech/testing/PlatformSpeechSynthesizerMock.cpp | b009c475ac3d1ef9d77f46b5803b01b096fad980 | [
"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",
"MIT",
"Apache-2.0",
"BSD-3-Clause"
] | permissive | metux/chromium-suckless | efd087ba4f4070a6caac5bfbfb0f7a4e2f3c438a | 72a05af97787001756bae2511b7985e61498c965 | refs/heads/orig | 2022-12-04T23:53:58.681218 | 2017-04-30T10:59:06 | 2017-04-30T23:35:58 | 89,884,931 | 5 | 3 | BSD-3-Clause | 2022-11-23T20:52:53 | 2017-05-01T00:09:08 | null | UTF-8 | C++ | false | false | 4,957 | cpp | /*
* Copyright (C) 2013 Apple Computer, 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.
*
* THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``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 APPLE COMPUTER, INC. OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "modules/speech/testing/PlatformSpeechSynthesizerMock.h"
#include "platform/speech/PlatformSpeechSynthesisUtterance.h"
namespace blink {
PlatformSpeechSynthesizerMock* PlatformSpeechSynthesizerMock::create(
PlatformSpeechSynthesizerClient* client) {
PlatformSpeechSynthesizerMock* synthesizer =
new PlatformSpeechSynthesizerMock(client);
synthesizer->initializeVoiceList();
client->voicesDidChange();
return synthesizer;
}
PlatformSpeechSynthesizerMock::PlatformSpeechSynthesizerMock(
PlatformSpeechSynthesizerClient* client)
: PlatformSpeechSynthesizer(client),
m_speakingErrorOccurredTimer(
this,
&PlatformSpeechSynthesizerMock::speakingErrorOccurred),
m_speakingFinishedTimer(
this,
&PlatformSpeechSynthesizerMock::speakingFinished) {}
PlatformSpeechSynthesizerMock::~PlatformSpeechSynthesizerMock() {}
void PlatformSpeechSynthesizerMock::speakingErrorOccurred(TimerBase*) {
ASSERT(m_currentUtterance);
client()->speakingErrorOccurred(m_currentUtterance);
speakNext();
}
void PlatformSpeechSynthesizerMock::speakingFinished(TimerBase*) {
ASSERT(m_currentUtterance);
client()->didFinishSpeaking(m_currentUtterance);
speakNext();
}
void PlatformSpeechSynthesizerMock::speakNext() {
if (m_speakingErrorOccurredTimer.isActive())
return;
if (m_queuedUtterances.isEmpty()) {
m_currentUtterance = nullptr;
return;
}
m_currentUtterance = m_queuedUtterances.takeFirst();
speakNow();
}
void PlatformSpeechSynthesizerMock::initializeVoiceList() {
m_voiceList.clear();
m_voiceList.append(PlatformSpeechSynthesisVoice::create(
String("mock.voice.bruce"), String("bruce"), String("en-US"), true,
true));
m_voiceList.append(PlatformSpeechSynthesisVoice::create(
String("mock.voice.clark"), String("clark"), String("en-US"), true,
false));
m_voiceList.append(PlatformSpeechSynthesisVoice::create(
String("mock.voice.logan"), String("logan"), String("fr-CA"), true,
true));
}
void PlatformSpeechSynthesizerMock::speak(
PlatformSpeechSynthesisUtterance* utterance) {
if (!m_currentUtterance) {
m_currentUtterance = utterance;
speakNow();
return;
}
m_queuedUtterances.append(utterance);
}
void PlatformSpeechSynthesizerMock::speakNow() {
ASSERT(m_currentUtterance);
client()->didStartSpeaking(m_currentUtterance);
// Fire a fake word and then sentence boundary event.
client()->boundaryEventOccurred(m_currentUtterance, SpeechWordBoundary, 0);
client()->boundaryEventOccurred(m_currentUtterance, SpeechSentenceBoundary,
m_currentUtterance->text().length());
// Give the fake speech job some time so that pause and other functions have
// time to be called.
m_speakingFinishedTimer.startOneShot(.1, BLINK_FROM_HERE);
}
void PlatformSpeechSynthesizerMock::cancel() {
if (!m_currentUtterance)
return;
// Per spec, removes all queued utterances.
m_queuedUtterances.clear();
m_speakingFinishedTimer.stop();
m_speakingErrorOccurredTimer.startOneShot(.1, BLINK_FROM_HERE);
}
void PlatformSpeechSynthesizerMock::pause() {
if (!m_currentUtterance)
return;
client()->didPauseSpeaking(m_currentUtterance);
}
void PlatformSpeechSynthesizerMock::resume() {
if (!m_currentUtterance)
return;
client()->didResumeSpeaking(m_currentUtterance);
}
DEFINE_TRACE(PlatformSpeechSynthesizerMock) {
visitor->trace(m_currentUtterance);
visitor->trace(m_queuedUtterances);
PlatformSpeechSynthesizer::trace(visitor);
}
} // namespace blink
| [
"enrico.weigelt@gr13.net"
] | enrico.weigelt@gr13.net |
c8d9d73112d12d7ead3d7b8d67f3331b2806d17b | d3e8d0168fb08e1be19dc5c2057a423279191ffb | /c/struct/netistä.cpp | 21e7ac53fc7d5b602ff2f92a9ad736d6cb589500 | [] | no_license | xormor2/c-harjoituksia | 14a3a43a166bbc1a6629b4f252bf3d622dafc38e | a04f505a5a18ec6b6c6c16f191c394b1db456788 | refs/heads/master | 2023-07-06T12:39:31.225509 | 2023-06-29T17:00:27 | 2023-06-29T17:00:27 | 98,787,488 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 303 | cpp | #include <stdio.h>
int main()
{
struct foo
{
int x;
float y;
};
struct foo var;
struct foo* pvar;
pvar = &var;
var.x = 5;
(&var)->y = 14.3;
printf("%i - %.02f\n", var.x, (&var)->y);
pvar->x = 6;
pvar->y = 22.4;
printf("%i - %.02f\n", pvar->x, pvar->y);
return 0;
}
| [
"noreply@github.com"
] | noreply@github.com |
7b17a39d410c41d76fbce70496cc127ef1e3ab6d | 9d3445273e6eccee4b14c61c3752fb5d7f8f6765 | /csci_1202/Student3.cpp | 28e9fd7008123e0e5eaa7362f7a8162d8e8193bc | [] | no_license | chisom360/C | a0d045c2a18d902e7b0f5bfc57c51908b764e17d | 13e560bf5cff6150c39a661b213358dfd146fdcc | refs/heads/master | 2020-03-26T22:51:54.288640 | 2019-05-28T00:37:17 | 2019-05-28T00:37:17 | 145,492,197 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,424 | cpp | /* FILE: Student3.cpp */
/*
Static members are "class" variables, that is, they are
independent of any particular objects.
Static methods can be accessed using an object of the
class. This also identifies the class and member being
accessed.
*/
#include <iostream>
#include <cstring>
using namespace std;
class Student
{
static long count; // Keeps count of Student objects
// ... and generates id numbers.
char *name;
double gpa;
long id;
public:
static long getCount();
const char *getName() const;
char *setName(char const *const);
double getGpa() const;
double setGpa(double);
long getId() const;
char getGrade() const;
void display() const;
void print() const;
Student();
Student(char *n, double g);
};
long Student::count = 0;
Student::Student() // default constructor
{
id = ++count;
}
Student::Student(char *n, double g)
{
name = new char[strlen(n) + 1];
strcpy(name, n);
gpa = g;
id = ++count;
}
long Student::getCount()
{
return count;
}
const char *Student::getName() const
{
return name;
}
char *Student::setName(const char *const name)
{ // Exercising this
strcpy(this->name, name);
return this->name;
}
double Student::getGpa() const
{
return gpa;
}
double Student::setGpa(double gpa)
{
return this->gpa = gpa;
}
long Student::getId() const
{
return id;
}
char Student::getGrade() const
{
char grade;
if (gpa >= 3.5)
grade = 'A';
else if (gpa >= 2.5)
grade = 'B';
else if (gpa >= 1.5)
grade = 'C';
else if (gpa >= 0.5)
grade = 'D';
else
grade = 'F';
return grade;
}
void Student::display() const
{
cout << "Student name = " << name << endl;
cout << "Student gpa = " << gpa << endl;
cout << "Student id = " << id << endl;
}
void Student::print() const
{
cout << name << ", " << gpa << ", " << id;
}
int main()
{
cout << "Number of students is: " << Student::getCount() << endl;
// No choice but to use class name,
// ... no objects exist.
Student s("Joe Cool", 3.95),
s2("Cool Joe", 3.5),
s3("Joe Llama", 3.2);
s.print();
cout << " is a " << s.getGrade() << " student." << endl;
s2.print();
cout << " is a " << s2.getGrade() << " student." << endl;
s3.print();
cout << " is a " << s3.getGrade() << " student." << endl;
cout << "Number of students is: " << s2.getCount() << endl;
// s2 is used to call static method
s.setName("Joe Coolest");
s2.setName(s3.getName());
s2.setGpa(2.25);
s3.setName("Charlie Brown");
s3.setGpa(3.25);
cout << endl
<< endl;
s.print();
cout << " is a " << s.getGrade() << " student." << endl;
s2.print();
cout << " is a " << s2.getGrade() << " student." << endl;
s3.print();
cout << " is a " << s3.getGrade() << " student." << endl;
cout << "Number of students is: " << s2.getCount() << endl;
// s2 is used to call static method
return 0;
}
/* OUTPUT: Student3.cpp
Number of students is: 0
Joe Cool, 3.95, 1 is a A student.
Cool Joe, 3.5, 2 is a A student.
Joe Llama, 3.2, 3 is a B student.
Number of students is: 3
Joe Coolest, 3.95, 1 is a A student.
Joe Llama, 2.25, 2 is a C student.
Charlie Brown, 3.25, 3 is a B student.
Number of students is: 3
*/
| [
"esele001@umn.edu"
] | esele001@umn.edu |
ce2b4e795ede4f35ba3a3634fe4438c49b9a05e7 | abf9ba8d6bb62f2b383b26d7c67e7a8dbef0e5ef | /день 5 , 6 ,7/задание 48 я иду на урок инфаорматики day 5.cpp | 758f123e0b7d30e0869264ad580348bb12f5cfd2 | [] | no_license | VitalikGuds/Practic-PS-3-1-OPPtam | 530346d82c82bf011faa77b6367ba1011346f596 | 5f8281f23e9cb5751087562d3b9c95456163db59 | refs/heads/master | 2021-08-18T16:47:49.661573 | 2017-11-23T10:03:50 | 2017-11-23T10:03:50 | 111,414,881 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 386 | cpp |
//There is a typed file with thirty numbers. Write the number of the existing file in the reverse order to another file
#include <iostream>
#include <fstream>
using namespace std;
int main()
{
ifstream f("input.txt");
string s,q;
while(!f.eof()){
f>>s;
q=s+'\n'+q;
}
f.close();cout<<q;
ofstream o("file.txt"); o<<q; o.close();
return 0;
}
| [
"vitalik-guds@ukr.net"
] | vitalik-guds@ukr.net |
5f9db7c79a0082e751d1888d24d4d497bceae059 | 47ab511d1e5f2418745f6319b7584221e578a705 | /PersonConstructorEx/main.cpp | 3e21e897f53a4374c5ecda165cea486c6dd9ac4c | [] | no_license | sdaingade/cpplabs | f460936a6e2e4d68e13a9745b6edaae9aa75ba83 | fa6e644c1f83cbd73d4d6494a1d07f942915b62f | refs/heads/master | 2021-05-29T23:53:37.281887 | 2015-10-04T16:14:06 | 2015-10-04T16:14:06 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 667 | cpp | /*
* Copyright SciSpike
*
* This file contains a test loop and main for the
* from C to CPP program
*/
#include "person.h"
#include <cstring>
/*
* Test code
*/
int main() {
// TODO: The person should be created with name and age
// passed to a constructor
Person stackPerson;
stackPerson.setName("John Doe");
stackPerson.setAge(40);
stackPerson.print();
stackPerson.incrementAge();
// TODO: The person should be created with name and age
// passed to a constructor
Person *heapPerson = new Person;
heapPerson->setName("John Doe");
heapPerson->setAge(40);
heapPerson->print();
delete heapPerson;
return 0;
}
| [
"petter.graff@scispike.com"
] | petter.graff@scispike.com |
a70d516fe8a1258eda8411710141fa39f3ef4755 | f0cb36e64008a0d58ee236e674b33e1571f59fb4 | /source/de/hackcraft/world/sub/model/ModelSystem.cpp | 8cde6aa8b34c0d2ebf3e452040b56bd865649e61 | [] | no_license | logzero/linwarrior | 034bed07dd3ce509bc79024ddca2c7fc2f183204 | 45d3bd13833ce8cce374a3f5b41a2302d01be24f | refs/heads/master | 2021-01-20T21:20:11.427448 | 2012-05-24T19:16:53 | 2012-05-24T19:16:53 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,945 | cpp | #include "ModelSystem.h"
#include "de/hackcraft/world/World.h"
#include <iostream>
using std::cout;
using std::endl;
ModelSystem* ModelSystem::instance = NULL;
ModelSystem::ModelSystem() {
instance = this;
visobjects = NULL;
}
ModelSystem::ModelSystem(const ModelSystem& orig) {
}
ModelSystem::~ModelSystem() {
}
ModelSystem* ModelSystem::getInstance() {
return instance;
}
void ModelSystem::clusterObjects() {
try {
int j = 0;
geomap.clear();
for(IModel* model : models) {
float px = model->getPosX();
float pz = model->getPosZ();
if (!finitef(px) || !finitef(pz)) {
//mUncluster.push_back(model);
} else {
geomap.put(px, pz, model);
}
j++;
}
} catch (char* s) {
cout << "Could not cluster models: " << s << endl;
}
}
void ModelSystem::animateObjects() {
for (IModel* model : models) {
model->animate(World::getInstance()->getTiming()->getSPF());
}
}
void ModelSystem::transformObjects() {
//cout << "transformObjects()\n";
for (IModel* model: models) {
glPushMatrix();
model->transform();
glPopMatrix();
}
}
void ModelSystem::setupView(float* pos, float* ori) {
// Find objects in visible range.
viewdistance = World::getInstance()->getViewdistance();
float* origin = pos;
float min[] = {origin[0] - viewdistance, origin[2] - viewdistance};
float max[] = {origin[0] + viewdistance, origin[2] + viewdistance};
if (visobjects != NULL) {
delete visobjects;
}
visobjects = geomap.getGeoInterval(min, max);
assert(visobjects != NULL);
//cout << "vis:" << objects->size() << " vs " << mObjects.size() << endl;
visorigin[0] = pos[0];
visorigin[1] = pos[1];
visorigin[2] = pos[2];
}
void ModelSystem::drawSolid() {
//cout << "drawSolid()\n";
float* origin = visorigin;
float maxrange = viewdistance;
float maxrange2 = maxrange*maxrange;
for(IModel* model: *visobjects) {
float x = model->getPosX() - origin[0];
float z = model->getPosZ() - origin[2];
float d2 = x * x + z * z;
if (d2 > maxrange2) continue;
glPushMatrix();
{
model->drawSolid();
}
glPopMatrix();
}
}
void ModelSystem::drawEffect() {
//cout << "drawEffect()\n";
float* origin = visorigin;
float maxrange = viewdistance;
float maxrange2 = maxrange*maxrange;
for(IModel* model: *visobjects) {
float x = model->getPosX() - origin[0];
float z = model->getPosZ() - origin[2];
float d2 = x * x + z * z;
if (d2 > maxrange2) continue;
glPushMatrix();
{
model->drawEffect();
}
glPopMatrix();
}
}
| [
"benjamin.pickhardt@udo.edu"
] | benjamin.pickhardt@udo.edu |
4df148ab29c67e3e5587bc841ccaabb975781d65 | 801d5bf63133303fb1506111527f3183f51ce9ef | /vendor/bundle/ruby/2.2.0/gems/passenger-5.3.4/src/agent/Core/SpawningKit/DummySpawner.h | c849ce0ecc54e1a160058899e5db020463e53e5d | [
"MIT"
] | permissive | albalenys/DevAdventures | d0479c549c5677af90651b62c157959bba24f2bb | 73c9e7c081680004efd782b360f09ba91369ef70 | refs/heads/master | 2023-01-19T12:09:29.527970 | 2020-05-28T01:07:04 | 2020-05-28T01:07:04 | 41,979,822 | 1 | 1 | null | 2023-01-19T05:31:07 | 2015-09-05T23:45:02 | JavaScript | UTF-8 | C++ | false | false | 4,217 | h | /*
* Phusion Passenger - https://www.phusionpassenger.com/
* Copyright (c) 2011-2017 Phusion Holding B.V.
*
* "Passenger", "Phusion Passenger" and "Union Station" are registered
* trademarks of Phusion Holding B.V.
*
* 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 _PASSENGER_SPAWNING_KIT_DUMMY_SPAWNER_H_
#define _PASSENGER_SPAWNING_KIT_DUMMY_SPAWNER_H_
#include <boost/shared_ptr.hpp>
#include <boost/atomic.hpp>
#include <vector>
#include <StaticString.h>
#include <Utils/StrIntUtils.h>
#include <Core/SpawningKit/Spawner.h>
#include <Core/SpawningKit/Exceptions.h>
namespace Passenger {
namespace SpawningKit {
using namespace std;
using namespace boost;
using namespace oxt;
class DummySpawner: public Spawner {
private:
boost::atomic<unsigned int> count;
void setConfigFromAppPoolOptions(Config *config, Json::Value &extraArgs,
const AppPoolOptions &options)
{
Spawner::setConfigFromAppPoolOptions(config, extraArgs, options);
config->spawnMethod = P_STATIC_STRING("dummy");
}
public:
unsigned int cleanCount;
DummySpawner(Context *context)
: Spawner(context),
count(1),
cleanCount(0)
{ }
virtual Result spawn(const AppPoolOptions &options) {
TRACE_POINT();
possiblyRaiseInternalError(options);
if (context->debugSupport != NULL) {
syscalls::usleep(context->debugSupport->dummySpawnDelay);
}
Config config;
Json::Value extraArgs;
setConfigFromAppPoolOptions(&config, extraArgs, options);
unsigned int number = count.fetch_add(1, boost::memory_order_relaxed);
Result result;
Result::Socket socket;
socket.address = "tcp://127.0.0.1:1234";
socket.protocol = "session";
socket.concurrency = 1;
socket.acceptHttpRequests = true;
if (context->debugSupport != NULL) {
socket.concurrency = context->debugSupport->dummyConcurrency;
}
result.initialize(*context, &config);
result.pid = number;
result.dummy = true;
result.gupid = "gupid-" + toString(number);
result.spawnEndTime = result.spawnStartTime;
result.spawnEndTimeMonotonic = result.spawnStartTimeMonotonic;
result.sockets.push_back(socket);
vector<StaticString> internalFieldErrors;
vector<StaticString> appSuppliedFieldErrors;
if (!result.validate(internalFieldErrors, appSuppliedFieldErrors)) {
Journey journey(SPAWN_DIRECTLY, !config.genericApp && config.startsUsingWrapper);
journey.setStepErrored(SPAWNING_KIT_HANDSHAKE_PERFORM, true);
SpawnException e(INTERNAL_ERROR, journey, &config);
e.setSummary("Error spawning the web application:"
" a bug in " SHORT_PROGRAM_NAME " caused the"
" spawn result to be invalid: "
+ toString(internalFieldErrors)
+ ", " + toString(appSuppliedFieldErrors));
e.setProblemDescriptionHTML(
"Bug: the spawn result is invalid: "
+ toString(internalFieldErrors)
+ ", " + toString(appSuppliedFieldErrors));
throw e.finalize();
}
return result;
}
virtual bool cleanable() const {
return true;
}
virtual void cleanup() {
cleanCount++;
}
};
typedef boost::shared_ptr<DummySpawner> DummySpawnerPtr;
} // namespace SpawningKit
} // namespace Passenger
#endif /* _PASSENGER_SPAWNING_KIT_DUMMY_SPAWNER_H_ */
| [
"albalenysd@gmail.com"
] | albalenysd@gmail.com |
4c12b4a1754d50ffc40e7bb7e07094b74a9c0779 | aee223c0ae52713006b40059c42d3e3648681b38 | /src/dbc/network/protocol/net_message_def.h | db673c7bda0d9bb0e799e5f98430565424e538c4 | [] | no_license | DeepBrainChain/DBC-AIComputingNet | 684d2a80dfefffa9cf1c1dde4018e0561e222e34 | 94448c385e37243f55bc45d60b1536b2db5ad4f4 | refs/heads/master | 2023-08-03T10:35:17.392602 | 2023-07-21T06:26:01 | 2023-07-21T06:26:01 | 118,290,364 | 21 | 13 | null | 2021-10-20T23:13:41 | 2018-01-20T23:50:43 | C++ | UTF-8 | C++ | false | false | 654 | h | #ifndef DBC_NETWORK_NET_MESSAGE_DEF_H
#define DBC_NETWORK_NET_MESSAGE_DEF_H
#include "net_message.h"
#include <boost/asio.hpp>
using namespace boost::asio::ip;
namespace network
{
class timer_click_msg : public message
{
public:
uint64_t cur_tick;
};
class tcp_socket_channel_error_msg : public message
{
public:
tcp::endpoint ep;
};
enum CLIENT_CONNECT_STATUS
{
CLIENT_CONNECT_SUCCESS = 0,
CLIENT_CONNECT_FAIL
};
class client_tcp_connect_notification : public message
{
public:
tcp::endpoint ep;
CLIENT_CONNECT_STATUS status;
};
}
#endif
| [
"bacuijg@163.com"
] | bacuijg@163.com |
6cb8174e2d39a3d4cf4674e7d67c2bb04872c049 | 2c517b5ca6beaa9f5cc472d828db50ec68a33e8f | /Machine Problem/mp2/main.cpp | ebcc06b7f76d06802f5a2fc543c3e466d04e001e | [] | no_license | yslenjoy/Data-Structure-Class-FA18 | 6b4bd511dd31b22a883d0ddd6a9b7d823b518aa0 | 92c725d0e687dcdb793b1a4a386e1a4cb9681b55 | refs/heads/master | 2020-04-15T00:49:15.150682 | 2019-01-05T21:51:04 | 2019-01-05T21:51:04 | 164,253,084 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 806 | cpp | #include "Image.h"
#include "StickerSheet.h"
#include <iostream>
using namespace std;
int main() {
//
// Reminder:
// Before exiting main, save your creation to disk as myImage.png
//
Image base;
base.readFromFile("pubg.png");
Image layer1;
layer1.readFromFile("8timesScope.png");
// layer1.scale(0.5);
Image layer2;
layer2.readFromFile("AWM.png");
Image layer3;
layer3.readFromFile("225.png");
layer3.scale(0.5);
// Image alma; alma.readFromFile("tests/alma.png");
// Image i; i.readFromFile("tests/i.png");
// StickerSheet sheet(alma, 5);
// sheet.addSticker(i, 20, 200);
// sheet.render().writeToFile("tests/myTest-render.png");
// // std::cout << "LINE :" << __LINE__ << std::endl;
// Image expected;
// expected.readFromFile("tests/expected.png");
return 0;
}
| [
"yslenjoy@gmail.com"
] | yslenjoy@gmail.com |
5fdd6d333bcdc1456228ac4139359d29b3b7a0cd | 3483232571b697d938e65cbc4bfc3458e83a5272 | /0/alphat.air | 2218f8783d38da2fde82e6977a7aafc5d18deaa2 | [] | no_license | exetercfd/runDirectoryInconel | bf2c27d21852b825f8b04cbf7d2658b590f9e69c | 83de3ac1a9adc72d4b3075c26890a1e8f5f978d6 | refs/heads/master | 2020-04-18T21:12:36.752407 | 2019-01-27T01:52:13 | 2019-01-27T01:52:13 | 167,759,020 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,380 | air | /*--------------------------------*- 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 "0";
object alphat.air;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensions [1 -1 -1 0 0 0 0];
internalField uniform 0;
boundaryField
{
back
{
type wedge;
}
front
{
type wedge;
}
inlet
{
type calculated;
value uniform 0;
}
outlet
{
type calculated;
value uniform 0;
}
walls
{
type compressible::alphatWallFunction;
Prt 0.85;
value uniform 0;
}
}
// ************************************************************************* //
| [
"andrew@thevisualroom.com"
] | andrew@thevisualroom.com |
5a4b3d35382fa17c8012eda6fe17c4797e586047 | 30a3a74b906f5ddf4ecff34ab028bc480a95e78c | /gmock/leetcode/MaximumSubarray_53.cpp | cb783a3c92a14b301f9dd639a935a7c6309ad0e4 | [] | no_license | Junch/StudyCppUTest | 3a6d0f5305de4b45f2a1b73bfdc491a5f25fe2cb | b12cbbb992e3cde0593855bf0793431086edbd63 | refs/heads/master | 2021-01-15T15:50:17.580680 | 2016-11-21T09:14:50 | 2016-11-21T09:14:50 | 8,309,383 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,456 | cpp | //
// MaximumSubarray_53.cpp
// https://leetcode.com/problems/maximum-subarray/
//
// Created by Jun Chen on 16/2/10.
//
//
#include <gmock/gmock.h>
#include <vector>
#include <algorithm>
using namespace std;
using namespace testing;
namespace MaximumSubarray {
class Solution {
public:
int maxSubArray(vector<int>& nums) {
int sums = nums[0];
int max = sums;
for (size_t i=1, len=nums.size(); i<len; ++i) {
if (sums < 0) {
sums = nums[i];
} else {
sums += nums[i];
}
if (sums > max) {
max = sums;
}
}
return max;
}
int maxSubArray2(vector<int>& nums) {
vector<int> sums(nums.size());
sums[0] = nums[0];
for (int i=1; i<nums.size(); ++i) {
if (sums[i-1] < 0) {
sums[i] = nums[i];
} else {
sums[i] = sums[i-1] + nums[i];
}
}
return *std::max_element(sums.begin(), sums.end());
}
};
TEST(MaximumSubarray, example) {
vector<int> arr{-2, 1, -3, 4, -1, 2, 1, -5, 4};
auto p = new Solution();
ASSERT_EQ(6, p->maxSubArray(arr));
}
TEST(MaximumSubarray, example2) {
vector<int> arr{-2, 1, -3, 4, -1, 2, 1, -5, 4};
auto p = new Solution();
ASSERT_EQ(6, p->maxSubArray(arr));
}
} | [
"junc76@gmail.com"
] | junc76@gmail.com |
950f5a023c682c0205dcbf272c3dc08cf68dc534 | 8869470cc0a34a4e668f9e328ef8cfa91487ab10 | /1015.cpp | 15cb4296872dab4f11076b5b4536c5a55123ade5 | [] | no_license | jack00000/PAT--TOP | db0465a4d589f120d6172c08c7187d0d6b266c30 | c7bc76463c0241cf4fd2b9439584aede9ebfb895 | refs/heads/master | 2021-01-11T16:01:22.013970 | 2017-01-25T05:41:42 | 2017-01-25T05:41:42 | 79,984,941 | 0 | 0 | null | null | null | null | GB18030 | C++ | false | false | 2,986 | cpp | 1015. Letter-moving Game (35)
时间限制
200 ms
内存限制
65536 kB
代码长度限制
8000 B
判题程序
Standard
作者
CAO, Peng
Here is a simple intersting letter-moving game. The game starts with 2 strings S and T consist of lower case English letters. S and T contain the same letters but the orders might be different. In other words S can be obtained by shuffling letters in String T. At each step, you can move one arbitrary letter in S either to the beginning or to the end of it. How many steps at least to change S into T?
Input Specification:
Each input file contains one test case. For each case, the first line contains the string S, and the second line contains the string T. They consist of only the lower case English letters and S can be obtained by shuffling T's letters. The length of S is no larger than 1000.
Output Specification:
For each case, print in a line the least number of steps to change S into T in the game.
Sample Input:
iononmrogdg
goodmorning
Sample Output:
8
Sample Solution:
(0) starts from iononmrogdg
(1) Move the last g to the beginning: giononmrogd
(2) Move m to the end: giononrogdm
(3) Move the first o to the end: ginonrogdmo
(4) Move r to the end: ginonogdmor
(5) Move the first n to the end: gionogdmorn
(6) Move i to the end: gonogdmorni
(7) Move the first n to the end: googdmornin
(8) Move the second g to the end: goodmorning
看似复杂的题目,其实如果换一个角度思考,其实是一道简单题。
不要从正面看,我们考虑把T串还原到S串,那么相当于把T串的两端删除一部分,重新填回去变成S串。
那么,只要保证,剩下的T串,可以在原来的S串中,找到对应的子序列,那么一定可以还原,
这样,答案就是删除掉的前后段的长度和。
为了效率,我们可以直接枚举剩余T串的起始位置,判断最长多少的剩余长度可以在S串中找到匹配。
这场顶级的压轴题意外的简单,只要能找到正确的思路。
[cpp] view plain copy 在CODE上查看代码片派生到我的代码片
#include<cmath>
#include<queue>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
#define ms(x,y) memset(x,y,sizeof(x))
#define rep(i,j,k) for(int i=j;i<=k;i++)
#define loop(i,j,k) for (int i=j;i!=-1;i=k[i])
#define inone(x) scanf("%d",&x)
#define intwo(x,y) scanf("%d%d",&x,&y)
#define inthr(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define lson x<<1,l,mid
#define rson x<<1|1,mid+1,r
const int N = 1e3 + 10;
const int INF = 0x7FFFFFFF;
char a[N], b[N];
int f[N], n, mx;
int main()
{
while (scanf("%s%s", a + 1, b + 1) != EOF)
{
n = strlen(a + 1);
rep(i, 1, n)
{
for (int j = 1, k = i; j <= n; j++)
{
if (k <= n && a[j] == b[k]) k++;
mx = max(mx, k - i);
}
}
printf("%d\n", n - mx);
}
return 0;
}
| [
"1558185399@qq.com"
] | 1558185399@qq.com |
bdb9638a26ffe243a45092748aa1a008d5287dcb | de5b28c7d6be37b33e7140835b290ebd74055a63 | /include/ilang/ila-mngr/u_unroller_smt.h | 446b71a9c43f376201685f51268e3e2f8d9ef585 | [
"MIT",
"BSD-3-Clause",
"LicenseRef-scancode-free-unknown"
] | permissive | zhanghongce/ILA-Tools | bf2797595d9283476852c05ee7eb0a067b22088a | 5ec5ff4c7c26101232a7e22bd6510a0f34bd8467 | refs/heads/master | 2023-04-13T21:14:38.283818 | 2020-10-23T02:54:25 | 2020-10-23T02:54:25 | 161,229,920 | 2 | 1 | MIT | 2018-12-10T20:03:39 | 2018-12-10T20:03:39 | null | UTF-8 | C++ | false | false | 7,012 | h | /// \file
/// Class UnrollerSmt, PathUnroller, and MonoUnroller - a collection of
/// ILA unrollers with SmtShim support.
#ifndef ILANG_ILA_MNGR_U_UNROLLER_SMT_H__
#define ILANG_ILA_MNGR_U_UNROLLER_SMT_H__
#include <map>
#include <string>
#include <vector>
#include <ilang/ila/instr_lvl_abs.h>
#include <ilang/target-smt/smt_shim.h>
#include <ilang/util/log.h>
/// \namespace ilang
namespace ilang {
/// \brief Base class for unrolling ILA execution in different settings.
template <class Generator> class UnrollerSmt {
public:
// ------------------------- CONSTRUCTOR/DESTRUCTOR ----------------------- //
/// Constructor.
UnrollerSmt(SmtShim<Generator>& smt_shim, const std::string& suffix)
: smt_gen_(smt_shim), unroller_suffix_(suffix) {}
// ------------------------- METHODS -------------------------------------- //
//
// Control property/predicate beyond the transition.
//
/// Add the predicate p to be asserted globally.
inline void AssertGlobal(const ExprPtr& p) { global_pred_.insert(p); }
/// Add the predicate p to be asserted at the first step (initial condition).
inline void AssertInitial(const ExprPtr& p) { initial_pred_.insert(p); }
/// Add the predicate p to be asserted at the k-th step.
inline void AssertStep(const ExprPtr& p, const int& k) {
step_pred_[k].insert(p);
}
/// Clear all the global assertions.
inline void ClearGlobalAssertion() { global_pred_.clear(); }
/// Clear all the initial assertions.
inline void ClearInitialAssertion() { initial_pred_.clear(); }
/// Clear all the step-specific assertions.
inline void ClearStepAssertion() { step_pred_.clear(); }
//
// Access SMT formula in the unrolled execution.
//
/// Return the SMT formula of expr at the beginning k-th step.
inline auto GetSmtCurrent(const ExprPtr& expr, const size_t& k) const {
return smt_gen_.GetShimExpr(expr, SuffixCurrent(k));
}
/// Return the SMT formula of expr at the end of k-th step.
inline auto GetSmtNext(const ExprPtr& expr, const size_t& k) const {
return smt_gen_.GetShimExpr(expr, SuffixNext(k));
}
/// Return the SMT function declaration of uninterpreted function func.
inline auto GetSmtFuncDecl(const FuncPtr& func) const {
return smt_gen_.GetShimFunc(func);
}
private:
// ------------------------- MEMBERS -------------------------------------- //
/// The underlying (templated) SMT generator.
SmtShim<Generator>& smt_gen_;
/// Unroller specific suffix.
const std::string unroller_suffix_;
/// Predicates to be asserted globally.
ExprSet global_pred_;
/// Predicates to be asserted initially.
ExprSet initial_pred_;
/// Predicates to be asserted at each step.
std::map<size_t, ExprSet> step_pred_;
// ------------------------- HELPERS -------------------------------------- //
/// Return suffix for current state.
inline std::string SuffixCurrent(const size_t& t) const {
return std::to_string(t) + "_" + unroller_suffix_;
}
/// Return suffix for next state.
inline std::string SuffixNext(const size_t& t) const {
return std::to_string(t) + "_" + unroller_suffix_ + ".nxt";
}
protected:
// ------------------------- TYPES ---------------------------------------- //
typedef decltype(smt_gen_.GetShimExpr(nullptr, "")) SmtExpr;
typedef decltype(smt_gen_.GetShimFunc(nullptr)) SmtFunc;
typedef std::vector<ExprPtr> IlaExprVec;
typedef std::vector<SmtExpr> SmtExprVec;
// ------------------------- MEMBERS -------------------------------------- //
/// Variables on which the instruction sequence depends
IlaExprVec deciding_vars_;
/// State update functions of the deciding variables
IlaExprVec update_holder_;
/// Non-execution semantics (state update) properties
IlaExprVec assert_holder_;
// ------------------------- METHODS -------------------------------------- //
/// Setup the deciding variabels
virtual void SetDecidingVars() = 0;
/// Make one transition (step) and setup the update_holder_ and assert_holder_
/// accordingly
virtual void MakeOneTransition(const size_t& idx) = 0;
/// Unroll the whole sequence
SmtExpr Unroll_(const size_t& len, const size_t& begin);
/// Unroll the whole sequence without connecting the steps
SmtExpr UnrollWithStepsUnconnected_(const size_t& len, const size_t& begin);
private:
// ------------------------- HELPERS -------------------------------------- //
inline void InterpIlaExprAndAppend(const IlaExprVec& ila_expr_src,
const std::string& suffix,
SmtExprVec& smt_expr_dst) {
for (const auto& e : ila_expr_src) {
smt_expr_dst.push_back(smt_gen_.GetShimExpr(e, suffix));
}
}
inline void InterpIlaExprAndAppend(const ExprSet& ila_expr_src,
const std::string& suffix,
SmtExprVec& smt_expr_dst) {
for (const auto& e : ila_expr_src) {
smt_expr_dst.push_back(smt_gen_.GetShimExpr(e, suffix));
}
}
inline void ElementWiseEqualAndAppend(const SmtExprVec& a,
const SmtExprVec& b,
SmtExprVec& smt_expr_dst) {
ILA_ASSERT(a.size() == b.size());
for (size_t i = 0; i < a.size(); i++) {
smt_expr_dst.push_back(smt_gen_.Equal(a.at(i), b.at(i)));
}
}
inline SmtExpr ConjunctAll(const SmtExprVec& vec) const {
auto conjunct_holder = smt_gen_.GetShimExpr(asthub::BoolConst(true));
for (const auto& e : vec) {
conjunct_holder = smt_gen_.BoolAnd(conjunct_holder, e);
}
return conjunct_holder;
}
}; // class UnrollerSmt
/// \brief Application class for unrolling a sequence of instructions.
template <class Generator> class PathUnroller : public UnrollerSmt<Generator> {
public:
// ------------------------- CONSTRUCTOR/DESTRUCTOR ----------------------- //
/// Constructor.
PathUnroller(SmtShim<Generator>& smt_shim, const std::string& suffix = "")
: UnrollerSmt<Generator>(smt_shim, suffix) {}
// ------------------------- METHODS -------------------------------------- //
/// Unroll the sequence
auto Unroll(const InstrVec& seq, const size_t& begin = 0) {
seq_ = seq;
return this->Unroll_(seq.size(), begin);
}
/// Unroll the sequence without connecting the steps
auto UnrollWithStepsUnconnected(const InstrVec& seq, const size_t& begin) {
seq_ = seq;
return this->UnrollWithStepsUnconnected_(seq.size(), begin);
}
protected:
// ------------------------- METHODS -------------------------------------- //
/// Setup the deciding variables
void SetDecidingVars();
/// Make one transition and setup holders accordingly
void MakeOneTransition(const size_t& idx);
private:
// ------------------------- MEMBERS -------------------------------------- //
/// The sequence of instructions.
InstrVec seq_;
}; // class PathUnroller
} // namespace ilang
#endif // ILANG_ILA_MNGR_U_UNROLLER_SMT_H__
| [
"byhuang1992@gmail.com"
] | byhuang1992@gmail.com |
4c4b5d284433d222fd12b9cb94e556480dccde07 | 1cece0d71f79fe991ede775181767e1a697ac374 | /tensorflow/core/util/dump_graph.cc | d275e076f865f809192e6f3aea652434d5654bb3 | [
"Apache-2.0"
] | permissive | microsoft/tensorflow-directml | 18d95a3f9ea0909fde8c1c245973eaa891e11348 | 3800a8e1cdeea062b9dac8584fb6303be7395b06 | refs/heads/directml | 2023-08-24T03:21:52.097089 | 2022-12-21T22:39:00 | 2022-12-21T22:39:00 | 291,217,084 | 459 | 43 | Apache-2.0 | 2022-12-21T22:39:02 | 2020-08-29T06:44:33 | C++ | UTF-8 | C++ | false | false | 4,355 | cc | /* Copyright 2018 The TensorFlow Authors. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
==============================================================================*/
// Helper functions for dumping Graphs, GraphDefs, and FunctionDefs to files for
// debugging.
#include "tensorflow/core/util/dump_graph.h"
#include "absl/strings/str_cat.h"
#include "tensorflow/core/lib/strings/proto_serialization.h"
#include "tensorflow/core/platform/env.h"
#include "tensorflow/core/platform/mutex.h"
namespace tensorflow {
namespace {
struct NameCounts {
mutex counts_mutex;
std::unordered_map<string, int> counts;
};
string MakeUniqueFilename(string name) {
static NameCounts& instance = *new NameCounts;
// Remove illegal characters from `name`.
for (int i = 0; i < name.size(); ++i) {
char ch = name[i];
if (ch == '/' || ch == '[' || ch == ']' || ch == '*' || ch == '?') {
name[i] = '_';
}
}
int count;
{
mutex_lock lock(instance.counts_mutex);
count = instance.counts[name]++;
}
string filename = name;
if (count > 0) {
absl::StrAppend(&filename, "_", count);
}
absl::StrAppend(&filename, ".pbtxt");
return filename;
}
#if defined(TENSORFLOW_LITE_PROTOS)
Status WriteToFile(const string& filepath,
const ::tensorflow::protobuf::MessageLite& proto) {
string s;
if (!SerializeToStringDeterministic(proto, &s)) {
return errors::Internal("Failed to serialize proto to string.");
}
return WriteStringToFile(Env::Default(), filepath, s);
}
#else
Status WriteToFile(const string& filepath,
const ::tensorflow::protobuf::Message& proto) {
return WriteTextProto(Env::Default(), filepath, proto);
}
#endif
template <class T>
string WriteTextProtoToUniqueFile(Env* env, const string& name,
const char* proto_type, T& proto,
const string& dirname) {
const char* dir = nullptr;
if (!dirname.empty()) {
dir = dirname.c_str();
} else {
dir = getenv("TF_DUMP_GRAPH_PREFIX");
}
if (!dir) {
LOG(WARNING)
<< "Failed to dump " << name << " because dump location is not "
<< " specified through either TF_DUMP_GRAPH_PREFIX environment "
<< "variable or function argument.";
return "(TF_DUMP_GRAPH_PREFIX not specified)";
}
Status status = env->RecursivelyCreateDir(dir);
if (!status.ok()) {
LOG(WARNING) << "Failed to create " << dir << " for dumping " << proto_type
<< ": " << status;
return "(unavailable)";
}
string filepath = absl::StrCat(dir, "/", MakeUniqueFilename(name));
status = WriteToFile(filepath, proto);
if (!status.ok()) {
LOG(WARNING) << "Failed to dump " << proto_type << " to file: " << filepath
<< " : " << status;
return "(unavailable)";
}
LOG(INFO) << "Dumped " << proto_type << " to " << filepath;
return filepath;
}
} // anonymous namespace
string DumpGraphDefToFile(const string& name, GraphDef const& graph_def,
const string& dirname) {
return WriteTextProtoToUniqueFile(Env::Default(), name, "GraphDef", graph_def,
dirname);
}
string DumpGraphToFile(const string& name, Graph const& graph,
const FunctionLibraryDefinition* flib_def,
const string& dirname) {
GraphDef graph_def;
graph.ToGraphDef(&graph_def);
if (flib_def) {
*graph_def.mutable_library() = flib_def->ToProto();
}
return DumpGraphDefToFile(name, graph_def, dirname);
}
string DumpFunctionDefToFile(const string& name, FunctionDef const& fdef,
const string& dirname) {
return WriteTextProtoToUniqueFile(Env::Default(), name, "FunctionDef", fdef,
dirname);
}
} // namespace tensorflow
| [
"gardener@tensorflow.org"
] | gardener@tensorflow.org |
4339b4d34d2a4a6459d732203603cac14f212ad3 | 0c27fbf4bb407efa8cb2989bfb6e002ebfecc661 | /caffe2/mobile/contrib/arm-compute/operators/conv_op.cc | b97aad1540c066387fd9c4f7544e4863f41b84d7 | [
"BSD-3-Clause",
"LicenseRef-scancode-generic-cla",
"Apache-2.0",
"BSD-2-Clause"
] | permissive | kose-y/pytorch | bd80e5819b8bfb101b433a0034f0dac7d454cf77 | 4855d2f3eb875b994d9efb2004b6258f8dee61e0 | refs/heads/master | 2020-03-08T02:33:38.114582 | 2018-04-24T13:10:34 | 2018-04-24T13:10:34 | 127,863,537 | 0 | 0 | null | 2018-04-03T06:46:27 | 2018-04-03T06:46:27 | null | UTF-8 | C++ | false | false | 4,300 | cc | #include "arm_compute/graph/Graph.h"
#include "arm_compute/graph/Nodes.h"
#include "caffe2/mobile/contrib/arm-compute/core/context.h"
#include "caffe2/mobile/contrib/arm-compute/core/operator.h"
#include "caffe2/operators/conv_op.h"
namespace caffe2 {
template <typename T>
class GLConvOp final : public ConvPoolOpBase<GLContext> {
public:
USE_CONV_POOL_BASE_FUNCTIONS(GLContext);
GLConvOp(const OperatorDef& operator_def, Workspace* ws)
: ConvPoolOpBase<GLContext>(operator_def, ws) {
// Since this is the default convolution implementation, we will
// use CAFFE_ENFORCE instead of OPERATOR_NEEDS_FEATURE.
CAFFE_ENFORCE(
group_ == 1 || order_ == StorageOrder::NCHW,
"Group convolution only supports NCHW order right now.");
}
~GLConvOp() {}
bool RunOnDevice() override;
private:
arm_compute::GCDirectConvolutionLayer conv_;
bool first_run_ = true, second_run_ = true;
GLContext::deleted_unique_ptr<const GLTensor<T>> X_, filter_, bias_;
};
template <typename T>
bool GLConvOp<T>::RunOnDevice() {
auto *Xblob = OperatorBase::Inputs()[0];
auto *filterblob = OperatorBase::Inputs()[1];
auto *biasblob = OperatorBase::Inputs()[2];
X_ = GLContext::getGLTensor<T>(Xblob, X_.release());
if (first_run_) {
filter_ = GLContext::getGLTensor<T>(filterblob);
bias_ = GLContext::getGLTensor<T>(biasblob);
}
GLTensor<T> *Y =
OperatorBase::Outputs()[0]->template GetMutable<GLTensor<T>>();
const int N = X_->dim32(0), H = X_->dim32(2), W = X_->dim32(3), C = X_->dim32(1);
LOG(INFO) << "[C2DEBUG] Conv " << N << " " << H << " " << W << " " << C;
CAFFE_ENFORCE_EQ(kernel_.size(), 2,
"Only 2d convolution is supported with ARM compute backend");
CAFFE_ENFORCE(X_->ndim(), filter_->ndim());
const int M = filter_->dim32(0);
CAFFE_ENFORCE(filter_->dim32(2) == kernel_h());
CAFFE_ENFORCE(filter_->dim32(3) == kernel_w());
CAFFE_ENFORCE(filter_->dim32(1) == C);
if (first_run_) {
first_run_ = false;
// resize output accordingly
TensorCPU fakeX;
fakeX.Resize(X_->dims());
TensorCPU fakeY;
ConvPoolOpBase<GLContext>::SetOutputSize(fakeX, &fakeY, filter_->dim32(0));
Y->ResizeLike(fakeY);
LOG(INFO) << "[C2DEBUG] dims of X " << X_->dims();
LOG(INFO) << "[C2DEBUG] dims of X(gctensor) "
<< X_->get_underlying()->info()->dimension(3) << " "
<< X_->get_underlying()->info()->dimension(2) << " "
<< X_->get_underlying()->info()->dimension(1) << " "
<< X_->get_underlying()->info()->dimension(0) << " "
;
LOG(INFO) << "[C2DEBUG] dims of Y " << Y->dims();
LOG(INFO) << "[C2DEBUG] dims of Y(gctensor) "
<< Y->get_underlying()->info()->dimension(3) << " "
<< Y->get_underlying()->info()->dimension(2) << " "
<< Y->get_underlying()->info()->dimension(1) << " "
<< Y->get_underlying()->info()->dimension(0) << " "
;
conv_.configure(
X_->get_underlying(), filter_->get_underlying(), bias_->get_underlying(),
Y->get_underlying(),
arm_compute::PadStrideInfo(stride_[0], stride_[1], pads_[0], pads_[1]));
} else if (second_run_) {
// Always attempt to copy the CPU to GPU on input
X_->lazy_allocate(Xblob, second_run_, true);
filter_->lazy_allocate(filterblob, second_run_, second_run_);
bias_->lazy_allocate(biasblob, second_run_, second_run_);
second_run_ = false;
TensorCPU fakeX;
fakeX.Resize(X_->dims());
TensorCPU fakeY;
ConvPoolOpBase<GLContext>::SetOutputSize(fakeX, &fakeY, filter_->dim32(0));
Y->ResizeLike(fakeY);
Y->allocate();
conv_.run();
} else {
X_->lazy_allocate(Xblob, second_run_, true);
TensorCPU fakeX;
fakeX.Resize(X_->dims());
TensorCPU fakeY;
ConvPoolOpBase<GLContext>::SetOutputSize(fakeX, &fakeY, filter_->dim32(0));
bool need_allocation = Y->ResizeLike(fakeY, true);
if (need_allocation) {
Y->allocate();
}
conv_.configure(
X_->get_underlying(), filter_->get_underlying(), bias_->get_underlying(),
Y->get_underlying(),
arm_compute::PadStrideInfo(stride_[0], stride_[1], pads_[0], pads_[1]));
conv_.run();
}
return true;
}
REGISTER_GL_OPERATOR(Conv, GLConvOp<DataType>);
} // namespace caffe2
| [
"noreply@github.com"
] | noreply@github.com |
d4fbe97308d3102de6f9d8f3942bfb8fde8b984c | 7fc9ca1aa8c9281160105c7f2b3a96007630add7 | /1196A.cpp | b65a3afb5bc0882d0bfcd4ecc82fb53e87feff00 | [] | no_license | PatelManav/Codeforces_Backup | 9b2318d02c42d8402c9874ae0c570d4176348857 | 9671a37b9de20f0f9d9849cd74e00c18de780498 | refs/heads/master | 2023-01-04T03:18:14.823128 | 2020-10-27T12:07:22 | 2020-10-27T12:07:22 | 300,317,389 | 2 | 1 | null | 2020-10-27T12:07:23 | 2020-10-01T14:54:31 | C++ | UTF-8 | C++ | false | false | 879 | cpp | /*May The Force Be With Me*/
#include <bits/stdc++.h>
#include <stdio.h>
#include <ctype.h>
#pragma GCC optimize ("Ofast")
#define ll long long
#define MOD 1000000007
#define endl "\n"
#define vll vector<long long>
#define pll pair<long long, long long>
#define all(c) c.begin(),c.end()
#define pb push_back
#define f first
#define s second
#define inf INT_MAX
#define size_1d 10000000
#define size_2d 1000
//Snippets: graph, segtree, delta, sieve, fastexp
using namespace std;
ll a, b, c;
void Input() {
cin >> a >> b >> c;
}
void Solve() {
cout << (a + b + c) / 2 << endl;
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
ll T = 1;
cin >> T;
//ll t = 1;
while (T--) {
Input();
//cout << "Case " << t << ": ";
Solve();
//t++;
}
return 0;
} | [
"helewrer3@gmail.com"
] | helewrer3@gmail.com |
a6cd048d3cb5992c4480d3dfbc68fcd9031698b3 | 020971797f9fa0a00b90238f9beaf77c2b368539 | /src/plane_line_intersector.cpp | b73174ce3646a31ec6182e7c6e1cd8d0d3d1cf45 | [] | no_license | oussamaabdulhay/d435iCamera | d271769de056a3c42c272df130f29beb9d6dd91c | ab9e978a2d1cb63c6a92032d62370d5094004562 | refs/heads/master | 2023-03-11T08:34:08.559064 | 2021-02-25T14:09:07 | 2021-02-25T14:09:07 | 286,220,590 | 0 | 1 | null | 2021-02-24T14:11:42 | 2020-08-09T11:09:19 | C++ | UTF-8 | C++ | false | false | 4,163 | cpp | #include "plane_line_intersector.hpp"
using namespace std;
plane_line_intersector::plane_line_intersector()
{
p_d_c.x = 0.1308;
p_d_c.y = 0.038;
p_d_c.z = -0.1137;
plane_point1.x=1.021;
plane_point1.y=3.127;
plane_point1.z=1.629;
plane_point2.x=0.244;
plane_point2.y=3.1517;
plane_point2.z=1.9122;
plane_point3.x=-0.535;
plane_point3.y=3.188;
plane_point3.z=1.495;
projection_plane.p0=plane_point1;
projection_plane.p1=plane_point2;
projection_plane.p2=plane_point3;
inertial_plane_offset=(plane_point1.y+plane_point2.y+plane_point3.y)/3.0;
this->_input_port_0 = new InputPort(ports_id::IP_0_UNIT_VEC, this);
this->_input_port_1 = new InputPort(ports_id::IP_1_DEPTH_DATA, this);
this->_input_port_2 = new InputPort(ports_id::IP_2_ROLL, this);
this->_input_port_3 = new InputPort(ports_id::IP_3_PITCH, this);
this->_input_port_4 = new InputPort(ports_id::IP_4_YAW, this);
this->_output_port_0 = new OutputPort(ports_id::OP_0_DATA, this);
this->_output_port_1 = new OutputPort(ports_id::OP_1_DATA, this);
this->_output_port_2 = new OutputPort(ports_id::OP_2_DATA, this);
this->_output_port_3 = new OutputPort(ports_id::OP_3_DATA, this);
_ports = {_input_port_0, _input_port_1, _input_port_2, _input_port_3, _input_port_4, _output_port_0, _output_port_1, _output_port_2, _output_port_3};
}
plane_line_intersector::~plane_line_intersector()
{
}
void plane_line_intersector::process(DataMsg* t_msg, Port* t_port) {
Vector3DMsg *provider = (Vector3DMsg *)t_msg;
if(t_port->getID() == ports_id::IP_0_UNIT_VEC)
{
rotated_pixel_vector.x=provider->data.x;
rotated_pixel_vector.y=provider->data.y;
rotated_pixel_vector.z=provider->data.z;
this->get_object_location();
}
else if(t_port->getID() == ports_id::IP_1_DEPTH_DATA) //TODO: Caution about update rate
{
depth=provider->data.x;
}
else if(t_port->getID() == ports_id::IP_2_ROLL)
{
drone_orientation.x =provider->data.x;
}
else if(t_port->getID() == ports_id::IP_3_PITCH)
{
drone_orientation.y =provider->data.x;
}
else if(t_port->getID() == ports_id::IP_4_YAW)
{
drone_orientation.z =provider->data.x;
}
}
Vector3D<float> plane_line_intersector::rotate_offset()
{
Eigen::Matrix<float, 3, 3> R_body_to_inertial_temp(3, 3);
RotationMatrix3by3 R_b_i;
R_body_to_inertial_temp = R_b_i.Update(drone_orientation); //Create the rotation matrices
R_body_to_inertial_temp.transposeInPlace(); //drone to inertial
Vector3D<float> t_results;
t_results.x = p_d_c.x * R_body_to_inertial_temp(0, 0) + p_d_c.y * R_body_to_inertial_temp(0, 1) + p_d_c.z * R_body_to_inertial_temp(0, 2);
t_results.y = p_d_c.x * R_body_to_inertial_temp(1, 0) + p_d_c.y * R_body_to_inertial_temp(1, 1) + p_d_c.z * R_body_to_inertial_temp(1, 2);
t_results.z = p_d_c.x * R_body_to_inertial_temp(2, 0) + p_d_c.y * R_body_to_inertial_temp(2, 1) + p_d_c.z * R_body_to_inertial_temp(2, 2);
return t_results;
}
Vector3D<float> plane_line_intersector::get_object_location()
{
Vector3D<float> object_location,data_transmitted_bo, data_transmitted_ao;
object_location.x= (rotated_pixel_vector.x * 3.80) / rotated_pixel_vector.y;
object_location.y= 3.80;
object_location.z=(rotated_pixel_vector.z * 3.80) / rotated_pixel_vector.y;
data_transmitted_bo.x = object_location.x;
data_transmitted_bo.y = object_location.y;
data_transmitted_bo.z = object_location.z;
Vector3DMsg data_before_offset;
data_before_offset.data = data_transmitted_bo;
this->_output_port_0->receiveMsgData(&data_before_offset);
Vector3D<float> rotated_offset = rotate_offset();
data_transmitted_ao.x = object_location.x + rotated_offset.x;
data_transmitted_ao.y = object_location.y + rotated_offset.y;
data_transmitted_ao.z = object_location.z + rotated_offset.x;
Vector3DMsg data_after_offset;
data_after_offset.data = data_transmitted_ao;
this->_output_port_1->receiveMsgData(&data_after_offset);
} | [
"oussama.abdulhay@gmail.com"
] | oussama.abdulhay@gmail.com |
35c569ffe4138ad829f55003aed980f3561a2b55 | c322776b39fd9a7cd993f483a5384b700b0c520e | /tesseract.mod/src/ccstruct/quspline.cpp | 22609b41c61c1927efce6e8f2a4e1dcb138a61cc | [
"LicenseRef-scancode-unknown-license-reference",
"Apache-2.0"
] | permissive | maxmods/bah.mod | c1af2b009c9f0c41150000aeae3263952787c889 | 6b7b7cb2565820c287eaff049071dba8588b70f7 | refs/heads/master | 2023-04-13T10:12:43.196598 | 2023-04-04T20:54:11 | 2023-04-04T20:54:11 | 14,444,179 | 28 | 26 | null | 2021-11-01T06:50:06 | 2013-11-16T08:29:27 | C++ | UTF-8 | C++ | false | false | 13,077 | cpp | /**********************************************************************
* File: quspline.cpp (Formerly qspline.c)
* Description: Code for the QSPLINE class.
* Author: Ray Smith
* Created: Tue Oct 08 17:16:12 BST 1991
*
* (C) Copyright 1991, Hewlett-Packard 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 "mfcpch.h"
#include "memry.h"
#include "quadlsq.h"
#include "quspline.h"
// Include automatically generated configuration file if running autoconf.
#ifdef HAVE_CONFIG_H
#include "config_auto.h"
#endif
#define QSPLINE_PRECISION 16 //no of steps to draw
/**********************************************************************
* QSPLINE::QSPLINE
*
* Constructor to build a QSPLINE given the components used in the old code.
**********************************************************************/
QSPLINE::QSPLINE( //constructor
inT32 count, //no of segments
inT32 *xstarts, //start coords
double *coeffs //coefficients
) {
inT32 index; //segment index
//get memory
xcoords = (inT32 *) alloc_mem ((count + 1) * sizeof (inT32));
quadratics = (QUAD_COEFFS *) alloc_mem (count * sizeof (QUAD_COEFFS));
segments = count;
for (index = 0; index < segments; index++) {
//copy them
xcoords[index] = xstarts[index];
quadratics[index] = QUAD_COEFFS (coeffs[index * 3],
coeffs[index * 3 + 1],
coeffs[index * 3 + 2]);
}
//right edge
xcoords[index] = xstarts[index];
}
/**********************************************************************
* QSPLINE::QSPLINE
*
* Constructor to build a QSPLINE by appproximation of points.
**********************************************************************/
QSPLINE::QSPLINE ( //constructor
int xstarts[], //spline boundaries
int segcount, //no of segments
int xpts[], //points to fit
int ypts[], int pointcount, //no of pts
int degree //fit required
) {
register int pointindex; /*no along text line */
register int segment; /*segment no */
inT32 *ptcounts; //no in each segment
QLSQ qlsq; /*accumulator */
segments = segcount;
xcoords = (inT32 *) alloc_mem ((segcount + 1) * sizeof (inT32));
ptcounts = (inT32 *) alloc_mem ((segcount + 1) * sizeof (inT32));
quadratics = (QUAD_COEFFS *) alloc_mem (segcount * sizeof (QUAD_COEFFS));
memmove (xcoords, xstarts, (segcount + 1) * sizeof (inT32));
ptcounts[0] = 0; /*none in any yet */
for (segment = 0, pointindex = 0; pointindex < pointcount; pointindex++) {
while (segment < segcount && xpts[pointindex] >= xstarts[segment]) {
segment++; /*try next segment */
/*cumulative counts */
ptcounts[segment] = ptcounts[segment - 1];
}
ptcounts[segment]++; /*no in previous partition */
}
while (segment < segcount) {
segment++;
/*zero the rest */
ptcounts[segment] = ptcounts[segment - 1];
}
for (segment = 0; segment < segcount; segment++) {
qlsq.clear ();
/*first blob */
pointindex = ptcounts[segment];
if (pointindex > 0
&& xpts[pointindex] != xpts[pointindex - 1]
&& xpts[pointindex] != xstarts[segment])
qlsq.add (xstarts[segment],
ypts[pointindex - 1]
+ (ypts[pointindex] - ypts[pointindex - 1])
* (xstarts[segment] - xpts[pointindex - 1])
/ (xpts[pointindex] - xpts[pointindex - 1]));
for (; pointindex < ptcounts[segment + 1]; pointindex++) {
qlsq.add (xpts[pointindex], ypts[pointindex]);
}
if (pointindex > 0 && pointindex < pointcount
&& xpts[pointindex] != xstarts[segment + 1])
qlsq.add (xstarts[segment + 1],
ypts[pointindex - 1]
+ (ypts[pointindex] - ypts[pointindex - 1])
* (xstarts[segment + 1] - xpts[pointindex - 1])
/ (xpts[pointindex] - xpts[pointindex - 1]));
qlsq.fit (degree);
quadratics[segment].a = qlsq.get_a ();
quadratics[segment].b = qlsq.get_b ();
quadratics[segment].c = qlsq.get_c ();
}
free_mem(ptcounts);
}
/**********************************************************************
* QSPLINE::QSPLINE
*
* Constructor to build a QSPLINE from another.
**********************************************************************/
QSPLINE::QSPLINE( //constructor
const QSPLINE &src) {
segments = 0;
xcoords = NULL;
quadratics = NULL;
*this = src;
}
/**********************************************************************
* QSPLINE::~QSPLINE
*
* Destroy a QSPLINE.
**********************************************************************/
QSPLINE::~QSPLINE ( //constructor
) {
if (xcoords != NULL) {
free_mem(xcoords);
xcoords = NULL;
}
if (quadratics != NULL) {
free_mem(quadratics);
quadratics = NULL;
}
}
/**********************************************************************
* QSPLINE::operator=
*
* Copy a QSPLINE
**********************************************************************/
QSPLINE & QSPLINE::operator= ( //assignment
const QSPLINE & source) {
if (xcoords != NULL)
free_mem(xcoords);
if (quadratics != NULL)
free_mem(quadratics);
segments = source.segments;
xcoords = (inT32 *) alloc_mem ((segments + 1) * sizeof (inT32));
quadratics = (QUAD_COEFFS *) alloc_mem (segments * sizeof (QUAD_COEFFS));
memmove (xcoords, source.xcoords, (segments + 1) * sizeof (inT32));
memmove (quadratics, source.quadratics, segments * sizeof (QUAD_COEFFS));
return *this;
}
/**********************************************************************
* QSPLINE::step
*
* Return the total of the step functions between the given coords.
**********************************************************************/
double QSPLINE::step( //find step functions
double x1, //between coords
double x2) {
int index1, index2; //indices of coords
double total; /*total steps */
index1 = spline_index (x1);
index2 = spline_index (x2);
total = 0;
while (index1 < index2) {
total +=
(double) quadratics[index1 + 1].y ((float) xcoords[index1 + 1]);
total -= (double) quadratics[index1].y ((float) xcoords[index1 + 1]);
index1++; /*next segment */
}
return total; /*total steps */
}
/**********************************************************************
* QSPLINE::y
*
* Return the y value at the given x value.
**********************************************************************/
double QSPLINE::y( //evaluate
double x //coord to evaluate at
) const {
inT32 index; //segment index
index = spline_index (x);
return quadratics[index].y (x);//in correct segment
}
/**********************************************************************
* QSPLINE::spline_index
*
* Return the index to the largest xcoord not greater than x.
**********************************************************************/
inT32 QSPLINE::spline_index( //evaluate
double x //coord to evaluate at
) const {
inT32 index; //segment index
inT32 bottom; //bottom of range
inT32 top; //top of range
bottom = 0;
top = segments;
while (top - bottom > 1) {
index = (top + bottom) / 2; //centre of range
if (x >= xcoords[index])
bottom = index; //new min
else
top = index; //new max
}
return bottom;
}
/**********************************************************************
* QSPLINE::move
*
* Reposition spline by vector
**********************************************************************/
void QSPLINE::move( // reposition spline
ICOORD vec // by vector
) {
inT32 segment; //index of segment
inT16 x_shift = vec.x ();
for (segment = 0; segment < segments; segment++) {
xcoords[segment] += x_shift;
quadratics[segment].move (vec);
}
xcoords[segment] += x_shift;
}
/**********************************************************************
* QSPLINE::overlap
*
* Return TRUE if spline2 overlaps this by no more than fraction less
* than the bounds of this.
**********************************************************************/
BOOL8 QSPLINE::overlap( //test overlap
QSPLINE *spline2, //2 cannot be smaller
double fraction //by more than this
) {
int leftlimit; /*common left limit */
int rightlimit; /*common right limit */
leftlimit = xcoords[1];
rightlimit = xcoords[segments - 1];
/*or too non-overlap */
if (spline2->segments < 3 || spline2->xcoords[1] > leftlimit + fraction * (rightlimit - leftlimit)
|| spline2->xcoords[spline2->segments - 1] < rightlimit
- fraction * (rightlimit - leftlimit))
return FALSE;
else
return TRUE;
}
/**********************************************************************
* extrapolate_spline
*
* Extrapolates the spline linearly using the same gradient as the
* quadratic has at either end.
**********************************************************************/
void QSPLINE::extrapolate( //linear extrapolation
double gradient, //gradient to use
int xmin, //new left edge
int xmax //new right edge
) {
register int segment; /*current segment of spline */
int dest_segment; //dest index
int *xstarts; //new boundaries
QUAD_COEFFS *quads; //new ones
int increment; //in size
increment = xmin < xcoords[0] ? 1 : 0;
if (xmax > xcoords[segments])
increment++;
if (increment == 0)
return;
xstarts = (int *) alloc_mem ((segments + 1 + increment) * sizeof (int));
quads =
(QUAD_COEFFS *) alloc_mem ((segments + increment) * sizeof (QUAD_COEFFS));
if (xmin < xcoords[0]) {
xstarts[0] = xmin;
quads[0].a = 0;
quads[0].b = gradient;
quads[0].c = y (xcoords[0]) - quads[0].b * xcoords[0];
dest_segment = 1;
}
else
dest_segment = 0;
for (segment = 0; segment < segments; segment++) {
xstarts[dest_segment] = xcoords[segment];
quads[dest_segment] = quadratics[segment];
dest_segment++;
}
xstarts[dest_segment] = xcoords[segment];
if (xmax > xcoords[segments]) {
quads[dest_segment].a = 0;
quads[dest_segment].b = gradient;
quads[dest_segment].c = y (xcoords[segments])
- quads[dest_segment].b * xcoords[segments];
dest_segment++;
xstarts[dest_segment] = xmax + 1;
}
segments = dest_segment;
free_mem(xcoords);
free_mem(quadratics);
xcoords = (inT32 *) xstarts;
quadratics = quads;
}
/**********************************************************************
* QSPLINE::plot
*
* Draw the QSPLINE in the given colour.
**********************************************************************/
#ifndef GRAPHICS_DISABLED
void QSPLINE::plot( //draw it
ScrollView* window, //window to draw in
ScrollView::Color colour //colour to draw in
) const {
inT32 segment; //index of segment
inT16 step; //index of poly piece
double increment; //x increment
double x; //x coord
window->Pen(colour);
for (segment = 0; segment < segments; segment++) {
increment =
(double) (xcoords[segment + 1] -
xcoords[segment]) / QSPLINE_PRECISION;
x = xcoords[segment];
for (step = 0; step <= QSPLINE_PRECISION; step++) {
if (segment == 0 && step == 0)
window->SetCursor(x, quadratics[segment].y (x));
else
window->DrawTo(x, quadratics[segment].y (x));
x += increment;
}
}
}
#endif
| [
"woollybah@b77917fb-863c-0410-9a43-030a88dac9d3"
] | woollybah@b77917fb-863c-0410-9a43-030a88dac9d3 |
ad08dace8ff007c3581156f81e4f3b1942a15762 | 4424a2e4d02907ebba98952b3460660a6d106b0f | /classexamples/analogInOut/analogInOut.ino | 79f5f89af75f241432eb630a02b65b56f94c3c87 | [] | no_license | zevenrodriguez/CIM542-642 | df22f12ea9cf809398383627a6a3d8bf1cfa90c0 | 8bcd46c2f98651b3b9bbade57e85fa5b1f59069b | refs/heads/master | 2021-01-11T23:59:46.399096 | 2020-05-05T18:31:55 | 2020-05-05T18:31:55 | 78,655,589 | 5 | 9 | null | null | null | null | UTF-8 | C++ | false | false | 803 | ino | int ledpin = 3;
int analogpin = A0;
int potRead = 0;
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
pinMode(ledpin, OUTPUT);
}
void loop() {
// put your main code here, to run repeatedly:
potRead = analogRead(analogpin);
//potRead = potRead/4;
//int mappedValue = map(potRead,0,1023,0,255); //led mapped value
//int mappedValue = map(potRead,330,960,31,4978); // tone mapped value
int mappedValue = map(potRead,330,960,31,4978); // tone mapped value photocell
if(mappedValue < 31){
mappedValue = 31;
}
if(mappedValue > 4978){
mappedValue = 4978;
}
Serial.print("Mapped Value: ");
Serial.print(mappedValue);
Serial.print(" potRead: ");
Serial.println(potRead);
//analogWrite(ledpin,mappedValue);
tone(ledpin,mappedValue);
}
| [
"zevenrodriguez@gmail.com"
] | zevenrodriguez@gmail.com |
ec9b599a018a1252ab290d2e7677d1d7bb2e0419 | 90e56431ed404efdad0fbccfa7c18ca7c0ac56c5 | /src/Clone.h | da42db3c462011950b3adea4d7f44e3fa9e2c5d5 | [] | no_license | laserpilot/SyphonFaceSubstitution | 60fbeaeeadc2d42e515c9ad634d3a289ef212a19 | 2421ea9f95b2a63db807ec9bd4db045a681c3a55 | refs/heads/master | 2020-06-04T09:35:58.790476 | 2015-01-30T20:37:24 | 2015-01-30T20:37:24 | 24,922,906 | 17 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 387 | h | #pragma once
#include "ofMain.h"
class Clone {
public:
void setup(int width, int height);
void setStrength(int strength);
void update(ofTexture& src, ofTexture& dst, ofTexture& mask);
void draw(float x, float y);
protected:
void maskedBlur(ofTexture& tex, ofTexture& mask, ofFbo& result);
ofFbo buffer, srcBlur, dstBlur;
ofShader maskBlurShader, cloneShader;
int strength;
}; | [
"blair@fakelove.tv"
] | blair@fakelove.tv |
7abdfa92229c6ee950beb80996f8611aba99498a | 2bca246e73ef16f30a522e6b70e4a4394b6d881b | /Minuit/include/MinuitParameter.h | 323123157da045724f45e5ee9ed7a190473132ce | [
"MIT"
] | permissive | lulzzz/ESsistMe | 8968558fd2814f970b701441b0d794c655bf30ce | 936cf32032b79212d8116125ebb81c79c0892558 | refs/heads/master | 2021-04-18T18:48:01.031766 | 2017-02-03T04:40:21 | 2017-02-03T04:40:21 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 20,404 | h | #ifndef MN_MinuitParameter_H_
#define MN_MinuitParameter_H_
#include <cstring>
#include <algorithm>
#include <memory>
// Define this to have extensions like linking and parameter sets
#define MINUIT_EXTENDED 1
#include <cassert>
#if MINUIT_EXTENDED
class MinuitParameterSet; // forward declaration
#include <vector>
#include <cmath>
#include <iostream>
//#include <sstream>
#define ASSERT_MSG(what,msg) if(!(what)) {printf("debug : Parameter : %s\n",msg);::exit(0);}
/* as wxCHECK2 but with a message explaining why we fail */
#define CHECK2_MSG(what, op, msg) if (!(what)) {printf("debug : Parameter : %s\n",msg); op; }
//#define MnPmNameLength 15
#else
#endif // MINUIT_EXTENDED
#define MnPmNameLength 11
/*! @class MinuitParameter
Class for the individual Minuit parameter with name and number;
contains the input numbers for the minimization or the output result
from minimization;
possible interactions: fix/release, set/remove limits, set value/error;
*/
#if MINUIT_EXTENDED
/*!
The parameters can be linked in two different ways.
-# In the first way the individual parameter records are linked together
This mode links this _slave_ MinuitParameter of some MinuitParameterSet
to some individual _master_ MinuitParameter of some MinuitParameterSet
Each record contains a MasterPointer, pointing to the master MinuitParameterSet,
MasterParameterNo gives the index of MinuitParameter in the _master_ MinuitParameterSet
When linking, the _slave_ MinuitParameter will be stored in the
_master_ 'MinuitParameterSet' AffectedList list
-# In the second way the parameter sets are linked together:
This mode links this _slave_ MinuitParameterSet to some other _master_ MinuitParameterSet.
MasterPointer points to the attached MinuitParameterSet,
MinuitParameterSet maintains two lists:
AttachmentList : holds the list of IDs of "MinuitParameterSet"s,
which affect this one.
AffectedList: holds the list of the MinuitParameterSet which are
affected by this one.
*/
#endif // MINUIT_EXTENDED
class MinuitParameter {
public:
#if MINUIT_EXTENDED
friend std::ostream& operator << (std::ostream &oss, const MinuitParameter &t);
friend std::istream& operator>> (std::istream &in, MinuitParameter &t);
/// pm attribute indices
enum pmAttributeIndex{ pmLimLow = 0, pmValue, pmLimHigh, pmError, pmWidth, pmPrecision, pmIntegerForm };
/// Parameter record link modes
enum pmLinkMode{
pmNoLink =0x00, ///< The parameter is NOT linked
pmReplaceLink, ///< = Master(MasterParNo)
pmAddLink, ///< = This[ParNo] + Master[MasterParNo]
pmMultiplyLink, ///< = This[ParNo] * Master[MasterParNo]
pm1LinkHigh = pmMultiplyLink,///< The highest possible 1-pm linking mode
pm2ParLinkMask = 0x10, ///< The mode bit signaling 2-pm linking
pm2LinearLink, ///< = This[ParNo] * Master[MasterParNo+1] + Master[MasterParNo]
pm2FWHMLinearLink, ///< = This[0] * Master[MasterParNo+1] + Master[MasterParNo]
pm2LinkHigh = pm2FWHMLinearLink ///< The highest possible 2-pm linking mode
};
/// Character representation of the link modes
#define pmNoLinkChar '@'
#define pmReplaceLinkChar '='
#define pmAddLinkChar '+'
#define pmMultiplyLinkChar '*'
#define pm2LinearLinkChar 'L'
#define pm2FWHMLinearLinkChar 'W'
#endif // MINUIT_EXTENDED
char pmLinkChars[4] = {pmNoLinkChar,pmReplaceLinkChar,pmAddLinkChar,pmMultiplyLinkChar};
std::string pmLinkStrings[4] = {("No link"), ("Replace"), ("Add"), ("Multiply") };
/*!
* @brief constructor for constant parameter
*
* @param[in] num Number of the parameter
* @param[in] name String ID of the parameter
* @param[in] val Value of the parameter
*/
MinuitParameter(unsigned int num, const char* name, double val) :
theNum(num), theValue(val), theError(0.), theConst(true), theFix(false),
theLoLimit(0.), theUpLimit(0.), theLoLimValid(false), theUpLimValid(false)
#if MINUIT_EXTENDED
,theWidth(8), theDecimals(2), LinkMode(pmNoLink), m_MySet(NULL), MasterPtr(NULL)
,MasterParameterNo(0), m_UserIndex(-1)
#endif // MINUIT_EXTENDED
{
setName(name);
}
/*!
* @brief constructor for standard parameter
*
* @param[in] num Sequence number of the parameter
* @param[in] name String ID of the parameter
* @param[in] val Value of the parameter
* @param[in] err Error of the parameter
*/
MinuitParameter(unsigned int num, const char* name, double val, double err) :
theNum(num), theValue(val), theError(err), theConst(false), theFix(false),
theLoLimit(0.), theUpLimit(0.), theLoLimValid(false), theUpLimValid(false)
#if MINUIT_EXTENDED
,theWidth(8), theDecimals(2), LinkMode(pmNoLink), m_MySet(NULL), MasterPtr(NULL)
,MasterParameterNo(0),m_UserIndex(-1)
#endif // MINUIT_EXTENDED
{
setName(name);
}
/*!
* @brief constructor for limited parameter
*
* @param[in] num Number of the parameter
* @param[in] name String ID of the parameter
* @param[in] val Value of the parameter
* @param[in] err Error of the parameter
* @param[in] min Minimum value of the parameter
* @param[in] max Maximum value of the parameter
*/
MinuitParameter(unsigned int num, const char* name, double val, double err,
double min, double max) :
theNum(num),theValue(val), theError(err), theConst(false), theFix(false),
theLoLimit(min), theUpLimit(max), theLoLimValid(true), theUpLimValid(true)
#if MINUIT_EXTENDED
,theWidth(8), theDecimals(2), LinkMode(pmNoLink), m_MySet(NULL), MasterPtr(NULL)
,MasterParameterNo(0),m_UserIndex(-1)
#endif // MINUIT_EXTENDED
{
assert(min != max);
if(min > max) {
theLoLimit = max;
theUpLimit = min;
}
setName(name);
}
~MinuitParameter() {}
/*!
* @brief Copy constructor
*
* @param[in] par Parameter to be copied
*/
MinuitParameter(const MinuitParameter& par) :
theNum(par.theNum), theValue(par.theValue), theError(par.theError),
theConst(par.theConst), theFix(par.theFix), theLoLimit(par.theLoLimit),
theUpLimit(par.theUpLimit), theLoLimValid(par.theLoLimValid),
theUpLimValid(par.theUpLimValid)
#if MINUIT_EXTENDED
,theWidth(par.theWidth), theDecimals(par.theDecimals), LinkMode(par.LinkMode)
,m_MySet(par.m_MySet), MasterPtr(par.MasterPtr),MasterParameterNo(par.MasterParameterNo),m_UserIndex(par.m_UserIndex)
#endif // MINUIT_EXTENDED
{
memcpy(theName, par.name(), MnPmNameLength*sizeof(char));
}
#if MINUIT_EXTENDED
/// This quasi-copy constructor makes a copy for the user-parameter vector
MinuitParameter(const unsigned int n, MinuitParameter& par, char *parname) :
theNum(n), theValue(par.theValue), theError(par.theError),
theConst(par.theConst), theFix(par.theFix), theLoLimit(par.theLoLimit),
theUpLimit(par.theUpLimit), theLoLimValid(par.theLoLimValid),
theUpLimValid(par.theUpLimValid)
,theWidth(par.theWidth), theDecimals(par.theDecimals), LinkMode(par.LinkMode),
m_MySet(par.m_MySet), MasterPtr(par.MasterPtr), MasterParameterNo(par.MasterParameterNo), m_UserIndex(n)
{
memcpy(theName, parname, MnPmNameLength*sizeof(char));
par.m_UserIndex = n; // remember index in the original copy
}
#endif // MINUIT_EXTENDED
MinuitParameter& operator=(const MinuitParameter& par) {
theNum = par.theNum;
memcpy(theName, par.theName, MnPmNameLength*sizeof(char));
theValue = par.theValue;
theError = par.theError;
theConst = par.theConst;
theFix = par.theFix;
theLoLimit = par.theLoLimit;
theUpLimit = par.theUpLimit;
theLoLimValid = par.theLoLimValid;
theUpLimValid = par.theUpLimValid;
#if MINUIT_EXTENDED
theWidth = par.theWidth;
theDecimals = par.theDecimals;
LinkMode = par.LinkMode;
m_MySet = par.m_MySet;
MasterPtr = par.MasterPtr;
MasterParameterNo = par.MasterParameterNo;
m_UserIndex = par.m_UserIndex;
#endif // MINUIT_EXTENDED
return *this;
}
//access methods
unsigned int number() const {return theNum;}
const char* name() const {return theName;}
#if MINUIT_EXTENDED
/// Return link mode corresponding to Ch
static pmLinkMode Char2LinkMode( const char Ch);
/// Return parameter set label
const char* GetLabel(void) const
{ return theName;}
// Attribute-related functions
/// Return parameter value
double GetParameterValue(bool Unlinked=false)
{ return value(Unlinked);}
/// Return user index
inline int GetUserIndex(void) const { return m_UserIndex;}
/// Return true if the new value V is different from the cuurnt one
inline bool IsValueDifferentFrom(const double V) const
{ return fabs(V-value())>fabs(V+value())*1E-6;}
/// Set the parameter attribute 'value'
bool SetParameterValue(double V, const bool Forced = false, bool Unlinked = false);
// Formatted output related stuff
/// Return the selected attribute formatted as string
const std::string GetFormattedItem(const pmAttributeIndex ItemIndex, bool linked=true, const int FillUp = 0);
/// General purpose formatting routine
static const std::string GetFormatted(const double val, int P, const int W=8,
const bool IsInteger = false, const int FillUp = 0);
/// Return the value attribute formatted as string
const std::string GetFormattedValue(bool linked=true, const int FillUp = 0);
/// Return precision parameter in the output format
inline short GetDecimals(void) const { return theDecimals;}
inline short GetWidth(void) const { return theWidth;}
// Link-related functions
/// Return the master info in string form
const std::string GetLinkedToString(void);
/// Return the link mode of the record
inline pmLinkMode GetLinkMode(void) const { return LinkMode;}
/// Return a char corresponding to the link mode
char GetLinkModeChar(void);
std::string GetLinkModeString(void) {return pmLinkStrings[LinkMode];}
/// Return the number of the slaves, linked to this master
inline short int GetMasterCount(void) const { return Slaves.size();}
/// Return parameter number in master parameterset
inline short int GetMasterParameterNo(void) const { return MasterParameterNo;}
/// Return pointer to the set the parameter belongs to
MinuitParameterSet *GetMyParameterSet(void) const { return m_MySet;}
/// Return pointer to the master
inline MinuitParameterSet *GetMasterPointer(void) const { return MasterPtr;}
/// Set the master pointer
inline void SetMasterPointer(MinuitParameterSet *P){MasterPtr = P;}
/// Return true if the parameter record is linked to a master parameter record
inline bool IsSlave(void) const
{ return !(NULL==MasterPtr);}
/// Return true if the pm is master for some other pm
inline bool IsMaster(void) const
{ return GetMasterCount()>0;}
/// Set the link mode given by char Ch. Return the link mode
short SetLinkModeByChar(const char Ch);
// Fixing-mask related functions
/// Return true if the parameter value is fixed
//FIXME inline bool IsFixed(void) const
// { return IsFlagSet(pmFixedValue);}
/// Return true if the requested but is set in the flag word
//FIXME inline bool IsFlagSet(const int NewFlag) const
// { return (Flags & NewFlag) == NewFlag;}
/// Clear bits(s) in fixing mask
//FIXME inline void ClearFlag(pmFixingMask NewFlag)
// { Flags = (pmFixingMask) (Flags & ~NewFlag);}
/// Toggle bit(s) in the fixing mask
//FIXME inline void ToggleFlag(const short int NewFlag)
// { Flags = (pmFixingMask)(Flags ^ NewFlag);}
protected:
/// Link this parameter to a parameter of a master parameter set
bool LinkTo(MinuitParameterSet *aMaster, const unsigned short int aMParNo, const pmLinkMode aLinkMode, MinuitParameterSet *aSlave);
/// Unlink the parameter record from its master
bool UnlinkFrom(MinuitParameterSet *aSlave);
public:
double value(bool Unlinked=false) const;
/// Set the parameter attribute 'value'
void setValue(double V, const bool Forced = false, bool Unlinked = false);
/// Return if value changed significantly in last 'setValue'
bool HasChanged() const { return m_changed;}
/// Return sequence ID whithin the set
#else
public:
double value() const {return theValue;}
void setValue(double val) {theValue = val;}
#endif // MINUIT_EXTENDED
//interaction
double error() const {return theError;}
void setError(double err) {theError = err;}
void setLimits(double low, double up) {
assert(low != up);
theLoLimit = low;
theUpLimit = up;
theLoLimValid = true;
theUpLimValid = true;
if(theValue>theUpLimit)theValue=theUpLimit;
if(theValue<theLoLimit)theValue=theLoLimit;
if(low > up) {
theLoLimit = up;
theUpLimit = low;
}
}
void setUpperLimit(double up) {
theLoLimit = 0.;
theUpLimit = up;
theLoLimValid = false;
theUpLimValid = true;
}
void setLowerLimit(double low) {
theLoLimit = low;
theUpLimit = 0.;
theLoLimValid = true;
theUpLimValid = false;
}
void removeLimits() {
theLoLimit = 0.;
theUpLimit = 0.;
theLoLimValid = false;
theUpLimValid = false;
}
void fix() {theFix = true;}
void release() {theFix = false;}
//state of parameter (fixed/const/limited)
bool isConst() const {return theConst;}
bool isFixed() const {return theFix;}
bool hasLimits() const {return theLoLimValid || theUpLimValid; }
bool hasLowerLimit() const {return theLoLimValid; }
bool hasUpperLimit() const {return theUpLimValid; }
double lowerLimit() const {return theLoLimit;}
double upperLimit() const {return theUpLimit;}
private:
unsigned int theNum;
char theName[MnPmNameLength];
double theValue;
double theError;
bool theConst;
bool theFix;
double theLoLimit;
double theUpLimit;
bool theLoLimValid;
bool theUpLimValid;
#if MINUIT_EXTENDED
unsigned short int theWidth; ///< Total width of the parameter value
short int theDecimals; ///< The decimal digits after the decimal point
pmLinkMode LinkMode; ///< Store link mode code if MasterPtr is set
MinuitParameterSet *m_MySet; ///< The parameter belongs to this set
MinuitParameterSet *MasterPtr; ///< Points back to the master, or NULL
short int MasterParameterNo; ///< Store parameter# if MasterPtr is set
int m_UserIndex; ///< Index of the pm in the Minuit array
std::vector <MinuitParameterSet*> Slaves ; ///< Pointers to the affected slaves
bool m_changed; ///< If the value changed significantly in last 'set'
// pmFixingMask Flags; ///< Store which of the parameters are fixed
friend class MinuitParameterSet; ///< Allow to handle attributes from the set
#endif // MINUIT_EXTENDED
private:
void setName(const char* name) {
int l = std::min(int(strlen(name)), MnPmNameLength);
memset(theName, 0, MnPmNameLength*sizeof(char));
memcpy(theName, name, l*sizeof(char));
theName[MnPmNameLength-1] = '\0';
}
};
#if MINUIT_EXTENDED
/// The "parameter set" structure: set of parameters
class MinuitParameterSet
{
friend std::ostream& operator << (std::ostream &oss, const MinuitParameterSet &t);
friend std::istream& operator>> (std::istream &in, MinuitParameterSet &t);
protected:
long UniqueID; ///< Component application-unique ID
std::string Label; ///< The label for the parameter set
// size_t NoOfItems; ///< Total number of records in this set
bool HasChanged; ///< If set, at least one pm in the set changed since last use
std::vector<int> Affects; ///< IDs of the attached sets, i.e. the ones which this set affects
std::vector<int> AffectedBy; ///< IDs of the sets affected by this one
#if 0
wxList *AttachmentList,///< This attached ones affect those FitParameterSet
*AffectedList; ///< Those FitParameterSet affect this on
#endif
static long BaseID; ///< The base ID for the unique IDs
char theName[MnPmNameLength]; ///< The name of the parameter set
public:
std::vector<MinuitParameter> Parameters; ///< The parameters belonging to this set
// Ctor, dtor, init, etc.
/// Create a parameter set, with aNoOfItems items and label aName
MinuitParameterSet( const char* aName=new char);
/// Copy constructor
MinuitParameterSet(const MinuitParameterSet &P);
/// Destructor
~MinuitParameterSet();
/// Add a new parameter to the set
void Add(MinuitParameter &P);
/// Add a new parameter to the set
void Add(MinuitParameter *P);
/// add free parameter name, value, error
void Add(const char* aLabel, double aValue, double aError);
/// add limited parameter name, value, error, lower bound, upper bound
void Add(const char* aLabel, double aValue, double aError, double aLower, double aHigher);
/// add const parameter name, vale
void Add(const char* aLabel, double aValue);
/// Return total number of parameters
inline size_t GetCount(void) const
{ return Parameters.size(); }
/// access to parameter values (row-wise)
std::vector<double> GetParameterValues() const;
/// Get the ParIndex-th FitParameter::GetFormattedItem
const std::string GetFormattedItem(const int ParIndex, const MinuitParameter::pmAttributeIndex ItemIndex)
{return Parameters[ParIndex].GetFormattedItem(ItemIndex);}
/// Return the ParIndex-th FitParameter::GetFormattedValue
const std::string GetFormattedValue(const int ParIndex)
{return Parameters[ParIndex].GetFormattedValue();}
/// Return parameter set label
const char* GetLabel(void) const
{ return theName;}
/// Return pointer to a parameter
MinuitParameter *GetParameter(const unsigned int Index)
{
ASSERT_MSG(Index<GetCount(), "Illegal master parameter index");
return &Parameters[Index];
}
inline const MinuitParameter & operator[](unsigned int Index) const
{
ASSERT_MSG(Index<Parameters.size(), "Illegal parameter index");
return Parameters[Index];
}
inline MinuitParameter & operator[](unsigned int Index)
{
ASSERT_MSG(Index<Parameters.size(), "Illegal parameter index");
return Parameters[Index];
}
/// Return value of the ParIndex-th parameter
double GetParameterValue(const int ParIndex)
{ return GetParameter(ParIndex)->GetParameterValue();}
/// Link a parameter record to another parameter record
bool LinkParameter(const unsigned short aSParNo, const MinuitParameter::pmLinkMode aLinkMode, MinuitParameterSet *Master, const unsigned short aMParNo);
/// Link a parameter record to another parameter record
bool LinkParameter(const unsigned short aSParNo, const char aLinkModeCh, MinuitParameterSet *Master, const unsigned short aMParNo)
{ return LinkParameter(aSParNo, MinuitParameter::Char2LinkMode(aLinkModeCh), Master, aMParNo); }
/// Unlink ParIndex-th parameter in this parameter set
bool UnlinkParameter(const unsigned int ParIndex);
void setName(const char* name) {
int l = std::min(int(strlen(name)), MnPmNameLength);
memset(theName, 0, MnPmNameLength*sizeof(char));
memcpy(theName, name, l*sizeof(char));
theName[10] = '\0';
}
};
#endif
#endif //MN_MinuitParameter_H_
| [
"Vegh.Janos@gmail.com"
] | Vegh.Janos@gmail.com |
346f53385b9a7970e38cf1784f418363244f478a | cb9f765f07cd7498ab67d1eb4a749360471ed1ee | /Lab_4/Lab_4/Lab_4.1.cpp | 5ab19ff64538365fa37452b8528504b02f4757f2 | [] | no_license | FFrancois98/CS_1 | 199893d9a5eb300883582ccb7494c21dd91239bd | da0d0015eb44b1f000bc3955a070073a3ba327b9 | refs/heads/master | 2021-04-26T23:56:52.241291 | 2018-03-05T08:13:50 | 2018-03-05T08:13:50 | 123,881,501 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 821 | cpp | #include <iostream> // include input/output library code
#include <string> // include string manipulate library code
using namespace std; // allows all of the names in a namespace
// to be accessed without the namespace
// identifier as a qualifier
int main()
{
string myname; // 1. declare variable to store my name
cout << "Enter your name "; // 2. prompt the user for their name
cin >> myname; // 3. get name from user
cout << "Hello " + myname << endl; // 4. output message
return 0; // return program completed OK to
// the operating system
}
/*
Enter your name Francois
Hello Francois
Press any key to continue . . .
*/ | [
"fleurevca.francois@bison.howard.edu"
] | fleurevca.francois@bison.howard.edu |
f951223bd5b8e839c769c7ecb67c54be1e16cda3 | d0e1b30c1be53948f56d38398d352426600b1e11 | /Shortest_Paths/main.cpp | d553490c7ab90f48e5823c50983eef2d26c0b2d6 | [] | no_license | tomerbdr/Shortest-Paths | 9541d06927cb4f096fe83944be1a5252078c3dbf | cc11b30fd8dd9c837b0d31292120db7aa4beaea4 | refs/heads/master | 2023-07-06T04:37:42.213254 | 2021-08-10T07:51:45 | 2021-08-10T07:51:45 | 356,194,667 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,927 | cpp | #include "ProgramOperator.h"
#include "SimpleDirectedGraph.h"
#include "PriorityQueue.h"
#include "ShortPath.h"
#include <iostream>
#include <stdlib.h>
using namespace std;
using namespace ShortestPaths;
/***********Program Instructions*************/
//
// ** The program should be execute from the command line with the following syntax:
// <exeName>.exe "<GraphFileName>.txt"
//
// ** The Graph-File format:
//
// <Num of vertices>
// <Source vertex>
// <Dest vertex>
// <FromVertex> <ToVertex> <EdgeWeight>
// .
// .
// .
// <FromVertex> <ToVertex> <EdgeWeight>
//
//
// ** Create instances of the desired graph and ShortPath algorithem in the main function
// ** Use the abstract class ProgramOperator's static methods to build graph from file and calculate the shortest path with the desired graph and algorithems
/**********************************************/
void main(int argc, char** argv)
{
try
{
SimpleDirectedGraph* G_List = new AdjacencyList;
SimpleDirectedGraph* G_Matrix = new AdjacencyMatrix;
int fromVertex, toVertex;
int* shortPathPtr;
ProgramOperator::MakeGraphsFromFile(argc, argv, G_List, G_Matrix,fromVertex,toVertex);
/*Adjacency List*/
PriorityQueue<SimpleDirectedGraph::Vertex*>* Q_Array = new ArrayPriorityQueue<SimpleDirectedGraph::Vertex*>;
PriorityQueue<SimpleDirectedGraph::Vertex*>* Q_Heap = new HeapPriorityQueue<SimpleDirectedGraph::Vertex*>;
Dijkstra Dijkstra_Heap_Adj_List_ShortPath(G_List, Q_Heap);
Dijkstra Dijkstra_Array_Adj_List_ShortPath(G_List, Q_Array);
BelmanFord Belman_Adj_List_ShortPath(G_List);
ProgramOperator::printShortPath(&Dijkstra_Heap_Adj_List_ShortPath, fromVertex, toVertex, "Adjacency Dijkstra heap ");
ProgramOperator::printShortPath(&Dijkstra_Array_Adj_List_ShortPath, fromVertex, toVertex, "Adjacency Dijkstra array ");
ProgramOperator::printShortPath(&Belman_Adj_List_ShortPath, fromVertex, toVertex, "Adjacency Bellman Ford ");
delete Q_Array;
delete Q_Heap;
/*Adjacency Matrix*/
Q_Array = new ArrayPriorityQueue<SimpleDirectedGraph::Vertex*>;
Q_Heap = new HeapPriorityQueue<SimpleDirectedGraph::Vertex*>;
Dijkstra Dijkstra_Heap_Adj_Matrix_ShortPath(G_Matrix, Q_Heap);
Dijkstra Dijkstra_Array_Adj_Matrix_ShortPath(G_Matrix, Q_Array);
BelmanFord Belman_Adj_Matrix_ShortPath(G_Matrix);
ProgramOperator::printShortPath(&Dijkstra_Heap_Adj_Matrix_ShortPath, fromVertex, toVertex, "Matrix Dijkstra heap ");
ProgramOperator::printShortPath(&Dijkstra_Array_Adj_Matrix_ShortPath, fromVertex, toVertex, "Matrix Dijkstra array ");
ProgramOperator::printShortPath(&Belman_Adj_Matrix_ShortPath, fromVertex, toVertex, "Matrix Bellman Ford ");
delete Q_Array;
delete Q_Heap;
delete G_List;
delete G_Matrix;
}
catch (exception& i_Exc)
{
cout << "Invalid input." << endl;
/* cout << i_Ecx.what() << endl */ // Use this line to see what is the exaclty exception
exit(1);
}
}
| [
"66356005+tomerbdr@users.noreply.github.com"
] | 66356005+tomerbdr@users.noreply.github.com |
50bda03c84e26aafaf4af35f799166e21b61aec0 | 33e64d2fb4c538d1ded70e5ad2ad07908f098791 | /assignment_package/src/scalenode.cpp | 100e827a412800064e67753aba46e5aca957db0f | [] | no_license | suxie/plantsim | b166a683e5e6b63112ed37a03e11fbade1935cf5 | 6d8e22135eac5d20a533857772e3a348350dad10 | refs/heads/main | 2023-02-18T04:40:21.891386 | 2021-01-20T21:09:59 | 2021-01-20T21:09:59 | 322,179,984 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 555 | cpp | #include "scalenode.h"
ScaleNode::ScaleNode(float x, float y, QString name)
: Node(name), x(x), y(y)
{}
float ScaleNode::getX() {
glm::mat3 scale = transform();
return scale[0][0];
}
float ScaleNode::getY() {
glm::mat3 scale = transform();
return scale[1][1];
}
glm::mat3 ScaleNode::transform() {
glm::mat3 scale = glm::mat3(1);
scale[0][0] = x;
scale[1][1] = y;
return scale;
}
void ScaleNode::scale(float x, float y) {
this->x = x;
this->y = y;
}
ScaleNode::~ScaleNode() {}
| [
"susanxx25@gmail.com"
] | susanxx25@gmail.com |
4c54e4aee7678d158c6c0e1be62defd82dbb1756 | f09b352fded2ad21670d2c99691fff0958debdd0 | /depen/glm/gtc/type_precision.hpp | 18038ec630d50ac33c5d432000be8be4d9326212 | [] | no_license | solesensei/CDecompose | aca4fcb98d8439c6cb330611b4846c179e68e657 | 30b71b2051ae2b85c2f0097819919dffc1117d09 | refs/heads/master | 2020-03-07T05:53:21.678299 | 2019-05-12T14:46:22 | 2019-05-12T14:46:22 | 127,308,255 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 25,187 | hpp | /// @ref gtc_type_precision
/// @file glm/gtc/type_precision.hpp
///
/// @see core (dependence)
/// @see gtc_quaternion (dependence)
///
/// @defgroup gtc_type_precision GLM_GTC_type_precision
/// @ingroup gtc
///
/// Include <glm/gtc/type_precision.hpp> to use the features of this extension.
///
/// Defines specific C++-based qualifier types.
///
/// @ref core_precision defines types based on GLSL's qualifier qualifiers. This
/// extension defines types based on explicitly-sized C++ data types.
#pragma once
// Dependency:
#include "../gtc/quaternion.hpp"
#include "../gtc/vec1.hpp"
#include "../vec2.hpp"
#include "../vec3.hpp"
#include "../vec4.hpp"
#include "../mat2x2.hpp"
#include "../mat2x3.hpp"
#include "../mat2x4.hpp"
#include "../mat3x2.hpp"
#include "../mat3x3.hpp"
#include "../mat3x4.hpp"
#include "../mat4x2.hpp"
#include "../mat4x3.hpp"
#include "../mat4x4.hpp"
#if GLM_MESSAGES == GLM_MESSAGES_ENABLED && !defined(GLM_EXT_INCLUDED)
# pragma message("GLM: GLM_GTC_type_precision extension included")
#endif
namespace glm
{
///////////////////////////
// Signed int vector types
/// @addtogroup gtc_type_precision
/// @{
/// Low qualifier 8 bit signed integer type.
/// @see gtc_type_precision
typedef detail::int8 lowp_int8;
/// Low qualifier 16 bit signed integer type.
/// @see gtc_type_precision
typedef detail::int16 lowp_int16;
/// Low qualifier 32 bit signed integer type.
/// @see gtc_type_precision
typedef detail::int32 lowp_int32;
/// Low qualifier 64 bit signed integer type.
/// @see gtc_type_precision
typedef detail::int64 lowp_int64;
/// Low qualifier 8 bit signed integer type.
/// @see gtc_type_precision
typedef detail::int8 lowp_int8_t;
/// Low qualifier 16 bit signed integer type.
/// @see gtc_type_precision
typedef detail::int16 lowp_int16_t;
/// Low qualifier 32 bit signed integer type.
/// @see gtc_type_precision
typedef detail::int32 lowp_int32_t;
/// Low qualifier 64 bit signed integer type.
/// @see gtc_type_precision
typedef detail::int64 lowp_int64_t;
/// Low qualifier 8 bit signed integer type.
/// @see gtc_type_precision
typedef detail::int8 lowp_i8;
/// Low qualifier 16 bit signed integer type.
/// @see gtc_type_precision
typedef detail::int16 lowp_i16;
/// Low qualifier 32 bit signed integer type.
/// @see gtc_type_precision
typedef detail::int32 lowp_i32;
/// Low qualifier 64 bit signed integer type.
/// @see gtc_type_precision
typedef detail::int64 lowp_i64;
/// Medium qualifier 8 bit signed integer type.
/// @see gtc_type_precision
typedef detail::int8 mediump_int8;
/// Medium qualifier 16 bit signed integer type.
/// @see gtc_type_precision
typedef detail::int16 mediump_int16;
/// Medium qualifier 32 bit signed integer type.
/// @see gtc_type_precision
typedef detail::int32 mediump_int32;
/// Medium qualifier 64 bit signed integer type.
/// @see gtc_type_precision
typedef detail::int64 mediump_int64;
/// Medium qualifier 8 bit signed integer type.
/// @see gtc_type_precision
typedef detail::int8 mediump_int8_t;
/// Medium qualifier 16 bit signed integer type.
/// @see gtc_type_precision
typedef detail::int16 mediump_int16_t;
/// Medium qualifier 32 bit signed integer type.
/// @see gtc_type_precision
typedef detail::int32 mediump_int32_t;
/// Medium qualifier 64 bit signed integer type.
/// @see gtc_type_precision
typedef detail::int64 mediump_int64_t;
/// Medium qualifier 8 bit signed integer type.
/// @see gtc_type_precision
typedef detail::int8 mediump_i8;
/// Medium qualifier 16 bit signed integer type.
/// @see gtc_type_precision
typedef detail::int16 mediump_i16;
/// Medium qualifier 32 bit signed integer type.
/// @see gtc_type_precision
typedef detail::int32 mediump_i32;
/// Medium qualifier 64 bit signed integer type.
/// @see gtc_type_precision
typedef detail::int64 mediump_i64;
/// High qualifier 8 bit signed integer type.
/// @see gtc_type_precision
typedef detail::int8 highp_int8;
/// High qualifier 16 bit signed integer type.
/// @see gtc_type_precision
typedef detail::int16 highp_int16;
/// High qualifier 32 bit signed integer type.
/// @see gtc_type_precision
typedef detail::int32 highp_int32;
/// High qualifier 64 bit signed integer type.
/// @see gtc_type_precision
typedef detail::int64 highp_int64;
/// High qualifier 8 bit signed integer type.
/// @see gtc_type_precision
typedef detail::int8 highp_int8_t;
/// High qualifier 16 bit signed integer type.
/// @see gtc_type_precision
typedef detail::int16 highp_int16_t;
/// 32 bit signed integer type.
/// @see gtc_type_precision
typedef detail::int32 highp_int32_t;
/// High qualifier 64 bit signed integer type.
/// @see gtc_type_precision
typedef detail::int64 highp_int64_t;
/// High qualifier 8 bit signed integer type.
/// @see gtc_type_precision
typedef detail::int8 highp_i8;
/// High qualifier 16 bit signed integer type.
/// @see gtc_type_precision
typedef detail::int16 highp_i16;
/// High qualifier 32 bit signed integer type.
/// @see gtc_type_precision
typedef detail::int32 highp_i32;
/// High qualifier 64 bit signed integer type.
/// @see gtc_type_precision
typedef detail::int64 highp_i64;
/// 8 bit signed integer type.
/// @see gtc_type_precision
typedef detail::int8 int8;
/// 16 bit signed integer type.
/// @see gtc_type_precision
typedef detail::int16 int16;
/// 32 bit signed integer type.
/// @see gtc_type_precision
typedef detail::int32 int32;
/// 64 bit signed integer type.
/// @see gtc_type_precision
typedef detail::int64 int64;
#if GLM_HAS_EXTENDED_INTEGER_TYPE
using std::int8_t;
using std::int16_t;
using std::int32_t;
using std::int64_t;
#else
/// 8 bit signed integer type.
/// @see gtc_type_precision
typedef detail::int8 int8_t;
/// 16 bit signed integer type.
/// @see gtc_type_precision
typedef detail::int16 int16_t;
/// 32 bit signed integer type.
/// @see gtc_type_precision
typedef detail::int32 int32_t;
/// 64 bit signed integer type.
/// @see gtc_type_precision
typedef detail::int64 int64_t;
#endif
/// 8 bit signed integer type.
/// @see gtc_type_precision
typedef detail::int8 i8;
/// 16 bit signed integer type.
/// @see gtc_type_precision
typedef detail::int16 i16;
/// 32 bit signed integer type.
/// @see gtc_type_precision
typedef detail::int32 i32;
/// 64 bit signed integer type.
/// @see gtc_type_precision
typedef detail::int64 i64;
/// 8 bit signed integer scalar type.
/// @see gtc_type_precision
typedef vec<1, i8, defaultp> i8vec1;
/// 8 bit signed integer vector of 2 components type.
/// @see gtc_type_precision
typedef vec<2, i8, defaultp> i8vec2;
/// 8 bit signed integer vector of 3 components type.
/// @see gtc_type_precision
typedef vec<3, i8, defaultp> i8vec3;
/// 8 bit signed integer vector of 4 components type.
/// @see gtc_type_precision
typedef vec<4, i8, defaultp> i8vec4;
/// 16 bit signed integer scalar type.
/// @see gtc_type_precision
typedef vec<1, i16, defaultp> i16vec1;
/// 16 bit signed integer vector of 2 components type.
/// @see gtc_type_precision
typedef vec<2, i16, defaultp> i16vec2;
/// 16 bit signed integer vector of 3 components type.
/// @see gtc_type_precision
typedef vec<3, i16, defaultp> i16vec3;
/// 16 bit signed integer vector of 4 components type.
/// @see gtc_type_precision
typedef vec<4, i16, defaultp> i16vec4;
/// 32 bit signed integer scalar type.
/// @see gtc_type_precision
typedef vec<1, i32, defaultp> i32vec1;
/// 32 bit signed integer vector of 2 components type.
/// @see gtc_type_precision
typedef vec<2, i32, defaultp> i32vec2;
/// 32 bit signed integer vector of 3 components type.
/// @see gtc_type_precision
typedef vec<3, i32, defaultp> i32vec3;
/// 32 bit signed integer vector of 4 components type.
/// @see gtc_type_precision
typedef vec<4, i32, defaultp> i32vec4;
/// 64 bit signed integer scalar type.
/// @see gtc_type_precision
typedef vec<1, i64, defaultp> i64vec1;
/// 64 bit signed integer vector of 2 components type.
/// @see gtc_type_precision
typedef vec<2, i64, defaultp> i64vec2;
/// 64 bit signed integer vector of 3 components type.
/// @see gtc_type_precision
typedef vec<3, i64, defaultp> i64vec3;
/// 64 bit signed integer vector of 4 components type.
/// @see gtc_type_precision
typedef vec<4, i64, defaultp> i64vec4;
/////////////////////////////
// Unsigned int vector types
/// Low qualifier 8 bit unsigned integer type.
/// @see gtc_type_precision
typedef detail::uint8 lowp_uint8;
/// Low qualifier 16 bit unsigned integer type.
/// @see gtc_type_precision
typedef detail::uint16 lowp_uint16;
/// Low qualifier 32 bit unsigned integer type.
/// @see gtc_type_precision
typedef detail::uint32 lowp_uint32;
/// Low qualifier 64 bit unsigned integer type.
/// @see gtc_type_precision
typedef detail::uint64 lowp_uint64;
/// Low qualifier 8 bit unsigned integer type.
/// @see gtc_type_precision
typedef detail::uint8 lowp_uint8_t;
/// Low qualifier 16 bit unsigned integer type.
/// @see gtc_type_precision
typedef detail::uint16 lowp_uint16_t;
/// Low qualifier 32 bit unsigned integer type.
/// @see gtc_type_precision
typedef detail::uint32 lowp_uint32_t;
/// Low qualifier 64 bit unsigned integer type.
/// @see gtc_type_precision
typedef detail::uint64 lowp_uint64_t;
/// Low qualifier 8 bit unsigned integer type.
/// @see gtc_type_precision
typedef detail::uint8 lowp_u8;
/// Low qualifier 16 bit unsigned integer type.
/// @see gtc_type_precision
typedef detail::uint16 lowp_u16;
/// Low qualifier 32 bit unsigned integer type.
/// @see gtc_type_precision
typedef detail::uint32 lowp_u32;
/// Low qualifier 64 bit unsigned integer type.
/// @see gtc_type_precision
typedef detail::uint64 lowp_u64;
/// Medium qualifier 8 bit unsigned integer type.
/// @see gtc_type_precision
typedef detail::uint8 mediump_uint8;
/// Medium qualifier 16 bit unsigned integer type.
/// @see gtc_type_precision
typedef detail::uint16 mediump_uint16;
/// Medium qualifier 32 bit unsigned integer type.
/// @see gtc_type_precision
typedef detail::uint32 mediump_uint32;
/// Medium qualifier 64 bit unsigned integer type.
/// @see gtc_type_precision
typedef detail::uint64 mediump_uint64;
/// Medium qualifier 8 bit unsigned integer type.
/// @see gtc_type_precision
typedef detail::uint8 mediump_uint8_t;
/// Medium qualifier 16 bit unsigned integer type.
/// @see gtc_type_precision
typedef detail::uint16 mediump_uint16_t;
/// Medium qualifier 32 bit unsigned integer type.
/// @see gtc_type_precision
typedef detail::uint32 mediump_uint32_t;
/// Medium qualifier 64 bit unsigned integer type.
/// @see gtc_type_precision
typedef detail::uint64 mediump_uint64_t;
/// Medium qualifier 8 bit unsigned integer type.
/// @see gtc_type_precision
typedef detail::uint8 mediump_u8;
/// Medium qualifier 16 bit unsigned integer type.
/// @see gtc_type_precision
typedef detail::uint16 mediump_u16;
/// Medium qualifier 32 bit unsigned integer type.
/// @see gtc_type_precision
typedef detail::uint32 mediump_u32;
/// Medium qualifier 64 bit unsigned integer type.
/// @see gtc_type_precision
typedef detail::uint64 mediump_u64;
/// High qualifier 8 bit unsigned integer type.
/// @see gtc_type_precision
typedef detail::uint8 highp_uint8;
/// High qualifier 16 bit unsigned integer type.
/// @see gtc_type_precision
typedef detail::uint16 highp_uint16;
/// High qualifier 32 bit unsigned integer type.
/// @see gtc_type_precision
typedef detail::uint32 highp_uint32;
/// High qualifier 64 bit unsigned integer type.
/// @see gtc_type_precision
typedef detail::uint64 highp_uint64;
/// High qualifier 8 bit unsigned integer type.
/// @see gtc_type_precision
typedef detail::uint8 highp_uint8_t;
/// High qualifier 16 bit unsigned integer type.
/// @see gtc_type_precision
typedef detail::uint16 highp_uint16_t;
/// High qualifier 32 bit unsigned integer type.
/// @see gtc_type_precision
typedef detail::uint32 highp_uint32_t;
/// High qualifier 64 bit unsigned integer type.
/// @see gtc_type_precision
typedef detail::uint64 highp_uint64_t;
/// High qualifier 8 bit unsigned integer type.
/// @see gtc_type_precision
typedef detail::uint8 highp_u8;
/// High qualifier 16 bit unsigned integer type.
/// @see gtc_type_precision
typedef detail::uint16 highp_u16;
/// High qualifier 32 bit unsigned integer type.
/// @see gtc_type_precision
typedef detail::uint32 highp_u32;
/// High qualifier 64 bit unsigned integer type.
/// @see gtc_type_precision
typedef detail::uint64 highp_u64;
/// Default qualifier 8 bit unsigned integer type.
/// @see gtc_type_precision
typedef detail::uint8 uint8;
/// Default qualifier 16 bit unsigned integer type.
/// @see gtc_type_precision
typedef detail::uint16 uint16;
/// Default qualifier 32 bit unsigned integer type.
/// @see gtc_type_precision
typedef detail::uint32 uint32;
/// Default qualifier 64 bit unsigned integer type.
/// @see gtc_type_precision
typedef detail::uint64 uint64;
#if GLM_HAS_EXTENDED_INTEGER_TYPE
using std::uint8_t;
using std::uint16_t;
using std::uint32_t;
using std::uint64_t;
#else
/// Default qualifier 8 bit unsigned integer type.
/// @see gtc_type_precision
typedef detail::uint8 uint8_t;
/// Default qualifier 16 bit unsigned integer type.
/// @see gtc_type_precision
typedef detail::uint16 uint16_t;
/// Default qualifier 32 bit unsigned integer type.
/// @see gtc_type_precision
typedef detail::uint32 uint32_t;
/// Default qualifier 64 bit unsigned integer type.
/// @see gtc_type_precision
typedef detail::uint64 uint64_t;
#endif
/// Default qualifier 8 bit unsigned integer type.
/// @see gtc_type_precision
typedef detail::uint8 u8;
/// Default qualifier 16 bit unsigned integer type.
/// @see gtc_type_precision
typedef detail::uint16 u16;
/// Default qualifier 32 bit unsigned integer type.
/// @see gtc_type_precision
typedef detail::uint32 u32;
/// Default qualifier 64 bit unsigned integer type.
/// @see gtc_type_precision
typedef detail::uint64 u64;
/// Default qualifier 8 bit unsigned integer scalar type.
/// @see gtc_type_precision
typedef vec<1, u8, defaultp> u8vec1;
/// Default qualifier 8 bit unsigned integer vector of 2 components type.
/// @see gtc_type_precision
typedef vec<2, u8, defaultp> u8vec2;
/// Default qualifier 8 bit unsigned integer vector of 3 components type.
/// @see gtc_type_precision
typedef vec<3, u8, defaultp> u8vec3;
/// Default qualifier 8 bit unsigned integer vector of 4 components type.
/// @see gtc_type_precision
typedef vec<4, u8, defaultp> u8vec4;
/// Default qualifier 16 bit unsigned integer scalar type.
/// @see gtc_type_precision
typedef vec<1, u16, defaultp> u16vec1;
/// Default qualifier 16 bit unsigned integer vector of 2 components type.
/// @see gtc_type_precision
typedef vec<2, u16, defaultp> u16vec2;
/// Default qualifier 16 bit unsigned integer vector of 3 components type.
/// @see gtc_type_precision
typedef vec<3, u16, defaultp> u16vec3;
/// Default qualifier 16 bit unsigned integer vector of 4 components type.
/// @see gtc_type_precision
typedef vec<4, u16, defaultp> u16vec4;
/// Default qualifier 32 bit unsigned integer scalar type.
/// @see gtc_type_precision
typedef vec<1, u32, defaultp> u32vec1;
/// Default qualifier 32 bit unsigned integer vector of 2 components type.
/// @see gtc_type_precision
typedef vec<2, u32, defaultp> u32vec2;
/// Default qualifier 32 bit unsigned integer vector of 3 components type.
/// @see gtc_type_precision
typedef vec<3, u32, defaultp> u32vec3;
/// Default qualifier 32 bit unsigned integer vector of 4 components type.
/// @see gtc_type_precision
typedef vec<4, u32, defaultp> u32vec4;
/// Default qualifier 64 bit unsigned integer scalar type.
/// @see gtc_type_precision
typedef vec<1, u64, defaultp> u64vec1;
/// Default qualifier 64 bit unsigned integer vector of 2 components type.
/// @see gtc_type_precision
typedef vec<2, u64, defaultp> u64vec2;
/// Default qualifier 64 bit unsigned integer vector of 3 components type.
/// @see gtc_type_precision
typedef vec<3, u64, defaultp> u64vec3;
/// Default qualifier 64 bit unsigned integer vector of 4 components type.
/// @see gtc_type_precision
typedef vec<4, u64, defaultp> u64vec4;
//////////////////////
// Float vector types
/// 32 bit single-qualifier floating-point scalar.
/// @see gtc_type_precision
typedef detail::float32 float32;
/// 64 bit double-qualifier floating-point scalar.
/// @see gtc_type_precision
typedef detail::float64 float64;
/// 32 bit single-qualifier floating-point scalar.
/// @see gtc_type_precision
typedef detail::float32 float32_t;
/// 64 bit double-qualifier floating-point scalar.
/// @see gtc_type_precision
typedef detail::float64 float64_t;
/// 32 bit single-qualifier floating-point scalar.
/// @see gtc_type_precision
typedef float32 f32;
/// 64 bit double-qualifier floating-point scalar.
/// @see gtc_type_precision
typedef float64 f64;
/// Single-qualifier floating-point vector of 1 component.
/// @see gtc_type_precision
typedef vec<1, float, defaultp> fvec1;
/// Single-qualifier floating-point vector of 2 components.
/// @see gtc_type_precision
typedef vec<2, float, defaultp> fvec2;
/// Single-qualifier floating-point vector of 3 components.
/// @see gtc_type_precision
typedef vec<3, float, defaultp> fvec3;
/// Single-qualifier floating-point vector of 4 components.
/// @see gtc_type_precision
typedef vec<4, float, defaultp> fvec4;
/// Single-qualifier floating-point vector of 1 component.
/// @see gtc_type_precision
typedef vec<1, f32, defaultp> f32vec1;
/// Single-qualifier floating-point vector of 2 components.
/// @see gtc_type_precision
typedef vec<2, f32, defaultp> f32vec2;
/// Single-qualifier floating-point vector of 3 components.
/// @see gtc_type_precision
typedef vec<3, f32, defaultp> f32vec3;
/// Single-qualifier floating-point vector of 4 components.
/// @see gtc_type_precision
typedef vec<4, f32, defaultp> f32vec4;
/// Double-qualifier floating-point vector of 1 component.
/// @see gtc_type_precision
typedef vec<1, f64, defaultp> f64vec1;
/// Double-qualifier floating-point vector of 2 components.
/// @see gtc_type_precision
typedef vec<2, f64, defaultp> f64vec2;
/// Double-qualifier floating-point vector of 3 components.
/// @see gtc_type_precision
typedef vec<3, f64, defaultp> f64vec3;
/// Double-qualifier floating-point vector of 4 components.
/// @see gtc_type_precision
typedef vec<4, f64, defaultp> f64vec4;
//////////////////////
// Float matrix types
/// Single-qualifier floating-point 1x1 matrix.
/// @see gtc_type_precision
//typedef detail::tmat1x1<f32> fmat1;
/// Single-qualifier floating-point 2x2 matrix.
/// @see gtc_type_precision
typedef mat<2, 2, f32, defaultp> fmat2;
/// Single-qualifier floating-point 3x3 matrix.
/// @see gtc_type_precision
typedef mat<3, 3, f32, defaultp> fmat3;
/// Single-qualifier floating-point 4x4 matrix.
/// @see gtc_type_precision
typedef mat<4, 4, f32, defaultp> fmat4;
/// Single-qualifier floating-point 1x1 matrix.
/// @see gtc_type_precision
//typedef f32 fmat1x1;
/// Single-qualifier floating-point 2x2 matrix.
/// @see gtc_type_precision
typedef mat<2, 2, f32, defaultp> fmat2x2;
/// Single-qualifier floating-point 2x3 matrix.
/// @see gtc_type_precision
typedef mat<2, 3, f32, defaultp> fmat2x3;
/// Single-qualifier floating-point 2x4 matrix.
/// @see gtc_type_precision
typedef mat<2, 4, f32, defaultp> fmat2x4;
/// Single-qualifier floating-point 3x2 matrix.
/// @see gtc_type_precision
typedef mat<3, 2, f32, defaultp> fmat3x2;
/// Single-qualifier floating-point 3x3 matrix.
/// @see gtc_type_precision
typedef mat<3, 3, f32, defaultp> fmat3x3;
/// Single-qualifier floating-point 3x4 matrix.
/// @see gtc_type_precision
typedef mat<3, 4, f32, defaultp> fmat3x4;
/// Single-qualifier floating-point 4x2 matrix.
/// @see gtc_type_precision
typedef mat<4, 2, f32, defaultp> fmat4x2;
/// Single-qualifier floating-point 4x3 matrix.
/// @see gtc_type_precision
typedef mat<4, 3, f32, defaultp> fmat4x3;
/// Single-qualifier floating-point 4x4 matrix.
/// @see gtc_type_precision
typedef mat<4, 4, f32, defaultp> fmat4x4;
/// Single-qualifier floating-point 1x1 matrix.
/// @see gtc_type_precision
//typedef detail::tmat1x1<f32, defaultp> f32mat1;
/// Single-qualifier floating-point 2x2 matrix.
/// @see gtc_type_precision
typedef mat<2, 2, f32, defaultp> f32mat2;
/// Single-qualifier floating-point 3x3 matrix.
/// @see gtc_type_precision
typedef mat<3, 3, f32, defaultp> f32mat3;
/// Single-qualifier floating-point 4x4 matrix.
/// @see gtc_type_precision
typedef mat<4, 4, f32, defaultp> f32mat4;
/// Single-qualifier floating-point 1x1 matrix.
/// @see gtc_type_precision
//typedef f32 f32mat1x1;
/// Single-qualifier floating-point 2x2 matrix.
/// @see gtc_type_precision
typedef mat<2, 2, f32, defaultp> f32mat2x2;
/// Single-qualifier floating-point 2x3 matrix.
/// @see gtc_type_precision
typedef mat<2, 3, f32, defaultp> f32mat2x3;
/// Single-qualifier floating-point 2x4 matrix.
/// @see gtc_type_precision
typedef mat<2, 4, f32, defaultp> f32mat2x4;
/// Single-qualifier floating-point 3x2 matrix.
/// @see gtc_type_precision
typedef mat<3, 2, f32, defaultp> f32mat3x2;
/// Single-qualifier floating-point 3x3 matrix.
/// @see gtc_type_precision
typedef mat<3, 3, f32, defaultp> f32mat3x3;
/// Single-qualifier floating-point 3x4 matrix.
/// @see gtc_type_precision
typedef mat<3, 4, f32, defaultp> f32mat3x4;
/// Single-qualifier floating-point 4x2 matrix.
/// @see gtc_type_precision
typedef mat<4, 2, f32, defaultp> f32mat4x2;
/// Single-qualifier floating-point 4x3 matrix.
/// @see gtc_type_precision
typedef mat<4, 3, f32, defaultp> f32mat4x3;
/// Single-qualifier floating-point 4x4 matrix.
/// @see gtc_type_precision
typedef mat<4, 4, f32, defaultp> f32mat4x4;
/// Double-qualifier floating-point 1x1 matrix.
/// @see gtc_type_precision
//typedef detail::tmat1x1<f64, defaultp> f64mat1;
/// Double-qualifier floating-point 2x2 matrix.
/// @see gtc_type_precision
typedef mat<2, 2, f64, defaultp> f64mat2;
/// Double-qualifier floating-point 3x3 matrix.
/// @see gtc_type_precision
typedef mat<3, 3, f64, defaultp> f64mat3;
/// Double-qualifier floating-point 4x4 matrix.
/// @see gtc_type_precision
typedef mat<4, 4, f64, defaultp> f64mat4;
/// Double-qualifier floating-point 1x1 matrix.
/// @see gtc_type_precision
//typedef f64 f64mat1x1;
/// Double-qualifier floating-point 2x2 matrix.
/// @see gtc_type_precision
typedef mat<2, 2, f64, defaultp> f64mat2x2;
/// Double-qualifier floating-point 2x3 matrix.
/// @see gtc_type_precision
typedef mat<2, 3, f64, defaultp> f64mat2x3;
/// Double-qualifier floating-point 2x4 matrix.
/// @see gtc_type_precision
typedef mat<2, 4, f64, defaultp> f64mat2x4;
/// Double-qualifier floating-point 3x2 matrix.
/// @see gtc_type_precision
typedef mat<3, 2, f64, defaultp> f64mat3x2;
/// Double-qualifier floating-point 3x3 matrix.
/// @see gtc_type_precision
typedef mat<3, 3, f64, defaultp> f64mat3x3;
/// Double-qualifier floating-point 3x4 matrix.
/// @see gtc_type_precision
typedef mat<3, 4, f64, defaultp> f64mat3x4;
/// Double-qualifier floating-point 4x2 matrix.
/// @see gtc_type_precision
typedef mat<4, 2, f64, defaultp> f64mat4x2;
/// Double-qualifier floating-point 4x3 matrix.
/// @see gtc_type_precision
typedef mat<4, 3, f64, defaultp> f64mat4x3;
/// Double-qualifier floating-point 4x4 matrix.
/// @see gtc_type_precision
typedef mat<4, 4, f64, defaultp> f64mat4x4;
//////////////////////////
// Quaternion types
/// Single-qualifier floating-point quaternion.
/// @see gtc_type_precision
typedef tquat<f32, defaultp> f32quat;
/// Double-qualifier floating-point quaternion.
/// @see gtc_type_precision
typedef tquat<f64, defaultp> f64quat;
/// @}
}//namespace glm
#include "type_precision.inl"
| [
"dimargfd@gmail.com"
] | dimargfd@gmail.com |
e2669cd926255c54a1ea9b732573c279d8f5586c | 917da3793dbb6910bd40b471f386653b5f548738 | /bandage.h | e6350ab6254d4b797d6b695d549cdb73c09cd694 | [] | no_license | dairemcdonald/Zombie-Zork | 7993332299e2dbbc8fdf05b8450dd9bc190c63ca | b355ec861c18497b3ddab56cfcb8e5e2e03b7ae0 | refs/heads/master | 2020-06-19T20:23:56.277504 | 2019-07-14T16:32:24 | 2019-07-14T16:32:24 | 196,858,505 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 155 | h | #ifndef BANDAGE_H
#define BANDAGE_H
#include "loot.h"
class bandage: public loot
{
public:
bandage();
protected:
private:
};
#endif // BANDAGE_H
| [
"15161153@studentmail.ul.ie"
] | 15161153@studentmail.ul.ie |
2fa2e8d8fa359a2be33a8ced305bfb402ad4c82d | 6b2a8dd202fdce77c971c412717e305e1caaac51 | /solutions_5631989306621952_1/C++/rezwan4029/bitmask.cpp | 1d507916b44e8c8120770c0819c78e2e5e46e117 | [] | 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 | 3,224 | cpp | /*
Rezwan_4029 , AUST
*/
#include <bits/stdc++.h>
#define pb push_back
#define all(x) x.begin(),x.end()
#define ms(a,v) memset(a,v,sizeof a)
#define II ({int a; scanf("%d", &a); a;})
#define LL ({Long a; scanf("%lld", &a); a;})
#define DD ({double a; scanf("%lf", &a); a;})
#define ff first
#define ss second
#define mp make_pair
#define gc getchar
#define EPS 1e-10
#define pi 3.1415926535897932384626433832795
using namespace std;
#define FI freopen ("in.txt", "r", stdin)
#define FO freopen ("out.txt", "w", stdout)
typedef long long Long;
typedef unsigned long long ull;
typedef vector<int> vi ;
typedef set<int> si;
typedef vector<Long>vl;
typedef pair<int,int>pii;
typedef pair<string,int>psi;
typedef pair<Long,Long>pll;
typedef pair<double,double>pdd;
typedef vector<pii> vpii;
#define forab(i, a, b) for (__typeof (b) i = (a) ; i <= b ; ++i)
#define rep(i, n) forab (i, 0, (n) - 1)
#define For(i, n) forab (i, 1, n)
#define rofba(i, a, b) for (__typeof (b)i = (b) ; i >= a ; --i)
#define per(i, n) rofba (i, 0, (n) - 1)
#define rof(i, n) rofba (i, 1, n)
#define forstl(i, s) for (__typeof ((s).end ()) i = (s).begin (); i != (s).end (); ++i)
#define __(args...) {dbg,args; cerr<<endl;}
struct debugger{template<typename T> debugger& operator , (const T& v){cerr<<v<<"\t"; return *this; }}dbg;
#define __1D(a,n) rep(i,n) { if(i) printf(" ") ; cout << a[i] ; }
#define __2D(a,r,c,f) forab(i,f,r-!f){forab(j,f,c-!f){if(j!=f)printf(" ");cout<<a[i][j];}cout<<endl;}
template<class A, class B> ostream &operator<<(ostream& o, const pair<A,B>& p){ return o<<"("<<p.ff<<", "<<p.ss<<")";} //Pair print
template<class T> ostream& operator<<(ostream& o, const vector<T>& v){ o<<"[";forstl(it,v)o<<*it<<", ";return o<<"]";} //Vector print
template<class T> ostream& operator<<(ostream& o, const set<T>& v){ o<<"[";forstl(it,v)o<<*it<<", ";return o<<"]";} //Set print
template<class T> inline void MAX(T &a , T b){ if (a < b ) a = b;}
template<class T> inline void MIN(T &a , T b){ if (a > b ) a = b;}
//Fast Reader
template<class T>inline bool read(T &x){int c=gc();int sgn=1;while(~c&&c<'0'||c>'9'){if(c=='-')sgn=-1;c=gc();}for(x=0;~c&&'0'<=c&&c<='9';c=gc())x=x*10+c-'0';x*=sgn;return ~c;}
//int dx[]={1,0,-1,0};int dy[]={0,1,0,-1}; //4 Direction
//int dx[]={1,1,0,-1,-1,-1,0,1};int dy[]={0,1,1,1,0,-1,-1,-1};//8 direction
//int dx[]={2,1,-1,-2,-2,-1,1,2};int dy[]={1,2,2,1,-1,-2,-2,-1};//Knight Direction
//int dx[]={2,1,-1,-2,-1,1};int dy[]={0,1,1,0,-1,-1}; //Hexagonal Direction
Long Pow(Long b,Long p){
Long ret = 1;
while(p){
if(p&1) ret *= b ;
p >>= (1ll) , b *= b ;
}
return ret ;
}
const int MX= 3000;
int A[MX], B[MX];
int main() {
FI;FO;
int T = II;
For(cs, T){
string s, ans ;
cin >> s ;
int len = s.size();
stringstream x ;
x << s[0];
ans += x.str();
printf("Case #%d: ", cs);
For(i, len-1){
stringstream x ;
x << s[i];
if( s[i] >= ans[0] ) ans = x.str() + ans ;
else ans = ans + x.str();
}
cout << ans << endl;
}
}
| [
"alexandra1.back@gmail.com"
] | alexandra1.back@gmail.com |
dc21efe66238d7c0b997fa0b7ae4838345079723 | 5db5837f38bed51d5783ca92876db3e3b20984ac | /src/script/bitcoinconsensus.cpp | 7e67668a049a5a578f4b65b7405c7d95784aa718 | [
"MIT"
] | permissive | edwardgrubb3rd/ErosCore | 31ddee84322b864b5158006597ccef9f8cd7e728 | 762bc620bdd60514e4dc6c1ea4e6d678a104c32e | refs/heads/master | 2021-04-12T19:03:39.256669 | 2020-02-28T07:04:00 | 2020-02-28T07:04:00 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,983 | cpp | // Copyright (c) 2009-2010 Satoshi Nakamoto
// Copyright (c) 2009-2014 The Bitcoin developers
// Copyright (c) 2018-2020 The EROS developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include "bitcoinconsensus.h"
#include "primitives/transaction.h"
#include "script/interpreter.h"
#include "version.h"
namespace {
/** A class that deserializes a single CTransaction one time. */
class TxInputStream
{
public:
TxInputStream(int nTypeIn, int nVersionIn, const unsigned char *txTo, size_t txToLen) :
m_type(nTypeIn),
m_version(nVersionIn),
m_data(txTo),
m_remaining(txToLen)
{}
TxInputStream& read(char* pch, size_t nSize)
{
if (nSize > m_remaining)
throw std::ios_base::failure(std::string(__func__) + ": end of data");
if (pch == NULL)
throw std::ios_base::failure(std::string(__func__) + ": bad destination buffer");
if (m_data == NULL)
throw std::ios_base::failure(std::string(__func__) + ": bad source buffer");
memcpy(pch, m_data, nSize);
m_remaining -= nSize;
m_data += nSize;
return *this;
}
template<typename T>
TxInputStream& operator>>(T& obj)
{
::Unserialize(*this, obj, m_type, m_version);
return *this;
}
private:
const int m_type;
const int m_version;
const unsigned char* m_data;
size_t m_remaining;
};
inline int set_error(bitcoinconsensus_error* ret, bitcoinconsensus_error serror)
{
if (ret)
*ret = serror;
return 0;
}
struct ECCryptoClosure
{
ECCVerifyHandle handle;
};
ECCryptoClosure instance_of_eccryptoclosure;
} // anon namespace
int bitcoinconsensus_verify_script(const unsigned char *scriptPubKey, unsigned int scriptPubKeyLen,
const unsigned char *txTo , unsigned int txToLen,
unsigned int nIn, unsigned int flags, bitcoinconsensus_error* err)
{
try {
TxInputStream stream(SER_NETWORK, PROTOCOL_VERSION, txTo, txToLen);
CTransaction tx;
stream >> tx;
if (nIn >= tx.vin.size())
return set_error(err, bitcoinconsensus_ERR_TX_INDEX);
if (tx.GetSerializeSize(SER_NETWORK, PROTOCOL_VERSION) != txToLen)
return set_error(err, bitcoinconsensus_ERR_TX_SIZE_MISMATCH);
// Regardless of the verification result, the tx did not error.
set_error(err, bitcoinconsensus_ERR_OK);
return VerifyScript(tx.vin[nIn].scriptSig, CScript(scriptPubKey, scriptPubKey + scriptPubKeyLen), flags, TransactionSignatureChecker(&tx, nIn), NULL);
} catch (const std::exception&) {
return set_error(err, bitcoinconsensus_ERR_TX_DESERIALIZE); // Error deserializing
}
}
unsigned int bitcoinconsensus_version()
{
// Just use the API version for now
return BITCOINCONSENSUS_API_VER;
}
| [
"60665036+ErosCore@users.noreply.github.com"
] | 60665036+ErosCore@users.noreply.github.com |
d6164729d8772b3d49250aa41c9bfeebbf7b545b | 6b2a8dd202fdce77c971c412717e305e1caaac51 | /solutions_2449486_0/C++/gogokefakefa/B.cpp | 462f44674970a03b5cda1aefecceedf3de53fc03 | [] | 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 | 773 | cpp | #include <iostream>
#include <cstring>
using namespace std;
string solve(){
int N, M, a[128][128], row[128], col[128];
memset ( row, 0, sizeof ( row ) );
memset ( col, 0, sizeof ( col ) );
cin >> N >> M;
for ( int i = 0; i < N; ++i )
for ( int j = 0; j < M; ++j ){
cin >> a[i][j];
row[i] = max ( row[i], a[i][j] );
col[j] = max ( col[j], a[i][j] );
}
for ( int i = 0; i < N; ++i )
for ( int j = 0; j < M; ++j )
if ( a[i][j] < row[i] && a[i][j] < col[j] )
return "NO";
return "YES";
}
int main(){
int N;
cin >> N;
for ( int i = 1; i <= N; ++i )
cout << "Case #" << i << ": " << solve () << endl;
}
| [
"eewestman@gmail.com"
] | eewestman@gmail.com |
50bb52e129f8b6e32c867020fdaf5d17c22e4f5d | 730b92e439dbb013950b8bbf417cfde1bb40f8b9 | /Cpp/k-Sum.cpp | e1753e404b74a78eb4d28416c63916ebcc2cdb95 | [] | no_license | yuede/Lintcode | fdbca5984c2860c8b532b5f4d99bce400b0b26d0 | d40b7ca1c03af7005cc78b26b877a769ca0ab723 | refs/heads/master | 2021-01-13T04:14:32.754210 | 2015-08-22T13:15:54 | 2015-08-22T13:15:54 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 851 | cpp | #include <vector>
class Solution {
public:
/**
* @param A: an integer array.
* @param k: a positive integer (k <= length(A))
* @param target: a integer
* @return an integer
*/
int kSum(vector<int> A, int k, int target) {
// wirte your code here
int len = A.size();
//sort(A.begin(), A.end());
vector<vector<vector<int> > > dp(len + 1, vector<vector<int> >(k + 1, vector<int>(target + 1)));
dp[0][0][0] = 1;
for (int i = 1; i <= len; i ++) {
for (int j = 0; j <= k && j <= i; j ++) {
for (int v = 0; v <= target; v ++) {
if (v >= A[i-1] && j > 0) dp[i][j][v] += dp[i-1][j-1][v-A[i-1]];
dp[i][j][v] += dp[i-1][j][v];
}
}
}
return dp[len][k][target];
}
};
| [
"jiangyi0425@gmail.com"
] | jiangyi0425@gmail.com |
14d4005b10d6a317e848375ae8af9b83616ac87d | cbb8cc0b7d61961b1bb880435af5fb63b53454cd | /Check/v0.0.3/src/Corrector.CLI/cells/2016/516020910186/L61/L03/Teacher.h | 38ccb9b41fef191c0fe4dfac763e648650f42ad7 | [] | no_license | StarkShang/Projects | 91ba09570fb3ee4e655ae3ae1b855d18524fcd74 | 5f6a3332db2ae1e2188a5aad2826d18022f2f57c | refs/heads/master | 2020-07-30T05:43:13.708514 | 2017-04-17T13:51:23 | 2017-04-17T13:51:23 | 73,653,507 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 137 | h | #pragma once
#include "Person.h"
class Teacher
{
public:
char Name[1024];
bool Gender;
int Age;
int TeacherID;
char Title[1024];
}; | [
"stark.shang@sjtu.edu.cn"
] | stark.shang@sjtu.edu.cn |
638ca1cba40133869d71302eeab14adef59f9929 | 9bb840b2769020cc7379ac0b985137b77e3932ab | /skynet-src/mq/mq_private.h | e668af56a6216199e5abab2826cb17cb8b356d24 | [] | no_license | xxgamecom/skynet | 3ee79bebb329ccf4e3a2670856e78a2b345d619d | 51f9b8af198cc12a4dbf74a9e6ce3a45b609d8e4 | refs/heads/master | 2023-04-11T11:51:13.305672 | 2021-04-14T09:55:45 | 2021-04-14T09:55:45 | 346,594,062 | 0 | 0 | null | 2021-04-14T09:55:46 | 2021-03-11T05:56:12 | Lua | UTF-8 | C++ | false | false | 2,436 | h | /**
* service private message queue
*/
#pragma once
#include <stdlib.h>
#include <stdint.h>
#include <mutex>
namespace skynet {
// forward declare
struct service_message;
// message drop function
typedef void (*message_drop_proc)(service_message* message, void* ud);
/**
* service private message queue (one per service)
* memory alginment for performance
*/
class mq_private
{
private:
// constants
enum
{
DEFAULT_QUEUE_CAPACITY = 64, // default ring buffer size
DEFAULT_OVERLOAD_THRESHOLD = 1024, // default overload threshold
};
public:
std::mutex mutex_; // message ring buffer protect
uint32_t svc_handle_ = 0; // the service handle to which it belongs
bool is_release_ = false; // release mark(当delete ctx时会设置此标记)
bool is_in_global_ = true; // false: not in global mq; true: in global mq, or the message is dispatching.
int overload_ = 0; // current overload
int overload_threshold_ = DEFAULT_OVERLOAD_THRESHOLD; // 过载阈值,初始是MQ_OVERLOAD
int cap_ = DEFAULT_QUEUE_CAPACITY; // message ring buffer capacity
int head_ = 0; // message ring buffer header
int tail_ = 0; // message ring buffer tailer
service_message* queue_ = nullptr; // message ring buffer
mq_private* next_ = nullptr; // link list: next message queue ptr
public:
// factory method, create a service private message queue
static mq_private* create(uint32_t svc_handle);
// 服务释放标记
void mark_release();
// 尝试释放私有队列
void release(message_drop_proc drop_func, void* ud);
public:
// 0 for success
void push(service_message* message);
bool pop(service_message* message);
// return the length of message queue, for debug
int length();
// 获取负载情况
int overload();
uint32_t svc_handle();
private:
// 扩展循环数组
void _expand_queue();
// 释放队列, 释放服务,清空循环数组
static void _drop_queue(mq_private* q, message_drop_proc drop_func, void* ud);
};
}
| [
"41859513@qq.com"
] | 41859513@qq.com |
dfaf8294b2e9b8fa57ae79943ac27bb29138996e | 937d05a14fcbcb606c827cdc64fb0fd195efdccd | /C++_chap14/exercise14_18/String.h | 07f5a51760f25fbcea6fecd291c0c1cf3e90d059 | [] | no_license | mukoedo1993/cpp_primer_solutions | 40d8681b0a7451b5e82e2b41c4307a789cdd3eba | c25ffe173e85a6d7de3ef85712163a46b6d94901 | refs/heads/main | 2023-04-28T17:16:34.115045 | 2021-05-19T19:06:59 | 2021-05-19T19:06:59 | 368,727,879 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,528 | h | #include <memory>
#include <algorithm>
#include <iostream>
class String {
public:
friend bool operator==(const String&,const String&);
friend bool operator!=(const String&,const String&);
friend bool operator>(const String&,const String&);
friend bool operator<(const String&,const String&);
String() : String("") { }//delegate constructor
String(const char*);
String(const String&);
String& operator=(const String&);
~String();
const char* c_str() const { return elements; }
size_t size() const { return end - elements; }
size_t length() const { return end - elements - 1; }
private:
std::pair<char*, char*> alloc_n_copy(const char*, const char*);
void range_initializer(const char*, const char*);
void free();
char* elements;
char* end;
std::allocator<char>alloc;
};
std::pair<char*, char*>
String::alloc_n_copy(const char* b, const char* e)
{
auto str = alloc.allocate(e - b);
return{ str, std::uninitialized_copy(b, e, str) };
}
//std::uninitialized_copy: Return value
//Iterator to the element past the last element copied.
//b and e are not necessarily iterators. pointers are ok for char*.
//range_initializer takes two const char*, and use both as range to initialize elements and end.
void String::range_initializer(const char* first, const char* last)
{
auto newstr = alloc_n_copy(first, last);
elements = newstr.first;
end = newstr.second;
}
String::String(const char* s)
{
char* sl = const_cast<char*>(s);//cast a const char* into a char*
while (*sl)
++sl;
range_initializer(s, ++sl);
}
String::String(const String& rhs)
{
range_initializer(rhs.elements, rhs.end);
std::cout << "copy constructor" << std::endl;
}
void String::free()
{
if (elements) {
std::for_each(elements, end,
[this]
(char& c) { alloc.destroy(&c); });//the enclosing function 'this' cannot be referenced until it is in the capture list.
alloc.deallocate(elements, end - elements);
}
}
String::~String()
{
free();
}
String& String::operator = (const String& rhs)
{
auto newstr = alloc_n_copy(rhs.elements, rhs.end);
free();
elements = newstr.first;
end = newstr.second;
std::cout << "copy-assignment" << std::endl;
return *this;
}
#include<iostream>
#include<memory>
#include<string>
#include<vector>
using std::vector;
#include <algorithm>
std::ostream& operator<<(std::ostream &os, const String&Str)
{
std::for_each(Str.c_str(),Str.c_str()+Str.length(),[&](char c)->void{os<<c;});
return os;
} | [
"wangzcyuanfang1997@gmail.com"
] | wangzcyuanfang1997@gmail.com |
c5cb9ea2f776684aa0890987d794142aa104798a | d83e76f5440e67df1581c822c3ae54e43b71cdf5 | /services/network/test/test_url_loader_factory.h | bab4f6ee823f6498bfdd13d320aff7871290a70a | [
"BSD-3-Clause"
] | permissive | Abhik1998/chromium | cbc7ee4020fd1f1430db69f39593106da87632dc | 67e4e691e38bb788c891c2bfb5ce4da1ed86b0dd | refs/heads/master | 2023-03-20T08:42:16.199668 | 2019-10-01T07:20:09 | 2019-10-01T07:20:09 | 212,037,122 | 1 | 0 | BSD-3-Clause | 2019-10-01T07:30:28 | 2019-10-01T07:30:27 | null | UTF-8 | C++ | false | false | 8,119 | h | // Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef SERVICES_NETWORK_TEST_TEST_URL_LOADER_FACTORY_H_
#define SERVICES_NETWORK_TEST_TEST_URL_LOADER_FACTORY_H_
#include <map>
#include <string>
#include <vector>
#include "base/macros.h"
#include "base/memory/ref_counted.h"
#include "mojo/public/cpp/bindings/binding_set.h"
#include "net/http/http_status_code.h"
#include "services/network/public/cpp/resource_request.h"
#include "services/network/public/mojom/url_loader.mojom.h"
#include "services/network/public/mojom/url_loader_factory.mojom.h"
#include "services/network/public/mojom/url_response_head.mojom-forward.h"
namespace network {
class WeakWrapperSharedURLLoaderFactory;
// A helper class to ease testing code that uses URLLoader interface. A test
// would pass this factory instead of the production factory to code, and
// would prime it with response data for arbitrary URLs.
class TestURLLoaderFactory : public mojom::URLLoaderFactory {
public:
struct PendingRequest {
PendingRequest();
~PendingRequest();
PendingRequest(PendingRequest&& other);
PendingRequest& operator=(PendingRequest&& other);
mojom::URLLoaderClientPtr client;
ResourceRequest request;
uint32_t options;
};
// Bitfield that is used with |SimulateResponseForPendingRequest()| to
// control which request is selected.
enum ResponseMatchFlags : uint32_t {
kMatchDefault = 0x0,
kUrlMatchPrefix = 0x1, // Whether URLs are a match if they start with the
// URL passed in to
// SimulateResponseForPendingRequest
kMostRecentMatch = 0x2, // Start with the most recent requests.
};
// Flags used with |AddResponse| to control how it produces a response.
enum ResponseProduceFlags : uint32_t {
kResponseDefault = 0,
kResponseOnlyRedirectsNoDestination = 0x1,
kSendHeadersOnNetworkError = 0x2,
};
TestURLLoaderFactory();
~TestURLLoaderFactory() override;
using Redirects =
std::vector<std::pair<net::RedirectInfo, mojom::URLResponseHeadPtr>>;
// Adds a response to be served. There is one unique response per URL, and if
// this method is called multiple times for the same URL the last response
// data is used.
// This can be called before or after a request is made. If it's called after,
// then pending requests will be "woken up".
void AddResponse(const GURL& url,
mojom::URLResponseHeadPtr head,
const std::string& content,
const URLLoaderCompletionStatus& status,
Redirects redirects = Redirects(),
ResponseProduceFlags rp_flags = kResponseDefault);
// Simpler version of above for the common case of success or error page.
void AddResponse(const std::string& url,
const std::string& content,
net::HttpStatusCode status = net::HTTP_OK);
// Returns true if there is a request for a given URL with a living client
// that did not produce a response yet. If |request_out| is non-null,
// it will give a const pointer to the request.
// WARNING: This does RunUntilIdle() first.
bool IsPending(const std::string& url,
const ResourceRequest** request_out = nullptr);
// Returns the total # of pending requests.
// WARNING: This does RunUntilIdle() first.
int NumPending();
// Clear all the responses that were previously set.
void ClearResponses();
using Interceptor = base::RepeatingCallback<void(const ResourceRequest&)>;
void SetInterceptor(const Interceptor& interceptor);
// Returns a mutable list of pending requests, for consumers that need direct
// access. It's recommended that consumers use AddResponse() rather than
// servicing requests themselves, whenever possible.
std::vector<PendingRequest>* pending_requests() { return &pending_requests_; }
// Returns the PendingRequest instance available at the given index |index|
// or null if not existing.
PendingRequest* GetPendingRequest(size_t index);
// Sends a response for the first (oldest) pending request with URL |url|.
// Returns false if no such pending request exists.
// |flags| can be used to change the default behavior:
// - if kUrlMatchPrefix is set, the pending request is a match if its URL
// starts with |url| (instead of being equal to |url|).
// - if kMostRecentMatch is set, the most recent (instead of oldest) pending
// request matching is used.
bool SimulateResponseForPendingRequest(
const GURL& url,
const network::URLLoaderCompletionStatus& completion_status,
mojom::URLResponseHeadPtr response_head,
const std::string& content,
ResponseMatchFlags flags = kMatchDefault);
// Simpler version of above for the common case of success or error page.
bool SimulateResponseForPendingRequest(
const std::string& url,
const std::string& content,
net::HttpStatusCode status = net::HTTP_OK,
ResponseMatchFlags flags = kMatchDefault);
// Sends a response for the given request |request|.
//
// Differently from its variant above, this method does not remove |request|
// from |pending_requests_|.
//
// This method is useful to process requests at a given pre-defined order.
void SimulateResponseWithoutRemovingFromPendingList(
PendingRequest* request,
mojom::URLResponseHeadPtr head,
std::string content,
const URLLoaderCompletionStatus& status);
// Simpler version of the method above.
void SimulateResponseWithoutRemovingFromPendingList(PendingRequest* request,
std::string content);
// mojom::URLLoaderFactory implementation.
void CreateLoaderAndStart(mojom::URLLoaderRequest request,
int32_t routing_id,
int32_t request_id,
uint32_t options,
const ResourceRequest& url_request,
mojom::URLLoaderClientPtr client,
const net::MutableNetworkTrafficAnnotationTag&
traffic_annotation) override;
void Clone(mojom::URLLoaderFactoryRequest request) override;
// Returns a 'safe' ref-counted weak wrapper around this TestURLLoaderFactory
// instance.
//
// Because this is a weak wrapper, it is possible for the underlying
// TestURLLoaderFactory instance to be destroyed while other code still holds
// a reference to it.
//
// The weak wrapper returned by this method is guaranteed to have had
// Detach() called before this is destructed, so that any future calls become
// no-ops, rather than a crash.
scoped_refptr<network::WeakWrapperSharedURLLoaderFactory>
GetSafeWeakWrapper();
private:
bool CreateLoaderAndStartInternal(const GURL& url,
mojom::URLLoaderClient* client);
static void SimulateResponse(mojom::URLLoaderClient* client,
Redirects redirects,
mojom::URLResponseHeadPtr head,
std::string content,
URLLoaderCompletionStatus status,
ResponseProduceFlags response_flags);
struct Response {
Response();
~Response();
Response(Response&&);
Response& operator=(Response&&);
GURL url;
Redirects redirects;
mojom::URLResponseHeadPtr head;
std::string content;
URLLoaderCompletionStatus status;
ResponseProduceFlags flags;
};
std::map<GURL, Response> responses_;
std::vector<PendingRequest> pending_requests_;
scoped_refptr<network::WeakWrapperSharedURLLoaderFactory> weak_wrapper_;
Interceptor interceptor_;
mojo::BindingSet<network::mojom::URLLoaderFactory> bindings_;
DISALLOW_COPY_AND_ASSIGN(TestURLLoaderFactory);
};
} // namespace network
#endif // SERVICES_NETWORK_TEST_TEST_URL_LOADER_FACTORY_H_
| [
"commit-bot@chromium.org"
] | commit-bot@chromium.org |
a3250a304c6b1d24001ba7dffb12b8c3c1de484d | a06515f4697a3dbcbae4e3c05de2f8632f8d5f46 | /corpus/taken_from_cppcheck_tests/stolen_880.cpp | 8d88fae632af211308046aa3def38fd1895b20f1 | [] | no_license | pauldreik/fuzzcppcheck | 12d9c11bcc182cc1f1bb4893e0925dc05fcaf711 | 794ba352af45971ff1f76d665b52adeb42dcab5f | refs/heads/master | 2020-05-01T01:55:04.280076 | 2019-03-22T21:05:28 | 2019-03-22T21:05:28 | 177,206,313 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 88 | cpp | namespace NS {
class szp;
}
class NS::szp
{
NS::szp &operator =(int *other) {}
};
| [
"github@pauldreik.se"
] | github@pauldreik.se |
d13a632f5498bc0b4ccf413ac3ae6cbd7fc8caa8 | f1df3b167609f638fc740eec63d0209aec78a10b | /mainwindow.cpp | dfc135eb2cfa831a1cace0216093eaf93de5ee66 | [] | no_license | roman-zm/qBackup-old | 4ec7ea76f3d40e61d28830116c7937211e092149 | ff409b45b0c549c0fb7efb308ec66a559f1e7c47 | refs/heads/master | 2021-06-13T07:16:49.095941 | 2017-04-11T19:21:14 | 2017-04-11T19:21:14 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 13,391 | cpp | #include "mainwindow.h"
#include "ui_mainwindow.h"
#include "tasksettings.h"
#include "ydapi.h"
#ifdef Q_OS_WIN32
#include "quazip/JlCompress.h"
#endif
#ifdef Q_OS_LINUX
#include "quazip5/JlCompress.h"
#endif
#include <QJsonDocument>
#include <QJsonObject>
#include <QListWidget>
#include <QInputDialog>
#include <QMessageBox>
#include <QSystemTrayIcon>
#include <QApplication>
#include <QMenu>
#include <QAction>
#include <QCloseEvent>
#include <QTimer>
#include <QtConcurrentRun>
#include <QNetworkAccessManager>
#include <QNetworkReply>
#include <QNetworkRequest>
#include <QFileDialog>
#include <QProcess>
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
readTasks();
connect(ui->backupsList, SIGNAL(itemDoubleClicked(QListWidgetItem*)),
this, SLOT(showTaskSettings(QListWidgetItem*)));
trayMenu = new QMenu(this);
triggVisible = new QAction(tr("Show/Hide"), this);
exitApplication = new QAction(tr("Exit"), this);
connect(triggVisible, SIGNAL(triggered()), this, SLOT(toggleVisible()));
connect(exitApplication, SIGNAL(triggered(bool)), qApp, SLOT(quit()));
trayMenu->addAction(triggVisible);
trayMenu->addAction(exitApplication);
systemTray = new QSystemTrayIcon(this);
systemTray->setIcon(QIcon(qApp->applicationDirPath()+QDir::separator()+"Backup.png"));
systemTray->setVisible(true);
systemTray->setContextMenu(trayMenu);
timer = new QTimer(this);
timer->start(50000);
connect(timer, SIGNAL(timeout()), this, SLOT(timeoutBackupEvent()));
connect(timer, SIGNAL(timeout()), this, SLOT(powerOff()));
connect(this, SIGNAL(signalTrayMessage(bool)), this, SLOT(slotTrayMessage(bool)));
connect(this, SIGNAL(startYDBackupSignal(QString)), this, SLOT());
manager = new QNetworkAccessManager(this);
api = new YDApi();
api->setToken(qSett.value("Token").toString());
connect(this, SIGNAL(startYDBackupSignal(QString)), this, SLOT(uploadOnYD(QString)));
connect(api, SIGNAL(finished()), this, SLOT(backupFinished()));
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::backupFinished()
{
systemTray->showMessage(tr("Information"), tr("Uploading complete"));
if(qSett.value("YDPoweroffCheckBox").toBool()){
powerOff();
}
}
void MainWindow::on_actionSettings_triggered()
{
settingWindow.show();
}
void MainWindow::on_actionExit_triggered()
{
qApp->quit();
}
void MainWindow::on_actionAdd_triggered()
{
QString name;
bool ok;
do {
name = QInputDialog::getText(
this, tr("Name"),
tr("Enter new backup name:"),
QLineEdit::Normal,"",&ok);
} while(ok && name.isEmpty());
ui->backupsList->addItem(name);
saveTasks();
}
void MainWindow::saveTasks()
{
QStringList names;
for(int i=0; i<ui->backupsList->count(); i++){
names.push_back(ui->backupsList->item(i)->text());
}
qSett.setValue("tasks", names);
qSett.sync();
}
void MainWindow::readTasks()
{
QStringList names = qSett.value("tasks").toStringList();
for(int i=0; i<names.size(); i++){
ui->backupsList->addItem(names.at(i));
}
}
void MainWindow::showTaskSettings(QListWidgetItem *item)
{
taskSettings *task = new taskSettings(this, item->text());
task->show();
}
void MainWindow::on_actionDelete_triggered()
{
QString name = ui->backupsList->currentItem()->text();
qSett.remove(name);
ui->backupsList->takeItem(ui->backupsList->currentRow());
saveTasks();
}
void MainWindow::toggleVisible()
{
this->setVisible(!this->isVisible());
}
void MainWindow::runBackup(QString taskName)
{
QDir dir = qSett.value(QString("%1/DirName").arg(taskName)).toString();
QDir backDir = qSett.value(QString("%1/BackupDirName").arg(taskName)).toString();
if(dir.isReadable() && backDir.isReadable()){
systemTray->showMessage(tr("Backup"),tr("Starting backup: ") + taskName);
QtConcurrent::run(this, &MainWindow::startBackupInThread, taskName);
} else {
systemTray->showMessage(tr("Error"), tr("Error in task paths"),QSystemTrayIcon::Critical);
}
}
void MainWindow::startBackupInThread(QString taskName)
{
bool a = false;
QString fileName = qSett.value(QString("%1/BackupDirName").arg(taskName)).toString()+
QDir::separator()+taskName+"-"+QDate::currentDate().toString("dd.MM.yyyy");
QString tempFileName = fileName + ".zip";
if(QFile(tempFileName).exists()){
bool exist = true;
for(int i=0; exist != false; i++){
QString buffFileName = fileName+QString("(%1)").arg(i);
if(!QFile(buffFileName+".zip").exists()){
exist = false;
fileName = buffFileName+".zip";
}
}
} else {
fileName += ".zip";
}
a = JlCompress::compressDir(fileName,
qSett.value(QString("%1/DirName").arg(taskName)).toString(),
true,QDir::AllDirs);
if(a == true){
a = QFile(fileName).exists();
if(qSett.value(QString("%1/YDEnabled").arg(taskName)).toBool()){
emit startYDBackupSignal(fileName);
}
}
emit signalTrayMessage(a);
}
void MainWindow::uploadOnYD(QString fileName)
{
api->upload(fileName);
}
void MainWindow::on_runBackupButton_clicked()
{
if(ui->backupsList->selectedItems().empty())
QMessageBox::critical(this, tr("Error"), tr("Select task"));
else
runBackup(ui->backupsList->selectedItems().at(0)->text());
}
void MainWindow::on_pushButton_clicked()
{
for(int i=0; i<ui->backupsList->count(); i++){
runBackup(ui->backupsList->item(i)->text());
}
}
void MainWindow::closeEvent(QCloseEvent *event)
{
event->ignore();
this->hide();
}
void MainWindow::timeoutBackupEvent()
{
for(int i=0; i<ui->backupsList->count(); i++){
QString taskName = ui->backupsList->item(i)->text();
QTime taskTime = qSett.value(QString("%1/Time").arg(taskName)).toTime();
if(qSett.value(QString("%1/Enabled").arg(taskName)).toBool()){
if(taskTime.hour() == QTime::currentTime().hour() && taskTime.minute() == QTime::currentTime().minute()){
runBackup(taskName);
}
}
}
}
void MainWindow::powerOff()
{
QTime powerOffTime = qSett.value("PowerOffTime").toTime();
if(qSett.value("PowerOffEnabled").toBool()){
if(powerOffTime.hour() == QTime::currentTime().hour() &&
powerOffTime.minute() == QTime::currentTime().minute()){
#ifdef Q_OS_WIN32
QProcess::startDetached("shutdown -s -f -t 00");
#endif
#ifdef Q_OS_LINUX
QProcess::startDetached("shutdown -P now");
#endif
qApp->quit();
}
}
}
void MainWindow::slotTrayMessage(bool succes){
if(!succes){
systemTray->showMessage(tr("Error"),tr("Backuping error"),QSystemTrayIcon::Critical);
} else {
systemTray->showMessage(tr("Succes"),tr("Backuping succes"));
//if(qSett.value("YDEnabled").toBool()) uploadOnYD(fileName, taskName);
}
}
/***********говнокод********************/
//void MainWindow::uploadFile(QString UpUrl)
//{
// QFile *file = new QFile(QFileDialog::getOpenFileName());
// if(!file->open(QIODevice::ReadOnly)) qDebug() << "Dont read";
// QString token = qSett.value("Token").toString();
// QString url = ui->lineEdit->text();
// QNetworkRequest request;
// request.setUrl(QUrl(url));
// request.setRawHeader(QByteArray("Accept"), QByteArray("application/json"));
// request.setRawHeader(QByteArray("Authorization"), QByteArray(token.toUtf8()));
//// request.setHeader(QNetworkRequest::ContentTypeHeader, QVariant("text/plain"));
//// request.setRawHeader(QByteArray("path"), QByteArray("disk:/gelska.lol"));
//// request.setRawHeader(QByteArray("url"), QByteArray(UpUrl.toUtf8()));
// connect(manager, SIGNAL(finished(QNetworkReply*)), this, SLOT(slotFinished(QNetworkReply*)));
// //manager->post(request, file->readAll());
// manager->put(request, file);
//}
//void MainWindow::slotFinished(QNetworkReply* reply)
//{
// QString answer = QString::fromUtf8(reply->readAll());
// ui->textEdit->setPlainText(answer);
// disconnect(manager, SIGNAL(finished(QNetworkReply*)), this, SLOT(slotFinished(QNetworkReply*)));
//// QJsonDocument jsonDoc = QJsonDocument::fromJson(reply->readAll());
//// QJsonObject jsonObj = jsonDoc.object();
//// qDebug() << jsonObj["href"].toString();
//// uploadFile(jsonObj["href"].toString());
//// ui->textEdit->setPlainText();
// reply->deleteLater();
//}
//void MainWindow::on_pushButton_2_clicked()
//{
//// QString token = qSett.value("Token").toString();
//// QString url = "https://cloud-api.yandex.net:443/v1/disk/resources?path=disk:";
//// url.append(ui->lineEdit->text());
//// QNetworkRequest request;
//// request.setUrl(QUrl(url));
//// request.setRawHeader(QByteArray("Accept"), QByteArray("application/json"));
//// request.setRawHeader(QByteArray("Authorization"), QByteArray(token.toUtf8()));
//// request.setRawHeader(QByteArray("path"), QByteArray("disk:/"));
//// connect(manager, SIGNAL(finished(QNetworkReply*)), this, SLOT(slotFinished(QNetworkReply*)));
//// manager->get(request);
// uploadFile("lol");
//}
//void MainWindow::on_DownloadButt_clicked()
//{
// qDebug() << "Download func";
// QString token = qSett.value("Token").toString();
// QString url = "https://cloud-api.yandex.net:443/v1/disk/resources/upload?";
// url.append("path=disk:/test.txt");
// QNetworkRequest request;
// request.setUrl(QUrl(url));
// request.setRawHeader(QByteArray("Accept"), QByteArray("application/json"));
// request.setRawHeader(QByteArray("Authorization"), QByteArray(token.toUtf8()));
// connect(manager, SIGNAL(finished(QNetworkReply*)), this, SLOT(slotFinished(QNetworkReply*)));
// manager->get(request);
//}
//void MainWindow::uploadOnYD(QString fileName, QString taskName)
//{
// QString token = qSett.value("Token").toString();
// qDebug() << "Download on ya func";
// QString url = "https://cloud-api.yandex.net:443/v1/disk/resources/upload?path=disk:/";
// url.append(taskName+QDate::currentDate().toString("dd.MM.yyyy")+".zip");
// QNetworkRequest request;
// request.setUrl(QUrl(url));
// request.setRawHeader(QByteArray("Accept"), QByteArray("application/json"));
// request.setRawHeader(QByteArray("Authorization"), QByteArray(token.toUtf8()));
// QNetworkAccessManager *managerTwo = new QNetworkAccessManager();
// QEventLoop *loop = new QEventLoop(this);
// connect(managerTwo, SIGNAL(finished()), loop, SLOT(quit()));
// QNetworkReply *reply = managerTwo->get(request);
// qDebug() << "Start loop";
// loop->exec();
// qDebug() << "Disconnected";
// QJsonDocument jsonDoc = QJsonDocument::fromJson(reply->readAll());
// QJsonObject jsonObj = jsonDoc.object();
// qDebug() << jsonObj["href"].toString();
// //uploadFileOnYD(jsonObj["href"].toString(), fileName, taskName);
// url = jsonObj["href"].toString();
// QFile *file = new QFile(fileName);
// if(!file->open(QIODevice::ReadOnly)){
// qDebug() << "Dont read";
// return;
// }
// request.setUrl(QUrl(url));
// request.setRawHeader(QByteArray("Accept"), QByteArray("application/json"));
// request.setRawHeader(QByteArray("Authorization"), QByteArray(token.toUtf8()));
//// request.setHeader(QNetworkRequest::ContentTypeHeader, QVariant("text/plain"));
//// request.setRawHeader(QByteArray("path"), QByteArray("disk:/gelska.lol"));
//// request.setRawHeader(QByteArray("url"), QByteArray(UpUrl.toUtf8()));
// disconnect(managerTwo, SIGNAL(finished()), loop, SLOT(quit()));
// connect(manager, SIGNAL(finished(QNetworkReply*)), this, SLOT(slotFinished(QNetworkReply*)));
// manager->put(request, file);
//}
//void MainWindow::uploadFileOnYD(QString url, QString fileName, QString taskName)
//{
// QFile *file = new QFile(fileName);
// if(!file->open(QIODevice::ReadOnly)){
// qDebug() << "Dont read";
// return;
// }
// QString token = qSett.value("Token").toString();
// QNetworkRequest request;
// request.setUrl(QUrl(url));
// request.setRawHeader(QByteArray("Accept"), QByteArray("application/json"));
// request.setRawHeader(QByteArray("Authorization"), QByteArray(token.toUtf8()));
//// request.setHeader(QNetworkRequest::ContentTypeHeader, QVariant("text/plain"));
//// request.setRawHeader(QByteArray("path"), QByteArray("disk:/gelska.lol"));
//// request.setRawHeader(QByteArray("url"), QByteArray(UpUrl.toUtf8()));
// connect(manager, SIGNAL(finished(QNetworkReply*)), this, SLOT(slotFinished(QNetworkReply*)));
// manager->put(request, file);
//}
| [
"roman.zm98@gmail.com"
] | roman.zm98@gmail.com |
9b71760461ac5c820b589a9f0bc31ce12fc927af | 606a8c3a5d704814480586dfbf159cd828711c92 | /src/stereo_processor/stereo_processor.cpp | 44c43814c6059be63b76c620891a1b13b53805fa | [
"MIT"
] | permissive | CharlesAO/dsvo | a6f624292a54f9abb297a18d2f3097ac16c2c069 | a6d6f3a5377b472550fd3f48308adc701ed5c679 | refs/heads/master | 2020-04-14T10:44:38.584541 | 2018-12-22T17:56:45 | 2018-12-22T17:56:45 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 21,739 | cpp | #include "stereo_processor/stereo_processor.hpp"
#include <thread>
#define PROP_DEBUG false
void StereoProcessor::track(const cv::Mat& _cur_img0, const cv::Mat& _cur_img1, double _cur_time) {
cur_time = _cur_time;
// need to restart
if(last_time > cur_time || (cur_time-last_time) > 1.0 || param_changed) {
std::cout<<"Reset"<<std::endl;
state.reset();
keyframes.clear();
point_cloud->clear();
param_changed = false;
init_time = cur_time;
}
std::clock_t frame_start = std::clock();
cv::GaussianBlur(_cur_img0, cur_img0, cv::Size(BLUR_SZ,BLUR_SZ), BLUR_VAR);
cv::GaussianBlur(_cur_img1, cur_img1, cv::Size(BLUR_SZ,BLUR_SZ), BLUR_VAR);
monoTrack();
state.showPose(stereo_match_flag);
time_ofs << "0 " << cur_time-init_time <<" "<< (std::clock() - frame_start) / (double)(CLOCKS_PER_SEC / 1000) << " -1" << std::endl;
// if(DEBUG) cv::waitKey();
}
void StereoProcessor::monoTrack() {
std::clock_t frame_start = std::clock();
state.time = ros::Time(cur_time);
//initialize key_frame at start or when state propagtion has too few points
if (keyframes.empty() || last_frame.feature_points.size() < PROP_MIN_POINTS) {
// if(DEBUG)
{
if(last_frame.feature_points.size() < PROP_MIN_POINTS) std::cout<<"state propagtion does not has enough points: "<<last_frame.feature_points.size()<<std::endl;
}
KeyFrame keyframe = createKeyFrame(state.pose);
keyframes.push_back(keyframe);
stereo_match_flag = true;
time_ofs << "3 " << cur_time-init_time <<" "<< (std::clock() - frame_start) / (double)(CLOCKS_PER_SEC / 1000) << " -1" << std::endl;
last_frame.features = keyframe.new_features;
last_frame.feature_points = keyframe.feature_points;
last_frame.pose_from_lastKF = Pose();
last_frame.img = keyframe.img0.clone();
last_time = cur_time;
R_last_frame = Eigen::Matrix3d::Identity();
t_last_frame = Eigen::Vector3d::Zero();
return;
}
lastKF = &keyframes.back();
// feature tracking for new points of new KeyFrame
if(!TEST_STEREO) {
if(!MULTI_THREAD) featureTrack(cur_img0);
else featureFrameQueue.push(cur_img0);
}
// propagate current state using existing feature points
if(!propagateState()) return;
time_ofs << "1 " << cur_time-init_time <<" "<< (std::clock() - frame_start) / (double)(CLOCKS_PER_SEC / 1000) << " " << last_frame.feature_points.size() << std::endl;
// transformation from lastKF, accumulated by propagtion
Eigen::Matrix3d R_lastKF_c2w = lastKF->pose.orientation.toRotationMatrix() * cam0.R_C2B;
Eigen::Vector3d t_lastKF_c2w = lastKF->pose.orientation.toRotationMatrix() * cam0.t_C2B + lastKF->pose.position;
Eigen::Matrix3d R_cur_c2w = state.pose.orientation.toRotationMatrix() * cam0.R_C2B;
Eigen::Vector3d t_cur_c2w = state.pose.orientation.toRotationMatrix() * cam0.t_C2B + state.pose.position;
Eigen::Matrix3d R_lastKF2Cur = R_cur_c2w.transpose() * R_lastKF_c2w;
Eigen::Vector3d t_lastKF2Cur = R_cur_c2w.transpose() * (t_lastKF_c2w - t_cur_c2w);
if(DEBUG) std::cout<<std::endl<<"propagateState: "<<last_frame.feature_points.size()<<" t_lastKF2Cur norm "<<t_lastKF2Cur.norm()<<std::endl;
// create new KeyFrame after moving enough distance
if (t_lastKF2Cur.norm()>KF_DIST)
{
if(MULTI_THREAD) {
while(!featureFrameQueue.empty()) {
std::this_thread::sleep_for (std::chrono::nanoseconds(1));
}
}
std::clock_t kf_start = std::clock();
if(TEST_STEREO) {
KeyFrame keyframe;
keyframe = createKeyFrame(state.pose);
keyframes.push_back(keyframe);
last_frame.feature_points = keyframe.feature_points;
last_frame.pose_from_lastKF = Pose();
time_ofs << "3 " << cur_time-init_time <<" "<< (std::clock() - kf_start) / (double)(CLOCKS_PER_SEC / 1000) << " -1" << std::endl;
} else {
cv::Mat R, t;
cv::eigen2cv(R_lastKF2Cur, R);
cv::eigen2cv(t_lastKF2Cur, t);
KFData kf_data(R, t, lastKF->feature_points, last_frame.feature_points.features(), lastKF->new_features, last_frame.features);
// create new KeyFrame if reconstructAndOptimize succeed
FeaturePoints new_feature_points;
std::vector<bool> new_pts_flags;
if(reconstructAndOptimize(kf_data, state.pose, new_feature_points, new_pts_flags)) {
// construct new keyframe
KeyFrame keyframe;
keyframe = createKeyFrame(state.pose, new_feature_points, new_pts_flags);
stereo_match_flag = false;
keyframes.push_back(keyframe);
// if (LOOP_CLOSURE) {
// // std::clock_t start = std::clock();
// local_KF_optimizer.optimize(keyframes, 5, cam0);
// // std::cout << "local_KF_optimizer: " << (std::clock() - start) / (double)(CLOCKS_PER_SEC / 1000) << " ms" << std::endl;
// }
// update last frame with new points
last_frame.features = keyframe.new_features;
last_frame.feature_points = keyframe.feature_points;
last_frame.pose_from_lastKF = Pose();
time_ofs << "2 " << cur_time-init_time <<" "<< (std::clock() - kf_start) / (double)(CLOCKS_PER_SEC / 1000) << " -1" << std::endl;
}
}
}
// update last_frame
last_frame.img = cur_img0.clone();
last_time = cur_time;
cv::waitKey(1);
}
void StereoProcessor::featureTrackThread() {
while(true) {
if(!thread_featureTrack_running) break;
if(!featureFrameQueue.empty()) {
cv::Mat& cur_img = featureFrameQueue.front();
std::vector<cv::Point2f> cur_features;
featureTrack(cur_img);
featureFrameQueue.pop();
} else {
std::this_thread::sleep_for (std::chrono::milliseconds(1));
}
}
}
void StereoProcessor::featureTrack(const cv::Mat& cur_img) {
if(last_frame.features.empty()) return;
std::clock_t start = std::clock();
// bi-directional optical flow to find feature correspondence temporally
std::vector<cv::Point2f> last_frame_features_back, lastKF_features_inlier, last_frame_features_inlier, cur_features, cur_features_inlier;
std::vector<uchar> status, status_back;
std::vector<float> err, err_back;
cv::calcOpticalFlowPyrLK(last_frame.img, cur_img, last_frame.features, cur_features, status, err, cv::Size(OF_size,OF_size), FEATURE_OF_PYMD-1);
cv::calcOpticalFlowPyrLK(cur_img, last_frame.img, cur_features, last_frame_features_back, status_back, err_back, cv::Size(OF_size,OF_size), FEATURE_OF_PYMD-1);
// remove outliers
cv::Mat line_img;
cv::vconcat(lastKF->img0, cur_img, line_img);
for(int i=0; i<status.size(); i++){
// remove outlier by forward-backward matching
if(!status[i] || !status_back[i] || cv::norm(last_frame.features[i]-last_frame_features_back[i]) > 1) continue;
lastKF_features_inlier.push_back(lastKF->new_features[i]);
last_frame_features_inlier.push_back(last_frame.features[i]);
cur_features_inlier.push_back(cur_features[i]);
if(DEBUG) cv::line(line_img, lastKF->new_features[i], cv::Point2f(cur_features[i].x, cur_features[i].y+lastKF->img0.rows), cv::Scalar(255,0,0));
}
if(DEBUG) std::cout<<"featureTrack: "<<status.size()<<" -> "<<cur_features_inlier.size()<<std::endl;
if(DEBUG) cv::imshow("featureTrack", line_img);
lastKF->new_features = lastKF_features_inlier;
last_frame.features = cur_features_inlier;
if(!MULTI_THREAD) time_ofs << "11 " << cur_time-init_time << " " << (std::clock() - start) / (double)(CLOCKS_PER_SEC / 1000) << " -1" << std::endl;
}
bool StereoProcessor::propagateState() {
std::clock_t start = std::clock();
/******************************************calculate pose by direct method******************************************/
double dist = pose_estimater.poseEstimate(last_frame.feature_points, last_frame.img, cam0.K, cur_img0, PROP_PYMD, PROP_MAX_STEP, R_last_frame, t_last_frame);
time_ofs << "121 " << cur_time-init_time << " " << (std::clock() - start) / (double)(CLOCKS_PER_SEC / 1000) << " -1" << std::endl;
/******************************************calculate pose by direct method******************************************/
/******************************************find feature correspondences by optical flow******************************************/
start = std::clock();
cv::Mat r_cv, R_cv, t_cv;
cv::eigen2cv(R_last_frame, R_cv);
cv::eigen2cv(t_last_frame, t_cv);
cv::Rodrigues(R_cv, r_cv);
std::vector<cv::Point2f> cur_features, cur_features_refined;
cv::projectPoints(last_frame.feature_points.points(), r_cv, t_cv, cam0.K, cv::Mat::zeros(1,4,CV_64F), cur_features);
cur_features_refined = cur_features;
std::vector<uchar> status;
std::vector<float> err;
cv::calcOpticalFlowPyrLK(last_frame.img, cur_img0, last_frame.feature_points.features(), cur_features_refined, status, err, cv::Size(OF_size,OF_size), PROP_PYMD,
cv::TermCriteria(cv::TermCriteria::COUNT+cv::TermCriteria::EPS, 30, 0.01), cv::OPTFLOW_USE_INITIAL_FLOW);
// remove point outliers
std::vector<cv::Point2f> lastKF_features_inlier, cur_features_refined_inlier;
PointsWithUncertainties lastKF_points_inlier;
for(int i=0; i<status.size(); i++){
if(!status[i]) continue;
cur_features_refined_inlier.push_back(cur_features_refined[i]);
lastKF_features_inlier.push_back(lastKF->feature_points[i].feature);
lastKF_points_inlier.push_back(lastKF->feature_points[i].point.point, cv::norm(cur_features[i] - cur_features_refined[i])); //TODO
}
if(DEBUG) std::cout<<"propagate refine: "<<last_frame.feature_points.size()<<" -> "<<lastKF_points_inlier.size()<<std::endl;
if(float(lastKF_points_inlier.size()) / last_frame.feature_points.size() < PROP_PTS_RATIO){
std::cout<<"propagateState refine ratio too low: "<<float(lastKF_points_inlier.size()) / last_frame.feature_points.size()<<std::endl;
R_last_frame = Eigen::Matrix3d::Identity();
t_last_frame = Eigen::Vector3d::Zero();
last_frame.feature_points.clear();
// cv::waitKey();
return false;
}
/******************************************find feature correspondences by optical flow******************************************/
/******************************************refine pose******************************************/
Eigen::Matrix3d R_lastKF = R_last_frame * last_frame.pose_from_lastKF.orientation.toRotationMatrix();
Eigen::Vector3d t_lastKF = R_last_frame * last_frame.pose_from_lastKF.position + t_last_frame;
if(DEBUG) {
cv::Mat test = cur_img0.clone();
helper::project3DPtsToImg(lastKF_points_inlier.points(), cam0.K, R_lastKF, t_lastKF, test);
cv::imshow("refine_pose before", test);
}
pose_estimater.refine_pose(lastKF_points_inlier, cur_features_refined_inlier, cam0.K, R_lastKF, t_lastKF);
if(DEBUG) {
cv::Mat test1 = cur_img0.clone();
helper::project3DPtsToImg(lastKF_points_inlier.points(), cam0.K, R_lastKF, t_lastKF, test1);
cv::imshow("refine_pose after", test1);
}
// propagate feature_points to current frame
cv::eigen2cv(R_lastKF, R_cv);
cv::eigen2cv(t_lastKF, t_cv);
cv::Scalar marker_color = cv::Scalar(0,0,255);
if(TEST_STEREO || stereo_match_flag) marker_color = cv::Scalar(0,255,0);
lastKF->feature_points.clear();
last_frame.feature_points.clear();
cv::Mat prop_img;
int marker_size = prop_img.rows / 50;
if(PROP_DEBUG) {
prop_img = cur_img0.clone();
cv::cvtColor(prop_img, prop_img, cv::COLOR_GRAY2BGR);
}
for(int i=0; i<lastKF_points_inlier.size(); i++) {
// project points from lastKF to current frame according to refined pose
cv::Point3f& p = lastKF_points_inlier[i].point;
cv::Mat new_p_m = R_cv * (cv::Mat_<double>(3,1) << p.x, p.y, p.z) + t_cv;
cv::Mat pm = cam0.K*new_p_m;
cv::Point2f proj = cv::Point2f(pm.at<double>(0) / pm.at<double>(2),pm.at<double>(1) / pm.at<double>(2));
cv::Point2f& f = cur_features_refined_inlier[i]; // current feature position refined by optical flow
if(PROP_DEBUG) {
cv::circle(prop_img, f, 3, cv::Scalar(0,255,0));
cv::line(prop_img, f, proj, cv::Scalar(0,255,255));
}
// remove outlier by reprojection error
double reproj_err = sqrt((proj.x-f.x)*(proj.x-f.x)+(proj.y-f.y)*(proj.y-f.y));
if(reproj_err<PROP_PROJ_DIST) {
lastKF->feature_points.push_back(lastKF_features_inlier[i], lastKF_points_inlier[i].point, reproj_err); //TODO
last_frame.feature_points.push_back(f, cv::Point3f(new_p_m), reproj_err);
if(PROP_DEBUG) cv::drawMarker(prop_img, proj, marker_color, cv::MARKER_CROSS, marker_size);
}
else {
if(PROP_DEBUG) cv::circle(prop_img, proj, 4, cv::Scalar(0,0,255));
}
}
if(DEBUG) std::cout<<"propagateState ratio "<<lastKF->feature_points.size()<<" / "<<lastKF_points_inlier.size()<<std::endl;
if(PROP_DEBUG) cv::imshow("propagate projection", prop_img);
if(float(lastKF->feature_points.size()) / lastKF_points_inlier.size() < PROP_PTS_RATIO){
std::cout<<"propagateState ratio too low: "<<float(lastKF->feature_points.size()) / lastKF_points_inlier.size()<<std::endl;
R_last_frame = Eigen::Matrix3d::Identity();
t_last_frame = Eigen::Vector3d::Zero();
last_frame.feature_points.clear();
// cv::waitKey();
return false;
}
time_ofs << "122 " << cur_time-init_time << " " << (std::clock() - start) / (double)(CLOCKS_PER_SEC / 1000) << " -1" << std::endl;
/******************************************refine pose******************************************/
// propagate last frame pose
last_frame.pose_from_lastKF.orientation = Eigen::Quaterniond(R_lastKF);
last_frame.pose_from_lastKF.position = t_lastKF;
// propagate state
Eigen::Matrix3d _R = lastKF->pose.orientation.toRotationMatrix() * cam0.R_C2B * R_lastKF.transpose();
Eigen::Matrix3d R_w = _R * cam0.R_B2C;
Eigen::Vector3d t_w = _R*(cam0.t_B2C-t_lastKF) + lastKF->pose.orientation.toRotationMatrix()*cam0.t_C2B + lastKF->pose.position;
Eigen::Vector3d velocity = (t_w - lastKF->pose.position) / (cur_time - lastKF->time);
if(velocity.norm() > MAX_VEL) {
std::cout<<"exceed max velocity: "<<velocity.norm()<<std::endl;
last_frame.feature_points.clear();
R_last_frame = Eigen::Matrix3d::Identity();
t_last_frame = Eigen::Vector3d::Zero();
return false;
}
state.pose.position = t_w;
state.pose.orientation = Eigen::Quaterniond(R_w);
return true;
}
bool StereoProcessor::reconstructAndOptimize(KFData& kf_data, Pose& cur_pose, FeaturePoints& curKF_fts_pts, std::vector<bool>& curKF_new_pts_flags)
{
std::clock_t start = std::clock();
//store original scale and normalize translation
double scale = cv::norm(kf_data.t_lastKF2Cur); // initial scale
kf_data.t_lastKF2Cur = kf_data.t_lastKF2Cur / scale; // normalize translation
/******************************************reconstruct and bundle adjust******************************************/
float orig_fts_size = kf_data.size();
cv::Mat _t_lastKF2Cur = kf_data.t_lastKF2Cur;
cv::transpose(_t_lastKF2Cur, _t_lastKF2Cur);
reconstructor.reconstructAndBundleAdjust(kf_data, cam0.K, BA_MAX_STEP, BA_REPROJ_DIST);
cv::Mat _angle = _t_lastKF2Cur*kf_data.t_lastKF2Cur;
double angle = _angle.at<double>(0,0);
if(DEBUG) std::cout<<"reconstructAndBundleAdjust angle= "<<angle<<" ratio= "<<kf_data.size() << "/" << orig_fts_size<<std::endl;
if(angle<0.9 || kf_data.size() / orig_fts_size < BA_INLIER_THRES) {
R_last_frame = Eigen::Matrix3d::Identity();
t_last_frame = Eigen::Vector3d::Zero();
return false;
}
time_ofs << "131 " << cur_time-init_time << " " << (std::clock() - start) / (double)(CLOCKS_PER_SEC / 1000) << " -1" << std::endl;
// draw reconstruction reprojection
if(DEBUG) {
cv::Mat r_vec;
cv::Rodrigues(kf_data.R_lastKF2Cur, r_vec);
std::vector<cv::Point2f> reproj0_pts, reproj1_pts;
cv::projectPoints(kf_data.points.points(), cv::Mat::zeros(3,1,CV_64F), cv::Mat::zeros(3,1,CV_64F), cam0.K, cv::Mat::zeros(1,4,CV_64F), reproj0_pts);
cv::projectPoints(kf_data.points.points(), r_vec, kf_data.t_lastKF2Cur, cam0.K, cv::Mat::zeros(1,4,CV_64F), reproj1_pts);
cv::Mat reproj0(lastKF->img0), reproj1(cur_img0);
cv::cvtColor(reproj0, reproj0, cv::COLOR_GRAY2BGR);
cv::cvtColor(reproj1, reproj1, cv::COLOR_GRAY2BGR);
int marker_size = reproj0.rows / 50;
for(int i=0; i<kf_data.size(); i++) {
cv::circle(reproj0, kf_data.lastKF_features[i], marker_size, cv::Scalar(255,0,0));
cv::drawMarker(reproj0, reproj0_pts[i], cv::Scalar(0,0,255), cv::MARKER_CROSS, marker_size);
cv::circle(reproj1, kf_data.cur_features[i], marker_size, cv::Scalar(255,0,0));
cv::drawMarker(reproj1, reproj1_pts[i], cv::Scalar(0,0,255), cv::MARKER_CROSS, marker_size);
}
cv::Mat reproj;
cv::hconcat(reproj0, reproj1, reproj);
cv::imshow("reconstructAndBundleAdjust", reproj);
cv::waitKey(1);
}
/******************************************reconstruct and bundle adjust******************************************/
/******************************************scale optimization******************************************/
start = std::clock();
double new_scale = scale;
double scale_err = scale_optimizer.optimize(kf_data.lastKF_features, kf_data.points, new_scale, cam1, lastKF->img0, lastKF->img1, SCALE_PYMD, SCALE_MAX_STEP);
if(DEBUG) std::cout<<"scale optimize err "<<scale_err<<std::endl;
// if(scale_err > 100.0) return false;
time_ofs << "132 " << cur_time-init_time << " " << (std::clock() - start) / (double)(CLOCKS_PER_SEC / 1000) << " -1" << std::endl;
if(!(new_scale>0.01 && new_scale<2*scale)) {
std::cout<<"bad scale after: "<<new_scale<<std::endl;
R_last_frame = Eigen::Matrix3d::Identity();
t_last_frame = Eigen::Vector3d::Zero();
return false;
}
scale = new_scale;
// rescale translation
kf_data.t_lastKF2Cur = scale*kf_data.t_lastKF2Cur;
// rescale points generated from reconstructAndBundleAdjust
for(int i=0; i<kf_data.size(); i++) {
kf_data.points[i].point = scale*kf_data.points[i].point;
}
// show scale optimization result
if(DEBUG) {
std::vector<cv::Point2f> lastKF_pts_proj;
cv::Mat r_cv;
cv::Rodrigues(cam1.stereo.R, r_cv);
cv::projectPoints(kf_data.points.points(), r_cv, cam1.stereo.t, cam1.K, cv::Mat::zeros(1,4,CV_64F), lastKF_pts_proj);
cv::Mat scale_img = lastKF->img1.clone();
cv::cvtColor(scale_img, scale_img, cv::COLOR_GRAY2BGR);
int marker_size = scale_img.rows / 50;
for(int i=0; i<lastKF_pts_proj.size(); i++) {
double u = lastKF_pts_proj[i].x;
double v = lastKF_pts_proj[i].y;
if(0<=u && u<scale_img.cols && 0<=v && v<scale_img.rows) {
cv::drawMarker(scale_img, cv::Point2d(u, v), cv::Scalar(0,0,255), cv::MARKER_CROSS, marker_size);
}
}
cv::imshow("scale optimization", scale_img);
}
/******************************************scale optimization******************************************/
// bring points to current frame
for(int i=0; i<kf_data.size(); i++) {
cv::Point3f p = kf_data.points[i].point;
cv::Mat p_cur = (kf_data.R_lastKF2Cur *(cv::Mat_<double>(3,1)<<p.x, p.y, p.z)) + kf_data.t_lastKF2Cur;
curKF_fts_pts.push_back(kf_data.cur_features[i],
cv::Point3f(p_cur.at<double>(0,0), p_cur.at<double>(1,0), p_cur.at<double>(2,0)),
kf_data.points[i].uncertainty);
curKF_new_pts_flags.push_back(kf_data.new_pts_flags[i]);
}
// [deprecated] refine stereo correspondence with LK
// if(REFINE_PIXEL) {
// curKF_fts_pts.clear();
// std::vector<cv::Point2f> lastKF_pts_proj;
// cv::Mat r_cv;
// cv::Rodrigues(cam1.stereo.R, r_cv);
// cv::projectPoints(kf_data.points.points(), r_cv, cam1.stereo.t, cam1.K, cv::Mat::zeros(1,4,CV_64F), lastKF_pts_proj);
//
// float MAX_DISP = 50.0;
// std::vector<uchar> status;
// std::vector<float> err;
// cv::calcOpticalFlowPyrLK(lastKF->img0, lastKF->img1, kf_data.lastKF_features, lastKF_pts_proj, status, err);
//
// float cx = cam0.K.at<double>(0,2);
// float cy = cam0.K.at<double>(1,2);
// float B = cam0.stereo.t.at<double>(0,0);
// float f = cam0.K.at<double>(0,0);
// float fB = f*B;
// for(int i=0; i<status.size(); i++) {
// if(!status[i]) continue;
// //triangulate point from stereo correspondence
// float u = kf_data.lastKF_features[i].x;
// float v = kf_data.lastKF_features[i].y;
// float dx = u - lastKF_pts_proj[i].x;
// float dy = v - lastKF_pts_proj[i].y;
// if (!(dx > 0 && dx<MAX_DISP && fabs(dy)<1)) continue;
//
// float z = fB / dx;
// float x = (u - cx) * z / f;
// float y = (v - cy) * z / f;
// cv::Point3f p(x, y, z);
//
// // bring it to current frame
// cv::Mat p_cur = (kf_data.R_lastKF2Cur *(cv::Mat_<double>(3,1)<<p.x, p.y, p.z)) + kf_data.t_lastKF2Cur;
//
// curKF_fts_pts.push_back(kf_data.cur_features[i],
// cv::Point3f(p_cur.at<double>(0,0), p_cur.at<double>(1,0), p_cur.at<double>(2,0)),
// kf_data.points[i].uncertainty);
// }
// }
// update current state
Eigen::Matrix3d R_lastKF2Cur_eigen;
Eigen::Vector3d t_lastKF2Cur_eigen;
cv::cv2eigen(kf_data.R_lastKF2Cur, R_lastKF2Cur_eigen);
cv::cv2eigen(kf_data.t_lastKF2Cur, t_lastKF2Cur_eigen);
Eigen::Matrix3d R_w2Cur = R_lastKF2Cur_eigen * cam0.R_B2C * lastKF->pose.orientation.toRotationMatrix().transpose();
Eigen::Vector3d t_Cur = (Eigen::Matrix3d::Identity() - R_lastKF2Cur_eigen) * cam0.t_B2C;
cur_pose.position = lastKF->pose.position - R_w2Cur.transpose() * (t_lastKF2Cur_eigen - t_Cur);
cur_pose.orientation = Eigen::Quaterniond(R_w2Cur.transpose() * cam0.R_B2C);
return true;
}
| [
"kimiwings@gmail.com"
] | kimiwings@gmail.com |
4e7f71bbe7d309283b071ffb6c764d762fb18790 | 49cfc3f1a96b3f75adf74821342999a20da3e04d | /include/threads/named_condition_variable.inl | d4ec719d56e0655e4f32e2ea8b42bb4f39b612c7 | [
"MIT"
] | permissive | mrexodia/CppCommon | bfb4456b984ceea64dd98853816f388c29bfe006 | 422bec80be2412e909539b73be40972ecc8acf83 | refs/heads/master | 2020-05-17T15:10:23.069691 | 2019-04-25T14:36:20 | 2019-04-25T14:36:20 | 183,780,482 | 1 | 0 | MIT | 2019-04-27T14:05:08 | 2019-04-27T14:05:08 | null | UTF-8 | C++ | false | false | 689 | inl | /*!
\file named_condition_variable.inl
\brief Named condition variable synchronization primitive inline implementation
\author Ivan Shynkarenka
\date 04.10.2016
\copyright MIT License
*/
namespace CppCommon {
template <typename TPredicate>
void NamedConditionVariable::Wait(TPredicate predicate)
{
while (!predicate())
Wait();
}
template <typename TPredicate>
bool NamedConditionVariable::TryWaitFor(const Timespan& timespan, TPredicate predicate)
{
Timestamp timeout = UtcTimestamp() + timespan;
while (!predicate())
if (!TryWaitFor(timeout - UtcTimestamp()))
return predicate();
return true;
}
} // namespace CppCommon
| [
"chronoxor@gmail.com"
] | chronoxor@gmail.com |
eb286045a70bf06531da98f2610c5ffaacbfe20f | a1804529be44f876f55143a66396381da743c229 | /code/Graphs/MVC.cpp | dae94c8f5a1f7b3acd5d121683e7c3040088bd83 | [] | no_license | dcordb/icpc-reference | 73fc0644e88c87f3447af9aab650f65f8aaf3bdc | 9d2b6e52cd807696e63987092372ee227cf36e6e | refs/heads/master | 2023-03-25T00:58:34.403609 | 2023-03-12T22:54:53 | 2023-03-12T22:54:53 | 214,291,425 | 1 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 1,207 | cpp | //Minimum Vertex Cover (taken from Wikipedia) to use with Hopcroft Karp or Kuhn Matching
//this goes in the namespace of HK or kuhn
//remember that Maximum Independet Set is the complement of a MVC
//MVC is minimum number of nodes to cover all edges
//MIS is maximum number of nodes such that there are not two adjacents
vector <int> getVertexCover() { //remember call getMaxFlow first
vector <int> lft, rgt;
queue <int> q;
for(int i = 1; i <= n; i++) {
if(i <= l) {
lft.push_back(i);
if(left[i] == 0)
q.push(i);
}
else rgt.push_back(i);
}
vector <int> mk(n + 1, 0);
vector <int> z;
while(!q.empty()) {
int u = q.front();
q.pop();
if(u == 0 || mk[u])
continue;
mk[u] = 1;
z.push_back(u);
for(int v : g[u]) {
if(left[u] == v)
continue;
if(!mk[v]) {
mk[v] = 1;
z.push_back(v);
q.push(right[v]);
}
}
}
sort(z.begin(), z.end());
vector <int> s1, s2, res;
set_difference(lft.begin(), lft.end(), z.begin(), z.end(), inserter(s1, s1.begin()));
set_intersection(rgt.begin(), rgt.end(), z.begin(), z.end(), inserter(s2, s2.begin()));
set_union(s1.begin(), s1.end(), s2.begin(), s2.end(), inserter(res, res.begin()));
return res;
} | [
"dcordb97@gmail.com"
] | dcordb97@gmail.com |
c0dac40572b0194ea78ece348e5c23429674d4d3 | 673913dd2bce4eec6eea66a92ebbdd41dca724ca | /src/Simd/src/Simd/SimdBaseResizeBilinear.cpp | a7320464a9bf01fbe6c7115967eee9aebbc3bbff | [] | no_license | fengbingchun/CUDA_Test | e0dc844d8b683c664ad870e0b5287c4765b47a12 | 9c554a2efe1d2a1b087c26be95102865b4d13e88 | refs/heads/master | 2023-05-30T03:02:00.374290 | 2023-05-21T04:39:58 | 2023-05-21T04:39:58 | 53,768,351 | 101 | 38 | null | null | null | null | UTF-8 | C++ | false | false | 5,498 | cpp | /*
* Simd Library (http://simd.sourceforge.net).
*
* Copyright (c) 2011-2015 Yermalayeu Ihar.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
#include <math.h>
#include "Simd/SimdMemory.h"
#include "Simd/SimdConst.h"
#include "Simd/SimdMath.h"
#include "Simd/SimdBase.h"
namespace Simd
{
namespace Base
{
namespace
{
struct Buffer
{
Buffer(size_t width, size_t height)
{
_p = Allocate(2*sizeof(int)*(2*width + height));
ix = (int*)_p;
ax = ix + width;
iy = ax + width;
ay = iy + height;
pbx[0] = (int*)(ay + height);
pbx[1] = pbx[0] + width;
}
~Buffer()
{
Free(_p);
}
int * ix;
int * ax;
int * iy;
int * ay;
int * pbx[2];
private:
void *_p;
};
}
void EstimateAlphaIndex(size_t srcSize, size_t dstSize, int * indexes, int * alphas, size_t channelCount)
{
float scale = (float)srcSize/dstSize;
for(size_t i = 0; i < dstSize; ++i)
{
float alpha = (float)((i + 0.5)*scale - 0.5);
ptrdiff_t index = (ptrdiff_t)::floor(alpha);
alpha -= index;
if(index < 0)
{
index = 0;
alpha = 0;
}
if(index > (ptrdiff_t)srcSize - 2)
{
index = srcSize - 2;
alpha = 1;
}
for(size_t c = 0; c < channelCount; c++)
{
size_t offset = i*channelCount + c;
indexes[offset] = (int)(channelCount*index + c);
alphas[offset] = (int)(alpha * FRACTION_RANGE + 0.5);
}
}
}
void ResizeBilinear(
const uint8_t *src, size_t srcWidth, size_t srcHeight, size_t srcStride,
uint8_t *dst, size_t dstWidth, size_t dstHeight, size_t dstStride, size_t channelCount)
{
assert(channelCount >= 1 && channelCount <= 4);
size_t dstRowSize = channelCount*dstWidth;
Buffer buffer(dstRowSize, dstHeight);
EstimateAlphaIndex(srcHeight, dstHeight, buffer.iy, buffer.ay, 1);
EstimateAlphaIndex(srcWidth, dstWidth, buffer.ix, buffer.ax, channelCount);
ptrdiff_t previous = -2;
for(size_t yDst = 0; yDst < dstHeight; yDst++, dst += dstStride)
{
int fy = buffer.ay[yDst];
ptrdiff_t sy = buffer.iy[yDst];
int k = 0;
if(sy == previous)
k = 2;
else if(sy == previous + 1)
{
Swap(buffer.pbx[0], buffer.pbx[1]);
k = 1;
}
previous = sy;
for(; k < 2; k++)
{
int* pb = buffer.pbx[k];
const uint8_t* ps = src + (sy + k)*srcStride;
for(size_t x = 0; x < dstRowSize; x++)
{
size_t sx = buffer.ix[x];
int fx = buffer.ax[x];
int t = ps[sx];
pb[x] = (t << LINEAR_SHIFT) + (ps[sx + channelCount] - t)*fx;
}
}
if(fy == 0)
for(size_t xDst = 0; xDst < dstRowSize; xDst++)
dst[xDst] = ((buffer.pbx[0][xDst] << LINEAR_SHIFT) + BILINEAR_ROUND_TERM) >> BILINEAR_SHIFT;
else if(fy == FRACTION_RANGE)
for(size_t xDst = 0; xDst < dstRowSize; xDst++)
dst[xDst] = ((buffer.pbx[1][xDst] << LINEAR_SHIFT) + BILINEAR_ROUND_TERM) >> BILINEAR_SHIFT;
else
{
for(size_t xDst = 0; xDst < dstRowSize; xDst++)
{
int t = buffer.pbx[0][xDst];
dst[xDst] = ((t << LINEAR_SHIFT) + (buffer.pbx[1][xDst] - t)*fy + BILINEAR_ROUND_TERM) >> BILINEAR_SHIFT;
}
}
}
}
}
}
| [
"fengbingchun@163.com"
] | fengbingchun@163.com |
52d04345848c59c55929873434ad44e05f517f93 | afec3b619926d18d7c5748c84a7873e82cbb8418 | /MeidaStream.cpp | f3d3c6cdc3c9693ac9fc932130b8165dc686f578 | [] | no_license | lianghuashow/FFmpegPlayerWithQt | 41aa5fd75cc4553c09b02d1a12ba09d2b347813a | b81c62eaccfe65755155cc32d4e6dc860fa5697b | refs/heads/master | 2023-02-08T05:32:59.930464 | 2020-12-31T01:47:53 | 2020-12-31T01:47:53 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 70 | cpp | //
// Created by chengkeke on 2020/6/13.
//
#include "MeidaStream.h"
| [
"417416576@qq.com"
] | 417416576@qq.com |
ee373f304b596606284c8429eaa6d36739ddbd80 | 8042163dbac5ddf47f078b4d14f4eb6fe1da030d | /tensorflow/compiler/mlir/xla/hlo_utils.h | f372cbf69bb909d73d9afad2acf3ea3b79a8c9dc | [
"Apache-2.0"
] | permissive | AITutorials/tensorflow | 4513de8db4e9bb74b784f5ba865ef8a573b9efc1 | 6bee0d45f8228f2498f53bd6dec0a691f53b3c7b | refs/heads/master | 2022-07-29T13:37:23.749388 | 2020-06-11T17:47:26 | 2020-06-11T17:57:06 | 271,615,051 | 3 | 0 | Apache-2.0 | 2020-06-11T18:07:11 | 2020-06-11T18:07:10 | null | UTF-8 | C++ | false | false | 3,325 | h | /* Copyright 2019 The TensorFlow Authors. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
==============================================================================*/
// This file defines helpers useful when creating or manipulating lhlo/hlo.
#ifndef TENSORFLOW_COMPILER_MLIR_XLA_HLO_UTILS_H_
#define TENSORFLOW_COMPILER_MLIR_XLA_HLO_UTILS_H_
#include "mlir/IR/Attributes.h" // from @llvm-project
#include "mlir/IR/Builders.h" // from @llvm-project
#include "mlir/IR/StandardTypes.h" // from @llvm-project
#include "tensorflow/compiler/mlir/xla/convert_op_folder.h"
#include "tensorflow/compiler/mlir/xla/ir/hlo_ops.h"
#include "tensorflow/compiler/xla/service/hlo_instruction.h"
namespace xla {
StatusOr<mlir::DenseElementsAttr> CreateDenseElementsAttrFromLiteral(
const LiteralBase& literal, mlir::Builder builder);
// Creates an DenseIntElementsAttr using the elements of the vector and the
// optional shape.
mlir::DenseIntElementsAttr CreateDenseIntElementsAttrFromVector(
const llvm::ArrayRef<int64> vector, mlir::Builder builder,
llvm::ArrayRef<int64_t> shape = {});
StatusOr<mlir::Type> ConvertPrimitiveTypeToMLIRType(PrimitiveType element_type,
mlir::Builder builder);
template <typename TypeT>
static StatusOr<TypeT> ConvertTensorShapeToType(const Shape& shape,
mlir::Builder builder) {
auto element_type_or =
ConvertPrimitiveTypeToMLIRType(shape.element_type(), builder);
if (!element_type_or.ok()) return element_type_or.status();
auto dimensions = shape.dimensions();
llvm::SmallVector<int64_t, 4> array(dimensions.begin(), dimensions.end());
return TypeT::get(array, element_type_or.ValueOrDie());
}
StatusOr<mlir::MemRefType> ConvertTensorShapeToMemRefType(
const Shape& shape, mlir::Builder builder);
template <>
inline StatusOr<mlir::MemRefType> ConvertTensorShapeToType(
const Shape& shape, mlir::Builder builder) {
return ConvertTensorShapeToMemRefType(shape, builder);
}
template <typename TypeT>
static StatusOr<mlir::Type> ConvertShapeToType(const Shape& shape,
mlir::Builder builder) {
if (shape.IsTuple()) {
llvm::SmallVector<mlir::Type, 4> contents;
contents.reserve(shape.tuple_shapes_size());
for (const auto& subtype : shape.tuple_shapes()) {
TF_ASSIGN_OR_RETURN(auto mlir_subtype,
ConvertShapeToType<TypeT>(subtype, builder));
contents.push_back(mlir_subtype);
}
return builder.getTupleType(contents);
}
if (shape.IsToken()) {
return mlir::xla_hlo::TokenType::get(builder.getContext());
}
return ConvertTensorShapeToType<TypeT>(shape, builder);
}
} // namespace xla
#endif // TENSORFLOW_COMPILER_MLIR_XLA_HLO_UTILS_H_
| [
"gardener@tensorflow.org"
] | gardener@tensorflow.org |
58b7d48e9883e719581da81374e15da97c55bc77 | 48d5dbf4475448f5df6955f418d7c42468d2a165 | /SDK/SoT_BP_PassiveShipAIController_parameters.hpp | 2cdc1ff93550cf04eeb517fb7c802a1c936a9480 | [] | no_license | Outshynd/SoT-SDK-1 | 80140ba84fe9f2cdfd9a402b868099df4e8b8619 | 8c827fd86a5a51f3d4b8ee34d1608aef5ac4bcc4 | refs/heads/master | 2022-11-21T04:35:29.362290 | 2020-07-10T14:50:55 | 2020-07-10T14:50:55 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 381 | hpp | #pragma once
// Sea of Thieves (1.4.16) SDK
#ifdef _MSC_VER
#pragma pack(push, 0x8)
#endif
#include "SoT_BP_PassiveShipAIController_classes.hpp"
namespace SDK
{
//---------------------------------------------------------------------------
//Parameters
//---------------------------------------------------------------------------
}
#ifdef _MSC_VER
#pragma pack(pop)
#endif
| [
"53855178+Shat-sky@users.noreply.github.com"
] | 53855178+Shat-sky@users.noreply.github.com |
81fdf1fef1f8673dbfcbd5b96f4b117abd4f90f8 | e39b3fad5b4ee23f926509a7e5fc50e84d9ebdc8 | /Codeforces/Div2/501-600/551-560/556/b.cpp | a2b742421e4d8ca9c036086a1cb29282f58dd83c | [] | no_license | izumo27/competitive-programming | f755690399c5ad1c58d3db854a0fa21eb8e5f775 | e721fc5ede036ec5456da9a394648233b7bfd0b7 | refs/heads/master | 2021-06-03T05:59:58.460986 | 2021-05-08T14:39:58 | 2021-05-08T14:39:58 | 123,675,037 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,519 | cpp | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define REP(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)
#define DEBUG(x) cout<<#x<<": "<<(x)<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()
template<typename T> inline void CHMAX(T& a, const T b) {if(a<b) a=b;}
template<typename T> inline void CHMIN(T& a, const T b) {if(a>b) a=b;}
constexpr ll MOD=1000000007ll;
// constexpr ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD
const double EPS=1e-11;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)
int main(){
ios::sync_with_stdio(false);
cin.tie(0);
// cout<<setprecision(10)<<fixed;
int n;
string s[60];
cin>>n;
REP(i, n){
cin>>s[i];
}
bool ok=true;
[&]{
REP(i, n){
REP(j, n){
if(s[i][j]=='#'){
continue;
}
s[i][j]='#';
if(i+2>=n || j-1<0 || j+1>=n){
ok=false;
return;
}
if(s[i+1][j-1]=='#' || s[i+1][j]=='#' || s[i+1][j+1]=='#' || s[i+2][j]=='#'){
ok=false;
return;
}
s[i+1][j-1]='#';
s[i+1][j]='#';
s[i+1][j+1]='#';
s[i+2][j]='#';
}
}
}();
cout<<(ok ? "YES" : "NO")<<'\n';
return 0;
}
| [
"22386882+izumo27@users.noreply.github.com"
] | 22386882+izumo27@users.noreply.github.com |
f7d861e172eff99279a485704819c0e928a20008 | 6fd10243dd9694a7f42928ba7bff1202025870b8 | /link_list/find_sum.cpp | 4e1f123e245b74edcb59574daa209c5513116770 | [] | no_license | wangshuaiCode/geeksforgeeks | 070db6ba6f3e2c38a56579a9cad953fc231d33ab | ece0f27e6e85f003225a388ffed173804862320f | refs/heads/master | 2020-05-17T16:26:20.372156 | 2014-10-24T14:50:55 | 2014-10-24T14:50:55 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 455 | cpp | bool isfindsum(struct node * head1, struct node *head2, struct node * head3, int num)
{
struct node * a = head1;
while(a ! = NULL)
{
struct node * b = head2;
struct node * c = head3;
while(b != NULL || c != NULL)
{
int sum = a->data + b->data + c->data;
if(sum == num )
{
return bool;
}
else if(sum < num)
{
b = b->next;
}
else
{
c = c->next;
}
}
a = a-> next;
}
return false;
}
| [
"ws93124@163.com"
] | ws93124@163.com |
074c4b36a4a00cc3e92e581983029d91170e3a40 | 1423d53a71a26564182424d65950c8d662c2699e | /Editor/include/SceneManager.h | 02029962fa2762326a8bfb20371a9399e8e2f8cf | [] | no_license | MattisFaucheux/NIX-Engine | 6116dc4b9cbf5cd497c5880cb2b02eb58f60c5e2 | 5a099065a90a3c434c29b34ca1da1cbd587087f7 | refs/heads/master | 2023-08-01T18:52:54.400583 | 2021-09-14T19:04:06 | 2021-09-14T19:04:06 | 406,487,331 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,353 | h | #pragma once
#include "EditorApp.h"
#include "GameObject.h"
#include "PhysicScene.h"
#define SCENE_ELEMENT "scene"
#define DEFAULT_SCENE_FOLDER_PATH "Assets\\Scenes"
#define DEFAULT_SCENE_NAME "defaultScene.scene"
#define DEFAULT_RESOURCES_SCENE_PATH "Resources\\Scenes\\defaultScene.scene"
namespace NIX::Editor
{
class Camera;
struct Scene
{
GameObject* sceneRoot = nullptr;
Physic::PhysicScene* physicSimulation = nullptr;
std::string sceneName = "";
Scene() = default;
Scene(GameObject* root)
{
physicSimulation = new Physic::PhysicScene();
Physic::PhysicSimulation::GetSingleton()->SetCurrentScene(physicSimulation);
sceneRoot = new GameObject(nullptr, *root);
}
~Scene();
void IsActive(bool value);
void Update();
void SwitchToSimulation();
void ExitSimulation();
void SimulationUpdate(float deltaTime);
void SimulationStart();
void UpdateWorldMatrix();
void Serialize(Core::Serializer& serializer, const std::string& scenePath);
};
class SceneManager
{
private:
inline static Scene* m_editorScene;
inline static Scene* m_simulationScene = nullptr;
inline static Scene* m_activeScene = nullptr;
inline static std::string m_currentScenePath = "";
inline static Rendering::Camera* m_editorCamera;
inline static Rendering::Camera* m_mainCamera;
inline static bool m_isSceneToLoad = false;
inline static std::string m_sceneToLoadPath = "";
public:
SceneManager();
static void Init();
static void InitCamera();
[[nodiscard]] static Rendering::Camera* GetEditorCamera();
static void SetScenePath(std::string_view scene);
[[nodiscard]] static std::string_view GetScenePath();
static void SetMainCamera(Rendering::Camera* camera);
[[nodiscard]] static Rendering::Camera* GetMainCamera();
static void SetActiveScene(Scene* activeScene);
[[nodiscard]] static Scene* GetActiveScene();
[[nodiscard]] static Scene* GetEditorScene();
[[nodiscard]] static Scene* GetSimulationScene();
static void InitSimulation();
static void DestroySimulation();
static void LoadScene(int sceneId);
static void LoadScene(std::string_view filePath);
static void LoadSceneToLoad();
static std::string GetActiveSceneName();
static void CreateDefaultScene(const std::string& openPath);
private:
static void LoadScene();
};
}
| [
"mattis.faucheux@gmail.com"
] | mattis.faucheux@gmail.com |
ae21dfd221720dc6cb4dbbe957ca2e759bca0cea | 33b567f6828bbb06c22a6fdf903448bbe3b78a4f | /opencascade/ShapeFix_WireSegment.hxx | 1e01b01f67001ada9147cb49f939f4382661a899 | [
"Apache-2.0"
] | permissive | CadQuery/OCP | fbee9663df7ae2c948af66a650808079575112b5 | b5cb181491c9900a40de86368006c73f169c0340 | refs/heads/master | 2023-07-10T18:35:44.225848 | 2023-06-12T18:09:07 | 2023-06-12T18:09:07 | 228,692,262 | 64 | 28 | Apache-2.0 | 2023-09-11T12:40:09 | 2019-12-17T20:02:11 | C++ | UTF-8 | C++ | false | false | 6,146 | hxx | // Created on: 1999-04-27
// Created by: Andrey BETENEV
// Copyright (c) 1999 Matra Datavision
// Copyright (c) 1999-2014 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef _ShapeFix_WireSegment_HeaderFile
#define _ShapeFix_WireSegment_HeaderFile
#include <Standard.hxx>
#include <Standard_DefineAlloc.hxx>
#include <Standard_Handle.hxx>
#include <TopoDS_Vertex.hxx>
#include <TopAbs_Orientation.hxx>
#include <TColStd_HSequenceOfInteger.hxx>
#include <Standard_Integer.hxx>
class ShapeExtend_WireData;
class TopoDS_Wire;
class TopoDS_Edge;
//! This class is auxiliary class (data storage) used in ComposeShell.
//! It is intended for representing segment of the wire
//! (or whole wire). The segment itself is represented by
//! ShapeExtend_WireData. In addition, some associated data
//! necessary for computations are stored:
//!
//! * Orientation flag - determines current use of the segment
//! and used for parity checking:
//!
//! TopAbs_FORWARD and TopAbs_REVERSED - says that segment was
//! traversed once in the corresponding direction, and hence
//! it should be traversed once more in opposite direction;
//!
//! TopAbs_EXTERNAL - the segment was not yet traversed in any
//! direction (i.e. not yet used as boundary)
//!
//! TopAbs_INTERNAL - the segment was traversed in both
//! directions and hence is out of further work.
//!
//! Segments of initial bounding wires are created with
//! orientation REVERSED (for outer wire) or FORWARD (for inner
//! wires), and segments of splitting seams - with orientation
//! EXTERNAL.
class ShapeFix_WireSegment
{
public:
DEFINE_STANDARD_ALLOC
//! Creates empty segment.
Standard_EXPORT ShapeFix_WireSegment();
//! Creates segment and initializes it with wire and orientation.
Standard_EXPORT ShapeFix_WireSegment(const Handle(ShapeExtend_WireData)& wire, const TopAbs_Orientation ori = TopAbs_EXTERNAL);
//! Creates segment and initializes it with wire and orientation.
Standard_EXPORT ShapeFix_WireSegment(const TopoDS_Wire& wire, const TopAbs_Orientation ori = TopAbs_EXTERNAL);
//! Clears all fields.
Standard_EXPORT void Clear();
//! Loads wire.
Standard_EXPORT void Load (const Handle(ShapeExtend_WireData)& wire);
//! Returns wire.
Standard_EXPORT const Handle(ShapeExtend_WireData)& WireData() const;
//! Sets orientation flag.
Standard_EXPORT void Orientation (const TopAbs_Orientation ori);
//! Returns orientation flag.
Standard_EXPORT TopAbs_Orientation Orientation() const;
//! Returns first vertex of the first edge in the wire
//! (no dependance on Orientation()).
Standard_EXPORT TopoDS_Vertex FirstVertex() const;
//! Returns last vertex of the last edge in the wire
//! (no dependance on Orientation()).
Standard_EXPORT TopoDS_Vertex LastVertex() const;
//! Returns True if FirstVertex() == LastVertex()
Standard_EXPORT Standard_Boolean IsClosed() const;
//! Returns Number of edges in the wire
Standard_EXPORT Standard_Integer NbEdges() const;
//! Returns edge by given index in the wire
Standard_EXPORT TopoDS_Edge Edge (const Standard_Integer i) const;
//! Replaces edge at index i by new one.
Standard_EXPORT void SetEdge (const Standard_Integer i, const TopoDS_Edge& edge);
//! Insert a new edge with index i and implicitly defined
//! patch indices (indefinite patch).
//! If i==0, edge is inserted at end of wire.
Standard_EXPORT void AddEdge (const Standard_Integer i, const TopoDS_Edge& edge);
//! Insert a new edge with index i and explicitly defined
//! patch indices. If i==0, edge is inserted at end of wire.
Standard_EXPORT void AddEdge (const Standard_Integer i, const TopoDS_Edge& edge, const Standard_Integer iumin, const Standard_Integer iumax, const Standard_Integer ivmin, const Standard_Integer ivmax);
//! Set patch indices for edge i.
Standard_EXPORT void SetPatchIndex (const Standard_Integer i, const Standard_Integer iumin, const Standard_Integer iumax, const Standard_Integer ivmin, const Standard_Integer ivmax);
Standard_EXPORT void DefineIUMin (const Standard_Integer i, const Standard_Integer iumin);
Standard_EXPORT void DefineIUMax (const Standard_Integer i, const Standard_Integer iumax);
Standard_EXPORT void DefineIVMin (const Standard_Integer i, const Standard_Integer ivmin);
//! Modify minimal or maximal patch index for edge i.
//! The corresponding patch index for that edge is modified so
//! as to satisfy eq. iumin <= myIUMin(i) <= myIUMax(i) <= iumax
Standard_EXPORT void DefineIVMax (const Standard_Integer i, const Standard_Integer ivmax);
//! Returns patch indices for edge i.
Standard_EXPORT void GetPatchIndex (const Standard_Integer i, Standard_Integer& iumin, Standard_Integer& iumax, Standard_Integer& ivmin, Standard_Integer& ivmax) const;
//! Checks patch indices for edge i to satisfy equations
//! IUMin(i) <= IUMax(i) <= IUMin(i)+1
Standard_EXPORT Standard_Boolean CheckPatchIndex (const Standard_Integer i) const;
Standard_EXPORT void SetVertex (const TopoDS_Vertex& theVertex);
Standard_EXPORT TopoDS_Vertex GetVertex() const;
Standard_EXPORT Standard_Boolean IsVertex() const;
protected:
private:
Handle(ShapeExtend_WireData) myWire;
TopoDS_Vertex myVertex;
TopAbs_Orientation myOrient;
Handle(TColStd_HSequenceOfInteger) myIUMin;
Handle(TColStd_HSequenceOfInteger) myIUMax;
Handle(TColStd_HSequenceOfInteger) myIVMin;
Handle(TColStd_HSequenceOfInteger) myIVMax;
};
#endif // _ShapeFix_WireSegment_HeaderFile
| [
"adam.jan.urbanczyk@gmail.com"
] | adam.jan.urbanczyk@gmail.com |
ac635fb187419ecff474a63a109224452193b6ee | e6abea92f59a1031d94bbcb3cee828da264c04cf | /NppPlugins/NppPlugin_ExtLexer/src/NppPlugin.cpp | f02770a3deed12acc5cdc8a7182f7870709581ef | [] | no_license | bruderstein/nppifacelib_mob | 5b0ad8d47a19a14a9815f6b480fd3a56fe2c5a39 | a34ff8b5a64e237372b939106463989b227aa3b7 | refs/heads/master | 2021-01-15T18:59:12.300763 | 2009-08-13T19:57:24 | 2009-08-13T19:57:24 | 285,922 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 14,194 | cpp | /* NppPlugin.cpp
*
* This file is part of the Notepad++ Plugin Interface Lib.
* Copyright 2009 Thell Fowler (thell@almostautomated.com)
*
* This program is free software; you can redistribute it and/or modify it under the terms of
* the GNU General Public License as published by the Free Software Foundation; either version
* 2 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with this program;
* if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/*
* This is the main Notepad++ Plugin file for use with Notepad++ Plugin Interface Lib.
*
*/
#include "NppPlugin.h"
// ===> INCLUDE YOUR LEXER HEADER HERE
#include "NppExtLexer_Conf.h"
#include "NppExtLexer_MYUSERLANG.h"
#include "NppExtLexer_Template.h"
#include "NppExtLexer_PowerShell.h"
/*
* Plugin Environment Setup:
*
* The v_getfuncarray namespace alias allows for emulation of a class's 'virtual' function by
* providing a 'symlink' like pointer to whichever npp_plugin namsespace extension that will
* be responsible for responding to the N++ PluginsManager getfuncArray call.
*
* An example of this is npp_plugin::external_lexer::getfuncArray() which adds lexer funcItems
* to the array and sorts them, then appends the plugin's primary funcItems in the order
* the were registered.
*
*/
// <--- Namespace Aliases --->
namespace lIface = npp_plugin::external_lexer; // The external lexer extension to the base interface.
namespace v_getfuncarray = lIface::virtual_plugin_func; // The active function array controller.
// ===> Include your lexer's Namespace Alias here.
namespace l_conf = NppExtLexer_Conf;
namespace l_myuserlang = NppExtLexer_MYUSERLANG;
namespace l_template = NppExtLexer_Template;
namespace l_powershell = NppExtLexer_PowerShell;
// <--- Required Plugin Interface Routines --->
BOOL APIENTRY DllMain(HANDLE hModule, DWORD reasonForCall, LPVOID /*lpReserved*/)
{
using namespace npp_plugin;
switch (reasonForCall)
{
case DLL_PROCESS_ATTACH:
// <--- Base initialization of the plugin object --->
initPlugin(TEXT("NppExternalLexers"), hModule);
// <--- Base menu function items setup --->
setPluginFuncItem(TEXT(""), NULL); // A separator line.
setPluginFuncItem(TEXT("Help.txt"), npp_plugin::Help_func);
setPluginFuncItem(TEXT("About..."), npp_plugin::About_func);
#ifdef NPP_PLUGININTERFACE_CMDMAP_EXTENSION_H
// <--- Initalize internal cmdId to funcItem cmdId map. --->
createCmdIdMap();
#endif
// <--- Base initialization of lexer values --->
/*
* The format is:
* - Language name within double quotes. Shown in the 'Language' menu.
* - A description within a TEXT(" ") statement. Shown in the status bar.
* - The name of the LexOrFold function in your namespace.
* - The name of the menu dialog function in your namespace.
*
*/
// ===> Include your lexer's initialization statement here.
lIface::initLexer( "Conf*", TEXT("Apache Config File. *Ext"),
l_conf::LexOrFold, l_conf::menuDlg );
lIface::initLexer( "MYUSERLANG*", TEXT("MYUSERLANG File. *Ext"),
l_myuserlang::LexOrFold, l_myuserlang::menuDlg );
lIface::initLexer( "Template*", TEXT("Lexer Template File. *Ext"),
l_template::LexOrFold, l_template::menuDlg);
lIface::initLexer( "PowerShell*", TEXT("PowerShell Scipt File. *Ext"),
l_powershell::LexOrFold, l_powershell::menuDlg);
// <--- Additional Menu Function Items --->
/*
* You can also add additional menu function items by calling
* lIface::setLexerFuncItem.
*
*/
//lIface::setLexerFuncItem( TEXT("Name"), NAMESPACE::FUNCTION );
case DLL_PROCESS_DETACH:
break;
case DLL_THREAD_ATTACH:
break;
case DLL_THREAD_DETACH:
break;
}
return TRUE;
}
extern "C" __declspec(dllexport) FuncItem * getFuncsArray(int *FuncsArraySize)
{
/*
* PluginsManager stores pointers to the functions that are exposed, allowing dialog and
* menu interaction. The base plugin's functions to retrieve the size and array can be
* 'virtualized' by altering the namespace alias located near the top this file.
*
*/
*FuncsArraySize = v_getfuncarray::getPluginFuncCount();
return ( v_getfuncarray::getPluginFuncArray() );
}
//---------------------------------------------------------------------------------------------
// Notepad++ and Scintilla Communications Processing
/*
* Listings of notifications and messages are in Notepad_plus_msgs.h and Scintilla.h.
*
* Notifications use the SCNotification structure described in Scintilla.h.
*
*/
// This function gives access to Notepad++'s notification facilities including forwarded
// notifications from Scintilla.
extern "C" __declspec(dllexport) void beNotified(SCNotification *notifyCode)
{
/*
* This function gives access to Notepad++'s notification facilities including forwarded
* notifications from Scintilla.
*
* Notifications can be filtered and language specific handlers called using a
* Namespace::Function() call.
*
* To filter a notification to your specific lexer use the lIface::getSCILexerIDByName()
* function and compare that to a value returned from messageProc(SCI_GETLEXER, 0, 0).
*
*/
int currSCILEXERID; // External lexers are assigned SCLEX_AUTOMATIC + id by Scintilla.
// ===> Include optional notification handlers in the switch.
int msg = notifyCode->nmhdr.code;
switch (notifyCode->nmhdr.code)
{
case SCN_MODIFIED:
npp_plugin::hCurrViewNeedsUpdate();
if (notifyCode->modificationType & (SC_MOD_DELETETEXT | SC_MOD_INSERTTEXT)) {
currSCILEXERID = messageProc(SCI_GETLEXER, 0, 0);
if ( currSCILEXERID > SCLEX_AUTOMATIC ) {
if ( currSCILEXERID == lIface::getSCILexerIDByName("PowerShell*") ) {
l_powershell::setDocModified( true );
}
}
}
break;
case NPPN_READY:
npp_plugin::setNppReady();
npp_plugin::hCurrViewNeedsUpdate();
currSCILEXERID = messageProc(SCI_GETLEXER, 0, 0);
if ( currSCILEXERID > SCLEX_AUTOMATIC ) {
if ( currSCILEXERID == lIface::getSCILexerIDByName("PowerShell*") ) {
// Highlighters don't get applied correctly until Npp is ready.
messageProc(SCI_STARTSTYLING, -1, 0);
}
}
break;
case NPPN_WORDSTYLESUPDATED:
/*
* You can use this notification to make sure that style configuration changes to
* highlighter styles take effect without requiring the user to make a doc change.
* Another use is to keep wordlists in memory while your language is active for the
* focused buffer.
*
* To see an example of both of these ideas in action see NppExtLexer_PowerShell.
*
*/
npp_plugin::hCurrViewNeedsUpdate();
currSCILEXERID = messageProc(SCI_GETLEXER, 0, 0);
if ( currSCILEXERID > SCLEX_AUTOMATIC ) {
if ( currSCILEXERID == lIface::getSCILexerIDByName("PowerShell*") ) {
l_powershell::WORDSTYLESUPDATEDproc();
}
}
break;
case NPPN_LANGCHANGED:
npp_plugin::hCurrViewNeedsUpdate();
currSCILEXERID = messageProc(SCI_GETLEXER, 0, 0);
if ( currSCILEXERID > SCLEX_AUTOMATIC ) {
if ( currSCILEXERID == lIface::getSCILexerIDByName("PowerShell*") ) {
l_powershell::setLanguageChanged( true );
}
}
break;
case NPPN_BUFFERACTIVATED:
npp_plugin::hCurrViewNeedsUpdate();
currSCILEXERID = messageProc(SCI_GETLEXER, 0, 0);
if ( currSCILEXERID > SCLEX_AUTOMATIC ) {
if ( currSCILEXERID == lIface::getSCILexerIDByName("PowerShell*") ) {
// Make sure highlighters get applied to the whole doc.
l_powershell::setLanguageChanged( true ); // This flags for a full doc lexing.
messageProc(SCI_STARTSTYLING, -1, 0);
}
}
break;
case NPPN_FILEOPENED:
npp_plugin::hCurrViewNeedsUpdate();
break;
default:
break;
}
}
extern "C" __declspec(dllexport) LRESULT messageProc(UINT Message, WPARAM wParam, LPARAM lParam)
{
/*
* This function give access to Notepad++'s messaging facilities. It was originally
* intended for the relay of Notepad++ messages and inter-plugin messages, yet having
* ::SendMessage( hCurrentView, SOME_MESSAGE_TOKENNAME, value, value );
* mixed in all over the place was ugly so this plugin uses messageProc to keep all of
* these in one area.
*
* This function either returns true or the return value that comes from each individual
* handler. So be sure to explicitly state the return in the switch case.
*
* Use the npp_plugin:: hCurrView, hMainView, hSecondView, and hNpp for the standard handles,
* some messages needs to be sent to both the main and second handle to get the desired
* results. ( Indicator setup messages are one example. )
*
* See Notepad_plus_msgs.h and Scintilla.h for notification IDs.
*
*/
using namespace npp_plugin;
// ===> Include optional messaging handlers here.
switch (Message)
{
// It would be good to check if Notepad++'s second view actually needs messaging
// although for now it seems that sending some messages to both views has less overhead.
// Notepad++ Messages
case NPPM_ACTIVATEDOC:
SendMessage( hNpp(), NPPM_ACTIVATEDOC, wParam, lParam);
break;
case NPPM_GETCURRENTDOCINDEX:
return SendMessage( hNpp(), NPPM_GETCURRENTDOCINDEX, wParam, lParam);
// Lexer messages
case SCI_STARTSTYLING:
SendMessage(hCurrView(), SCI_STARTSTYLING, wParam, lParam);
break;
case SCI_GETLEXER:
return SendMessage(hCurrView(), SCI_GETLEXER, wParam, lParam);
case SCI_BRACEMATCH:
return SendMessage(hCurrView(), SCI_BRACEMATCH, wParam, lParam);
// Style messages
case SCI_STYLEGETBACK:
return SendMessage(hCurrView(), SCI_STYLEGETBACK, wParam, lParam);
case SCI_STYLEGETBOLD:
return SendMessage(hCurrView(), SCI_STYLEGETBOLD, wParam, lParam);
case SCI_STYLEGETITALIC:
return SendMessage(hCurrView(), SCI_STYLEGETITALIC, wParam, lParam);
case SCI_STYLEGETUNDERLINE:
return SendMessage(hCurrView(), SCI_STYLEGETUNDERLINE, wParam, lParam);
// Indicator messages
// We send INDIC set messages to both handles to ensure style changes are properly set.
case SCI_INDICSETSTYLE:
SendMessage(hMainView(), SCI_INDICSETSTYLE, wParam, lParam);
SendMessage(hSecondView(), SCI_INDICSETSTYLE, wParam, lParam);
break;
case SCI_INDICSETFORE:
SendMessage(hMainView(), SCI_INDICSETFORE, wParam, lParam);
SendMessage(hSecondView(), SCI_INDICSETFORE, wParam, lParam);
break;
case SCI_INDICGETFORE:
return SendMessage(hCurrView(), SCI_INDICGETFORE, wParam, lParam);
case SCI_INDICSETUNDER:
SendMessage(hMainView(), SCI_INDICSETUNDER, wParam, lParam);
SendMessage(hSecondView(), SCI_INDICSETUNDER, wParam, lParam);
break;
case SCI_INDICGETUNDER:
return SendMessage(hCurrView(), SCI_INDICGETUNDER, wParam, lParam);
case SCI_INDICSETALPHA:
SendMessage(hMainView(), SCI_INDICSETALPHA, wParam, lParam);
SendMessage(hSecondView(), SCI_INDICSETALPHA, wParam, lParam);
break;
default:
return false;
} // End: Switch ( Message )
return TRUE;
}
// Plugin Helper Functions
void npp_plugin::Help_func()
{
TCHAR directoryPath[MAX_PATH];
::SendMessage( npp_plugin::hNpp(), NPPM_GETNPPDIRECTORY, MAX_PATH, (LPARAM)directoryPath );
tstring pluginHelpFile;
pluginHelpFile.append(directoryPath);
pluginHelpFile.append( TEXT("\\Plugins\\doc\\NppPlugin_ExtLexerHelp.txt") );
bool docOpened = ( 1 == SendMessage( npp_plugin::hNpp(), NPPM_DOOPEN, 0, (LPARAM)pluginHelpFile.c_str() ) );
if ( docOpened ) {
::MessageBox(npp_plugin::hNpp(),
TEXT("Make your way through this file to learn more about\n")
TEXT("developing your own Notepad++ External Lexer."),
TEXT("Notepad++ External Lexer Plugin Help Information"),
MB_OK);
}
else {
tstring errNotice;
errNotice.assign( TEXT("The plugin's help document was not found at:\n") );
errNotice.append( pluginHelpFile.c_str() );
errNotice.append( TEXT("\r\n\r\nIf you can't find this document on your system, please send an email to:\n") );
errNotice.append( TEXT(" Thell (@) almostautomated.com") );
::MessageBox(npp_plugin::hNpp(),
errNotice.c_str(),
TEXT("Plugin Help Document Not Available!"),
MB_ICONERROR);
}
}
void npp_plugin::About_func()
{
::MessageBox(npp_plugin::hNpp(),
TEXT(" N++ External Lexers plugin was created to make it extremely easy to create\n")
TEXT(" your own external lexer plugins to use with Notepad++. For those who are new\n")
TEXT(" to writing lexers it provides some helpful examples and lots of notes/comments.\n")
TEXT(" For people who already use several external lexers and continously tinker around\n")
TEXT(" making more, this plugin streamlines the interface and makes for quicker and\n")
TEXT(" cleaner coding.\r\n")
TEXT(" It is a pretty complete rewrite of the MyLexerTemplate by Kyle Fleming. \r\n\r\n")
TEXT(" Huge thanks and credit go to the following for being kind enough to share their\n")
TEXT(" time and knowledge by releasing sources to their projects:\r\n\r\n")
TEXT(" Don Ho - for Notepad++.\r\n")
TEXT(" Neil Hodgson - for Scintilla.\r\n")
TEXT(" Jens Lorenz - for the great example plugins.\r\n")
TEXT(" Kyle Fleming - for the Notepad++ external lexer work.\r\n")
TEXT(" Freenode ##C++ and ##C++-Offtopic regulars for the patience.\r\n\r\n")
TEXT(" Hopefully you find this plugin to be a useful tool. Enjoy!\r\n")
TEXT(" Thell Fowler (almostautomated)"),
TEXT("About This Plugin"), MB_OK);
}
| [
"T B Fowler@2fa2a738-4fc5-9a49-b7e4-8bd4648edc6b"
] | T B Fowler@2fa2a738-4fc5-9a49-b7e4-8bd4648edc6b |
7782270477f87af96b82665305b8f33de7061a80 | b9c730e01e33b6ff4383292833790933e556554e | /毕设/张宇轩/GROVE_SERVO/Grove_Servo_Servo_Arduino_Uno.h | 8791670c41ea7294670c06558db3bda9d6e7b1d2 | [] | no_license | tagyona/tinylink-lib | 7982783b6c023982e93aea703477fd25a25a7f38 | a78226c9cc42d98661794a2c635571df36e1985f | refs/heads/master | 2020-03-10T21:58:35.695237 | 2018-01-15T07:54:06 | 2018-01-15T07:54:06 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 386 | h | #ifndef GROVE_Servo_Servo_ARDUINO_UNO_H
#define GROVE_Servo_Servo_ARDUINO_UNO_H
#include <Servo.h>
#include "Sensor_template.h"
#include "Writer.h"
class Grove_Servo_Servo:public Sensor<int>,public Writer<int>{
private:
Servo myservo;
int _read();
public:
Grove_Servo_Servo();
void init();
void write(int pos);
};
extern Grove_Servo_Servo TL_Servo;
#endif | [
"noreply@github.com"
] | noreply@github.com |
91c28e53d6c4fd19dadc1a8a82a04111839e09b3 | 74a4883200055cd1c32f61fb71e54efdcfdf72aa | /cpp/713. 乘积小于K的子数组.cpp | f736463aed8d8e61703588f64d40e783fdda0121 | [] | no_license | jackymxp/leetcode-solution | 247af392f0b7c2b6b27cab19b7d79bf7eac27c6f | a0ab3ee4f3d5673209454b4b98b6bde0a7eb45d4 | refs/heads/master | 2021-06-30T21:55:39.174762 | 2020-12-26T04:17:42 | 2020-12-26T04:17:42 | 206,824,577 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 625 | cpp | #include <iostream>
#include <vector>
using namespace std;
class Solution {
public:
int numSubarrayProductLessThanK(vector<int>& nums, int k) {
if(k <= 1)
return 0;
int res = 0;
int left = 0, right = 0;//[left, right]
int len = nums.size();
int tmp = 1;
while(right < len)
{
tmp *= nums[right];
while(tmp >= k)
{
tmp /= nums[left];
left++;
}
res += right-left+1;
right++;
}
return res;
}
};
int main(void){
Solution s;
} | [
"jacky@gmail.com"
] | jacky@gmail.com |
2a5dac7523b789feacdb1aa1f82451ae027371c9 | 7d391a176f5b54848ebdedcda271f0bd37206274 | /src/BabylonCpp/tests/math/color4_test.cpp | 1398dbb13b3e712065ef51c13e86090068287a4d | [
"Apache-2.0",
"LicenseRef-scancode-free-unknown"
] | permissive | pthom/BabylonCpp | c37ea256f310d4fedea1a0b44922a1379df77690 | 52b04a61467ef56f427c2bb7cfbafc21756ea915 | refs/heads/master | 2021-06-20T21:15:18.007678 | 2019-08-09T08:23:12 | 2019-08-09T08:23:12 | 183,211,708 | 2 | 0 | Apache-2.0 | 2019-04-24T11:06:28 | 2019-04-24T11:06:28 | null | UTF-8 | C++ | false | false | 3,997 | cpp | #include <gmock/gmock.h>
#include <gtest/gtest.h>
#include <babylon/math/color3.h>
#include <babylon/math/color4.h>
TEST(TestColor4, CheckColors4)
{
using namespace BABYLON;
// Create test data
Float32Array colors{
0.1f, 0.2f, 0.3f, // First Color3
0.4f, 0.5f, 0.6f, // Second Color3
};
Float32Array result = Color4::CheckColors4(colors, colors.size() / 3);
// Set expected results
Float32Array expectedResult{
0.1f, 0.2f, 0.3f, 1.f, // First Color4
0.4f, 0.5f, 0.6f, 1.f, // Second Color4
};
// Perform comparison
EXPECT_THAT(result, ::testing::ContainerEq(expectedResult));
}
TEST(TestColor4, Constructor)
{
using namespace BABYLON;
// Constructor
Color4 color4;
EXPECT_FLOAT_EQ(0.f, color4.r);
EXPECT_FLOAT_EQ(0.f, color4.g);
EXPECT_FLOAT_EQ(0.f, color4.b);
EXPECT_FLOAT_EQ(1.f, color4.a);
color4 = Color4{1.f, 1.f, 1.f, 1.f};
EXPECT_FLOAT_EQ(1.f, color4.r);
EXPECT_FLOAT_EQ(1.f, color4.g);
EXPECT_FLOAT_EQ(1.f, color4.b);
EXPECT_FLOAT_EQ(1.f, color4.a);
// Copy constructor
color4 = Color4{color4};
EXPECT_FLOAT_EQ(1.f, color4.r);
EXPECT_FLOAT_EQ(1.f, color4.g);
EXPECT_FLOAT_EQ(1.f, color4.b);
EXPECT_FLOAT_EQ(1.f, color4.a);
}
TEST(TestColor4, FromHexString)
{
using namespace BABYLON;
// Red
std::string hex{"#FF000000"};
Color4 color4 = Color4::FromHexString(hex);
EXPECT_FLOAT_EQ(1.f, color4.r);
EXPECT_FLOAT_EQ(0.f, color4.g);
EXPECT_FLOAT_EQ(0.f, color4.b);
EXPECT_FLOAT_EQ(0.f, color4.a);
// Green
hex = std::string{"#00FF0000"};
color4 = Color4::FromHexString(hex);
EXPECT_FLOAT_EQ(0.f, color4.r);
EXPECT_FLOAT_EQ(1.f, color4.g);
EXPECT_FLOAT_EQ(0.f, color4.b);
EXPECT_FLOAT_EQ(0.f, color4.a);
// Blue
hex = std::string{"#0000FF00"};
color4 = Color4::FromHexString(hex);
EXPECT_FLOAT_EQ(0.f, color4.r);
EXPECT_FLOAT_EQ(0.f, color4.g);
EXPECT_FLOAT_EQ(1.f, color4.b);
EXPECT_FLOAT_EQ(0.f, color4.a);
hex = std::string{"#000000FF"};
color4 = Color4::FromHexString(hex);
EXPECT_FLOAT_EQ(0.f, color4.r);
EXPECT_FLOAT_EQ(0.f, color4.g);
EXPECT_FLOAT_EQ(0.f, color4.b);
EXPECT_FLOAT_EQ(1.f, color4.a);
}
TEST(TestColor4, Lerp)
{
using namespace BABYLON;
Color4 c1;
Color4 c2{1.f, 1.f, 1.f, 1.f};
Color4 color4 = Color4::Lerp(c1, c2, 0.3f);
EXPECT_FLOAT_EQ(0.3f, color4.r);
EXPECT_FLOAT_EQ(0.3f, color4.g);
EXPECT_FLOAT_EQ(0.3f, color4.b);
EXPECT_FLOAT_EQ(1.f, color4.a);
}
TEST(TestColor4, Operators)
{
using namespace BABYLON;
// To array
Color4 color4{0.1f, 0.2f, 0.3f, 0.1f};
Float32Array result;
color4.toArray(result);
EXPECT_FLOAT_EQ(0.1f, result[0]);
EXPECT_FLOAT_EQ(0.2f, result[1]);
EXPECT_FLOAT_EQ(0.3f, result[2]);
EXPECT_FLOAT_EQ(0.1f, result[3]);
// As array
result = color4.asArray();
EXPECT_FLOAT_EQ(0.1f, result[0]);
EXPECT_FLOAT_EQ(0.2f, result[1]);
EXPECT_FLOAT_EQ(0.3f, result[2]);
EXPECT_FLOAT_EQ(0.1f, result[3]);
// Add
Color4 otherColor{0.3f, 0.4f, 0.5f, 0.6f};
Color4 c = color4.add(otherColor);
EXPECT_FLOAT_EQ(0.4f, c.r);
EXPECT_FLOAT_EQ(0.6f, c.g);
EXPECT_FLOAT_EQ(0.8f, c.b);
EXPECT_FLOAT_EQ(0.7f, c.a);
// Subtract
otherColor = Color4{0.1f, 0.2f, 0.3f, 0.1f};
c = color4.subtract(otherColor);
EXPECT_FLOAT_EQ(0.f, c.r);
EXPECT_FLOAT_EQ(0.f, c.g);
EXPECT_FLOAT_EQ(0.f, c.b);
EXPECT_FLOAT_EQ(0.f, c.a);
// Scale
c = Color4{0.4f, 0.6f, 0.7f, 0.5f};
c = c.scale(0.5f);
EXPECT_FLOAT_EQ(0.20f, c.r);
EXPECT_FLOAT_EQ(0.30f, c.g);
EXPECT_FLOAT_EQ(0.35f, c.b);
EXPECT_FLOAT_EQ(0.25f, c.a);
}
TEST(TestColor4, ToHexString)
{
using namespace BABYLON;
// Red
Color3 color3 = Color3::Red();
Color4 color4 = color3.toColor4();
EXPECT_EQ(color4.toHexString(), "#FF0000FF");
// Green
color3 = Color3::Green();
color4 = color3.toColor4();
EXPECT_EQ(color4.toHexString(), "#00FF00FF");
// Blue
color3 = Color3::Blue();
color4 = color3.toColor4();
EXPECT_EQ(color4.toHexString(), "#0000FFFF");
}
| [
"sam.dauwe@gmail.com"
] | sam.dauwe@gmail.com |
6c434ec7c883b603636a8fe7cef7242c72468f48 | d84b00ef1177af72932662cbbb1d1ab95c7e288c | /src/qt/transactionfilterproxy.cpp | 47f873fa4b44a92086d8760ad265e61a69a2e88e | [
"MIT"
] | permissive | N1ppa69/Picture-ex-core | 86a0f7b48a960aee4a4eb26fa4c41c0c100c62e4 | c2beb62086f6459dc8a8cdaddb5dd677eae027e1 | refs/heads/master | 2020-12-06T09:58:42.780975 | 2019-12-25T11:20:55 | 2019-12-26T11:55:06 | 232,430,287 | 1 | 0 | MIT | 2020-01-07T22:35:33 | 2020-01-07T22:35:32 | null | UTF-8 | C++ | false | false | 4,588 | cpp | // Copyright (c) 2011-2013 The Bitcoin developers
// Copyright (c) 2017 The PIVX developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include "transactionfilterproxy.h"
#include "transactionrecord.h"
#include "transactiontablemodel.h"
#include <cstdlib>
#include <QDateTime>
// Earliest date that can be represented (far in the past)
const QDateTime TransactionFilterProxy::MIN_DATE = QDateTime::fromTime_t(0);
// Last date that can be represented (far in the future)
const QDateTime TransactionFilterProxy::MAX_DATE = QDateTime::fromTime_t(0xFFFFFFFF);
TransactionFilterProxy::TransactionFilterProxy(QObject* parent) : QSortFilterProxyModel(parent),
dateFrom(MIN_DATE),
dateTo(MAX_DATE),
addrPrefix(),
typeFilter(COMMON_TYPES),
watchOnlyFilter(WatchOnlyFilter_All),
minAmount(0),
limitRows(-1),
showInactive(true),
fHideOrphans(false)
{
}
bool TransactionFilterProxy::filterAcceptsRow(int sourceRow, const QModelIndex& sourceParent) const
{
QModelIndex index = sourceModel()->index(sourceRow, 0, sourceParent);
int type = index.data(TransactionTableModel::TypeRole).toInt();
QDateTime datetime = index.data(TransactionTableModel::DateRole).toDateTime();
bool involvesWatchAddress = index.data(TransactionTableModel::WatchonlyRole).toBool();
QString address = index.data(TransactionTableModel::AddressRole).toString();
QString label = index.data(TransactionTableModel::LabelRole).toString();
qint64 amount = llabs(index.data(TransactionTableModel::AmountRole).toLongLong());
int status = index.data(TransactionTableModel::StatusRole).toInt();
if (!showInactive && status == TransactionStatus::Conflicted)
return false;
if (fHideOrphans && isOrphan(status, type))
return false;
if (!(TYPE(type) & typeFilter))
return false;
if (involvesWatchAddress && watchOnlyFilter == WatchOnlyFilter_No)
return false;
if (!involvesWatchAddress && watchOnlyFilter == WatchOnlyFilter_Yes)
return false;
if (datetime < dateFrom || datetime > dateTo)
return false;
if (!address.contains(addrPrefix, Qt::CaseInsensitive) && !label.contains(addrPrefix, Qt::CaseInsensitive))
return false;
if (amount < minAmount)
return false;
return true;
}
void TransactionFilterProxy::setDateRange(const QDateTime& from, const QDateTime& to)
{
this->dateFrom = from;
this->dateTo = to;
invalidateFilter();
}
void TransactionFilterProxy::setAddressPrefix(const QString& addrPrefix)
{
this->addrPrefix = addrPrefix;
invalidateFilter();
}
void TransactionFilterProxy::setTypeFilter(quint32 modes)
{
this->typeFilter = modes;
invalidateFilter();
}
void TransactionFilterProxy::setMinAmount(const CAmount& minimum)
{
this->minAmount = minimum;
invalidateFilter();
}
void TransactionFilterProxy::setWatchOnlyFilter(WatchOnlyFilter filter)
{
this->watchOnlyFilter = filter;
invalidateFilter();
}
void TransactionFilterProxy::setLimit(int limit)
{
this->limitRows = limit;
}
void TransactionFilterProxy::setShowInactive(bool showInactive)
{
this->showInactive = showInactive;
invalidateFilter();
}
void TransactionFilterProxy::setHideOrphans(bool fHide)
{
this->fHideOrphans = fHide;
invalidateFilter();
}
int TransactionFilterProxy::rowCount(const QModelIndex& parent) const
{
if (limitRows != -1) {
return std::min(QSortFilterProxyModel::rowCount(parent), limitRows);
} else {
return QSortFilterProxyModel::rowCount(parent);
}
}
bool TransactionFilterProxy::isOrphan(const int status, const int type)
{
return ( (type == TransactionRecord::Generated || type == TransactionRecord::StakeMint ||
type == TransactionRecord::Stakezpic || type == TransactionRecord::MNReward)
&& (status == TransactionStatus::Conflicted || status == TransactionStatus::NotAccepted) );
}
| [
"ultrapoolcom@gmail.com"
] | ultrapoolcom@gmail.com |
95ae8a323dae0c65d94ba8c57f6bc31a7f7d112f | bef6a509431ada1417093349b46265e6060c16a3 | /Player/Player.hpp | 80e27f5f3ac0213ab65de8327c019ef8a1a3cee2 | [] | no_license | Piterosik/GamJam | 667754da0d482bc38715bb9bf1b6898e039450c9 | 48e9fb0ca8490684c74d21a1d9b7dec893ea4a6d | refs/heads/master | 2020-07-01T21:44:36.935848 | 2016-11-20T06:27:47 | 2016-11-20T06:27:47 | 74,256,246 | 0 | 0 | null | 2016-11-20T06:07:57 | 2016-11-20T06:07:56 | null | UTF-8 | C++ | false | false | 678 | hpp | #ifndef PLAYER_HPP
#define PLAYER_HPP
#include <SFML/Graphics.hpp>
#include <SFML/System.hpp>
#include <SFML/Audio.hpp>
#include "../Game.hpp"
#include "../TexturesManager/TexturesManager.hpp"
#include "../Hallway/Hallway.hpp"
class Player
{
public:
Player();
virtual ~Player();
void draw(sf::RenderWindow & _window);
void update( int _milseconds,Hallway & _hall);
protected:
public:
sf::Sprite m_player;
float m_pos_x,m_pos_y;
int m_lastFrame;
int m_frame;
int m_elapsedTime;
float m_speed;
float m_rotation;
std::size_t m_textureHandles[3];
};
#endif // PLAYER_HPP
| [
"szymon-paczos@linux.pl"
] | szymon-paczos@linux.pl |
1d0907074d74be423a8981ea99e025ecdff39772 | f6439b5ed1614fd8db05fa963b47765eae225eb5 | /chrome/browser/chromeos/login/screens/screen_factory.cc | 0496e8c849461bd15804430fcf821ffd261c46a5 | [
"BSD-3-Clause"
] | permissive | aranajhonny/chromium | b8a3c975211e1ea2f15b83647b4d8eb45252f1be | caf5bcb822f79b8997720e589334266551a50a13 | refs/heads/master | 2021-05-11T00:20:34.020261 | 2018-01-21T03:31:45 | 2018-01-21T03:31:45 | 118,301,142 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,953 | cc | // Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/chromeos/login/screens/screen_factory.h"
#include "chrome/browser/chromeos/login/enrollment/enrollment_screen.h"
#include "chrome/browser/chromeos/login/screens/base_screen.h"
#include "chrome/browser/chromeos/login/screens/error_screen.h"
#include "chrome/browser/chromeos/login/screens/eula_screen.h"
#include "chrome/browser/chromeos/login/screens/kiosk_autolaunch_screen.h"
#include "chrome/browser/chromeos/login/screens/network_screen.h"
#include "chrome/browser/chromeos/login/screens/reset_screen.h"
#include "chrome/browser/chromeos/login/screens/terms_of_service_screen.h"
#include "chrome/browser/chromeos/login/screens/update_screen.h"
#include "chrome/browser/chromeos/login/screens/user_image_screen.h"
#include "chrome/browser/chromeos/login/screens/wrong_hwid_screen.h"
#include "chrome/browser/chromeos/login/supervised/supervised_user_creation_screen.h"
namespace chromeos {
// static
const char ScreenFactory::kEnrollmentScreenId[] = "enroll";
const char ScreenFactory::kErrorScreenId[] = "error-message";
const char ScreenFactory::kEulaScreenId[] = "eula";
const char ScreenFactory::kKioskAutolaunchScreenId[] = "autolaunch";
const char ScreenFactory::kNetworkScreenId[] = "network";
const char ScreenFactory::kResetScreenId[] = "reset";
const char ScreenFactory::kSupervisedUserCreationScreenId[] =
"locally-managed-user-creation-flow";
const char ScreenFactory::kTermsOfServiceScreenId[] = "tos";
const char ScreenFactory::kUpdateScreenId[] = "update";
const char ScreenFactory::kUserImageScreenId[] = "image";
const char ScreenFactory::kWrongHWIDScreenId[] = "wrong-hwid";
const char ScreenFactory::kLoginScreenId[] = "login";
ScreenFactory::ScreenFactory(ScreenObserver* observer,
OobeDisplay* oobe_display)
: observer_(observer),
oobe_display_(oobe_display) {
}
ScreenFactory::~ScreenFactory() {
}
BaseScreen* ScreenFactory::CreateScreen(const std::string& id) {
BaseScreen* result = CreateScreenImpl(id);
DCHECK_EQ(id, result->GetID());
return result;
}
BaseScreen* ScreenFactory::CreateScreenImpl(const std::string& id) {
if (id == kNetworkScreenId) {
return new NetworkScreen(observer_, oobe_display_->GetNetworkScreenActor());
} else if (id == kUpdateScreenId) {
return new UpdateScreen(observer_, oobe_display_->GetUpdateScreenActor());
} else if (id == kUserImageScreenId) {
return new UserImageScreen(observer_,
oobe_display_->GetUserImageScreenActor());
} else if (id == kEulaScreenId) {
return new EulaScreen(observer_, oobe_display_->GetEulaScreenActor());
} else if (id == kEnrollmentScreenId) {
return new EnrollmentScreen(observer_,
oobe_display_->GetEnrollmentScreenActor());
} else if (id == kResetScreenId) {
return new ResetScreen(observer_, oobe_display_->GetResetScreenActor());
} else if (id == kKioskAutolaunchScreenId) {
return new KioskAutolaunchScreen(
observer_, oobe_display_->GetKioskAutolaunchScreenActor());
} else if (id == kTermsOfServiceScreenId) {
return new TermsOfServiceScreen(observer_,
oobe_display_->GetTermsOfServiceScreenActor());
} else if (id == kWrongHWIDScreenId) {
return new WrongHWIDScreen(
observer_,
oobe_display_->GetWrongHWIDScreenActor());
} else if (id == kSupervisedUserCreationScreenId) {
return new SupervisedUserCreationScreen(
observer_,
oobe_display_->GetSupervisedUserCreationScreenActor());
} else if (id == kErrorScreenId) {
return new ErrorScreen(observer_, oobe_display_->GetErrorScreenActor());
}
// TODO(antrim): support for login screen.
NOTREACHED() << "Unknown screen ID: " << id;
return NULL;
}
} // namespace chromeos
| [
"jhonnyjosearana@gmail.com"
] | jhonnyjosearana@gmail.com |
f3fcd935d1b5237847858e61045de27094401e0d | 8dbb16968ddcec0105e0a54e6156a70d74c3e46f | /common/contrib/mini_excel/test.cpp | c22a0421b18f2acaf6786d32d3e9ad6264572406 | [
"MIT"
] | permissive | cbtek/RStats2017 | 255168056409674e1f562c86678f60b01a6c3923 | 596f98dbfaad6589eea7f4e1aaf6f32eadd75648 | refs/heads/master | 2022-07-27T21:42:23.285099 | 2022-07-19T15:38:28 | 2022-07-19T15:38:28 | 81,021,802 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 834 | cpp | #include "MiniExcelReader.h"
#include <cstring>
int main(int argc, const char *argv[])
{
MiniExcelReader::ExcelFile x;
if (!x.open("../1.xlsx"))
{
printf("can't open.");
return 1;
}
MiniExcelReader::Sheet* sh = x.getSheet("Sheet1");
FILE* file = fopen("../out.txt", "w");
const MiniExcelReader::Range& dim = sh->getDimension();
for (int r = dim.firstRow; r <= dim.lastRow; r++)
{
for (int c = dim.firstCol; c <= dim.lastCol; c++)
{
MiniExcelReader::Cell* cell = sh->getCell(r, c);
const char* str = cell ? cell->value.c_str() : ".";
fwrite(str, strlen(str), 1, file);
fwrite("|", 1, 1, file);
}
fwrite("\n", 1, 1, file);
}
fclose(file);
return 0;
}
| [
"corey.berry@cbtek.net"
] | corey.berry@cbtek.net |
4616c42eb0437fc076abd6d411a409c01977eb38 | 652f35fce87e500f679a519bca2f1df46811d162 | /applications/ShallowWaterApplication/custom_utilities/shallow_water_utilities.cpp | ca1a8b249cfec6ad08173c0adf077030b03c29d1 | [
"BSD-3-Clause"
] | permissive | xiaoxiongnpu/Kratos | 0cbe7fb68694903e7f5c1758aa65d6ff29dbe33b | 072cc1a84b3efe19c08644c005f7766123632398 | refs/heads/master | 2021-02-06T11:57:37.349019 | 2020-02-28T17:06:50 | 2020-02-28T17:06:50 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 9,415 | cpp | // | / |
// ' / __| _` | __| _ \ __|
// . \ | ( | | ( |\__ `
// _|\_\_| \__,_|\__|\___/ ____/
// Multi-Physics
//
// License: BSD License
// Kratos default license: kratos/license.txt
//
// Main authors: Miguel Maso Sotomayor
//
// System includes
// External includes
// Project includes
#include "shallow_water_application_variables.h"
#include "shallow_water_utilities.h"
namespace Kratos
{
void ShallowWaterUtilities::ComputeFreeSurfaceElevation(ModelPart& rModelPart)
{
#pragma omp parallel for
for (int i = 0; i < static_cast<int>(rModelPart.NumberOfNodes()); ++i)
{
auto it_node = rModelPart.NodesBegin() + i;
it_node->FastGetSolutionStepValue(FREE_SURFACE_ELEVATION) = it_node->FastGetSolutionStepValue(HEIGHT) - it_node->FastGetSolutionStepValue(BATHYMETRY);
}
}
void ShallowWaterUtilities::ComputeHeightFromFreeSurface(ModelPart& rModelPart)
{
#pragma omp parallel for
for (int i = 0; i < static_cast<int>(rModelPart.NumberOfNodes()); ++i)
{
auto it_node = rModelPart.NodesBegin() + i;
it_node->FastGetSolutionStepValue(HEIGHT) = it_node->FastGetSolutionStepValue(FREE_SURFACE_ELEVATION) + it_node->FastGetSolutionStepValue(BATHYMETRY);
}
}
void ShallowWaterUtilities::ComputeVelocity(ModelPart& rModelPart)
{
const double epsilon = rModelPart.GetProcessInfo()[DRY_HEIGHT];
#pragma omp parallel for
for (int i = 0; i < static_cast<int>(rModelPart.NumberOfNodes()); ++i)
{
auto it_node = rModelPart.NodesBegin() + i;
const double height = it_node->FastGetSolutionStepValue(HEIGHT);
it_node->FastGetSolutionStepValue(VELOCITY) = it_node->FastGetSolutionStepValue(MOMENTUM) / (std::abs(height) + epsilon);
}
}
void ShallowWaterUtilities::ComputeMomentum(ModelPart& rModelPart)
{
#pragma omp parallel for
for (int i = 0; i < static_cast<int>(rModelPart.NumberOfNodes()); ++i)
{
auto it_node = rModelPart.NodesBegin() + i;
it_node->FastGetSolutionStepValue(MOMENTUM) = it_node->FastGetSolutionStepValue(VELOCITY) * it_node->FastGetSolutionStepValue(HEIGHT);
}
}
void ShallowWaterUtilities::ComputeAccelerations(ModelPart& rModelPart)
{
double dt_inv = rModelPart.GetProcessInfo()[DELTA_TIME];
#pragma omp parallel for
for (int i = 0; i < static_cast<int>(rModelPart.NumberOfNodes()); ++i)
{
auto it_node = rModelPart.NodesBegin() + i;
// Free suface derivative or vertical velocity
auto delta_surface = it_node->FastGetSolutionStepValue(FREE_SURFACE_ELEVATION) - it_node->FastGetSolutionStepValue(FREE_SURFACE_ELEVATION,1);
it_node->FastGetSolutionStepValue(VELOCITY_Z) = dt_inv * delta_surface;
// Acceleration
auto delta_vel = it_node->FastGetSolutionStepValue(VELOCITY) - it_node->FastGetSolutionStepValue(VELOCITY,1);
it_node->SetValue(ACCELERATION, dt_inv * delta_vel);
}
}
void ShallowWaterUtilities::FlipScalarVariable(Variable<double>& rOriginVariable, Variable<double>& rDestinationVariable, ModelPart& rModelPart)
{
#pragma omp parallel for
for (int i = 0; i < static_cast<int>(rModelPart.NumberOfNodes()); ++i)
{
auto it_node = rModelPart.NodesBegin() + i;
it_node->FastGetSolutionStepValue(rDestinationVariable) = -it_node->FastGetSolutionStepValue(rOriginVariable);
}
}
void ShallowWaterUtilities::IdentifySolidBoundary(ModelPart& rSkinModelPart, double SeaWaterLevel, Flags SolidBoundaryFlag)
{
#pragma omp parallel for
for (int i = 0; i < static_cast<int>(rSkinModelPart.NumberOfNodes()); ++i)
{
auto it_node = rSkinModelPart.NodesBegin() + i;
if (it_node->FastGetSolutionStepValue(TOPOGRAPHY) < SeaWaterLevel)
{
it_node->Set(SolidBoundaryFlag, true);
}
else
{
auto topography_gradient = it_node->FastGetSolutionStepValue(TOPOGRAPHY_GRADIENT);
auto normal = it_node->FastGetSolutionStepValue(NORMAL);
double sign = inner_prod(normal, topography_gradient);
// NOTE: Normal is positive outwards
// NOTE: The flowstream is opposite to the topography gradient
// An inwards flow will produce a positive sign: a SOLID boundary
it_node->Set(SolidBoundaryFlag, (sign >= 0.0));
}
}
#pragma omp parallel for
for (int i = 0; i < static_cast<int>(rSkinModelPart.NumberOfConditions()); ++i)
{
auto it_cond = rSkinModelPart.ConditionsBegin() + i;
bool is_solid = true;
for (auto& node : it_cond->GetGeometry())
{
if (node.IsNot(SolidBoundaryFlag)) {
is_solid = false;
}
}
it_cond->Set(SolidBoundaryFlag, is_solid);
}
}
void ShallowWaterUtilities::IdentifyWetDomain(ModelPart& rModelPart, Flags WetFlag, double Thickness)
{
#pragma omp parallel for
for (int i = 0; i < static_cast<int>(rModelPart.NumberOfNodes()); ++i)
{
auto it_node = rModelPart.NodesBegin() + i;
const double height = it_node->FastGetSolutionStepValue(HEIGHT);
it_node->Set(WetFlag, (height > Thickness));
}
#pragma omp parallel for
for (int i = 0; i < static_cast<int>(rModelPart.NumberOfElements()); ++i)
{
int method = 1;
auto it_elem = rModelPart.ElementsBegin() + i;
auto& geom = it_elem->GetGeometry();
bool is_wet = geom[0].Is(WetFlag);
bool is_shoreline = false;
for (size_t j = 1; j < geom.size(); ++j)
{
if (geom[j].Is(WetFlag) != is_wet)
is_shoreline = true;
}
if (!is_shoreline)
{
it_elem->Set(WetFlag, is_wet);
}
else
{
if (method == 0) {
it_elem->Set(WetFlag, false);
}
else if (method == 1) {
it_elem->Set(WetFlag, true);
}
else if (method == 2) {
double height_acc = 0.0;
for (auto& node : geom)
{
height_acc += node.FastGetSolutionStepValue(VELOCITY_Z);
}
it_elem->Set(WetFlag, (height_acc > 0.0));
}
else if (method == 3) {
Geometry<Node<3>>::ShapeFunctionsGradientsType DN_DX(1);
geom.ShapeFunctionsIntegrationPointsGradients(DN_DX, GeometryData::GI_GAUSS_1);
array_1d<double,3> height_grad = ZeroVector(3);
array_1d<double,3> velocity = ZeroVector(3);
for (size_t j = 0; j < geom.size(); ++j)
{
height_grad[0] += DN_DX[0](j,0) * geom[j].FastGetSolutionStepValue(HEIGHT);
height_grad[1] += DN_DX[0](j,1) * geom[j].FastGetSolutionStepValue(HEIGHT);
velocity += geom[j].FastGetSolutionStepValue(VELOCITY);
}
velocity /= geom.size();
double run_up = -inner_prod(height_grad, velocity);
it_elem->Set(WetFlag, (run_up > 0.0));
}
}
}
}
void ShallowWaterUtilities::ResetDryDomain(ModelPart& rModelPart, double Thickness)
{
#pragma omp parallel for
for (int i = 0; i < static_cast<int>(rModelPart.NumberOfNodes()); ++i)
{
auto it_node = rModelPart.NodesBegin() + i;
double& height = it_node->FastGetSolutionStepValue(HEIGHT);
if (height < Thickness)
{
height = 0.1 * Thickness;
it_node->FastGetSolutionStepValue(MOMENTUM) = ZeroVector(3);
}
}
}
void ShallowWaterUtilities::ComputeVisualizationWaterHeight(ModelPart& rModelPart, Flags WetFlag, double SeaWaterLevel)
{
#pragma omp parallel for
for (int i = 0; i < static_cast<int>(rModelPart.NumberOfNodes()); ++i)
{
auto it_node = rModelPart.NodesBegin() + i;
if (it_node->Is(WetFlag)) {
if (it_node->FastGetSolutionStepValue(TOPOGRAPHY) > SeaWaterLevel) {
it_node->SetValue(WATER_HEIGHT, it_node->FastGetSolutionStepValue(HEIGHT));
}
else {
it_node->SetValue(WATER_HEIGHT, it_node->FastGetSolutionStepValue(FREE_SURFACE_ELEVATION) - SeaWaterLevel);
}
}
else {
// This is the undefined value for GiD
it_node->SetValue(WATER_HEIGHT, std::numeric_limits<float>::lowest());
}
}
}
void ShallowWaterUtilities::ComputeVisualizationWaterSurface(ModelPart& rModelPart)
{
#pragma omp parallel for
for (int i = 0; i < static_cast<int>(rModelPart.NumberOfNodes()); ++i)
{
auto it_node = rModelPart.NodesBegin() + i;
it_node->SetValue(WATER_SURFACE_Z, it_node->FastGetSolutionStepValue(FREE_SURFACE_ELEVATION));
}
}
void ShallowWaterUtilities::NormalizeVector(ModelPart& rModelPart, Variable<array_1d<double,3>>& rVariable)
{
#pragma omp parallel for
for (int i = 0; i < static_cast<int>(rModelPart.NumberOfNodes()); ++i)
{
auto it_node = rModelPart.NodesBegin() + i;
auto& vector = it_node->FastGetSolutionStepValue(rVariable);
const auto modulus = norm_2(vector);
if (modulus > std::numeric_limits<double>::epsilon())
vector /= modulus;
}
}
} // namespace Kratos.
| [
"mmaso@cimne.upc.edu"
] | mmaso@cimne.upc.edu |
ce9d64a30da319571af30c4acf99e9e05e839431 | 8050bbeaf86021d5e89c7d81eedfd5ce0b391bb3 | /KingWolf.h | 0e882bd37ac59fe4956211c039c65cc822076358 | [] | no_license | disneyyy/Wolf0828 | fcf5fa57ff0ee3e3400e96fedf04ee924daa3813 | a490e0f45ffa2c8e7289f22cef6f9b2547992a05 | refs/heads/main | 2023-08-01T01:02:14.280758 | 2021-09-23T03:45:18 | 2021-09-23T03:45:18 | 409,438,059 | 0 | 0 | null | null | null | null | BIG5 | C++ | false | false | 710 | h | #ifndef KINGWOLF_H
#define KINGWOLF_H
#include "Character.h"
#include <iostream>
using namespace std;
class KingWolf: public Character{
public:
KingWolf(int m=10):Character(m){
}
char skill(char* name, int b){
char a=' ';
while(true){
system("cls");
cout<<b<<"號技能發動!請輸入要殺害哪位玩家,若放棄則輸入0:"<<endl;
cin>>decision;
if(decision>n||decision<0)
continue;
else{
if(decision!=0){
if(CheckName(decision, ' ', name)||CheckName(decision, 'L', name))
continue;
a= name[decision-1];
kill(name, decision);
}
//system("pause");
//system("cls");
return a;
}
}
}
};
#endif
| [
"noreply@github.com"
] | noreply@github.com |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.