blob_id
stringlengths 40
40
| directory_id
stringlengths 40
40
| path
stringlengths 3
264
| content_id
stringlengths 40
40
| detected_licenses
sequencelengths 0
85
| license_type
stringclasses 2
values | repo_name
stringlengths 5
140
| snapshot_id
stringlengths 40
40
| revision_id
stringlengths 40
40
| branch_name
stringclasses 905
values | visit_date
timestamp[us]date 2015-08-09 11:21:18
2023-09-06 10:45:07
| revision_date
timestamp[us]date 1997-09-14 05:04:47
2023-09-17 19:19:19
| committer_date
timestamp[us]date 1997-09-14 05:04:47
2023-09-06 06:22:19
| github_id
int64 3.89k
681M
⌀ | star_events_count
int64 0
209k
| fork_events_count
int64 0
110k
| gha_license_id
stringclasses 22
values | gha_event_created_at
timestamp[us]date 2012-06-07 00:51:45
2023-09-14 21:58:39
⌀ | gha_created_at
timestamp[us]date 2008-03-27 23:40:48
2023-08-21 23:17:38
⌀ | gha_language
stringclasses 141
values | src_encoding
stringclasses 34
values | language
stringclasses 1
value | is_vendor
bool 1
class | is_generated
bool 2
classes | length_bytes
int64 3
10.4M
| extension
stringclasses 115
values | content
stringlengths 3
10.4M
| authors
sequencelengths 1
1
| author_id
stringlengths 0
158
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
e9578aed0af88b526a6f09485928b1d1db43e439 | fb7efe44f4d9f30d623f880d0eb620f3a81f0fbd | /content/browser/frame_host/frame_tree.cc | 7d3d5d7bf4537361baf947dc90aeef802d955ce2 | [
"BSD-3-Clause"
] | permissive | wzyy2/chromium-browser | 2644b0daf58f8b3caee8a6c09a2b448b2dfe059c | eb905f00a0f7e141e8d6c89be8fb26192a88c4b7 | refs/heads/master | 2022-11-23T20:25:08.120045 | 2018-01-16T06:41:26 | 2018-01-16T06:41:26 | 117,618,467 | 3 | 2 | BSD-3-Clause | 2022-11-20T22:03:57 | 2018-01-16T02:09:10 | null | UTF-8 | C++ | false | false | 18,437 | cc | // Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "content/browser/frame_host/frame_tree.h"
#include <stddef.h>
#include <queue>
#include <utility>
#include "base/bind.h"
#include "base/callback.h"
#include "base/containers/hash_tables.h"
#include "base/lazy_instance.h"
#include "base/memory/ptr_util.h"
#include "base/unguessable_token.h"
#include "content/browser/frame_host/frame_tree_node.h"
#include "content/browser/frame_host/navigation_controller_impl.h"
#include "content/browser/frame_host/navigation_entry_impl.h"
#include "content/browser/frame_host/navigator.h"
#include "content/browser/frame_host/render_frame_host_factory.h"
#include "content/browser/frame_host/render_frame_host_impl.h"
#include "content/browser/frame_host/render_frame_proxy_host.h"
#include "content/browser/renderer_host/render_view_host_factory.h"
#include "content/browser/renderer_host/render_view_host_impl.h"
#include "content/common/content_switches_internal.h"
#include "content/common/frame_owner_properties.h"
#include "content/common/input_messages.h"
#include "content/common/site_isolation_policy.h"
#include "third_party/WebKit/public/web/WebSandboxFlags.h"
namespace content {
namespace {
// Helper function to collect SiteInstances involved in rendering a single
// FrameTree (which is a subset of SiteInstances in main frame's proxy_hosts_
// because of openers).
std::set<SiteInstance*> CollectSiteInstances(FrameTree* tree) {
std::set<SiteInstance*> instances;
for (FrameTreeNode* node : tree->Nodes())
instances.insert(node->current_frame_host()->GetSiteInstance());
return instances;
}
} // namespace
FrameTree::NodeIterator::NodeIterator(const NodeIterator& other) = default;
FrameTree::NodeIterator::~NodeIterator() {}
FrameTree::NodeIterator& FrameTree::NodeIterator::operator++() {
if (current_node_ != root_of_subtree_to_skip_) {
for (size_t i = 0; i < current_node_->child_count(); ++i) {
FrameTreeNode* child = current_node_->child_at(i);
queue_.push(child);
}
}
if (!queue_.empty()) {
current_node_ = queue_.front();
queue_.pop();
} else {
current_node_ = nullptr;
}
return *this;
}
bool FrameTree::NodeIterator::operator==(const NodeIterator& rhs) const {
return current_node_ == rhs.current_node_;
}
FrameTree::NodeIterator::NodeIterator(FrameTreeNode* starting_node,
FrameTreeNode* root_of_subtree_to_skip)
: current_node_(starting_node),
root_of_subtree_to_skip_(root_of_subtree_to_skip) {}
FrameTree::NodeIterator FrameTree::NodeRange::begin() {
return NodeIterator(root_, root_of_subtree_to_skip_);
}
FrameTree::NodeIterator FrameTree::NodeRange::end() {
return NodeIterator(nullptr, nullptr);
}
FrameTree::NodeRange::NodeRange(FrameTreeNode* root,
FrameTreeNode* root_of_subtree_to_skip)
: root_(root), root_of_subtree_to_skip_(root_of_subtree_to_skip) {}
FrameTree::FrameTree(Navigator* navigator,
RenderFrameHostDelegate* render_frame_delegate,
RenderViewHostDelegate* render_view_delegate,
RenderWidgetHostDelegate* render_widget_delegate,
RenderFrameHostManager::Delegate* manager_delegate)
: render_frame_delegate_(render_frame_delegate),
render_view_delegate_(render_view_delegate),
render_widget_delegate_(render_widget_delegate),
manager_delegate_(manager_delegate),
root_(new FrameTreeNode(this,
navigator,
render_frame_delegate,
render_widget_delegate,
manager_delegate,
nullptr,
// The top-level frame must always be in a
// document scope.
blink::WebTreeScopeType::kDocument,
std::string(),
std::string(),
base::UnguessableToken::Create(),
FrameOwnerProperties())),
focused_frame_tree_node_id_(FrameTreeNode::kFrameTreeNodeInvalidId),
load_progress_(0.0) {}
FrameTree::~FrameTree() {
delete root_;
root_ = nullptr;
}
FrameTreeNode* FrameTree::FindByID(int frame_tree_node_id) {
for (FrameTreeNode* node : Nodes()) {
if (node->frame_tree_node_id() == frame_tree_node_id)
return node;
}
return nullptr;
}
FrameTreeNode* FrameTree::FindByRoutingID(int process_id, int routing_id) {
RenderFrameHostImpl* render_frame_host =
RenderFrameHostImpl::FromID(process_id, routing_id);
if (render_frame_host) {
FrameTreeNode* result = render_frame_host->frame_tree_node();
if (this == result->frame_tree())
return result;
}
RenderFrameProxyHost* render_frame_proxy_host =
RenderFrameProxyHost::FromID(process_id, routing_id);
if (render_frame_proxy_host) {
FrameTreeNode* result = render_frame_proxy_host->frame_tree_node();
if (this == result->frame_tree())
return result;
}
return nullptr;
}
FrameTreeNode* FrameTree::FindByName(const std::string& name) {
if (name.empty())
return root_;
for (FrameTreeNode* node : Nodes()) {
if (node->frame_name() == name)
return node;
}
return nullptr;
}
FrameTree::NodeRange FrameTree::Nodes() {
return NodesExceptSubtree(nullptr);
}
FrameTree::NodeRange FrameTree::SubtreeNodes(FrameTreeNode* subtree_root) {
return NodeRange(subtree_root, nullptr);
}
FrameTree::NodeRange FrameTree::NodesExceptSubtree(FrameTreeNode* node) {
return NodeRange(root_, node);
}
bool FrameTree::AddFrame(FrameTreeNode* parent,
int process_id,
int new_routing_id,
blink::WebTreeScopeType scope,
const std::string& frame_name,
const std::string& frame_unique_name,
const base::UnguessableToken& devtools_frame_token,
blink::WebSandboxFlags sandbox_flags,
const ParsedFeaturePolicyHeader& container_policy,
const FrameOwnerProperties& frame_owner_properties) {
CHECK_NE(new_routing_id, MSG_ROUTING_NONE);
// A child frame always starts with an initial empty document, which means
// it is in the same SiteInstance as the parent frame. Ensure that the process
// which requested a child frame to be added is the same as the process of the
// parent node.
if (parent->current_frame_host()->GetProcess()->GetID() != process_id)
return false;
std::unique_ptr<FrameTreeNode> new_node = base::WrapUnique(new FrameTreeNode(
this, parent->navigator(), render_frame_delegate_,
render_widget_delegate_, manager_delegate_, parent, scope, frame_name,
frame_unique_name, devtools_frame_token, frame_owner_properties));
// Set sandbox flags and container policy and make them effective immediately,
// since initial sandbox flags and feature policy should apply to the initial
// empty document in the frame. This needs to happen before the call to
// AddChild so that the effective policy is sent to any newly-created
// RenderFrameProxy objects when the RenderFrameHost is created.
new_node->SetPendingSandboxFlags(sandbox_flags);
new_node->SetPendingContainerPolicy(container_policy);
new_node->CommitPendingFramePolicy();
// Add the new node to the FrameTree, creating the RenderFrameHost.
FrameTreeNode* added_node =
parent->AddChild(std::move(new_node), process_id, new_routing_id);
// The last committed NavigationEntry may have a FrameNavigationEntry with the
// same |frame_unique_name|, since we don't remove FrameNavigationEntries if
// their frames are deleted. If there is a stale one, remove it to avoid
// conflicts on future updates.
NavigationEntryImpl* last_committed_entry = static_cast<NavigationEntryImpl*>(
parent->navigator()->GetController()->GetLastCommittedEntry());
if (last_committed_entry)
last_committed_entry->ClearStaleFrameEntriesForNewFrame(added_node);
// Now that the new node is part of the FrameTree and has a RenderFrameHost,
// we can announce the creation of the initial RenderFrame which already
// exists in the renderer process.
added_node->current_frame_host()->SetRenderFrameCreated(true);
return true;
}
void FrameTree::RemoveFrame(FrameTreeNode* child) {
FrameTreeNode* parent = child->parent();
if (!parent) {
NOTREACHED() << "Unexpected RemoveFrame call for main frame.";
return;
}
parent->RemoveChild(child);
}
void FrameTree::CreateProxiesForSiteInstance(
FrameTreeNode* source,
SiteInstance* site_instance) {
// Create the RenderFrameProxyHost for the new SiteInstance.
if (!source || !source->IsMainFrame()) {
RenderViewHostImpl* render_view_host = GetRenderViewHost(site_instance);
if (!render_view_host) {
root()->render_manager()->CreateRenderFrameProxy(site_instance);
} else {
root()->render_manager()->EnsureRenderViewInitialized(render_view_host,
site_instance);
}
}
// Proxies are created in the FrameTree in response to a node navigating to a
// new SiteInstance. Since |source|'s navigation will replace the currently
// loaded document, the entire subtree under |source| will be removed, and
// thus proxy creation is skipped for all nodes in that subtree.
//
// However, a proxy *is* needed for the |source| node itself. This lets
// cross-process navigations in |source| start with a proxy and follow a
// remote-to-local transition, which avoids race conditions in cases where
// other navigations need to reference |source| before it commits. See
// https://crbug.com/756790 for more background. Therefore,
// NodesExceptSubtree(source) will include |source| in the nodes traversed
// (see NodeIterator::operator++).
for (FrameTreeNode* node : NodesExceptSubtree(source)) {
// If a new frame is created in the current SiteInstance, other frames in
// that SiteInstance don't need a proxy for the new frame.
RenderFrameHostImpl* current_host =
node->render_manager()->current_frame_host();
SiteInstance* current_instance = current_host->GetSiteInstance();
if (current_instance != site_instance) {
if (node == source && !current_host->IsRenderFrameLive()) {
// There's no need to create a proxy at |source| when the current
// RenderFrameHost isn't live, as in that case, the pending
// RenderFrameHost will be committed immediately, and the proxy
// destroyed right away, in GetFrameHostForNavigation. This makes the
// race described above not possible.
continue;
}
node->render_manager()->CreateRenderFrameProxy(site_instance);
}
}
}
RenderFrameHostImpl* FrameTree::GetMainFrame() const {
return root_->current_frame_host();
}
FrameTreeNode* FrameTree::GetFocusedFrame() {
return FindByID(focused_frame_tree_node_id_);
}
void FrameTree::SetFocusedFrame(FrameTreeNode* node, SiteInstance* source) {
if (node == GetFocusedFrame())
return;
std::set<SiteInstance*> frame_tree_site_instances =
CollectSiteInstances(this);
SiteInstance* current_instance =
node->current_frame_host()->GetSiteInstance();
// Update the focused frame in all other SiteInstances. If focus changes to
// a cross-process frame, this allows the old focused frame's renderer
// process to clear focus from that frame and fire blur events. It also
// ensures that the latest focused frame is available in all renderers to
// compute document.activeElement.
//
// We do not notify the |source| SiteInstance because it already knows the
// new focused frame (since it initiated the focus change), and we notify the
// new focused frame's SiteInstance (if it differs from |source|) separately
// below.
for (auto* instance : frame_tree_site_instances) {
if (instance != source && instance != current_instance) {
RenderFrameProxyHost* proxy =
node->render_manager()->GetRenderFrameProxyHost(instance);
proxy->SetFocusedFrame();
}
}
// If |node| was focused from a cross-process frame (i.e., via
// window.focus()), tell its RenderFrame that it should focus.
if (current_instance != source)
node->current_frame_host()->SetFocusedFrame();
focused_frame_tree_node_id_ = node->frame_tree_node_id();
node->DidFocus();
// The accessibility tree data for the root of the frame tree keeps
// track of the focused frame too, so update that every time the
// focused frame changes.
root()->current_frame_host()->UpdateAXTreeData();
}
void FrameTree::SetFrameRemoveListener(
const base::Callback<void(RenderFrameHost*)>& on_frame_removed) {
on_frame_removed_ = on_frame_removed;
}
RenderViewHostImpl* FrameTree::CreateRenderViewHost(
SiteInstance* site_instance,
int32_t routing_id,
int32_t main_frame_routing_id,
bool swapped_out,
bool hidden) {
RenderViewHostMap::iterator iter =
render_view_host_map_.find(site_instance->GetId());
if (iter != render_view_host_map_.end())
return iter->second;
RenderViewHostImpl* rvh =
static_cast<RenderViewHostImpl*>(RenderViewHostFactory::Create(
site_instance, render_view_delegate_, render_widget_delegate_,
routing_id, main_frame_routing_id, swapped_out, hidden));
render_view_host_map_[site_instance->GetId()] = rvh;
return rvh;
}
RenderViewHostImpl* FrameTree::GetRenderViewHost(SiteInstance* site_instance) {
RenderViewHostMap::iterator iter =
render_view_host_map_.find(site_instance->GetId());
if (iter != render_view_host_map_.end())
return iter->second;
return nullptr;
}
void FrameTree::AddRenderViewHostRef(RenderViewHostImpl* render_view_host) {
SiteInstance* site_instance = render_view_host->GetSiteInstance();
RenderViewHostMap::iterator iter =
render_view_host_map_.find(site_instance->GetId());
CHECK(iter != render_view_host_map_.end());
CHECK(iter->second == render_view_host);
iter->second->increment_ref_count();
}
void FrameTree::ReleaseRenderViewHostRef(RenderViewHostImpl* render_view_host) {
SiteInstance* site_instance = render_view_host->GetSiteInstance();
int32_t site_instance_id = site_instance->GetId();
RenderViewHostMap::iterator iter =
render_view_host_map_.find(site_instance_id);
CHECK(iter != render_view_host_map_.end());
CHECK_EQ(iter->second, render_view_host);
// Decrement the refcount and shutdown the RenderViewHost if no one else is
// using it.
CHECK_GT(iter->second->ref_count(), 0);
iter->second->decrement_ref_count();
if (iter->second->ref_count() == 0) {
iter->second->ShutdownAndDestroy();
render_view_host_map_.erase(iter);
}
}
void FrameTree::FrameRemoved(FrameTreeNode* frame) {
if (frame->frame_tree_node_id() == focused_frame_tree_node_id_)
focused_frame_tree_node_id_ = FrameTreeNode::kFrameTreeNodeInvalidId;
// No notification for the root frame.
if (!frame->parent()) {
CHECK_EQ(frame, root_);
return;
}
// Notify observers of the frame removal.
if (!on_frame_removed_.is_null())
on_frame_removed_.Run(frame->current_frame_host());
}
void FrameTree::UpdateLoadProgress() {
double progress = 0.0;
ProgressBarCompletion completion = GetProgressBarCompletionPolicy();
int frame_count = 0;
switch (completion) {
case ProgressBarCompletion::DOM_CONTENT_LOADED:
case ProgressBarCompletion::RESOURCES_BEFORE_DCL:
if (root_->has_started_loading())
progress = root_->loading_progress();
break;
case ProgressBarCompletion::LOAD_EVENT:
for (FrameTreeNode* node : Nodes()) {
// Ignore the current frame if it has not started loading.
if (!node->has_started_loading())
continue;
progress += node->loading_progress();
frame_count++;
}
break;
case ProgressBarCompletion::RESOURCES_BEFORE_DCL_AND_SAME_ORIGIN_IFRAMES:
for (FrameTreeNode* node : Nodes()) {
// Ignore the current frame if it has not started loading,
// if the frame is cross-origin, or about:blank.
if (!node->has_started_loading() || !node->HasSameOrigin(*root_) ||
node->current_url() == url::kAboutBlankURL)
continue;
progress += node->loading_progress();
frame_count++;
}
break;
default:
NOTREACHED();
}
if (frame_count != 0)
progress /= frame_count;
if (progress <= load_progress_)
return;
load_progress_ = progress;
// Notify the WebContents.
root_->navigator()->GetDelegate()->DidChangeLoadProgress();
}
void FrameTree::ResetLoadProgress() {
for (FrameTreeNode* node : Nodes())
node->reset_loading_progress();
load_progress_ = 0.0;
}
bool FrameTree::IsLoading() const {
for (const FrameTreeNode* node : const_cast<FrameTree*>(this)->Nodes()) {
if (node->IsLoading())
return true;
}
return false;
}
void FrameTree::ReplicatePageFocus(bool is_focused) {
std::set<SiteInstance*> frame_tree_site_instances =
CollectSiteInstances(this);
// Send the focus update to main frame's proxies in all SiteInstances of
// other frames in this FrameTree. Note that the main frame might also know
// about proxies in SiteInstances for frames in a different FrameTree (e.g.,
// for window.open), so we can't just iterate over its proxy_hosts_ in
// RenderFrameHostManager.
for (auto* instance : frame_tree_site_instances)
SetPageFocus(instance, is_focused);
}
void FrameTree::SetPageFocus(SiteInstance* instance, bool is_focused) {
RenderFrameHostManager* root_manager = root_->render_manager();
// This is only used to set page-level focus in cross-process subframes, and
// requests to set focus in main frame's SiteInstance are ignored.
if (instance != root_manager->current_frame_host()->GetSiteInstance()) {
RenderFrameProxyHost* proxy =
root_manager->GetRenderFrameProxyHost(instance);
proxy->Send(new InputMsg_SetFocus(proxy->GetRoutingID(), is_focused));
}
}
} // namespace content
| [
"[email protected]"
] | |
a7a947a870eaddbb321f8d6bb687d1dd7ead9c38 | a75feff03ca2f3236e20bf6eeb303be3e6bf89c2 | /BusBar-PC/common/excel/icom.h | b4761e4cd683c2b66340f1061583c74b576bd647 | [] | no_license | luozhiyong131/BusBar | 50b446c00fadff0a56a454de413dd80ad8ce4b6b | e9119903134276e866a68f7e70fad2ddb2770f8a | refs/heads/master | 2021-06-23T14:27:06.610207 | 2019-05-20T07:19:57 | 2019-05-20T07:19:57 | 92,152,932 | 3 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 169 | h | #ifndef ICOM_H
#define ICOM_H
//#include "icom_global.h"
#include <QString>
#include <QtCore>
class Q_DECL_IMPORT Icom
{
public:
Icom();
};
#endif // ICOM_H
| [
"[email protected]"
] | |
ff49272f339552a6fc3fc4796e266488dd3085c9 | 67c32bbfb61b27dac37952e6799a7a181fc92d66 | /game.cpp | eb7c6295bfd502d7f733babc78d61efdfbd56bb7 | [] | no_license | 4lo/link | 1c801a46657cd213be345b1306c24f314ce11430 | 4359f8f6b36ee68c895abd170e9b5f85b622f36a | refs/heads/master | 2021-07-05T07:38:25.935341 | 2017-09-29T01:41:12 | 2017-09-29T01:41:12 | 103,359,411 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,915 | cpp | #include "game.h"
Game::Game(){
//初始化整体游戏操作区域,包括边框
for(int i = 0; i < 12; i++)
for(int j = 0; j < 18; j++)
mapOfAll[i][j] = 0;
}
//通过数组中编号来获取图片的坐标
void Game::getCoordinate(int &x1, int &y1, int &x2, int &y2, QString pic1, QString pic2){
x1 = pic1.toInt() / 18;
x2 = pic2.toInt() / 18;
y1 = pic1.toInt() % 18;
y2 = pic2.toInt() % 18;
}
/*
d 0 d
x x x
d x x
用一条线连接的情况
*/
bool Game::linkWithOneLine(QString pic1, QString pic2, bool isThis){
bool result{false};
int x1{},x2{},y1{},y2{};
getCoordinate(x1,y1,x2,y2,pic1,pic2);
result = couldBelinked(x1,y1,x2,y2);
if (result && isThis){
mapOfAll[x1][y1] = 0;
mapOfAll[x2][y2] = 0;
pictureNumber -= 2;
oneLine = true;
}
return result;
}
/*
0 0 d
0 x x
d x d
用两条线连接的情况
*/
bool Game::linkWithTwoLines(QString pic1, QString pic2,QString& p1,bool isThis){
bool result{false};
int x1{},x2{},y1{},y2{};
getCoordinate(x1,y1,x2,y2,pic1,pic2);
if (x1 == x2 || y1 == y2)
return false;
if (mapOfAll[x1][y1] != mapOfAll[x2][y2] && isThis)
return false;
if (mapOfAll[x1][y2] == 0){
mapOfAll[x1][y2] = mapOfAll[x1][y1];
if (couldBelinked(x1,y1,x1,y2) && couldBelinked(x2,y2,x1,y2)){
result = true;
p1 = QString::number(x1 * 18 + y2);
}
mapOfAll[x1][y2] = 0;
}
if (mapOfAll[x2][y1] == 0){
mapOfAll[x2][y1] = mapOfAll[x1][y1];
if (couldBelinked(x1,y1,x2,y1) && couldBelinked(x2,y2,x2,y1)){
result = true;
p1 = QString::number((x2 * 18 + y1));
}
mapOfAll[x2][y1] = 0;
}
if (result && isThis){
pictureNumber -= 2;
mapOfAll[x1][y1] = 0;
mapOfAll[x2][y2] = 0;
twoLines = true;
}
return result;
}
/*
x 0 d
d 0 x
x x x
用三条线连接的情况
*/
bool Game::linkWithThreeLines(QString pic1, QString pic2, QString& p1, QString& p2){
bool result{false};
int x1{},x2{},y1{}, y2{};
getCoordinate(x1,y1,x2,y2,pic1,pic2);
if (mapOfAll[x1][y1] != mapOfAll[x2][y2])
return false;
for (int i = 0; i < 12 *18; i++){
QString a = QString::number(i);
if(mapOfAll[i/18][i%18] == 0){
mapOfAll[i/18][i%18] = mapOfAll[x1][y1];
if (linkWithOneLine(pic1,a,false) && linkWithTwoLines(pic2,a,p2,false)){
p1 = a;
result = true;
mapOfAll[i/18][i%18] = 0;
break;
}
mapOfAll[i/18][i%18] = 0;
}
}
//若可以消去,则清空两个按钮的ID
if(result){
pictureNumber -= 2;
mapOfAll[x1][y1] = 0;
mapOfAll[x2][y2] = 0;
threeLines = true;
}
return result;
}
//胜利判定
bool Game::isWin(){
if (pictureNumber == 0){
return true;
}else{
return false;
}
}
//三种连接情况的基础,直线连接算法
bool Game::couldBelinked(int x1, int y1, int x2, int y2){
if (x1 != x2 && y1 != y2)
return false;
if (mapOfAll[x1][y1] != mapOfAll[x2][y2])
return false;
if (mapOfAll[x1][y1] == 0 || mapOfAll[x2][y2] == 0)
return false;
if (x1 == x2){
for (int i = y1 + 1; i < y2; i++){
if(mapOfAll[x1][i] != 0)
return false;
}
for (int i = y2 + 1; i < y1; i++){
if(mapOfAll[x1][i] != 0)
return false;
}
}
if (y1 == y2){
for (int i = x1 + 1; i < x2; i++){
if (mapOfAll[i][y1] != 0)
return false;
}
for (int i = x2 + 1; i < x1; i++){
if (mapOfAll[i][y1] != 0)
return false;
}
}
return true;
}
| [
"[email protected]"
] | |
71276826585b944110869c4df2effc17450cc2bf | 15539b06bf0a8859e20e21e104a2a24e24e4f49f | /examples/Effects/universal/ForestNoiseMatrix/ForestNoiseMatrix.ino | 607ff1012cf4746477b069016684723b8b42f5d2 | [
"MIT"
] | permissive | xdzmkus/LEDMatrix | f9e353fae229e7b2fc9e0691235eaa13e7af230f | 8862de3be3c59738deb474b68b9f44ab6b5d006a | refs/heads/master | 2023-05-12T19:09:38.892539 | 2023-04-28T14:34:55 | 2023-04-28T14:34:55 | 232,426,895 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,667 | ino | #if defined(ESP8266)
#define FASTLED_FORCE_SOFTWARE_SPI
#define FASTLED_FORCE_SOFTWARE_PINS
#define LED_PIN D5 // leds pin
#elif defined(ESP32)
#define LED_PIN 16 // leds pin
#else
#define LED_PIN 9 // leds pin
#endif
#include <FastLED.h>
#define MATRIX_H 8
#define MATRIX_W 32
#define NUM_LEDS (MATRIX_H * MATRIX_W)
#define CURRENT_LIMIT 8000
#define BRIGHTNESS 30
CRGB leds[NUM_LEDS];
#include "MatrixLineConverters.h"
#include "UniversalLEDMatrixEffects.h"
NoiseMatrixLedEffect<ZigZagFromTopLeftToBottomAndRight, leds, MATRIX_W, MATRIX_H>* effect;
#include <ClockTimer.hpp>
#define EFFECT_DURATION_SEC 30
MillisTimer tickerEffects(EFFECT_DURATION_SEC* MillisTimer::CLOCKS_IN_SEC);
void changeEffect()
{
uint8_t zoom = random(5, 100);
uint8_t speed = random(5, 60);
Serial.print("SCALE: "); Serial.print(zoom); Serial.print("\tSPEED: "); Serial.println(speed);
delete effect;
effect = new NoiseMatrixLedEffect<ZigZagFromTopLeftToBottomAndRight, leds, MATRIX_W, MATRIX_H>(speed, ForestColors_p, zoom);
effect->start();
}
void setupLED()
{
FastLED.addLeds<WS2812B, LED_PIN, GRB>(leds, NUM_LEDS).setCorrection(TypicalSMD5050);
FastLED.setMaxPowerInVoltsAndMilliamps(5, CURRENT_LIMIT);
FastLED.setBrightness(BRIGHTNESS);
FastLED.clear(true);
}
void setup()
{
Serial.begin(115200);
Serial.println(F("Forest Noise effect"));
setupLED();
effect = new NoiseMatrixLedEffect<ZigZagFromTopLeftToBottomAndRight, leds, MATRIX_W, MATRIX_H>(15, ForestColors_p);
effect->start();
tickerEffects.start();
}
void loop()
{
if (tickerEffects.isReady())
{
changeEffect();
}
if (effect->isReady())
{
effect->paint();
FastLED.show();
}
}
| [
"[email protected]"
] | |
2b48a1da43f28a23890dc6bd46701fe0b90bee77 | 23a9d18926f2313c8684e976ad9cb46bf5ac9fd1 | /app/projectwidget.h | 8add8a36f0a5d994bcac8b885fac659211a867c3 | [] | no_license | Jenswoltering/soundtable-1 | 5d2d72efca10f5096dc134c97f024bdb82a9e1c7 | 383edb28287732f968858a8993910b5bea308890 | refs/heads/develop | 2020-12-25T22:07:01.393552 | 2015-01-16T12:15:16 | 2015-01-16T12:15:16 | 29,345,211 | 0 | 1 | null | 2015-01-16T11:09:20 | 2015-01-16T11:09:19 | null | UTF-8 | C++ | false | false | 262 | h | #ifndef PROJECTWIDGET_H
#define PROJECTWIDGET_H
#include <QWidget>
class ProjectWidget : public QWidget
{
Q_OBJECT
public:
explicit ProjectWidget(QWidget *parent = 0) : QWidget(parent) {}
virtual ~ProjectWidget() {}
};
#endif // PROJECTWIDGET_H
| [
"[email protected]"
] | |
1f8894f062a4056143936a99858ef0fb5f5a1030 | 8a179678a86552b6aa996ea06e2802229e1854ed | /GTest/ControllerTest.cpp | bf0fcd6d955ef267510b68d587cfc616eb2ce48c | [] | no_license | jeremiahwitt/CandyCrisis | 5cd1b7cc90bdbb6493fb7b4c9d588e9c93876beb | 393561afd9debdf03d85d3969c3dd3c4c13381b6 | refs/heads/master | 2021-09-10T14:13:26.574484 | 2018-03-25T16:39:05 | 2018-03-25T16:39:05 | 121,061,435 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 458 | cpp | #include "pch.h"
TEST(ControllerTest, GetSolutionPathUpdated) {
GameBoard* board = new GameBoard("aaaaabbebbccccc");
Controller testController(board);
testController.makeMove(UP);
testController.makeMove(LEFT);
string expectedSolutionPathSoFar = "C B ";
ASSERT_TRUE(expectedSolutionPathSoFar.at(0) == testController.getSolutionPath().at(0));
ASSERT_TRUE(expectedSolutionPathSoFar.at(2) == testController.getSolutionPath().at(2));
delete board;
}
| [
"[email protected]"
] | |
899a5f7c9197d6fee76fd409cd1d440aac9d16c8 | 0eff74b05b60098333ad66cf801bdd93becc9ea4 | /second/download/squid/gumtree/squid_repos_function_3383_squid-3.5.27.cpp | 1980ace20310b91fb487106894a17faec2209062 | [] | no_license | niuxu18/logTracker-old | 97543445ea7e414ed40bdc681239365d33418975 | f2b060f13a0295387fe02187543db124916eb446 | refs/heads/master | 2021-09-13T21:39:37.686481 | 2017-12-11T03:36:34 | 2017-12-11T03:36:34 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 445 | cpp | void
PconnModule::dump(StoreEntry *e)
{
typedef Pools::const_iterator PCI;
int i = 0; // TODO: Why number pools if they all have names?
for (PCI p = pools.begin(); p != pools.end(); ++p, ++i) {
// TODO: Let each pool dump itself the way it wants to.
storeAppendPrintf(e, "\n Pool %d Stats\n", i);
(*p)->dumpHist(e);
storeAppendPrintf(e, "\n Pool %d Hash Table\n",i);
(*p)->dumpHash(e);
}
} | [
"[email protected]"
] | |
c3fab8c0e07c36ab53409878bb5a23245e50153d | 7de176060a61db803d19915e3db1f094fbe84539 | /packages/ode/src/meta/ode_has_velocity_method_callable_with_three_args.hpp | 9f1d3c6764afb837b61a6ce54ab5c139dbca6d07 | [
"BSD-3-Clause"
] | permissive | samajors/pressio | d183d65b6bef66c047037db8ff8d8c5673ec6bd7 | 164826bf58cb37a68b04755e3db943b4ce620a59 | refs/heads/master | 2022-11-15T01:37:37.046439 | 2020-05-11T15:27:16 | 2020-05-11T15:27:16 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,019 | hpp | /*
//@HEADER
// ************************************************************************
//
// ode_has_velocity_method_callable_with_three_args.hpp
// Pressio
// Copyright 2019
// National Technology & Engineering Solutions of Sandia, LLC (NTESS)
//
// Under the terms of Contract DE-NA0003525 with NTESS, the
// U.S. Government retains certain rights in this software.
//
// Pressio is licensed under BSD-3-Clause terms of use:
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
//
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// 3. Neither the name of the copyright holder nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
// FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
// COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
// HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
// IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
// Questions? Contact Francesco Rizzi ([email protected])
//
// ************************************************************************
//@HEADER
*/
#ifndef ODE_HAS_VELOCITY_METHOD_CALLABLE_WITH_THREE_ARGS_HPP_
#define ODE_HAS_VELOCITY_METHOD_CALLABLE_WITH_THREE_ARGS_HPP_
#include "../ode_ConfigDefs.hpp"
namespace pressio{ namespace ode{ namespace meta {
template <
typename T,
typename state_t,
typename sc_t,
typename velo_t,
typename = void
>
struct has_velocity_method_callable_with_three_args : std::false_type{};
template <
typename T,
typename state_t,
typename sc_t,
typename velo_t
>
struct has_velocity_method_callable_with_three_args<
T, state_t, sc_t, velo_t,
::pressio::mpl::enable_if_t<
std::is_void<
decltype(
std::declval<T const>().velocity(
std::declval<state_t const&>(),
std::declval<sc_t const &>(),
std::declval<velo_t &>()
)
)
>::value
>
> : std::true_type{};
}}} // namespace pressio::ode::meta
#endif
| [
"[email protected]"
] | |
b795f30ff864ae22e687fee89b73911fa21760f3 | 33c8b0c3d7428fb6f8eb47c4e745a441c53059d5 | /tmp/Code/Runtime/BerserkCore/Threading/Task.hpp | 1e2c23519e4005044e18e3095dcf90d7a751648b | [
"MIT"
] | permissive | EgorOrachyov/Berserk | be8d084d8f536d3fb8fa0502e597cdaf84a0e521 | 13972d73df813e7c2de6a680f3c100171d7be5e7 | refs/heads/master | 2022-01-12T22:30:31.124909 | 2021-12-31T17:14:21 | 2021-12-31T17:14:21 | 134,462,378 | 44 | 4 | null | 2019-01-22T23:21:32 | 2018-05-22T19:00:04 | C++ | UTF-8 | C++ | false | false | 5,089 | hpp | /**********************************************************************************/
/* This file is part of Berserk Engine project */
/* https://github.com/EgorOrachyov/Berserk */
/**********************************************************************************/
/* MIT License */
/* */
/* Copyright (c) 2018 - 2021 Egor Orachyov */
/* */
/* 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 BERSERK_TASK_HPP
#define BERSERK_TASK_HPP
#include <BerserkCore/Typedefs.hpp>
#include <BerserkCore/Templates/Array.hpp>
#include <BerserkCore/Templates/SmartPointer.hpp>
#include <BerserkCore/Platform/Atomic.hpp>
#include <BerserkCore/Strings/StringName.hpp>
#include <BerserkCore/Threading/TaskContext.hpp>
namespace Berserk {
/** Priority to execute task in task manager */
enum class TaskPriority {
/** Run as soon as no task with higher priority in queue */
Low = 0,
/** Run as soon as no tasks with high priority */
Medium = 1,
/** Run as soon as added in the queue */
High = 2,
/** Total count */
Max = 3
};
/** Task lifetime status */
enum class TaskStatus {
/** Not active or not pending execution */
Inactive = 0,
/** Pending to be executed */
InProgress = 1,
/** Successfully finished execution */
Completed = 2,
/** Execution canceled (removed from queue) */
Canceled = 3
};
/** Basic task to run in task manager */
class Task {
public:
using Callable = Function<void(TaskContext&)>;
/**
* Creates inactive task for future run.
*
* @param name Task name for debugging
* @param callable Function to execution when task is running
* @param priority Task priority
*/
Task(StringName name, TaskPriority priority, Callable callable);
Task(const Task&) = delete;
Task(Task&&) noexcept = delete;
virtual ~Task() = default;
/** @return Task debug name */
const StringName& GetName() const { return mName; }
/** @return Task function to executed */
const Callable& GetFunction() const { return mFunction; }
/** @return Task priority for execution */
TaskPriority GetPriority() const { return mPriority; }
/** @return Task status */
TaskStatus GetStatus() const;
/** @return True if the task has completed. */
bool IsCompleted() const;
/** @return True if the task has been canceled. */
bool IsCanceled() const;
/** @return True if the task has started or completed execution. */
bool IsStarted() const;
/** Blocks thread execution until task is completed */
void BlockUntilCompleted(uint64 sleep = 1000) const;
private:
friend class TaskManager;
friend class TaskQueue;
virtual bool CanStart(bool& shouldRemoveFromQueue);
virtual void NotifyQueued();
virtual void NotifyCompleted();
virtual void NotifyCanceled();
Callable mFunction;
StringName mName;
TaskPriority mPriority;
AtomicUint32 mWaiting{0};
AtomicUint32 mStatus{0};
};
}
#endif //BERSERK_TASK_HPP | [
"[email protected]"
] | |
b2a70703c2b30b33066e895c3dc626ee544fed88 | 34a674b4e69ca8b59e463dba7080cf37e3768a4c | /keypad_bluetooth_module/keypad_bluetooth_module.ino | 6aa8642574741e31f4f1998bab47739bc35f63ec | [] | no_license | Sanggoe/Arduino | 03f5794c36fda471ea1770b4c3e79438f74bf23f | 1e09c40bf2e17a7848c42d4073759d396451b372 | refs/heads/master | 2023-06-28T01:47:20.380991 | 2021-07-30T08:16:31 | 2021-07-30T08:16:31 | 255,376,655 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,449 | ino | // keypad 관련 선언
#include <Keypad.h>
const byte numRows = 4;
const byte numCols = 3;
char keymap[numRows][numCols] =
{
{'1', '2', '3'},
{'4', '5', '6'},
{'7', '8', '9'},
{'*', '0', '#'}
};
byte rowPins[numRows] = {8, 7, 6, 5};
byte colPins[numCols] = {4, 3, 2};
Keypad myKeypad = Keypad(makeKeymap(keymap), rowPins, colPins, numRows, numCols);
// bluetooth 관련 선언
#include <SoftwareSerial.h>
int bluetooth_Tx = 9;
int bluetooth_Rx = 10;
SoftwareSerial bluetooth(bluetooth_Tx, bluetooth_Rx);
void setup()
{
// serial 모니터
Serial.begin(9600);
// bluetooth 수신
bluetooth.begin(9600);
}
// password 입력 관련 선언
char password[] = {'1', '2', '3', '4'}; // password 설정
char input_status = 0; // keypad input 받는 상태 여부
char bluetooth_status = 0; // bluetooth input 받는 상태 여부
int input_count = 0; // password 누른 횟수
int input_right = 0; // password 일치 횟수
void loop()
{
char key_pressed = myKeypad.getKey();
char phone_pressed = (char)bluetooth.read();
if (key_pressed == '#' || phone_pressed == '#') {
Serial.print("# Input Password : ");
input_status = 1;
while (input_status) {
key_pressed = myKeypad.getKey();
if (bluetooth.available()) {
phone_pressed = (char)bluetooth.read();
bluetooth_status = 1;
}
// when input something
if (key_pressed != NO_KEY || bluetooth_status) {
bluetooth_status = 0;
// if input '#' or count 4, finish input
if (key_pressed == '#' || phone_pressed == '#' || input_count == 4 ) {
if (input_count != 0 && input_count == input_right) {
Serial.println("\nPassword Collect!");
// 잠금 해제
} else {
Serial.println("\nPassword Wrong!");
}
input_status = 0;
input_count = 0;
input_right = 0;
} else if (key_pressed == password[input_count] || phone_pressed == password[input_count]) {
input_count++;
input_right++;
Serial.print("key_pressed : ");
Serial.print(key_pressed);
Serial.print(" phone_pressed : ");
Serial.println(phone_pressed);
} else {
input_count++;
Serial.print("key_pressed : ");
Serial.print(key_pressed);
Serial.print(" phone_pressed : ");
Serial.println(phone_pressed);
}
}
}
}
}
| [
"[email protected]"
] | |
82587223c59cc06049b6976c28c1d9f8897beadd | b317dae7deeec535a4953c544117538bb6cd29b2 | /Hot_Room_Monitor/Hot_Room_Monitor.ino | 8c9e62f340eaf8db1f87fd2fb53c340140ed5c1f | [] | no_license | serliu/HotroomMonitoring | 9d2767a4f236afa0dac0a0944a92ff695b7e665d | 10ad806f6bbed8dc37a3b112c84e307415ab010b | refs/heads/master | 2020-04-05T12:32:51.226118 | 2017-08-04T20:43:38 | 2017-08-04T20:43:38 | 95,133,135 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 19,419 | ino |
//<-------------Included Libraries---------------->
#include <Wire.h>
#include "Adafruit_MCP9808.h"
#include <Arduino.h>
#include <SPI.h>
#include <Ethernet2.h>
#include <SD.h>
#include <EEPROM.h>
#include <TimeLib.h>
#include <DS1307RTC.h>
//<----------------------------------------------->
/* ************************************************************************
* *** Hot Room Temperature Monitor ***
* ************************************************************************
* Built using parts of:
* Super Graphing Data Logger by Everett Robinson, December 2016 http://everettsprojects.com
*
*
*
* Authors:
* Ejnar Arechavala - github.com/ejnarvala
* Serena Liu - github.com/serliu
*
*
*
*/
//<-------------STATIC DEFINIITONS----------------->
#define UPPER_TEMP_THRESH 38
#define LOWER_TEMP_THRESH 10
#define MEASURE_INTERVAL_NORMAL 30000
#define MEASURE_INTERVAL_EMERGENCY 5000
#define DAYS_BETWEEN_NEW_LOG 1 //how often to make a new log
#define ADDR_COUNT 1 //address for where day count will be stored in EEPROM
#define ADDR_DAY 0 //address for where day number " "
#define NUM_SENSORS 2
//<------------------------------------------------>
//<-----------------IP SETTINGS-------------------->
byte mac[] = { 0x8A, 0x7F, 0xA7, 0x2F, 0x8D, 0xE0 };
IPAddress ip(192,168,100,100);
IPAddress gateway(192,160,0,254);
IPAddress subnet(255, 255, 0, 0);
EthernetServer server(80);
int port = 80; //only open port on this network
EthernetClient client;
//<---------------END IP SETTINGS------------------>
//<------------------LOGGING VARIABLES--------------------->
String file_name;
int filenum;
tmElements_t tm;
unsigned long lastIntervalTime = 0;
unsigned long lastResetTime = 0;
long measure_interval = MEASURE_INTERVAL_NORMAL; //Time between measurements
String str2log = "";
char timestamp[30];
//<------------------------------------------------>
//<------------------SENSOR VARIABLES-------------->
Adafruit_MCP9808 *sensors = (Adafruit_MCP9808*)malloc(NUM_SENSORS*sizeof(Adafruit_MCP9808));
int *sensor_addresses= (int*) malloc (NUM_SENSORS*sizeof(int));
float *temps = (float*) malloc (NUM_SENSORS* sizeof(float));
bool emergency_mode = false;
//<------------------------------------------------>
void setup(){
//Start Serial monitoring
Serial.begin(9600);
//Start SD card
initialize_sd();
// sdRWTest(); //Uncomment to test SD card Read/Write
//Start Temperature Sensor
initialize_tempsensor(sensors, sensor_addresses);
//Start Ethernet Connection
initialize_ethernet();
RTC.read(tm);
SdFile::dateTimeCallback(dateTime);
// Serial.println("Today is " + twoDigitString(tm.Month) + "-" + twoDigitString(tm.Day) + "-" + (String) tmYearToCalendar(tm.Year)); Serial.println(timestamp);
sprintf(timestamp, "%02d:%02d:%02d %2d/%2d/%2d \n", tm.Hour,tm.Minute,tm.Second,tm.Month,tm.Day,tm.Year+1970);
Serial.println(timestamp);
getTemps(temps, sensors);
Serial.print("Initial Temperatures:");
for(int i = 0; i < NUM_SENSORS; i++){
Serial.print(" " + (String) temps[i]);
}
Serial.println("");
//set filename upon restart
file_name = "data/" + ((String)tmYearToCalendar(tm.Year)).substring(2) + "-" + twoDigitString(tm.Month) + "-" + twoDigitString(tm.Day) + ".CSV";
}
void loop(){
if((millis()%lastResetTime >= 18000000)){ //reset ethernet every 5 hours for stability
Ethernet.begin(mac, ip, gateway, gateway, subnet);
server.begin();
Serial.println("Server reset @ " + (String) Ethernet.localIP());
lastResetTime = millis();
}
//Check if its time to take a new measurement
if((millis()%lastIntervalTime) >= measure_interval){ //if its time, get new measuremnt and record it
//Check if a day has passed to create a new log
RTC.read(tm);
Serial.println("Today is " + twoDigitString(tm.Month) + "-" + twoDigitString(tm.Day) + "-" + (String) tmYearToCalendar(tm.Year));
//If new day happnes, new log will be started
//file_name = "data/" + twoDigitString(tm.Month) + "-" + twoDigitString(tm.Day) + "-" + ((String)tmYearToCalendar(tm.Year)).substring(2) + ".CSV"; //update file name with new date
//This code can be used to wait for multiple days to pass. Uncomment below and comment out line above to use;
// Serial.println("EEPROM Day: " + (String)EEPROM.read(ADDR_DAY));
if(EEPROM.read(ADDR_DAY) != tm.Day){
Serial.println((String)EEPROM.read(ADDR_DAY) + " != " + (String)tm.Day + " || NEW DAY");
EEPROM.write(ADDR_DAY, tm.Day); //overwrite EEPROM day
EEPROM.write(ADDR_COUNT, EEPROM.read(ADDR_COUNT) + 1); //increment count by one
}
//if number of days to make a new log has occured, make a new log
if(EEPROM.read(ADDR_COUNT) >= DAYS_BETWEEN_NEW_LOG){
EEPROM.write(ADDR_COUNT, 0); //reset count
file_name = "data/" + ((String)tmYearToCalendar(tm.Year)).substring(2) + "-" + twoDigitString(tm.Month) + "-" + twoDigitString(tm.Day) + ".CSV";
}
getTemps(temps, sensors);
str2log = twoDigitString(tm.Month) + '-' + twoDigitString(tm.Day) + '-' + (String)tmYearToCalendar(tm.Year) + ' ' + twoDigitString(tm.Hour) + ':' + twoDigitString(tm.Minute) + ':' + twoDigitString(tm.Second);
for(int i = 0; i < NUM_SENSORS; i++){
str2log += (',' + (String) temps[i]);
}
sdLog(file_name, str2log);
Serial.println("Writing: "+ str2log);
//If any sensors are out of bounds, send turn on emergency mode
for (int n = 0; n < NUM_SENSORS; n++){
if (temps[n] > UPPER_TEMP_THRESH || temps[n] < LOWER_TEMP_THRESH){
emergency_mode = true;
}
}
if(emergency_mode){
Serial.println("EMERGENCY MODE ACTIVATED; MEASUREMENT INTERVAL CHANGED TO 5 SECONDS");
measure_interval = MEASURE_INTERVAL_EMERGENCY;
emergency_mode = false;
}else{
measure_interval = MEASURE_INTERVAL_NORMAL;
}
lastIntervalTime = millis(); //update time since last interval
}
//<---------------------WEB PAGE CODE-------------------------------------------------->
char clientline[BUFSIZ];
int index = 0;
EthernetClient client = server.available();
if (client) {
// an http request ends with a blank line
boolean current_line_is_blank = true;
// reset the input buffer
index = 0;
while (client.connected()) {
if (client.available()) {
char c = client.read();
// If it isn't a new line, add the character to the buffer
if (c != '\n' && c != '\r') {
clientline[index] = c;
index++;
// are we too big for the buffer? start tossing out data
if (index >= BUFSIZ)
index = BUFSIZ -1;
// continue to read more data!
continue;
}
// got a \n or \r new line, which means the string is done
clientline[index] = 0;
// Print it out for debugging
Serial.println(clientline);
// Look for substring such as a request to get the root file
if (strstr(clientline, "GET / ") != 0) {
// send a standard http response header
HtmlHeaderOK(client);
// print all the data files, use a helper to keep it clean
//Styling to make the website look pretty
client.print(F("<!DOCTYPE html><html><style> #green{background:limegreen;} #red{background:red;} th{font-weight:bold;} th,td {padding: 12px; color: #fff; text-align: center; border: 0px none;} table{color: #fff; border: 1px solid #ddd; border-collapse: collapse; width: auto;}"));
client.print(F("h1 {font-size: 42px; color: #fff;} h2{color: #fff; font-size: 32px;} html {background: #ddd; height: 100%;} ul{columns: 5}"));
client.print(F("body { color: #fff; height: 100%; background: #3498db; box-shadow: 0 0 2px rgba(0, 0, 0, 0.06); color: #545454; font-family: \"Helvetica Neue\", Helvetica, Arial, sans-serif; text-align: center; line-height: 1.5; margin: 0 auto; max-width: 900px; padding: 2em 2em 4em;} li { list-style-type: none; font-size: 18px; font-family: \"Helvetica Neue\", Helvetica, Arial, sans-serif;} </style>"));
client.print(F("<head><title>Arduino Battery Lab Monitor</title></head><body>"));
client.print(F("<h1>Arduino Battery Lab Monitor</h1>"));
client.print(F("<table style=\"width:100%\"><tr><th>Temperature</th>"));
getTemps(temps, sensors); //Update Temperature readings
for (int i = 0; i < NUM_SENSORS; i++){
if (temps[i] > UPPER_TEMP_THRESH || temps[i] < LOWER_TEMP_THRESH){
client.print(F("<td id=\"red\">"));
}
else {
client.print(F("<td id=\"green\">"));
}
client.print((String)temps[i] + "</td>");
}
client.print(F("</tr></table>"));
client.print(F("<h2>View data for the week of (mm-dd-yy):</h2>"));
ListFiles(client);
client.print(F("</body></html>"));
}
else if (strstr(clientline, "GET /json")!=0){ //used for live update data
client.println(F("HTTP/1.1 200 OK"));
client.println("Access-Control-Allow-Origin: *");
client.println(F("Content-Type: application/json;charset=utf-8"));
// client.println(F("Connection: close"));
client.println(F(""));
getTemps(temps, sensors);
RTC.read(tm);
//formatting into json
client.print("{");
client.print("\"date\": ");
client.print("\"" +twoDigitString(tm.Month) + '-' + twoDigitString(tm.Day) + '-' + (String)tmYearToCalendar(tm.Year) + ' ' + twoDigitString(tm.Hour) + ':' + twoDigitString(tm.Minute) + ':' + twoDigitString(tm.Second)+"\"");
client.print(",");
for(int i = 0; i < NUM_SENSORS; i++){
client.print("\"S");
client.print(i);
client.print("\": ");
client.print(temps[i]);
if( i!= (NUM_SENSORS-1) ){
client.print(",");
}
}
client.println("}");
// client.stop();
break;
} else if (strstr(clientline, "GET /history")!=0){ //url for iframe in main app
// send a standard http response header
HtmlHeaderOK(client);
client.println(F(""));
client.print(F("<!DOCTYPE html><style> body{font-family: \"Helvetica Neue\", Helvetica, Arial, sans-serif; color:#FBFBFF; height: 100%; background: #01AADA; color #FBFBFF; margin: 0 auto; max-width: 100%; padding: 2em 2em 4em;} a:link{ text-decoration:none; font-weight: bold;color:#fff;}a:visited {text-decoration:none;font-weight:bold;color:#ddd;}a:hover{text-decoration:underline;font-weight:bold;color:#fff;}"));
client.print(F("a:active{text-decoration:underline;font-weight:bold;color: white;}th,td {padding: 7px;color: #FBFBFF;text-align: center;border: 1px solid #0B4F6C;} table{color: #FBFBFF; border-collapse: collapse; border: 1px solid #0B4F6C; width: 100%;table-layout: fixed;}</style><html><body>"));
ListFiles(client);
client.print(F("</body></html>"));
}else if (strstr(clientline, "GET /") != 0) {
// this time no space after the /, so a sub-file!
char *filename;
filename = strtok(clientline + 5, "?"); // look after the "GET /" (5 chars) but before
// the "?" if a data file has been specified. A little trick, look for the " HTTP/1.1"
// string and turn the first character of the substring into a 0 to clear it out.
(strstr(clientline, " HTTP"))[0] = 0;
// print the file we want
Serial.println(filename);
File file = SD.open(filename,FILE_READ);
if (!file) {
HtmlHeader404(client);
break;
}
Serial.println("Opened!");
//HtmlHeaderOK(client);
client.println(F("HTTP/1.1 200 OK"));
client.println(F("Content-Type: text/html"));
client.println("");
while(file.available()) {
int num_bytes_read;
uint8_t byte_buffer[32];
num_bytes_read=file.read(byte_buffer,32);
client.write(byte_buffer,num_bytes_read);
}
file.close();
}
else {
// everything else is a 404
HtmlHeader404(client);
}
break;
}
}
// give the web browser time to receive the data
delay(1);
client.stop();
}
}
void initialize_tempsensor(Adafruit_MCP9808 *sensors, int *sensor_addresses){
Serial.println("Initializing Temp Sensors");
for(int i = 0; i < NUM_SENSORS; i++){
sensor_addresses[i] = 24 + i;
sensors[i] = Adafruit_MCP9808();
if(!sensors[i].begin(sensor_addresses[i])){
Serial.println("Couldn't find Sensor " + (String) i);
} else{
Serial.println("Sensor: " + (String) i + " Initialized");
}
}
// if (!tempsensor0.begin(0x18)) {
// Serial.println("Couldn't find Sensor 0");
// }
// if (!tempsensor1.begin(0x19)) {
// Serial.println("Couldn't find Sensor 1");
// }
Serial.println(F("Temperature Sensors Initialized"));
}
// Sets up DHCP, waits 25s to make sure its connected
//sets some pin outputs for sd card
void initialize_ethernet()
{
Serial.println("Initializing Ethernet");
Ethernet.begin(mac, ip, gateway, gateway, subnet);
delay(25000); //Long enough to be fuly set up
server.begin();
Serial.println(Ethernet.localIP());
}
// call back for file timestamps
void dateTime(uint16_t* date, uint16_t* time) {
RTC.read(tm);
sprintf(timestamp, "%02d:%02d:%02d %2d/%2d/%2d \n", tm.Hour,tm.Minute,tm.Second,tm.Month,tm.Day,tm.Year +1970);
Serial.println(timestamp);
// return date using FAT_DATE macro to format fields
*date = FAT_DATE(tm.Year+1970, tm.Month, tm.Day);
// return time using FAT_TIME macro to format fields
*time = FAT_TIME(tm.Hour, tm.Minute, tm.Second);
}
//Sets up SD card
void initialize_sd() {
pinMode(4, OUTPUT); //Needed to not conflict with ethernet
digitalWrite(4, HIGH);
while (!SD.begin(4)) { //Initializes sd card
Serial.println(F("Card failed, or not present")); //Prints if SD not detected
//return; // don't do anything more:
delay(1000);
}
Serial.println(F("SD card initialized."));
}
//Run this test to create and remove a text file
//on the SD card to test Read/Write functionality
void sdRWTest(void){
File myFile;
if (SD.exists("example.txt")) {
Serial.println("example.txt exists.");
} else {
Serial.println("example.txt doesn't exist.");
}
// open a new file and immediately close it:
Serial.println("Creating example.txt...");
SdFile::dateTimeCallback(dateTime);
myFile = SD.open("example.txt", FILE_WRITE);
myFile.close();
// Check to see if the file exists:
if (SD.exists("example.txt")) {
Serial.println("example.txt exists.");
} else {
Serial.println("example.txt doesn't exist.");
}
// delete the file:
Serial.println("Removing example.txt...");
SD.remove("example.txt");
if (SD.exists("example.txt")) {
Serial.println("example.txt exists.");
} else {
Serial.println("example.txt doesn't exist.");
}
}
//Inputs char array pointer to file name on sd and
//String of what to append to that file;
void sdLog(String fileName, String stringToWrite) {
SdFile::dateTimeCallback(dateTime);
File myFile = SD.open(fileName, FILE_WRITE);
// if the file opened okay, write to it:
if (myFile) {
Serial.print("Writing to ");
Serial.print(fileName);
Serial.print("...");
myFile.println(stringToWrite);
// close the file:
myFile.close();
Serial.println("done.");
} else {
// if the file didn't open, print an error:
Serial.print("error opening ");
Serial.println(fileName);
}
}
// A function that takes care of the listing of files for the
// main page one sees when they first connect to the arduino.
// it only lists the files in the /data/ folder. Make sure this
// exists on your SD card.
void ListFiles(EthernetClient client) {
File workingDir = SD.open("/data/");
int filecount = 0;
client.print("<table><tr>");
while(true) {
File entry = workingDir.openNextFile();
if (! entry) {
break;
}
if ((filecount % 5 == 0) && (filecount != 0)){
client.print("</tr><tr>");
}
client.print("<td><a href=\"/HC.htm?file=");
client.print(entry.name());
client.print("\">");
client.print(entry.name());
client.println("</a></td>");
entry.close();
filecount++;
}
client.println("</tr></table>");
//Serial.println("Number of files: " + (String) filecount);
if(filecount > 29){
removeOldestLog();
}
workingDir.close();
}
void removeOldestLog(){
File workingDir = SD.open("/data/");
File entry = workingDir.openNextFile();
SD.remove("/data/" + (String) entry.name());
Serial.println("Oldest Log Removed");
}
void getTemps(float *temps, Adafruit_MCP9808 *sensors) {
for(int i = 0; i < NUM_SENSORS; i++){
temps[i] = sensors[i].readTempC();
}
// temps[0] = tempsensor0.readTempC();
// temps[1] = tempsensor1.readTempC();
}
String twoDigitString(int num){
if(num < 10){
return '0' + (String) num;
}
else{
return (String) num;
}
}
//-------------------RAM SAVING HTML HEADERS----------------------
// Strings stored in flash mem for the Html Header (saves ram)
const char HeaderOK_0[] PROGMEM = "HTTP/1.1 200 OK"; //
const char HeaderOK_1[] PROGMEM = "Content-Type: text/html"; //
//const char HeaderOK_2[] PROGMEM = "Connection: keep-alive"; // the connection will be closed after completion of the response
//const char HeaderOK_3[] PROGMEM = "Refresh: 5"; // refresh the page automatically every 5 sec
const char HeaderOK_4[] PROGMEM = ""; //
// A table of pointers to the flash memory strings for the header
const char* const HeaderOK_table[] PROGMEM = {
HeaderOK_0,
HeaderOK_1,
// HeaderOK_2,
// HeaderOK_3,
HeaderOK_4
};
// A function for reasy printing of the headers
void HtmlHeaderOK(EthernetClient client) {
char buffer[30]; //A character array to hold the strings from the flash mem
for (int i = 0; i < 3; i++) {
strcpy_P(buffer, (char*)pgm_read_word(&(HeaderOK_table[i])));
client.println( buffer );
}
}
// Strings stored in flash mem for the Html 404 Header
const char Header404_0[] PROGMEM = "HTTP/1.1 404 Not Found"; //
const char Header404_1[] PROGMEM = "Content-Type: text/html"; //
const char Header404_2[] PROGMEM = ""; //
const char Header404_3[] PROGMEM = "<h2>File Not Found!</h2>";
// A table of pointers to the flash memory strings for the header
const char* const Header404_table[] PROGMEM = {
Header404_0,
Header404_1,
Header404_2,
Header404_3
};
// Easy peasy 404 header function
void HtmlHeader404(EthernetClient client) {
char buffer[30]; //A character array to hold the strings from the flash mem
for (int i = 0; i < 4; i++) {
strcpy_P(buffer, (char*)pgm_read_word(&(Header404_table[i])));
client.println( buffer );
}
}
//-------------------------------------------------------------------
| [
"[email protected]"
] | |
a1905182f4a2678aff5a6ac3f7683bc7ba74532b | fa8dd6254e3f84648ab8eb6980f2332260750c48 | /Bex/src/Bex/bexio/sentry.hpp | 5ad99ab4bd09e60886672f5e49435931ec57eab8 | [] | no_license | zhangzewen/Bex | 7087999522b77fbb740efe984e4a225b99798502 | 88a8e7e1a7bb785024393fbb92750315690719f9 | refs/heads/master | 2020-12-25T10:50:09.111956 | 2014-07-28T13:19:09 | 2014-07-28T13:19:09 | null | 0 | 0 | null | null | null | null | GB18030 | C++ | false | false | 1,452 | hpp | #ifndef __BEX_IO_SENTRY_HPP__
#define __BEX_IO_SENTRY_HPP__
//////////////////////////////////////////////////////////////////////////
/// 标记
namespace Bex { namespace bexio
{
template <typename NativeType>
class sentry
{
public:
explicit sentry(bool bset = false)
{
if (bset) set();
}
// 设置标记
inline bool set()
{
return native_.try_lock();
}
// 清除标记
inline bool reset()
{
return native_.unlock();
}
// 是否已设置
inline bool is_set() const
{
return native_.is_locked();
}
private:
NativeType native_;
};
template <>
class sentry<bool>
{
public:
explicit sentry(bool bset = false)
: native_(bset)
{
}
// 设置标记
inline bool set()
{
bool ret = (native_ != true);
native_ = true;
return ret;
}
// 清除标记
inline bool reset()
{
bool ret = (native_ != false);
native_ = false;
return ret;
}
// 是否已设置
inline bool is_set() const
{
return native_;
}
private:
volatile bool native_;
};
} //namespace bexio
} //namespace Bex
#endif //__BEX_IO_SENTRY_HPP__ | [
"[email protected]"
] | |
af8944574292ba8c372125ef6238e4888e4109ba | f83ef53177180ebfeb5a3e230aa29794f52ce1fc | /ACE/ACE_wrappers/TAO/orbsvcs/performance-tests/RTEvent/lib/Auto_Disconnect.h | b6f2325dce08a13a71f6ee70b965a90befcbe19f | [
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-proprietary-license",
"LicenseRef-scancode-sun-iiop"
] | permissive | msrLi/portingSources | fe7528b3fd08eed4a1b41383c88ee5c09c2294ef | 57d561730ab27804a3172b33807f2bffbc9e52ae | refs/heads/master | 2021-07-08T01:22:29.604203 | 2019-07-10T13:07:06 | 2019-07-10T13:07:06 | 196,183,165 | 2 | 1 | Apache-2.0 | 2020-10-13T14:30:53 | 2019-07-10T10:16:46 | null | UTF-8 | C++ | false | false | 1,088 | h | /**
* @file Auto_Disconnect.h
*
* @author Carlos O'Ryan <[email protected]>
*/
#ifndef TAO_PERF_RTEC_AUTO_DISCONNECT_H
#define TAO_PERF_RTEC_AUTO_DISCONNECT_H
#include "tao/corba.h"
#include "ace/Auto_Functor.h"
/**
* @class Disconnect
*
* @brief Helper functor to call the disconnect() method of a class.
*/
template<class Client>
class Disconnect
{
public:
void operator() (Client *client);
};
/**
* @class Auto_Disconnect
*
* @brief Automatically invoke the disconnect() operation on some
* RTEC client.
*/
template<class Client>
class Auto_Disconnect : public ACE_Utils::Auto_Functor<Client,Disconnect<Client> >
{
public:
/// Constructor
/**
* @param client The client
*/
explicit Auto_Disconnect (Client *s = 0);
/// Assignment operator
Auto_Disconnect<Client>& operator= (Client *client);
};
#if defined(__ACE_INLINE__)
#include "Auto_Disconnect.inl"
#endif /* __ACE_INLINE__ */
#if defined (ACE_TEMPLATES_REQUIRE_SOURCE)
#include "Auto_Disconnect.cpp"
#endif /* ACE_TEMPLATES_REQUIRE_SOURCE */
#endif /* TAO_PERF_RTEC_AUTO_DISCONNECT_H */
| [
"[email protected]"
] | |
4b35f6133fa4837b8415cd324521b7652bc61fe9 | 73cfd700522885a3fec41127e1f87e1b78acd4d3 | /_Include/cryptopp/ripemd.cpp | 2cbd5cb0077d684fe673cfde1ecdd74868b0d9fb | [
"BSL-1.0",
"LicenseRef-scancode-public-domain",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | pu2oqa/muServerDeps | 88e8e92fa2053960671f9f57f4c85e062c188319 | 92fcbe082556e11587887ab9d2abc93ec40c41e4 | refs/heads/master | 2023-03-15T12:37:13.995934 | 2019-02-04T10:07:14 | 2019-02-04T10:07:14 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 31,460 | cpp | // ripemd.cpp
// RIPEMD-160 written and placed in the public domain by Wei Dai
// RIPEMD-320, RIPEMD-128, RIPEMD-256 written by Kevin Springle
// and also placed in the public domain
#include "pch.h"
#include "ripemd.h"
#include "misc.h"
NAMESPACE_BEGIN(CryptoPP)
#define F(x, y, z) (x ^ y ^ z)
#define G(x, y, z) (z ^ (x & (y^z)))
#define H(x, y, z) (z ^ (x | ~y))
#define I(x, y, z) (y ^ (z & (x^y)))
#define J(x, y, z) (x ^ (y | ~z))
#define k0 0
#define k1 0x5a827999UL
#define k2 0x6ed9eba1UL
#define k3 0x8f1bbcdcUL
#define k4 0xa953fd4eUL
#define k5 0x50a28be6UL
#define k6 0x5c4dd124UL
#define k7 0x6d703ef3UL
#define k8 0x7a6d76e9UL
#define k9 0
// *************************************************************
// for 160 and 320
#define Subround(f, a, b, c, d, e, x, s, k) \
a += f(b, c, d) + x + k;\
a = rotlFixed((word32)a, s) + e;\
c = rotlFixed((word32)c, 10U)
void RIPEMD160::InitState(HashWordType *state)
{
state[0] = 0x67452301L;
state[1] = 0xefcdab89L;
state[2] = 0x98badcfeL;
state[3] = 0x10325476L;
state[4] = 0xc3d2e1f0L;
}
void RIPEMD160::Transform (word32 *digest, const word32 *X)
{
unsigned long a1, b1, c1, d1, e1, a2, b2, c2, d2, e2;
a1 = a2 = digest[0];
b1 = b2 = digest[1];
c1 = c2 = digest[2];
d1 = d2 = digest[3];
e1 = e2 = digest[4];
Subround(F, a1, b1, c1, d1, e1, X[ 0], 11, k0);
Subround(F, e1, a1, b1, c1, d1, X[ 1], 14, k0);
Subround(F, d1, e1, a1, b1, c1, X[ 2], 15, k0);
Subround(F, c1, d1, e1, a1, b1, X[ 3], 12, k0);
Subround(F, b1, c1, d1, e1, a1, X[ 4], 5, k0);
Subround(F, a1, b1, c1, d1, e1, X[ 5], 8, k0);
Subround(F, e1, a1, b1, c1, d1, X[ 6], 7, k0);
Subround(F, d1, e1, a1, b1, c1, X[ 7], 9, k0);
Subround(F, c1, d1, e1, a1, b1, X[ 8], 11, k0);
Subround(F, b1, c1, d1, e1, a1, X[ 9], 13, k0);
Subround(F, a1, b1, c1, d1, e1, X[10], 14, k0);
Subround(F, e1, a1, b1, c1, d1, X[11], 15, k0);
Subround(F, d1, e1, a1, b1, c1, X[12], 6, k0);
Subround(F, c1, d1, e1, a1, b1, X[13], 7, k0);
Subround(F, b1, c1, d1, e1, a1, X[14], 9, k0);
Subround(F, a1, b1, c1, d1, e1, X[15], 8, k0);
Subround(G, e1, a1, b1, c1, d1, X[ 7], 7, k1);
Subround(G, d1, e1, a1, b1, c1, X[ 4], 6, k1);
Subround(G, c1, d1, e1, a1, b1, X[13], 8, k1);
Subround(G, b1, c1, d1, e1, a1, X[ 1], 13, k1);
Subround(G, a1, b1, c1, d1, e1, X[10], 11, k1);
Subround(G, e1, a1, b1, c1, d1, X[ 6], 9, k1);
Subround(G, d1, e1, a1, b1, c1, X[15], 7, k1);
Subround(G, c1, d1, e1, a1, b1, X[ 3], 15, k1);
Subround(G, b1, c1, d1, e1, a1, X[12], 7, k1);
Subround(G, a1, b1, c1, d1, e1, X[ 0], 12, k1);
Subround(G, e1, a1, b1, c1, d1, X[ 9], 15, k1);
Subround(G, d1, e1, a1, b1, c1, X[ 5], 9, k1);
Subround(G, c1, d1, e1, a1, b1, X[ 2], 11, k1);
Subround(G, b1, c1, d1, e1, a1, X[14], 7, k1);
Subround(G, a1, b1, c1, d1, e1, X[11], 13, k1);
Subround(G, e1, a1, b1, c1, d1, X[ 8], 12, k1);
Subround(H, d1, e1, a1, b1, c1, X[ 3], 11, k2);
Subround(H, c1, d1, e1, a1, b1, X[10], 13, k2);
Subround(H, b1, c1, d1, e1, a1, X[14], 6, k2);
Subround(H, a1, b1, c1, d1, e1, X[ 4], 7, k2);
Subround(H, e1, a1, b1, c1, d1, X[ 9], 14, k2);
Subround(H, d1, e1, a1, b1, c1, X[15], 9, k2);
Subround(H, c1, d1, e1, a1, b1, X[ 8], 13, k2);
Subround(H, b1, c1, d1, e1, a1, X[ 1], 15, k2);
Subround(H, a1, b1, c1, d1, e1, X[ 2], 14, k2);
Subround(H, e1, a1, b1, c1, d1, X[ 7], 8, k2);
Subround(H, d1, e1, a1, b1, c1, X[ 0], 13, k2);
Subround(H, c1, d1, e1, a1, b1, X[ 6], 6, k2);
Subround(H, b1, c1, d1, e1, a1, X[13], 5, k2);
Subround(H, a1, b1, c1, d1, e1, X[11], 12, k2);
Subround(H, e1, a1, b1, c1, d1, X[ 5], 7, k2);
Subround(H, d1, e1, a1, b1, c1, X[12], 5, k2);
Subround(I, c1, d1, e1, a1, b1, X[ 1], 11, k3);
Subround(I, b1, c1, d1, e1, a1, X[ 9], 12, k3);
Subround(I, a1, b1, c1, d1, e1, X[11], 14, k3);
Subround(I, e1, a1, b1, c1, d1, X[10], 15, k3);
Subround(I, d1, e1, a1, b1, c1, X[ 0], 14, k3);
Subround(I, c1, d1, e1, a1, b1, X[ 8], 15, k3);
Subround(I, b1, c1, d1, e1, a1, X[12], 9, k3);
Subround(I, a1, b1, c1, d1, e1, X[ 4], 8, k3);
Subround(I, e1, a1, b1, c1, d1, X[13], 9, k3);
Subround(I, d1, e1, a1, b1, c1, X[ 3], 14, k3);
Subround(I, c1, d1, e1, a1, b1, X[ 7], 5, k3);
Subround(I, b1, c1, d1, e1, a1, X[15], 6, k3);
Subround(I, a1, b1, c1, d1, e1, X[14], 8, k3);
Subround(I, e1, a1, b1, c1, d1, X[ 5], 6, k3);
Subround(I, d1, e1, a1, b1, c1, X[ 6], 5, k3);
Subround(I, c1, d1, e1, a1, b1, X[ 2], 12, k3);
Subround(J, b1, c1, d1, e1, a1, X[ 4], 9, k4);
Subround(J, a1, b1, c1, d1, e1, X[ 0], 15, k4);
Subround(J, e1, a1, b1, c1, d1, X[ 5], 5, k4);
Subround(J, d1, e1, a1, b1, c1, X[ 9], 11, k4);
Subround(J, c1, d1, e1, a1, b1, X[ 7], 6, k4);
Subround(J, b1, c1, d1, e1, a1, X[12], 8, k4);
Subround(J, a1, b1, c1, d1, e1, X[ 2], 13, k4);
Subround(J, e1, a1, b1, c1, d1, X[10], 12, k4);
Subround(J, d1, e1, a1, b1, c1, X[14], 5, k4);
Subround(J, c1, d1, e1, a1, b1, X[ 1], 12, k4);
Subround(J, b1, c1, d1, e1, a1, X[ 3], 13, k4);
Subround(J, a1, b1, c1, d1, e1, X[ 8], 14, k4);
Subround(J, e1, a1, b1, c1, d1, X[11], 11, k4);
Subround(J, d1, e1, a1, b1, c1, X[ 6], 8, k4);
Subround(J, c1, d1, e1, a1, b1, X[15], 5, k4);
Subround(J, b1, c1, d1, e1, a1, X[13], 6, k4);
Subround(J, a2, b2, c2, d2, e2, X[ 5], 8, k5);
Subround(J, e2, a2, b2, c2, d2, X[14], 9, k5);
Subround(J, d2, e2, a2, b2, c2, X[ 7], 9, k5);
Subround(J, c2, d2, e2, a2, b2, X[ 0], 11, k5);
Subround(J, b2, c2, d2, e2, a2, X[ 9], 13, k5);
Subround(J, a2, b2, c2, d2, e2, X[ 2], 15, k5);
Subround(J, e2, a2, b2, c2, d2, X[11], 15, k5);
Subround(J, d2, e2, a2, b2, c2, X[ 4], 5, k5);
Subround(J, c2, d2, e2, a2, b2, X[13], 7, k5);
Subround(J, b2, c2, d2, e2, a2, X[ 6], 7, k5);
Subround(J, a2, b2, c2, d2, e2, X[15], 8, k5);
Subround(J, e2, a2, b2, c2, d2, X[ 8], 11, k5);
Subround(J, d2, e2, a2, b2, c2, X[ 1], 14, k5);
Subround(J, c2, d2, e2, a2, b2, X[10], 14, k5);
Subround(J, b2, c2, d2, e2, a2, X[ 3], 12, k5);
Subround(J, a2, b2, c2, d2, e2, X[12], 6, k5);
Subround(I, e2, a2, b2, c2, d2, X[ 6], 9, k6);
Subround(I, d2, e2, a2, b2, c2, X[11], 13, k6);
Subround(I, c2, d2, e2, a2, b2, X[ 3], 15, k6);
Subround(I, b2, c2, d2, e2, a2, X[ 7], 7, k6);
Subround(I, a2, b2, c2, d2, e2, X[ 0], 12, k6);
Subround(I, e2, a2, b2, c2, d2, X[13], 8, k6);
Subround(I, d2, e2, a2, b2, c2, X[ 5], 9, k6);
Subround(I, c2, d2, e2, a2, b2, X[10], 11, k6);
Subround(I, b2, c2, d2, e2, a2, X[14], 7, k6);
Subround(I, a2, b2, c2, d2, e2, X[15], 7, k6);
Subround(I, e2, a2, b2, c2, d2, X[ 8], 12, k6);
Subround(I, d2, e2, a2, b2, c2, X[12], 7, k6);
Subround(I, c2, d2, e2, a2, b2, X[ 4], 6, k6);
Subround(I, b2, c2, d2, e2, a2, X[ 9], 15, k6);
Subround(I, a2, b2, c2, d2, e2, X[ 1], 13, k6);
Subround(I, e2, a2, b2, c2, d2, X[ 2], 11, k6);
Subround(H, d2, e2, a2, b2, c2, X[15], 9, k7);
Subround(H, c2, d2, e2, a2, b2, X[ 5], 7, k7);
Subround(H, b2, c2, d2, e2, a2, X[ 1], 15, k7);
Subround(H, a2, b2, c2, d2, e2, X[ 3], 11, k7);
Subround(H, e2, a2, b2, c2, d2, X[ 7], 8, k7);
Subround(H, d2, e2, a2, b2, c2, X[14], 6, k7);
Subround(H, c2, d2, e2, a2, b2, X[ 6], 6, k7);
Subround(H, b2, c2, d2, e2, a2, X[ 9], 14, k7);
Subround(H, a2, b2, c2, d2, e2, X[11], 12, k7);
Subround(H, e2, a2, b2, c2, d2, X[ 8], 13, k7);
Subround(H, d2, e2, a2, b2, c2, X[12], 5, k7);
Subround(H, c2, d2, e2, a2, b2, X[ 2], 14, k7);
Subround(H, b2, c2, d2, e2, a2, X[10], 13, k7);
Subround(H, a2, b2, c2, d2, e2, X[ 0], 13, k7);
Subround(H, e2, a2, b2, c2, d2, X[ 4], 7, k7);
Subround(H, d2, e2, a2, b2, c2, X[13], 5, k7);
Subround(G, c2, d2, e2, a2, b2, X[ 8], 15, k8);
Subround(G, b2, c2, d2, e2, a2, X[ 6], 5, k8);
Subround(G, a2, b2, c2, d2, e2, X[ 4], 8, k8);
Subround(G, e2, a2, b2, c2, d2, X[ 1], 11, k8);
Subround(G, d2, e2, a2, b2, c2, X[ 3], 14, k8);
Subround(G, c2, d2, e2, a2, b2, X[11], 14, k8);
Subround(G, b2, c2, d2, e2, a2, X[15], 6, k8);
Subround(G, a2, b2, c2, d2, e2, X[ 0], 14, k8);
Subround(G, e2, a2, b2, c2, d2, X[ 5], 6, k8);
Subround(G, d2, e2, a2, b2, c2, X[12], 9, k8);
Subround(G, c2, d2, e2, a2, b2, X[ 2], 12, k8);
Subround(G, b2, c2, d2, e2, a2, X[13], 9, k8);
Subround(G, a2, b2, c2, d2, e2, X[ 9], 12, k8);
Subround(G, e2, a2, b2, c2, d2, X[ 7], 5, k8);
Subround(G, d2, e2, a2, b2, c2, X[10], 15, k8);
Subround(G, c2, d2, e2, a2, b2, X[14], 8, k8);
Subround(F, b2, c2, d2, e2, a2, X[12], 8, k9);
Subround(F, a2, b2, c2, d2, e2, X[15], 5, k9);
Subround(F, e2, a2, b2, c2, d2, X[10], 12, k9);
Subround(F, d2, e2, a2, b2, c2, X[ 4], 9, k9);
Subround(F, c2, d2, e2, a2, b2, X[ 1], 12, k9);
Subround(F, b2, c2, d2, e2, a2, X[ 5], 5, k9);
Subround(F, a2, b2, c2, d2, e2, X[ 8], 14, k9);
Subround(F, e2, a2, b2, c2, d2, X[ 7], 6, k9);
Subround(F, d2, e2, a2, b2, c2, X[ 6], 8, k9);
Subround(F, c2, d2, e2, a2, b2, X[ 2], 13, k9);
Subround(F, b2, c2, d2, e2, a2, X[13], 6, k9);
Subround(F, a2, b2, c2, d2, e2, X[14], 5, k9);
Subround(F, e2, a2, b2, c2, d2, X[ 0], 15, k9);
Subround(F, d2, e2, a2, b2, c2, X[ 3], 13, k9);
Subround(F, c2, d2, e2, a2, b2, X[ 9], 11, k9);
Subround(F, b2, c2, d2, e2, a2, X[11], 11, k9);
c1 = digest[1] + c1 + d2;
digest[1] = digest[2] + d1 + e2;
digest[2] = digest[3] + e1 + a2;
digest[3] = digest[4] + a1 + b2;
digest[4] = digest[0] + b1 + c2;
digest[0] = c1;
}
// *************************************************************
void RIPEMD320::InitState(HashWordType *state)
{
state[0] = 0x67452301L;
state[1] = 0xefcdab89L;
state[2] = 0x98badcfeL;
state[3] = 0x10325476L;
state[4] = 0xc3d2e1f0L;
state[5] = 0x76543210L;
state[6] = 0xfedcba98L;
state[7] = 0x89abcdefL;
state[8] = 0x01234567L;
state[9] = 0x3c2d1e0fL;
}
void RIPEMD320::Transform (word32 *digest, const word32 *X)
{
unsigned long a1, b1, c1, d1, e1, a2, b2, c2, d2, e2, t;
a1 = digest[0];
b1 = digest[1];
c1 = digest[2];
d1 = digest[3];
e1 = digest[4];
a2 = digest[5];
b2 = digest[6];
c2 = digest[7];
d2 = digest[8];
e2 = digest[9];
Subround(F, a1, b1, c1, d1, e1, X[ 0], 11, k0);
Subround(F, e1, a1, b1, c1, d1, X[ 1], 14, k0);
Subround(F, d1, e1, a1, b1, c1, X[ 2], 15, k0);
Subround(F, c1, d1, e1, a1, b1, X[ 3], 12, k0);
Subround(F, b1, c1, d1, e1, a1, X[ 4], 5, k0);
Subround(F, a1, b1, c1, d1, e1, X[ 5], 8, k0);
Subround(F, e1, a1, b1, c1, d1, X[ 6], 7, k0);
Subround(F, d1, e1, a1, b1, c1, X[ 7], 9, k0);
Subround(F, c1, d1, e1, a1, b1, X[ 8], 11, k0);
Subround(F, b1, c1, d1, e1, a1, X[ 9], 13, k0);
Subround(F, a1, b1, c1, d1, e1, X[10], 14, k0);
Subround(F, e1, a1, b1, c1, d1, X[11], 15, k0);
Subround(F, d1, e1, a1, b1, c1, X[12], 6, k0);
Subround(F, c1, d1, e1, a1, b1, X[13], 7, k0);
Subround(F, b1, c1, d1, e1, a1, X[14], 9, k0);
Subround(F, a1, b1, c1, d1, e1, X[15], 8, k0);
Subround(J, a2, b2, c2, d2, e2, X[ 5], 8, k5);
Subround(J, e2, a2, b2, c2, d2, X[14], 9, k5);
Subround(J, d2, e2, a2, b2, c2, X[ 7], 9, k5);
Subround(J, c2, d2, e2, a2, b2, X[ 0], 11, k5);
Subround(J, b2, c2, d2, e2, a2, X[ 9], 13, k5);
Subround(J, a2, b2, c2, d2, e2, X[ 2], 15, k5);
Subround(J, e2, a2, b2, c2, d2, X[11], 15, k5);
Subround(J, d2, e2, a2, b2, c2, X[ 4], 5, k5);
Subround(J, c2, d2, e2, a2, b2, X[13], 7, k5);
Subround(J, b2, c2, d2, e2, a2, X[ 6], 7, k5);
Subround(J, a2, b2, c2, d2, e2, X[15], 8, k5);
Subround(J, e2, a2, b2, c2, d2, X[ 8], 11, k5);
Subround(J, d2, e2, a2, b2, c2, X[ 1], 14, k5);
Subround(J, c2, d2, e2, a2, b2, X[10], 14, k5);
Subround(J, b2, c2, d2, e2, a2, X[ 3], 12, k5);
Subround(J, a2, b2, c2, d2, e2, X[12], 6, k5);
t = a1; a1 = a2; a2 = t;
Subround(G, e1, a1, b1, c1, d1, X[ 7], 7, k1);
Subround(G, d1, e1, a1, b1, c1, X[ 4], 6, k1);
Subround(G, c1, d1, e1, a1, b1, X[13], 8, k1);
Subround(G, b1, c1, d1, e1, a1, X[ 1], 13, k1);
Subround(G, a1, b1, c1, d1, e1, X[10], 11, k1);
Subround(G, e1, a1, b1, c1, d1, X[ 6], 9, k1);
Subround(G, d1, e1, a1, b1, c1, X[15], 7, k1);
Subround(G, c1, d1, e1, a1, b1, X[ 3], 15, k1);
Subround(G, b1, c1, d1, e1, a1, X[12], 7, k1);
Subround(G, a1, b1, c1, d1, e1, X[ 0], 12, k1);
Subround(G, e1, a1, b1, c1, d1, X[ 9], 15, k1);
Subround(G, d1, e1, a1, b1, c1, X[ 5], 9, k1);
Subround(G, c1, d1, e1, a1, b1, X[ 2], 11, k1);
Subround(G, b1, c1, d1, e1, a1, X[14], 7, k1);
Subround(G, a1, b1, c1, d1, e1, X[11], 13, k1);
Subround(G, e1, a1, b1, c1, d1, X[ 8], 12, k1);
Subround(I, e2, a2, b2, c2, d2, X[ 6], 9, k6);
Subround(I, d2, e2, a2, b2, c2, X[11], 13, k6);
Subround(I, c2, d2, e2, a2, b2, X[ 3], 15, k6);
Subround(I, b2, c2, d2, e2, a2, X[ 7], 7, k6);
Subround(I, a2, b2, c2, d2, e2, X[ 0], 12, k6);
Subround(I, e2, a2, b2, c2, d2, X[13], 8, k6);
Subround(I, d2, e2, a2, b2, c2, X[ 5], 9, k6);
Subround(I, c2, d2, e2, a2, b2, X[10], 11, k6);
Subround(I, b2, c2, d2, e2, a2, X[14], 7, k6);
Subround(I, a2, b2, c2, d2, e2, X[15], 7, k6);
Subround(I, e2, a2, b2, c2, d2, X[ 8], 12, k6);
Subround(I, d2, e2, a2, b2, c2, X[12], 7, k6);
Subround(I, c2, d2, e2, a2, b2, X[ 4], 6, k6);
Subround(I, b2, c2, d2, e2, a2, X[ 9], 15, k6);
Subround(I, a2, b2, c2, d2, e2, X[ 1], 13, k6);
Subround(I, e2, a2, b2, c2, d2, X[ 2], 11, k6);
t = b1; b1 = b2; b2 = t;
Subround(H, d1, e1, a1, b1, c1, X[ 3], 11, k2);
Subround(H, c1, d1, e1, a1, b1, X[10], 13, k2);
Subround(H, b1, c1, d1, e1, a1, X[14], 6, k2);
Subround(H, a1, b1, c1, d1, e1, X[ 4], 7, k2);
Subround(H, e1, a1, b1, c1, d1, X[ 9], 14, k2);
Subround(H, d1, e1, a1, b1, c1, X[15], 9, k2);
Subround(H, c1, d1, e1, a1, b1, X[ 8], 13, k2);
Subround(H, b1, c1, d1, e1, a1, X[ 1], 15, k2);
Subround(H, a1, b1, c1, d1, e1, X[ 2], 14, k2);
Subround(H, e1, a1, b1, c1, d1, X[ 7], 8, k2);
Subround(H, d1, e1, a1, b1, c1, X[ 0], 13, k2);
Subround(H, c1, d1, e1, a1, b1, X[ 6], 6, k2);
Subround(H, b1, c1, d1, e1, a1, X[13], 5, k2);
Subround(H, a1, b1, c1, d1, e1, X[11], 12, k2);
Subround(H, e1, a1, b1, c1, d1, X[ 5], 7, k2);
Subround(H, d1, e1, a1, b1, c1, X[12], 5, k2);
Subround(H, d2, e2, a2, b2, c2, X[15], 9, k7);
Subround(H, c2, d2, e2, a2, b2, X[ 5], 7, k7);
Subround(H, b2, c2, d2, e2, a2, X[ 1], 15, k7);
Subround(H, a2, b2, c2, d2, e2, X[ 3], 11, k7);
Subround(H, e2, a2, b2, c2, d2, X[ 7], 8, k7);
Subround(H, d2, e2, a2, b2, c2, X[14], 6, k7);
Subround(H, c2, d2, e2, a2, b2, X[ 6], 6, k7);
Subround(H, b2, c2, d2, e2, a2, X[ 9], 14, k7);
Subround(H, a2, b2, c2, d2, e2, X[11], 12, k7);
Subround(H, e2, a2, b2, c2, d2, X[ 8], 13, k7);
Subround(H, d2, e2, a2, b2, c2, X[12], 5, k7);
Subround(H, c2, d2, e2, a2, b2, X[ 2], 14, k7);
Subround(H, b2, c2, d2, e2, a2, X[10], 13, k7);
Subround(H, a2, b2, c2, d2, e2, X[ 0], 13, k7);
Subround(H, e2, a2, b2, c2, d2, X[ 4], 7, k7);
Subround(H, d2, e2, a2, b2, c2, X[13], 5, k7);
t = c1; c1 = c2; c2 = t;
Subround(I, c1, d1, e1, a1, b1, X[ 1], 11, k3);
Subround(I, b1, c1, d1, e1, a1, X[ 9], 12, k3);
Subround(I, a1, b1, c1, d1, e1, X[11], 14, k3);
Subround(I, e1, a1, b1, c1, d1, X[10], 15, k3);
Subround(I, d1, e1, a1, b1, c1, X[ 0], 14, k3);
Subround(I, c1, d1, e1, a1, b1, X[ 8], 15, k3);
Subround(I, b1, c1, d1, e1, a1, X[12], 9, k3);
Subround(I, a1, b1, c1, d1, e1, X[ 4], 8, k3);
Subround(I, e1, a1, b1, c1, d1, X[13], 9, k3);
Subround(I, d1, e1, a1, b1, c1, X[ 3], 14, k3);
Subround(I, c1, d1, e1, a1, b1, X[ 7], 5, k3);
Subround(I, b1, c1, d1, e1, a1, X[15], 6, k3);
Subround(I, a1, b1, c1, d1, e1, X[14], 8, k3);
Subround(I, e1, a1, b1, c1, d1, X[ 5], 6, k3);
Subround(I, d1, e1, a1, b1, c1, X[ 6], 5, k3);
Subround(I, c1, d1, e1, a1, b1, X[ 2], 12, k3);
Subround(G, c2, d2, e2, a2, b2, X[ 8], 15, k8);
Subround(G, b2, c2, d2, e2, a2, X[ 6], 5, k8);
Subround(G, a2, b2, c2, d2, e2, X[ 4], 8, k8);
Subround(G, e2, a2, b2, c2, d2, X[ 1], 11, k8);
Subround(G, d2, e2, a2, b2, c2, X[ 3], 14, k8);
Subround(G, c2, d2, e2, a2, b2, X[11], 14, k8);
Subround(G, b2, c2, d2, e2, a2, X[15], 6, k8);
Subround(G, a2, b2, c2, d2, e2, X[ 0], 14, k8);
Subround(G, e2, a2, b2, c2, d2, X[ 5], 6, k8);
Subround(G, d2, e2, a2, b2, c2, X[12], 9, k8);
Subround(G, c2, d2, e2, a2, b2, X[ 2], 12, k8);
Subround(G, b2, c2, d2, e2, a2, X[13], 9, k8);
Subround(G, a2, b2, c2, d2, e2, X[ 9], 12, k8);
Subround(G, e2, a2, b2, c2, d2, X[ 7], 5, k8);
Subround(G, d2, e2, a2, b2, c2, X[10], 15, k8);
Subround(G, c2, d2, e2, a2, b2, X[14], 8, k8);
t = d1; d1 = d2; d2 = t;
Subround(J, b1, c1, d1, e1, a1, X[ 4], 9, k4);
Subround(J, a1, b1, c1, d1, e1, X[ 0], 15, k4);
Subround(J, e1, a1, b1, c1, d1, X[ 5], 5, k4);
Subround(J, d1, e1, a1, b1, c1, X[ 9], 11, k4);
Subround(J, c1, d1, e1, a1, b1, X[ 7], 6, k4);
Subround(J, b1, c1, d1, e1, a1, X[12], 8, k4);
Subround(J, a1, b1, c1, d1, e1, X[ 2], 13, k4);
Subround(J, e1, a1, b1, c1, d1, X[10], 12, k4);
Subround(J, d1, e1, a1, b1, c1, X[14], 5, k4);
Subround(J, c1, d1, e1, a1, b1, X[ 1], 12, k4);
Subround(J, b1, c1, d1, e1, a1, X[ 3], 13, k4);
Subround(J, a1, b1, c1, d1, e1, X[ 8], 14, k4);
Subround(J, e1, a1, b1, c1, d1, X[11], 11, k4);
Subround(J, d1, e1, a1, b1, c1, X[ 6], 8, k4);
Subround(J, c1, d1, e1, a1, b1, X[15], 5, k4);
Subround(J, b1, c1, d1, e1, a1, X[13], 6, k4);
Subround(F, b2, c2, d2, e2, a2, X[12], 8, k9);
Subround(F, a2, b2, c2, d2, e2, X[15], 5, k9);
Subround(F, e2, a2, b2, c2, d2, X[10], 12, k9);
Subround(F, d2, e2, a2, b2, c2, X[ 4], 9, k9);
Subround(F, c2, d2, e2, a2, b2, X[ 1], 12, k9);
Subround(F, b2, c2, d2, e2, a2, X[ 5], 5, k9);
Subround(F, a2, b2, c2, d2, e2, X[ 8], 14, k9);
Subround(F, e2, a2, b2, c2, d2, X[ 7], 6, k9);
Subround(F, d2, e2, a2, b2, c2, X[ 6], 8, k9);
Subround(F, c2, d2, e2, a2, b2, X[ 2], 13, k9);
Subround(F, b2, c2, d2, e2, a2, X[13], 6, k9);
Subround(F, a2, b2, c2, d2, e2, X[14], 5, k9);
Subround(F, e2, a2, b2, c2, d2, X[ 0], 15, k9);
Subround(F, d2, e2, a2, b2, c2, X[ 3], 13, k9);
Subround(F, c2, d2, e2, a2, b2, X[ 9], 11, k9);
Subround(F, b2, c2, d2, e2, a2, X[11], 11, k9);
t = e1; e1 = e2; e2 = t;
digest[0] += a1;
digest[1] += b1;
digest[2] += c1;
digest[3] += d1;
digest[4] += e1;
digest[5] += a2;
digest[6] += b2;
digest[7] += c2;
digest[8] += d2;
digest[9] += e2;
}
#undef Subround
// *************************************************************
// for 128 and 256
#define Subround(f, a, b, c, d, x, s, k) \
a += f(b, c, d) + x + k;\
a = rotlFixed((word32)a, s);
void RIPEMD128::InitState(HashWordType *state)
{
state[0] = 0x67452301L;
state[1] = 0xefcdab89L;
state[2] = 0x98badcfeL;
state[3] = 0x10325476L;
}
void RIPEMD128::Transform (word32 *digest, const word32 *X)
{
unsigned long a1, b1, c1, d1, a2, b2, c2, d2;
a1 = a2 = digest[0];
b1 = b2 = digest[1];
c1 = c2 = digest[2];
d1 = d2 = digest[3];
Subround(F, a1, b1, c1, d1, X[ 0], 11, k0);
Subround(F, d1, a1, b1, c1, X[ 1], 14, k0);
Subround(F, c1, d1, a1, b1, X[ 2], 15, k0);
Subround(F, b1, c1, d1, a1, X[ 3], 12, k0);
Subround(F, a1, b1, c1, d1, X[ 4], 5, k0);
Subround(F, d1, a1, b1, c1, X[ 5], 8, k0);
Subround(F, c1, d1, a1, b1, X[ 6], 7, k0);
Subround(F, b1, c1, d1, a1, X[ 7], 9, k0);
Subround(F, a1, b1, c1, d1, X[ 8], 11, k0);
Subround(F, d1, a1, b1, c1, X[ 9], 13, k0);
Subround(F, c1, d1, a1, b1, X[10], 14, k0);
Subround(F, b1, c1, d1, a1, X[11], 15, k0);
Subround(F, a1, b1, c1, d1, X[12], 6, k0);
Subround(F, d1, a1, b1, c1, X[13], 7, k0);
Subround(F, c1, d1, a1, b1, X[14], 9, k0);
Subround(F, b1, c1, d1, a1, X[15], 8, k0);
Subround(G, a1, b1, c1, d1, X[ 7], 7, k1);
Subround(G, d1, a1, b1, c1, X[ 4], 6, k1);
Subround(G, c1, d1, a1, b1, X[13], 8, k1);
Subround(G, b1, c1, d1, a1, X[ 1], 13, k1);
Subround(G, a1, b1, c1, d1, X[10], 11, k1);
Subround(G, d1, a1, b1, c1, X[ 6], 9, k1);
Subround(G, c1, d1, a1, b1, X[15], 7, k1);
Subround(G, b1, c1, d1, a1, X[ 3], 15, k1);
Subround(G, a1, b1, c1, d1, X[12], 7, k1);
Subround(G, d1, a1, b1, c1, X[ 0], 12, k1);
Subround(G, c1, d1, a1, b1, X[ 9], 15, k1);
Subround(G, b1, c1, d1, a1, X[ 5], 9, k1);
Subround(G, a1, b1, c1, d1, X[ 2], 11, k1);
Subround(G, d1, a1, b1, c1, X[14], 7, k1);
Subround(G, c1, d1, a1, b1, X[11], 13, k1);
Subround(G, b1, c1, d1, a1, X[ 8], 12, k1);
Subround(H, a1, b1, c1, d1, X[ 3], 11, k2);
Subround(H, d1, a1, b1, c1, X[10], 13, k2);
Subround(H, c1, d1, a1, b1, X[14], 6, k2);
Subround(H, b1, c1, d1, a1, X[ 4], 7, k2);
Subround(H, a1, b1, c1, d1, X[ 9], 14, k2);
Subround(H, d1, a1, b1, c1, X[15], 9, k2);
Subround(H, c1, d1, a1, b1, X[ 8], 13, k2);
Subround(H, b1, c1, d1, a1, X[ 1], 15, k2);
Subround(H, a1, b1, c1, d1, X[ 2], 14, k2);
Subround(H, d1, a1, b1, c1, X[ 7], 8, k2);
Subround(H, c1, d1, a1, b1, X[ 0], 13, k2);
Subround(H, b1, c1, d1, a1, X[ 6], 6, k2);
Subround(H, a1, b1, c1, d1, X[13], 5, k2);
Subround(H, d1, a1, b1, c1, X[11], 12, k2);
Subround(H, c1, d1, a1, b1, X[ 5], 7, k2);
Subround(H, b1, c1, d1, a1, X[12], 5, k2);
Subround(I, a1, b1, c1, d1, X[ 1], 11, k3);
Subround(I, d1, a1, b1, c1, X[ 9], 12, k3);
Subround(I, c1, d1, a1, b1, X[11], 14, k3);
Subround(I, b1, c1, d1, a1, X[10], 15, k3);
Subround(I, a1, b1, c1, d1, X[ 0], 14, k3);
Subround(I, d1, a1, b1, c1, X[ 8], 15, k3);
Subround(I, c1, d1, a1, b1, X[12], 9, k3);
Subround(I, b1, c1, d1, a1, X[ 4], 8, k3);
Subround(I, a1, b1, c1, d1, X[13], 9, k3);
Subround(I, d1, a1, b1, c1, X[ 3], 14, k3);
Subround(I, c1, d1, a1, b1, X[ 7], 5, k3);
Subround(I, b1, c1, d1, a1, X[15], 6, k3);
Subround(I, a1, b1, c1, d1, X[14], 8, k3);
Subround(I, d1, a1, b1, c1, X[ 5], 6, k3);
Subround(I, c1, d1, a1, b1, X[ 6], 5, k3);
Subround(I, b1, c1, d1, a1, X[ 2], 12, k3);
Subround(I, a2, b2, c2, d2, X[ 5], 8, k5);
Subround(I, d2, a2, b2, c2, X[14], 9, k5);
Subround(I, c2, d2, a2, b2, X[ 7], 9, k5);
Subround(I, b2, c2, d2, a2, X[ 0], 11, k5);
Subround(I, a2, b2, c2, d2, X[ 9], 13, k5);
Subround(I, d2, a2, b2, c2, X[ 2], 15, k5);
Subround(I, c2, d2, a2, b2, X[11], 15, k5);
Subround(I, b2, c2, d2, a2, X[ 4], 5, k5);
Subround(I, a2, b2, c2, d2, X[13], 7, k5);
Subround(I, d2, a2, b2, c2, X[ 6], 7, k5);
Subround(I, c2, d2, a2, b2, X[15], 8, k5);
Subround(I, b2, c2, d2, a2, X[ 8], 11, k5);
Subround(I, a2, b2, c2, d2, X[ 1], 14, k5);
Subround(I, d2, a2, b2, c2, X[10], 14, k5);
Subround(I, c2, d2, a2, b2, X[ 3], 12, k5);
Subround(I, b2, c2, d2, a2, X[12], 6, k5);
Subround(H, a2, b2, c2, d2, X[ 6], 9, k6);
Subround(H, d2, a2, b2, c2, X[11], 13, k6);
Subround(H, c2, d2, a2, b2, X[ 3], 15, k6);
Subround(H, b2, c2, d2, a2, X[ 7], 7, k6);
Subround(H, a2, b2, c2, d2, X[ 0], 12, k6);
Subround(H, d2, a2, b2, c2, X[13], 8, k6);
Subround(H, c2, d2, a2, b2, X[ 5], 9, k6);
Subround(H, b2, c2, d2, a2, X[10], 11, k6);
Subround(H, a2, b2, c2, d2, X[14], 7, k6);
Subround(H, d2, a2, b2, c2, X[15], 7, k6);
Subround(H, c2, d2, a2, b2, X[ 8], 12, k6);
Subround(H, b2, c2, d2, a2, X[12], 7, k6);
Subround(H, a2, b2, c2, d2, X[ 4], 6, k6);
Subround(H, d2, a2, b2, c2, X[ 9], 15, k6);
Subround(H, c2, d2, a2, b2, X[ 1], 13, k6);
Subround(H, b2, c2, d2, a2, X[ 2], 11, k6);
Subround(G, a2, b2, c2, d2, X[15], 9, k7);
Subround(G, d2, a2, b2, c2, X[ 5], 7, k7);
Subround(G, c2, d2, a2, b2, X[ 1], 15, k7);
Subround(G, b2, c2, d2, a2, X[ 3], 11, k7);
Subround(G, a2, b2, c2, d2, X[ 7], 8, k7);
Subround(G, d2, a2, b2, c2, X[14], 6, k7);
Subround(G, c2, d2, a2, b2, X[ 6], 6, k7);
Subround(G, b2, c2, d2, a2, X[ 9], 14, k7);
Subround(G, a2, b2, c2, d2, X[11], 12, k7);
Subround(G, d2, a2, b2, c2, X[ 8], 13, k7);
Subround(G, c2, d2, a2, b2, X[12], 5, k7);
Subround(G, b2, c2, d2, a2, X[ 2], 14, k7);
Subround(G, a2, b2, c2, d2, X[10], 13, k7);
Subround(G, d2, a2, b2, c2, X[ 0], 13, k7);
Subround(G, c2, d2, a2, b2, X[ 4], 7, k7);
Subround(G, b2, c2, d2, a2, X[13], 5, k7);
Subround(F, a2, b2, c2, d2, X[ 8], 15, k9);
Subround(F, d2, a2, b2, c2, X[ 6], 5, k9);
Subround(F, c2, d2, a2, b2, X[ 4], 8, k9);
Subround(F, b2, c2, d2, a2, X[ 1], 11, k9);
Subround(F, a2, b2, c2, d2, X[ 3], 14, k9);
Subround(F, d2, a2, b2, c2, X[11], 14, k9);
Subround(F, c2, d2, a2, b2, X[15], 6, k9);
Subround(F, b2, c2, d2, a2, X[ 0], 14, k9);
Subround(F, a2, b2, c2, d2, X[ 5], 6, k9);
Subround(F, d2, a2, b2, c2, X[12], 9, k9);
Subround(F, c2, d2, a2, b2, X[ 2], 12, k9);
Subround(F, b2, c2, d2, a2, X[13], 9, k9);
Subround(F, a2, b2, c2, d2, X[ 9], 12, k9);
Subround(F, d2, a2, b2, c2, X[ 7], 5, k9);
Subround(F, c2, d2, a2, b2, X[10], 15, k9);
Subround(F, b2, c2, d2, a2, X[14], 8, k9);
c1 = digest[1] + c1 + d2;
digest[1] = digest[2] + d1 + a2;
digest[2] = digest[3] + a1 + b2;
digest[3] = digest[0] + b1 + c2;
digest[0] = c1;
}
// *************************************************************
void RIPEMD256::InitState(HashWordType *state)
{
state[0] = 0x67452301L;
state[1] = 0xefcdab89L;
state[2] = 0x98badcfeL;
state[3] = 0x10325476L;
state[4] = 0x76543210L;
state[5] = 0xfedcba98L;
state[6] = 0x89abcdefL;
state[7] = 0x01234567L;
}
void RIPEMD256::Transform (word32 *digest, const word32 *X)
{
unsigned long a1, b1, c1, d1, a2, b2, c2, d2, t;
a1 = digest[0];
b1 = digest[1];
c1 = digest[2];
d1 = digest[3];
a2 = digest[4];
b2 = digest[5];
c2 = digest[6];
d2 = digest[7];
Subround(F, a1, b1, c1, d1, X[ 0], 11, k0);
Subround(F, d1, a1, b1, c1, X[ 1], 14, k0);
Subround(F, c1, d1, a1, b1, X[ 2], 15, k0);
Subround(F, b1, c1, d1, a1, X[ 3], 12, k0);
Subround(F, a1, b1, c1, d1, X[ 4], 5, k0);
Subround(F, d1, a1, b1, c1, X[ 5], 8, k0);
Subround(F, c1, d1, a1, b1, X[ 6], 7, k0);
Subround(F, b1, c1, d1, a1, X[ 7], 9, k0);
Subround(F, a1, b1, c1, d1, X[ 8], 11, k0);
Subround(F, d1, a1, b1, c1, X[ 9], 13, k0);
Subround(F, c1, d1, a1, b1, X[10], 14, k0);
Subround(F, b1, c1, d1, a1, X[11], 15, k0);
Subround(F, a1, b1, c1, d1, X[12], 6, k0);
Subround(F, d1, a1, b1, c1, X[13], 7, k0);
Subround(F, c1, d1, a1, b1, X[14], 9, k0);
Subround(F, b1, c1, d1, a1, X[15], 8, k0);
Subround(I, a2, b2, c2, d2, X[ 5], 8, k5);
Subround(I, d2, a2, b2, c2, X[14], 9, k5);
Subround(I, c2, d2, a2, b2, X[ 7], 9, k5);
Subround(I, b2, c2, d2, a2, X[ 0], 11, k5);
Subround(I, a2, b2, c2, d2, X[ 9], 13, k5);
Subround(I, d2, a2, b2, c2, X[ 2], 15, k5);
Subround(I, c2, d2, a2, b2, X[11], 15, k5);
Subround(I, b2, c2, d2, a2, X[ 4], 5, k5);
Subround(I, a2, b2, c2, d2, X[13], 7, k5);
Subround(I, d2, a2, b2, c2, X[ 6], 7, k5);
Subround(I, c2, d2, a2, b2, X[15], 8, k5);
Subround(I, b2, c2, d2, a2, X[ 8], 11, k5);
Subround(I, a2, b2, c2, d2, X[ 1], 14, k5);
Subround(I, d2, a2, b2, c2, X[10], 14, k5);
Subround(I, c2, d2, a2, b2, X[ 3], 12, k5);
Subround(I, b2, c2, d2, a2, X[12], 6, k5);
t = a1; a1 = a2; a2 = t;
Subround(G, a1, b1, c1, d1, X[ 7], 7, k1);
Subround(G, d1, a1, b1, c1, X[ 4], 6, k1);
Subround(G, c1, d1, a1, b1, X[13], 8, k1);
Subround(G, b1, c1, d1, a1, X[ 1], 13, k1);
Subround(G, a1, b1, c1, d1, X[10], 11, k1);
Subround(G, d1, a1, b1, c1, X[ 6], 9, k1);
Subround(G, c1, d1, a1, b1, X[15], 7, k1);
Subround(G, b1, c1, d1, a1, X[ 3], 15, k1);
Subround(G, a1, b1, c1, d1, X[12], 7, k1);
Subround(G, d1, a1, b1, c1, X[ 0], 12, k1);
Subround(G, c1, d1, a1, b1, X[ 9], 15, k1);
Subround(G, b1, c1, d1, a1, X[ 5], 9, k1);
Subround(G, a1, b1, c1, d1, X[ 2], 11, k1);
Subround(G, d1, a1, b1, c1, X[14], 7, k1);
Subround(G, c1, d1, a1, b1, X[11], 13, k1);
Subround(G, b1, c1, d1, a1, X[ 8], 12, k1);
Subround(H, a2, b2, c2, d2, X[ 6], 9, k6);
Subround(H, d2, a2, b2, c2, X[11], 13, k6);
Subround(H, c2, d2, a2, b2, X[ 3], 15, k6);
Subround(H, b2, c2, d2, a2, X[ 7], 7, k6);
Subround(H, a2, b2, c2, d2, X[ 0], 12, k6);
Subround(H, d2, a2, b2, c2, X[13], 8, k6);
Subround(H, c2, d2, a2, b2, X[ 5], 9, k6);
Subround(H, b2, c2, d2, a2, X[10], 11, k6);
Subround(H, a2, b2, c2, d2, X[14], 7, k6);
Subround(H, d2, a2, b2, c2, X[15], 7, k6);
Subround(H, c2, d2, a2, b2, X[ 8], 12, k6);
Subround(H, b2, c2, d2, a2, X[12], 7, k6);
Subround(H, a2, b2, c2, d2, X[ 4], 6, k6);
Subround(H, d2, a2, b2, c2, X[ 9], 15, k6);
Subround(H, c2, d2, a2, b2, X[ 1], 13, k6);
Subround(H, b2, c2, d2, a2, X[ 2], 11, k6);
t = b1; b1 = b2; b2 = t;
Subround(H, a1, b1, c1, d1, X[ 3], 11, k2);
Subround(H, d1, a1, b1, c1, X[10], 13, k2);
Subround(H, c1, d1, a1, b1, X[14], 6, k2);
Subround(H, b1, c1, d1, a1, X[ 4], 7, k2);
Subround(H, a1, b1, c1, d1, X[ 9], 14, k2);
Subround(H, d1, a1, b1, c1, X[15], 9, k2);
Subround(H, c1, d1, a1, b1, X[ 8], 13, k2);
Subround(H, b1, c1, d1, a1, X[ 1], 15, k2);
Subround(H, a1, b1, c1, d1, X[ 2], 14, k2);
Subround(H, d1, a1, b1, c1, X[ 7], 8, k2);
Subround(H, c1, d1, a1, b1, X[ 0], 13, k2);
Subround(H, b1, c1, d1, a1, X[ 6], 6, k2);
Subround(H, a1, b1, c1, d1, X[13], 5, k2);
Subround(H, d1, a1, b1, c1, X[11], 12, k2);
Subround(H, c1, d1, a1, b1, X[ 5], 7, k2);
Subround(H, b1, c1, d1, a1, X[12], 5, k2);
Subround(G, a2, b2, c2, d2, X[15], 9, k7);
Subround(G, d2, a2, b2, c2, X[ 5], 7, k7);
Subround(G, c2, d2, a2, b2, X[ 1], 15, k7);
Subround(G, b2, c2, d2, a2, X[ 3], 11, k7);
Subround(G, a2, b2, c2, d2, X[ 7], 8, k7);
Subround(G, d2, a2, b2, c2, X[14], 6, k7);
Subround(G, c2, d2, a2, b2, X[ 6], 6, k7);
Subround(G, b2, c2, d2, a2, X[ 9], 14, k7);
Subround(G, a2, b2, c2, d2, X[11], 12, k7);
Subround(G, d2, a2, b2, c2, X[ 8], 13, k7);
Subround(G, c2, d2, a2, b2, X[12], 5, k7);
Subround(G, b2, c2, d2, a2, X[ 2], 14, k7);
Subround(G, a2, b2, c2, d2, X[10], 13, k7);
Subround(G, d2, a2, b2, c2, X[ 0], 13, k7);
Subround(G, c2, d2, a2, b2, X[ 4], 7, k7);
Subround(G, b2, c2, d2, a2, X[13], 5, k7);
t = c1; c1 = c2; c2 = t;
Subround(I, a1, b1, c1, d1, X[ 1], 11, k3);
Subround(I, d1, a1, b1, c1, X[ 9], 12, k3);
Subround(I, c1, d1, a1, b1, X[11], 14, k3);
Subround(I, b1, c1, d1, a1, X[10], 15, k3);
Subround(I, a1, b1, c1, d1, X[ 0], 14, k3);
Subround(I, d1, a1, b1, c1, X[ 8], 15, k3);
Subround(I, c1, d1, a1, b1, X[12], 9, k3);
Subround(I, b1, c1, d1, a1, X[ 4], 8, k3);
Subround(I, a1, b1, c1, d1, X[13], 9, k3);
Subround(I, d1, a1, b1, c1, X[ 3], 14, k3);
Subround(I, c1, d1, a1, b1, X[ 7], 5, k3);
Subround(I, b1, c1, d1, a1, X[15], 6, k3);
Subround(I, a1, b1, c1, d1, X[14], 8, k3);
Subround(I, d1, a1, b1, c1, X[ 5], 6, k3);
Subround(I, c1, d1, a1, b1, X[ 6], 5, k3);
Subround(I, b1, c1, d1, a1, X[ 2], 12, k3);
Subround(F, a2, b2, c2, d2, X[ 8], 15, k9);
Subround(F, d2, a2, b2, c2, X[ 6], 5, k9);
Subround(F, c2, d2, a2, b2, X[ 4], 8, k9);
Subround(F, b2, c2, d2, a2, X[ 1], 11, k9);
Subround(F, a2, b2, c2, d2, X[ 3], 14, k9);
Subround(F, d2, a2, b2, c2, X[11], 14, k9);
Subround(F, c2, d2, a2, b2, X[15], 6, k9);
Subround(F, b2, c2, d2, a2, X[ 0], 14, k9);
Subround(F, a2, b2, c2, d2, X[ 5], 6, k9);
Subround(F, d2, a2, b2, c2, X[12], 9, k9);
Subround(F, c2, d2, a2, b2, X[ 2], 12, k9);
Subround(F, b2, c2, d2, a2, X[13], 9, k9);
Subround(F, a2, b2, c2, d2, X[ 9], 12, k9);
Subround(F, d2, a2, b2, c2, X[ 7], 5, k9);
Subround(F, c2, d2, a2, b2, X[10], 15, k9);
Subround(F, b2, c2, d2, a2, X[14], 8, k9);
t = d1; d1 = d2; d2 = t;
digest[0] += a1;
digest[1] += b1;
digest[2] += c1;
digest[3] += d1;
digest[4] += a2;
digest[5] += b2;
digest[6] += c2;
digest[7] += d2;
}
NAMESPACE_END
/////////////////////////////////////////////////
// vnDev.Games - Trong.LIVE - DAO VAN TRONG //
////////////////////////////////////////////////////////////////////////////////
| [
"[email protected]"
] | |
fbc3e50e5ffb2665dbcd9f659cdd0de7db2f8295 | e2d56a14b669a3fe9eadd1c855323dc3e2e74f51 | /src-common/cpp/data/ByteSlice.h | de29cc88f12184fe61a8297d925234a3caef0a17 | [] | no_license | matteobertozzi/misc-common | 2d40d843692a76a34839b82076146639c9e35f6c | d02dca2403b8cddbdf5bb4c0b2a82201db170940 | refs/heads/master | 2021-01-23T11:49:22.957834 | 2014-12-08T10:49:32 | 2014-12-08T10:49:32 | 3,178,931 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,353 | h | /*
* Copyright 2012 Matteo Bertozzi
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef _BYTE_SLICE_H_
#define _BYTE_SLICE_H_
#include <stdint.h>
#include <stddef.h>
class Writable;
class ByteSlice {
public:
virtual size_t length (void) const = 0;
virtual int write (Writable *writable) const;
virtual uint8_t fetch8 (size_t index) const = 0;
virtual uint16_t fetch16 (size_t index) const;
virtual uint32_t fetch32 (size_t index) const;
virtual uint64_t fetch64 (size_t index) const;
virtual int compare (const ByteSlice *other) const;
uint8_t operator[] (size_t index) const { return(fetch8(index)); }
bool isEmpty (void) const { return(!length()); };
int compare (const ByteSlice& other) const { return(compare(&other)); }
bool equal (const ByteSlice& other) const { return(!compare(other)); }
bool equal (const ByteSlice *other) const { return(!compare(other)); }
};
inline bool operator==(const ByteSlice& a, const ByteSlice& b) {
return(a.equal(b));
}
inline bool operator!=(const ByteSlice& a, const ByteSlice& b) {
return(!a.equal(b));
}
inline uint16_t ByteSlice::fetch16 (size_t index) const {
uint16_t x;
uint8_t *p = (uint8_t *)&x;
index <<= 1;
p[0] = fetch8(index + 0);
p[1] = fetch8(index + 1);
return(x);
}
inline uint32_t ByteSlice::fetch32 (size_t index) const {
uint32_t x;
uint16_t *p = (uint16_t *)&x;
index <<= 1;
p[0] = fetch16(index + 0);
p[1] = fetch16(index + 1);
return(x);
}
inline uint64_t ByteSlice::fetch64 (size_t index) const {
uint64_t x;
uint32_t *p = (uint32_t *)&x;
index <<= 1;
p[0] = fetch32(index + 0);
p[1] = fetch32(index + 1);
return(x);
}
#endif /* !_BYTE_SLICE_H_ */
| [
"[email protected]"
] | |
b913f3180250c3542d2e21131200d7dec224152d | 6146e33102797407ede06ce2daa56c28fdfa2812 | /include/GafferScene/MeshNormals.h | fb16291caa72256c9cac1771cc9ae4ba4399048a | [
"BSD-3-Clause"
] | permissive | GafferHQ/gaffer | e1eb78ba8682bfbb7b17586d6e7b47988c3b7d64 | 59cab96598c59b90bee6d3fc1806492a5c03b4f1 | refs/heads/main | 2023-09-01T17:36:45.227956 | 2023-08-30T09:10:56 | 2023-08-30T09:10:56 | 9,043,124 | 707 | 144 | BSD-3-Clause | 2023-09-14T09:05:37 | 2013-03-27T00:04:53 | Python | UTF-8 | C++ | false | false | 3,258 | h | //////////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2023, Image Engine Design Inc. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above
// copyright notice, this list of conditions and the following
// disclaimer.
//
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following
// disclaimer in the documentation and/or other materials provided with
// the distribution.
//
// * Neither the name of John Haddon nor the names of
// any other contributors to this software may be used to endorse or
// promote products derived from this software without specific prior
// written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
//////////////////////////////////////////////////////////////////////////
#pragma once
#include "GafferScene/ObjectProcessor.h"
#include "Gaffer/StringPlug.h"
#include "Gaffer/TypedPlug.h"
namespace GafferScene
{
class GAFFERSCENE_API MeshNormals : public ObjectProcessor
{
public :
MeshNormals( const std::string &name=defaultName<MeshNormals>() );
~MeshNormals() override;
Gaffer::IntPlug *interpolationPlug();
const Gaffer::IntPlug *interpolationPlug() const;
Gaffer::IntPlug *weightingPlug();
const Gaffer::IntPlug *weightingPlug() const;
Gaffer::FloatPlug *thresholdAnglePlug();
const Gaffer::FloatPlug *thresholdAnglePlug() const;
Gaffer::StringPlug *positionPlug();
const Gaffer::StringPlug *positionPlug() const;
Gaffer::StringPlug *normalPlug();
const Gaffer::StringPlug *normalPlug() const;
GAFFER_NODE_DECLARE_TYPE( GafferScene::MeshNormals, MeshNormalsTypeId, ObjectProcessor );
protected :
bool affectsProcessedObject( const Gaffer::Plug *input ) const override;
void hashProcessedObject( const ScenePath &path, const Gaffer::Context *context, IECore::MurmurHash &h ) const override;
IECore::ConstObjectPtr computeProcessedObject( const ScenePath &path, const Gaffer::Context *context, const IECore::Object *inputObject ) const override;
private :
Gaffer::ValuePlug::CachePolicy processedObjectComputeCachePolicy() const final;
static size_t g_firstPlugIndex;
};
IE_CORE_DECLAREPTR( MeshNormals )
} // namespace GafferScene
| [
"[email protected]"
] | |
c787d9408e33fddec553d9d67c9e9f69e98063e3 | 7af9b68f00b590d2fd9e1b6049e3737d28fa2827 | /src/MotorDriver/MotorDriver.cpp | 742c44df3c8fe5e15e65fde37036d4b1ed4d3718 | [
"MIT"
] | permissive | derdoktor667/ESP32_FC | 36401efdd12cf4fa318397cf6ab9a93be34777c7 | 7c813d72b58a0e47c3348d95005e8af9228b56cd | refs/heads/main | 2023-06-26T13:55:18.637023 | 2021-08-03T21:40:21 | 2021-08-03T21:40:21 | 361,152,915 | 4 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,232 | cpp | //
// Name: MotorDriver.cpp
// Created: 19.07.2021 20:13:31
// Author: derdoktor667
//
#include "MotorDriver.h"
void set_motor_type(uint8_t _motor_number, motor_type_t _type) {
motor_type[_motor_number] = _type;
};
motor_type_t get_motor_type(uint8_t _motor_number) {
return motor_type[_motor_number];
};
void set_Signal_Rx_Type(rx_type_t _rx_type) {
rx_type = _rx_type;
};
rx_type_t get_Signal_Rx_Type() {
return rx_type;
};
void set_motor_signal(uint8_t _motor_Nr, uint16_t signal) {
auto throttle_input = 0;
if (Serial.available() > 0) {
SystemState = USB_MODE;
}
switch (SystemState) {
case RUNNING:
break;
case ERROR:
break;
case CONFIG:
break;
case USB_MODE:
if ((Serial.available() > 0) || (signal == 0)) {
throttle_input = (Serial.readStringUntil('\n')).toInt();
motor_throttle[_motor_Nr] = throttle_input;
}
break;
}
switch (motor_type[_motor_Nr]) {
case OFF:
break;
case PWM:
break;
case ONESHOT:
break;
case DSHOT:
break;
}
};
| [
"[email protected]"
] | |
9ee0838b45acc449c48fd45b3ac19481698671f1 | 6c119a3c755de1b26389be07204ac5b2fc8bb87e | /BinarySearch2/BinarySearch2.cpp | 10497c2cecf82629f62c90f333152e939d0bb9d4 | [] | no_license | Uli-art/BinarySearch | b367e26bc1bb0bc9f3099b40cc1f642a2d1776c1 | dd752c236c83bf6b30e2dc61c8e8119390f364c7 | refs/heads/master | 2023-09-06T02:56:20.508890 | 2021-11-23T22:54:49 | 2021-11-23T22:54:49 | 431,277,895 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,852 | cpp | // BinarySearch2.cpp : Этот файл содержит функцию "main". Здесь начинается и заканчивается выполнение программы.
//
#include <iostream>
#include <algorithm>
#include <vector>
bool Sorted(std::vector<int> array) {
for (int i = 1; i < array.size(); i++) {
if (array[i] < array[i - 1]) {
return false;
}
}
return true;
}
void Sort(std::vector<int>& array) {
for (int i = 0; i < array.size(); i++)
for (int j = i + 1; j < array.size(); j++) {
if (array[j] < array[i]) {
int temp = array[j];
array[j] = array[i];
array[i] = temp;
}
}
}
int BinarySearch(std::vector<int> array, int value) {
if (!Sorted(array))
Sort(array);
for (int i = 0; i < array.size(); i++) {
std::cout << array[i] << " ";
}
std::cout << std::endl;
int Left = 0;
int Right = array.size();
int Middle;
while (Left < Right) {
Middle = (Left + Right) / 2;
if (value >= array[Middle]) Left = Middle + 1;
else Right = Middle;
}
--Left;
if (Left < 0 || array[Left] != value) return -1;
return Left;
}
int main()
{
std::vector<int> a{ 10,2,0,14,43,25,18,1,5,45 };
std::cout << BinarySearch(a, 25) << std::endl;
std::vector<int> b{ 3, 6 , 13, 28, 54, 83, 97 };
std::cout << BinarySearch(b, 2) << std::endl;
}
// Запуск программы: CTRL+F5 или меню "Отладка" > "Запуск без отладки"
// Отладка программы: F5 или меню "Отладка" > "Запустить отладку"
// Советы по началу работы
// 1. В окне обозревателя решений можно добавлять файлы и управлять ими.
// 2. В окне Team Explorer можно подключиться к системе управления версиями.
// 3. В окне "Выходные данные" можно просматривать выходные данные сборки и другие сообщения.
// 4. В окне "Список ошибок" можно просматривать ошибки.
// 5. Последовательно выберите пункты меню "Проект" > "Добавить новый элемент", чтобы создать файлы кода, или "Проект" > "Добавить существующий элемент", чтобы добавить в проект существующие файлы кода.
// 6. Чтобы снова открыть этот проект позже, выберите пункты меню "Файл" > "Открыть" > "Проект" и выберите SLN-файл.
| [
"[email protected]"
] | |
b8e60fbee445bbe4f3bcf7283479c0bd31241020 | b33afecf2196a69f6cf354455b87a1eace57bf1b | /Product/SideProduct/KudaBakarTelur.cpp | cf0d9810f1cb96c68f9924fb01244ebfef5d9caf | [] | no_license | ferdysan360/ObjectOriented-Engis-Farm | d220178a61358e270aca273979b27f4378f9897a | 5b6a51b88d9a20347721020939da5e3b9ae81ffd | refs/heads/master | 2020-04-27T23:10:53.807291 | 2019-04-11T16:12:52 | 2019-04-11T16:12:52 | 174,765,633 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 114 | cpp | #include "KudaBakarTelur.hpp"
KudaBakarTelur::KudaBakarTelur() : SideProduct("Kuda Bakar Telur", 17, 25){} | [
"[email protected]"
] | |
2ca9711bca172ec65997819a26c4a1729a6ff6bb | f1d3015b7fddea05fb79d619e26acf5c9b31cdb1 | /UWP/Il2CppOutputProject/IL2CPP/libil2cpp/os/c-api/tests/MemoryMappedFileTests.cpp | 923c2bcf28d1c05c06605a5f2703a16bbf2d195f | [
"MIT"
] | permissive | rndmized/OkamiBushi | f33a3d3a44cd6b3481bdf124795d8af3dca09ada | 10ea681f9716d17aa605e0cbb764b7a4b63ae038 | refs/heads/master | 2021-08-24T12:56:52.840860 | 2017-12-10T00:00:08 | 2017-12-10T00:00:08 | 108,860,526 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 6,297 | cpp | #if ENABLE_UNIT_TESTS
#include "UnitTest++.h"
#include "../MemoryMappedFile-c-api.h"
#include "../../MemoryMappedFile.h"
#include "../../File.h"
#include "../File-c-api.h"
#include "PathHelper.h"
#if IL2CPP_TARGET_POSIX
#include <fcntl.h>
#include <unistd.h>
#endif
static const char* TEST_FILE_NAME = CURRENT_DIRECTORY("MEM_MAP_TEST_FILE");
static const char* TEST_STRING = "THIS IS A TEST\r\nSTRING TO \r\nBE USED IN A \r\nMEMORY MAPPED FILE\r\n";
class MapTestsWithParamsFixture
{
public:
MapTestsWithParamsFixture() : offset(0), length(7)
{
Initialize();
}
MapTestsWithParamsFixture(size_t offset_in, size_t length_in) : offset(offset_in), length(length_in)
{
Initialize();
}
~MapTestsWithParamsFixture()
{
il2cpp::os::MemoryMappedFile::Unmap(apiAddress, length);
il2cpp::os::MemoryMappedFile::Unmap(classAddress, length);
CloseTestFile(handle);
DeleteTestFile(handle);
handle = NULL;
}
il2cpp::os::FileHandle* handle;
void* apiAddress;
void* classAddress;
size_t length;
size_t offset;
private:
void Initialize()
{
handle = NULL;
handle = CreateTestFile();
WriteCharactersToTestFile(handle);
apiAddress = NULL;
classAddress = il2cpp::os::MemoryMappedFile::Map(handle, length, offset);
}
il2cpp::os::FileHandle* CreateTestFile()
{
int error;
il2cpp::os::FileHandle* handle = il2cpp::os::File::Open(TEST_FILE_NAME, kFileModeOpenOrCreate, kFileAccessReadWrite, kFileShareReadWrite, 0, &error);
return handle;
}
void WriteCharactersToTestFile(il2cpp::os::FileHandle* handle)
{
static const char* buffer = TEST_STRING;
int error;
il2cpp::os::File::Write(handle, buffer, (int)strlen(buffer), &error);
}
int CloseTestFile(il2cpp::os::FileHandle* handle)
{
int error;
il2cpp::os::File::Close(handle, &error);
return error;
}
int DeleteTestFile(il2cpp::os::FileHandle* handle)
{
int error;
il2cpp::os::File::DeleteFile(TEST_FILE_NAME, &error);
return error;
}
};
class MapTestsFixture : public MapTestsWithParamsFixture
{
public:
MapTestsFixture() : MapTestsWithParamsFixture(0, 0)
{
}
};
SUITE(MemoryMappedFile)
{
TEST_FIXTURE(MapTestsFixture, MapReturnsAValidPointer)
{
apiAddress = UnityPalMemoryMappedFileMap(handle);
CHECK_NOT_NULL(apiAddress);
}
TEST_FIXTURE(MapTestsFixture, MappedPointerHasMatchingCharactersAsFile)
{
apiAddress = UnityPalMemoryMappedFileMap(handle);
CHECK_EQUAL(0, strncmp("THIS", (const char*)apiAddress, 4));
}
TEST_FIXTURE(MapTestsFixture, MappedPointerHasMatchingSizeAsFile)
{
apiAddress = UnityPalMemoryMappedFileMap(handle);
CHECK_EQUAL(strlen(TEST_STRING), strlen((const char*)apiAddress));
}
TEST_FIXTURE(MapTestsFixture, ApiMapReturnsPointerThatDoesNotMatchClass)
{
apiAddress = UnityPalMemoryMappedFileMap(handle);
CHECK_NOT_EQUAL(apiAddress, classAddress);
}
TEST_FIXTURE(MapTestsFixture, ApiMappedPointerCharactersMatchClassMappedPointer)
{
apiAddress = UnityPalMemoryMappedFileMap(handle);
CHECK_EQUAL(strncmp("THIS", (const char*)classAddress, 4), strncmp("THIS", (const char*)apiAddress, 4));
}
TEST_FIXTURE(MapTestsFixture, ApiMappedLengthMatchesClassMatchedLength)
{
apiAddress = UnityPalMemoryMappedFileMap(handle);
CHECK_EQUAL(strlen((const char*)classAddress), strlen((const char*)apiAddress));
}
TEST_FIXTURE(MapTestsWithParamsFixture, MapWithParamsReturnsAValidPointer)
{
apiAddress = UnityPalMemoryMappedFileMapWithParams(handle, length, offset);
CHECK_NOT_NULL(apiAddress);
}
#if IL2CPP_TARGET_POSIX
TEST_FIXTURE(MapTestsWithParamsFixture, MapWithFileDescriptorReturnsAValidPointer)
{
int fd = open(TEST_FILE_NAME, O_RDONLY);
apiAddress = UnityPalMemoryMappedFileMapWithFileDescriptor(fd, length, offset);
CHECK_NOT_NULL(apiAddress);
close(fd);
}
TEST_FIXTURE(MapTestsWithParamsFixture, MappedWithFileDescriptorPointerHasMatchingCharactersAsFile)
{
int fd = open(TEST_FILE_NAME, O_RDONLY);
apiAddress = UnityPalMemoryMappedFileMapWithFileDescriptor(fd, length, offset);
CHECK_EQUAL(0, strncmp("THIS IS", (const char*)apiAddress, length));
close(fd);
}
TEST_FIXTURE(MapTestsWithParamsFixture, MappedWithFileDescriptorPointerHasMatchingSizeAsFile)
{
int fd = open(TEST_FILE_NAME, O_RDONLY);
apiAddress = UnityPalMemoryMappedFileMapWithFileDescriptor(fd, length, offset);
CHECK_EQUAL(strlen(TEST_STRING), strlen((const char*)apiAddress));
close(fd);
}
#endif
TEST_FIXTURE(MapTestsWithParamsFixture, MappedWithParamsPointerHasMatchingCharactersAsFile)
{
apiAddress = UnityPalMemoryMappedFileMapWithParams(handle, length, offset);
CHECK_EQUAL(0, strncmp("THIS IS", (const char*)apiAddress, length));
}
TEST_FIXTURE(MapTestsWithParamsFixture, MappedWithParamsPointerHasMatchingSizeAsFile)
{
apiAddress = UnityPalMemoryMappedFileMapWithParams(handle, length, offset);
CHECK_EQUAL(strlen(TEST_STRING), strlen((const char*)apiAddress));
}
TEST_FIXTURE(MapTestsWithParamsFixture, ApiMapWithParamsReturnsPointerThatDoesNotMatchClass)
{
apiAddress = UnityPalMemoryMappedFileMapWithParams(handle, length, offset);
CHECK_NOT_EQUAL(apiAddress, classAddress);
}
TEST_FIXTURE(MapTestsWithParamsFixture, ApiMappedWithParamsPointerCharactersMatchClassMappedPointer)
{
apiAddress = UnityPalMemoryMappedFileMapWithParams(handle, length, offset);
CHECK_EQUAL(strncmp("THIS IS", (const char*)classAddress, length), strncmp("THIS IS", (const char*)apiAddress, length));
}
TEST_FIXTURE(MapTestsWithParamsFixture, ApiMappedWithParamsLengthMatchesClassMatchedLength)
{
apiAddress = UnityPalMemoryMappedFileMapWithParams(handle, length, offset);
CHECK_EQUAL(strlen((const char*)classAddress), strlen((const char*)apiAddress));
}
}
#endif // ENABLE_UNIT_TESTS
| [
"[email protected]"
] | |
da6ab91732f23357025e56ef34cffcae845e9d78 | 45c59e5f456f11f1714b2ddf976b62dfebecfa7d | /Case10/0/cz_solid_34/k | c681ffb90b91b2e017b5e6b6d3b07273ae039164 | [] | no_license | JoelWright24/Masters-Thesis-in-OpenFOAM | 9224f71cdb38e96a378996996c5c86235db9ee13 | b6c420b5054494a26a7d65a34835b27be9e0da4a | refs/heads/main | 2023-02-20T17:18:13.067439 | 2021-01-22T19:30:36 | 2021-01-22T19:30:36 | 332,039,823 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 890 | /*--------------------------------*- C++ -*----------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Version: 6
\\/ M anipulation |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class volScalarField;
location "0/cz_solid_34";
object k;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensions [0 2 -2 0 0 0 0];
internalField uniform 6.51042;
boundaryField
{
cz_solid_34_to_fluid
{
type calculated;
value uniform 0;
}
}
// ************************************************************************* //
| [
"[email protected]"
] | ||
1f7c5ea73e14689f6ba77e9a7333718aeb904132 | a2a7706d59ab0d726f0ef0dd84d44531a8c87256 | /tests/madoka/time_tone.cpp | b7eabd4ae7a4d0c2526aed5001edd968318a3178 | [
"MIT"
] | permissive | cre-ne-jp/irclog2json | 485e21d087be4618ef30c05b724413733492ba59 | 721f9c6f247ae9d972dff8c1b3befa36bb1e062e | refs/heads/master | 2021-11-18T19:16:28.591033 | 2021-09-19T15:45:24 | 2021-09-19T15:45:24 | 204,485,550 | 0 | 0 | null | 2021-09-11T14:45:24 | 2019-08-26T13:49:23 | C++ | UTF-8 | C++ | false | false | 769 | cpp | #define _XOPEN_SOURCE
#include <doctest/doctest.h>
#include <ctime>
#include <picojson.h>
#include "message/madoka_line_parser.h"
#include "message/message_base.h"
#include "tests/test_helper.h"
TEST_CASE("Madoka time tone") {
using irclog2json::message::MadokaLineParser;
struct tm tm_date {};
strptime("2000-02-27", "%F", &tm_date);
MadokaLineParser parser{"kataribe", tm_date};
const auto m = parser.ToMessage("2000/02/07 03:00:00");
REQUIRE_FALSE(m);
}
TEST_CASE("Madoka time tone at EOF") {
using irclog2json::message::MadokaLineParser;
struct tm tm_date {};
strptime("2000-02-07", "%F", &tm_date);
MadokaLineParser parser{"kataribe", tm_date};
const auto m = parser.ToMessage("2000/02/08 00:00:00 end");
REQUIRE_FALSE(m);
}
| [
"[email protected]"
] | |
6962d1bf8f82d53bc0f52cd5c4e5fc8928cf5d0e | 9e444427f7833eb169ff7d8964b6a1d9e6cceb9c | /lab3/Source.cpp | b2c5298748c6bb77cf6a05a61af10785d03866cd | [] | no_license | GhostKicker/parallel_plus | 3229918d252e3dcb592d0c6edca0a2c7c6f9f5e2 | 23dcb69a5730171c00b3c1f35062a48a205c98a1 | refs/heads/master | 2020-03-10T13:59:18.120022 | 2018-06-01T21:37:05 | 2018-06-01T21:37:05 | 129,414,124 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,060 | cpp | #define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <algorithm>
#include <vector>
#include <omp.h>
#include <time.h>
using namespace std;
int n;
template <typename T>
inline void deb(T& a)
{
for (auto it : a)
cout << it << " ";
cout << endl;
}
template<typename T>
void q_sort_omp(vector<T>& arr, int left = 0, int right = n - 1)
{
if (left >= right) return;
int l = left;
int r = right;
T mid = arr[(rand() % (right - left + 1)) + left];
while (l <= r)
{
while (arr[l] < mid) l++;
while (arr[r] > mid) r--;
if (l <= r)
swap(arr[l++], arr[r--]);
}
if (right - left > 1000)
{
#pragma omp parallel sections
{
#pragma omp section
q_sort_omp(arr, left, r);
#pragma omp section
q_sort_omp(arr, l, right);
}
}
else
{
q_sort(arr, left, r);
q_sort(arr, l, right);
}
}
template<typename T>
void q_sort(vector<T>& arr, int left = 0, int right = n - 1)
{
if (left >= right) return;
int l = left;
int r = right;
T mid = arr[(rand() % (right - left + 1)) + left];
while (l <= r)
{
while (arr[l] < mid) l++;
while (arr[r] > mid) r--;
if (l <= r)
swap(arr[l++], arr[r--]);
}
q_sort(arr, left, r);
q_sort(arr, l, right);
}
template <typename T>
void mergesort_omp(vector<T>& arr, int l = 0, int r = n - 1)
{
if (r - l < 1)
{
return;
}
int mid = (l + r) / 2;
if (r - l > 10000)
{
#pragma omp parallel sections
{
#pragma omp section
mergesort_omp(arr, l, mid);
#pragma omp section
mergesort_omp(arr, mid + 1, r);
}
}
else
{
mergesort(arr, l, mid);
mergesort(arr, mid + 1, r);
}
auto b1 = arr.begin() + l;
auto e1 = arr.begin() + mid + 1;
auto b2 = arr.begin() + mid + 1;
auto e2 = arr.begin() + r + 1;
vector<int> temp(r - l + 1);
merge(b1, e1, b2, e2, temp.begin());
#pragma omp parallel for
for (int i = 0; i < temp.size(); ++i)
arr[l + i] = temp[i];
}
template <typename T>
void mergesort(vector<T>& arr, int l = 0, int r = n - 1)
{
if (r - l < 1)
{
return;
}
int mid = (l + r) / 2;
mergesort(arr, l, mid);
mergesort(arr, mid + 1, r);
auto b1 = arr.begin() + l;
auto e1 = arr.begin() + mid + 1;
auto b2 = arr.begin() + mid + 1;
auto e2 = arr.begin() + r + 1;
vector<int> temp(r - l + 1);
merge(b1, e1, b2, e2, temp.begin());
for (int i = 0; i < temp.size(); ++i)
arr[l + i] = temp[i];
}
int main()
{
clock_t cl1, cl2;
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
cin >> n;
vector<int> v(n);
omp_set_num_threads(100);
for (int i = 0; i < n; i++)
v[i] = rand();
//int cur = n;
//for (auto& it : v)
// it = cur--;
auto v1 = v;
auto v2 = v;
auto v3 = v;
auto v4 = v;
int time;
cl1 = clock();
q_sort_omp(v1);
cl2 = clock();
cout << "qsort: parallel: " << n
<< " elements in " << (cl2 - cl1) / double(CLOCKS_PER_SEC)
<< " seconds" << endl;
cl1 = clock();
q_sort(v2);
cl2 = clock();
cout << "qsort: ordinary: " << n
<< " elements in " << (cl2 - cl1) / double(CLOCKS_PER_SEC)
<< " seconds" << endl;
cl1 = clock();
mergesort_omp(v3);
cl2 = clock();
cout << "merge: parallel: " << n
<< " elements in " << (cl2 - cl1) / double(CLOCKS_PER_SEC)
<< " seconds" << endl;
cl1 = clock();
mergesort(v4);
cl2 = clock();
cout << "merge: ordinary: " << n
<< " elements in " << (cl2 - cl1) / double(CLOCKS_PER_SEC)
<< " seconds" << endl;
cout << v1[0] << " " << v1[v1.size() - 1] << endl;
cout << v2[0] << " " << v2[v1.size() - 1] << endl;
cout << v3[0] << " " << v3[v1.size() - 1] << endl;
cout << v4[0] << " " << v4[v1.size() - 1] << endl;
return 0;
}
| [
"[email protected]"
] | |
34061c1b1838365bac151e5e57d40fc7d0f60188 | df88c3e89e2edf1567f85e1e6b8253cf9cc468b8 | /src/Features/Fragmentation.cpp | 1653ec220958018dcac72823d3547e51fc1f8f37 | [] | no_license | YourFavoriteCode/DeformationModel2 | 215a2ee3acb2ddcbd95e6eaab2da8a445c17033e | 698e8a6679b0a5bd1309d7455c3fdf628d1147df | refs/heads/master | 2021-07-20T05:10:43.254763 | 2018-09-15T15:58:48 | 2018-09-15T15:58:48 | 143,641,105 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 448 | cpp | // This is an open source non-commercial project. Dear PVS-Studio, please check it.
// PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com
#include "stdafx.h"
#include "Fragmentation.h"
namespace model
{
void calcDislocationsPower()
{
}
void fragmentate(Grain* g)
{
// Вычисляем эволюцию мощности дисклинаций
for (int i = 0; i < g->disclinations.size(); i++)
{
}
}
} | [
"admin@DESKTOP-AQOPG8K"
] | admin@DESKTOP-AQOPG8K |
b2130c5c253004af189adcfcd0b181cd399f3e72 | f4c1902534825c7b97a9392e78b148345a011147 | /CodeForces/gym100989/J.cpp | dec2e54d6f5bc85a82931868c0534a3ecc13b53f | [] | no_license | obsolescenceL/obsolescenceL | 6443fbfc88f5286007800b809839ef3b663b6ce0 | 096f50469beb0c98b71b828d185b685d071177ed | refs/heads/master | 2020-04-04T00:15:43.241792 | 2017-06-10T05:24:38 | 2017-06-10T05:24:38 | 28,584,497 | 3 | 2 | null | 2017-06-10T05:24:39 | 2014-12-29T07:41:23 | C++ | UTF-8 | C++ | false | false | 1,216 | cpp | /*************************************************************************
File Name: J.cpp
ID: obsoles1
PROG:
LANG: C++
Mail: [email protected]
Created Time: 2016年07月18日 星期一 12时57分04秒
************************************************************************/
#include<bits/stdc++.h>
#define Max(x,y) ((x)>(y)?(x):(y))
#define Min(x,y) ((x)<(y)?(x):(y))
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();++it)
#define Abs(x,y) ((x)>(y)?((x)-(y)):((y)-(x)))
#define ll long long
#define Mem0(x) memset(x,0,sizeof(x))
#define Mem1(x) memset(x,-1,sizeof(x))
#define MemX(x) memset(x,0x3f,sizeof(x))
#define pb push_back
using namespace std;
const int N=110;
int k[N],mp[N][N],n;
char op[N][2];
void Print(int ch,int d){
int i;
for(i=0;i<d;++i)printf(" ");
if(k[ch])printf("%s ",op[ch]);
else printf(" ");
if(ch)printf("object%d\n",ch);
else puts("project");
if(op[ch][0]=='-'){
for(i=0;i<k[ch];++i)
Print(mp[ch][i],d+1);
}
}
int main(){
int i,j;
while(~scanf("%d",&n)){
for(i=0;i<=n;++i){
scanf("%s%d",op[i],&k[i]);
for(j=0;j<k[i];++j)
scanf("%d",&mp[i][j]);
}
Print(0,0);
}
}
| [
"[email protected]"
] | |
1113f2a4526e23cdba0656648e4d74e3b50de760 | d1819186ad148fa0f16f306b92172b8999c64cf7 | /smartutente.cpp | abddb13c8f0d270838500356c660f3caef6860c7 | [] | no_license | redalbert93/VirusLab | 056dc4070cc8f92fb531ee0c7c676a807672fbca | 46fe2a27d0a3db389ff7151a7571e9d66073b943 | refs/heads/master | 2021-01-20T12:37:46.004526 | 2017-02-21T10:18:31 | 2017-02-21T10:18:31 | 82,665,372 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,198 | cpp | #include "smartutente.h"
SmartUtente::SmartUtente(utente* p):punt(p){
if (punt) {
punt->riferimenti++;
}
}
utente* SmartUtente::getUtente() const{
return punt;
}
SmartUtente::SmartUtente(const SmartUtente& s) : punt(s.punt) {
if (punt) {
punt->riferimenti++;
}
}
SmartUtente::SmartUtente::~SmartUtente() {
if (punt) {
punt->riferimenti--;
if (punt->riferimenti == 0) {
delete punt;
}
}
}
SmartUtente& SmartUtente::SmartUtente::operator=(const SmartUtente& s) {
if (this != &s) {
utente* t = punt;
punt = s.punt;
if (punt) {
punt->riferimenti++;
}
if (t) {
t->riferimenti--;
if (t->riferimenti == 0) {
delete t;
}
}
}
return *this;
}
utente& SmartUtente::SmartUtente::operator*() const {
return *punt;
}
utente* SmartUtente::SmartUtente::operator->() const {
return punt;
}
bool SmartUtente::SmartUtente::operator==(const SmartUtente& s) const {
return punt == s.punt;
}
bool SmartUtente::SmartUtente::operator!=(const SmartUtente& s) const {
return punt != s.punt;
}
| [
"[email protected]"
] | |
df606b3e406fcd7bbd2184654c008de318295e95 | d1192b3941633d635eba90c0598b4736fcd23672 | /Smol Up/src/Render/RenderUtil.cpp | 2ad94a2dfa40bbafa4c0b20b3eeacbf1fa2a2c01 | [] | no_license | jinzokami/smol-engine | fe6827a53268d13fd7fafa9f356bb87c9566772d | 2d43b7bbb0ab1ea3079f89732959c1805bde503c | refs/heads/master | 2021-07-10T08:59:04.638359 | 2020-07-16T04:12:45 | 2020-07-16T04:12:45 | 166,580,188 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,698 | cpp |
#include "RenderUtil.hpp"
void parse_obj(const char* filename, std::vector<Vert> &buffer, bool &has_uv, bool &has_normal)
{
//if any features are missing, fill them with dummy values, the shader should ignore the dummy values, wasteful improve this.
std::vector<Vec3> verts;
std::vector<Vec2> uvs;
std::vector<Vec3> normals;
std::vector<Face> faces;
bool tex_present = true;
bool norm_present = true;
FILE * file = NULL;
fopen_s(&file, filename, "r");
if (file == NULL)
{
printf("Error: Model \"%s\" not loaded, doesn't exist.\n", filename);
return;
}
while (!feof(file))
{
char token[3];
fscanf_s(file, "%s", token, (unsigned int)sizeof(token));
if (strcmp(token, "v") == 0)
{
Vec3 vert;
fscanf_s(file, "%f %f %f", &vert.x, &vert.y, &vert.z);
verts.push_back(vert);
}
else if (strcmp(token, "vt") == 0)
{
Vec2 uv;
fscanf_s(file, "%f %f", &uv.x, &uv.y);
uvs.push_back(uv);
}
else if (strcmp(token, "vn") == 0)
{
Vec3 normal;
fscanf_s(file, "%f %f %f", &normal.x, &normal.y, &normal.z);
normals.push_back(normal);
}
else if (strcmp(token, "f") == 0)
{
//means tokens 2, 3, and 4 are v/vt/vn v/vt/vn v/vt/vn
Face face;
int matched;
char f[3][256];
fscanf_s(file, "%s %s %s", f[0], (unsigned int)sizeof(f[0]), f[1], (unsigned int)sizeof(f[1]), f[2], (unsigned int)sizeof(f[2]));
for (int i = 0; i < 3; i++)
{
//detect missing features
int match = sscanf_s(f[i], "%d/%d/%d", &face.vert[i], &face.uv[i], &face.normal[i]);
if (match != 3)
{
match = sscanf_s(f[i], "%d//%d", &face.vert[i], &face.normal[i]);
if (match != 2)
{
match = sscanf_s(f[i], "%d/%d", &face.vert[i], &face.uv[i]);
if (match != 2)
{
match = sscanf_s(f[i], "%d", &face.vert[i]);
//missing normal and uv
face.uv[i] = 0;
face.normal[i] = 0;
tex_present = false;
norm_present = false;
}
else
{
//missing normal
face.normal[i] = 0;
norm_present = false;
}
}
else
{
//missing uv
face.uv[i] = 0;
tex_present = false;
}
}
}
//obj files count from 1 here we move down to 0
face.vert[0]--; face.vert[1]--; face.vert[2]--;
face.uv[0]--; face.uv[1]--; face.uv[2]--;
face.normal[0]--; face.normal[1]--; face.normal[2]--;
faces.push_back(face);
}
//advance to the next line. maybe. TODO: guarantee advancement to the next line.
char dec_buf[256];
fgets(dec_buf, 256, file);
}
for (int i = 0; i < faces.size(); i++)
{
for (int j = 0; j < 3; j++) //that hardcoded 3 could be however many vertices in the "face" if we ever support n-gons or quads
{
Vert vertex;
if (tex_present && norm_present)
{
vertex = {
{verts[faces[i].vert[j]].x, verts[faces[i].vert[j]].y, verts[faces[i].vert[j]].z},
{uvs[faces[i].uv[j]].x, uvs[faces[i].uv[j]].y},
{normals[faces[i].normal[j]].x, normals[faces[i].normal[j]].y, normals[faces[i].normal[j]].z}
};
}
else if (tex_present)
{
vertex = {
{verts[faces[i].vert[j]].x, verts[faces[i].vert[j]].y, verts[faces[i].vert[j]].z},
{uvs[faces[i].uv[j]].x, uvs[faces[i].uv[j]].y},
{0, 0, 0}
};
}
else if (norm_present)
{
vertex = {
{verts[faces[i].vert[j]].x, verts[faces[i].vert[j]].y, verts[faces[i].vert[j]].z},
{0, 0},
{normals[faces[i].normal[j]].x, normals[faces[i].normal[j]].y, normals[faces[i].normal[j]].z}
};
}
else
{
vertex = {
{verts[faces[i].vert[j]].x, verts[faces[i].vert[j]].y, verts[faces[i].vert[j]].z},
{0, 0},
{0, 0, 0}
};
}
buffer.push_back(vertex);
}
}
} | [
"[email protected]"
] | |
8612ab5d0f43b7d51c450b33ed49e9f3abfb8517 | d16c894e0740abcd1e17032e389e170eedfbcff8 | /material.h | 8bbd6c080ce64687f27e2f6c3b686b16db1b6a14 | [] | no_license | lenixlobo/YaPT | 61f93bc1e082b8140eed2c961d5007fa3081d353 | 26350bc346c881fe81eb80324f7810c30c7441d1 | refs/heads/master | 2020-12-01T18:36:25.808318 | 2020-01-20T16:37:25 | 2020-01-20T16:37:25 | 230,730,180 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,875 | h | #pragma once
#include "ray.h"
#include "vec3.h"
vec3 reflect(const vec3& v, const vec3& n) {
//reflected ray is v + 2B
//B=dot(v,n)
//since v is in opposite dir, use -ve
return v - 2 * dot(v, n) * n;
};
//TODO: add refraction
bool refract(const vec3& v,const vec3& n, float ni_over_nt, vec3& refracted) {
vec3 uv = unit_vector(v);
float dt = dot(uv,n);
float discriminant = 1.0 - ni_over_nt*ni_over_nt*(1-dt*dt);
if (discriminant > 0) {
//update refracted
refracted = ni_over_nt*(uv-n*dt) - n*sqrt(discriminant);
return true;
}
else {
return false;
}
}
//polynomial approximation by Christophe Schlick
float schlick(float cosine, float red_idx) {
float r0 = (1-red_idx)/(1+red_idx);
r0 = r0 * r0;
return r0 + (1 - r0) * pow((1 - cosine), 5);
}
class material {
public:
virtual bool scatter(const ray& r_in ,const hit_record& rec, vec3& attenuation, ray& scattered) const = 0;
};
class lambertian : public material {
public:
lambertian(const vec3& a): albedo(a) {};
bool scatter(const ray& r_in, const hit_record& rec, vec3& attenuation, ray& scattered) const {
//TODO: Add Scatter for Lamberetain SHading Model
// I = cos(theta) = unit(globalizednormal)*unit(lightdirection);
vec3 target = rec.p + rec.normal + random_in_unit_sphere();
scattered = ray(rec.p, target-rec.p);
attenuation = albedo;
return true;
}
vec3 albedo;
};
class metal : public material {
public:
metal(const vec3 a,float f) : albedo(a) {
if (f < 1) fuzz = f; else fuzz = 1;
};
bool scatter(const ray& r_in, const hit_record& rec, vec3& attenuation, ray& scattered) const{
vec3 reflected = reflect(unit_vector(r_in.direction()) , rec.normal);
scattered = ray(rec.p,reflected);
attenuation = albedo;
return (dot( scattered.direction() ,rec.normal)>0);
}
vec3 albedo;
float fuzz;
};
class dielectric : public material {
public:
dielectric(float x) : ref_idx(x) {};
bool scatter(const ray& r_in, const hit_record& rec, vec3& attenuation, ray& scattered) const {
vec3 outward_normal;
vec3 reflected = reflect(r_in.direction(),rec.normal);
float ni_over_nt;
attenuation = vec3(1.0,1.0,1.0);
vec3 refracted;
float reflect_prob;
float cosine;
if (dot(r_in.direction(), rec.normal) > 0) {
outward_normal = -rec.normal;
ni_over_nt = ref_idx;
cosine = ref_idx*dot(r_in.direction(),rec.normal)/r_in.direction().length();
}
else {
outward_normal = rec.normal;
ni_over_nt = 1.0/ref_idx;
cosine = -dot(r_in.direction(), rec.normal) / r_in.direction().length();
}
if (refract(r_in.direction(),outward_normal,ni_over_nt,refracted)) {
reflect_prob = schlick(cosine,ref_idx);
}
else {
reflect_prob = 1.0;
}
if (random_double() < reflect_prob) {
scattered = ray(rec.p, reflected);
}
else {
scattered = ray(rec.p, refracted);
}
return true;
}
float ref_idx;//refractive index
}; | [
"[email protected]"
] | |
651eed543bf6725031ad75c3cf5715c2667d5c61 | 61a986a372e064fb3b5a57946f915b254250a099 | /BreakpadDemo/libbreakpad/src/main/cpp/native-lib.cpp | fb07e97ebaa97b31dc0e118e8ad377210a711aa6 | [] | no_license | sunnybird/AdvanAndroid | eb1536670156897705ce5c41f5128ed78a0d0102 | 591e12550c3935386e8f809a7da00c8c905f5459 | refs/heads/master | 2020-04-09T08:26:53.057860 | 2018-12-03T14:40:11 | 2018-12-03T14:40:11 | 160,194,461 | 3 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 1,045 | cpp | #include <jni.h>
#include <string>
#include <android/log.h>
#include "client/linux/handler/exception_handler.h"
#include "client/linux/handler/minidump_descriptor.h"
#define TAG "breakpad"
#define LOGD(...) __android_log_print(ANDROID_LOG_DEBUG, TAG, __VA_ARGS__)
bool DumpCallback(const google_breakpad::MinidumpDescriptor& descriptor,
void* context, bool succeeded) {
LOGD("Dump path: %s\n", descriptor.path());
return succeeded;
}
extern "C"
JNIEXPORT void JNICALL
Java_com_example_libbreakpad_BreakPadManager_initBrakPad(JNIEnv *env, jobject instance, jstring path_) {
const char *path = env->GetStringUTFChars(path_, 0);
google_breakpad::MinidumpDescriptor descriptor(path);
static google_breakpad::ExceptionHandler eh(descriptor, NULL, DumpCallback, NULL, true, -1);
env->ReleaseStringUTFChars(path_, path);
}
extern "C"
JNIEXPORT void JNICALL
Java_com_example_libbreakpad_BreakPadManager_testBreak(JNIEnv *env, jobject instance) {
volatile int* a = reinterpret_cast<volatile int*>(NULL);
*a = 1;
}
| [
"[email protected]"
] | |
e7256dfb557d0c44de31fe566a9dcbaee3bc93b7 | 989fbdb229e8d8f93de4dd2e784c520ca837dd15 | /src/base/Pair.cpp | 0b79f2cf7d334494db52059b079bc92770874e86 | [] | no_license | gehldp/OpenEaagles | 3ed7f37d91499067a64dae8fa5826a1e8e47d1f0 | 3f7964d007278792d5f7ac3645b3cd32c11008e3 | refs/heads/master | 2021-01-15T15:58:14.038678 | 2017-08-10T02:35:03 | 2017-08-10T02:35:03 | 2,516,276 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,262 | cpp |
#include "openeaagles/base/Pair.hpp"
#include "openeaagles/base/Integer.hpp"
#include "openeaagles/base/Float.hpp"
#include "openeaagles/base/Boolean.hpp"
#include "openeaagles/base/String.hpp"
namespace oe {
namespace base {
IMPLEMENT_SUBCLASS(Pair, "Pair")
EMPTY_SLOTTABLE(Pair)
Pair::Pair(const char* slot, Object* object)
{
STANDARD_CONSTRUCTOR()
// Set the slot name (already ref() in 'new' constructor)
slotname = new Identifier(slot);
// Set the object & ref()
if (object != nullptr) {
obj = object;
obj->ref();
}
}
void Pair::copyData(const Pair& pair1, const bool)
{
BaseClass::copyData(pair1);
// unref() any old data
if (slotname != nullptr) {
slotname->unref();
}
if (obj != nullptr) {
obj->unref();
}
// Copy slotname (already ref() by constructor in clone())
if (pair1.slotname != nullptr) {
slotname = static_cast<Identifier*>(pair1.slotname->clone());
}
else {
slotname = nullptr;
}
// Copy the object (already ref() by constructor in clone())
if (pair1.obj != nullptr) {
obj = pair1.obj->clone();
}
else {
obj = nullptr;
}
}
void Pair::deleteData()
{
if (slotname != nullptr) slotname->unref();
slotname = nullptr;
if (obj != nullptr) obj->unref();
obj = nullptr;
}
//------------------------------------------------------------------------------
// isValid() -- is this a valid Pair
//------------------------------------------------------------------------------
bool Pair::isValid() const
{
if (!Object::isValid()) return false;
if (slotname == nullptr || obj == nullptr) return false;
return slotname->isValid() && obj->isValid();
}
std::ostream& Pair::serialize(std::ostream& sout, const int indent, const bool) const
{
if (slot() != nullptr && !slot()->isEmpty()) {
sout << slot()->getString();
}
else {
sout << "<null>";
}
sout << ": ";
//sout << endl;
const Object* obj = object();
if (obj != nullptr) {
obj->serialize(sout,indent);
}
else sout << "<null>";
sout << std::endl;
return sout;
}
}
}
| [
"[email protected]"
] | |
15020c9996d909bba8dc832e3bb7ad93724759e2 | 4ab8f8e888600df75c41eb1f0173471a29e1df63 | /CharBonus.h | 480c3fed67955e5dfad1552480f7c708d7a09ffa | [] | no_license | Emma1718/Literaki | 90a681939d48407202423489b9dd6ff79ed84a07 | d17766bd7cd925b53d254a7c99fc78aa9a384337 | refs/heads/master | 2016-09-05T11:51:14.686320 | 2012-11-28T19:52:06 | 2012-11-28T19:52:06 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 413 | h | #ifndef CHARBONUS_H
#define CHARBONUS_H
#include "Field.h"
class CharBonus : public Field {
protected:
int which_char;
int multiplier; // Operations
public:
CharBonus(Map *, int, int, int, int);
CharBonus(const CharBonus &);
~CharBonus();
int calculate (int *);
GtkWidget *draw(Gtk *);
void looseBonus();
void backToStandart();
void changeButton();
void copyData(Field &);
};
#endif
| [
"[email protected]"
] | |
4c1b38ab715f0ec69d8b29cd06f06932705bad51 | cc3198013ee01bcf0363393dc65ba70ef66f8e48 | /trunk/mamep/src/emu/bus/c64/music64.h | b9e270e038d4a4a06090f08ad46726319f39a28d | [] | no_license | svn2github/mameplus | 9188a20f6cec8223478288429a631c8d8f75dead | 2e7d741ede3bf495c04a399a77e9d36d088315d5 | refs/heads/master | 2020-12-24T15:14:08.317156 | 2015-01-10T14:10:50 | 2015-01-10T14:10:50 | 11,351,283 | 9 | 14 | null | null | null | null | UTF-8 | C++ | false | false | 2,021 | h | // license:BSD-3-Clause
// copyright-holders:Curt Coder
/**********************************************************************
Wersi Wersiboard Music 64 / Siel CMK 49 Keyboard emulation
Copyright MESS Team.
Visit http://mamedev.org for licensing and usage restrictions.
**********************************************************************/
#pragma once
#ifndef __MUSIC64__
#define __MUSIC64__
#include "emu.h"
#include "exp.h"
//**************************************************************************
// TYPE DEFINITIONS
//**************************************************************************
// ======================> c64_music64_cartridge_device
class c64_music64_cartridge_device : public device_t,
public device_c64_expansion_card_interface
{
public:
// construction/destruction
c64_music64_cartridge_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
// optional information overrides
virtual machine_config_constructor device_mconfig_additions() const;
virtual ioport_constructor device_input_ports() const;
protected:
// device-level overrides
virtual void device_start();
virtual void device_reset();
// device_c64_expansion_card_interface overrides
virtual UINT8 c64_cd_r(address_space &space, offs_t offset, UINT8 data, int sphi2, int ba, int roml, int romh, int io1, int io2);
virtual void c64_cd_w(address_space &space, offs_t offset, UINT8 data, int sphi2, int ba, int roml, int romh, int io1, int io2);
virtual int c64_game_r(offs_t offset, int sphi2, int ba, int rw);
virtual int c64_exrom_r(offs_t offset, int sphi2, int ba, int rw);
private:
required_device<c64_expansion_slot_device> m_exp;
required_ioport m_kb0;
required_ioport m_kb1;
required_ioport m_kb2;
required_ioport m_kb3;
required_ioport m_kb4;
required_ioport m_kb5;
required_ioport m_kb6;
};
// device type definition
extern const device_type C64_MUSIC64;
#endif
| [
"yuifan@e0215e0a-1e64-f442-9f1d-d2f61a7f4648"
] | yuifan@e0215e0a-1e64-f442-9f1d-d2f61a7f4648 |
ea54512828a244cc3781fd300c545ceb166d1c31 | 39568e19301a7a112398be542154950af25591de | /hw/ip/kmac/dv/dpi/vendor/kerukuro_digestpp/algorithm/detail/constants/md5_constants.hpp | 0a9d3d1cdc6615d4e12fec6ffff8d2011055223b | [
"Unlicense",
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | lowRISC/opentitan | 493995bc7cf7cb3aee486a5203af3fd62bba3bfc | 51f6017b8425b14d5a4aa9abace8fe5a25ef08c8 | refs/heads/master | 2023-08-31T22:05:09.425796 | 2023-08-14T14:52:15 | 2023-08-31T20:31:13 | 204,516,692 | 2,077 | 634 | Apache-2.0 | 2023-09-14T21:16:21 | 2019-08-26T16:30:16 | SystemVerilog | UTF-8 | C++ | false | false | 1,526 | hpp | /*
This code is written by kerukuro and released into public domain.
*/
#ifndef DIGESTPP_PROVIDERS_MD5_CONSTANTS_HPP
#define DIGESTPP_PROVIDERS_MD5_CONSTANTS_HPP
namespace digestpp
{
namespace detail
{
template<typename T>
struct md5_constants
{
const static uint32_t K[64];
const static unsigned char S[64];
};
template<typename T>
const uint32_t md5_constants<T>::K[64] = {
0xd76aa478, 0xe8c7b756, 0x242070db, 0xc1bdceee, 0xf57c0faf, 0x4787c62a, 0xa8304613, 0xfd469501,
0x698098d8, 0x8b44f7af, 0xffff5bb1, 0x895cd7be, 0x6b901122, 0xfd987193, 0xa679438e, 0x49b40821,
0xf61e2562, 0xc040b340, 0x265e5a51, 0xe9b6c7aa, 0xd62f105d, 0x02441453, 0xd8a1e681, 0xe7d3fbc8,
0x21e1cde6, 0xc33707d6, 0xf4d50d87, 0x455a14ed, 0xa9e3e905, 0xfcefa3f8, 0x676f02d9, 0x8d2a4c8a,
0xfffa3942, 0x8771f681, 0x6d9d6122, 0xfde5380c, 0xa4beea44, 0x4bdecfa9, 0xf6bb4b60, 0xbebfbc70,
0x289b7ec6, 0xeaa127fa, 0xd4ef3085, 0x04881d05, 0xd9d4d039, 0xe6db99e5, 0x1fa27cf8, 0xc4ac5665,
0xf4292244, 0x432aff97, 0xab9423a7, 0xfc93a039, 0x655b59c3, 0x8f0ccc92, 0xffeff47d, 0x85845dd1,
0x6fa87e4f, 0xfe2ce6e0, 0xa3014314, 0x4e0811a1, 0xf7537e82, 0xbd3af235, 0x2ad7d2bb, 0xeb86d391
};
template<typename T>
const unsigned char md5_constants<T>::S[64] = {
7, 12, 17, 22, 7, 12, 17, 22, 7, 12, 17, 22, 7, 12, 17, 22, 5, 9, 14, 20, 5, 9, 14, 20, 5, 9, 14, 20, 5, 9, 14, 20, 4,
11, 16, 23, 4, 11, 16, 23, 4, 11, 16, 23, 4, 11, 16, 23, 6, 10, 15, 21, 6, 10, 15, 21, 6, 10, 15, 21, 6, 10, 15, 21
};
} // namespace detail
} // namespace digestpp
#endif | [
"[email protected]"
] | |
df158f77aeede3fa5cdf05aed5079dc45ef35db3 | 83f40f62daca1c0af9f0e6174b30c74b3bc93ab8 | /MapMiddleware/Src/Ui/MapTool.cpp | 41af15991b87ec48a005476b315bc45132e6c7ea | [] | no_license | deverwh/MapMiddleware | 1f7347490a071a09d8615995f8886bd5a43b633c | aa84a93fd76a7a520bb4ce41afc4598f44ebd901 | refs/heads/master | 2020-12-03T04:27:59.260139 | 2020-03-25T14:33:18 | 2020-03-25T14:33:18 | 231,199,759 | 2 | 2 | null | null | null | null | UTF-8 | C++ | false | false | 2,132 | cpp | #include "MapTool.h"
#include "ui_MapTool.h"
#include "AbstractMapHandle.h"
#include <QPushButton>
MapTool::MapTool(AbstractMapHandle *mapHandle /* = Q_NULLPTR */)
: m_mapHandle(mapHandle)
{
ui = new Ui::MapTool();
ui->setupUi(this);
this->setWindowFlags(Qt::Tool | Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint);
this->setAttribute(Qt::WA_TranslucentBackground, true);
ui->arrowPushButton->setStyleSheet("border-image:url(:/images/btn_hover.png);");
connect(m_mapHandle, &AbstractMapHandle::mapStateChanged, this, [&](MapHandleState::State state)
{
switch (state)
{
case MapHandleState::Arrow:
on_buttonGroup_buttonClicked(ui->arrowPushButton);
break;
case MapHandleState::Roaming:
on_buttonGroup_buttonClicked(ui->roamingPushButton);
break;
case MapHandleState::ZoomIn:
on_buttonGroup_buttonClicked(ui->zoomInPushButton);
break;
case MapHandleState::ZoonOut:
on_buttonGroup_buttonClicked(ui->zoomOutPushButton);
break;
default:
break;
}
});
}
MapTool::~MapTool()
{
delete ui;
}
void MapTool::on_arrowPushButton_clicked()
{
m_mapHandle->setMapState(MapHandleState::Arrow);
}
void MapTool::on_roamingPushButton_clicked()
{
m_mapHandle->setMapState(MapHandleState::Roaming);
}
void MapTool::on_zoomInPushButton_clicked()
{
m_mapHandle->setMapState(MapHandleState::ZoomIn);
m_mapHandle->zoomIn();
}
void MapTool::on_zoomOutPushButton_clicked()
{
m_mapHandle->setMapState(MapHandleState::ZoonOut);
m_mapHandle->zoomOut();
}
void MapTool::on_buttonGroup_buttonClicked(QAbstractButton * button)
{
button->setStyleSheet("border-image:url(:/images/btn_hover.png);");
for (auto b : ui->buttonGroup->buttons())
{
if (b != button)
{
b->setStyleSheet("border-image:url(:/images/btn_normal.png);");
}
}
}
void MapTool::on_gridPushButton_clicked()
{
if (m_isShowGrid)
{
m_mapHandle->setGridHidden(true);
ui->gridPushButton->setStyleSheet("border-image:url(:/images/btn_normal.png);");
}
else
{
m_mapHandle->setGridHidden(false);
ui->gridPushButton->setStyleSheet("border-image:url(:/images/btn_hover.png);");
}
m_isShowGrid = !m_isShowGrid;
} | [
"[email protected]"
] | |
507d73ebd93cc2f16e2aea6bd103e5e22c5b4287 | 746bbef0f5ab866864ce47f57fb31220816a91d7 | /common/sci_i2c_io.hpp | 76986c5867e7f689ddd959d3db4b1a5680e82d6b | [
"MIT",
"BSD-3-Clause",
"LicenseRef-scancode-free-unknown"
] | permissive | hirakuni45/RX | baf64286b70132eb41db7ed52c6a2f9b70cf0f45 | 679878b98d0c03597e16431e87e75a9a24f5c8d1 | refs/heads/master | 2023-05-04T13:27:26.894545 | 2023-04-18T13:54:06 | 2023-04-18T13:54:06 | 14,785,870 | 65 | 19 | BSD-3-Clause | 2023-09-14T01:41:49 | 2013-11-28T20:27:58 | C++ | UTF-8 | C++ | false | false | 17,159 | hpp | #pragma once
//=========================================================================//
/*! @file
@brief RX グループ SCI 簡易 I2C 制御 @n
※RX600 シリーズでは、グループ割り込みとして TEIx を共有する @n
ので、割り込みレベルには注意する事(上書きされる)@n
※現在、マスターモードのみ実装
@author 平松邦仁 ([email protected])
@copyright Copyright (C) 2018, 2022 Kunihito Hiramatsu @n
Released under the MIT license @n
https://github.com/hirakuni45/RX/blob/master/LICENSE
*/
//=========================================================================//
#include "common/renesas.hpp"
#include "common/fixed_fifo.hpp"
#include "common/vect.h"
#include "common/i2c_base.hpp"
namespace device {
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++//
/*!
@brief SCI/I2C 構造体
*/
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++//
struct sci_i2c_t {
enum class TASK : uint8_t {
IDLE,
START_SEND, // start send
SEND_FIRST, // send 1st
SEND_DATA, // send data
STOP_SEND, // stop condition
START_RECV, // start recv
RECV_DATA_PRE, // recv data pre (first 1)
RECV_DATA, // recv data
STOP_RECV, // stop for recv
};
uint8_t adr_;
uint8_t* dst_;
uint16_t len_;
i2c_base::FUNC_TYPE func_;
sci_i2c_t(uint8_t adr = 0) noexcept : adr_(adr), dst_(nullptr), len_(0), func_(nullptr)
{ }
};
// I2C の最大コマンド受付数は(16-1)個
typedef utils::fixed_fifo<sci_i2c_t, 16> I2C_BUFF;
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++//
/*!
@brief SCI I2C I/O 制御クラス
@param[in] SCI SCI 型
@param[in] RBF 受信バッファクラス
@param[in] SBF 送信バッファクラス
@param[in] PSEL ポート選択
*/
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++//
template <class SCI, class RBF, class SBF, port_map::ORDER PSEL = port_map::ORDER::FIRST>
class sci_i2c_io : public i2c_base {
public:
private:
static RBF recv_;
static SBF send_;
ICU::LEVEL level_;
ERROR error_;
uint16_t i2c_loop_;
static volatile sci_i2c_t::TASK task_;
static volatile uint8_t state_;
static I2C_BUFF i2c_buff_;
// ※マルチタスクの場合適切な実装をする
void sleep_() noexcept { asm("nop"); }
void Print(sci_i2c_t::TASK task) const
{
switch(task) {
case sci_i2c_t::TASK::IDLE:
utils::format("IDLE");
break;
case sci_i2c_t::TASK::START_SEND:
utils::format("START_SEND 0b%07b, (%d)")
% static_cast<uint16_t>(i2c_buff_.get_at().adr_) % send_.length();
break;
case sci_i2c_t::TASK::SEND_DATA:
utils::format("SEND_DATA (%d)") % send_.length();
break;
case sci_i2c_t::TASK::START_RECV:
utils::format("START_RECV 0b%07b, (%d)")
% static_cast<uint16_t>(i2c_buff_.get_at().adr_) % recv_.length();
break;
case sci_i2c_t::TASK::RECV_DATA_PRE:
utils::format("RECV_DATA_PRE");
break;
case sci_i2c_t::TASK::RECV_DATA:
utils::format("RECV_DATA");
break;
case sci_i2c_t::TASK::STOP_RECV:
utils::format("STOP_RECV");
break;
case sci_i2c_t::TASK::STOP_SEND:
utils::format("STOP_SEND");
break;
default:
break;
}
utils::format("\n");
}
static void i2c_service_()
{
const auto& t = i2c_buff_.get_at();
switch(task_) {
case sci_i2c_t::TASK::IDLE:
break;
case sci_i2c_t::TASK::START_SEND:
SCI::SIMR3 = SCI::SIMR3.IICSTIF.b(0) |
SCI::SIMR3.IICSCLS.b(0b00) | SCI::SIMR3.IICSDAS.b(0b00);
SCI::TDR = t.adr_ << 1; // R/W = 0 (write)
task_ = sci_i2c_t::TASK::SEND_FIRST;
break;
case sci_i2c_t::TASK::SEND_FIRST:
if(SCI::SISR.IICACKR()) {
if(send_.length() > 0) {
SCI::TDR = send_.get();
task_ = sci_i2c_t::TASK::SEND_DATA;
break;
} else {
SCI::SIMR3 = SCI::SIMR3.IICSTPREQ.b(1) |
SCI::SIMR3.IICSCLS.b(0b00) | SCI::SIMR3.IICSDAS.b(0b00);
task_ = sci_i2c_t::TASK::STOP_SEND;
}
} else {
SCI::SIMR3 = SCI::SIMR3.IICSTPREQ.b(1) |
SCI::SIMR3.IICSCLS.b(0b00) | SCI::SIMR3.IICSDAS.b(0b00);
task_ = sci_i2c_t::TASK::STOP_SEND;
}
break;
case sci_i2c_t::TASK::SEND_DATA:
if(send_.length() > 0) {
SCI::TDR = send_.get();
} else {
SCI::SIMR3 = SCI::SIMR3.IICSTPREQ.b(1) |
SCI::SIMR3.IICSCLS.b(0b00) | SCI::SIMR3.IICSDAS.b(0b00);
task_ = sci_i2c_t::TASK::STOP_SEND;
}
break;
case sci_i2c_t::TASK::STOP_SEND:
if(t.func_ != nullptr) t.func_();
i2c_buff_.get_go();
SCI::SIMR3 = SCI::SIMR3.IICSTIF.b(0) |
SCI::SIMR3.IICSCLS.b(0b11) | SCI::SIMR3.IICSDAS.b(0b11);
task_ = sci_i2c_t::TASK::IDLE;
SCI::SCR.TEIE = 0;
SCI::SCR.TIE = 0;
break;
case sci_i2c_t::TASK::START_RECV:
SCI::TDR = (t.adr_ << 1) | 1; // R/W = 1 (read)
task_ = sci_i2c_t::TASK::RECV_DATA_PRE;
SCI::SCR.TIE = 1;
break;
case sci_i2c_t::TASK::RECV_DATA_PRE:
if(SCI::SISR.IICACKR() != 0) {
SCI::SCR.RIE = 0;
task_ = sci_i2c_t::TASK::STOP_RECV;
state_ = static_cast<uint8_t>(ERROR::ACK);
SCI::SCR.TEIE = 1;
} else {
if(t.len_ > 1) {
SCI::SIMR2.IICACKT = 0;
} else {
SCI::SIMR2.IICACKT = 1;
}
SCI::TDR = 0xff; // dummy data
task_ = sci_i2c_t::TASK::RECV_DATA;
SCI::SCR.RIE = 1;
}
break;
case sci_i2c_t::TASK::RECV_DATA:
if(t.len_ == (recv_.length() + 1)) {
SCI::SIMR2.IICACKT = 1;
}
recv_.put(SCI::RDR());
SCI::TDR = 0xff; // dummy data
if(t.len_ == recv_.length()) {
SCI::SCR.RIE = 0;
task_ = sci_i2c_t::TASK::STOP_RECV;
SCI::SCR.TEIE = 1;
}
break;
case sci_i2c_t::TASK::STOP_RECV:
{
uint8_t* p = t.dst_;
for(uint16_t i = 0; i < t.len_; ++i) {
*p++ = recv_.get();
}
}
default:
break;
}
}
static INTERRUPT_FUNC void recv_task_()
{
i2c_service_();
}
static INTERRUPT_FUNC void send_task_()
{
i2c_service_();
}
static INTERRUPT_FUNC void i2c_condition_task_()
{
i2c_service_();
}
bool i2c_start_() noexcept
{
SCI::SIMR3 = SCI::SIMR3.IICSTAREQ.b() |
SCI::SIMR3.IICSCLS.b(0b01) | SCI::SIMR3.IICSDAS.b(0b01);
uint32_t n = 0;
bool ret = true;
while(SCI::SIMR3.IICSTIF() == 0) {
++n;
if(n >= i2c_loop_) {
ret = false;
break;
}
}
SCI::SIMR3 = SCI::SIMR3.IICSCLS.b(0b00) | SCI::SIMR3.IICSDAS.b(0b00);
return ret;
}
bool i2c_stop_() noexcept
{
SCI::SIMR3 = SCI::SIMR3.IICSTPREQ.b() |
SCI::SIMR3.IICSCLS.b(0b01) | SCI::SIMR3.IICSDAS.b(0b01);
uint32_t n = 0;
bool ret = true;
while(SCI::SIMR3.IICSTIF() == 0) {
++n;
if(n >= i2c_loop_) {
ret = false;
break;
}
}
SCI::SIMR3 = SCI::SIMR3.IICSCLS.b(0b11) | SCI::SIMR3.IICSDAS.b(0b11);
return ret;
}
public:
//-----------------------------------------------------------------//
/*!
@brief コンストラクター
*/
//-----------------------------------------------------------------//
sci_i2c_io() noexcept : i2c_base(), level_(ICU::LEVEL::NONE), i2c_loop_(0) { }
//-----------------------------------------------------------------//
/*!
@brief 最終エラーコードを取得
@return 最終エラーコード
*/
//-----------------------------------------------------------------//
ERROR get_last_error() const noexcept { return error_; }
//-----------------------------------------------------------------//
/*!
@brief I2C を有効にする
@param[in] mode 動作モード(マスターモードのみ)
@param[in] spd スピード・タイプ
@param[in] level 割り込みレベル(0の場合ポーリング)
@return エラーなら「false」
*/
//-----------------------------------------------------------------//
bool start(MODE mode, SPEED spd, ICU::LEVEL level = ICU::LEVEL::NONE) noexcept
{
// I2C オプションが無い場合エラー
if(PSEL == port_map::ORDER::FIRST_I2C || PSEL == port_map::ORDER::SECOND_I2C || PSEL == port_map::ORDER::THIRD_I2C) {
} else {
return false;
}
// 割り込み動作に不具合があるので、強制的にポーリングとする。
level = ICU::LEVEL::NONE;
uint32_t clk = static_cast<uint32_t>(spd);
uint32_t brr = SCI::PCLK * 8 / clk;
uint32_t mddr = ((brr & 0xff00) << 8) / brr;
brr >>= 8;
if(brr >= 256 || brr <= 1) {
return false;
}
--brr;
// utils::format("BRR: %d, MDDR: %d\n")
// % static_cast<uint16_t>(brr) % static_cast<uint16_t>(mddr);
// ポーリング時の I2C ループ定数
// 200 ---> I2C Start/Stop loop for STANDARD
// 5 ---> マージン倍率
i2c_loop_ = 200 * 5;
level_ = level;
power_mgr::turn(SCI::PERIPHERAL);
SCI::SCR = 0x00; // TE, RE disable. CKE = 0
port_map::turn(SCI::PERIPHERAL, true, PSEL);
SCI::SIMR3 = SCI::SIMR3.IICSDAS.b(0b11) | SCI::SIMR3.IICSCLS.b(0b11);
SCI::SMR = 0x00;
SCI::SCMR = SCI::SCMR.SDIR.b();
SCI::BRR = brr;
SCI::MDDR = mddr;
bool brme = false;
if(mddr >= 128) brme = true;
// NFEN: ノイズ除去有効の場合「1」
SCI::SEMR = SCI::SEMR.NFEN.b(0) | SCI::SEMR.BRME.b(brme);
SCI::SNFR = SCI::SNFR.NFCS.b(0b001); // 1/1
SCI::SIMR1 = SCI::SIMR1.IICM.b() | SCI::SIMR1.IICDL.b(0b00000);
SCI::SIMR2 = SCI::SIMR2.IICACKT.b() | SCI::SIMR2.IICCSC.b() | SCI::SIMR2.IICINTM.b();
SCI::SPMR = 0x00;
if(level_ != ICU::LEVEL::NONE) {
task_ = sci_i2c_t::TASK::IDLE;
// RXI, TXI の設定
icu_mgr::set_interrupt(SCI::RXI, recv_task_, level_);
icu_mgr::set_interrupt(SCI::TXI, send_task_, level_);
// TEIx (STI interrupt)
auto grp = icu_mgr::get_group_vector(SCI::TEI);
if(grp == ICU::VECTOR::NONE) { // NONE が返ると通常割り込み
// 通常ベクターの場合、割り込み関数を登録、
// tev がグループベクターの場合にコンパイルエラーになるので回避
icu_mgr::set_task(static_cast<ICU::VECTOR>(SCI::TEI), i2c_condition_task_);
icu_mgr::set_level(static_cast<ICU::VECTOR>(SCI::TEI), level_);
} else {
// グループベクターの場合、通常関数を登録
icu_mgr::set_level(grp, level_);
icu_mgr::install_group_task(SCI::TEI, i2c_service_);
utils::format("install group vector for TE (LVL:%d)\n") % static_cast<uint16_t>(level_);
}
}
SCI::SCR = SCI::SCR.RE.b() | SCI::SCR.TE.b();
error_ = ERROR::NONE;
return true;
}
//-----------------------------------------------------------------//
/*!
@brief 同期 @n
※ポーリング時スルー
*/
//-----------------------------------------------------------------//
void sync() noexcept
{
if(level_ == ICU::LEVEL::NONE) return;
utils::format("SCI-I2C Start sync...\n");
auto task = task_;
utils::format("Begin: ");
Print(task);
while(task_ != sci_i2c_t::TASK::IDLE) {
if(task != task_) {
utils::format("End: ");
Print(task);
task = task_;
utils::format("Begin: ");
Print(task);
}
}
if(state_ != 0) {
utils::format("State: %d\n") % static_cast<uint16_t>(state_);
}
}
//-----------------------------------------------------------------//
/*!
@brief データ送信
@param[in] adr I2C アドレス(下位7ビット)
@param[in] src 送信データ
@param[in] len 送信長
@param[in] func 送信終了タスク
@return 送信正常終了なら「true」
*/
//-----------------------------------------------------------------//
bool send(uint8_t adr, const void* src, uint16_t len, FUNC_TYPE func = nullptr) noexcept
{
if(src == nullptr || len == 0) return false;
if(level_ == ICU::LEVEL::NONE) { // ポーリング動作時
if(!i2c_start_()) {
error_ = ERROR::START;
i2c_stop_();
return false;
}
SCI::TDR = adr << 1; // R/W = 0 (write)
while(SCI::SSR.TDRE() == 0) {
sleep_();
}
while(SCI::SSR.TEND() == 0) {
sleep_();
}
const uint8_t* p = static_cast<const uint8_t*>(src);
while(len > 0) {
if(SCI::SISR.IICACKR()) {
break;
}
SCI::TDR = *p++;
--len;
while(SCI::SSR.TDRE() == 0) {
sleep_();
}
while(SCI::SSR.TEND() == 0) {
sleep_();
}
}
if(!i2c_stop_()) {
error_ = ERROR::STOP;
return false;
}
if(func != nullptr) func();
error_ = ERROR::NONE;
} else { // 割り込み動作時
const uint8_t* p = static_cast<const uint8_t*>(src);
for(uint32_t i = 0; i < len; ++i) {
send_.put(*p);
++p;
}
sci_i2c_t t;
t.adr_ = adr;
t.dst_ = nullptr;
t.len_ = len;
t.func_ = func;
i2c_buff_.put(t);
if(task_ == sci_i2c_t::TASK::IDLE) {
state_ = 0;
task_ = sci_i2c_t::TASK::START_SEND;
SCI::SIMR3 = SCI::SIMR3.IICSTAREQ.b() |
SCI::SIMR3.IICSCLS.b(0b01) | SCI::SIMR3.IICSDAS.b(0b01);
SCI::SCR.TIE = 1;
SCI::SCR.TEIE = 1;
}
}
return true;
}
//-----------------------------------------------------------------//
/*!
@brief 送信(シングルバイト付き)
@param[in] adr I2C 7ビットアドレス
@param[in] first ファーストバイト
@param[in] src 転送先
@param[in] len 送信バイト数
@param[in] sync 非同期の場合「false」
@return 送信が完了した場合「true」
*/
//-----------------------------------------------------------------//
bool send(uint8_t adr, uint8_t first, const void* src, uint16_t len) noexcept
{
uint8_t tmp[len + 1];
tmp[0] = first;
std::memcpy(&tmp[1], src, len);
return send(adr, tmp, len + 1);
}
//-----------------------------------------------------------------//
/*!
@brief 送信(ダブルバイト付き)
@param[in] adr I2C 7ビットアドレス
@param[in] first ファーストバイト
@param[in] second セカンドバイト
@param[in] src 転送先
@param[in] len 送信バイト数
@param[in] sync 非同期の場合「false」
@return 送信が完了した場合「true」
*/
//-----------------------------------------------------------------//
bool send(uint8_t adr, uint8_t first, uint8_t second, const void* src, uint16_t len) noexcept
{
uint8_t tmp[len + 2];
tmp[0] = first;
tmp[1] = second;
std::memcpy(&tmp[2], src, len);
return send(adr, tmp, len + 2);
}
//-----------------------------------------------------------------//
/*!
@brief データ受信
@param[in] adr I2C アドレス(下位7ビット)
@param[in] dst 受信データ
@param[in] len 受信長
@param[in] func 受信終了関数
@return 送信正常終了なら「true」
*/
//-----------------------------------------------------------------//
bool recv(uint8_t adr, void* dst, uint16_t len, FUNC_TYPE func = nullptr) noexcept
{
if(dst == nullptr || len == 0) return false;
if(level_ == ICU::LEVEL::NONE) { // ポーリング動作
if(!i2c_start_()) {
error_ = ERROR::START;
i2c_stop_();
return false;
}
SCI::TDR = (adr << 1) | 1; // R/W = 1 (read)
while(SCI::SSR.TDRE() == 0) {
sleep_();
}
while(SCI::SSR.TEND() == 0) {
sleep_();
}
volatile uint8_t tmp = SCI::RDR(); // ダミーリード
if(SCI::SISR.IICACKR() != 0) {
error_ = ERROR::ACK;
i2c_stop_();
return false;
}
if(len > 1) {
SCI::SIMR2.IICACKT = 0;
}
uint8_t* p = static_cast<uint8_t*>(dst);
while(len > 0) {
if(len == 1) {
SCI::SIMR2.IICACKT = 1;
}
SCI::TDR = 0xff; // dummy data
while(SCI::SSR.RDRF() == 0) {
sleep_();
}
*p++ = SCI::RDR();
--len;
while(SCI::SSR.TEND() == 0) {
sleep_();
}
}
if(!i2c_stop_()) {
error_ = ERROR::STOP;
return false;
}
if(func != nullptr) func();
error_ = ERROR::NONE;
} else {
sci_i2c_t t;
t.adr_ = adr;
t.dst_ = static_cast<uint8_t*>(dst);
t.len_ = len;
t.func_ = func;
i2c_buff_.put(t);
if(task_ == sci_i2c_t::TASK::IDLE) {
state_ = 0;
task_ = sci_i2c_t::TASK::START_RECV;
SCI::SIMR3 = SCI::SIMR3.IICSTAREQ.b() |
SCI::SIMR3.IICSCLS.b(0b01) | SCI::SIMR3.IICSDAS.b(0b01);
SCI::SCR.TEIE = 1;
}
}
return true;
}
};
// テンプレート関数、実態の定義
template<class SCI, class RBF, class SBF, port_map::ORDER PSEL>
RBF sci_i2c_io<SCI, RBF, SBF, PSEL>::recv_;
template<class SCI, class RBF, class SBF, port_map::ORDER PSEL>
SBF sci_i2c_io<SCI, RBF, SBF, PSEL>::send_;
template<class SCI, class RBF, class SBF, port_map::ORDER PSEL>
volatile sci_i2c_t::TASK sci_i2c_io<SCI, RBF, SBF, PSEL>::task_;
template<class SCI, class RBF, class SBF, port_map::ORDER PSEL>
volatile uint8_t sci_i2c_io<SCI, RBF, SBF, PSEL>::state_;
template<class SCI, class RBF, class SBF, port_map::ORDER PSEL>
I2C_BUFF sci_i2c_io<SCI, RBF, SBF, PSEL>::i2c_buff_;
}
| [
"[email protected]"
] | |
5feab2aae0bfd25962bc9484e9e5c0298ba4c9e8 | ab1c643f224197ca8c44ebd562953f0984df321e | /pchealth/helpctr/service/database/helpset.cpp | f35ecb1db7a4ad32aaff77df820b847074d18dd2 | [] | no_license | KernelPanic-OpenSource/Win2K3_NT_admin | e162e0452fb2067f0675745f2273d5c569798709 | d36e522f16bd866384bec440517f954a1a5c4a4d | refs/heads/master | 2023-04-12T13:25:45.807158 | 2021-04-13T16:33:59 | 2021-04-13T16:33:59 | 357,613,696 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 3,316 | cpp | /******************************************************************************
Copyright (c) 2000 Microsoft Corporation
Module Name:
HelpSet.cpp
Abstract:
This file contains the implementation of the Taxonomy::HelpSet class,
that is used as an identifier for the set of Help files to operate upon.
Revision History:
Davide Massarenti (Dmassare) 11/25/2000
created
******************************************************************************/
#include "stdafx.h"
////////////////////////////////////////////////////////////////////////////////
MPC::wstring Taxonomy::HelpSet::m_strSKU_Machine;
long Taxonomy::HelpSet::m_lLCID_Machine;
////////////////////
HRESULT Taxonomy::HelpSet::SetMachineInfo( /*[in]*/ const InstanceBase& inst )
{
m_strSKU_Machine = inst.m_ths.m_strSKU;
m_lLCID_Machine = inst.m_ths.m_lLCID;
return S_OK;
}
DWORD Taxonomy::HelpSet::GetMachineLCID()
{
return ::GetSystemDefaultLCID();
}
DWORD Taxonomy::HelpSet::GetUserLCID()
{
return MAKELCID( ::GetUserDefaultUILanguage(), SORTIDFROMLCID( GetMachineLCID() ) );
}
void Taxonomy::HelpSet::GetLCIDDisplayString( /*[in]*/ long lLCID, /*[out]*/ MPC::wstring& str )
{
WCHAR rgTmp[256];
if(::GetLocaleInfoW( lLCID, LOCALE_SLANGUAGE, rgTmp, MAXSTRLEN(rgTmp) ))
{
str = rgTmp;
}
}
////////////////////
Taxonomy::HelpSet::HelpSet( /*[in]*/ LPCWSTR szSKU ,
/*[in]*/ long lLCID )
{
(void)Initialize( szSKU, lLCID );
}
Taxonomy::HelpSet::HelpSet( /*[in]*/ const HelpSet& ths )
{
*this = ths;
}
Taxonomy::HelpSet& Taxonomy::HelpSet::operator=( /*[in]*/ const HelpSet& ths )
{
m_strSKU = ths.m_strSKU;
m_lLCID = ths.m_lLCID ;
return *this;
}
////////////////////
HRESULT Taxonomy::HelpSet::Initialize( /*[in]*/ LPCWSTR szSKU ,
/*[in]*/ long lLCID )
{
m_strSKU = STRINGISPRESENT(szSKU) ? szSKU : m_strSKU_Machine.c_str();
m_lLCID = lLCID ? lLCID : m_lLCID_Machine;
return S_OK;
}
HRESULT Taxonomy::HelpSet::Initialize( /*[in]*/ LPCWSTR szSKU ,
/*[in]*/ LPCWSTR szLanguage )
{
return Initialize( szSKU, STRINGISPRESENT(szLanguage) ? _wtol( szLanguage ) : 0 );
}
////////////////////
bool Taxonomy::HelpSet::IsMachineHelp() const
{
return !_wcsicmp( GetSKU () , GetMachineSKU () ) &&
GetLanguage() == GetMachineLanguage() ;
}
////////////////////
bool Taxonomy::HelpSet::operator==( /*[in]*/ const HelpSet& sel ) const
{
return !_wcsicmp( GetSKU () , sel.GetSKU () ) &&
GetLanguage() == sel.GetLanguage() ;
}
bool Taxonomy::HelpSet::operator<( /*[in]*/ const HelpSet& sel ) const
{
int iCmp = _wcsicmp( GetSKU(), sel.GetSKU() );
if(iCmp == 0)
{
iCmp = (int)(GetLanguage() - sel.GetLanguage());
}
return (iCmp < 0);
}
HRESULT Taxonomy::operator>>( /*[in]*/ MPC::Serializer& stream, /*[out]*/ Taxonomy::HelpSet& val )
{
HRESULT hr;
if(SUCCEEDED(hr = (stream >> val.m_strSKU)) &&
SUCCEEDED(hr = (stream >> val.m_lLCID )) )
{
hr = S_OK;
}
return hr;
}
HRESULT Taxonomy::operator<<( /*[in]*/ MPC::Serializer& stream, /*[in] */ const Taxonomy::HelpSet& val )
{
HRESULT hr;
if(SUCCEEDED(hr = (stream << val.m_strSKU)) &&
SUCCEEDED(hr = (stream << val.m_lLCID )) )
{
hr = S_OK;
}
return hr;
}
| [
"[email protected]"
] | |
ec248186f4cac61eb32867cbd072eec9805c389b | 84cdb00dfca6d3b8b73aa87305ffd49ad3f041cb | /EAB programs/wavehc_play6completeonce/wavehc_play6completeonce.ino | 7da6679f237b2552eebd4ada753063a3fa30c3be | [] | no_license | abzman/arduino_wave | cdc5a37cf61e330ce50979ae212836e50a9992f0 | a308e38369e9e6d009058258d91baf141aa57d9c | refs/heads/master | 2021-01-20T04:32:45.543207 | 2014-06-15T09:09:35 | 2014-06-15T09:09:35 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 6,216 | ino | #include <FatReader.h>
#include <SdReader.h>
#include <avr/pgmspace.h>
#include "WaveUtil.h"
#include "WaveHC.h"
SdReader card; // This object holds the information for the card
FatVolume vol; // This holds the information for the partition on the card
FatReader root; // This holds the information for the filesystem on the card
FatReader f; // This holds the information for the file we're play
WaveHC wave; // This is the only wave (audio) object, since we will only play one at a time
#define DEBOUNCE 5 // button debouncer
const int knockSensor = 0; // Piezo sensor on pin 0.
const int threshold = 3; // Minimum signal from the piezo to register as a knock
const int knockFadeTime = 150; // milliseconds we allow a knock to fade before we listen for another one. (Debounce timer.)
// here is where we define the buttons that we'll use. button "1" is the first, button "6" is the 6th, etc
byte buttons[] = {14, 15, 16, 17, 18, 19};
// This handy macro lets us determine how big the array up above is, by checking the size
#define NUMBUTTONS sizeof(buttons)
// we will track if a button is just pressed, just released, or 'pressed' (the current state
volatile byte pressed[NUMBUTTONS], justpressed[NUMBUTTONS], justreleased[NUMBUTTONS];
// this handy function will return the number of bytes currently free in RAM, great for debugging!
int freeRam(void)
{
extern int __bss_end;
extern int *__brkval;
int free_memory;
if((int)__brkval == 0) {
free_memory = ((int)&free_memory) - ((int)&__bss_end);
}
else {
free_memory = ((int)&free_memory) - ((int)__brkval);
}
return free_memory;
}
void sdErrorCheck(void)
{
if (!card.errorCode()) return;
putstring("\n\rSD I/O error: ");
Serial.print(card.errorCode(), HEX);
putstring(", ");
Serial.println(card.errorData(), HEX);
while(1);
}
void setup() {
byte i;
// set up serial port
Serial.begin(9600);
putstring_nl("WaveHC with ");
Serial.print(NUMBUTTONS, DEC);
putstring_nl("buttons");
putstring("Free RAM: "); // This can help with debugging, running out of RAM is bad
Serial.println(freeRam()); // if this is under 150 bytes it may spell trouble!
// Set the output pins for the DAC control. This pins are defined in the library
pinMode(2, OUTPUT);
pinMode(3, OUTPUT);
pinMode(4, OUTPUT);
pinMode(5, OUTPUT);
// pin13 LED
pinMode(13, OUTPUT);
// Make input & enable pull-up resistors on switch pins
for (i=0; i< NUMBUTTONS; i++) {
pinMode(buttons[i], INPUT);
digitalWrite(buttons[i], HIGH);
}
// if (!card.init(true)) { //play with 4 MHz spi if 8MHz isn't working for you
if (!card.init()) { //play with 8 MHz spi (default faster!)
putstring_nl("Card init. failed!"); // Something went wrong, lets print out why
sdErrorCheck();
while(1); // then 'halt' - do nothing!
}
// enable optimize read - some cards may timeout. Disable if you're having problems
card.partialBlockRead(true);
// Now we will look for a FAT partition!
uint8_t part;
for (part = 0; part < 5; part++) { // we have up to 5 slots to look in
if (vol.init(card, part))
break; // we found one, lets bail
}
if (part == 5) { // if we ended up not finding one :(
putstring_nl("No valid FAT partition!");
sdErrorCheck(); // Something went wrong, lets print out why
while(1); // then 'halt' - do nothing!
}
// Lets tell the user about what we found
putstring("Using partition ");
Serial.print(part, DEC);
putstring(", type is FAT");
Serial.println(vol.fatType(),DEC); // FAT16 or FAT32?
// Try to open the root directory
if (!root.openRoot(vol)) {
putstring_nl("Can't open root dir!"); // Something went wrong,
while(1); // then 'halt' - do nothing!
}
// Whew! We got past the tough parts.
putstring_nl("Ready!");
TCCR2A = 0;
TCCR2B = 1<<CS22 | 1<<CS21 | 1<<CS20;
//Timer2 Overflow Interrupt Enable
TIMSK2 |= 1<<TOIE2;
}
SIGNAL(TIMER2_OVF_vect) {
check_switches();
}
void check_switches()
{
static byte previousstate[NUMBUTTONS];
static byte currentstate[NUMBUTTONS];
byte index;
for (index = 0; index < NUMBUTTONS; index++) {
currentstate[index] = digitalRead(buttons[index]); // read the button
/*
Serial.print(index, DEC);
Serial.print(": cstate=");
Serial.print(currentstate[index], DEC);
Serial.print(", pstate=");
Serial.print(previousstate[index], DEC);
Serial.print(", press=");
*/
if (currentstate[index] == previousstate[index]) {
if ((pressed[index] == LOW) && (currentstate[index] == LOW)) {
// just pressed
justpressed[index] = 1;
}
else if ((pressed[index] == HIGH) && (currentstate[index] == HIGH)) {
// just released
justreleased[index] = 1;
}
pressed[index] = !currentstate[index]; // remember, digital HIGH means NOT pressed
}
//Serial.println(pressed[index], DEC);
previousstate[index] = currentstate[index]; // keep a running tally of the buttons
}
}
void loop() {
byte i;
knockSensorValue = analogRead(knockSensor);
if (knockSensorValue >=threshold){
playcomplete("PIEZO.WAV");
}
delay(knockFadeTime);
}
// Plays a full file from beginning to end with no pause.
void playcomplete(char *name) {
// call our helper to find and play this name
playfile(name);
while (wave.isplaying) {
// do nothing while its playing
}
// now its done playing
}
void playfile(char *name) {
// see if the wave object is currently doing something
if (wave.isplaying) {// already playing something, so stop it!
wave.stop(); // stop it
}
// look in the root directory and open the file
if (!f.open(root, name)) {
putstring("Couldn't open file "); Serial.print(name); return;
}
// OK read the file and turn it into a wave object
if (!wave.create(f)) {
putstring_nl("Not a valid WAV"); return;
}
// ok time to play! start playback
wave.play();
}
| [
"[email protected]"
] | |
a34590887589d2ac01655046276118e8c5bc2a11 | 963a5e28023f4c060fd6e0c4268561ac31260547 | /num-analysis/main.cpp | 28d3dcd0fabcfbf2cb432679aaa1e2e2bff84199 | [] | no_license | baiwen1979/cpp-samples | 278263841201067dd9f8e03127bdd1b1962eea12 | 6c63958c0ad41dd13487a5f7fceac88954abb0a2 | refs/heads/master | 2022-12-17T15:53:23.624310 | 2020-09-19T15:08:51 | 2020-09-19T15:08:51 | 106,642,911 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,316 | cpp | #include <iostream>
#include "test.h"
using namespace std;
// 测试方程 f(x) = x - 4 = 0
float f1(float x) {
return x - 4;
}
// f'(x) = 1
float df1(float x) {
return 1;
}
// 测试方程 f(x) = x^2 - 4 = 0
float f2(float x) {
return x * x - 4;
}
// f'(x) = 2x
float df2(float x) {
return 2 * x;
}
//可以编写其它方程对应的f(x)和f'(x)函数进行测试,以观察哪种方法更好
int main() {
cout << "测试牛顿迭代法求方程f(X)=X-4=0的迭代过程和误差情况" << endl;
cout << "初始根x0=5.0,实际根为4.0,迭代次数为10" << endl;
testNewtonIteration(f1, df1, 5.0, 4.0, 10);
cout << "初始根x0=10.0,实际根为4.0,迭代次数为20"<< endl;
testNewtonIteration(f1, df1, 10.0, 4.0, 20);
cout << endl;
cout << "测试牛顿迭代法求方程f(X)=X^2-4=0的迭代过程和误差情况" << endl;
cout << "初始根x0=3.0,实际根为2.0,迭代次数为10" << endl;
testNewtonIteration(f2, df2, 3.0, 2.0, 10);
cout << "初始根x0=10.0,实际根为2.0,迭代次数为10" << endl;
testNewtonIteration(f2, df2, 10.0, 2.0, 20);
// 从运行结果看,第二种方法每次迭代误差更小,
// 收敛更快,需要的迭代次数也更少,因此更好。
// 此处可以运行更多的测试
} | [
"[email protected]"
] | |
ff3029b809d1ddef9b94a1ee194013cc36a73027 | 16451b68e5a9da816e05a52465d8b0d118d7d40c | /data/tplcache/ad63c15568ac9a372ff282bd349a92a7.inc | 0025be97cf0df8ba300445d0a9e2be0a48d7ecd9 | [] | no_license | winter2012/tian_ya_tu_ku | 6e22517187ae47242d3fde16995f085a68c04280 | 82d2f8b73f6ed15686f59efa9a5ebb8117c18ae5 | refs/heads/master | 2020-06-20T17:42:14.565617 | 2019-07-16T12:02:09 | 2019-07-16T12:02:09 | 197,184,466 | 0 | 1 | null | null | null | null | GB18030 | C++ | false | false | 1,588 | inc | {dede:pagestyle maxwidth='800' ddmaxwidth='235' row='3' col='3' value='2'/}
{dede:comments}图集类型会采集时生成此配置是正常的,不过如果后面没有跟着img标记则表示规则无效{/dede:comments}
{dede:img ddimg='' text='图 1'}/uploads/allimg/c131124/13U29323295120-2Vc3.jpg{/dede:img}
{dede:img ddimg='' text='图 2'}/uploads/allimg/c131124/13U29323542430-2935D.jpg{/dede:img}
{dede:img ddimg='' text='图 3'}/uploads/allimg/c131124/13U29323600340-301T0.jpg{/dede:img}
{dede:img ddimg='' text='图 4'}/uploads/allimg/c131124/13U2932545E40-313248.jpg{/dede:img}
{dede:img ddimg='' text='图 5'}/uploads/allimg/c131124/13U29325512140-3233Q.jpg{/dede:img}
{dede:img ddimg='' text='图 6'}/uploads/allimg/c131124/13U29325JJ60-335A7.jpg{/dede:img}
{dede:img ddimg='' text='图 7'}/uploads/allimg/c131124/13U29325LK60-34R64.jpg{/dede:img}
{dede:img ddimg='' text='图 8'}/uploads/allimg/c131124/13U2932E3R30-35B07.jpg{/dede:img}
{dede:img ddimg='' text='图 9'}/uploads/allimg/c131124/13U2932EN530-3E103.jpg{/dede:img}
{dede:img ddimg='' text='图 10'}/uploads/allimg/c131124/13U2932L25M0-3M9D.jpg{/dede:img}
{dede:img ddimg='' text='图 11'}/uploads/allimg/c131124/13U2932L92C0-3Q0S.jpg{/dede:img}
{dede:img ddimg='' text='图 12'}/uploads/allimg/c131124/13U2932R3010-39A19.jpg{/dede:img}
{dede:img ddimg='' text='图 13'}/uploads/allimg/c131124/13U2932R5a0-401c6.jpg{/dede:img}
{dede:img ddimg='' text='图 14'}/uploads/allimg/c131124/13U2932X62540-415053.jpg{/dede:img}
{dede:img ddimg='' text='图 15'}/uploads/allimg/c131124/13U29332156420-429347.jpg{/dede:img} | [
"[email protected]"
] | |
746b7bdc5201c3d00acb2809efb17e45126b17ab | 9fd8b8269986c56e056de95836d2135438b1ce42 | /GodoriGUI/GodoriGUI.cpp | d54e6a0ee9a1d59ff84bdbdd72e0bbdc225baae5 | [] | no_license | gomdorilla99/godoria | 96ed68779a1768bbc6c0586cdbbcb9ff09e99ebf | 00fba665c4aea24610a8c98872d8d78919c317a1 | refs/heads/master | 2020-05-07T20:53:42.550402 | 2020-01-12T04:07:20 | 2020-01-12T04:07:20 | 180,882,313 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 5,949 | cpp |
// GodoriGUI.cpp: 응용 프로그램에 대한 클래스 동작을 정의합니다.
//
#include "stdafx.h"
#include "afxwinappex.h"
#include "afxdialogex.h"
#include "GodoriGUI.h"
#include "MainFrm.h"
#include "GodoriGUIDoc.h"
#include "GodoriGUIView.h"
#include "Diler.h"
#include "Player.h"
#include "Card.h"
#include "Singleton.h"
#include <gdiplus.h>
using namespace Gdiplus;
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
ULONG_PTR g_GdiPlusTokenBoxData;
// CGodoriGUIApp
BEGIN_MESSAGE_MAP(CGodoriGUIApp, CWinApp)
ON_COMMAND(ID_APP_ABOUT, &CGodoriGUIApp::OnAppAbout)
// 표준 파일을 기초로 하는 문서 명령입니다.
ON_COMMAND(ID_FILE_NEW, &CWinApp::OnFileNew)
ON_COMMAND(ID_FILE_OPEN, &CWinApp::OnFileOpen)
// 표준 인쇄 설정 명령입니다.
ON_COMMAND(ID_FILE_PRINT_SETUP, &CWinApp::OnFilePrintSetup)
END_MESSAGE_MAP()
void InitFrameworkmain();
//InitFrameworkmain();
void WaitFrameworkmain();
auto & Diller = CDiler::GetInstance(ID_PLAYER2);
auto & Player1 = CPlayer::GetInstance(ID_PLAYER1);
auto & Player2 = CPlayer::GetInstance(ID_PLAYER2);
// CGodoriGUIApp 생성
CGodoriGUIApp::CGodoriGUIApp() noexcept
{
// 다시 시작 관리자 지원
m_dwRestartManagerSupportFlags = AFX_RESTART_MANAGER_SUPPORT_ALL_ASPECTS;
#ifdef _MANAGED
// 응용 프로그램을 공용 언어 런타임 지원을 사용하여 빌드한 경우(/clr):
// 1) 이 추가 설정은 다시 시작 관리자 지원이 제대로 작동하는 데 필요합니다.
// 2) 프로젝트에서 빌드하려면 System.Windows.Forms에 대한 참조를 추가해야 합니다.
System::Windows::Forms::Application::SetUnhandledExceptionMode(System::Windows::Forms::UnhandledExceptionMode::ThrowException);
#endif
// TODO: 아래 응용 프로그램 ID 문자열을 고유 ID 문자열로 바꾸십시오(권장).
// 문자열에 대한 서식: CompanyName.ProductName.SubProduct.VersionInformation
SetAppID(_T("GodoriGUI.AppID.NoVersion"));
// TODO: 여기에 생성 코드를 추가합니다.
// InitInstance에 모든 중요한 초기화 작업을 배치합니다.
}
// 유일한 CGodoriGUIApp 개체입니다.
CGodoriGUIApp theApp;
// CGodoriGUIApp 초기화
BOOL CGodoriGUIApp::InitInstance()
{
// 응용 프로그램 매니페스트가 ComCtl32.dll 버전 6 이상을 사용하여 비주얼 스타일을
// 사용하도록 지정하는 경우, Windows XP 상에서 반드시 InitCommonControlsEx()가 필요합니다.
// InitCommonControlsEx()를 사용하지 않으면 창을 만들 수 없습니다.
INITCOMMONCONTROLSEX InitCtrls;
InitCtrls.dwSize = sizeof(InitCtrls);
// 응용 프로그램에서 사용할 모든 공용 컨트롤 클래스를 포함하도록
// 이 항목을 설정하십시오.
InitCtrls.dwICC = ICC_WIN95_CLASSES;
InitCommonControlsEx(&InitCtrls);
CWinApp::InitInstance();
// OLE 라이브러리를 초기화합니다.
if (!AfxOleInit())
{
AfxMessageBox(IDP_OLE_INIT_FAILED);
return FALSE;
}
AfxEnableControlContainer();
EnableTaskbarInteraction(FALSE);
// RichEdit 컨트롤을 사용하려면 AfxInitRichEdit2()가 있어야 합니다.
// AfxInitRichEdit2();
// 표준 초기화
// 이들 기능을 사용하지 않고 최종 실행 파일의 크기를 줄이려면
// 아래에서 필요 없는 특정 초기화
// 루틴을 제거해야 합니다.
// 해당 설정이 저장된 레지스트리 키를 변경하십시오.
// TODO: 이 문자열을 회사 또는 조직의 이름과 같은
// 적절한 내용으로 수정해야 합니다.
SetRegistryKey(_T("로컬 응용 프로그램 마법사에서 생성된 응용 프로그램"));
LoadStdProfileSettings(4); // MRU를 포함하여 표준 INI 파일 옵션을 로드합니다.
// 응용 프로그램의 문서 템플릿을 등록합니다. 문서 템플릿은
// 문서, 프레임 창 및 뷰 사이의 연결 역할을 합니다.
CSingleDocTemplate* pDocTemplate;
pDocTemplate = new CSingleDocTemplate(
IDR_MAINFRAME,
RUNTIME_CLASS(CGodoriGUIDoc),
RUNTIME_CLASS(CMainFrame), // 주 SDI 프레임 창입니다.
RUNTIME_CLASS(CGodoriGUIView));
if (!pDocTemplate)
return FALSE;
AddDocTemplate(pDocTemplate);
// 표준 셸 명령, DDE, 파일 열기에 대한 명령줄을 구문 분석합니다.
CCommandLineInfo cmdInfo;
ParseCommandLine(cmdInfo);
// 명령줄에 지정된 명령을 디스패치합니다.
// 응용 프로그램이 /RegServer, /Register, /Unregserver 또는 /Unregister로 시작된 경우 FALSE를 반환합니다.
if (!ProcessShellCommand(cmdInfo))
return FALSE;
// 창 하나만 초기화되었으므로 이를 표시하고 업데이트합니다.
m_pMainWnd->ShowWindow(SW_SHOW);
m_pMainWnd->SetMenu(NULL);
//SetWindowSystemMenu(1, 0, 1);
CMenu *p_menu = m_pMainWnd->GetSystemMenu(FALSE);
p_menu->EnableMenuItem(SC_MAXIMIZE, MF_BYCOMMAND | MF_GRAYED);
m_pMainWnd->UpdateWindow();
return TRUE;
}
int CGodoriGUIApp::ExitInstance()
{
//TODO: 추가한 추가 리소스를 처리합니다.
AfxOleTerm(FALSE);
WaitFrameworkmain();
return CWinApp::ExitInstance();
}
// CGodoriGUIApp 메시지 처리기
// 응용 프로그램 정보에 사용되는 CAboutDlg 대화 상자입니다.
class CAboutDlg : public CDialogEx
{
public:
CAboutDlg() noexcept;
// 대화 상자 데이터입니다.
#ifdef AFX_DESIGN_TIME
enum { IDD = IDD_ABOUTBOX };
#endif
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 지원입니다.
// 구현입니다.
protected:
DECLARE_MESSAGE_MAP()
};
CAboutDlg::CAboutDlg() noexcept : CDialogEx(IDD_ABOUTBOX)
{
}
void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
CDialogEx::DoDataExchange(pDX);
}
BEGIN_MESSAGE_MAP(CAboutDlg, CDialogEx)
END_MESSAGE_MAP()
// 대화 상자를 실행하기 위한 응용 프로그램 명령입니다.
void CGodoriGUIApp::OnAppAbout()
{
CAboutDlg aboutDlg;
aboutDlg.DoModal();
}
// CGodoriGUIApp 메시지 처리기
| [
"[email protected]"
] | |
f3663ac5b8f1223c82ce48be9e57869fad4cfb00 | a137b3c6526f4a1d42c0b68c5e2bbfd49a4593e6 | /SimpleDBApplication/simpledb.cpp | 32e7a1e727768525f983e871a2ef077e1610563c | [] | no_license | bgwilf/Projects-I-worked-On | b1e444a1cd569470ad578c96c12ae2965d752fb7 | 83f7c0aa1baf6140d56704e0d3ecf8822bb2e270 | refs/heads/master | 2020-05-31T20:09:42.743770 | 2019-11-01T15:17:28 | 2019-11-01T15:17:28 | 190,470,464 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,615 | cpp | /* Project:
* File: simpleDB.cpp
* Team Members: Gilles wilfried Bassole & SOUROU K AGBE
*
*
*/
//#include "orderedLinkedList.h"
#include <cstdlib>
#include "orderedList.h"
using namespace std;
int main() {
cout<<"\t\t\t//**********************************************************//" <<endl
<<"\t\t\t// //" <<endl
<<"\t\t\t// SIMPLE DATABASE PROJECT //" <<endl
<<"\t\t\t// //" <<endl
<<"\t\t\t// @Gilles @SOUROU//" <<endl
<<"\t\t\t//**********************************************************//" <<endl;
int choice=0;
NodeType *first = NULL;
NodeType *last = NULL;
bool option = true;
// Present a menu and code the handling of the input.
while (choice!=10)
{
cout<<"\n\t\t\t<------ PROJECT MENU ------>"<<endl;
if (option)
cout << "AT THE START OF THE PROGRAM PLEASE SELECT OPTION 1 TO LOAD THE DATABASE" << endl;
cout<<"\t1. CREATECLASSLIST "<<endl
<<"\t2. INSERT "<<endl
<<"\t3. DELETE "<<endl
<<"\t4. SORT "<<endl
<<"\t5. SEARCH "<<endl
<<"\t6. UPDATE "<<endl
<<"\t7. HONOR_STUDENTS "<<endl
<<"\t8. WARN_STUDENTS "<<endl
<<"\t9. PRINT "<<endl
<<"\t10.QUIT "<<endl<<endl;
cout<<"\t\t PLease make a selection to: ";
cin >>choice;
//if input failed
if (cin.fail())
{
cout << "\nPlease select an option between 1 and 10." << endl;
cin.clear();
cin.ignore(1000, '\n');
}
else if (choice != 1 && option == true) //if user does not select option 1 as first option
{
if (choice != 10)
cout << "\nPlease select option 1 before the other options." << endl;
}
else
{
switch (choice)
{
case 1: // create class list
cout << "\ncreate class list..." << endl;
CreateClassList(first, last);
PrintList(first);
option = false;
break;
case 2: //INSERT
cout << "INSERTION...";
Insert(first);
break;
case 3: //DELETE
cout << "DELETION" << endl;
Delete(first);
break;
case 4: //SORT
cout << "SORT ..." << endl;
Sort(first);
break;
case 5: //SEARCH
cout << "SEARCH " << endl;
Search(first);
break;
case 6: //UPDATE
cout << "UPDATE LISTING " << endl;
Update(first);
break;
case 7: //HONORSTUDENTS
cout << " PRINTING LIST OF HONORSTUDENTS..." << endl;
HonorStudents(first);
break;
case 8: //WARNSTUDENTS
cout << "WARN STUDENTS " << endl;
WarnStudent(first);
break;
case 9: //PRINTING
cout << " PRINTING LIST" << endl;
Print(first);
break;
case 10: //QUITTING
cout << "You chose to QUIT!!! ";//quit = true;
cout << "GOOD BYE!" << endl;
break;
default:
cout << "ERROR: Invalid input...try again !!" << endl;
cout << "Please select an option between 1 and 10." << endl;
break;
}//End Switch
}// end else
} // end while loop
cout <<"Exiting program now..."<<endl;
return 0;
}
| [
"[email protected]"
] | |
5a3df3dc818d14511cd4569defac5602b945928f | a598a3b1018999f4c6aff304e1a85f1b23ec8c09 | /Handler_820_20120109/Run_TowerLamp.h | 1dc3d77f5a0898cad80ea8696920ccf1727844be | [] | no_license | ybs0111/AMT820 | ee06b968f4017370db70752aa3d1b903f1e6b5ae | fee003ae143299f503aa26e655c7ce476e8b6ecf | refs/heads/master | 2021-01-23T01:17:24.245424 | 2017-12-07T06:10:37 | 2017-12-07T06:10:37 | 85,891,285 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 895 | h | // Run_TowerLamp.h: interface for the CRun_TowerLamp class.
//
//////////////////////////////////////////////////////////////////////
#if !defined(AFX_RUN_TOWERLAMP_H__DDA03974_99D4_4189_95AF_AC8690043920__INCLUDED_)
#define AFX_RUN_TOWERLAMP_H__DDA03974_99D4_4189_95AF_AC8690043920__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
class CRun_TowerLamp
{
public:
CRun_TowerLamp();
virtual ~CRun_TowerLamp();
// Attributes
public:
bool InitFlag;
int MoveStep;
int mn_lamp_step;
int mn_form_step;
long ml_form_time[3];
long ml_lamp_time[3];
int mn_pcb_exist_check;
long ml_lamp_change_time[3];
// Operations
public:
void Run_FormChange();
void Run_Move();
void Thread_Run();
};
extern CRun_TowerLamp Run_TowerLamp;
extern CRun_TowerLamp Run_TowerLamp_Manual;
#endif // !defined(AFX_RUN_TOWERLAMP_H__DDA03974_99D4_4189_95AF_AC8690043920__INCLUDED_)
| [
"[email protected]"
] | |
16a129efb4e95c83f7e528338cad27668bb5c287 | 23e4759cfb7507477f78c5c68373748e85eebf97 | /class_notes/w4_analogout/w4_analogout.ino | 5717369c33900763fdfc809b6026b1d359e12c80 | [] | no_license | abhimanyuvasishth/intro-to-im | 85388f121452c070776bcb474d743ebbc17af50a | 9bacdb528fbe0e2bb2a0cac09e7b6389a46254fc | refs/heads/master | 2021-01-16T00:05:07.509423 | 2016-12-15T10:26:33 | 2016-12-15T10:26:33 | 68,454,361 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 403 | ino | void setup() {
// put your setup code here, to run once:
for (int x = 2; x <= 4; x++){
pinMode(x, INPUT_PULLUP);
}
}
void loop() {
// put your main code here, to run repeatedly:
if (digitalRead(2) == LOW){
tone(8, 440, 20);
}
else if (digitalRead(3) == LOW ){
tone(8, 494, 20);
}
else if (digitalRead(4) == LOW){
tone(8, 131, 20);
}
else {
noTone(8);
}
}
| [
"[email protected]"
] | |
1f92c51418c6a772616b76952bc7a30053d33d8f | 947e791f2146fd450d3ce7783ba9c281aea1019d | /Source/BuildingEscape/BalanceMass.cpp | efd379515dbbf745c060f58154d54caa2bbd6ec0 | [] | no_license | Cxmilo/03_Building_Escape | e16b1bf1e5f3a58ecec98209d216551b0397521b | 8ef3baf68c8766e64d9aae08d5a0c9d4a5a4b861 | refs/heads/master | 2020-03-26T00:48:52.597415 | 2018-08-14T23:18:10 | 2018-08-14T23:18:10 | 144,339,113 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,179 | cpp | // Fill out your copyright notice in the Description page of Project Settings.
#include "BalanceMass.h"
// Sets default values
ABalanceMass::ABalanceMass()
{
// Set this actor to call Tick() every frame. You can turn this off to improve performance if you don't need it.
PrimaryActorTick.bCanEverTick = true;
}
// Called when the game starts or when spawned
void ABalanceMass::BeginPlay()
{
Super::BeginPlay();
ReadDataTable();
}
void ABalanceMass::ReadDataTable()
{
if (IsValid(massDataTable))
{
FMassBalanceStruct* data = massDataTable->FindRow<FMassBalanceStruct>(presetName, "", false);
SetMassTable(data->MassTable);
SetMassChair(data->MassChair);
}
else
{
UE_LOG(LogTemp, Error, TEXT("Data Table is invalid"));
}
}
// Called every frame
void ABalanceMass::Tick(float DeltaTime)
{
Super::Tick(DeltaTime);
}
void ABalanceMass::SetMassTable(float MassTable)
{
this->MassTable = MassTable;
}
void ABalanceMass::SetMassChair(float MassChair)
{
this->MassChair = MassChair;
}
float ABalanceMass::GetMassTable()
{
ReadDataTable();
return this->MassTable;
}
float ABalanceMass::GetMassChair()
{
ReadDataTable();
return this->MassChair;
}
| [
"[email protected]"
] | |
0267764e28b62e725a82ff479bc9a127c0c26585 | b856389f505ea4703c42dcbb7874577c7ac7a959 | /Caustics/Model.h | 7444345c21a64a3daa94e9443642d67acd204e20 | [] | no_license | SecondRealityLabs/Caustics | cdc7b9669be78954d0b3fcb81783f1fa84417167 | feece771a99c1de6574c891f6f071355d914f4b4 | refs/heads/master | 2020-12-24T06:37:57.623733 | 2017-01-31T18:41:36 | 2017-01-31T18:41:36 | 73,467,222 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 298 | h | #pragma once
#include <vector>
#include "Mesh.h"
#include "Texture.h"
class Model
{
private:
std::vector<Mesh> meshes;
std::vector<Texture> textures;
public:
Model();
~Model();
void addMesh(void);
void delMesh(void);
void addTexture(void);
void delTexture(void);
};
| [
"[email protected]"
] | |
df81573f8d8cf0ff98d8737168a7c53ed2fea2dd | 70473c666b22481fb88d4447e42f3a3d145b00d3 | /pigisland/include/kmint/pigisland/C2DMatrix.hpp | d77ea9e417a2368b0da0a6bea55b2c27795ef638 | [] | no_license | Roykovic/pigislandkmint | 8e29b69dbc81d99f5c30a4d201da024088b93518 | aa900403e136ceb94e4a91193be6270fcb75fde4 | refs/heads/main | 2023-02-01T10:06:18.383978 | 2020-12-17T10:36:34 | 2020-12-17T10:36:34 | 318,136,431 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 5,364 | hpp | #ifndef C2DMATRIX_H
#define C2DMATRIX_H
//------------------------------------------------------------------------
//
// Name: C2DMatrix.h
//
// Author: Mat Buckland 2002
//
// Desc: 2D Matrix class
//
//------------------------------------------------------------------------
#include <math.h>
#include <vector>
using Vector2D = kmint::math::vector2d;
class C2DMatrix
{
private:
struct Matrix
{
double _11, _12, _13;
double _21, _22, _23;
double _31, _32, _33;
Matrix()
{
_11 = 0.0; _12 = 0.0; _13 = 0.0;
_21 = 0.0; _22 = 0.0; _23 = 0.0;
_31 = 0.0; _32 = 0.0; _33 = 0.0;
}
};
Matrix m_Matrix;
//multiplies m_Matrix with mIn
inline void MatrixMultiply(Matrix& mIn);
public:
C2DMatrix()
{
//initialize the matrix to an identity matrix
Identity();
}
//create an identity matrix
inline void Identity();
//create a transformation matrix
inline void Translate(double x, double y);
//create a scale matrix
inline void Scale(double xScale, double yScale);
//create a rotation matrix
inline void Rotate(double rotation);
//create a rotation matrix from a fwd and side 2D vector
inline void Rotate(const kmint::math::vector2d& fwd, const kmint::math::vector2d& side);
//applys a transformation matrix to a std::vector of points
inline void TransformVector2Ds(std::vector<kmint::math::vector2d>& vPoints);
//applys a transformation matrix to a point
inline void TransformVector2Ds(kmint::math::vector2d& vPoint);
//accessors to the matrix elements
void _11(double val) { m_Matrix._11 = val; }
void _12(double val) { m_Matrix._12 = val; }
void _13(double val) { m_Matrix._13 = val; }
void _21(double val) { m_Matrix._21 = val; }
void _22(double val) { m_Matrix._22 = val; }
void _23(double val) { m_Matrix._23 = val; }
void _31(double val) { m_Matrix._31 = val; }
void _32(double val) { m_Matrix._32 = val; }
void _33(double val) { m_Matrix._33 = val; }
};
//multiply two matrices together
inline void C2DMatrix::MatrixMultiply(Matrix& mIn)
{
C2DMatrix::Matrix mat_temp;
//first row
mat_temp._11 = (m_Matrix._11 * mIn._11) + (m_Matrix._12 * mIn._21) + (m_Matrix._13 * mIn._31);
mat_temp._12 = (m_Matrix._11 * mIn._12) + (m_Matrix._12 * mIn._22) + (m_Matrix._13 * mIn._32);
mat_temp._13 = (m_Matrix._11 * mIn._13) + (m_Matrix._12 * mIn._23) + (m_Matrix._13 * mIn._33);
//second
mat_temp._21 = (m_Matrix._21 * mIn._11) + (m_Matrix._22 * mIn._21) + (m_Matrix._23 * mIn._31);
mat_temp._22 = (m_Matrix._21 * mIn._12) + (m_Matrix._22 * mIn._22) + (m_Matrix._23 * mIn._32);
mat_temp._23 = (m_Matrix._21 * mIn._13) + (m_Matrix._22 * mIn._23) + (m_Matrix._23 * mIn._33);
//third
mat_temp._31 = (m_Matrix._31 * mIn._11) + (m_Matrix._32 * mIn._21) + (m_Matrix._33 * mIn._31);
mat_temp._32 = (m_Matrix._31 * mIn._12) + (m_Matrix._32 * mIn._22) + (m_Matrix._33 * mIn._32);
mat_temp._33 = (m_Matrix._31 * mIn._13) + (m_Matrix._32 * mIn._23) + (m_Matrix._33 * mIn._33);
m_Matrix = mat_temp;
}
//applies a 2D transformation matrix to a std::vector of Vector2Ds
inline void C2DMatrix::TransformVector2Ds(std::vector<kmint::math::vector2d>& vPoint)
{
for (unsigned int i = 0; i < vPoint.size(); ++i)
{
double tempX = (m_Matrix._11 * vPoint[i].x()) + (m_Matrix._21 * vPoint[i].y()) + (m_Matrix._31);
double tempY = (m_Matrix._12 * vPoint[i].x()) + (m_Matrix._22 * vPoint[i].y()) + (m_Matrix._32);
vPoint[i].x(tempX);
vPoint[i].y(tempY);
}
}
//applies a 2D transformation matrix to a single Vector2D
inline void C2DMatrix::TransformVector2Ds(kmint::math::vector2d& vPoint)
{
double tempX = (m_Matrix._11 * vPoint.x()) + (m_Matrix._21 * vPoint.y()) + (m_Matrix._31);
double tempY = (m_Matrix._12 * vPoint.x()) + (m_Matrix._22 * vPoint.y()) + (m_Matrix._32);
vPoint.x(tempX);
vPoint.y(tempY);
}
//create an identity matrix
inline void C2DMatrix::Identity()
{
m_Matrix._11 = 1; m_Matrix._12 = 0; m_Matrix._13 = 0;
m_Matrix._21 = 0; m_Matrix._22 = 1; m_Matrix._23 = 0;
m_Matrix._31 = 0; m_Matrix._32 = 0; m_Matrix._33 = 1;
}
//create a transformation matrix
inline void C2DMatrix::Translate(double x, double y)
{
Matrix mat;
mat._11 = 1; mat._12 = 0; mat._13 = 0;
mat._21 = 0; mat._22 = 1; mat._23 = 0;
mat._31 = x; mat._32 = y; mat._33 = 1;
//and multiply
MatrixMultiply(mat);
}
//create a scale matrix
inline void C2DMatrix::Scale(double xScale, double yScale)
{
C2DMatrix::Matrix mat;
mat._11 = xScale; mat._12 = 0; mat._13 = 0;
mat._21 = 0; mat._22 = yScale; mat._23 = 0;
mat._31 = 0; mat._32 = 0; mat._33 = 1;
//and multiply
MatrixMultiply(mat);
}
//create a rotation matrix
inline void C2DMatrix::Rotate(double rot)
{
C2DMatrix::Matrix mat;
double Sin = sin(rot);
double Cos = cos(rot);
mat._11 = Cos; mat._12 = Sin; mat._13 = 0;
mat._21 = -Sin; mat._22 = Cos; mat._23 = 0;
mat._31 = 0; mat._32 = 0; mat._33 = 1;
//and multiply
MatrixMultiply(mat);
}
//create a rotation matrix from a 2D vector
inline void C2DMatrix::Rotate(const kmint::math::vector2d& fwd, const kmint::math::vector2d& side)
{
C2DMatrix::Matrix mat;
mat._11 = fwd.x(); mat._12 = fwd.y(); mat._13 = 0;
mat._21 = side.x(); mat._22 = side.y(); mat._23 = 0;
mat._31 = 0; mat._32 = 0; mat._33 = 1;
//and multiply
MatrixMultiply(mat);
}
#endif | [
"[email protected]"
] | |
58b5738befef8cfdb9d39ed2b29133bc2212b8bb | 150efb710ac4fece398cd840b2680aeca950c711 | /cs-5050/hw5/code/ClosestPair.hpp | be3ab9470daa3fbec6954cf468b3a0acc8d6553d | [] | no_license | fayroslee/school | 5a109674f6765f4def9101228844e4525b8396de | a41e96d304a92036a5de893922161a0b9052f6a6 | refs/heads/master | 2021-01-11T15:20:14.724069 | 2014-04-25T14:56:01 | 2014-04-25T14:56:01 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 533 | hpp | #ifndef CLOSEST_PAIR_H
#define CLOSEST_PAIR_H
#include <utility>
#include <vector>
#include <algorithm>
#include <climits>
#include "Point.hpp"
class ClosestPair {
public:
std::vector<Point> randomPoints(int n);
std::vector<Point> uniformPoints(int n);
std::vector<Point> mixedPoints(int n);
double nTimesN(std::vector<Point>& points, int low, int high);
double divideAndConquerSlow(std::vector<Point>& points, int low, int high);
double divideAndConquerFast(std::vector<Point>& points, int low, int high);
};
#endif | [
"[email protected]"
] | |
7623a5ec31cde6d8479009a4d6396223290684b2 | 24237ca3bff2eef206972f9550d9d5105a349216 | /src/blind_trajectory_planner_node.cpp | 46a48eeb18da4a847696bc8dcef51458121dcc2c | [] | no_license | NikHoh/ar_land | 4062218bd1a674893ff146fd2c262fa07c71a0e0 | 8f42a254b2ee414bf6c58d7495821b91ed7184bf | refs/heads/master | 2020-04-05T11:28:54.176301 | 2019-04-11T11:12:27 | 2019-04-11T11:12:27 | 156,836,544 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 8,781 | cpp | #include "ar_land/blind_trajectory_planner_node.hpp"
#include <tf2/transform_datatypes.h>
#include <angles/angles.h>
#include "ar_land/tools.hpp"
blind_trajectory_planner_node::blind_trajectory_planner_node()
: flight_state(Idle)
, thrust(0)
{
ROS_INFO("Im Konstruktor des blind_trjactory_planners");
// initialize topics
ros::NodeHandle n("~");
// reads parameter with name (1) from parameter server and saves it in name (2), if not found default is (3)
n.param<std::string>("T_cam_board_topic", T_cam_board_topic, "/ar_single_board/transform");
n.param<std::string>("pose_goal_in_world_topic", pose_goal_in_world_topic, "/ar_land/T_world_goal_topic");
n.param<std::string>("world_frame_id", world_frame_id, "/world");
n.param<std::string>("drone_frame_id", drone_frame_id, "/crazyflie/base_link");
n.param<std::string>("goal_frame_id", goal_frame_id, "/crazyflie/goal");
n.param<std::string>("board_frame_id", board_frame_id, "board_c3po");
n.param<std::string>("cam_frame_id", cam_frame_id, "/cam");
// Subscribers
T_cam_board_sub = nh.subscribe(T_cam_board_topic, 1, &blind_trajectory_planner_node::setGoalinWorld, this); // subscribed zu (1) und führt bei empfangener Nachricht (3) damit aus
control_out_sub = nh.subscribe("cmd_vel",1, &blind_trajectory_planner_node::getValue, this);
// Publishers
pose_goal_in_world_pub = nh.advertise<geometry_msgs::PoseStamped>(pose_goal_in_world_topic, 1); // states that pose_goal_in_world_pub publishes to topic (1)
control_out_pub = nh.advertise<geometry_msgs::Twist>("cmd_vel", 1);
//Services
flight_state_change_srv = nh.advertiseService("flight_state_change", &blind_trajectory_planner_node::state_change, this);
goal_change_srv_serv = nh.advertiseService("/ar_land/goal_change", &blind_trajectory_planner_node::goal_change, this);
goal_position_in_board.setValue(0,0,0.7);
}
bool blind_trajectory_planner_node::state_change(ar_land::flight_state_changeRequest &req,
ar_land::flight_state_changeResponse &res)
{
ROS_INFO("State change requested");
flight_state = State(req.flight_state);
res.changed = 1;
switch(flight_state)
{
case Idle:
{
geometry_msgs::Twist msg;
msg.linear.x = 0;
msg.linear.y = 0;
msg.linear.z = 0;
msg.angular.x = 0;
msg.angular.y = 0;
msg.angular.z = 0;
control_out_pub.publish(msg);
ROS_INFO("State change to Idle");
}
break;
case Automatic:
{
nh.setParam("/ar_land/pid_controller_node/controller_enabled", true);
ROS_INFO("State change to Automatic");
}
break;
case TakingOff:
{
double startTime = ros::Time::now().toSec();
while(flight_state != Automatic)
{
// press red button (Logitech controller) / triangle (PS4 controller)
if (ros::Time::now().toSec() - startTime < 1.5) // drone has not finished takeoff
{
thrust = 45500;
geometry_msgs::Twist msg;
msg.linear.z = thrust;
control_out_pub.publish(msg);
}
else // drone has completed takeoff --> switch to automatic mode
{
nh.setParam("/ar_land/pid_controller_node/z_integral", 44500);
nh.setParam("/ar_land/pid_controller_node/controller_enabled", true);
flight_state = Automatic;
ROS_INFO("TakingOff done");
}
}
}
break;
case Landing:
{
nh.setParam("/ar_land/pid_controller_node/resetPID", true);
float thrust = last_thrust;
ros::Rate rate(10);
geometry_msgs::Twist control_out;
while(thrust > 0)
{
thrust -= 100;
if(thrust < 36500)
{
thrust = 0;
}
control_out.linear.z = thrust;
control_out.linear.x = 0;
control_out.linear.y = 0;
control_out_pub.publish(control_out);
rate.sleep();
}
flight_state = Idle;
}
break;
case Emergency:
{
nh.setParam("/ar_land/pid_controller_node/resetPID", true);
nh.setParam("/ar_land/pid_controller_node/controller_enabled", false);
geometry_msgs::Twist msg;
msg.linear.x = 0;
msg.linear.y = 0;
msg.linear.z = 0;
msg.angular.x = 0;
msg.angular.y = 0;
msg.angular.z = 0;
control_out_pub.publish(msg);
ROS_INFO("State change to Emergency");
}
break;
default:
{
ROS_ERROR("Flight state not set");
}
break;
}
return true;
}
void blind_trajectory_planner_node::getValue(const geometry_msgs::Twist &msg){
last_thrust = msg.linear.z;
}
bool blind_trajectory_planner_node::goal_change(ar_land::goal_change::Request& req, ar_land::goal_change::Response& res)
{
ROS_INFO("Goal change requested. %d: ", (int) req.button_code);
switch(req.button_code)
{
case 1:
{
double x = goal_position_in_board.getX();
goal_position_in_board.setX(x-0.1);
ROS_INFO("Set new goal position to (%0.2f, %0.2f, %0.2f)", goal_position_in_board.getX(), goal_position_in_board.getY(), goal_position_in_board.getZ());
}
break;
case 2:
{
double x = goal_position_in_board.getX();
goal_position_in_board.setX(x+0.1);
ROS_INFO("Set new goal position to (%0.2f, %0.2f, %0.2f)", goal_position_in_board.getX(), goal_position_in_board.getY(), goal_position_in_board.getZ());
}
break;
case 3:
{
double y = goal_position_in_board.getY();
goal_position_in_board.setY(y-0.1);
ROS_INFO("Set new goal position to (%0.2f, %0.2f, %0.2f)", goal_position_in_board.getX(), goal_position_in_board.getY(), goal_position_in_board.getZ());
}
break;
case 4:
{
double y = goal_position_in_board.getY();
goal_position_in_board.setY(y+0.1);
ROS_INFO("Set new goal position to (%0.2f, %0.2f, %0.2f)", goal_position_in_board.getX(), goal_position_in_board.getY(), goal_position_in_board.getZ());
}
break;
case 5:
{
double z = goal_position_in_board.getZ();
goal_position_in_board.setZ(z-0.1);
ROS_INFO("Set new goal position to (%0.2f, %0.2f, %0.2f)", goal_position_in_board.getX(), goal_position_in_board.getY(), goal_position_in_board.getZ());
}
break;
case 6:
{
double z = goal_position_in_board.getZ();
goal_position_in_board.setZ(z+0.1);
ROS_INFO("Set new goal position to (%0.2f, %0.2f, %0.2f)", goal_position_in_board.getX(), goal_position_in_board.getY(), goal_position_in_board.getZ());
}
break;
default:
{
ROS_ERROR("Error in Button Code");
}
break;
}
}
void blind_trajectory_planner_node::setGoalinWorld(const geometry_msgs::TransformStamped &T_cam_board_msg) {
// Broadcasting T_board_cam as transform to achieve valid tf-tree (message comes from the single_board_node)
tf::StampedTransform T_cam_board;
tf::transformStampedMsgToTF(T_cam_board_msg, T_cam_board);
tf::StampedTransform T_board_cam;
T_board_cam.setData(T_cam_board.inverse());
T_board_cam.stamp_ = T_cam_board.stamp_;
T_board_cam.frame_id_ = board_frame_id;
T_board_cam.child_frame_id_ = cam_frame_id;
tf_br.sendTransform(T_board_cam); // broadcasts the board_to_cam_tf coming from the marker detection into the tf tree, but tf can be older (if it lost track of marker)
if(flight_state == Automatic)
{
tf::StampedTransform world_to_board_tf;
tf::StampedTransform cam_to_drone_tf;
tf::StampedTransform world_to_goal_tf;
try{
tf_lis.lookupTransform(world_frame_id, board_frame_id, ros::Time(0), world_to_board_tf); // tf which is set up in parameter server
tf_lis.lookupTransform(cam_frame_id, drone_frame_id, ros::Time(0), cam_to_drone_tf); // tf which is set up in parameter server
}
catch (tf::TransformException &ex) {
ROS_ERROR("%s",ex.what());
ros::Duration(1.0).sleep();
}
// The Goal follows ROS conventions (Z axis up, X to the right and Y to the front)
// We set the goal above the world coordinate frame (our marker)
world_to_goal_tf.setIdentity();
world_to_goal_tf.setOrigin(goal_position_in_board);
world_to_goal_tf.child_frame_id_ = goal_frame_id;
world_to_goal_tf.frame_id_ = world_frame_id;
world_to_goal_tf.stamp_ = ros::Time::now();
tf_br.sendTransform(world_to_goal_tf);
geometry_msgs::TransformStamped T_world_goal_msg;
geometry_msgs::PoseStamped pose_goal_in_world_msg;
tf::transformStampedTFToMsg(world_to_goal_tf, T_world_goal_msg);
tools_func::convert(T_world_goal_msg, pose_goal_in_world_msg);
pose_goal_in_world_pub.publish(pose_goal_in_world_msg); // neccessary for pid_controller_node
}
}
int main(int argc, char** argv) {
ros::init(argc, argv, "blind_trajectory_planner_node"); // initializes node named blind_trajectory_planner_node
ros::NodeHandle n("~");
blind_trajectory_planner_node node; // Creates trajectory_planner_node
ros::spin();
return 0;
}
| [
"[email protected]"
] | |
b04bc6c04eb5d83ab547d3acd19421c054e32a85 | ead3cf7bf2453a1aa8d8c6948cf17b677bfba38c | /Game/playerBlow.h | c0e718ae3ac92b3b95b68c85fb48085b7d5bd0e3 | [] | no_license | ShunYamashita/Earnest_repos2 | 15e1b600de0aaa48a417d236766b1f42476144ac | 90494ef400b4332662580da2092f2834b0dc9e41 | refs/heads/master | 2021-09-04T12:34:03.434069 | 2018-01-18T17:56:58 | 2018-01-18T17:56:58 | 115,842,219 | 0 | 0 | null | null | null | null | SHIFT_JIS | C++ | false | false | 1,498 | h | //--------------------------------------------------------------------------------------
// プレイヤーステート( 吹っ飛び ) ( playerBlow.h )
//
// Author : SHUN YAMASHITA
//--------------------------------------------------------------------------------------
#ifndef _PLAYER_BLOW_H_
#define _PLAYER_BLOW_H_
//--------------------------------------------------------------------------------------
// ヘッダーファイル
//--------------------------------------------------------------------------------------
#include "playerState.h"
//--------------------------------------------------------------------------------------
// クラスの前方宣言
//--------------------------------------------------------------------------------------
class Player;
//--------------------------------------------------------------------------------------
// プレイヤーステート( 吹っ飛び ) クラスの定義
//--------------------------------------------------------------------------------------
class PlayerBlow : public PlayerState
{
public:
PlayerBlow( Player* player )
{
SetPlayer( player );
};
void Init( void ) override; // 初期化
void Uninit( void ) override; // 終了
void Update( void ) override; // 更新
void Draw( void ) override; // 描画
static PlayerBlow* Create( void ); // 生成
private:
void Action( void ); // アクション
float m_blowPower; // 吹っ飛びの力
};
#endif
| [
"[email protected]"
] | |
f12a3864e687a54b602f090ac9e348d9fc028012 | 2a4b8cec1af2a59bd53c928fa48cf1305f5371e2 | /GS ACK Request/gsserver.h | 0dab666e44beb66cb38111cb38c6ab2d422b0fd3 | [] | no_license | danortega13/GroundStation | 8b9b4592039f8cbcf9a3e1a3b4073a91a3d1443d | c673dff95c60784e675b212636fc6d747afe5be6 | refs/heads/master | 2020-12-26T03:45:00.450568 | 2016-03-09T19:27:17 | 2016-03-09T19:27:17 | 49,742,772 | 0 | 0 | null | 2016-01-15T20:19:31 | 2016-01-15T20:19:29 | C++ | UTF-8 | C++ | false | false | 3,566 | h | #ifndef GSSERVER_H
#define GSSERVER_H
#include <QQueue>
#include <QPair>
#include <QThread>
#include <QUdpSocket>
#include "serverqueue.h"
//#include "net.h"
#include "networklistener.h"
#include "messagebox.h"
#define DEFAULT_PRIORITY 10
const static QString UAV_IP_ADDRESS = "localhost";
/**
GsServer is the server object for the ground station. The current
implementation will be changing, but this is the first working version.
I will be cleaning the code and making frequent implementation changes in
the near future. The functions and variables however will probably remain
stable.
@author Jordan Dickson
@date 1-29-1016
@version 2.0
*/
class GsServer : public QThread{
//Q_OBJECT
public:
/**
Creates a new server hosted on the localhost (127.0.0.1) on port 3495.
@param myMessageBox the messagebox used for outgoing packets
*/
GsServer(messagebox *myMessageBox);
/**
Destructor for GsServer
*/
~GsServer();
/**
Override run to implement thread as a server.
*/
void run();
void startServer();
/**
Opens ther server by hosting it on the default port and listening for
connections.
*/
void openServer();
/**
Opens ther server by hosting it on a socket and listening for
connections.
*/
void openServer(QHostAddress target, unsigned int port);
/**
Closes the server by dropping all current connections and ending the
listener thread.
*/
void closeServer();
/**
waits for a specified number of milliseconds
@param millis the number of milliseconds to wait
*/
void waitNet(unsigned millis);
/**
* @brief sendPacket adds a packet to the send queue for this server. The
* default priority is 10. The packet will be sent as soon as the socket
* is free for sending. Lowest prioirty is sent first.
* @param packet the packet to be added into the send queue
* @author Jordan Dickson
* @date Feb 5 2016
*/
void sendPacket(Protocol::Packet* packet);
/**
* @brief sendPacket adds a packet to the send queue for this server. The
* packet will be sent as soon as the socket is free for sending. Lowest
* priority is sent first.
* @param packet the packet to be added into the send queue
* @param priority the priority of the packet (lowest number sent first)
* @date Feb 5 2016
*/
void sendPacket(Protocol::Packet* packet, unsigned int priority);
/**
file descriptor for the UAV. Used to send information over the network.
*/
int uav_fd;
/**
the maximum size of a packet that will be sent by this server.
*/
unsigned char maxPackSize = 255;
/**
The NetworkListener used by this server to process incoming signals.
*/
NetworkListener networkListener;
private:
bool running;
/* Alvin Truong added on 16-1-27*/
const static int PACKET_LENGTH = 1000;
const static int SEND_PORT = 20715;
const static int LISTEN_PORT = 20715;
static int NUM_RECV_PACKETS;
/**
Stores the port number of this server.
*/
unsigned short port;
/**
Sends the most significant datagram.
*/
void sendNextPacket();
/**
* @brief myMessageBox is the messagebox from mapexecution that will be used for
* outgoing packets.
*/
messagebox *myMessageBox;
QUdpSocket outSocket;
QHostAddress target;
ServerQueue outPackets;
};
#endif // GSSERVER_H
| [
"[email protected]"
] | |
3cbd214d6a925b082ba9b5bad59f565cda6e41a7 | 5f056f1aac64414b071093da703c79a66f1ba6df | /include/boats.h | 6d410fb49952cc4703a0bb2598e1afe05f212bf4 | [] | no_license | MarcoAFC/BattleshipGenerator | 78d2853704f96ceecb670e5812b5f65a75165238 | ec940a2e1c3eb56a666b5b0095eb4b63f917a318 | refs/heads/master | 2020-07-04T04:11:35.252388 | 2019-09-03T21:04:40 | 2019-09-03T21:04:40 | 202,151,486 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 185 | h | #pragma once
class Boat{
public:
int size;
int orient;
int posX;
int posY;
Boat(int size, int orient);
};
class Subm{
public:
int posX;
int posY;
};
| [
"[email protected]"
] | |
10d72a7baf7d1e0ed6385abb04cb41897e224ba1 | b899013c03043a9bb2bacdab483ee19c0375265d | /d_03/ex02/ScavTrap.hpp | 3dc5889677c39d48596736f31df1fd4153e025f0 | [] | no_license | KaraboCoder/piscine-cpp | 81ef69967954ef3d26d74308db0ea1c6c37d469b | 8cabb3118f8bd6e1a94ff0e8ebd382be37ec3b9b | refs/heads/master | 2020-03-28T21:02:52.289947 | 2018-09-17T12:58:13 | 2018-09-17T12:58:13 | 149,124,840 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,171 | hpp | /* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ScavTrap.hpp :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: kngwato <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2018/06/08 13:41:08 by kngwato #+# #+# */
/* Updated: 2018/06/08 13:41:11 by kngwato ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef SCAVTRAP_HPP
#define SCAVTRAP_HPP
#include <iostream>
#include "ClapTrap.hpp"
class ScavTrap : public ClapTrap{
public:
ScavTrap(std::string name);
ScavTrap(const ScavTrap&);
~ScavTrap(void);
void challengeNewcomer() const;
};
#endif | [
"[email protected]"
] | |
c155fbd8912846cd293358bd16c35bc9e26d7abc | a7dc9df7ecc9438c96b7a33038a3c70f0ff5bc86 | /soa/service/zookeeper_configuration_service.cc | ceb488a5c9937205f9875202417179755017dec4 | [
"Apache-2.0"
] | permissive | duyet/BGateRTB | ca19a2f23fad6a5063ec4463a3049984ed09ec67 | ea1782f7cd89a15e64cd87a175816ee68aee8934 | refs/heads/master | 2022-07-24T03:45:05.099793 | 2022-07-17T11:20:43 | 2022-07-17T11:20:43 | 37,047,062 | 0 | 0 | Apache-2.0 | 2022-07-17T11:21:09 | 2015-06-08T05:10:18 | C++ | UTF-8 | C++ | false | false | 7,830 | cc | /** zookeeper_configuration_service.cc
Jeremy Barnes, 26 September 2012
Copyright (c) 2012 Datacratic Inc. All rights reserved.
Configuration service using Zookeeper.
*/
#include "zookeeper_configuration_service.h"
#include "soa/service/zookeeper.h"
#include "jml/utils/exc_assert.h"
#include <boost/algorithm/string.hpp>
#include <sys/utsname.h>
using namespace std;
using namespace ML;
namespace Datacratic {
std::string printZookeeperEventType(int type)
{
if (type == ZOO_CREATED_EVENT)
return "CREATED";
if (type == ZOO_DELETED_EVENT)
return "DELETED";
if (type == ZOO_CHANGED_EVENT)
return "CHANGED";
if (type == ZOO_CHILD_EVENT)
return "CHILD";
if (type == ZOO_SESSION_EVENT)
return "SESSION";
if (type == ZOO_NOTWATCHING_EVENT)
return "NOTWATCHING";
return ML::format("UNKNOWN(%d)", type);
}
std::string printZookeeperState(int state)
{
if (state == ZOO_EXPIRED_SESSION_STATE)
return "ZOO_EXPIRED_SESSION_STATE";
if (state == ZOO_AUTH_FAILED_STATE)
return "ZOO_AUTH_FAILED_STATE";
if (state == ZOO_CONNECTING_STATE)
return "ZOO_CONNECTING_STATE";
if (state == ZOO_ASSOCIATING_STATE)
return "ZOO_ASSOCIATING_STATE";
if (state == ZOO_CONNECTED_STATE)
return "ZOO_CONNECTED_STATE";
return ML::format("ZOO_UNKNOWN_STATE(%d)", state);
}
std::string printChangeType(ConfigurationService::ChangeType change)
{
switch (change)
{
#define CHANGE_CASE(change, str) \
case change: \
return str;
CHANGE_CASE(ConfigurationService::CREATED, "CREATED")
CHANGE_CASE(ConfigurationService::DELETED, "DELETED")
CHANGE_CASE(ConfigurationService::VALUE_CHANGED, "VALUE_CHANGED")
CHANGE_CASE(ConfigurationService::NEW_CHILD, "NEW_CHILD")
#undef CHANGE_CASE
}
ExcCheck(false, "Bad code path");
}
void
watcherFn(int type, int state, std::string const & path, void * watcherCtx)
{
typedef std::shared_ptr<ConfigurationService::Watch::Data> SharedPtr;
std::unique_ptr<SharedPtr> data(reinterpret_cast<SharedPtr *>(watcherCtx));
// SharedPtr * data = reinterpret_cast<SharedPtr *>(watcherCtx);
#if 0
cerr << "zookeeper_configuration_service.cc::watcherFn:type = " << printZookeeperEventType(type)
<< " state = " << printZookeeperState(state)
<< " path = " << path << " context "
<< watcherCtx << " data " << data->get() << endl << endl;
#endif
ConfigurationService::ChangeType change;
if (type == ZOO_CREATED_EVENT)
change = ConfigurationService::CREATED;
if (type == ZOO_DELETED_EVENT)
change = ConfigurationService::DELETED;
if (type == ZOO_CHANGED_EVENT)
change = ConfigurationService::VALUE_CHANGED;
if (type == ZOO_CHILD_EVENT)
change = ConfigurationService::NEW_CHILD;
auto & item = *data;
if (item->watchReferences > 0) {
#if 0
cerr << "watcherFn:calling with path " << path << " and change "
<< printChangeType(change) << endl;
#endif
item->onChange(path, change);
}
}
ZookeeperCallbackType
getWatcherFn(const ConfigurationService::Watch & watch)
{
if (!watch)
return nullptr;
return watcherFn;
}
/*****************************************************************************/
/* ZOOKEEPER CONFIGURATION SERVICE */
/*****************************************************************************/
ZookeeperConfigurationService::
ZookeeperConfigurationService()
{
}
ZookeeperConfigurationService::
ZookeeperConfigurationService(std::string host,
std::string prefix,
std::string location,
int timeout)
{
init(std::move(host), std::move(prefix), std::move(location));
}
ZookeeperConfigurationService::
~ZookeeperConfigurationService()
{
}
void
ZookeeperConfigurationService::
init(std::string host,
std::string prefix,
std::string location,
int timeout)
{
currentLocation = std::move(location);
zoo.reset(new ZookeeperConnection());
zoo->connect(host, timeout);
if (!prefix.empty() && prefix[prefix.size() - 1] != '/')
prefix = prefix + "/";
if (!prefix.empty() && prefix[0] != '/')
prefix = "/" + prefix;
this->prefix = std::move(prefix);
currentInstallation = this->prefix;
zoo->createPath(this->prefix);
}
Json::Value
ZookeeperConfigurationService::
getJson(const std::string & key, Watch watch)
{
ExcAssert(zoo);
auto val = zoo->readNode(prefix + key, getWatcherFn(watch),
watch.get());
try {
if (val == "")
return Json::Value();
return Json::parse(val);
} catch (...) {
cerr << "error parsing JSON entry '" << val << "'" << endl;
throw;
}
}
void
ZookeeperConfigurationService::
set(const std::string & key,
const Json::Value & value)
{
//cerr << "setting " << key << " to " << value << endl;
// TODO: race condition
if (!zoo->createNode(prefix + key, boost::trim_copy(value.toString()),
false, false,
false /* must succeed */,
true /* create path */).second)
zoo->writeNode(prefix + key, boost::trim_copy(value.toString()));
ExcAssert(zoo);
}
std::string
ZookeeperConfigurationService::
setUnique(const std::string & key,
const Json::Value & value)
{
//cerr << "setting unique " << key << " to " << value << endl;
ExcAssert(zoo);
return zoo->createNode(prefix + key, boost::trim_copy(value.toString()),
true /* ephemeral */,
false /* sequential */,
true /* mustSucceed */,
true /* create path */)
.first;
}
std::vector<std::string>
ZookeeperConfigurationService::
getChildren(const std::string & key,
Watch watch)
{
//cerr << "getChildren " << key << " watch " << watch << endl;
return zoo->getChildren(prefix + key,
false /* fail if not there */,
getWatcherFn(watch),
watch.get());
}
bool
ZookeeperConfigurationService::
forEachEntry(const OnEntry & onEntry,
const std::string & startPrefix) const
{
//cerr << "forEachEntry: startPrefix = " << startPrefix << endl;
ExcAssert(zoo);
std::function<bool (const std::string &)> doNode
= [&] (const std::string & currentPrefix)
{
//cerr << "doNode " << currentPrefix << endl;
string r = zoo->readNode(prefix + currentPrefix);
//cerr << "r = " << r << endl;
if (r != "") {
if (!onEntry(currentPrefix, Json::parse(r)))
return false;
}
vector<string> children = zoo->getChildren(prefix + currentPrefix,
false);
for (auto child: children) {
//cerr << "child = " << child << endl;
string newPrefix = currentPrefix + "/" + child;
if (currentPrefix.empty())
newPrefix = child;
if (!doNode(newPrefix))
return false;
}
return true;
};
if (!zoo->nodeExists(prefix + startPrefix)) {
return true;
}
return doNode(startPrefix);
}
void
ZookeeperConfigurationService::
removePath(const std::string & path)
{
ExcAssert(zoo);
zoo->removePath(prefix + path);
}
} // namespace Datacratic
| [
"root@ubuntu-virtual-machine.(none)"
] | root@ubuntu-virtual-machine.(none) |
80ad181ca6867468473c3eb246106241c571c3fd | 76a62a262dbc7e4037147870d587f6e5d9d27583 | /Kernel_Force_Delete/Kernel_Force_Delete.cc | ca3ee9d6b0feabb5631a60ef8f08d19bf9006b60 | [] | no_license | codingman/Kernel-Force-Delete | 5ab0cdf3b00a7bdac7e556602fb49da203456514 | a617982f016ef87007e9ec3b457c4e0619e8f97e | refs/heads/master | 2021-09-15T12:53:09.232713 | 2018-06-02T03:40:41 | 2018-06-02T03:40:41 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,208 | cc | #include "Kernel_Force_Delete.h"
bool Kernel_Force_Delete::Delete_File_Mode1(wchar_t *path)
{
HANDLE fileHandle;
NTSTATUS result;
IO_STATUS_BLOCK ioBlock;
DEVICE_OBJECT *device_object = nullptr;
void* object = NULL;
OBJECT_ATTRIBUTES fileObject;
UNICODE_STRING uPath;
PEPROCESS eproc = IoGetCurrentProcess();
//switch context to UserMode
KeAttachProcess(eproc);
RtlInitUnicodeString(&uPath, path);
InitializeObjectAttributes(&fileObject,
&uPath,
OBJ_CASE_INSENSITIVE,
NULL,
NULL);
result = IoCreateFileSpecifyDeviceObjectHint(
&fileHandle,
SYNCHRONIZE | FILE_WRITE_ATTRIBUTES | FILE_READ_ATTRIBUTES | FILE_READ_DATA, //0x100181
&fileObject,
&ioBlock,
0,
0,
FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, //FILE_SHARE_VALID_FLAGS,
FILE_OPEN,
FILE_NON_DIRECTORY_FILE | FILE_SYNCHRONOUS_IO_NONALERT,//0x60,
0,
0,
CreateFileTypeNone,
0,
IO_IGNORE_SHARE_ACCESS_CHECK,
device_object);
if (result != STATUS_SUCCESS)
{
DbgPrint("error in IoCreateFileSpecifyDeviceObjectHint");
goto _Error;
}
result = ObReferenceObjectByHandle(fileHandle, 0, 0, 0, &object, 0);
if (result != STATUS_SUCCESS)
{
DbgPrint("error in ObReferenceObjectByHandle");
ZwClose(fileHandle);
goto _Error;
}
/*
METHOD 1
*/
((FILE_OBJECT*)object)->SectionObjectPointer->ImageSectionObject = 0;
((FILE_OBJECT*)object)->DeleteAccess = 1;
result = ZwDeleteFile(&fileObject);
ObDereferenceObject(object);
ZwClose(fileHandle);
if (result != STATUS_SUCCESS)
{
DbgPrint("\n[+]error in ZwDeleteFile");
goto _Error;
}
result = ZwDeleteFile(&fileObject);
if (NT_SUCCESS(result))
{
KeDetachProcess();
return true;
}
_Error:
KeDetachProcess();
return false;
}
bool Kernel_Force_Delete::Unlock_File_Mode1(wchar_t *path)
{
HANDLE fileHandle;
NTSTATUS result;
IO_STATUS_BLOCK ioBlock;
DEVICE_OBJECT *device_object = nullptr;
void* object = NULL;
OBJECT_ATTRIBUTES fileObject;
UNICODE_STRING uPath;
PEPROCESS eproc = IoGetCurrentProcess();
//switch context to UserMode
KeAttachProcess(eproc);
RtlInitUnicodeString(&uPath, path);
InitializeObjectAttributes(&fileObject,
&uPath,
OBJ_CASE_INSENSITIVE,
NULL,
NULL);
result = IoCreateFileSpecifyDeviceObjectHint(
&fileHandle,
SYNCHRONIZE | FILE_WRITE_ATTRIBUTES | FILE_READ_ATTRIBUTES | FILE_READ_DATA, //0x100181
&fileObject,
&ioBlock,
0,
0,
FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, //FILE_SHARE_VALID_FLAGS,
FILE_OPEN,
FILE_NON_DIRECTORY_FILE | FILE_SYNCHRONOUS_IO_NONALERT,//0x60,
0,
0,
CreateFileTypeNone,
0,
IO_IGNORE_SHARE_ACCESS_CHECK,
device_object);
if (result != STATUS_SUCCESS)
{
DbgPrint("error in IoCreateFileSpecifyDeviceObjectHint");
goto _Error;
}
result = ObReferenceObjectByHandle(fileHandle, 0, 0, 0, &object, 0);
if (result != STATUS_SUCCESS)
{
DbgPrint("error in ObReferenceObjectByHandle");
ZwClose(fileHandle);
goto _Error;
}
/*
METHOD 1
*/
((FILE_OBJECT*)object)->SectionObjectPointer->ImageSectionObject = 0;
((FILE_OBJECT*)object)->DeleteAccess = 1;
ObDereferenceObject(object);
ZwClose(fileHandle);
KeDetachProcess();
return true;
_Error:
KeDetachProcess();
return false;
}
| [
"[email protected]"
] | |
3b2e3d1ebd0c68579524e3388c0e77e600d0d45b | 30a6cb4273fc2f153bc705ae5176e4d726ebf364 | /src/infra/solver.h | 17df2189cf2042036526a3204d9fd03f6a24cd1c | [
"MIT"
] | permissive | Rixxuss/AI_Miss_Cann | 30bb4e20780810f4d3e39e9638e1215292bd0071 | e6f727c7d4be9a6dcceb72b5876047fa118db0f3 | refs/heads/master | 2022-05-20T15:20:13.706696 | 2019-04-07T19:43:59 | 2019-04-07T19:43:59 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,138 | h | #ifndef _INFRA_SOLVER_H_
#define _INFRA_SOLVER_H_
#include "../global.h"
#include "problem.h"
#include "node.h"
namespace ai {
/**
* Deque to store the Nodes pointers.
*/
typedef std::deque<Node*> store_t;
/**
* Vector of Node pointers which are the solution.
*/
typedef std::vector<const Node*> solution_t;
/**
* Solver is a Singleton Class that defines the solver of the problem.
* It has argument and method like:
* ° Frontier
* ° Explored
* ° Breadth_First_Search
*
* @author Eduardo Culau
* @version 1.5
* @since 1.4
*/
class Solver
{
public:
/**
* Return the current instance or create one if it don't exist.
*
* @return Solver* Setting pointer
*/
static Solver* get(){
if ( !_instance ) {
_instance = new Solver;
}
return _instance;
}
/**
* Applies the Breadth First Search on the problem and solve it.
*
* @return solution_t solution of the problem
*/
static solution_t Breadth_First_Search ();
/**
* Travel back to the origin to get all solution nodes.
*
* @param node pointer of the last node
* @return solution_t solution of the problem
*/
static solution_t Solution (const Node* node);
private:
/**
* The single instance of the class.
*/
static Solver *_instance;
/**
* Private Constructor
*/
Solver(){}
/**
* Private Destructor
*/
~Solver(){}
/**
* Applies the Breadth First Search on the problem and solve it.
*
* @param node pointer of the last node
* @return solution_t solution of the problem
*/
static bool stateFind (const store_t& dq, const State& state);
/**
* Deque to store the Nodes* in the frontier. Used to solve the problem.
*/
store_t frontier;
/**
* Deque to store the Nodes* that was explored. Used to solve the problem.
*/
store_t explored;
};
}
#endif
| [
"[email protected]"
] | |
afb40dc76a9236ece17b20bc26d531a23e35330f | 594975831ea01c49bc9a3253ca1ccbac9f4f5eea | /cgfFrame/include/CAL/BwQuaternion.h | 9e46871b4152f699d8b517ba77db5a6d9db4d278 | [] | no_license | WarfareCode/linux | 0344589884de3d345b50fa8ba9cad29e94feb9c6 | a0ef3d4da620f3eeb1cf54fa2a86e14c9b96c65a | refs/heads/master | 2021-10-09T18:32:47.071838 | 2018-12-25T08:14:56 | 2018-12-25T08:14:56 | null | 0 | 0 | null | null | null | null | GB18030 | C++ | false | false | 7,646 | h |
#ifndef __BW_Quaternion_H__
#define __BW_Quaternion_H__
#include "BwCal.h"
#include "BwMatrix3.h"
#include "BwMath.h"
#include <assert.h>
//--------------------------------------------------------------------------------
// 作者:皮学贤
// 时间:2010-06-07
// 功能:四元组(用于旋转控制)
//================================================================================
namespace BwCal
{
class BW_CAL_API Quaternion
{
public:
inline Quaternion ( Real fW = 1.0, Real fX = 0.0, Real fY = 0.0, Real fZ = 0.0)
{
w = fW;
x = fX;
y = fY;
z = fZ;
}
/// Construct a quaternion from a rotation matrix
inline Quaternion(const Matrix3& rot)
{
this->FromRotationMatrix(rot);
}
/// Construct a quaternion from an angle/axis
inline Quaternion(const Radian& rfAngle, const Vec3& rkAxis)
{
this->FromAngleAxis(rfAngle, rkAxis);
}
/// Construct a quaternion from 3 orthonormal local axes
inline Quaternion(const Vec3& xaxis, const Vec3& yaxis, const Vec3& zaxis)
{
this->FromAxes(xaxis, yaxis, zaxis);
}
/// Construct a quaternion from 3 orthonormal local axes
inline Quaternion(const Vec3* akAxis)
{
this->FromAxes(akAxis);
}
/// Construct a quaternion from 4 manual w/x/y/z values
inline Quaternion(Real* valptr)
{
memcpy(&w, valptr, sizeof(Real)*4);
}
/// Array accessor operator
inline Real operator [] ( const size_t i ) const
{
assert( i < 4 );
return *(&w+i);
}
/// Array accessor operator
inline Real& operator [] ( const size_t i )
{
assert( i < 4 );
return *(&w+i);
}
/// Pointer accessor for direct copying
inline Real* ptr()
{
return &w;
}
/// Pointer accessor for direct copying
inline const Real* ptr() const
{
return &w;
}
void FromRotationMatrix (const Matrix3& kRot);
void ToRotationMatrix (Matrix3& kRot) const;
void FromAngleAxis (const Radian& rfAngle, const Vec3& rkAxis);
void ToAngleAxis (Radian& rfAngle, Vec3& rkAxis) const;
inline void ToAngleAxis (Degree& dAngle, Vec3& rkAxis) const {
Radian rAngle;
ToAngleAxis ( rAngle, rkAxis );
dAngle = rAngle;
}
void FromAxes (const Vec3* akAxis);
void FromAxes (const Vec3& xAxis, const Vec3& yAxis, const Vec3& zAxis);
void ToAxes (Vec3* akAxis) const;
void ToAxes (Vec3& xAxis, Vec3& yAxis, Vec3& zAxis) const;
/// Get the local x-axis
Vec3 xAxis(void) const;
/// Get the local y-axis
Vec3 yAxis(void) const;
/// Get the local z-axis
Vec3 zAxis(void) const;
inline Quaternion& operator= (const Quaternion& rkQ)
{
w = rkQ.w;
x = rkQ.x;
y = rkQ.y;
z = rkQ.z;
return *this;
}
Quaternion operator+ (const Quaternion& rkQ) const;
Quaternion operator- (const Quaternion& rkQ) const;
Quaternion operator* (const Quaternion& rkQ) const;
Quaternion operator* (Real fScalar) const;
BW_CAL_API friend Quaternion operator* (Real fScalar,
const Quaternion& rkQ);
Quaternion operator- () const;
inline bool operator== (const Quaternion& rhs) const
{
return (rhs.x == x) && (rhs.y == y) &&
(rhs.z == z) && (rhs.w == w);
}
inline bool operator!= (const Quaternion& rhs) const
{
return !operator==(rhs);
}
// functions of a quaternion
Real Dot (const Quaternion& rkQ) const; // dot product
Real Norm () const; // squared-length
/// Normalises this quaternion, and returns the previous length
Real normalise(void);
Quaternion Inverse () const; // apply to non-zero quaternion
Quaternion UnitInverse () const; // apply to unit-length quaternion
Quaternion Exp () const;
Quaternion Log () const;
// rotation of a vector by a quaternion
Vec3 operator* (const Vec3& rkVector) const;
/** Calculate the local roll element of this quaternion.
@param reprojectAxis By default the method returns the 'intuitive' result
that is, if you projected the local Y of the quaternion onto the X and
Y axes, the angle between them is returned. If set to false though, the
result is the actual yaw that will be used to implement the quaternion,
which is the shortest possible path to get to the same orientation and
may involve less axial rotation.
*/
Radian getRoll(bool reprojectAxis = true) const;
/** Calculate the local pitch element of this quaternion
@param reprojectAxis By default the method returns the 'intuitive' result
that is, if you projected the local Z of the quaternion onto the X and
Y axes, the angle between them is returned. If set to true though, the
result is the actual yaw that will be used to implement the quaternion,
which is the shortest possible path to get to the same orientation and
may involve less axial rotation.
*/
Radian getPitch(bool reprojectAxis = true) const;
/** Calculate the local yaw element of this quaternion
@param reprojectAxis By default the method returns the 'intuitive' result
that is, if you projected the local Z of the quaternion onto the X and
Z axes, the angle between them is returned. If set to true though, the
result is the actual yaw that will be used to implement the quaternion,
which is the shortest possible path to get to the same orientation and
may involve less axial rotation.
*/
Radian getYaw(bool reprojectAxis = true) const;
/// Equality with tolerance (tolerance is max angle difference)
bool equals(const Quaternion& rhs, const Radian& tolerance) const;
/** return true if the Quat represents a zero rotation, and therefore can be ignored in computations.*/
bool zeroRotation() const { return x==0.0 && y==0.0 && z==0.0 && w==1.0; }
// spherical linear interpolation
static Quaternion Slerp (Real fT, const Quaternion& rkP,
const Quaternion& rkQ, bool shortestPath = false);
static Quaternion SlerpExtraSpins (Real fT,
const Quaternion& rkP, const Quaternion& rkQ,
int iExtraSpins);
// setup for spherical quadratic interpolation
static void Intermediate (const Quaternion& rkQ0,
const Quaternion& rkQ1, const Quaternion& rkQ2,
Quaternion& rka, Quaternion& rkB);
// spherical quadratic interpolation
static Quaternion Squad (Real fT, const Quaternion& rkP,
const Quaternion& rkA, const Quaternion& rkB,
const Quaternion& rkQ, bool shortestPath = false);
// normalised linear interpolation - faster but less accurate (non-constant rotation velocity)
static Quaternion nlerp(Real fT, const Quaternion& rkP,
const Quaternion& rkQ, bool shortestPath = false);
// cutoff for sine near zero
static const Real ms_fEpsilon;
// special values
static const Quaternion ZERO;
static const Quaternion IDENTITY;
Real w, x, y, z;
/** Function for writing to a stream. Outputs "Quaternion(w, x, y, z)" with w,x,y,z
being the member values of the quaternion.
*/
//inline friend std::ostream& operator <<
// ( std::ostream& o, const Quaternion& q )
//{
// o << "Quaternion(" << q.w << ", " << q.x << ", " << q.y << ", " << q.z << ")";
// return o;
//}
};
}
#endif
| [
"[email protected]"
] | |
56019cfa8fdc629ee9e81c9ce58c308018c3c7d7 | 3bc0d20e8a1a23da4399cd9e86ebc8132c8f1640 | /src/cpp/cpp_bopt.cpp | 49a037ad23df262ec027178ff8bc1a55a46446f3 | [] | no_license | RomainBrault/OV2SGD | 8fbd3de1ee826532d4624b1d688406ef968efc8b | eee48bd8dcbbe9c5de5ef7ceee91efb2a8017fe3 | refs/heads/master | 2021-01-19T05:46:27.357618 | 2016-10-04T09:15:35 | 2016-10-04T09:15:35 | 65,005,602 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 686 | cpp | // #include "bopt.hpp"
// using namespace Eigen;
// using namespace std;
// using namespace sitmo;
// BDSOVK::BDSOVK(const loss_t & gloss,
// const feature_map_t & feature_map,
// const gamma_t & gamma, double nu1, double nu2, long int T,
// long int p,
// long int batch, long int block, long int T_cap, double cond) :
// _gloss(gloss),
// _phi(feature_map),
// _gamma(gamma),
// _nu1(nu1), _nu2(nu2), _T(T), _T_cap(T_cap), _d(0), _p(p),
// _batch(batch), _block(block), _cond(cond),
// _coefs(2 * feature_map.r() * get_T_cap() * block),
// _B(get_r(), get_p())
// {
// initParallel();
// }
| [
"[email protected]"
] | |
ec52582d8f0d071ccbe3987a0bd2e4b9dbc08f67 | b88922ee39b1d0032b51cf9171162fadbf0367fa | /coupledFoam/test/0/oil.U | e53c7cd764851e30b8eacc4a6d112a3a17105ab7 | [] | no_license | FoamScience/OpenRSR.tutorials | 57f7a185bc5ef158ecf59bd1ab66da2b20ca064e | 5e3a14e7895c257bae69cb228d468aceb66866fe | refs/heads/master | 2020-06-18T07:35:03.207734 | 2020-03-08T11:53:55 | 2020-03-08T11:53:55 | 196,216,260 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,169 | u | /*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | foam-extend: Open Source CFD |
| \\ / O peration | Version: 4.0 |
| \\ / A nd | Web: http://www.foam-extend.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class volVectorField;
location "0";
object oil.U;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensions [ 0 1 -1 0 0 0 0 ];
internalField uniform ( 0 0 0 );
boundaryField
{
inlet
{
type fixedValue;
value uniform ( 0 0 0 );
}
outlet
{
type zeroGradient;
}
frontAndBack
{
type empty;
}
}
// ************************************************************************* //
| [
"[email protected]"
] | |
c5983ea2892676266499d90f8de359ab3a13e949 | b45579daa34c7d333abd2d60664c53c89169a967 | /src/qt/bitcoinunits.cpp | 0b35cf6f525ff31ddb7b2617ad74c2d9c7c51c23 | [
"MIT"
] | permissive | xstart11/coin1 | c3c80807990d1034ad6c14908956a6903ce17bed | af9ca8f0e34634a91da5ae8aec35094b1af4ccb6 | refs/heads/master | 2020-03-28T22:03:20.291029 | 2018-09-18T13:11:51 | 2018-09-18T13:11:51 | 149,202,082 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 8,117 | cpp | // Copyright (c) 2011-2014 The Bitcoin developers
// Copyright (c) 2014-2015 The Dash developers
// Copyright (c) 2015-2017 The PIVX developers
// Copyright (c) 2018 The Daral developers
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include "bitcoinunits.h"
#include "chainparams.h"
#include "primitives/transaction.h"
#include <QSettings>
#include <QStringList>
BitcoinUnits::BitcoinUnits(QObject* parent) : QAbstractListModel(parent),
unitlist(availableUnits())
{
}
QList<BitcoinUnits::Unit> BitcoinUnits::availableUnits()
{
QList<BitcoinUnits::Unit> unitlist;
unitlist.append(DRL);
unitlist.append(mDRL);
unitlist.append(uDRL);
return unitlist;
}
bool BitcoinUnits::valid(int unit)
{
switch (unit) {
case DRL:
case mDRL:
case uDRL:
return true;
default:
return false;
}
}
QString BitcoinUnits::id(int unit)
{
switch (unit) {
case DRL:
return QString("daral");
case mDRL:
return QString("mdaral");
case uDRL:
return QString::fromUtf8("udaral");
default:
return QString("???");
}
}
QString BitcoinUnits::name(int unit)
{
if (Params().NetworkID() == CBaseChainParams::MAIN) {
switch (unit) {
case DRL:
return QString("DRL");
case mDRL:
return QString("mDRL");
case uDRL:
return QString::fromUtf8("μDRL");
default:
return QString("???");
}
} else {
switch (unit) {
case DRL:
return QString("tDRL");
case mDRL:
return QString("mtDRL");
case uDRL:
return QString::fromUtf8("μtDRL");
default:
return QString("???");
}
}
}
QString BitcoinUnits::description(int unit)
{
if (Params().NetworkID() == CBaseChainParams::MAIN) {
switch (unit) {
case DRL:
return QString("DRL");
case mDRL:
return QString("Milli-DRL (1 / 1" THIN_SP_UTF8 "000)");
case uDRL:
return QString("Micro-DRL (1 / 1" THIN_SP_UTF8 "000" THIN_SP_UTF8 "000)");
default:
return QString("???");
}
} else {
switch (unit) {
case DRL:
return QString("TestDRLs");
case mDRL:
return QString("Milli-TestDRL (1 / 1" THIN_SP_UTF8 "000)");
case uDRL:
return QString("Micro-TestDRL (1 / 1" THIN_SP_UTF8 "000" THIN_SP_UTF8 "000)");
default:
return QString("???");
}
}
}
qint64 BitcoinUnits::factor(int unit)
{
switch (unit) {
case DRL:
return 100000000;
case mDRL:
return 100000;
case uDRL:
return 100;
default:
return 100000000;
}
}
int BitcoinUnits::decimals(int unit)
{
switch (unit) {
case DRL:
return 8;
case mDRL:
return 5;
case uDRL:
return 2;
default:
return 0;
}
}
QString BitcoinUnits::format(int unit, const CAmount& nIn, bool fPlus, SeparatorStyle separators)
{
// Note: not using straight sprintf here because we do NOT want
// localized number formatting.
if (!valid(unit))
return QString(); // Refuse to format invalid unit
qint64 n = (qint64)nIn;
qint64 coin = factor(unit);
int num_decimals = decimals(unit);
qint64 n_abs = (n > 0 ? n : -n);
qint64 quotient = n_abs / coin;
qint64 remainder = n_abs % coin;
QString quotient_str = QString::number(quotient);
QString remainder_str = QString::number(remainder).rightJustified(num_decimals, '0');
// Use SI-style thin space separators as these are locale independent and can't be
// confused with the decimal marker.
QChar thin_sp(THIN_SP_CP);
int q_size = quotient_str.size();
if (separators == separatorAlways || (separators == separatorStandard && q_size > 4))
for (int i = 3; i < q_size; i += 3)
quotient_str.insert(q_size - i, thin_sp);
if (n < 0)
quotient_str.insert(0, '-');
else if (fPlus && n > 0)
quotient_str.insert(0, '+');
if (num_decimals <= 0)
return quotient_str;
return quotient_str + QString(".") + remainder_str;
}
// TODO: Review all remaining calls to BitcoinUnits::formatWithUnit to
// TODO: determine whether the output is used in a plain text context
// TODO: or an HTML context (and replace with
// TODO: BtcoinUnits::formatHtmlWithUnit in the latter case). Hopefully
// TODO: there aren't instances where the result could be used in
// TODO: either context.
// NOTE: Using formatWithUnit in an HTML context risks wrapping
// quantities at the thousands separator. More subtly, it also results
// in a standard space rather than a thin space, due to a bug in Qt's
// XML whitespace canonicalisation
//
// Please take care to use formatHtmlWithUnit instead, when
// appropriate.
QString BitcoinUnits::formatWithUnit(int unit, const CAmount& amount, bool plussign, SeparatorStyle separators)
{
return format(unit, amount, plussign, separators) + QString(" ") + name(unit);
}
QString BitcoinUnits::formatHtmlWithUnit(int unit, const CAmount& amount, bool plussign, SeparatorStyle separators)
{
QString str(formatWithUnit(unit, amount, plussign, separators));
str.replace(QChar(THIN_SP_CP), QString(THIN_SP_HTML));
return QString("<span style='white-space: nowrap;'>%1</span>").arg(str);
}
QString BitcoinUnits::floorWithUnit(int unit, const CAmount& amount, bool plussign, SeparatorStyle separators)
{
QSettings settings;
int digits = settings.value("digits").toInt();
QString result = format(unit, amount, plussign, separators);
if (decimals(unit) > digits) result.chop(decimals(unit) - digits);
return result + QString(" ") + name(unit);
}
QString BitcoinUnits::floorHtmlWithUnit(int unit, const CAmount& amount, bool plussign, SeparatorStyle separators)
{
QString str(floorWithUnit(unit, amount, plussign, separators));
str.replace(QChar(THIN_SP_CP), QString(THIN_SP_HTML));
return QString("<span style='white-space: nowrap;'>%1</span>").arg(str);
}
bool BitcoinUnits::parse(int unit, const QString& value, CAmount* val_out)
{
if (!valid(unit) || value.isEmpty())
return false; // Refuse to parse invalid unit or empty string
int num_decimals = decimals(unit);
// Ignore spaces and thin spaces when parsing
QStringList parts = removeSpaces(value).split(".");
if (parts.size() > 2) {
return false; // More than one dot
}
QString whole = parts[0];
QString decimals;
if (parts.size() > 1) {
decimals = parts[1];
}
if (decimals.size() > num_decimals) {
return false; // Exceeds max precision
}
bool ok = false;
QString str = whole + decimals.leftJustified(num_decimals, '0');
if (str.size() > 18) {
return false; // Longer numbers will exceed 63 bits
}
CAmount retvalue(str.toLongLong(&ok));
if (val_out) {
*val_out = retvalue;
}
return ok;
}
QString BitcoinUnits::getAmountColumnTitle(int unit)
{
QString amountTitle = QObject::tr("Amount");
if (BitcoinUnits::valid(unit)) {
amountTitle += " (" + BitcoinUnits::name(unit) + ")";
}
return amountTitle;
}
int BitcoinUnits::rowCount(const QModelIndex& parent) const
{
Q_UNUSED(parent);
return unitlist.size();
}
QVariant BitcoinUnits::data(const QModelIndex& index, int role) const
{
int row = index.row();
if (row >= 0 && row < unitlist.size()) {
Unit unit = unitlist.at(row);
switch (role) {
case Qt::EditRole:
case Qt::DisplayRole:
return QVariant(name(unit));
case Qt::ToolTipRole:
return QVariant(description(unit));
case UnitRole:
return QVariant(static_cast<int>(unit));
}
}
return QVariant();
}
CAmount BitcoinUnits::maxMoney()
{
return Params().MaxMoneyOut();
}
| [
"[email protected]"
] | |
7acf29a5deb6fd697470e803013029a5c799ac02 | 95289c6a482737e356f78ce26f7c0c3c76b2418e | /c/algorithms/algorithms/qsort.cpp | 43c384e26e73405e733bbb2473da3912e885cb9e | [] | no_license | zhengjinwei123/cplusplus | 045e27967d7b716308f26213711306131a69dc39 | 4477ce9eb5c2b3e58620e7e48a704d62b4352e30 | refs/heads/master | 2020-03-13T20:24:00.319770 | 2019-04-24T08:25:22 | 2019-04-24T08:25:22 | 131,273,389 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 38 | cpp | #include "stdafx.h"
#include "qsort.h" | [
"zhengjinwei123"
] | zhengjinwei123 |
523351f5e7efbb691b4214204399082a94132ba6 | 6690ff8dae019b3c018c387e2e756baba0627463 | /mainobject.h | d2bcb68ece89bf8c83191f62e5f88ebbec085caf | [] | no_license | ondrejandrej/sql-terminal | ff8e352731d69affe7497c117e0d310d43ec79a6 | c62eb74961a5b098034cc07004035d422d072425 | refs/heads/master | 2021-01-10T18:44:43.577707 | 2013-07-23T09:58:27 | 2013-07-23T09:58:27 | 10,526,333 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,356 | h | #ifndef MAINOBJECT_H
#define MAINOBJECT_H
#include <QObject>
#include <QFont>
#include <QSettings>
#include <QMap>
#include <QDeclarativeContext>
#include "qmlapplicationviewer.h"
#include "utils.h"
class MainObject : public QObject
{
Q_OBJECT
public:
explicit MainObject(QObject *parent = 0);
~MainObject();
signals:
public slots:
void processCommand(QString prompt, QString command);
void loadData();
void createDatabase();
private:
QFont baseFont;
QmlApplicationViewer viewer;
QDeclarativeContext &context;
TextBuffer console;
QString incompleteCmd;
CommandHistory cmdHistory;
QMap<QString, QString> parameters;
bool setParameter(const QString param, const QString val);
void createDBConnection();
void printHelp();
void runQuery(QString query);
void loadSettings()
{
parameters["fontsize"] = "9";
parameters["bgcolor"] = "lightblue";
parameters["fgcolor"] = "black";
QSettings settings("Cute Projects", "SQL Terminal");
QMapIterator<QString, QString> i(parameters);
while(i.hasNext()) {
i.next();
context.setContextProperty( i.key(),
settings.value(i.key(), i.value()));
}
cmdHistory.setData(settings.value("Command history").toStringList());
}
QTimer *timer;
QString index_to_load;
};
#endif // MAINOBJECT_H
| [
"[email protected]"
] | |
34f3ef0baf5692710b9999bfaf52f3117a602134 | b18d49d1736fd71f2f731df82772857bf755a490 | /assignment_3/count_ones.cpp | 352c88a434d404c24260edc28d7ad3cb4031b10f | [] | no_license | wenleeqc/cs780c | 50f0962fce72d6ae8d71e2b706bf4a90fe8eb0cf | 6849249e25816dcb83c46d3d1a472ed5abe2a1ee | refs/heads/main | 2023-07-18T22:09:27.717601 | 2021-09-10T15:20:02 | 2021-09-10T15:20:02 | 405,100,920 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 672 | cpp | #include <iostream>
using namespace std;
// helper function
// count ones of current number
int countCurrentNumber(int num) {
int count = 0;
int currentNumber = num;
while (currentNumber) {
// check if last digit is equal to one
if (currentNumber % 10 == 1) {
count++;
}
// remove last digit
currentNumber /= 10;
}
return count;
}
int countOnes(int num) {
int totalCount = 0;
for (int i = 1; i <= num; i++) {
totalCount += countCurrentNumber(i);
}
return totalCount;
}
int main()
{
int ones = countOnes(15); // return 8
cout << "Number of ones: " << ones << endl;
} | [
"[email protected]"
] | |
af8665c049015828bdb3ff740e17bee6cb4b4817 | b8ee6cd9e4154637dcd6f2363f10ecdb6f4c1d49 | /src/phEngine/engine/animation/AnimationComponent.h | 805d54ff5ff911847e10f5ca5ee4ddd137943a80 | [] | no_license | Foxious/phEngine | c6cffb816b3821ad7e6201e64054f9731ec25afe | dd9da22c7a9bebbd04cc5194219f94f545a16719 | refs/heads/master | 2021-01-22T17:58:09.983902 | 2013-05-08T21:56:25 | 2013-05-08T21:56:25 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,620 | h | #ifndef ANIMATION_COMPONENT_H
#define ANIMATION_COMPONENT_H
#include <string>
#include <vector>
#include "Texture.h"
#include "Vector.h"
#include "XForm.h"
struct AnimationData
{
unsigned int startFrame;
std::vector<float> frames;
std::string name;
};
enum PlaybackFlags
{
Anim_Loop = 0x01,
};
enum AnimationStates
{
Anim_Playing = 0x01,
Anim_Paused = 0x02,
Anim_Finished = 0x04,
};
// Class that handles the interaction betweeen animations
// ph TODO : change this into a factory/manager thingamy so that
// we're not constantly reading from disk to load these.
class AnimationComponent
{
public:
AnimationComponent()
: time(0.0f)
, currentFrame(0)
, playbackFlags(0)
{
currentAnimIndex = 0;
}
AnimationComponent(const std::string& jsonData);
void Update(float dt);
void PlayAnim(unsigned int index, int flags = 0);
void PlayAnim(const std::string& name, int flags = 0);
void PlayAnim(const char* name, int flags = 0);
void PauseAnim();
void ResumeAnim();
bool IsPlaying() { return (state & Anim_Playing) > 0; }
bool IsPaused() { return (state & Anim_Paused) > 0; }
void SetPlaybackSpeed(float amount) { playbackSpeed = amount; }
XForm GetXForm() { return mUV; }
void LoadFromJSON(const std::string& name);
private:
unsigned int FindAnim(const std::string& name);
void ParseJsonData(const std::string& jsonData);
const AnimationData& GetCurrentAnim();
void ClearData();
private:
float time;
unsigned int currentFrame;
XForm mUV;
std::vector<AnimationData> anims;
unsigned int currentAnimIndex;
int playbackFlags;
int state;
float playbackSpeed;
};
#endif | [
"[email protected]"
] | |
ddcb5edadcd3154876287fe564e73a46eea27c13 | 9f4027ffa2d1d613edace1a92bda1f48aa79e943 | /Assignment4/linked_list.h | 1874f02afb7c5439a5b791af0d2cd215a48b1f82 | [] | no_license | vinhvu97/CECS-275 | bda641bd643e27a3a5e868a8efd7f8443b9fd678 | f4e1cead5773c8676657a57d078b3088d5e055de | refs/heads/master | 2020-04-02T08:46:15.002748 | 2018-10-23T04:10:47 | 2018-10-23T04:10:47 | 154,259,471 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,716 | h | //Vinh Vu, 015347252, Assignment Four
#ifndef LINKED_LIST_H
#define LINKED_LIST_H
#pragma warning( disable : 4290 )
#include <vector>
#include <string>
using namespace std;
class LinkedList
{
public:
LinkedList();
LinkedList(vector<string> &strings);
LinkedList(const LinkedList &other);
LinkedList operator=(const LinkedList &other);
~LinkedList();
void add(string element);
void addToFront(string element);
void addToRear(string element);
void addAt(string element, int index) throw (string); // Indices: 0, 1, ..., n-1
void addBefore(string elementToAdd, string elementToAddBefore) throw(string);
void addAfter(string elementToAdd, string elementToAddAfter) throw(string);
void remove(string element) throw (string);
void removeAt(int index) throw (string); // Indices: 0, 1, ..., n-1
void removeFront() throw (string);
void removeRear() throw (string);
string getAt(int index) const throw (string) ; // Indices: 0, 1, ..., n-1
string getFront() const throw (string);
string getRear() const throw (string);
int getCount() const;
bool isEmpty() const;
bool isPresent(string element) const;
vector<string> toVector(bool sorted) const;
LinkedList operator+(const LinkedList &other);
LinkedList operator-(const LinkedList &other);
bool operator==(const LinkedList &other);
friend ostream &operator<<(ostream &os, const LinkedList &list);
private:
class Node
{
friend class LinkedList;
private:
inline Node(string data)
{
mPrevious = mNext = 0;
mData = data;
}
string mData;
Node *mPrevious;
Node *mNext;
};
void init();
void copyAll(const LinkedList &other);
void deleteAll();
int find(string s) const;
Node *mFront;
Node *mRear;
};
#endif
| [
"[email protected]"
] | |
7edc1d3214c1511713d6703ea1208f5a3e525082 | ac1c9fbc1f1019efb19d0a8f3a088e8889f1e83c | /out/release/gen/services/network/public/mojom/cors_origin_pattern.mojom-blink.h | 4f323362652d2f3e1ed9b3ad63118287ade4ffe8 | [
"BSD-3-Clause"
] | permissive | xueqiya/chromium_src | 5d20b4d3a2a0251c063a7fb9952195cda6d29e34 | d4aa7a8f0e07cfaa448fcad8c12b29242a615103 | refs/heads/main | 2022-07-30T03:15:14.818330 | 2021-01-16T16:47:22 | 2021-01-16T16:47:22 | 330,115,551 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 21,845 | h | // services/network/public/mojom/cors_origin_pattern.mojom-blink.h is auto generated by mojom_bindings_generator.py, do not edit
// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef SERVICES_NETWORK_PUBLIC_MOJOM_CORS_ORIGIN_PATTERN_MOJOM_BLINK_H_
#define SERVICES_NETWORK_PUBLIC_MOJOM_CORS_ORIGIN_PATTERN_MOJOM_BLINK_H_
#include <stdint.h>
#include <limits>
#include <type_traits>
#include <utility>
#include "base/callback.h"
#include "base/macros.h"
#include "base/optional.h"
#include "mojo/public/cpp/bindings/mojo_buildflags.h"
#if BUILDFLAG(MOJO_TRACE_ENABLED)
#include "base/trace_event/trace_event.h"
#endif
#include "mojo/public/cpp/bindings/clone_traits.h"
#include "mojo/public/cpp/bindings/equals_traits.h"
#include "mojo/public/cpp/bindings/lib/serialization.h"
#include "mojo/public/cpp/bindings/struct_ptr.h"
#include "mojo/public/cpp/bindings/struct_traits.h"
#include "mojo/public/cpp/bindings/union_traits.h"
#include "services/network/public/mojom/cors_origin_pattern.mojom-shared.h"
#include "services/network/public/mojom/cors_origin_pattern.mojom-blink-forward.h"
#include "url/mojom/origin.mojom-blink.h"
#include "mojo/public/cpp/bindings/lib/wtf_clone_equals_util.h"
#include "mojo/public/cpp/bindings/lib/wtf_hash_util.h"
#include "third_party/blink/renderer/platform/wtf/hash_functions.h"
#include "third_party/blink/renderer/platform/wtf/text/wtf_string.h"
#include "third_party/blink/public/platform/web_common.h"
namespace WTF {
struct network_mojom_internal_CorsPortMatchMode_DataHashFn {
static unsigned GetHash(const ::network::mojom::CorsPortMatchMode& value) {
using utype = std::underlying_type<::network::mojom::CorsPortMatchMode>::type;
return DefaultHash<utype>::Hash().GetHash(static_cast<utype>(value));
}
static bool Equal(const ::network::mojom::CorsPortMatchMode& left, const ::network::mojom::CorsPortMatchMode& right) {
return left == right;
}
static const bool safe_to_compare_to_empty_or_deleted = true;
};
template <>
struct HashTraits<::network::mojom::CorsPortMatchMode>
: public GenericHashTraits<::network::mojom::CorsPortMatchMode> {
static_assert(true,
"-1000000 is a reserved enum value");
static_assert(true,
"-1000001 is a reserved enum value");
static const bool hasIsEmptyValueFunction = true;
static bool IsEmptyValue(const ::network::mojom::CorsPortMatchMode& value) {
return value == static_cast<::network::mojom::CorsPortMatchMode>(-1000000);
}
static void ConstructDeletedValue(::network::mojom::CorsPortMatchMode& slot, bool) {
slot = static_cast<::network::mojom::CorsPortMatchMode>(-1000001);
}
static bool IsDeletedValue(const ::network::mojom::CorsPortMatchMode& value) {
return value == static_cast<::network::mojom::CorsPortMatchMode>(-1000001);
}
};
} // namespace WTF
namespace WTF {
struct network_mojom_internal_CorsDomainMatchMode_DataHashFn {
static unsigned GetHash(const ::network::mojom::CorsDomainMatchMode& value) {
using utype = std::underlying_type<::network::mojom::CorsDomainMatchMode>::type;
return DefaultHash<utype>::Hash().GetHash(static_cast<utype>(value));
}
static bool Equal(const ::network::mojom::CorsDomainMatchMode& left, const ::network::mojom::CorsDomainMatchMode& right) {
return left == right;
}
static const bool safe_to_compare_to_empty_or_deleted = true;
};
template <>
struct HashTraits<::network::mojom::CorsDomainMatchMode>
: public GenericHashTraits<::network::mojom::CorsDomainMatchMode> {
static_assert(true,
"-1000000 is a reserved enum value");
static_assert(true,
"-1000001 is a reserved enum value");
static const bool hasIsEmptyValueFunction = true;
static bool IsEmptyValue(const ::network::mojom::CorsDomainMatchMode& value) {
return value == static_cast<::network::mojom::CorsDomainMatchMode>(-1000000);
}
static void ConstructDeletedValue(::network::mojom::CorsDomainMatchMode& slot, bool) {
slot = static_cast<::network::mojom::CorsDomainMatchMode>(-1000001);
}
static bool IsDeletedValue(const ::network::mojom::CorsDomainMatchMode& value) {
return value == static_cast<::network::mojom::CorsDomainMatchMode>(-1000001);
}
};
} // namespace WTF
namespace WTF {
struct network_mojom_internal_CorsOriginAccessMatchPriority_DataHashFn {
static unsigned GetHash(const ::network::mojom::CorsOriginAccessMatchPriority& value) {
using utype = std::underlying_type<::network::mojom::CorsOriginAccessMatchPriority>::type;
return DefaultHash<utype>::Hash().GetHash(static_cast<utype>(value));
}
static bool Equal(const ::network::mojom::CorsOriginAccessMatchPriority& left, const ::network::mojom::CorsOriginAccessMatchPriority& right) {
return left == right;
}
static const bool safe_to_compare_to_empty_or_deleted = true;
};
template <>
struct HashTraits<::network::mojom::CorsOriginAccessMatchPriority>
: public GenericHashTraits<::network::mojom::CorsOriginAccessMatchPriority> {
static_assert(true,
"-1000000 is a reserved enum value");
static_assert(true,
"-1000001 is a reserved enum value");
static const bool hasIsEmptyValueFunction = true;
static bool IsEmptyValue(const ::network::mojom::CorsOriginAccessMatchPriority& value) {
return value == static_cast<::network::mojom::CorsOriginAccessMatchPriority>(-1000000);
}
static void ConstructDeletedValue(::network::mojom::CorsOriginAccessMatchPriority& slot, bool) {
slot = static_cast<::network::mojom::CorsOriginAccessMatchPriority>(-1000001);
}
static bool IsDeletedValue(const ::network::mojom::CorsOriginAccessMatchPriority& value) {
return value == static_cast<::network::mojom::CorsOriginAccessMatchPriority>(-1000001);
}
};
} // namespace WTF
namespace network {
namespace mojom {
namespace blink {
class BLINK_PLATFORM_EXPORT CorsOriginPattern {
public:
template <typename T>
using EnableIfSame = std::enable_if_t<std::is_same<CorsOriginPattern, T>::value>;
using DataView = CorsOriginPatternDataView;
using Data_ = internal::CorsOriginPattern_Data;
template <typename... Args>
static CorsOriginPatternPtr New(Args&&... args) {
return CorsOriginPatternPtr(
base::in_place, std::forward<Args>(args)...);
}
template <typename U>
static CorsOriginPatternPtr From(const U& u) {
return mojo::TypeConverter<CorsOriginPatternPtr, U>::Convert(u);
}
template <typename U>
U To() const {
return mojo::TypeConverter<U, CorsOriginPattern>::Convert(*this);
}
CorsOriginPattern();
CorsOriginPattern(
const WTF::String& protocol,
const WTF::String& domain,
uint16_t port,
CorsDomainMatchMode domain_match_mode,
CorsPortMatchMode port_match_mode,
CorsOriginAccessMatchPriority priority);
~CorsOriginPattern();
// Clone() is a template so it is only instantiated if it is used. Thus, the
// bindings generator does not need to know whether Clone() or copy
// constructor/assignment are available for members.
template <typename StructPtrType = CorsOriginPatternPtr>
CorsOriginPatternPtr Clone() const;
// Equals() is a template so it is only instantiated if it is used. Thus, the
// bindings generator does not need to know whether Equals() or == operator
// are available for members.
template <typename T, CorsOriginPattern::EnableIfSame<T>* = nullptr>
bool Equals(const T& other) const;
size_t Hash(size_t seed) const;
template <typename UserType>
static WTF::Vector<uint8_t> Serialize(UserType* input) {
return mojo::internal::SerializeImpl<
CorsOriginPattern::DataView, WTF::Vector<uint8_t>>(input);
}
template <typename UserType>
static mojo::Message SerializeAsMessage(UserType* input) {
return mojo::internal::SerializeAsMessageImpl<
CorsOriginPattern::DataView>(input);
}
// The returned Message is serialized only if the message is moved
// cross-process or cross-language. Otherwise if the message is Deserialized
// as the same UserType |input| will just be moved to |output| in
// DeserializeFromMessage.
template <typename UserType>
static mojo::Message WrapAsMessage(UserType input) {
return mojo::Message(std::make_unique<
internal::CorsOriginPattern_UnserializedMessageContext<
UserType, CorsOriginPattern::DataView>>(0, 0, std::move(input)));
}
template <typename UserType>
static bool Deserialize(const void* data,
size_t data_num_bytes,
UserType* output) {
return mojo::internal::DeserializeImpl<CorsOriginPattern::DataView>(
data, data_num_bytes, std::vector<mojo::ScopedHandle>(), output, Validate);
}
template <typename UserType>
static bool Deserialize(const WTF::Vector<uint8_t>& input,
UserType* output) {
return CorsOriginPattern::Deserialize(
input.size() == 0 ? nullptr : &input.front(), input.size(), output);
}
template <typename UserType>
static bool DeserializeFromMessage(mojo::Message input,
UserType* output) {
auto context = input.TakeUnserializedContext<
internal::CorsOriginPattern_UnserializedMessageContext<
UserType, CorsOriginPattern::DataView>>();
if (context) {
*output = std::move(context->TakeData());
return true;
}
input.SerializeIfNecessary();
return mojo::internal::DeserializeImpl<CorsOriginPattern::DataView>(
input.payload(), input.payload_num_bytes(),
std::move(*input.mutable_handles()), output, Validate);
}
WTF::String protocol;
WTF::String domain;
uint16_t port;
CorsDomainMatchMode domain_match_mode;
CorsPortMatchMode port_match_mode;
CorsOriginAccessMatchPriority priority;
private:
static bool Validate(const void* data,
mojo::internal::ValidationContext* validation_context);
};
// The comparison operators are templates, so they are only instantiated if they
// are used. Thus, the bindings generator does not need to know whether
// comparison operators are available for members.
template <typename T, CorsOriginPattern::EnableIfSame<T>* = nullptr>
bool operator<(const T& lhs, const T& rhs);
template <typename T, CorsOriginPattern::EnableIfSame<T>* = nullptr>
bool operator<=(const T& lhs, const T& rhs) {
return !(rhs < lhs);
}
template <typename T, CorsOriginPattern::EnableIfSame<T>* = nullptr>
bool operator>(const T& lhs, const T& rhs) {
return rhs < lhs;
}
template <typename T, CorsOriginPattern::EnableIfSame<T>* = nullptr>
bool operator>=(const T& lhs, const T& rhs) {
return !(lhs < rhs);
}
class BLINK_PLATFORM_EXPORT CorsOriginAccessPatterns {
public:
template <typename T>
using EnableIfSame = std::enable_if_t<std::is_same<CorsOriginAccessPatterns, T>::value>;
using DataView = CorsOriginAccessPatternsDataView;
using Data_ = internal::CorsOriginAccessPatterns_Data;
template <typename... Args>
static CorsOriginAccessPatternsPtr New(Args&&... args) {
return CorsOriginAccessPatternsPtr(
base::in_place, std::forward<Args>(args)...);
}
template <typename U>
static CorsOriginAccessPatternsPtr From(const U& u) {
return mojo::TypeConverter<CorsOriginAccessPatternsPtr, U>::Convert(u);
}
template <typename U>
U To() const {
return mojo::TypeConverter<U, CorsOriginAccessPatterns>::Convert(*this);
}
CorsOriginAccessPatterns();
CorsOriginAccessPatterns(
const ::scoped_refptr<const ::blink::SecurityOrigin>& source_origin,
WTF::Vector<CorsOriginPatternPtr> allow_patterns,
WTF::Vector<CorsOriginPatternPtr> block_patterns);
~CorsOriginAccessPatterns();
// Clone() is a template so it is only instantiated if it is used. Thus, the
// bindings generator does not need to know whether Clone() or copy
// constructor/assignment are available for members.
template <typename StructPtrType = CorsOriginAccessPatternsPtr>
CorsOriginAccessPatternsPtr Clone() const;
// Equals() is a template so it is only instantiated if it is used. Thus, the
// bindings generator does not need to know whether Equals() or == operator
// are available for members.
template <typename T, CorsOriginAccessPatterns::EnableIfSame<T>* = nullptr>
bool Equals(const T& other) const;
template <typename UserType>
static WTF::Vector<uint8_t> Serialize(UserType* input) {
return mojo::internal::SerializeImpl<
CorsOriginAccessPatterns::DataView, WTF::Vector<uint8_t>>(input);
}
template <typename UserType>
static mojo::Message SerializeAsMessage(UserType* input) {
return mojo::internal::SerializeAsMessageImpl<
CorsOriginAccessPatterns::DataView>(input);
}
// The returned Message is serialized only if the message is moved
// cross-process or cross-language. Otherwise if the message is Deserialized
// as the same UserType |input| will just be moved to |output| in
// DeserializeFromMessage.
template <typename UserType>
static mojo::Message WrapAsMessage(UserType input) {
return mojo::Message(std::make_unique<
internal::CorsOriginAccessPatterns_UnserializedMessageContext<
UserType, CorsOriginAccessPatterns::DataView>>(0, 0, std::move(input)));
}
template <typename UserType>
static bool Deserialize(const void* data,
size_t data_num_bytes,
UserType* output) {
return mojo::internal::DeserializeImpl<CorsOriginAccessPatterns::DataView>(
data, data_num_bytes, std::vector<mojo::ScopedHandle>(), output, Validate);
}
template <typename UserType>
static bool Deserialize(const WTF::Vector<uint8_t>& input,
UserType* output) {
return CorsOriginAccessPatterns::Deserialize(
input.size() == 0 ? nullptr : &input.front(), input.size(), output);
}
template <typename UserType>
static bool DeserializeFromMessage(mojo::Message input,
UserType* output) {
auto context = input.TakeUnserializedContext<
internal::CorsOriginAccessPatterns_UnserializedMessageContext<
UserType, CorsOriginAccessPatterns::DataView>>();
if (context) {
*output = std::move(context->TakeData());
return true;
}
input.SerializeIfNecessary();
return mojo::internal::DeserializeImpl<CorsOriginAccessPatterns::DataView>(
input.payload(), input.payload_num_bytes(),
std::move(*input.mutable_handles()), output, Validate);
}
::scoped_refptr<const ::blink::SecurityOrigin> source_origin;
WTF::Vector<CorsOriginPatternPtr> allow_patterns;
WTF::Vector<CorsOriginPatternPtr> block_patterns;
private:
static bool Validate(const void* data,
mojo::internal::ValidationContext* validation_context);
DISALLOW_COPY_AND_ASSIGN(CorsOriginAccessPatterns);
};
// The comparison operators are templates, so they are only instantiated if they
// are used. Thus, the bindings generator does not need to know whether
// comparison operators are available for members.
template <typename T, CorsOriginAccessPatterns::EnableIfSame<T>* = nullptr>
bool operator<(const T& lhs, const T& rhs);
template <typename T, CorsOriginAccessPatterns::EnableIfSame<T>* = nullptr>
bool operator<=(const T& lhs, const T& rhs) {
return !(rhs < lhs);
}
template <typename T, CorsOriginAccessPatterns::EnableIfSame<T>* = nullptr>
bool operator>(const T& lhs, const T& rhs) {
return rhs < lhs;
}
template <typename T, CorsOriginAccessPatterns::EnableIfSame<T>* = nullptr>
bool operator>=(const T& lhs, const T& rhs) {
return !(lhs < rhs);
}
template <typename StructPtrType>
CorsOriginPatternPtr CorsOriginPattern::Clone() const {
return New(
mojo::Clone(protocol),
mojo::Clone(domain),
mojo::Clone(port),
mojo::Clone(domain_match_mode),
mojo::Clone(port_match_mode),
mojo::Clone(priority)
);
}
template <typename T, CorsOriginPattern::EnableIfSame<T>*>
bool CorsOriginPattern::Equals(const T& other_struct) const {
if (!mojo::Equals(this->protocol, other_struct.protocol))
return false;
if (!mojo::Equals(this->domain, other_struct.domain))
return false;
if (!mojo::Equals(this->port, other_struct.port))
return false;
if (!mojo::Equals(this->domain_match_mode, other_struct.domain_match_mode))
return false;
if (!mojo::Equals(this->port_match_mode, other_struct.port_match_mode))
return false;
if (!mojo::Equals(this->priority, other_struct.priority))
return false;
return true;
}
template <typename T, CorsOriginPattern::EnableIfSame<T>*>
bool operator<(const T& lhs, const T& rhs) {
if (lhs.protocol < rhs.protocol)
return true;
if (rhs.protocol < lhs.protocol)
return false;
if (lhs.domain < rhs.domain)
return true;
if (rhs.domain < lhs.domain)
return false;
if (lhs.port < rhs.port)
return true;
if (rhs.port < lhs.port)
return false;
if (lhs.domain_match_mode < rhs.domain_match_mode)
return true;
if (rhs.domain_match_mode < lhs.domain_match_mode)
return false;
if (lhs.port_match_mode < rhs.port_match_mode)
return true;
if (rhs.port_match_mode < lhs.port_match_mode)
return false;
if (lhs.priority < rhs.priority)
return true;
if (rhs.priority < lhs.priority)
return false;
return false;
}
template <typename StructPtrType>
CorsOriginAccessPatternsPtr CorsOriginAccessPatterns::Clone() const {
return New(
mojo::Clone(source_origin),
mojo::Clone(allow_patterns),
mojo::Clone(block_patterns)
);
}
template <typename T, CorsOriginAccessPatterns::EnableIfSame<T>*>
bool CorsOriginAccessPatterns::Equals(const T& other_struct) const {
if (!mojo::Equals(this->source_origin, other_struct.source_origin))
return false;
if (!mojo::Equals(this->allow_patterns, other_struct.allow_patterns))
return false;
if (!mojo::Equals(this->block_patterns, other_struct.block_patterns))
return false;
return true;
}
template <typename T, CorsOriginAccessPatterns::EnableIfSame<T>*>
bool operator<(const T& lhs, const T& rhs) {
if (lhs.source_origin < rhs.source_origin)
return true;
if (rhs.source_origin < lhs.source_origin)
return false;
if (lhs.allow_patterns < rhs.allow_patterns)
return true;
if (rhs.allow_patterns < lhs.allow_patterns)
return false;
if (lhs.block_patterns < rhs.block_patterns)
return true;
if (rhs.block_patterns < lhs.block_patterns)
return false;
return false;
}
} // namespace blink
} // namespace mojom
} // namespace network
namespace mojo {
template <>
struct BLINK_PLATFORM_EXPORT StructTraits<::network::mojom::blink::CorsOriginPattern::DataView,
::network::mojom::blink::CorsOriginPatternPtr> {
static bool IsNull(const ::network::mojom::blink::CorsOriginPatternPtr& input) { return !input; }
static void SetToNull(::network::mojom::blink::CorsOriginPatternPtr* output) { output->reset(); }
static const decltype(::network::mojom::blink::CorsOriginPattern::protocol)& protocol(
const ::network::mojom::blink::CorsOriginPatternPtr& input) {
return input->protocol;
}
static const decltype(::network::mojom::blink::CorsOriginPattern::domain)& domain(
const ::network::mojom::blink::CorsOriginPatternPtr& input) {
return input->domain;
}
static decltype(::network::mojom::blink::CorsOriginPattern::port) port(
const ::network::mojom::blink::CorsOriginPatternPtr& input) {
return input->port;
}
static decltype(::network::mojom::blink::CorsOriginPattern::domain_match_mode) domain_match_mode(
const ::network::mojom::blink::CorsOriginPatternPtr& input) {
return input->domain_match_mode;
}
static decltype(::network::mojom::blink::CorsOriginPattern::port_match_mode) port_match_mode(
const ::network::mojom::blink::CorsOriginPatternPtr& input) {
return input->port_match_mode;
}
static decltype(::network::mojom::blink::CorsOriginPattern::priority) priority(
const ::network::mojom::blink::CorsOriginPatternPtr& input) {
return input->priority;
}
static bool Read(::network::mojom::blink::CorsOriginPattern::DataView input, ::network::mojom::blink::CorsOriginPatternPtr* output);
};
template <>
struct BLINK_PLATFORM_EXPORT StructTraits<::network::mojom::blink::CorsOriginAccessPatterns::DataView,
::network::mojom::blink::CorsOriginAccessPatternsPtr> {
static bool IsNull(const ::network::mojom::blink::CorsOriginAccessPatternsPtr& input) { return !input; }
static void SetToNull(::network::mojom::blink::CorsOriginAccessPatternsPtr* output) { output->reset(); }
static const decltype(::network::mojom::blink::CorsOriginAccessPatterns::source_origin)& source_origin(
const ::network::mojom::blink::CorsOriginAccessPatternsPtr& input) {
return input->source_origin;
}
static const decltype(::network::mojom::blink::CorsOriginAccessPatterns::allow_patterns)& allow_patterns(
const ::network::mojom::blink::CorsOriginAccessPatternsPtr& input) {
return input->allow_patterns;
}
static const decltype(::network::mojom::blink::CorsOriginAccessPatterns::block_patterns)& block_patterns(
const ::network::mojom::blink::CorsOriginAccessPatternsPtr& input) {
return input->block_patterns;
}
static bool Read(::network::mojom::blink::CorsOriginAccessPatterns::DataView input, ::network::mojom::blink::CorsOriginAccessPatternsPtr* output);
};
} // namespace mojo
#endif // SERVICES_NETWORK_PUBLIC_MOJOM_CORS_ORIGIN_PATTERN_MOJOM_BLINK_H_ | [
"[email protected]"
] | |
efffdb994db6027afc6c9a4a578f2d8bc6ccc32b | 5389b2713ac4b0a918df2ba88fe5958a2f5ee7ad | /src/core/GlutWindow.h | e7fe5acba0a9f5e2a8a2dd213242fb577fefeffb | [] | no_license | Goriar/Ai-Project | b45bece9dc337fcd0b56d2b20e4da9e33ad6287c | 78f07b94560b5fd52ba8a0024eec512701675bc5 | refs/heads/master | 2021-01-18T17:25:42.916811 | 2013-10-04T10:40:54 | 2013-10-04T10:40:54 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 589 | h | #pragma once
#include "mathutil\Vector.h"
#include <windows.h>
class CArcBall;
class GlutWindow
{
public:
GlutWindow(void);
~GlutWindow(void);
virtual void renderFrame();
virtual void idle();
virtual void resize(int width, int height);
virtual void keyEvent(unsigned char key,int x,int y);
virtual void mouseButtonEvent(int button, int state,int x,int y);
virtual void mouseMoveEvent(int x,int y);
virtual bool handleButtonEvent(int button, int state, int x, int y);
virtual bool handleMoveEvent(int x, int y);
protected:
int nWidth, nHeight;
void initializeGL();
};
| [
"[email protected]"
] | |
588c00c12f945e6c3333c1a7c6bd7323e5ebdfb1 | 8567438779e6af0754620a25d379c348e4cd5a5d | /ui/gfx/buffer_format_util.cc | 4432b3e9a6c88568fe60ea4165f99b42816cd981 | [
"BSD-3-Clause"
] | permissive | thngkaiyuan/chromium | c389ac4b50ccba28ee077cbf6115c41b547955ae | dab56a4a71f87f64ecc0044e97b4a8f247787a68 | refs/heads/master | 2022-11-10T02:50:29.326119 | 2017-04-08T12:28:57 | 2017-04-08T12:28:57 | 84,073,924 | 0 | 1 | BSD-3-Clause | 2022-10-25T19:47:15 | 2017-03-06T13:04:15 | null | UTF-8 | C++ | false | false | 7,587 | cc | // Copyright 2015 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 "ui/gfx/buffer_format_util.h"
#include "base/logging.h"
#include "base/macros.h"
#include "base/numerics/safe_math.h"
namespace gfx {
namespace {
const BufferFormat kBufferFormats[] = {BufferFormat::ATC,
BufferFormat::ATCIA,
BufferFormat::DXT1,
BufferFormat::DXT5,
BufferFormat::ETC1,
BufferFormat::R_8,
BufferFormat::RG_88,
BufferFormat::BGR_565,
BufferFormat::RGBA_4444,
BufferFormat::RGBX_8888,
BufferFormat::RGBA_8888,
BufferFormat::BGRX_8888,
BufferFormat::BGRA_8888,
BufferFormat::UYVY_422,
BufferFormat::YUV_420_BIPLANAR,
BufferFormat::YVU_420};
static_assert(arraysize(kBufferFormats) ==
(static_cast<int>(BufferFormat::LAST) + 1),
"BufferFormat::LAST must be last value of kBufferFormats");
bool RowSizeForBufferFormatChecked(
size_t width, BufferFormat format, size_t plane, size_t* size_in_bytes) {
base::CheckedNumeric<size_t> checked_size = width;
switch (format) {
case BufferFormat::ATCIA:
case BufferFormat::DXT5:
DCHECK_EQ(0u, plane);
*size_in_bytes = width;
return true;
case BufferFormat::ATC:
case BufferFormat::DXT1:
case BufferFormat::ETC1:
DCHECK_EQ(0u, plane);
DCHECK_EQ(0u, width % 2);
*size_in_bytes = width / 2;
return true;
case BufferFormat::R_8:
checked_size += 3;
if (!checked_size.IsValid())
return false;
*size_in_bytes = (checked_size & ~0x3).ValueOrDie();
return true;
case BufferFormat::RG_88:
case BufferFormat::BGR_565:
case BufferFormat::RGBA_4444:
case BufferFormat::UYVY_422:
checked_size *= 2;
checked_size += 3;
if (!checked_size.IsValid())
return false;
*size_in_bytes = (checked_size & ~0x3).ValueOrDie();
return true;
case BufferFormat::BGRX_8888:
case BufferFormat::RGBX_8888:
case BufferFormat::RGBA_8888:
case BufferFormat::BGRA_8888:
checked_size *= 4;
if (!checked_size.IsValid())
return false;
*size_in_bytes = checked_size.ValueOrDie();
return true;
case BufferFormat::YVU_420:
DCHECK_EQ(0u, width % 2);
*size_in_bytes = width / SubsamplingFactorForBufferFormat(format, plane);
return true;
case BufferFormat::YUV_420_BIPLANAR:
DCHECK_EQ(width % 2, 0u);
*size_in_bytes = width;
return true;
}
NOTREACHED();
return false;
}
} // namespace
std::vector<BufferFormat> GetBufferFormatsForTesting() {
return std::vector<BufferFormat>(kBufferFormats,
kBufferFormats + arraysize(kBufferFormats));
}
size_t NumberOfPlanesForBufferFormat(BufferFormat format) {
switch (format) {
case BufferFormat::ATC:
case BufferFormat::ATCIA:
case BufferFormat::DXT1:
case BufferFormat::DXT5:
case BufferFormat::ETC1:
case BufferFormat::R_8:
case BufferFormat::RG_88:
case BufferFormat::BGR_565:
case BufferFormat::RGBA_4444:
case BufferFormat::RGBX_8888:
case BufferFormat::RGBA_8888:
case BufferFormat::BGRX_8888:
case BufferFormat::BGRA_8888:
case BufferFormat::UYVY_422:
return 1;
case BufferFormat::YUV_420_BIPLANAR:
return 2;
case BufferFormat::YVU_420:
return 3;
}
NOTREACHED();
return 0;
}
size_t SubsamplingFactorForBufferFormat(BufferFormat format, size_t plane) {
switch (format) {
case BufferFormat::ATC:
case BufferFormat::ATCIA:
case BufferFormat::DXT1:
case BufferFormat::DXT5:
case BufferFormat::ETC1:
case BufferFormat::R_8:
case BufferFormat::RG_88:
case BufferFormat::BGR_565:
case BufferFormat::RGBA_4444:
case BufferFormat::RGBX_8888:
case BufferFormat::RGBA_8888:
case BufferFormat::BGRX_8888:
case BufferFormat::BGRA_8888:
case BufferFormat::UYVY_422:
return 1;
case BufferFormat::YVU_420: {
static size_t factor[] = {1, 2, 2};
DCHECK_LT(static_cast<size_t>(plane), arraysize(factor));
return factor[plane];
}
case BufferFormat::YUV_420_BIPLANAR: {
static size_t factor[] = {1, 2};
DCHECK_LT(static_cast<size_t>(plane), arraysize(factor));
return factor[plane];
}
}
NOTREACHED();
return 0;
}
size_t RowSizeForBufferFormat(size_t width, BufferFormat format, size_t plane) {
size_t row_size = 0;
bool valid = RowSizeForBufferFormatChecked(width, format, plane, &row_size);
DCHECK(valid);
return row_size;
}
size_t BufferSizeForBufferFormat(const Size& size, BufferFormat format) {
size_t buffer_size = 0;
bool valid = BufferSizeForBufferFormatChecked(size, format, &buffer_size);
DCHECK(valid);
return buffer_size;
}
bool BufferSizeForBufferFormatChecked(const Size& size,
BufferFormat format,
size_t* size_in_bytes) {
base::CheckedNumeric<size_t> checked_size = 0;
size_t num_planes = NumberOfPlanesForBufferFormat(format);
for (size_t i = 0; i < num_planes; ++i) {
size_t row_size = 0;
if (!RowSizeForBufferFormatChecked(size.width(), format, i, &row_size))
return false;
base::CheckedNumeric<size_t> checked_plane_size = row_size;
checked_plane_size *= size.height() /
SubsamplingFactorForBufferFormat(format, i);
if (!checked_plane_size.IsValid())
return false;
checked_size += checked_plane_size.ValueOrDie();
if (!checked_size.IsValid())
return false;
}
*size_in_bytes = checked_size.ValueOrDie();
return true;
}
size_t BufferOffsetForBufferFormat(const Size& size,
BufferFormat format,
size_t plane) {
DCHECK_LT(plane, gfx::NumberOfPlanesForBufferFormat(format));
switch (format) {
case BufferFormat::ATC:
case BufferFormat::ATCIA:
case BufferFormat::DXT1:
case BufferFormat::DXT5:
case BufferFormat::ETC1:
case BufferFormat::R_8:
case BufferFormat::RG_88:
case BufferFormat::BGR_565:
case BufferFormat::RGBA_4444:
case BufferFormat::RGBX_8888:
case BufferFormat::RGBA_8888:
case BufferFormat::BGRX_8888:
case BufferFormat::BGRA_8888:
case BufferFormat::UYVY_422:
return 0;
case BufferFormat::YVU_420: {
static size_t offset_in_2x2_sub_sampling_sizes[] = {0, 4, 5};
DCHECK_LT(plane, arraysize(offset_in_2x2_sub_sampling_sizes));
return offset_in_2x2_sub_sampling_sizes[plane] *
(size.width() / 2 + size.height() / 2);
}
case gfx::BufferFormat::YUV_420_BIPLANAR: {
static size_t offset_in_2x2_sub_sampling_sizes[] = {0, 4};
DCHECK_LT(plane, arraysize(offset_in_2x2_sub_sampling_sizes));
return offset_in_2x2_sub_sampling_sizes[plane] *
(size.width() / 2 + size.height() / 2);
}
}
NOTREACHED();
return 0;
}
} // namespace gfx
| [
"[email protected]"
] | |
b81803c5ba3196ea1f62be60cdf828ba2a99d632 | 627157a23a44a38852c3e146efb8fd993f6c4128 | /CF1493A.cpp | 62d92e5b0908084b5e94d51ee2cd3031b4e36b65 | [] | no_license | hsh778205/luogu_code | e598fd87896a61ea6c75e3c918885bd00ea6933b | 5280e8d5cae5d5ac51cb9dbbe2a69fd8a8c3595a | refs/heads/master | 2021-07-21T12:24:37.708033 | 2021-03-30T06:29:21 | 2021-03-30T06:29:21 | 247,858,584 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,577 | cpp | /**************************************************************
* Problem: CF1493A Anti-knapsack
* Author: Vanilla_chan
* Date: 20210308
**************************************************************/
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<map>
#include<set>
#include<queue>
#include<vector>
#include<limits.h>
#define IL inline
#define re register
#define LL long long
#define ULL unsigned long long
#ifdef TH
#define debug printf("Now is %d\n",__LINE__);
#else
#define debug
#endif
#ifdef ONLINE_JUDGE
char buf[1<<23],* p1=buf,* p2=buf,obuf[1<<23],* O=obuf;
#define getchar() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++)
#endif
using namespace std;
template<class T>inline void read(T& x)
{
char ch=getchar();
int fu;
while(!isdigit(ch)&&ch!='-') ch=getchar();
if(ch=='-') fu=-1,ch=getchar();
x=ch-'0';ch=getchar();
while(isdigit(ch)) { x=x*10+ch-'0';ch=getchar(); }
x*=fu;
}
inline int read()
{
int x=0,fu=1;
char ch=getchar();
while(!isdigit(ch)&&ch!='-') ch=getchar();
if(ch=='-') fu=-1,ch=getchar();
x=ch-'0';ch=getchar();
while(isdigit(ch)) { x=x*10+ch-'0';ch=getchar(); }
return x*fu;
}
int G[55];
template<class T>inline void write(T x)
{
int g=0;
if(x<0) x=-x,putchar('-');
do { G[++g]=x%10;x/=10; } while(x);
for(int i=g;i>=1;--i)putchar('0'+G[i]);putchar('\n');
}
int t;
int n,k;
int main()
{
t=read();
while(t--)
{
n=read();
k=read();
write(n-k+k/2);
for(int i=1;i+k<=n;i++) write(i+k);
for(int i=k-1;(i<<1)>=k;i--) write(i);
}
return 0;
}
| [
"[email protected]"
] | |
cc3a5bbef24e5ac1c9960342c7837302964e207d | a090af918e3ec59140027dbddd54aa4ca1c73910 | /Uva/JU_D.cpp | c1b35b63bcebf09dfd9ab0d48804238c51b164ab | [] | no_license | nitesh-147/Programming-Problem-Solution | b739e2a3c9cfeb2141baf1d34e43eac0435ecb2a | df7d53e0863954ddf358539d23266b28d5504212 | refs/heads/master | 2023-03-16T00:37:10.236317 | 2019-11-28T18:11:33 | 2019-11-28T18:11:33 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,068 | cpp | #include <cstring>
#include <cassert>
#include <vector>
#include <list>
#include <queue>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <fstream>
#include <climits>
#define scan(a) scanf("%d",&a);
#define s2(a,b) scanf("%d %d",&a,&b)
#define PI 2acos(-1.0)
#define s1(a) scanf("%d",&a);
#define INF 2<<15
#define PB(A) push_back(A)
#define clr(a,b) memset(a,b,sizeof(a))
#define LL long long
#define ULL unsigned long long
using namespace std;
int main()
{
int i,j,k;
long n,m;
while(cin>>n>>m)
{
if(n==0 &&m==0)
cout<<"0 0\n";
else if(n==0)
cout<<"Impossible"<<endl;
else if(m==0)
cout<<n<<" "<<n<<endl;
else
{
int ans=(m>=n)?m:n;
cout<<ans<<" "<<n+m-1<<endl;
}
}
return 0;
}
| [
"[email protected]"
] | |
d1a2a6dac183dbca5f89c1edcc76d9dca59335bf | 38fef199650f4bcd14efe43587de3ce89e87c52d | /apps/coupler/include/options.hh | e4323c597179a9a66d10348fb84b515167c64103 | [] | no_license | ipdemes/mpas-o-flecsi-2.0 | 0a174733fd9b82791cf648dc09696c8a0f10b39e | 3c9fa96ea4f598cf8eaa069fbdad898407246bd6 | refs/heads/master | 2023-06-21T07:38:44.028376 | 2021-07-29T16:37:05 | 2021-07-29T16:37:05 | 344,925,769 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 529 | hh | /*----------------------------------------------------------------------------*
Copyright (c) 2020 Triad National Security, LLC
All rights reserved
*----------------------------------------------------------------------------*/
#pragma once
#include "flecsi/execution.hh"
namespace coupler {
inline flecsi::program_option<std::size_t>
x_extents("x-extents", "The x extents of the mesh.", 1);
inline flecsi::program_option<std::size_t>
y_extents("y-extents", "The y extents of the mesh.", 1);
} // namespace poisson
| [
"[email protected]"
] | |
1e739283c896df835a9261b9b0d074e9cff42793 | 3c192dad91488a6845e716883e3a7f577322c67a | /KargenMinCut/Weighted_UF.cpp | 82ebcd0c4d753cb43c41c4b16fe8eef6ae77eb48 | [] | no_license | Dustin-Chase/kargerMinCut | da0a5a3c3aa7a714cd1d2c33a044514d598bee23 | cdc32fb9c019f0cb07a9187320496124df18024f | refs/heads/master | 2021-01-17T16:11:30.057987 | 2016-08-03T00:52:44 | 2016-08-03T00:52:44 | 64,802,483 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 685 | cpp | #include "stdafx.h"
#include "Weighted_UF.h"
Weighted_UF::Weighted_UF(int N) : count(N), sz(N + 1, 1)
{
for (int i = 0; i <= N; ++i) id.push_back(i);
}
int Weighted_UF::getCount()
{
return count;
}
bool Weighted_UF::connected(int p, int q)
{
return find(p) == find(q);
}
int Weighted_UF::find(int p)
{
while (p != id[p]) p = id[p];
return p;
}
void Weighted_UF::wfUnion(int p, int q)
{
int i = find(p);
int j = find(q);
if (i == j) return;
//make smaller root point to larger one
if (sz[i] < sz[j]) { id[i] = j; sz[j] += sz[i]; }
else { id[j] = i; sz[i] += sz[j]; }
count--;
}
int Weighted_UF::getMax()
{
return *std::max_element(sz.begin(), sz.end());
}
| [
"[email protected]"
] | |
7d1e2a381669cd7364e5e4e1192837f85002d58c | 9fc40503cfa90babe5e89af8d83d047ed55168f4 | /mpi_back/my_work_backup_wordcount/my_work_wordcount_arm/my_work/test/test_bug.cpp | 18b5c43c3222995a360e3fcb87b134587c4cc93e | [
"BSD-3-Clause"
] | permissive | simonsjy/MPI_Phoenix | 33c0986f0f5f61416bcd98a865cd74dfc4ea0a8d | 652a1bd00313efb6bd32cff6b2caf5431872d6b2 | refs/heads/master | 2021-01-10T19:03:09.967515 | 2014-08-13T02:22:30 | 2014-08-13T02:22:30 | 22,878,101 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,404 | cpp | #include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include <string.h>
//typedef long long uint64_t;
int main()
{
#if 0
int filelen;
char *rcv_data_buffer;
FILE *fp = fopen("test.data", "rb");
assert(fp != NULL);
fseek(fp, 0, SEEK_END);
filelen = ftell(fp);
rewind(fp);
rcv_data_buffer = (char*)malloc(filelen);
assert(rcv_data_buffer != NULL);
fread(rcv_data_buffer, 1, filelen, fp);
fclose(fp);
printf("sizeof long long %d\r\n", sizeof(uint64_t));
char *index = rcv_data_buffer;
for(int i = 0; i < 30; i++)
{
printf("%x ", index[i]);
}
for(int i = 0; i < 100; i++)
{
uint64_t *key_index = (uint64_t*)index;
uint64_t *value_index = (uint64_t*)(index + sizeof(uint64_t));
char *key, *value;
printf("\r\nproc %d keysize %llu\r\n",0, *key_index);
printf("\r\nproc %d valuesize %llu\r\n",0, *value_index);
key = index + 2*sizeof(uint64_t);
value = key + *key_index;
index = index + *key_index + *value_index + 2*sizeof(uint64_t);
key[strlen(key)] = '\0';
printf("\r\nkey %s\r\n", key);
printf("\r\nvalue %llu\r\n", *(uint64_t*)value);
}
#endif
char abc[]="0x1234567890000000";
uint64_t def = 0x123;
int *kk;
printf("%lu\r\n", *(int*)abc);
printf("%llu\r\n", def);
//def = *(uint64_t*)abc;
kk = (int*)abc;
printf("kk %x\r\n", kk);
printf("*kk %llu\r\n", kk[0]);
printf("%llu\r\n", *(uint64_t*)abc);
return 0;
}
| [
"[email protected]"
] | |
9bf4707366521a5804f6d79776e5b2ee552fe3f8 | 40d5485760211f848a325ec5491c4f4e83eccda5 | /Aula 12 - Hashing/exemplosFunctor.cpp | 04b1a141ccbdb112921e7aba97a5231acb52fb15 | [
"MIT"
] | permissive | EhODavi/INF213 | 1699953ec46bbca98c577289497ef7b8374da980 | 2099354f1e8f9eda9a92531e5dc45a736ef3882e | refs/heads/main | 2023-02-02T14:50:44.367104 | 2020-12-19T19:23:37 | 2020-12-19T19:23:37 | 322,921,942 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,779 | cpp | #include <list>
#include <iostream>
using namespace std;
#include <string>
using namespace std;
class Functor1 {
public:
void operator()() const {
cout << "Ola" << endl;
}
};
class Functor2 {
public:
void operator()(int x) const {
cout << x << endl;
}
};
class FunctorCompara {
public:
bool operator()(int a, int b) const { //retorna true sse a<b
return a<b;
}
};
class FunctorCompara2 {
public:
bool operator()(int a, int b) const { //retorna true sse a>b
return a>b;
}
};
template <class Func>
void f(const int v1[], const int v2[], int n) {
Func f; //cria o "objeto funcao"
for(int i=0;i<n;i++) {
cout << v1[i] << " " << v2[i] << " " << f(v1[i],v2[i]) << endl;
}
cout << endl;
}
template <class T, class Func>
void bubbleSort(T v[],int n, const Func &comparaMenor) {
while(true) {
bool trocou = false;
for(int i=0;i<n-1;i++) {
if(!comparaMenor(v[i],v[i+1])) {
swap(v[i],v[i+1]);
trocou = true;
}
}
if(!trocou) return;
}
}
int main() {
Functor1 f1;
Functor2 f2;
f1(); //imprime Ola
f2(5); //imprime 5
FunctorCompara menor;
FunctorCompara2 maior;
cout << menor(1,5) << endl;
cout << maior(5,1) << endl;
int v1[] = {1,5,10};
int v2[] = {2,8,1};
f<FunctorCompara>(v1,v2,3); //chama f passando o functor que verifica se o primeiro argumento eh menor do que o segundo...
f<FunctorCompara2>(v1,v2,3);
//usando um functor para prover uma funcao de comparacao customizada para um algoritmo de ordenacao...
cout << "Ordenando em ordem crescente..." << endl;
bubbleSort(v1,3,FunctorCompara());
for(int i=0;i<3;i++)
cout << v1[i] << " ";
cout << endl;
cout << "Ordenando em ordem decrescente..." << endl;
bubbleSort(v1,3,FunctorCompara2());
for(int i=0;i<3;i++)
cout << v1[i] << " ";
cout << endl;
} | [
"[email protected]"
] | |
1ff20a16022726f5463793252fcb048dc20d42b6 | 6ef5befa26c034f70be867ae4c59d60555652b47 | /Source/ResourceManager.cpp | 29a047e5dd01348b96f36cc491c8d4019e3d0abd | [] | no_license | StupidCodeGenerator/bwapi_myai_1 | fad24c2008c34eb6317b55c2b9c6125e60094e72 | 37de0f7c8e550eba212b5636bb88e83d192cbf75 | refs/heads/master | 2021-06-02T23:10:31.678791 | 2020-09-04T13:42:52 | 2020-09-04T13:42:52 | 100,729,251 | 0 | 0 | null | null | null | null | GB18030 | C++ | false | false | 4,406 | cpp | #include "ResourceManager.h"
#include <BWAPI.h>
#include "MyAiModule.h"
#include "utils.h"
#include "MineralExtend.h"
int ResourceManager::OnInit() {
return FUCK_SUCCESS;
}
int ResourceManager::OnUpdate() {
std::list<int> deadList;
deadList.clear();
// 去掉那些找不到的Unit
std::map<int, MineralExtend*>::iterator fuckIT = m_MineralsMap.begin();
for (fuckIT; fuckIT != m_MineralsMap.end(); fuckIT++) {
if (!fuckIT->second) {
deadList.push_back(fuckIT->first);
continue;
}
else {
BWAPI::Unit unit = AI_MODULE->FindMinerals(fuckIT->second->m_UnitID);
if (!unit) {
deadList.push_back(fuckIT->first);
SAFE_DELETE(fuckIT->second); // 顺便给second释放了
continue;
}
}
}
std::list<int>::iterator shitIT = deadList.begin();
for (shitIT; shitIT != deadList.end(); shitIT++) {
m_MineralsMap.erase(*shitIT);
}
return FUCK_SUCCESS;
}
int ResourceManager::CreateMineralExtend(BWAPI::Unit unit) {
if (!unit || !unit->exists()) {
return FUCK_ERR__NULL_UNIT;
}
if (m_MineralsMap.find(unit->getID()) != m_MineralsMap.end()) {
return FUCK_ERR__UNIT_ALREADY_IN;
}
MineralExtend* pFuck = new MineralExtend();
pFuck->OnInit(unit->getID());
m_MineralsMap.insert(make_pair(unit->getID(), pFuck));
return FUCK_SUCCESS;
}
// 直接循环查找, 排鸡毛排序
// 最后返回的是UnitID
int ResourceManager::FindMineralUnitID_of_MinSCV(int maxDistance, BWAPI::Unit scvUnit) {
// 1. 首先找到一个集合, 包含所有SCV数量最小的集合.
std::list<int> minSCV_Set;
minSCV_Set.clear();
int minValue = 99999;
std::map<int, MineralExtend*>::iterator fuckIT = m_MineralsMap.begin();
for (fuckIT; fuckIT != m_MineralsMap.end(); fuckIT++) {
int value = fuckIT->second->GetSCVCount();
if (value < minValue) {
minValue = value;
minSCV_Set.clear();
minSCV_Set.push_back(fuckIT->first);
}
else if (value == minValue) {
minSCV_Set.push_back(fuckIT->first);
}
}
// 2. 找到这个集合后, 如果集合Count为1, 直接返回, 如果小于1返回错误
if (minSCV_Set.size() < 1) {
return NULL_UNIT_ID;
}
else if (minSCV_Set.size() == 1) {
return *(minSCV_Set.begin());
}
// 3. 对于minSCV_Set.size() > 1 的情况, 要找到距离自己最近的
int minDistance = 99999;
int finalUnit = NULL_UNIT_ID;
std::list<int>::iterator shitIT = minSCV_Set.begin();
for (shitIT; shitIT != minSCV_Set.end(); shitIT++) {
BWAPI::Unit mineralObj = AI_MODULE->FindMinerals(*shitIT);
if (!mineralObj) {
continue;
}
int distance = scvUnit->getDistance(mineralObj);
if (distance < minDistance) {
minDistance = distance;
finalUnit = mineralObj->getID();
}
}
return finalUnit;
}
std::list<int> ResourceManager::FindMineralUnitInRange(BWAPI::Position center, int radius) {
std::list<int> output;
std::map<int, MineralExtend*>::iterator fuckIT = m_MineralsMap.begin();
for (fuckIT; fuckIT != m_MineralsMap.end(); fuckIT++) {
BWAPI::Unit unit = FIND_UNIT(fuckIT->second->m_UnitID);
if (unit && unit->getDistance(center) <= radius) {
output.push_back(unit->getID());
}
}
return output;
}
std::list<int> ResourceManager::FindGasUnitInRange(BWAPI::Position center, int radius) {
std::list<int> output;
for (auto &u : BWAPI::Broodwar->getAllUnits()) {
if (u && u->getType() == BWAPI::UnitTypes::Resource_Vespene_Geyser && u->getDistance(center) < radius) {
output.push_back(u->getID());
}
}
return output;
}
int ResourceManager::AddSCV_of_Mineral(int mineralUnitID) {
std::map<int, MineralExtend*>::iterator fuckIT = m_MineralsMap.find(mineralUnitID);
if (fuckIT == m_MineralsMap.end() || !fuckIT->second) {
return FUCK_ERR__NULL_UNIT;
}
fuckIT->second->AddSCV();
return FUCK_SUCCESS;
}
int ResourceManager::RemoveSCV_of_Mineral(int mineralUnitID) {
std::map<int, MineralExtend*>::iterator fuckIT = m_MineralsMap.find(mineralUnitID);
if (fuckIT == m_MineralsMap.end() || !fuckIT->second) {
return FUCK_ERR__NULL_UNIT;
}
fuckIT->second->RemoveSCV();
return FUCK_SUCCESS;
}
void ResourceManager::OnDraw() {
int time = BWAPI::Broodwar->elapsedTime();
std::map<int, MineralExtend*>::iterator fuckIT = m_MineralsMap.begin();
for (fuckIT; fuckIT != m_MineralsMap.end(); fuckIT++) {
BWAPI::Unit u = FIND_UNIT(fuckIT->second->m_UnitID);
if (!u) {
continue;
}
BWAPI::Broodwar->drawCircleMap(u->getPosition(), 30, BWAPI::Colors::White);
}
}
| [
"[email protected]"
] | |
dd0a4fa6965e67105015a0bd7bc0dc019746bc22 | 7798ecd619f6c002506e1ad552baed4a9c14952e | /src/snake.cpp | 9d6c6c8241b2d6d4709d4f40e1cd92e128518963 | [] | no_license | koyalbhartia/Cpp-Capstone-SnakeGame | 5e5ab8fb4bca008a1e738452f821af3135fadef5 | 3b4d1391d1f19c5fc7e5f3e9782ecfe53ae47893 | refs/heads/master | 2022-08-26T08:48:54.161407 | 2020-05-26T22:31:35 | 2020-05-26T22:31:35 | 267,153,666 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,024 | cpp | #include "snake.h"
#include <cmath>
#include <iostream>
void Snake::Speed()
{
levelsetter.user_level();
int level=levelsetter.getLevel();
speed=level*0.1;
}
void Snake::Update() {
SDL_Point prev_cell{
static_cast<int>(head_x),
static_cast<int>(
head_y)}; // We first capture the head's cell before updating.
UpdateHead();
SDL_Point current_cell{
static_cast<int>(head_x),
static_cast<int>(head_y)}; // Capture the head's cell after updating.
// Update all of the body vector items if the snake head has moved to a new
// cell.
if (current_cell.x != prev_cell.x || current_cell.y != prev_cell.y) {
UpdateBody(current_cell, prev_cell);
}
}
void Snake::UpdateHead() {
switch (direction) {
case Direction::kUp:
head_y -= speed;
break;
case Direction::kDown:
head_y += speed;
break;
case Direction::kLeft:
head_x -= speed;
break;
case Direction::kRight:
head_x += speed;
break;
}
// Wrap the Snake around to the beginning if going off of the screen.
head_x = fmod(head_x + grid_width, grid_width);
head_y = fmod(head_y + grid_height, grid_height);
}
void Snake::UpdateBody(SDL_Point ¤t_head_cell, SDL_Point &prev_head_cell) {
// Add previous head location to vector
body.push_back(prev_head_cell);
if (!growing) {
// Remove the tail from the vector.
body.erase(body.begin());
} else {
growing = false;
size++;
}
// Check if the snake has died.
for (auto const &item : body) {
if (current_head_cell.x == item.x && current_head_cell.y == item.y) {
alive = false;
}
}
}
void Snake::GrowBody() { growing = true; }
// Inefficient method to check if cell is occupied by snake.
bool Snake::SnakeCell(int x, int y) {
if (x == static_cast<int>(head_x) && y == static_cast<int>(head_y)) {
return true;
}
for (auto const &item : body) {
if (x == item.x && y == item.y) {
return true;
}
}
return false;
} | [
"[email protected]"
] | |
3aa859744ba82f98f5b53e9838bc0db94118fe26 | 0e34e74e7f6fa6da3fa92cd17f360f8ee04282d7 | /src/chess/ai/ai.h | e5bef1a51892fd1416c76198dbe50de0987bbc45 | [
"MIT"
] | permissive | YellowWaitt/chess | 4724cbd073ccac25538293bcc535f3762a3f4231 | de20e3fa3c89065a73614da0d46049fdced4bbc0 | refs/heads/main | 2023-08-17T22:48:50.958315 | 2021-10-18T15:51:54 | 2021-10-18T15:51:54 | 418,551,640 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 452 | h | #pragma once
#include <memory>
#include "chess/game/chessgame.h"
class AI {
public:
AI(std::shared_ptr<ChessGame> game);
int getDepth();
Move search();
void setDepth(int depth);
void setGame(std::shared_ptr<ChessGame> game);
void stopSearch();
bool wasStopped() const;
private:
struct Private;
std::shared_ptr<Private> d;
std::shared_ptr<ChessGame> game;
};
| [
"[email protected]"
] | |
b7a762202a6132d59370a9384ded6eb809bc7392 | cefd6c17774b5c94240d57adccef57d9bba4a2e9 | /WebKit/Source/JavaScriptCore/heap/MarkedSpace.h | 752d8462ca1b288665195ff2edbf9ff8c18b1bd9 | [
"BSL-1.0"
] | permissive | adzhou/oragle | 9c054c25b24ff0a65cb9639bafd02aac2bcdce8b | 5442d418b87d0da161429ffa5cb83777e9b38e4d | refs/heads/master | 2022-11-01T05:04:59.368831 | 2014-03-12T15:50:08 | 2014-03-12T15:50:08 | 17,238,063 | 0 | 1 | BSL-1.0 | 2022-10-18T04:23:53 | 2014-02-27T05:39:44 | C++ | UTF-8 | C++ | false | false | 9,975 | h | /*
* Copyright (C) 1999-2000 Harri Porten ([email protected])
* Copyright (C) 2001 Peter Kelly ([email protected])
* Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2011 Apple Inc. All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
#ifndef MarkedSpace_h
#define MarkedSpace_h
#include "MachineStackMarker.h"
#include "MarkedAllocator.h"
#include "MarkedBlock.h"
#include "MarkedBlockSet.h"
#include <array>
#include <wtf/PageAllocationAligned.h>
#include <wtf/Bitmap.h>
#include <wtf/DoublyLinkedList.h>
#include <wtf/HashSet.h>
#include <wtf/Noncopyable.h>
#include <wtf/Vector.h>
namespace JSC {
class DelayedReleaseScope;
class Heap;
class HeapIterationScope;
class JSCell;
class LiveObjectIterator;
class LLIntOffsetsExtractor;
class WeakGCHandle;
class SlotVisitor;
struct ClearMarks : MarkedBlock::VoidFunctor {
void operator()(MarkedBlock* block)
{
block->clearMarks();
}
};
struct ClearRememberedSet : MarkedBlock::VoidFunctor {
void operator()(MarkedBlock* block)
{
block->clearRememberedSet();
}
};
struct Sweep : MarkedBlock::VoidFunctor {
void operator()(MarkedBlock* block) { block->sweep(); }
};
struct MarkCount : MarkedBlock::CountFunctor {
void operator()(MarkedBlock* block) { count(block->markCount()); }
};
struct Size : MarkedBlock::CountFunctor {
void operator()(MarkedBlock* block) { count(block->markCount() * block->cellSize()); }
};
class MarkedSpace {
WTF_MAKE_NONCOPYABLE(MarkedSpace);
public:
MarkedSpace(Heap*);
~MarkedSpace();
void lastChanceToFinalize();
MarkedAllocator& firstAllocator();
MarkedAllocator& allocatorFor(size_t);
MarkedAllocator& immortalStructureDestructorAllocatorFor(size_t);
MarkedAllocator& normalDestructorAllocatorFor(size_t);
void* allocateWithNormalDestructor(size_t);
void* allocateWithImmortalStructureDestructor(size_t);
void* allocateWithoutDestructor(size_t);
void resetAllocators();
void visitWeakSets(HeapRootVisitor&);
void reapWeakSets();
MarkedBlockSet& blocks() { return m_blocks; }
void willStartIterating();
bool isIterating() { return m_isIterating; }
void didFinishIterating();
void stopAllocating();
void resumeAllocating(); // If we just stopped allocation but we didn't do a collection, we need to resume allocation.
typedef HashSet<MarkedBlock*>::iterator BlockIterator;
template<typename Functor> typename Functor::ReturnType forEachLiveCell(HeapIterationScope&, Functor&);
template<typename Functor> typename Functor::ReturnType forEachLiveCell(HeapIterationScope&);
template<typename Functor> typename Functor::ReturnType forEachDeadCell(HeapIterationScope&, Functor&);
template<typename Functor> typename Functor::ReturnType forEachDeadCell(HeapIterationScope&);
template<typename Functor> typename Functor::ReturnType forEachBlock(Functor&);
template<typename Functor> typename Functor::ReturnType forEachBlock();
void shrink();
void freeBlock(MarkedBlock*);
void freeOrShrinkBlock(MarkedBlock*);
void didAddBlock(MarkedBlock*);
void didConsumeFreeList(MarkedBlock*);
void didAllocateInBlock(MarkedBlock*);
void clearMarks();
void clearRememberedSet();
void clearNewlyAllocated();
void sweep();
size_t objectCount();
size_t size();
size_t capacity();
bool isPagedOut(double deadline);
#if USE(CF)
template<typename T> void releaseSoon(RetainPtr<T>&&);
#endif
private:
friend class DelayedReleaseScope;
friend class LLIntOffsetsExtractor;
template<typename Functor> void forEachAllocator(Functor&);
template<typename Functor> void forEachAllocator();
// [ 32... 128 ]
static const size_t preciseStep = MarkedBlock::atomSize;
static const size_t preciseCutoff = 128;
static const size_t preciseCount = preciseCutoff / preciseStep;
// [ 1024... blockSize ]
static const size_t impreciseStep = 2 * preciseCutoff;
static const size_t impreciseCutoff = MarkedBlock::blockSize / 2;
static const size_t impreciseCount = impreciseCutoff / impreciseStep;
struct Subspace {
std::array<MarkedAllocator, preciseCount> preciseAllocators;
std::array<MarkedAllocator, impreciseCount> impreciseAllocators;
MarkedAllocator largeAllocator;
};
Subspace m_normalDestructorSpace;
Subspace m_immortalStructureDestructorSpace;
Subspace m_normalSpace;
Heap* m_heap;
size_t m_capacity;
bool m_isIterating;
MarkedBlockSet m_blocks;
Vector<MarkedBlock*> m_blocksWithNewObjects;
DelayedReleaseScope* m_currentDelayedReleaseScope;
};
template<typename Functor> inline typename Functor::ReturnType MarkedSpace::forEachLiveCell(HeapIterationScope&, Functor& functor)
{
ASSERT(isIterating());
BlockIterator end = m_blocks.set().end();
for (BlockIterator it = m_blocks.set().begin(); it != end; ++it)
(*it)->forEachLiveCell(functor);
return functor.returnValue();
}
template<typename Functor> inline typename Functor::ReturnType MarkedSpace::forEachLiveCell(HeapIterationScope& scope)
{
Functor functor;
return forEachLiveCell(scope, functor);
}
template<typename Functor> inline typename Functor::ReturnType MarkedSpace::forEachDeadCell(HeapIterationScope&, Functor& functor)
{
ASSERT(isIterating());
BlockIterator end = m_blocks.set().end();
for (BlockIterator it = m_blocks.set().begin(); it != end; ++it)
(*it)->forEachDeadCell(functor);
return functor.returnValue();
}
template<typename Functor> inline typename Functor::ReturnType MarkedSpace::forEachDeadCell(HeapIterationScope& scope)
{
Functor functor;
return forEachDeadCell(scope, functor);
}
inline MarkedAllocator& MarkedSpace::allocatorFor(size_t bytes)
{
ASSERT(bytes);
if (bytes <= preciseCutoff)
return m_normalSpace.preciseAllocators[(bytes - 1) / preciseStep];
if (bytes <= impreciseCutoff)
return m_normalSpace.impreciseAllocators[(bytes - 1) / impreciseStep];
return m_normalSpace.largeAllocator;
}
inline MarkedAllocator& MarkedSpace::immortalStructureDestructorAllocatorFor(size_t bytes)
{
ASSERT(bytes);
if (bytes <= preciseCutoff)
return m_immortalStructureDestructorSpace.preciseAllocators[(bytes - 1) / preciseStep];
if (bytes <= impreciseCutoff)
return m_immortalStructureDestructorSpace.impreciseAllocators[(bytes - 1) / impreciseStep];
return m_immortalStructureDestructorSpace.largeAllocator;
}
inline MarkedAllocator& MarkedSpace::normalDestructorAllocatorFor(size_t bytes)
{
ASSERT(bytes);
if (bytes <= preciseCutoff)
return m_normalDestructorSpace.preciseAllocators[(bytes - 1) / preciseStep];
if (bytes <= impreciseCutoff)
return m_normalDestructorSpace.impreciseAllocators[(bytes - 1) / impreciseStep];
return m_normalDestructorSpace.largeAllocator;
}
inline void* MarkedSpace::allocateWithoutDestructor(size_t bytes)
{
return allocatorFor(bytes).allocate(bytes);
}
inline void* MarkedSpace::allocateWithImmortalStructureDestructor(size_t bytes)
{
return immortalStructureDestructorAllocatorFor(bytes).allocate(bytes);
}
inline void* MarkedSpace::allocateWithNormalDestructor(size_t bytes)
{
return normalDestructorAllocatorFor(bytes).allocate(bytes);
}
template <typename Functor> inline typename Functor::ReturnType MarkedSpace::forEachBlock(Functor& functor)
{
for (size_t i = 0; i < preciseCount; ++i)
m_normalSpace.preciseAllocators[i].forEachBlock(functor);
for (size_t i = 0; i < impreciseCount; ++i)
m_normalSpace.impreciseAllocators[i].forEachBlock(functor);
m_normalSpace.largeAllocator.forEachBlock(functor);
for (size_t i = 0; i < preciseCount; ++i)
m_normalDestructorSpace.preciseAllocators[i].forEachBlock(functor);
for (size_t i = 0; i < impreciseCount; ++i)
m_normalDestructorSpace.impreciseAllocators[i].forEachBlock(functor);
m_normalDestructorSpace.largeAllocator.forEachBlock(functor);
for (size_t i = 0; i < preciseCount; ++i)
m_immortalStructureDestructorSpace.preciseAllocators[i].forEachBlock(functor);
for (size_t i = 0; i < impreciseCount; ++i)
m_immortalStructureDestructorSpace.impreciseAllocators[i].forEachBlock(functor);
m_immortalStructureDestructorSpace.largeAllocator.forEachBlock(functor);
return functor.returnValue();
}
template <typename Functor> inline typename Functor::ReturnType MarkedSpace::forEachBlock()
{
Functor functor;
return forEachBlock(functor);
}
inline void MarkedSpace::didAddBlock(MarkedBlock* block)
{
m_capacity += block->capacity();
m_blocks.add(block);
}
inline void MarkedSpace::didAllocateInBlock(MarkedBlock* block)
{
#if ENABLE(GGC)
m_blocksWithNewObjects.append(block);
#else
UNUSED_PARAM(block);
#endif
}
inline void MarkedSpace::clearRememberedSet()
{
forEachBlock<ClearRememberedSet>();
}
inline size_t MarkedSpace::objectCount()
{
return forEachBlock<MarkCount>();
}
inline size_t MarkedSpace::size()
{
return forEachBlock<Size>();
}
inline size_t MarkedSpace::capacity()
{
return m_capacity;
}
} // namespace JSC
#endif // MarkedSpace_h
| [
"[email protected]"
] | |
5fdefb72adf08e9ce7e5a6484baaf8899f63fe41 | 0c3a00a110988e96e669fdf9295a5add6152837d | /Source/wali/include/wali/Countable.hpp | d74edc5442cb2d5561b62d7511a26aab9fbbd562 | [
"MIT"
] | permissive | pdschubert/WALi-OpenNWA | 0e360ac04326aa9cd20155b311898e1b6ff99d07 | 57c26420fb25bbb4bba8a6de3641fef0eb9967e0 | refs/heads/master | 2022-08-27T07:32:07.005480 | 2022-08-18T13:54:50 | 2022-08-18T13:54:50 | 148,313,943 | 1 | 5 | NOASSERTION | 2020-02-20T12:06:30 | 2018-09-11T12:30:20 | C++ | UTF-8 | C++ | false | false | 1,251 | hpp | #ifndef wali_COUNTABLE_GUARD
#define wali_COUNTABLE_GUARD 1
/**
* @author Nicholas Kidd
*/
#include "wali/Common.hpp"
#include "wali/ref_ptr.hpp"
namespace wali
{
class Countable
{
public:
ref_ptr<Countable>::count_t count;
public:
/**
* <b>Note:</b> The capability that a reference counted
* object should never be reclaimed has been removed.
* If you require an object to "live forever", then it
* is up to you to hold onto a reference to the object.
*/
Countable() : count(0) {}
/**
* The copy constructor creates a new instance of
* Countable, therefore its "count" is initialized to 0.
*/
Countable( const Countable& c ATTR_UNUSED ) : count(0)
{
(void) c;
}
/**
* Countable::operator= does not modify "this's" count.
* This is because operator= does not modify the number of
* pointers which refer to this. Therefore, operator= is a
* nop.
*/
Countable& operator=( const Countable& c ATTR_UNUSED ) throw()
{
(void) c;
return *this;
}
virtual ~Countable() {}
}; // class Countable
} // namespace wali
#endif // wali_COUNTABLE_GUARD
| [
"[email protected]"
] | |
733b8eee36cdf4ac4e6f7f45bbb5abd6a6cc5001 | e7a6dcad59bcd383ac7b007fd4fe5968799202c3 | /SSEngine/Engine/Core/Private/String/PooledString.cpp | 3ed8a07ac024d48de3412b072ce422764f2044a1 | [] | no_license | flashshan/SSEngine | d6848eab4ab1ba0ed56333da8fc9846415ba6da7 | ed33adbf3b9e372d0f6a64d562bf0787e31ed764 | refs/heads/master | 2021-09-25T02:34:58.750177 | 2018-10-17T07:12:24 | 2018-10-17T07:12:24 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 507 | cpp | #include "Core\String\PooledString.h"
bool PooledString::Equal(const char *i_string) const
{
if (strlen(i_string) != length_)
{
return false;
}
for (uint32 i = 0;i < length_;++i)
{
if (i_string[i] != string_[i])
{
return false;
}
}
return true;
}
bool PooledString::Equal(const char *i_string, uint32 i_length) const
{
if (i_length != length_)
{
return false;
}
for (uint32 i = 0;i < i_length; ++i)
{
if (i_string[i] != string_[i])
{
return false;
}
}
return true;
} | [
"[email protected]"
] | |
e9ab6d9259faddc4ec6850451c67ec45685a351d | 47947b3fc5c450697ddb0a79e7fa1258d4ffe6fa | /GEDEFinal/Agent.cpp | dd62a510ef51884a370f31bbcc06fd8e47aa6636 | [] | no_license | Tsiniloiv/GEDE2016Final | feec7a22071aab2fb623992db9f1f3ab434b52bd | 89f4c2119c28389cf84183316c7550f167d44ac6 | refs/heads/master | 2021-01-10T15:17:28.433773 | 2016-04-04T22:21:33 | 2016-04-04T22:21:33 | 54,785,124 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 446 | cpp | #include "OGRE/Ogre.h"
#include "State.cpp"
#include "OIS\OIS.h"
#include "SearchNode.cpp"
using namespace std;
class Agent {
/*
Member variables: current state, current path
Methods: search, return next destination
*/
private:
State currState;
std::deque<Ogre::Vector3> currSolution;
public:
Agent(State s) {
currState = s;
}
void search() {
SearchNode root = SearchNode(currState, nullptr, actions::none, 0);
}
}; | [
"[email protected]"
] | |
4fade441bab5158c22661e021cbb918c29fb2c75 | f0bd42c8ae869dee511f6d41b1bc255cb32887d5 | /SPOJ/1112 - Number Steps.cpp | 225bbc4cd52c969a582a294ff2ba7bb9f49e05de | [] | no_license | osamahatem/CompetitiveProgramming | 3c68218a181d4637c09f31a7097c62f20977ffcd | a5b54ae8cab47b2720a64c68832a9c07668c5ffb | refs/heads/master | 2021-06-10T10:21:13.879053 | 2020-07-07T14:59:44 | 2020-07-07T14:59:44 | 113,673,720 | 3 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 423 | cpp | #include<cstdio>
main()
{
int n,x,y;
scanf("%d",&n);
for(n;n>0;n--)
{
scanf("%d%d",&x,&y);
if(x==y || x-y==2)
{
if(x%2==0)
{
printf("%d\n",x+y);
}
else
{
printf("%d\n",x+y-1);
}
}
else
{
printf("No Number\n");
}
}
return 0;
}
| [
"[email protected]"
] | |
292745fd33d5106ca1274fc80ac287d01b3b9f34 | 8cd1360b1b51912feed056c50596f59a0acbcbac | /BOJ_11060.cpp | 2361ff74fcd56e7e2be0892790744eb4e29dad6f | [] | no_license | evga7/Practice_Algorithm_01 | 9b3ea1c48594cda7242c85036abed6621c2825b7 | c6bf370926f517b4454f5990671df6c1abc03414 | refs/heads/master | 2021-09-24T09:53:30.729444 | 2021-09-16T10:51:49 | 2021-09-16T10:51:49 | 201,005,519 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 617 | cpp | #include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <string.h>
using namespace std;
int T, N, M;
int arr[1001];
int dp[1001];
int main()
{
int i, j;
int N;
scanf("%d", &N);
for (i = 1; i <= N; i++)
{
scanf("%d", &arr[i]);
}
dp[1] = 1;
for (i = 1; i <= N; i++)
{
if (dp[i] == 0)
break;
for (j = 1; j <=arr[i]; j++)
{
if (i + j > 1000)
break;
if (dp[i + j] == 0)
{
dp[i + j] = dp[i] + 1;
}
else
dp[i + j] = min(dp[i] + 1, dp[i + j]);
}
}
if (dp[N] == 0)
printf("-1");
else
printf("%d", dp[N]-1);
} | [
"[email protected]"
] | |
951830cc6e8e8903073973073e4fcddc1508e292 | 5ddf736c86cd6a9621c5351e7499e7fbb39ffe08 | /XDataThread.cpp | 39b201a77fd677f46d4d8492e5b0a1896f0fac58 | [] | no_license | XingShunlee/OpenCVFFmpegRtmp | bd2036886aaae3e81baffa2071680589ece55e82 | d8d4369349a4f0c851f83dd7368540157abe2f65 | refs/heads/master | 2023-03-15T23:50:51.501722 | 2019-08-05T06:36:39 | 2019-08-05T06:36:39 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,387 | cpp | //
// Created by hengfeng zhuo on 2019-08-05.
//
#include "XDataThread.h"
XDataThread::XDataThread() {
}
XDataThread::~XDataThread() {
}
bool XDataThread::Start() {
this->isExit = false;
// 启动QT线程
QThread::start();
return true;
}
// wait()阻塞当前的进程,直到满足如下两个条件之一:
// 1.相关的线程完成其任务,然后如果线程已经结束,则该函数返回true,如果线程没有启动,则该函数也会返回true。
// 2. 经过了特定长度的时间,如果时间是ULONG_MAX(默认值),那么wait()函数几乎不会超时。
// (即该函数必须从run()函数返回)如果wait函数超时,那么该函数会返回false。
void XDataThread::Stop() {
this->isExit = true;
wait(); // 等待退出
}
void XDataThread::Push(XData d) {
mutex.lock();
// 如果数据超出大小了,丢弃数据
if (datas.size() > maxList) {
datas.front().Drop();
datas.pop_front(); // 取出队列第一个元素
}
// 存入数据
datas.push_back(d); // 存入到队列最后
mutex.unlock();
}
XData XDataThread::Pop() {
mutex.lock();
if (datas.empty()) {
// 如果是空的,就返回一个空数据
mutex.unlock();
return XData();
}
XData d = datas.front();
datas.pop_front();
mutex.unlock();
return d;
}
| [
"[email protected]"
] | |
6e7ea3ec7a685313c81d35de20fb9dd331dd3910 | 0f4012d03230b59125ac3c618f9b5e5e61d4cc7d | /Cocos2d-x/2.0-x-2.03_branch_231_NoScript/projects/BJL/Classes/net/TcpNetwork.h | 6891fe70527edd0d35dc10fb7b863b85b3242a11 | [
"MIT"
] | permissive | daxingyou/SixCocos2d-xVC2012 | 80d0a8701dda25d8d97ad88b762aadd7e014c6ee | 536e5c44b08c965744cd12103d3fabd403051f19 | refs/heads/master | 2022-04-27T06:41:50.396490 | 2020-05-01T02:57:20 | 2020-05-01T02:57:20 | null | 0 | 0 | null | null | null | null | GB18030 | C++ | false | false | 1,495 | h | //
// TcpNetwork.h
// SDH
//
// Created by zhouwei on 13-6-6.
//
//
#ifndef __SDH__TcpNetwork__
#define __SDH__TcpNetwork__
#include <iostream>
#include "common/Define.h"
#include "ans/BaseObject.h"
#include "event/GBEvent.h"
#include "net/GC_Socket.h"
//class MsgDispatch;
class ClientSock : public BaseObject
{
public:
ClientSock();
~ClientSock();
void update();
//判断释放连接游戏服务器
bool isConectServer();
//连接服务器
bool connectGameServer(const char* ip, unsigned short port);
void sendData(WORD wMainCmdID,WORD wSubCmdID);
void sendData(void* pData,WORD wDataSize,WORD wMainCmdID,WORD wSubCmdID,WORD wRountID);
void sendData(WORD wMainCmdID,WORD wSubCmdID,void* pData,DWORD wDataSize);
void recvData(GBEventArg& arg);
WORD encryptBuffer(BYTE pcbDataBuffer[], WORD wDataSize, WORD wBufferSize);
WORD crevasseBuffer(BYTE pcbDataBuffer[], WORD wDataSize);
//随机映射
WORD SeedRandMap(WORD wSeed);
//映射发送数据
BYTE MapSendByte(BYTE const cbData);
//映射接收数据
BYTE MapRecvByte(BYTE const cbData);
//重置
void reset();
//关闭套接字
void closeSocket();
public:
//void setDispatch(MsgDispatch* p) { m_pMsgDispatch = p; }
private:
IGC_SocketStream* m_pISocketStrem;
//MsgDispatch* m_pMsgDispatch;
private:
BYTE m_cbSendRound;
BYTE m_cbRecvRound;
DWORD m_dwSendXorKey;
DWORD m_dwRecvXorKey;
DWORD m_dwSendPacketCount;
DWORD m_dwRecvPacketCount;
};
#endif /* defined(__SDH__TcpNetwork__) */
| [
"[email protected]"
] | |
928cadad396313ea5dbd8778dde8fe3f7144bf9a | 590931551fe8fdc421b7be31fdada97336754435 | /rpg/prop.cpp | f739a2349d5ffe5d76e5f3e7e08991b23fe8ee6f | [] | no_license | changyook21/Classic-RPG-game | fed6fb7bd49c78cc7065079115caff174b19c52b | 3f73b780dfc80e52ab290e0a51724d5d0f4751ca | refs/heads/master | 2016-08-11T17:50:37.476519 | 2016-01-19T07:50:11 | 2016-01-19T07:50:11 | 49,935,810 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 18,134 | cpp | #include <iostream>
using namespace std;
#include "main.h"
#include "unit.h"
#include "item.h"
#include "board.h"
#include "prop.h"
//extern Board *sim->board;
#include "sim.h"
extern Sim *sim;
//------------------------------------------------------------------------------
// class Prop: the parent class of class Tree & Portal & Fountain & Bush
//------------------------------------------------------------------------------
Prop::Prop() {
this->shape = '\0';
row = -1;
col = -1;
}
Prop::Prop(char shape) {
this->shape = shape;
row = -1;
col = -1;
}
Prop::~Prop() {
}
void Prop::print() {
cout << shape;
}
int Prop::getRow() {
return row;
}
void Prop::setRow(int row) {
this->row = row;
}
int Prop::getCol() {
return col;
}
void Prop::setCol(int col) {
this->col = col;
}
bool Prop::isClimbable() {
// N/A
return false;
}
bool Prop::kickout() {
// N/A
return false;
}
bool Prop::isTree() {
// N/A
return false;
}
bool Prop::isPortal() {
// N/A
return false;
}
bool Prop::isFount() {
// N/A
return false;
}
bool Prop::isDoor() {
// N/A
return false;
}
bool Prop::isCar() {
return false;
}
bool Prop::isHolyStatue() {
// N/A
return false;
}
bool Prop::isBush() {
// N/A
return false;
}
void Prop::trigger(Unit *unit) {
// N/A
}
void Prop::deactivate(Unit *unit) {
// N/A
}
void Prop::drive(int dir) {
// N/A
}
void Prop::effect(Unit *unit, Item *item, Prop *prop) {
// N/A
}
void Prop::save(ostream &out) {
out << "#-------------------- class Prop" << endl;
out << "# shape" << endl;
out << shape << endl;
out << "# row" << endl;
out << row << endl;
out << "# col" << endl;
out << col << endl;
}
void Prop::load(istream &in) {
char buf[MAX_LEN_BUF];
//out << "#-------------------- class Prop" << endl;
in.getline(buf, MAX_LEN_BUF); // skip comment
//out << "# shape" << endl;
in.getline(buf, MAX_LEN_BUF); // skip comment
//out << shape << endl;
in >> shape;
in.get(); // skip enter code.
//out << "# row" << endl;
in.getline(buf, MAX_LEN_BUF); // skip comment
//out << row << endl;
in >> row;
in.get(); // skip enter code.
//out << "# col" << endl;
in.getline(buf, MAX_LEN_BUF); // skip comment
//out << col << endl;
in >> col;
in.get(); // skip enter code.
}
Prop *createPropByShape(char shape) {
if (shape == DEFAULT_TREE_SHAPE) {
return new Tree();
}
else if (shape == DEFAULT_PORTAL_SHAPE) {
return new Portal();
}
else if (shape == DEFAULT_FOUNTAIN_SHAPE) {
return new Fount();
}
else if (shape == DEFAULT_BUSH_SHAPE) {
return new Bush();
}
else if (shape == DEFAULT_CAR_SHAPE) {
return new Car();
}
else if (shape == DEFAULT_HOLY_STATUE_SHAPE) {
return new HolyStatue();
}
else if (shape == DEFAULT_EXIT_SHAPE) {
return new Exit();
}
else if (shape == DEFAULT_WALL_SHAPE_01 ||
shape == DEFAULT_WALL_SHAPE_02 ||
shape == DEFAULT_WALL_SHAPE_03) {
return new Wall(shape);
}
else if (shape == DEFAULT_DOOR_SHAPE) {
return new Exit();
}
return NULL;
}
Prop *createPropByID(string propID) {
if (propID == PROP_ID_TREE) {
return new Tree();
}
else if (propID == PROP_ID_PORTAL) {
return new Portal();
}
else if (propID == PROP_ID_FOUNTAIN) {
return new Fount();
}
else if (propID == PROP_ID_BUSH) {
return new Bush();
}
else if (propID == PROP_ID_CAR) {
return new Car();
}
else if (propID == PROP_ID_HOLY_STATUE) {
return new HolyStatue();
}
else if (propID == PROP_ID_EXIT) {
return new Exit();
}
else if (propID == PROP_ID_WALL) {
return new Wall();
}
else if (propID == PROP_ID_DOOR) {
return new Wall();
}
return NULL;
}
//------------------------------------------------------------------------------
// class Tree: the child class of class Prop.
//------------------------------------------------------------------------------
Tree::Tree() : Prop(DEFAULT_TREE_SHAPE) {
}
Tree::Tree(char shape) : Prop(shape) {
}
Tree::~Tree() {
}
bool Tree::isTree() {
return true;
}
string Tree::getID() {
return PROP_ID_TREE;
}
void Tree::save(ostream &out) {
Prop::save(out);
out << "#-------------------- class Tree" << endl;
}
void Tree::load(istream &in) {
Prop::load(in);
char buf[MAX_LEN_BUF];
//out << "#-------------------- class Tree" << endl;
in.getline(buf, MAX_LEN_BUF); // skip comment
}
//------------------------------------------------------------------------------
// class Portal: the child class of class Prop.
//------------------------------------------------------------------------------
Portal::Portal() : Prop(DEFAULT_PORTAL_SHAPE) {
}
Portal::Portal(char shape) : Prop(shape) {
}
Portal::~Portal() {
}
bool Portal::isClimbable() {
return true;
}
bool Portal::isPortal() {
return true;
}
void Portal::trigger(Unit *unit) { // virtual function
if (unit == NULL) {
return;
}
while (true) { // infinite loop
int randRow = rand() % sim->board->getRowSize();
int randCol = rand() % sim->board->getColSize();
if (sim->board->getProp(randRow, randCol) == NULL &&
sim->board->getUnit(randRow, randCol) == NULL &&
sim->board->getItem(randRow, randCol) == NULL) {
sim->board->setUnit(unit->getRow(), unit->getCol(), NULL);
sim->board->setUnit(randRow, randCol, unit);
break;
}
}
}
string Portal::getID() {
return PROP_ID_PORTAL;
}
void Portal::save(ostream &out) {
Prop::save(out);
out << "#-------------------- class Portal" << endl;
}
void Portal::load(istream &in) {
Prop::load(in);
char buf[MAX_LEN_BUF];
//out << "#-------------------- class Portal" << endl;
in.getline(buf, MAX_LEN_BUF); // skip comment
}
//------------------------------------------------------------------------------
// class Fountain: the child class of class Prop.
//------------------------------------------------------------------------------
Fount::Fount() : Prop(DEFAULT_FOUNTAIN_SHAPE) {
hp = DEFAULT_FOUNTAIN_HP;
mp = DEFAULT_FOUNTAIN_MP;
}
Fount::Fount(char shape, int hp, int mp) : Prop(shape) {
this->hp = hp;
this->mp = mp;
}
Fount::~Fount() {
}
bool Fount::isFount() {
return true;
}
void Fount::trigger(Unit *unit) { // virtual function
if (unit == NULL) {
return;
}
unit->incHp(hp);
unit->incMp(mp);
}
string Fount::getID() {
return PROP_ID_FOUNTAIN;
}
void Fount::save(ostream &out) {
Prop::save(out);
out << "#-------------------- class Fount" << endl;
out << "# hp" << endl;
out << hp << endl;
out << "# mp" << endl;
out << mp << endl;
}
void Fount::load(istream &in) {
Prop::load(in);
char buf[MAX_LEN_BUF];
//out << "#-------------------- class Prop" << endl;
in.getline(buf, MAX_LEN_BUF); // skip comment
//out << "# hp" << endl;
in.getline(buf, MAX_LEN_BUF); // skip comment
//out << hp << endl;
in >> hp;
in.get(); // skip enter code.
//out << "# mp" << endl;
in.getline(buf, MAX_LEN_BUF); // skip comment
//out << mp << endl;
in >> mp;
in.get(); // skip enter code.
}
//------------------------------------------------------------------------------
// class Bush: the child class of class Prop.
//------------------------------------------------------------------------------
Bush::Bush() : Prop(DEFAULT_BUSH_SHAPE) {
unitHidden = NULL;
}
Bush::Bush(char shape) : Prop(shape) {
unitHidden = NULL;
}
Bush::~Bush() {
}
bool Bush::isClimbable() {
return true;
}
bool Bush::isBush() {
return true;
}
void Bush::trigger(Unit *unit) { // virtual function
if (unit == NULL) {
return;
}
if (unitHidden != NULL) {
return;
}
sim->board->setUnit(unit->getRow(), unit->getCol(), NULL);
unit->setRow(row);
unit->setCol(col);
unitHidden = unit;
}
void Bush::deactivate(Unit *unit) {
unitHidden = NULL;
}
string Bush::getID() {
return PROP_ID_BUSH;
}
void Bush::save(ostream &out) {
Prop::save(out);
out << "#-------------------- class Bush" << endl;
//out << "# unitHidden" << endl;
//unitHidden->save(out);
}
void Bush::load(istream &in) {
Prop::load(in);
char buf[MAX_LEN_BUF];
//out << "#-------------------- class Bush" << endl;
in.getline(buf, MAX_LEN_BUF); // skip comment
// don't save unitHidden
}
//------------------------------------------------------------------------------
// class Door
//------------------------------------------------------------------------------
Door::Door() : Prop(DEFAULT_DOOR_SHAPE) {
}
Door::Door(char shape) : Prop(shape) {
}
Door::~Door() {
}
bool Door::isDoor() {
return true;
}
void Door::trigger(Unit *unit) { // virtual function
if (unit == NULL) {
return;
}
}
string Door::getID() {
return PROP_ID_DOOR;
}
void Door::save(ostream &out) {
Prop::save(out);
out << "#-------------------- class Bush" << endl;
//out << "# unitHidden" << endl;
//unitHidden->save(out);
}
void Door::load(istream &in) {
Prop::load(in);
char buf[MAX_LEN_BUF];
//out << "#-------------------- class Bush" << endl;
in.getline(buf, MAX_LEN_BUF); // skip comment
// don't save unitHidden
}
//------------------------------------------------------------------------------
// class Car: the child class of class Prop.
//------------------------------------------------------------------------------
Car::Car() : Prop(DEFAULT_CAR_SHAPE) {
passenger = NULL;
prevDir = DEFAULT_CAR_DIR;
dir = DEFAULT_CAR_DIR;
speed = SPEED_CAR;
visited = false;
}
Car::Car(char shape) : Prop(shape) {
passenger = NULL;
prevDir = DEFAULT_CAR_DIR;
dir = DEFAULT_CAR_DIR;
speed = SPEED_CAR;
visited = false;
}
Car::~Car() {
}
void Car::setDir(int dir) {
this->dir = dir;
}
bool Car::isVisited() {
return visited;
}
void Car::resetVisited() {
visited = false;
}
bool Car::kickout() {
if (passenger != NULL) {
int exitDir = (prevDir + NUM_DIRS - 1) % NUM_DIRS;
for (int i = 0; i < NUM_DIRS; i++) {
int exitRow = -1;
int exitCol = -1;
if (exitDir == DIR_N) {
exitRow = row - 1;
exitCol = col;
}
else if (exitDir == DIR_E) {
exitRow = row;
exitCol = col + 1;
}
else if (exitDir == DIR_S) {
exitRow = row + 1;
exitCol = col;
}
else { // if (exitDir == DIR_W) {
exitRow = row;
exitCol = col - 1;
}
// if the exit position is empty
if (sim->board->validate(exitRow, exitCol) &&
sim->board->getProp(exitRow, exitCol) == NULL &&
sim->board->getUnit(exitRow, exitCol) == NULL) {
sim->board->setUnit(exitRow, exitCol, passenger);
passenger = NULL;
return true;
}
exitDir = (exitDir + 1) % NUM_DIRS;
}
}
return false;
}
bool Car::isCar() {
return true;
}
void Car::trigger(Unit *unit) { // virtual function
if (unit == NULL) {
return;
}
if (passenger != NULL) {
return;
}
passenger = unit;
}
void Car::deactivate(Unit *unit) {
passenger = NULL;
}
void Car::drive(int dir) {
visited = true;
if (passenger != NULL) {
if (dir == DIR_NONE) {
if (this->dir == DIR_NONE) {
return;
}
}
else {
if (this->dir == DIR_NONE) {
prevDir = this->dir;
this->dir = dir;
}
}
int nextRow = -1;
int nextCol = -1;
if (this->dir == DIR_N) {
nextRow = row - 1;
nextCol = col;
}
else if (this->dir == DIR_E) {
nextRow = row;
nextCol = col + 1;
}
else if (this->dir == DIR_S) {
nextRow = row + 1;
nextCol = col;
}
else if (this->dir == DIR_W) {
nextRow = row;
nextCol = col - 1;
}
else {
return;
}
// if the next position is empty
if (sim->board->validate(nextRow, nextCol) &&
sim->board->getProp(nextRow, nextCol) == NULL &&
sim->board->getUnit(nextRow, nextCol) == NULL) {
sim->board->setProp(row, col, NULL);
sim->board->setProp(nextRow, nextCol, this);
}
else {
sim->board->setProp(row, col, NULL);
}
}
}
string Car::getID() {
return PROP_ID_CAR;
}
void Car::save(ostream &out) {
Prop::save(out);
out << "#-------------------- class Car" << endl;
//out << "# passenger" << endl;
//passenger->save(out);
out << "# prevDir" << endl;
out << prevDir << endl;
out << "# dir" << endl;
out << dir << endl;
out << "# speed" << endl;
out << speed << endl;
out << "# visited" << endl;
out << visited << endl;
}
void Car::load(istream &in) {
Prop::load(in);
char buf[MAX_LEN_BUF];
//out << "#-------------------- class Car" << endl;
in.getline(buf, MAX_LEN_BUF); // skip comment
// don't save unitHidden
//out << "# prevDir" << endl;
in.getline(buf, MAX_LEN_BUF); // skip comment
//out << prevDir << endl;
in >> prevDir;
in.get(); // skip enter code.
//out << "# dir" << endl;
in.getline(buf, MAX_LEN_BUF); // skip comment
//out << dir << endl;
in >> dir;
in.get(); // skip enter code.
//out << "# speed" << endl;
in.getline(buf, MAX_LEN_BUF); // skip comment
//out << speed << endl;
in >> speed;
in.get(); // skip enter code.
//out << "# visited" << endl;
in.getline(buf, MAX_LEN_BUF); // skip comment
//out << visited << endl;
in >> visited;
in.get(); // skip enter code.
}
//------------------------------------------------------------------------------
// class Fountain: the child class of class Prop.
//------------------------------------------------------------------------------
HolyStatue::HolyStatue() : Prop(DEFAULT_HOLY_STATUE_SHAPE) {
initHolyStatue(DEFAULT_HOLY_STATUE_HP, DEFAULT_HOLY_STATUE_MP);
}
HolyStatue::HolyStatue(char shape, int hp, int mp) : Prop(shape) {
initHolyStatue(hp, mp);
}
void HolyStatue::initHolyStatue(int hp, int mp) {
this->hp = hp;
this->mp = mp;
interval = HOLY_STATUE_INTERVAL;
}
HolyStatue::~HolyStatue() {
}
bool HolyStatue::isHolyStatue() {
return true;
}
void HolyStatue::start() {
if (interval == HOLY_STATUE_INTERVAL) {
sim->board->startWave(NULL, NULL, this,
row, col, SHOCKWAVE_HOLY_STATUE_ID);
}
interval--;
if (interval <= 0) {
interval = HOLY_STATUE_INTERVAL;
}
}
void HolyStatue::trigger(Unit *unit) { // virtual function
}
void HolyStatue::effect(Unit *unit, Item *item, Prop *prop) {
if (unit == NULL) {
return;
}
unit->incHp(hp);
unit->incMp(mp);
}
string HolyStatue::getID() {
return PROP_ID_HOLY_STATUE;
}
void HolyStatue::save(ostream &out) {
Prop::save(out);
out << "#-------------------- class HolyStatue" << endl;
out << "# hp" << endl;
out << hp << endl;
out << "# mp" << endl;
out << mp << endl;
out << "# interval" << endl;
out << interval << endl;
}
void HolyStatue::load(istream &in) {
Prop::load(in);
char buf[MAX_LEN_BUF];
//out << "#-------------------- class HolyStatue" << endl;
in.getline(buf, MAX_LEN_BUF); // skip comment
//out << "# hp" << endl;
in.getline(buf, MAX_LEN_BUF); // skip comment
//out << hp << endl;
in >> hp;
in.get(); // skip enter code.
//out << "# mp" << endl;
in.getline(buf, MAX_LEN_BUF); // skip comment
//out << mp << endl;
in >> mp;
in.get(); // skip enter code.
//out << "# interval" << endl;
in.getline(buf, MAX_LEN_BUF); // skip comment
//out << interval << endl;
in >> interval;
in.get(); // skip enter code.
}
//------------------------------------------------------------------------------
// class Exit: the child class of class Prop.
//------------------------------------------------------------------------------
Exit::Exit() : Prop(DEFAULT_EXIT_SHAPE) {
}
Exit::Exit(char shape) : Prop(shape) {
}
Exit::~Exit() {
}
bool Exit::isClimbable() {
return true;
}
bool Exit::isExit() {
return true;
}
void Exit::trigger(Unit *unit) { // virtual function
if (unit == NULL) {
return;
}
sim->board->setExited(true);
}
string Exit::getID() {
return PROP_ID_EXIT;
}
void Exit::save(ostream &out) {
Prop::save(out);
out << "#-------------------- class Exit" << endl;
}
void Exit::load(istream &in) {
Prop::load(in);
char buf[MAX_LEN_BUF];
//out << "#-------------------- class Exit" << endl;
in.getline(buf, MAX_LEN_BUF); // skip comment
}
//------------------------------------------------------------------------------
// class Wall: the child class of class Prop.
//------------------------------------------------------------------------------
Wall::Wall() : Prop(DEFAULT_WALL_SHAPE_01) {
}
Wall::Wall(char shape) : Prop(shape) {
}
Wall::~Wall() {
}
bool Wall::isWall() {
return true;
}
string Wall::getID() {
return PROP_ID_WALL;
}
void Wall::save(ostream &out) {
Prop::save(out);
out << "#-------------------- class Wall" << endl;
}
void Wall::load(istream &in) {
Prop::load(in);
char buf[MAX_LEN_BUF];
//out << "#-------------------- class Wall" << endl;
in.getline(buf, MAX_LEN_BUF); // skip comment
}
| [
"[email protected]"
] | |
1439c575951e19cdf7a0359073d9ce23969acda9 | 95a43c10c75b16595c30bdf6db4a1c2af2e4765d | /codecrawler/_code/hdu4946/16215042.cpp | 252a7169c0f1c5e3bfb41c05fa94c3bdf21ac9b4 | [] | no_license | kunhuicho/crawl-tools | 945e8c40261dfa51fb13088163f0a7bece85fc9d | 8eb8c4192d39919c64b84e0a817c65da0effad2d | refs/heads/master | 2021-01-21T01:05:54.638395 | 2016-08-28T17:01:37 | 2016-08-28T17:01:37 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,411 | cpp | #include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <queue>
#include <iomanip>
using namespace std;
const int maxn=505;
struct Point{
int x,y,v,id,flag,vis;
Point(int x=0,int y=0):x(x),y(y){}
}e[maxn],p[maxn],ch[maxn];
typedef Point Vector;
Vector operator - (Vector A,Vector B){return Vector(A.x-B.x,A.y-B.y);}
int Cross(Vector A,Vector B){return A.x*B.y-A.y*B.x;}//å积
int cmp1(Point a,Point b)
{
if(a.v==b.v)return a.x<b.x||(a.x==b.x&&a.y<b.y);
return a.v>b.v;
}
int cmp2(Point a,Point b)
{
return a.id<b.id;
}
int ConvexHull(Point *p,Point *ch,int n)//æ±å¸å
{
//sort(p,p+n,cmp3);
int i,m=0,k;
for(i=0;i<n;i++)
{
while(m>1&&Cross(ch[m-1]-ch[m-2],p[i]-ch[m-2])<=0)m--;
ch[m++]=p[i];
}
k=m;
for(i=n-2;i>=0;i--)
{
//cout<<"*"<<m<<endl;
while(m>k&&Cross(ch[m-1]-ch[m-2],p[i]-ch[m-2])<=0)m--;
ch[m++]=p[i];
}
if(n>1)m--;
return m;
}
int main()
{
//freopen("D:\\in.txt","r",stdin);
int n,tt=0;
while(scanf("%d",&n)!=EOF)
{
if(n==0)break;
int i,j,k,t,m;
for(i=0;i<n;i++)
{
scanf("%d%d%d",&e[i].x,&e[i].y,&e[i].v);
e[i].id=i;
e[i].flag=0;
e[i].vis=0;
}
sort(e,e+n,cmp1);
for(i=1;i<n;i++)
{
if(e[i].v!=e[i-1].v)break;
if(e[i].x==e[i-1].x&&e[i].y==e[i-1].y)e[i].vis=e[i-1].vis=1;
}
t=i;
for(i=0;i<t;i++)
{
p[i]=e[i];
}
if(e[0].v==0)t=0;
m=ConvexHull(p,ch,t);
for(i=0;i<t;i++)
{
for(j=0;j<m;j++)
{
if(Cross(ch[j]-ch[(j+1)%m],ch[j]-e[i])==0)
{
if(!e[i].vis)//è¯¥ç¹æ²¡æä¸ä¹éåä¸é度ç¸åçç¹
e[i].flag=1;
break;
}
}
}
sort(e,e+n,cmp2);
printf("Case #%d: ",++tt);
for(i=0;i<n;i++)printf("%d",e[i].flag);
printf("\n");
}
return 0;
}
/*
5
0 0 1
1 0 1
0 1 1
1 1 1
2 0 1
3
0 0 0
1 1 0
2 2 0
9
0 0 1
1 0 1
2 0 1
0 1 1
1 1 2
2 1 1
0 2 1
1 2 1
2 2 1
ans:
11111
000
000010000
*/
| [
"[email protected]"
] | |
a34c10c2d5db35f22b798f02860ad51309412caf | 8cf32b4cbca07bd39341e1d0a29428e420b492a6 | /contracts/libc++/upstream/test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/float.pass.cpp | da4d7dc349c9376a263d6131e7826aae5ae29f92 | [
"MIT",
"NCSA"
] | permissive | cubetrain/CubeTrain | e1cd516d5dbca77082258948d3c7fc70ebd50fdc | b930a3e88e941225c2c54219267f743c790e388f | refs/heads/master | 2020-04-11T23:00:50.245442 | 2018-12-17T16:07:16 | 2018-12-17T16:07:16 | 156,970,178 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,101 | cpp | //===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <ostream>
// template <class charT, class traits = char_traits<charT> >
// class basic_ostream;
// operator<<(float val);
#include <ostream>
#include <cassert>
template <class CharT>
class testbuf
: public std::basic_streambuf<CharT>
{
typedef std::basic_streambuf<CharT> base;
std::basic_string<CharT> str_;
public:
testbuf()
{
}
std::basic_string<CharT> str() const
{return std::basic_string<CharT>(base::pbase(), base::pptr());}
protected:
virtual typename base::int_type
overflow(typename base::int_type __c = base::traits_type::eof())
{
if (__c != base::traits_type::eof())
{
int n = static_cast<int>(str_.size());
str_.push_back(static_cast<CharT>(__c));
str_.resize(str_.capacity());
base::setp(const_cast<CharT*>(str_.data()),
const_cast<CharT*>(str_.data() + str_.size()));
base::pbump(n+1);
}
return __c;
}
};
int main()
{
{
std::ostream os((std::streambuf*)0);
float n = 0;
os << n;
assert(os.bad());
assert(os.fail());
}
{
testbuf<char> sb;
std::ostream os(&sb);
float n = 0;
os << n;
assert(sb.str() == "0");
}
{
testbuf<char> sb;
std::ostream os(&sb);
float n = -10;
os << n;
assert(sb.str() == "-10");
}
{
testbuf<char> sb;
std::ostream os(&sb);
hex(os);
float n = -10.5;
os << n;
assert(sb.str() == "-10.5");
}
}
| [
"[email protected]"
] | |
3d47f2efb799981ed3751788201c13a05bc5ebe0 | 0218591b35109f5bb1906a70ea1ae385fed4e5f3 | /cf_279_vir/a.cpp | a41a1722591018418d10129f3d2887246d4aa0e1 | [] | no_license | poojan124/Competitive | c7eb695aceb1cf74d92eb93fc25c3ce61faa7171 | d51bb791e79a88f84224a36954bc978b57a10ffc | refs/heads/master | 2021-01-11T06:36:52.745300 | 2020-08-15T01:30:37 | 2020-08-15T01:31:15 | 71,857,851 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,266 | cpp | #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
#define PI 3.1415926535897932384626433832795
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define trav(x,v) for (auto &x : v)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define F0R(i, a) for (int i = 0; i < (a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= (a); i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
#define pv(v) trav(x, v) cout << x << " "; cout << endl; // print vector/array
#define pvv(vv) trav(xx, vv){pv(xx);} // print 2-d vector/2-d array
#define pm(m) trav(x, m) cout << x.F << ":" << x.S << " "; cout << endl; //print map/lookup table
const int MOD = 1000000007;
int main(){
ios::sync_with_stdio(false);
cin.tie(0);
int n;
cin>>n;
int a[n];
vector<vector<int>> v(4);
int x;
F0R(i,n){
cin>>x;
v[x].pb(i+1);
}
int min_ = min(v[1].size(),min(v[2].size(),v[3].size()));
cout<<min_<<endl;
F0R(i,min_)
cout<<v[1][i]<<" "<<v[2][i]<<" "<<v[3][i]<<"\n";
return 0;
} | [
"[email protected]"
] | |
1fbe600de6fbe6983462fec7a603ee99e2ea2942 | d2f78406cfbc33c02f54cf5e6475523221cbd64b | /Project2- zoo_game/Turtle.cpp | 4dfbd4af97fe96693d5a1dfcd24d17b15d633627 | [] | no_license | adam4321/CS-162_Programming_2 | ff66d1b705bc28801f0916fd98a3d5b99ce830ea | 05aadc3757d3818d514a990faa8936e42138135a | refs/heads/master | 2020-09-16T07:16:23.133727 | 2019-12-16T10:40:27 | 2019-12-16T10:40:27 | 223,693,490 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,026 | cpp | /*********************************************************************
** Program name: Zoo Tycoon
** Author: Adam Wright
** Date: 4/21/2019
** Description: Derived class of Animal that implements a Turtle
*********************************************************************/
#include "Turtle.hpp"
#include "Animal.hpp"
/*********************************************************************
** Description: Default constructor that initializes a Turtle
*********************************************************************/
Turtle::Turtle() : Animal(0)
{
cost = 100;
numBabies = 10;
baseFoodCost = BASE_FOOD_COST / 2;
payoff = 0.05 * 100;
}
/*********************************************************************
** Description: Default constructor that initializes a Turtle
*********************************************************************/
Turtle::Turtle(int ageInput) : Animal(ageInput)
{
cost = 100;
numBabies = 10;
baseFoodCost = BASE_FOOD_COST / 2;
payoff = 0.05 * 100;
} | [
"[email protected]"
] | |
53e13d63a291495653f561570b591ad4a46f541e | 72da1d65262b9ee7b0f12990f10537ebaf12c34e | /Examples/document_2003/document4.h | e86fbe5e4a63bbbbd98aebae9ef6f604b4aa7ebd | [] | no_license | mdmitry1973/CShell | 81003ab73cde84aae0c99791ecdca4a16572141b | ca860a18a941eacc25d0689a7f3c1589955c3496 | refs/heads/master | 2020-04-07T10:15:05.158622 | 2013-07-21T17:59:17 | 2013-07-21T17:59:17 | 3,851,077 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 548 | h | // document4.h : main header file for the document4 application
//
#pragma once
#ifndef __AFXWIN_H__
#error include 'stdafx.h' before including this file for PCH
#endif
#include "resource.h" // main symbols
// Cdocument4App:
// See document4.cpp for the implementation of this class
//
class Cdocument4App : public CWinApp
{
public:
Cdocument4App();
// Overrides
public:
virtual BOOL InitInstance();
// Implementation
afx_msg void OnAppAbout();
DECLARE_MESSAGE_MAP()
};
extern Cdocument4App theApp; | [
"[email protected]"
] | |
a89cc919126ceddd62e293ace3db236042381506 | 3d2053c68cacda89b55b2fcb2a65fed9d93e75fc | /seurat/ingest/subset_view_group_loader.h | 40e57e28c7425393b70f9f9e3148936143b9d2e5 | [
"Apache-2.0"
] | permissive | n1ckfg/seurat | 99dddf9dc665d522c2c781aea205272e4c89e145 | 1e60a31ae9ca80ddd9afc34c64171b792e5f1c89 | refs/heads/master | 2020-03-15T17:07:18.397694 | 2019-04-08T21:13:52 | 2019-04-08T21:13:52 | 132,251,747 | 1 | 1 | null | 2018-05-05T13:45:49 | 2018-05-05T13:45:49 | null | UTF-8 | C++ | false | false | 1,929 | h | /*
Copyright 2017 Google Inc. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS-IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
#ifndef VR_SEURAT_INGEST_SUBSET_VIEW_GROUP_LOADER_H_
#define VR_SEURAT_INGEST_SUBSET_VIEW_GROUP_LOADER_H_
#include <memory>
#include "seurat/ingest/view_group_loader.h"
namespace seurat {
namespace ingest {
// Wraps another ViewGroupLoader to select a subset of all views, up to a
// specified maximum number.
class SubsetViewGroupLoader : public ViewGroupLoader {
public:
SubsetViewGroupLoader(std::unique_ptr<ViewGroupLoader> delegate,
int max_view_groups)
: delegate_(std::move(delegate)),
max_view_groups_(
std::min(max_view_groups, delegate_->GetNumViewGroups())) {
CHECK_GE(max_view_groups_, 0);
}
// ViewGroupLoader implementation.
int GetNumViewGroups() const override { return max_view_groups_; }
base::Status LoadViewGroup(
int view_group_index, std::vector<std::shared_ptr<base::Camera>>* cameras,
std::vector<image::Ldi4f>* ldis) const override;
private:
// Maps the |view_group_index| to the range of the delegate.
int MapViewGroupIndex(int view_gropup_index) const;
// The ViewGroupLoader to wrap.
const std::unique_ptr<ViewGroupLoader> delegate_;
// The number of view groups returned by this loader.
const int max_view_groups_;
};
} // namespace ingest
} // namespace seurat
#endif // VR_SEURAT_INGEST_SUBSET_VIEW_GROUP_LOADER_H_
| [
"[email protected]"
] | |
2422b5403d235dfbedfa6886d542e8fbfc51326e | 322d62d10d19bfb37080db10c7475faff1501882 | /src/Core/Skybox.h | c2b77d52174aaaf7371665aa7feb72ddeda1edab | [] | no_license | rathyon/pbr | dfa38e1ad6d49090bc06dca074e1b4749c77751c | dcd23756d508d830f3aab93850cc7e0ef269380f | refs/heads/master | 2020-12-26T09:22:31.019782 | 2020-09-03T11:30:56 | 2020-09-03T11:30:56 | 237,463,805 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 614 | h | #ifndef __PBR_SKYBOX_H__
#define __PBR_SKYBOX_H__
#include <PBR.h>
#include <RenderInterface.h>
#include <Geometry.h>
namespace pbr {
class Skybox {
public:
Skybox(const std::string& folder);
Skybox(RRID cubeProg, RRID cubeTex);
void initialize();
void draw() const;
RRID irradianceTex() const;
RRID cubeTex() const;
RRID ggxTex() const;
private:
RRID _cubeProg;
RRID _geoId;
// Textures
RRID _cubeTex;
RRID _irradianceTex;
RRID _ggxTex;
sref<Geometry> _geo;
};
}
#endif | [
"[email protected]"
] | |
f6a4506325d19bd27431e0c16be8348f659fd052 | 7ab428a7000da92474a750f61733e5f670e1ee56 | /day17.cpp | 1c858c77c7762f838224d516de73c1e3a0a98d7b | [] | no_license | atiwari3bu/hackerrank_30Days | d81de61147770d1af3d5643d715a3d4fb4cb4b38 | c4d635c3f1ff434c92fe55d2f0750fad8e3114af | refs/heads/master | 2020-04-12T21:43:25.082015 | 2019-01-08T16:14:50 | 2019-01-08T16:14:50 | 162,770,233 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 886 | cpp | #include <cmath>
#include <iostream>
#include <exception>
#include <stdexcept>
using namespace std;
//Write your code here
struct MyException : public exception {
const char * what () const throw () {
return "n and p should be non-negative";
}
};
struct Calculator{
int power(int base, int raised_to){
int result=1;
if(base< 0 || raised_to<0) throw MyException();
else{
for(int i=0;i<raised_to;++i){
result=base*result;
}
}
return result;
}
};
int main()
{
Calculator myCalculator=Calculator();
int T,n,p;
cin>>T;
while(T-->0){
if(scanf("%d %d",&n,&p)==2){
try{
int ans=myCalculator.power(n,p);
cout<<ans<<endl;
}
catch(exception& e){
cout<<e.what()<<endl;
}
}
}
}
| [
"[email protected]"
] | |
e317653a08068c6402a631f9468b0de0c1aa0fe6 | add83d013bb9b9a79a503f9dd5dee3bf07db6575 | /games/cannonsmash/files/patch-loadparts.cpp.diff | 7e15b661b906565961514f7ea49cf58b4e05fb99 | [
"BSD-2-Clause"
] | permissive | ple-utt239/macports-ports | a6801c210affd1ac09b041ec9401d7c7ccd6e5b7 | 851fd37840a31d07562203f125cb336131e219b1 | refs/heads/master | 2022-12-02T09:56:11.324174 | 2020-08-17T20:01:12 | 2020-08-17T20:05:03 | 288,282,517 | 2 | 0 | NOASSERTION | 2020-08-17T20:43:54 | 2020-08-17T20:43:53 | null | UTF-8 | C++ | false | false | 419 | diff | --- loadparts.cpp.orig Wed Nov 19 09:49:31 2003
+++ loadparts.cpp Fri Mar 19 18:17:45 2004
@@ -245,7 +245,7 @@
while ('\\' == line[l-1]) {
// concat next line(s)
- int bufsize = clamp(0U, sizeof(line)-l, sizeof(line)-1);
+ int bufsize = clamp((long unsigned int)0, sizeof(line)-l, sizeof(line)-1);
fgets(&line[l-2], bufsize, fp);
if (feof((FILE*)fp)) break;
l = strlen(line);
| [
"[email protected]"
] | |
5431244a46e07e32045b41347a478119aaf8519e | a0520d6a3da7e4b51f7422908c60f6c99efcad08 | /Lista3_Tvc3/ArvoreBinaria/No.h | 9c2ededdd534720a4261b0350a2d1f7ddef0a799 | [] | no_license | thiago9864/estrutura_de_dados1 | daf4da84b03bf46fcad684b0d33713d10c395a07 | 2ecf781c6ccde57f9d8106720c1ffc9c06ad24d5 | refs/heads/master | 2020-03-29T14:51:29.515037 | 2018-09-23T23:53:45 | 2018-09-23T23:53:45 | 150,035,307 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 391 | h | #ifndef NO_H_INCLUDED
#define NO_H_INCLUDED
class No {
public:
No(){};
~No(){};
void setEsq(No* e){esq = e;};
void setDir(No* d){dir = d;};
void setInfo(int i){info = i;};
No* getEsq(){return esq;};
No* getDir(){return dir;};
int getInfo(){return info;};
private:
int info;
No *esq;
No *dir;
};
#endif // NO_H_INCLUDED
| [
"[email protected]"
] | |
6b60ec835153fda0a653b91fcbb5f8bb01232e76 | b4848b78349cbeba5542eb141b8aeae528b5a17f | /src/Controlet.cpp | 87ca262faa2b5e5486b4fe15f8d5202fad26e473 | [] | no_license | JohnCrash/iRobot | f7b50f45ae04c7432f2f80d2cd128c6181f47e68 | 608d8b788cb8df193366071672f3d21a3c5a1db6 | refs/heads/master | 2016-09-06T13:09:34.333188 | 2014-08-05T08:10:21 | 2014-08-05T08:10:21 | 22,343,109 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 478 | cpp | #include "stdheader.h"
#include "Controlet.h"
#include "InputFilter.h"
Controlet::Controlet():
mEnable(true),
mGlobal(false)
{
InputFilter::getSingleton().addControlet( this );
}
Controlet::~Controlet(){
InputFilter::getSingleton().removeControlet( this );
}
void Controlet::setEnable( bool b ){
mEnable = b;
}
bool Controlet::isEnable(){
return mEnable;
}
bool Controlet::isGlobal() const
{
return mGlobal;
}
void Controlet::setGlobal( bool b )
{
mGlobal = b;
}
| [
"[email protected]"
] | |
c047b9b77332fe007a96fbbdd9b9fb8c28a9faea | ac3ed3c725cec730004e1c76ff6b77e396a1602a | /src/common/ConsoleOutput.cpp | 3f2a3c9675cf338c485188dc8ff4d7e93fa9bdce | [] | no_license | KoltesDigital/etherdream-glsl | d82be8531a845e1d67e9679f0245062b6ebf78d1 | d3b34244c75dc392134b402ed4b52fb81cf8b7f1 | refs/heads/master | 2020-04-27T09:43:46.592603 | 2019-05-31T11:47:03 | 2019-05-31T11:47:03 | 174,226,467 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 979 | cpp | #include "ConsoleOutput.hpp"
#include <algorithm>
#include "system.hpp"
ConsoleOutput::ConsoleOutput(const CommonParameters &commonParameters, cli::Parser &parser)
: Output{ commonParameters }
{
limitPoints = parser.option("limit-points")
.alias("l")
.description("If greater than 0, limits the number of dumped points.")
.defaultValue("0")
.getValueAs<int>();
pauseDuration = parser.option("pause-duration")
.alias("d")
.description("Pause between renderings, in seconds.")
.defaultValue("0")
.getValueAs<float>();
}
InitializationStatus ConsoleOutput::initialize()
{
return InitializationStatus::Success;
}
bool ConsoleOutput::needPoints()
{
return true;
}
bool ConsoleOutput::streamPoints(const Point *data)
{
auto count = limitPoints > 0 ? std::min(limitPoints, commonParameters.pointCount) : commonParameters.pointCount;
for (int i = 0; i < count; ++i)
{
std::cout << data[i] << std::endl;
}
systemPause(pauseDuration);
return true;
}
| [
"[email protected]"
] | |
623a685ffb10db4f45f9e9047b6578dab8d8b8ad | 1a2a63174c607e9218e061b66655c156803b4f56 | /medium/12. Integer to Roman/Integer to Roman.cpp | 039f9feca7392940064f31655f66be4b46b60642 | [] | no_license | BoHauHuang/Leetcode | 56f030088582799a3795005da0e6938cc879a980 | b8bda1a0b14b10a119c3f97a8e3507596fec14cf | refs/heads/master | 2022-06-28T16:56:09.279361 | 2022-06-10T18:13:04 | 2022-06-10T18:13:04 | 139,982,981 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 472 | cpp | class Solution {
public:
string intToRoman(int num) {
int nums[13] = {1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1};
string roman[13] = {"M", "CM", "D", "CD", "C", "XC", "L", "XL", "X", "IX", "V", "IV", "I"};
string ans = "";
for(int i = 0 ; i < 13 ; i++){
while(nums[i] <= num){
ans += roman[i];
num -= nums[i];
}
}
return ans;
}
};
| [
"[email protected]"
] | |
a75afea4ccacf71a713bbd2f78f2c29851b53f9c | 01914080d71b10f4d2c1289be0330e373228f2cf | /Tools/LA3Tools/tools/source/encoder.cpp | c692e9d562220a602b8af59850a1eeb786ce87bd | [] | no_license | OverTheRinabow/LA3-Scripts | 5fbf20eab28f7d4852bf39bce89874f9d0ca513f | 4b9a511daa01bc815a5e6f51158faf66b6199a2c | refs/heads/master | 2023-06-12T00:29:45.526285 | 2021-07-05T10:50:16 | 2021-07-05T10:50:16 | 286,333,069 | 0 | 0 | null | 2020-08-09T23:21:47 | 2020-08-09T23:21:47 | null | UTF-8 | C++ | false | false | 5,449 | cpp | #include <cstdio>
#include <cstdlib>
#include <cstring>
//------------------------------------
const int N = 80;
char sign[82]=" !\"#%&'()*+,-./:=?0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
//-------------------------------------
char pairs[80*80+2][3];
int pair2shift[80*80+2];
int shiftcode = 0x889F;
int c = 0;
//now make a 2dim mapping array.256kb
int field[256][256];
//data initializing...
void init(){
//generate all possible combinations
for(int i=0; i< N; i++)
for(int j=0; j< N; j++){
pairs[i*N + j][0] = sign[i];
pairs[i*N + j][1] = sign[j];
pairs[i*N + j][2] = 0;
}
//iterating all font trhough Shift-JIS
pair2shift[ c++ ] = shiftcode++;
for(int i=0; i<6; i++)
for(int j=0; j<16; j++)
pair2shift[ c++ ] = shiftcode++;
for(int i=0; i<15; i++){//0x89 - 0x97
shiftcode += 64;// set second byte to 0x40
for(int j=0; j<12; j++)//12 lines
for(int k=0; k<16; k++)//16 columns
pair2shift[ c++ ] = shiftcode++;
}
shiftcode += 64;
for(int i=0; i<3; i++)
for(int j=0; j<16; j++)
pair2shift[ c++ ] = shiftcode++;
pair2shift[ c++ ] = shiftcode++;
pair2shift[ c++ ] = shiftcode++;
pair2shift[ c++ ] = shiftcode++;//0x9872
shiftcode += 16;
for(int i=0; i<13; i++)
pair2shift[ c++ ] = shiftcode++;//jump and start from 0x9883
for(int i=0; i<7; i++)
for(int j=0; j<16; j++)
pair2shift[ c++ ] = shiftcode++;//fill to the end of 0x98xx
for(int i=0; i<7; i++){
shiftcode += 64;
for(int j=0; j<12; j++)
for(int k=0; k<16; k++)
pair2shift[ c++ ] = shiftcode++;
}
//e0 segment
shiftcode = 0xE000;
for(int i=0; i<10; i++){
shiftcode += 64;
for(int j=0; j<12; j++)
for(int k=0; k<16; k++)
pair2shift[ c++ ] = shiftcode++;
}
--c;//
c-=3;//end
for(int i=0; i<256; i++)
for(int j=0; j<256; j++)
field[i][j] = 0x8140;
for(int i=0; i<6400; i++){
field[ pairs[i][0] ][ pairs[i][1] ] = pair2shift[i];
}
return;
}
//print character-pair reference list
void showAll(){
for(int i=0; i<6400; i++)
printf("%s %x %x\n",pairs[i],pair2shift[i],field[pairs[i][0]][pairs[i][1]]);
return;
}
int main(int argc, char *argv[]){
init();
//showAll();
FILE *pFw = NULL;
FILE *pIn = NULL;
if(argc == 3){
pIn = fopen( argv[1],"rb");
pFw = fopen( argv[2], "wb");
} else {
pIn = fopen("inT.txt","rb");
pFw = fopen("inTencoded.txt", "wb");
}
unsigned char *buffer=NULL;
size_t result;
long lSize;
bool strSelect = false;
if(pIn != NULL){
fseek (pIn , 0 , SEEK_END);
lSize = ftell (pIn);
rewind (pIn);
buffer = (unsigned char*) malloc (sizeof(char)*(lSize));
if (buffer == NULL) {fputs ("Memory error",stderr); exit (2);}
// write buffer to the file
result = fread (buffer , sizeof(char), lSize, pIn);
fclose(pIn);
}
int zn1, zn2,pr,pw;
unsigned char dest[500000];
//support for strsel.bin, strana.bin
if(buffer[16]==0x0A)
strSelect = true;
for(pr=pw=16; pr<lSize; pr++,pw++){
//Check first if it's common Shift-JIS character, if so just copy
if( buffer[pr] > 0x80 && buffer[pr+1] >= 0x40) {
dest[ pw ] = buffer[ pr ];
dest[ ++pw ] = buffer[ ++pr ];
continue;
//then check if is script control code: recognized - $n $p $e3, also copy
}else if(buffer[pr]=='$'){
dest[ pw ] = buffer[ pr ];
if(buffer[pr+1] == 'n' || buffer[pr+1] == 'p'){
dest[ ++pw ] = buffer[ ++pr ];
} else if ( buffer[pr+1] == 'e' ) {
dest[ ++pw ] = buffer[ ++pr ];
dest[ ++pw ] = buffer[ ++pr ];
}
continue;
//if first byte start with ascii character
}else if( buffer[pr] < 0x80 && buffer[pr] >= 0x20 ){
//if it's strSel file and option - just copy single ascii char
if(strSelect){
if( buffer[pr] == '-' && buffer[pr+1] == '\n'){
dest[pw] = buffer[pr];
continue;
}
}
//if second one is not ascii or it's white space or control code '$' just make pair with space
if( buffer[pr+1] > 0x80 || buffer[pr+1] <0x20 || buffer[pr+1] == '$'){
zn1 = ((field[ buffer [ pr ] ][ 0x20 ] & 0xFF00) >> 8);
zn2 = (field[ buffer [ pr ] ][ 0x20 ] & 0xFF);
dest[pw] = zn1;
dest[++pw] = zn2;
continue;
//if both are ascii just encode to character pair
} else {
zn1 = ((field[ buffer[ pr ] ][ buffer[ pr+1 ] ] & 0xFF00) >> 8);
zn2 = (field[ buffer [ pr ] ][ buffer[ pr+1 ] ]& 0xFF);
dest[pw] = zn1;
dest[++pw] = zn2;
pr++;
continue;
}
}
//if not recognized just copy
dest[ pw ] = buffer[ pr ];
}
fwrite(buffer, sizeof(char), 16, pFw);
fwrite(dest + 16 , sizeof(char), pw-16, pFw);
fclose(pFw);
free(buffer);
return 0;
}
| [
"[email protected]"
] | |
c244430af7f5045453b7836e4ccd41b660e51554 | 950c8f54d667f981c73ddf61a4c995a408925563 | /source/main.cpp | 7f40474c29efc8c84476841e356404f07194cdd9 | [] | no_license | sshedbalkar/AlienEngine | bdfbfb5fa8e317ee77b17e646853bde1c32f086c | cf8f94ad06a86d6b5bcbfb2f43e4362544a9f32b | refs/heads/main | 2022-12-29T08:49:08.671509 | 2020-10-10T15:01:04 | 2020-10-10T15:01:04 | 302,921,508 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,785 | cpp | ///////////////////////////////////////////////////////////////////////////////////////
//
// WinMain
// The main entry point for the game--everything starts here.
//
// Authors: ,
// Copyright 2010, Digipen Institute of Technology
//
///////////////////////////////////////////////////////////////////////////////////////
#include "MemAllocatorGen.h"
#include "Precompiled.h"
#include "Core.h"
#include "WindowsSystem.h"
#include "Graphics.h"
#include "Physics.h"
#include "GameLogic.h"
#include "Audio.h"
#include "DebugTools.h"
#include <ctime>
#include <crtdbg.h>
#include "LevelEditor.h"
#include "Global.h"
using namespace Framework;
//The title the window will have at the top
const char windowTitle[] = "AlienEngine";
const int ClientWidth = 1280;
const int ClientHeight = 720;
const bool FullScreen = false;
void EnableMemoryLeakChecking(int breakAlloc=-1)
{
//Set the leak checking flag
int tmpDbgFlag = _CrtSetDbgFlag(_CRTDBG_REPORT_FLAG);
tmpDbgFlag |= _CRTDBG_LEAK_CHECK_DF;
_CrtSetDbgFlag(tmpDbgFlag);
//If a valid break alloc provided set the breakAlloc
if(breakAlloc!=-1) _CrtSetBreakAlloc( breakAlloc );
}
//The entry point for the application--called automatically when the game starts.
//The first parameter is a handle to the application instance.
//The second parameter is the previous app instance which you can use to prevent being launched multiple times
//The third parameter is the command line string, but use GetCommandLine() instead.
//The last parameter is the manner in which the application's window is to be displayed (not needed).
#ifdef _DEBUG
int main()
#endif
#ifndef _DEBUG
INT WINAPI WinMain( HINSTANCE, HINSTANCE, LPSTR, int )
#endif
{
// _CrtSetDbgFlag ( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF );
srand(unsigned(time(NULL)));
//#ifdef _DEBUG
// Debug::DebugTools::getInstance()->enable(true);
// EnableMemoryLeakChecking();
//#else
////#define std::cout(...) ((void)0)
//#endif
WNDCLASSEX wc;
#ifdef _DEBUG
EnableMemoryLeakChecking();
#endif
std::cout<<"Alien Main...\n";
//Create the core engine which manages all the systems that make up the game
CoreEngine* engine = new CoreEngine();
//Initialize the game by creating the various systems needed and adding them to the core engine
WindowsSystem* windows = new WindowsSystem(windowTitle, ClientWidth, ClientHeight, FullScreen);
wc.hIcon= LoadIcon(windows->hInstance , "Assets/textures/Icon.ico");
//
GlobalInit();
Graphics * graphics = new Graphics();
graphics->SetWindowProperties(windows->hWnd, ClientWidth, ClientHeight, FullScreen);
engine->AddSystem(windows);
engine->AddSystem(new GameObjectFactory());
engine->AddSystem(new Physics());
engine->AddSystem(new GameLogic());
engine->AddSystem(graphics);
engine->AddSystem(new Audio());
engine->AddSystem(new LevelEditor());
//TODO: Add additional systems, such as audio, and possibly xinput, lua, etc.
engine->Initialize();
//Everything is set up, so activate the window
windows->ActivateWindow();
//inform the application that the game is about to begin
engine->FirstFrameRun();
//Run the game
engine->GameLoop();
//Delete all the game objects
FACTORY->DestroyAllObjects();
//Delete all the systems
engine->DestroySystems();
//Delete the engine itself
delete engine;
//
GlobalFree();
//
#ifdef _DEBUG
::_CrtDumpMemoryLeaks();
#endif
Memory::PrintLeaks();
Memory::PrintStats();
//Game over, application will now close
return 0;
}
void DebugPrintHandler( const char * msg , ... )
{
const int BufferSize = 1024;
char FinalMessage[BufferSize];
va_list args;
va_start(args, msg);
vsnprintf_s(FinalMessage , BufferSize , _TRUNCATE , msg, args);
va_end(args);
OutputDebugString(FinalMessage);
OutputDebugString("\n");
}
//A basic error output function
bool SignalErrorHandler(const char * exp, const char * file, int line, const char * msg , ...)
{
const int BufferSize = 1024;
char FinalMessage[BufferSize];
//Print out the file and line in visual studio format so the error can be
//double clicked in the output window file(line) : error
int offset = sprintf_s(FinalMessage,"%s(%d) : ", file , line );
if (msg != NULL)
{
va_list args;
va_start(args, msg);
vsnprintf_s(FinalMessage + offset, BufferSize - offset, _TRUNCATE , msg, args);
va_end(args);
}
else
{
strcpy_s(FinalMessage + offset, BufferSize - offset, "No Error Message");
}
//Print to visual studio output window
OutputDebugString(FinalMessage);
OutputDebugString("\n");
//Display a message box to the user
MessageBoxA(NULL, FinalMessage, "Error", 0);
//Do not debug break
return true;
}
| [
"[email protected]"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.