blob_id stringlengths 40 40 | directory_id stringlengths 40 40 | path stringlengths 3 264 | content_id stringlengths 40 40 | detected_licenses listlengths 0 85 | license_type stringclasses 2
values | repo_name stringlengths 5 140 | snapshot_id stringlengths 40 40 | revision_id stringlengths 40 40 | branch_name stringclasses 986
values | visit_date timestamp[us] | revision_date timestamp[us] | committer_date timestamp[us] | github_id int64 3.89k 681M ⌀ | star_events_count int64 0 209k | fork_events_count int64 0 110k | gha_license_id stringclasses 23
values | gha_event_created_at timestamp[us] | gha_created_at timestamp[us] | gha_language stringclasses 145
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 122
values | content stringlengths 3 10.4M | authors listlengths 1 1 | author_id stringlengths 0 158 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
2352a1a15b1dffaba3e75bea13e0374deac52c3e | 5be76ee3bac0211e551b6809912e66c0138831f0 | /ffmpegdemo/Chapter2.cpp | a409a64d2db0b75f8f7b66df8dc885e10f25efc4 | [
"MIT"
] | permissive | DuckDeck/ffmpegdemo | f831812f838a11c1fc4d9caab5cb87860ffd5349 | b0630b9824a8593e9f4a3bb214539bac1a792fa1 | refs/heads/master | 2020-03-26T18:05:39.948746 | 2019-12-21T00:11:18 | 2019-12-21T00:11:18 | 145,195,868 | 1 | 0 | null | null | null | null | GB18030 | C++ | false | false | 2,887 | cpp | #include <opencv2/opencv.hpp>
#include "stdafx.h"
#include <opencv2/highgui.hpp>
#include <iostream>
using namespace cv;
using namespace std;
//视频
void playVideo() {
namedWindow("Video", WINDOW_AUTOSIZE);
VideoCapture cap;
cap.open("asset/test.mp4");
Mat frame;
for (;;) {
cap >> frame;
if (frame.empty()) break;
imshow("Video", frame);
if (waitKey(33) >= 0)break;
}
}
int g_slider_position = 0;
int g_run = 1, g_dontset = 0;
VideoCapture g_cap;
void onTrackbarSilde(int pos, void *) {
g_cap.set(CAP_PROP_POS_FRAMES, pos);
if (!g_dontset) {
g_run = 1;
}
g_dontset = 0;
}
void playVideoWithDrag() {
namedWindow("Video", WINDOW_AUTOSIZE);
g_cap.open("asset/face.mp4");
int frames = g_cap.get(CAP_PROP_FRAME_COUNT);
int tmpw = g_cap.get(CAP_PROP_FRAME_WIDTH);
int tmph = g_cap.get(CAP_PROP_FRAME_HEIGHT);
cout << "Video has " << frames << "frames of dimensions (" << tmpw << "," << tmph << ")." << endl;
createTrackbar("Position", "Video", &g_slider_position, frames, onTrackbarSilde);
Mat frame;
for (;;) {
if (g_run != 0) {
g_cap >> frame;
if (frame.empty()) {
break;
}
int current_pos = g_cap.get(CAP_PROP_POS_FRAMES); //获取到当前frame
g_dontset = 1;
setTrackbarPos("Position", "Video", current_pos);
imshow("Video", frame);
g_run -= 1;
}
char c = waitKey(10);
if (c == 's') {
g_run = 1;
cout << "Single step ,run = " << g_run << endl;
}
if (c == 'r') {
g_run = -1;
cout << "Run mode ,run = " << g_run << endl;
}
if (c == 27) {
break;
}
}
}
void openCamera() {
namedWindow("Video", WINDOW_AUTOSIZE);
VideoCapture cap;
cap.open(-1);
//死活打不开摄像头 ,文件也打不开? 不是死活打不开,是没有用代码展示出来
//好像还是不行
if (!cap.isOpened()) {
std::cerr << "Could not open capture" << endl;
}
Mat frame;
for (;;) {
cap >> frame;
if (frame.empty()) break;
imshow("Video", frame);
if (waitKey(33) >= 0)break;
}
}
void writeAVIFile(){
namedWindow("Write AVI", WINDOW_AUTOSIZE);
namedWindow("Log Polar", WINDOW_AUTOSIZE);
g_cap.open("asset/test.mp4");
double fps = g_cap.get(CAP_PROP_FPS);
Size size((int)g_cap.get(CAP_PROP_FRAME_WIDTH), (int)g_cap.get(CAP_PROP_FRAME_HEIGHT));
VideoWriter vWriter;
vWriter.open("assert/test1.mp4", CAP_OPENCV_MJPEG, fps, size,true);
//报错写不出来,可能是格式不支持
Mat logpolar_frame, bgr_frame;
for (;;) {
g_cap >> bgr_frame;
if (bgr_frame.empty())break;
imshow("Write AVI", bgr_frame);
logPolar(bgr_frame, logpolar_frame, Point2f(bgr_frame.cols / 2, bgr_frame.rows / 2), 100, WARP_FILL_OUTLIERS);
imshow("Log Polar", logpolar_frame);
vWriter << logpolar_frame;
if (waitKey(33) >= 0)break;
}
g_cap.release();
}
int learnOpenCV1()
{
//playVideo();
//playVideoWithDrag();
//openCamera();
writeAVIFile();
waitKey(0);
return 0;
}
| [
"3421902@qq.com"
] | 3421902@qq.com |
4e4e6b0787cba4799b7175c6879bd93e3811100b | f2ad82525768c2a45edcbd59ce22445b36b3403b | /xtt/lib/xtt/gtk/xtt_xcolwind_gtk.h | 9fdd3fe72cf8660ddc8fcc7229f79021d45e91c7 | [] | no_license | jordibrus/proview | 55fdf2623ff7b46f0ccfce1bcdce4543457a9d9a | 29f5e0cc6dab430593c1d6bf95dd5077d6732953 | refs/heads/master | 2021-01-18T00:18:45.670513 | 2013-11-16T20:03:39 | 2013-11-16T20:03:39 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 5,051 | h | /*
* Proview Open Source Process Control.
* Copyright (C) 2005-2013 SSAB EMEA AB.
*
* This file is part of Proview.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Proview. If not, see <http://www.gnu.org/licenses/>
*
* Linking Proview statically or dynamically with other modules is
* making a combined work based on Proview. Thus, the terms and
* conditions of the GNU General Public License cover the whole
* combination.
*
* In addition, as a special exception, the copyright holders of
* Proview give you permission to, from the build function in the
* Proview Configurator, combine Proview with modules generated by the
* Proview PLC Editor to a PLC program, regardless of the license
* terms of these modules. You may copy and distribute the resulting
* combined work under the terms of your choice, provided that every
* copy of the combined work is accompanied by a complete copy of
* the source code of Proview (the version used to produce the
* combined work), being distributed under the terms of the GNU
* General Public License plus this exception.
*/
#ifndef xtt_xcolwind_gtk_h
#define xtt_xcolwind_gtk_h
/* xtt_xcolwind_gtk.h -- Collect window */
#ifndef xtt_xcolwind_h
# include "xtt_xcolwind.h"
#endif
#ifndef cow_wow_gtk_h
# include "cow_wow_gtk.h"
#endif
class XColWindGtk : public XColWind {
public:
XColWindGtk (
GtkWidget *xa_parent_wid,
void *xa_parent_ctx,
pwr_sAttrRef *xa_objar,
char *xa_title,
int xa_advanced_user,
xcolwind_eType xa_type,
int *xa_sts);
~XColWindGtk();
GtkWidget *parent_wid;
GtkWidget *brow_widget;
GtkWidget *form_widget;
GtkWidget *toplevel;
GtkWidget *msg_label;
GtkWidget *cmd_prompt;
GtkWidget *cmd_input;
GtkWidget *cmd_scrolledinput;
GtkWidget *cmd_scrolledtextview;
GtkWidget *cmd_scrolled_ok;
GtkWidget *cmd_scrolled_ca;
GtkTextBuffer *cmd_scrolled_buffer;
GtkWidget *pane;
static CoWowRecall value_recall;
CoWowEntryGtk *cmd_entry;
CoWowFocusTimerGtk focustimer;
int input_max_length;
void message( char severity, const char *message);
void set_prompt( const char *prompt);
void change_value( int set_focus);
int open_changevalue( char *name);
void change_value_close();
void pop();
void set_title( char *title);
void set_window_size( int w, int h);
void get_window_size( int *w, int *h);
void print();
static void activate_open( GtkWidget *w, gpointer data);
static void activate_save( GtkWidget *w, gpointer data);
static void activate_saveas( GtkWidget *w, gpointer data);
static void activate_insert( GtkWidget *w, gpointer data);
static void activate_delete( GtkWidget *w, gpointer data);
static void activate_print( GtkWidget *w, gpointer data);
static void activate_moveup( GtkWidget *w, gpointer data);
static void activate_movedown( GtkWidget *w, gpointer data);
static void activate_change_value( GtkWidget *w, gpointer data);
static void activate_close_changeval( GtkWidget *w, gpointer data);
static void activate_exit( GtkWidget *w, gpointer data);
static void activate_display_object( GtkWidget *w, gpointer data);
static void activate_show_cross( GtkWidget *w, gpointer data);
static void activate_open_classgraph( GtkWidget *w, gpointer data);
static void activate_open_plc( GtkWidget *w, gpointer data);
static void activate_zoomin( GtkWidget *w, gpointer data);
static void activate_zoomout( GtkWidget *w, gpointer data);
static void activate_zoomreset( GtkWidget *w, gpointer data);
static void activate_scantime1(GtkWidget *w, gpointer data);
static void activate_scantime2(GtkWidget *w, gpointer data);
static void activate_scantime3(GtkWidget *w, gpointer data);
static void activate_scantime4(GtkWidget *w, gpointer data);
static void activate_scantime5(GtkWidget *w, gpointer data);
static void activate_help( GtkWidget *w, gpointer data);
static gboolean action_inputfocus( GtkWidget *w, GdkEvent *event, gpointer data);
static void valchanged_cmd_input( GtkWidget *w, gpointer data);
static void activate_cmd_input( GtkWidget *w, gpointer data);
static void activate_cmd_scrolled_ok( GtkWidget *w, gpointer data);
static void activate_cmd_scrolled_ca( GtkWidget *w, gpointer data);
static void action_text_inserted( GtkTextBuffer *w, GtkTextIter *iter, gchar *str, gint len, gpointer data);
};
#endif
| [
"claes.sjofors@proview.se"
] | claes.sjofors@proview.se |
209a1f864899f7f483051523ea3352a8fd2c54c5 | 04b1803adb6653ecb7cb827c4f4aa616afacf629 | /third_party/blink/renderer/core/layout/layout_table_section.cc | c39aa598db96a2821326c8f434cccb1ef1baf321 | [
"LGPL-2.0-or-later",
"GPL-1.0-or-later",
"MIT",
"Apache-2.0",
"LGPL-2.0-only",
"BSD-2-Clause",
"LGPL-2.1-only",
"LicenseRef-scancode-warranty-disclaimer",
"GPL-2.0-only",
"LicenseRef-scancode-other-copyleft",
"BSD-3-Clause"
] | permissive | Samsung/Castanets | 240d9338e097b75b3f669604315b06f7cf129d64 | 4896f732fc747dfdcfcbac3d442f2d2d42df264a | refs/heads/castanets_76_dev | 2023-08-31T09:01:04.744346 | 2021-07-30T04:56:25 | 2021-08-11T05:45:21 | 125,484,161 | 58 | 49 | BSD-3-Clause | 2022-10-16T19:31:26 | 2018-03-16T08:07:37 | null | UTF-8 | C++ | false | false | 81,591 | cc | /*
* Copyright (C) 1997 Martin Jones (mjones@kde.org)
* (C) 1997 Torben Weis (weis@kde.org)
* (C) 1998 Waldo Bastian (bastian@kde.org)
* (C) 1999 Lars Knoll (knoll@kde.org)
* (C) 1999 Antti Koivisto (koivisto@kde.org)
* Copyright (C) 2003, 2004, 2005, 2006, 2008, 2009, 2010, 2013 Apple Inc.
* All rights reserved.
* Copyright (C) 2006 Alexey Proskuryakov (ap@nypop.com)
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#include "third_party/blink/renderer/core/layout/layout_table_section.h"
#include <algorithm>
#include <limits>
#include "third_party/blink/renderer/core/frame/use_counter.h"
#include "third_party/blink/renderer/core/layout/hit_test_result.h"
#include "third_party/blink/renderer/core/layout/layout_analyzer.h"
#include "third_party/blink/renderer/core/layout/layout_table_cell.h"
#include "third_party/blink/renderer/core/layout/layout_table_col.h"
#include "third_party/blink/renderer/core/layout/layout_table_row.h"
#include "third_party/blink/renderer/core/layout/layout_view.h"
#include "third_party/blink/renderer/core/layout/subtree_layout_scope.h"
#include "third_party/blink/renderer/core/paint/paint_layer.h"
#include "third_party/blink/renderer/core/paint/table_section_painter.h"
#include "third_party/blink/renderer/platform/runtime_enabled_features.h"
#include "third_party/blink/renderer/platform/wtf/hash_set.h"
namespace blink {
void LayoutTableSection::TableGridRow::
SetRowLogicalHeightToRowStyleLogicalHeight() {
DCHECK(row);
logical_height = row->StyleRef().LogicalHeight();
}
void LayoutTableSection::TableGridRow::UpdateLogicalHeightForCell(
const LayoutTableCell* cell) {
// We ignore height settings on rowspan cells.
if (cell->ResolvedRowSpan() != 1)
return;
const Length& cell_logical_height = cell->StyleRef().LogicalHeight();
if (cell_logical_height.IsPositive()) {
switch (cell_logical_height.GetType()) {
case Length::kPercent:
// TODO(alancutter): Make this work correctly for calc lengths.
if (!(logical_height.IsPercentOrCalc()) ||
(logical_height.IsPercent() &&
logical_height.Percent() < cell_logical_height.Percent()))
logical_height = cell_logical_height;
break;
case Length::kFixed:
if (logical_height.IsAuto() ||
(logical_height.IsFixed() &&
logical_height.Value() < cell_logical_height.Value()))
logical_height = cell_logical_height;
break;
default:
break;
}
}
}
void CellSpan::EnsureConsistency(const unsigned maximum_span_size) {
static_assert(std::is_same<decltype(start_), unsigned>::value,
"Asserts below assume start_ is unsigned");
static_assert(std::is_same<decltype(end_), unsigned>::value,
"Asserts below assume end_ is unsigned");
CHECK_LE(start_, maximum_span_size);
CHECK_LE(end_, maximum_span_size);
CHECK_LE(start_, end_);
}
LayoutTableSection::LayoutTableSection(Element* element)
: LayoutTableBoxComponent(element),
c_col_(0),
c_row_(0),
needs_cell_recalc_(false),
force_full_paint_(false),
has_multiple_cell_levels_(false),
has_spanning_cells_(false),
is_repeating_header_group_(false),
is_repeating_footer_group_(false) {
// init LayoutObject attributes
SetInline(false); // our object is not Inline
}
LayoutTableSection::~LayoutTableSection() = default;
void LayoutTableSection::StyleDidChange(StyleDifference diff,
const ComputedStyle* old_style) {
DCHECK(StyleRef().Display() == EDisplay::kTableFooterGroup ||
StyleRef().Display() == EDisplay::kTableRowGroup ||
StyleRef().Display() == EDisplay::kTableHeaderGroup);
LayoutTableBoxComponent::StyleDidChange(diff, old_style);
PropagateStyleToAnonymousChildren();
if (!old_style)
return;
LayoutTable* table = Table();
if (!table)
return;
LayoutTableBoxComponent::InvalidateCollapsedBordersOnStyleChange(
*this, *table, diff, *old_style);
if (LayoutTableBoxComponent::DoCellsHaveDirtyWidth(*this, *table, diff,
*old_style)) {
MarkAllCellsWidthsDirtyAndOrNeedsLayout(
LayoutTable::kMarkDirtyAndNeedsLayout);
}
}
void LayoutTableSection::WillBeRemovedFromTree() {
LayoutTableBoxComponent::WillBeRemovedFromTree();
// Preventively invalidate our cells as we may be re-inserted into
// a new table which would require us to rebuild our structure.
SetNeedsCellRecalc();
}
void LayoutTableSection::AddChild(LayoutObject* child,
LayoutObject* before_child) {
if (!child->IsTableRow()) {
LayoutObject* last = before_child;
if (!last)
last = LastRow();
if (last && last->IsAnonymous() && last->IsTablePart() &&
!last->IsBeforeOrAfterContent()) {
if (before_child == last)
before_child = last->SlowFirstChild();
last->AddChild(child, before_child);
return;
}
if (before_child && !before_child->IsAnonymous() &&
before_child->Parent() == this) {
LayoutObject* row = before_child->PreviousSibling();
if (row && row->IsTableRow() && row->IsAnonymous()) {
row->AddChild(child);
return;
}
}
// If beforeChild is inside an anonymous cell/row, insert into the cell or
// into the anonymous row containing it, if there is one.
LayoutObject* last_box = last;
while (last_box && last_box->Parent()->IsAnonymous() &&
!last_box->IsTableRow())
last_box = last_box->Parent();
if (last_box && last_box->IsAnonymous() &&
!last_box->IsBeforeOrAfterContent()) {
last_box->AddChild(child, before_child);
return;
}
LayoutObject* row = LayoutTableRow::CreateAnonymousWithParent(this);
AddChild(row, before_child);
row->AddChild(child);
return;
}
if (before_child)
SetNeedsCellRecalc();
unsigned insertion_row = c_row_;
++c_row_;
c_col_ = 0;
EnsureRows(c_row_);
LayoutTableRow* row = ToLayoutTableRow(child);
grid_[insertion_row].row = row;
row->SetRowIndex(insertion_row);
if (!before_child)
grid_[insertion_row].SetRowLogicalHeightToRowStyleLogicalHeight();
if (before_child && before_child->Parent() != this)
before_child = SplitAnonymousBoxesAroundChild(before_child);
DCHECK(!before_child || before_child->IsTableRow());
LayoutTableBoxComponent::AddChild(child, before_child);
}
static inline void CheckThatVectorIsDOMOrdered(
const Vector<LayoutTableCell*, 1>& cells) {
#ifndef NDEBUG
// This function should be called on a non-empty vector.
DCHECK_GT(cells.size(), 0u);
const LayoutTableCell* previous_cell = cells[0];
for (wtf_size_t i = 1; i < cells.size(); ++i) {
const LayoutTableCell* current_cell = cells[i];
// The check assumes that all cells belong to the same row group.
DCHECK_EQ(previous_cell->Section(), current_cell->Section());
// 2 overlapping cells can't be on the same row.
DCHECK_NE(current_cell->Row(), previous_cell->Row());
// Look backwards in the tree for the previousCell's row. If we are
// DOM ordered, we should find it.
const LayoutTableRow* row = current_cell->Row();
for (; row && row != previous_cell->Row(); row = row->PreviousRow()) {
}
DCHECK_EQ(row, previous_cell->Row());
previous_cell = current_cell;
}
#endif // NDEBUG
}
void LayoutTableSection::AddCell(LayoutTableCell* cell, LayoutTableRow* row) {
// We don't insert the cell if we need cell recalc as our internal columns'
// representation will have drifted from the table's representation. Also
// recalcCells will call addCell at a later time after sync'ing our columns'
// with the table's.
if (NeedsCellRecalc())
return;
DCHECK(cell);
unsigned r_span = cell->ResolvedRowSpan();
unsigned c_span = cell->ColSpan();
if (r_span > 1 || c_span > 1)
has_spanning_cells_ = true;
const Vector<LayoutTable::ColumnStruct>& columns =
Table()->EffectiveColumns();
unsigned insertion_row = row->RowIndex();
// ### mozilla still seems to do the old HTML way, even for strict DTD
// (see the annotation on table cell layouting in the CSS specs and the
// testcase below:
// <TABLE border>
// <TR><TD>1 <TD rowspan="2">2 <TD>3 <TD>4
// <TR><TD colspan="2">5
// </TABLE>
unsigned n_cols = NumCols(insertion_row);
while (c_col_ < n_cols && (GridCellAt(insertion_row, c_col_).HasCells() ||
GridCellAt(insertion_row, c_col_).InColSpan()))
c_col_++;
grid_[insertion_row].UpdateLogicalHeightForCell(cell);
EnsureRows(insertion_row + r_span);
grid_[insertion_row].row = row;
unsigned col = c_col_;
// tell the cell where it is
bool in_col_span = false;
unsigned col_size = columns.size();
while (c_span) {
unsigned current_span;
if (c_col_ >= col_size) {
Table()->AppendEffectiveColumn(c_span);
current_span = c_span;
} else {
if (c_span < columns[c_col_].span)
Table()->SplitEffectiveColumn(c_col_, c_span);
current_span = columns[c_col_].span;
}
for (unsigned r = 0; r < r_span; r++) {
EnsureCols(insertion_row + r, c_col_ + 1);
auto& grid_cell = GridCellAt(insertion_row + r, c_col_);
grid_cell.Cells().push_back(cell);
CheckThatVectorIsDOMOrdered(grid_cell.Cells());
// If cells overlap then we take the special paint path for them.
if (grid_cell.Cells().size() > 1)
has_multiple_cell_levels_ = true;
if (in_col_span)
grid_cell.SetInColSpan(true);
}
c_col_++;
c_span -= current_span;
in_col_span = true;
}
cell->SetAbsoluteColumnIndex(Table()->EffectiveColumnToAbsoluteColumn(col));
}
bool LayoutTableSection::RowHasOnlySpanningCells(unsigned row) {
if (grid_[row].grid_cells.IsEmpty())
return false;
for (const auto& grid_cell : grid_[row].grid_cells) {
// Empty cell is not a valid cell so it is not a rowspan cell.
if (!grid_cell.HasCells())
return false;
if (grid_cell.Cells()[0]->ResolvedRowSpan() == 1)
return false;
}
return true;
}
void LayoutTableSection::PopulateSpanningRowsHeightFromCell(
LayoutTableCell* cell,
struct SpanningRowsHeight& spanning_rows_height) {
const unsigned row_span = cell->ResolvedRowSpan();
const unsigned row_index = cell->RowIndex();
spanning_rows_height.spanning_cell_height_ignoring_border_spacing =
cell->LogicalHeightForRowSizing();
spanning_rows_height.row_height.resize(row_span);
spanning_rows_height.total_rows_height = 0;
for (unsigned row = 0; row < row_span; row++) {
unsigned actual_row = row + row_index;
spanning_rows_height.row_height[row] = row_pos_[actual_row + 1] -
row_pos_[actual_row] -
BorderSpacingForRow(actual_row);
if (!spanning_rows_height.row_height[row])
spanning_rows_height.is_any_row_with_only_spanning_cells |=
RowHasOnlySpanningCells(actual_row);
spanning_rows_height.total_rows_height +=
spanning_rows_height.row_height[row];
spanning_rows_height.spanning_cell_height_ignoring_border_spacing -=
BorderSpacingForRow(actual_row);
}
// We don't span the following row so its border-spacing (if any) should be
// included.
spanning_rows_height.spanning_cell_height_ignoring_border_spacing +=
BorderSpacingForRow(row_index + row_span - 1);
}
void LayoutTableSection::DistributeExtraRowSpanHeightToPercentRows(
LayoutTableCell* cell,
float total_percent,
int& extra_row_spanning_height,
Vector<int>& rows_height) {
if (!extra_row_spanning_height || !total_percent)
return;
const unsigned row_span = cell->ResolvedRowSpan();
const unsigned row_index = cell->RowIndex();
float percent = std::min(total_percent, 100.0f);
const int table_height = row_pos_[grid_.size()] + extra_row_spanning_height;
// Our algorithm matches Firefox. Extra spanning height would be distributed
// Only in first percent height rows those total percent is 100. Other percent
// rows would be uneffected even extra spanning height is remain.
int accumulated_position_increase = 0;
for (unsigned row = row_index; row < (row_index + row_span); row++) {
if (percent > 0 && extra_row_spanning_height > 0) {
// TODO(alancutter): Make this work correctly for calc lengths.
if (grid_[row].logical_height.IsPercent()) {
int to_add =
(table_height *
std::min(grid_[row].logical_height.Percent(), percent) / 100) -
rows_height[row - row_index];
to_add = std::max(std::min(to_add, extra_row_spanning_height), 0);
accumulated_position_increase += to_add;
extra_row_spanning_height -= to_add;
percent -= grid_[row].logical_height.Percent();
}
}
row_pos_[row + 1] += accumulated_position_increase;
}
}
static void UpdatePositionIncreasedWithRowHeight(
int extra_height,
float row_height,
float total_height,
int& accumulated_position_increase,
double& remainder) {
// Without the cast we lose enough precision to cause heights to miss pixels
// (and trigger asserts) in some web tests.
double proportional_position_increase =
remainder + (extra_height * double(row_height)) / total_height;
// The epsilon is to push any values that are close to a whole number but
// aren't due to floating point imprecision. The epsilons are not accumulated,
// any that aren't necessary are lost in the cast to int.
int position_increase_int = proportional_position_increase + 0.000001;
accumulated_position_increase += position_increase_int;
remainder = proportional_position_increase - position_increase_int;
}
// This is mainly used to distribute whole extra rowspanning height in percent
// rows when all spanning rows are percent rows.
// Distributing whole extra rowspanning height in percent rows based on the
// ratios of percent because this method works same as percent distribution when
// only percent rows are present and percent is 100. Also works perfectly fine
// when percent is not equal to 100.
void LayoutTableSection::DistributeWholeExtraRowSpanHeightToPercentRows(
LayoutTableCell* cell,
float total_percent,
int& extra_row_spanning_height,
Vector<int>& rows_height) {
if (!extra_row_spanning_height || !total_percent)
return;
const unsigned row_span = cell->ResolvedRowSpan();
const unsigned row_index = cell->RowIndex();
double remainder = 0;
int accumulated_position_increase = 0;
for (unsigned row = row_index; row < (row_index + row_span); row++) {
// TODO(alancutter): Make this work correctly for calc lengths.
if (grid_[row].logical_height.IsPercent()) {
UpdatePositionIncreasedWithRowHeight(
extra_row_spanning_height, grid_[row].logical_height.Percent(),
total_percent, accumulated_position_increase, remainder);
}
row_pos_[row + 1] += accumulated_position_increase;
}
DCHECK(!round(remainder)) << "remainder was " << remainder;
extra_row_spanning_height -= accumulated_position_increase;
}
void LayoutTableSection::DistributeExtraRowSpanHeightToAutoRows(
LayoutTableCell* cell,
int total_auto_rows_height,
int& extra_row_spanning_height,
Vector<int>& rows_height) {
if (!extra_row_spanning_height || !total_auto_rows_height)
return;
const unsigned row_span = cell->ResolvedRowSpan();
const unsigned row_index = cell->RowIndex();
int accumulated_position_increase = 0;
double remainder = 0;
// Aspect ratios of auto rows should not change otherwise table may look
// different than user expected. So extra height distributed in auto spanning
// rows based on their weight in spanning cell.
for (unsigned row = row_index; row < (row_index + row_span); row++) {
if (grid_[row].logical_height.IsAuto()) {
UpdatePositionIncreasedWithRowHeight(
extra_row_spanning_height, rows_height[row - row_index],
total_auto_rows_height, accumulated_position_increase, remainder);
}
row_pos_[row + 1] += accumulated_position_increase;
}
DCHECK(!round(remainder)) << "remainder was " << remainder;
extra_row_spanning_height -= accumulated_position_increase;
}
void LayoutTableSection::DistributeExtraRowSpanHeightToRemainingRows(
LayoutTableCell* cell,
int total_remaining_rows_height,
int& extra_row_spanning_height,
Vector<int>& rows_height) {
if (!extra_row_spanning_height || !total_remaining_rows_height)
return;
const unsigned row_span = cell->ResolvedRowSpan();
const unsigned row_index = cell->RowIndex();
int accumulated_position_increase = 0;
double remainder = 0;
// Aspect ratios of the rows should not change otherwise table may look
// different than user expected. So extra height distribution in remaining
// spanning rows based on their weight in spanning cell.
for (unsigned row = row_index; row < (row_index + row_span); row++) {
if (!grid_[row].logical_height.IsPercentOrCalc()) {
UpdatePositionIncreasedWithRowHeight(
extra_row_spanning_height, rows_height[row - row_index],
total_remaining_rows_height, accumulated_position_increase,
remainder);
}
row_pos_[row + 1] += accumulated_position_increase;
}
DCHECK(!round(remainder)) << "remainder was " << remainder;
extra_row_spanning_height -= accumulated_position_increase;
}
static bool CellIsFullyIncludedInOtherCell(const LayoutTableCell* cell1,
const LayoutTableCell* cell2) {
return (cell1->RowIndex() >= cell2->RowIndex() &&
(cell1->RowIndex() + cell1->ResolvedRowSpan()) <=
(cell2->RowIndex() + cell2->ResolvedRowSpan()));
}
// To avoid unneeded extra height distributions, we apply the following sorting
// algorithm:
static bool CompareRowSpanCellsInHeightDistributionOrder(
const LayoutTableCell* cell1,
const LayoutTableCell* cell2) {
// Sorting bigger height cell first if cells are at same index with same span
// because we will skip smaller height cell to distribute it's extra height.
if (cell1->RowIndex() == cell2->RowIndex() &&
cell1->ResolvedRowSpan() == cell2->ResolvedRowSpan())
return (cell1->LogicalHeightForRowSizing() >
cell2->LogicalHeightForRowSizing());
// Sorting inner most cell first because if inner spanning cell'e extra height
// is distributed then outer spanning cell's extra height will adjust
// accordingly. In reverse order, there is more chances that outer spanning
// cell's height will exceed than defined by user.
if (CellIsFullyIncludedInOtherCell(cell1, cell2))
return true;
// Sorting lower row index first because first we need to apply the extra
// height of spanning cell which comes first in the table so lower rows's
// position would increment in sequence.
if (!CellIsFullyIncludedInOtherCell(cell2, cell1))
return (cell1->RowIndex() < cell2->RowIndex());
return false;
}
unsigned LayoutTableSection::CalcRowHeightHavingOnlySpanningCells(
unsigned row,
int& accumulated_cell_position_increase,
unsigned row_to_apply_extra_height,
unsigned& extra_table_height_to_propgate,
Vector<int>& rows_count_with_only_spanning_cells) {
DCHECK(RowHasOnlySpanningCells(row));
unsigned row_height = 0;
for (const auto& row_span_cell : grid_[row].grid_cells) {
DCHECK(row_span_cell.HasCells());
LayoutTableCell* cell = row_span_cell.Cells()[0];
DCHECK_GE(cell->ResolvedRowSpan(), 2u);
const unsigned cell_row_index = cell->RowIndex();
const unsigned cell_row_span = cell->ResolvedRowSpan();
// As we are going from the top of the table to the bottom to calculate the
// row heights for rows that only contain spanning cells and all previous
// rows are processed we only need to find the number of rows with spanning
// cells from the current cell to the end of the current cells spanning
// height.
unsigned start_row_for_spanning_cell_count = std::max(cell_row_index, row);
unsigned end_row = cell_row_index + cell_row_span;
unsigned spanning_cells_rows_count_having_zero_height =
rows_count_with_only_spanning_cells[end_row - 1];
if (start_row_for_spanning_cell_count)
spanning_cells_rows_count_having_zero_height -=
rows_count_with_only_spanning_cells
[start_row_for_spanning_cell_count - 1];
int total_rowspan_cell_height =
(row_pos_[end_row] - row_pos_[cell_row_index]) -
BorderSpacingForRow(end_row - 1);
total_rowspan_cell_height += accumulated_cell_position_increase;
if (row_to_apply_extra_height >= cell_row_index &&
row_to_apply_extra_height < end_row)
total_rowspan_cell_height += extra_table_height_to_propgate;
if (total_rowspan_cell_height < cell->LogicalHeightForRowSizing()) {
unsigned extra_height_required =
cell->LogicalHeightForRowSizing() - total_rowspan_cell_height;
row_height = std::max(
row_height,
extra_height_required / spanning_cells_rows_count_having_zero_height);
}
}
return row_height;
}
void LayoutTableSection::UpdateRowsHeightHavingOnlySpanningCells(
LayoutTableCell* cell,
struct SpanningRowsHeight& spanning_rows_height,
unsigned& extra_height_to_propagate,
Vector<int>& rows_count_with_only_spanning_cells) {
DCHECK(spanning_rows_height.row_height.size());
int accumulated_position_increase = 0;
const unsigned row_span = cell->ResolvedRowSpan();
const unsigned row_index = cell->RowIndex();
DCHECK_EQ(row_span, spanning_rows_height.row_height.size());
for (unsigned row = 0; row < spanning_rows_height.row_height.size(); row++) {
unsigned actual_row = row + row_index;
if (!spanning_rows_height.row_height[row] &&
RowHasOnlySpanningCells(actual_row)) {
spanning_rows_height.row_height[row] =
CalcRowHeightHavingOnlySpanningCells(
actual_row, accumulated_position_increase, row_index + row_span,
extra_height_to_propagate, rows_count_with_only_spanning_cells);
accumulated_position_increase += spanning_rows_height.row_height[row];
}
row_pos_[actual_row + 1] += accumulated_position_increase;
}
spanning_rows_height.total_rows_height += accumulated_position_increase;
}
// Distribute rowSpan cell height in rows those comes in rowSpan cell based on
// the ratio of row's height if 1 RowSpan cell height is greater than the total
// height of rows in rowSpan cell.
void LayoutTableSection::DistributeRowSpanHeightToRows(
SpanningLayoutTableCells& row_span_cells) {
DCHECK(row_span_cells.size());
// 'rowSpanCells' list is already sorted based on the cells rowIndex in
// ascending order
// Arrange row spanning cell in the order in which we need to process first.
std::sort(row_span_cells.begin(), row_span_cells.end(),
CompareRowSpanCellsInHeightDistributionOrder);
unsigned extra_height_to_propagate = 0;
unsigned last_row_index = 0;
unsigned last_row_span = 0;
Vector<int> rows_count_with_only_spanning_cells;
// At this stage, Height of the rows are zero for the one containing only
// spanning cells.
int count = 0;
for (unsigned row = 0; row < grid_.size(); row++) {
if (RowHasOnlySpanningCells(row))
count++;
rows_count_with_only_spanning_cells.push_back(count);
}
for (unsigned i = 0; i < row_span_cells.size(); i++) {
LayoutTableCell* cell = row_span_cells[i];
unsigned row_index = cell->RowIndex();
unsigned row_span = cell->ResolvedRowSpan();
unsigned spanning_cell_end_index = row_index + row_span;
unsigned last_spanning_cell_end_index = last_row_index + last_row_span;
// Only the highest spanning cell will distribute its extra height in a row
// if more than one spanning cell is present at the same level.
if (row_index == last_row_index && row_span == last_row_span)
continue;
int original_before_position = row_pos_[spanning_cell_end_index];
// When 2 spanning cells are ending at same row index then while extra
// height distribution of first spanning cell updates position of the last
// row so getting the original position of the last row in second spanning
// cell need to reduce the height changed by first spanning cell.
if (spanning_cell_end_index == last_spanning_cell_end_index)
original_before_position -= extra_height_to_propagate;
if (extra_height_to_propagate) {
for (unsigned row = last_spanning_cell_end_index + 1;
row <= spanning_cell_end_index; row++)
row_pos_[row] += extra_height_to_propagate;
}
last_row_index = row_index;
last_row_span = row_span;
struct SpanningRowsHeight spanning_rows_height;
PopulateSpanningRowsHeightFromCell(cell, spanning_rows_height);
// Here we are handling only row(s) who have only rowspanning cells and do
// not have any empty cell.
if (spanning_rows_height.is_any_row_with_only_spanning_cells)
UpdateRowsHeightHavingOnlySpanningCells(
cell, spanning_rows_height, extra_height_to_propagate,
rows_count_with_only_spanning_cells);
// This code handle row(s) that have rowspanning cell(s) and at least one
// empty cell. Such rows are not handled below and end up having a height of
// 0. That would mean content overlapping if one of their cells has any
// content. To avoid the problem, we add all the remaining spanning cells'
// height to the last spanned row. This means that we could grow a row past
// its 'height' or break percentage spreading however this is better than
// overlapping content.
// FIXME: Is there a better algorithm?
if (!spanning_rows_height.total_rows_height) {
if (spanning_rows_height.spanning_cell_height_ignoring_border_spacing)
row_pos_[spanning_cell_end_index] +=
spanning_rows_height.spanning_cell_height_ignoring_border_spacing +
BorderSpacingForRow(spanning_cell_end_index - 1);
extra_height_to_propagate =
row_pos_[spanning_cell_end_index] - original_before_position;
continue;
}
if (spanning_rows_height.spanning_cell_height_ignoring_border_spacing <=
spanning_rows_height.total_rows_height) {
extra_height_to_propagate =
row_pos_[row_index + row_span] - original_before_position;
continue;
}
// Below we are handling only row(s) who have at least one visible cell
// without rowspan value.
float total_percent = 0;
int total_auto_rows_height = 0;
int total_remaining_rows_height = spanning_rows_height.total_rows_height;
// FIXME: Inner spanning cell height should not change if it have fixed
// height when it's parent spanning cell is distributing it's extra height
// in rows.
// Calculate total percentage, total auto rows height and total rows height
// except percent rows.
for (unsigned row = row_index; row < spanning_cell_end_index; row++) {
// TODO(alancutter): Make this work correctly for calc lengths.
if (grid_[row].logical_height.IsPercent()) {
total_percent += grid_[row].logical_height.Percent();
total_remaining_rows_height -=
spanning_rows_height.row_height[row - row_index];
} else if (grid_[row].logical_height.IsAuto()) {
total_auto_rows_height +=
spanning_rows_height.row_height[row - row_index];
}
}
int extra_row_spanning_height =
spanning_rows_height.spanning_cell_height_ignoring_border_spacing -
spanning_rows_height.total_rows_height;
if (total_percent < 100 && !total_auto_rows_height &&
!total_remaining_rows_height) {
// Distributing whole extra rowspanning height in percent row when only
// non-percent rows height is 0.
DistributeWholeExtraRowSpanHeightToPercentRows(
cell, total_percent, extra_row_spanning_height,
spanning_rows_height.row_height);
} else {
DistributeExtraRowSpanHeightToPercentRows(
cell, total_percent, extra_row_spanning_height,
spanning_rows_height.row_height);
DistributeExtraRowSpanHeightToAutoRows(cell, total_auto_rows_height,
extra_row_spanning_height,
spanning_rows_height.row_height);
DistributeExtraRowSpanHeightToRemainingRows(
cell, total_remaining_rows_height, extra_row_spanning_height,
spanning_rows_height.row_height);
}
DCHECK(!extra_row_spanning_height);
// Getting total changed height in the table
extra_height_to_propagate =
row_pos_[spanning_cell_end_index] - original_before_position;
}
if (extra_height_to_propagate) {
// Apply changed height by rowSpan cells to rows present at the end of the
// table
for (unsigned row = last_row_index + last_row_span + 1; row <= grid_.size();
row++)
row_pos_[row] += extra_height_to_propagate;
}
}
bool LayoutTableSection::RowHasVisibilityCollapse(unsigned row) const {
return ((grid_[row].row &&
grid_[row].row->StyleRef().Visibility() == EVisibility::kCollapse) ||
StyleRef().Visibility() == EVisibility::kCollapse);
}
// Find out the baseline of the cell
// If the cell's baseline is more than the row's baseline then the cell's
// baseline become the row's baseline and if the row's baseline goes out of the
// row's boundaries then adjust row height accordingly.
void LayoutTableSection::UpdateBaselineForCell(LayoutTableCell* cell,
unsigned row,
LayoutUnit& baseline_descent) {
if (!cell->IsBaselineAligned())
return;
// Ignoring the intrinsic padding as it depends on knowing the row's baseline,
// which won't be accurate until the end of this function.
LayoutUnit baseline_position =
cell->CellBaselinePosition() - cell->IntrinsicPaddingBefore();
if (baseline_position >
cell->BorderBefore() +
(cell->PaddingBefore() - cell->IntrinsicPaddingBefore())) {
grid_[row].baseline = std::max(grid_[row].baseline, baseline_position);
LayoutUnit cell_start_row_baseline_descent;
if (cell->ResolvedRowSpan() == 1) {
baseline_descent =
std::max(baseline_descent,
cell->LogicalHeightForRowSizing() - baseline_position);
cell_start_row_baseline_descent = baseline_descent;
}
row_pos_[row + 1] = std::max(
row_pos_[row + 1],
(row_pos_[row] + grid_[row].baseline + cell_start_row_baseline_descent)
.ToInt());
}
}
int16_t LayoutTableSection::VBorderSpacingBeforeFirstRow() const {
// We ignore the border-spacing on any non-top section, as it is already
// included in the previous section's last row position.
if (this != Table()->TopSection())
return 0;
return Table()->VBorderSpacing();
}
int LayoutTableSection::CalcRowLogicalHeight() {
#if DCHECK_IS_ON()
SetLayoutNeededForbiddenScope layout_forbidden_scope(*this);
#endif
DCHECK(!NeedsLayout());
// We may have to forcefully lay out cells here, in which case we need a
// layout state.
LayoutState state(*this);
row_pos_.resize(grid_.size() + 1);
row_pos_[0] = VBorderSpacingBeforeFirstRow();
SpanningLayoutTableCells row_span_cells;
// At fragmentainer breaks we need to prevent rowspanned cells (and whatever
// else) from distributing their extra height requirements over the rows that
// it spans. Otherwise we'd need to refragment afterwards.
unsigned index_of_first_stretchable_row = 0;
is_any_row_collapsed_ = false;
for (unsigned r = 0; r < grid_.size(); r++) {
grid_[r].baseline = LayoutUnit(-1);
LayoutUnit baseline_descent;
if (!is_any_row_collapsed_)
is_any_row_collapsed_ = RowHasVisibilityCollapse(r);
if (state.IsPaginated() && grid_[r].row)
row_pos_[r] += grid_[r].row->PaginationStrut().Ceil();
if (grid_[r].logical_height.IsSpecified()) {
// Our base size is the biggest logical height from our cells' styles
// (excluding row spanning cells).
row_pos_[r + 1] =
std::max(row_pos_[r] + MinimumValueForLength(grid_[r].logical_height,
LayoutUnit())
.Round(),
0);
} else {
// Non-specified lengths are ignored because the row already accounts for
// the cells intrinsic logical height.
row_pos_[r + 1] = std::max(row_pos_[r], 0);
}
for (auto& grid_cell : grid_[r].grid_cells) {
if (grid_cell.InColSpan())
continue;
for (auto* cell : grid_cell.Cells()) {
// For row spanning cells, we only handle them for the first row they
// span. This ensures we take their baseline into account.
if (cell->RowIndex() != r)
continue;
if (r < index_of_first_stretchable_row ||
(state.IsPaginated() &&
CrossesPageBoundary(
LayoutUnit(row_pos_[r]),
LayoutUnit(cell->LogicalHeightForRowSizing())))) {
// Entering or extending a range of unstretchable rows. We enter this
// mode when a cell in a row crosses a fragmentainer boundary, and
// we'll stay in this mode until we get to a row where we're past all
// rowspanned cells that we encountered while in this mode.
DCHECK(state.IsPaginated());
unsigned row_index_below_cell = r + cell->ResolvedRowSpan();
index_of_first_stretchable_row =
std::max(index_of_first_stretchable_row, row_index_below_cell);
} else if (cell->ResolvedRowSpan() > 1) {
DCHECK(!row_span_cells.Contains(cell));
cell->SetIsSpanningCollapsedRow(false);
unsigned end_row = cell->ResolvedRowSpan() + r;
for (unsigned spanning = r; spanning < end_row; spanning++) {
if (RowHasVisibilityCollapse(spanning)) {
cell->SetIsSpanningCollapsedRow(true);
break;
}
}
row_span_cells.push_back(cell);
}
if (cell->HasOverrideLogicalHeight()) {
cell->ClearIntrinsicPadding();
cell->ClearOverrideSize();
cell->ForceLayout();
}
if (cell->ResolvedRowSpan() == 1)
row_pos_[r + 1] = std::max(
row_pos_[r + 1], row_pos_[r] + cell->LogicalHeightForRowSizing());
// Find out the baseline. The baseline is set on the first row in a
// rowSpan.
UpdateBaselineForCell(cell, r, baseline_descent);
}
}
if (r < index_of_first_stretchable_row && grid_[r].row) {
// We're not allowed to resize this row. Just scratch what we've
// calculated so far, and use the height that we got during initial
// layout instead.
row_pos_[r + 1] = row_pos_[r] + grid_[r].row->LogicalHeight().ToInt();
}
// Add the border-spacing to our final position.
row_pos_[r + 1] += BorderSpacingForRow(r);
row_pos_[r + 1] = std::max(row_pos_[r + 1], row_pos_[r]);
}
if (!row_span_cells.IsEmpty())
DistributeRowSpanHeightToRows(row_span_cells);
DCHECK(!NeedsLayout());
// Collapsed rows are dealt with after distributing row span height to rows.
// This is because the distribution calculations should be as if the row were
// not collapsed. First, all rows' collapsed heights are set. After, row
// positions are adjusted accordingly.
if (is_any_row_collapsed_) {
row_collapsed_height_.resize(grid_.size());
for (unsigned r = 0; r < grid_.size(); r++) {
if (RowHasVisibilityCollapse(r)) {
// Update vector that keeps track of collapsed height of each row.
row_collapsed_height_[r] = row_pos_[r + 1] - row_pos_[r];
} else {
// Reset rows that are no longer collapsed.
row_collapsed_height_[r] = 0;
}
}
int total_collapsed_height = 0;
for (unsigned r = 0; r < grid_.size(); r++) {
total_collapsed_height += row_collapsed_height_[r];
// Adjust row position according to the height collapsed so far.
row_pos_[r + 1] -= total_collapsed_height;
DCHECK_GE(row_pos_[r + 1], row_pos_[r]);
}
}
return row_pos_[grid_.size()];
}
void LayoutTableSection::UpdateLayout() {
DCHECK(NeedsLayout());
LayoutAnalyzer::Scope analyzer(*this);
CHECK(!NeedsCellRecalc());
DCHECK(!Table()->NeedsSectionRecalc());
// addChild may over-grow grid_ but we don't want to throw away the memory
// too early as addChild can be called in a loop (e.g during parsing). Doing
// it now ensures we have a stable-enough structure.
grid_.ShrinkToFit();
LayoutState state(*this);
const Vector<int>& column_pos = Table()->EffectiveColumnPositions();
LayoutUnit row_logical_top(VBorderSpacingBeforeFirstRow());
SubtreeLayoutScope layouter(*this);
for (unsigned r = 0; r < grid_.size(); ++r) {
auto& grid_cells = grid_[r].grid_cells;
unsigned cols = grid_cells.size();
// First, propagate our table layout's information to the cells. This will
// mark the row as needing layout if there was a column logical width
// change.
for (unsigned start_column = 0; start_column < cols; ++start_column) {
auto& grid_cell = grid_cells[start_column];
LayoutTableCell* cell = grid_cell.PrimaryCell();
if (!cell || grid_cell.InColSpan())
continue;
unsigned end_col = start_column;
unsigned cspan = cell->ColSpan();
while (cspan && end_col < cols) {
DCHECK_LT(end_col, Table()->EffectiveColumns().size());
cspan -= Table()->EffectiveColumns()[end_col].span;
end_col++;
}
int table_layout_logical_width = column_pos[end_col] -
column_pos[start_column] -
Table()->HBorderSpacing();
cell->SetCellLogicalWidth(table_layout_logical_width, layouter);
}
if (LayoutTableRow* row = grid_[r].row) {
if (state.IsPaginated())
row->SetLogicalTop(row_logical_top);
if (!row->NeedsLayout())
MarkChildForPaginationRelayoutIfNeeded(*row, layouter);
row->LayoutIfNeeded();
if (state.IsPaginated()) {
AdjustRowForPagination(*row, layouter);
UpdateFragmentationInfoForChild(*row);
row_logical_top = row->LogicalBottom();
row_logical_top += LayoutUnit(Table()->VBorderSpacing());
}
if (!Table()->HasSameDirectionAs(row)) {
UseCounter::Count(GetDocument(),
WebFeature::kTableRowDirectionDifferentFromTable);
}
}
}
if (!Table()->HasSameDirectionAs(this)) {
UseCounter::Count(GetDocument(),
WebFeature::kTableSectionDirectionDifferentFromTable);
}
ClearNeedsLayout();
}
void LayoutTableSection::DistributeExtraLogicalHeightToPercentRows(
int& extra_logical_height,
int total_percent) {
if (!total_percent)
return;
unsigned total_rows = grid_.size();
int total_height = row_pos_[total_rows] + extra_logical_height;
int total_logical_height_added = 0;
total_percent = std::min(total_percent, 100);
int row_height = row_pos_[1] - row_pos_[0];
for (unsigned r = 0; r < total_rows; ++r) {
// TODO(alancutter): Make this work correctly for calc lengths.
if (total_percent > 0 && grid_[r].logical_height.IsPercent()) {
int to_add = std::min<int>(
extra_logical_height,
(total_height * grid_[r].logical_height.Percent() / 100) -
row_height);
// If toAdd is negative, then we don't want to shrink the row (this bug
// affected Outlook Web Access).
to_add = std::max(0, to_add);
total_logical_height_added += to_add;
extra_logical_height -= to_add;
total_percent -= grid_[r].logical_height.Percent();
}
DCHECK_GE(total_rows, 1u);
if (r < total_rows - 1)
row_height = row_pos_[r + 2] - row_pos_[r + 1];
row_pos_[r + 1] += total_logical_height_added;
}
}
void LayoutTableSection::DistributeExtraLogicalHeightToAutoRows(
int& extra_logical_height,
unsigned auto_rows_count) {
if (!auto_rows_count)
return;
int total_logical_height_added = 0;
for (unsigned r = 0; r < grid_.size(); ++r) {
if (auto_rows_count > 0 && grid_[r].logical_height.IsAuto()) {
// Recomputing |extraLogicalHeightForRow| guarantees that we properly
// ditribute round |extraLogicalHeight|.
int extra_logical_height_for_row = extra_logical_height / auto_rows_count;
total_logical_height_added += extra_logical_height_for_row;
extra_logical_height -= extra_logical_height_for_row;
--auto_rows_count;
}
row_pos_[r + 1] += total_logical_height_added;
}
}
void LayoutTableSection::DistributeRemainingExtraLogicalHeight(
int& extra_logical_height) {
unsigned total_rows = grid_.size();
if (extra_logical_height <= 0 || !row_pos_[total_rows])
return;
int total_logical_height_added = 0;
int previous_row_position = row_pos_[0];
float total_row_size = row_pos_[total_rows] - previous_row_position;
for (unsigned r = 0; r < total_rows; r++) {
// weight with the original height
float height_to_add = extra_logical_height *
(row_pos_[r + 1] - previous_row_position) /
total_row_size;
total_logical_height_added =
std::min<int>(total_logical_height_added + std::ceil(height_to_add),
extra_logical_height);
previous_row_position = row_pos_[r + 1];
row_pos_[r + 1] += total_logical_height_added;
}
extra_logical_height -= total_logical_height_added;
}
int LayoutTableSection::DistributeExtraLogicalHeightToRows(
int extra_logical_height) {
if (!extra_logical_height)
return extra_logical_height;
unsigned total_rows = grid_.size();
if (!total_rows)
return extra_logical_height;
if (!row_pos_[total_rows] && NextSibling())
return extra_logical_height;
unsigned auto_rows_count = 0;
int total_percent = 0;
for (unsigned r = 0; r < total_rows; r++) {
if (grid_[r].logical_height.IsAuto())
++auto_rows_count;
else if (grid_[r].logical_height.IsPercent())
total_percent += grid_[r].logical_height.Percent();
}
int remaining_extra_logical_height = extra_logical_height;
DistributeExtraLogicalHeightToPercentRows(remaining_extra_logical_height,
total_percent);
DistributeExtraLogicalHeightToAutoRows(remaining_extra_logical_height,
auto_rows_count);
DistributeRemainingExtraLogicalHeight(remaining_extra_logical_height);
return extra_logical_height - remaining_extra_logical_height;
}
static bool CellHasExplicitlySpecifiedHeight(const LayoutTableCell& cell) {
if (cell.StyleRef().LogicalHeight().IsFixed())
return true;
LayoutBlock* cb = cell.ContainingBlock();
if (cb->AvailableLogicalHeightForPercentageComputation() == -1)
return false;
return true;
}
static bool ShouldFlexCellChild(const LayoutTableCell& cell,
LayoutObject* cell_descendant) {
if (!CellHasExplicitlySpecifiedHeight(cell))
return false;
// TODO(dgrogan): Delete ShouldFlexCellChild. It's only called when
// CellHasExplicitlySpecifiedHeight is false.
NOTREACHED() << "This is dead code?";
if (cell_descendant->StyleRef().OverflowY() == EOverflow::kVisible ||
cell_descendant->StyleRef().OverflowY() == EOverflow::kHidden)
return true;
return cell_descendant->IsBox() &&
ToLayoutBox(cell_descendant)->ShouldBeConsideredAsReplaced();
}
void LayoutTableSection::LayoutRows() {
#if DCHECK_IS_ON()
SetLayoutNeededForbiddenScope layout_forbidden_scope(*this);
#endif
DCHECK(!NeedsLayout());
LayoutAnalyzer::Scope analyzer(*this);
// FIXME: Changing the height without a layout can change the overflow so it
// seems wrong.
unsigned total_rows = grid_.size();
// Set the width of our section now. The rows will also be this width.
SetLogicalWidth(Table()->ContentLogicalWidth());
int16_t vspacing = Table()->VBorderSpacing();
LayoutState state(*this);
// Set the rows' location and size.
for (unsigned r = 0; r < total_rows; r++) {
if (LayoutTableRow* row = grid_[r].row) {
row->SetLogicalLocation(LayoutPoint(0, row_pos_[r]));
row->SetLogicalWidth(LogicalWidth());
LayoutUnit row_logical_height;
// If the row is collapsed then it has 0 height. vspacing was implicitly
// removed earlier, when row_pos_[r+1] was set to row_pos[r].
if (!RowHasVisibilityCollapse(r)) {
row_logical_height =
LayoutUnit(row_pos_[r + 1] - row_pos_[r] - vspacing);
}
DCHECK_GE(row_logical_height, 0);
if (state.IsPaginated() && r + 1 < total_rows) {
// If the next row has a pagination strut, we need to subtract it. It
// should not be included in this row's height.
if (LayoutTableRow* next_row_object = grid_[r + 1].row)
row_logical_height -= next_row_object->PaginationStrut();
}
DCHECK_GE(row_logical_height, 0);
row->SetLogicalHeight(row_logical_height);
row->UpdateAfterLayout();
}
}
// Vertically align and flex the cells in each row.
for (unsigned r = 0; r < total_rows; r++) {
LayoutTableRow* row = grid_[r].row;
unsigned n_cols = NumCols(r);
for (unsigned c = 0; c < n_cols; c++) {
LayoutTableCell* cell = OriginatingCellAt(r, c);
if (!cell)
continue;
int r_height;
int row_logical_top;
unsigned row_span = std::max(1U, cell->ResolvedRowSpan());
unsigned end_row_index = std::min(r + row_span, total_rows) - 1;
LayoutTableRow* last_row_object = grid_[end_row_index].row;
if (last_row_object && row) {
row_logical_top = row->LogicalTop().ToInt();
r_height = last_row_object->LogicalBottom().ToInt() - row_logical_top;
} else {
r_height = row_pos_[end_row_index + 1] - row_pos_[r] - vspacing;
row_logical_top = row_pos_[r];
}
RelayoutCellIfFlexed(*cell, r, r_height);
SubtreeLayoutScope layouter(*cell);
EVerticalAlign cell_vertical_align;
// If the cell crosses a fragmentainer boundary, just align it at the
// top. That's how it was laid out initially, before we knew the final
// row height, and re-aligning it now could result in the cell being
// fragmented differently, which could change its height and thus violate
// the requested alignment. Give up instead of risking circular
// dependencies and unstable layout.
if (state.IsPaginated() &&
CrossesPageBoundary(LayoutUnit(row_logical_top),
LayoutUnit(r_height)))
cell_vertical_align = EVerticalAlign::kTop;
else
cell_vertical_align = cell->StyleRef().VerticalAlign();
// Calculate total collapsed height affecting one cell.
int collapsed_height = 0;
if (is_any_row_collapsed_) {
unsigned end_row = cell->ResolvedRowSpan() + r;
for (unsigned spanning = r; spanning < end_row; spanning++) {
collapsed_height += row_collapsed_height_[spanning];
}
}
cell->ComputeIntrinsicPadding(collapsed_height, r_height,
cell_vertical_align, layouter);
LayoutRect old_cell_rect = cell->FrameRect();
SetLogicalPositionForCell(cell, c);
cell->LayoutIfNeeded();
LayoutSize child_offset(cell->Location() - old_cell_rect.Location());
if (child_offset.Width() || child_offset.Height()) {
// If the child moved, we have to issue paint invalidations to it as
// well as any floating/positioned descendants. An exception is if we
// need a layout. In this case, we know we're going to issue paint
// invalidations ourselves (and the child) anyway.
if (!Table()->SelfNeedsLayout())
cell->SetShouldCheckForPaintInvalidation();
}
}
if (row)
row->ComputeLayoutOverflow();
}
DCHECK(!NeedsLayout());
SetLogicalHeight(LayoutUnit(row_pos_[total_rows]));
ComputeLayoutOverflowFromDescendants();
}
void LayoutTableSection::UpdateLogicalWidthForCollapsedCells(
const Vector<int>& col_collapsed_width) {
if (!RuntimeEnabledFeatures::VisibilityCollapseColumnEnabled())
return;
unsigned total_rows = grid_.size();
for (unsigned r = 0; r < total_rows; r++) {
unsigned n_cols = NumCols(r);
for (unsigned c = 0; c < n_cols; c++) {
LayoutTableCell* cell = OriginatingCellAt(r, c);
if (!cell)
continue;
if (!col_collapsed_width.size()) {
cell->SetIsSpanningCollapsedColumn(false);
continue;
}
// TODO(joysyu): Current behavior assumes that collapsing the first column
// in a col-spanning cell makes the cell width zero. This is consistent
// with collapsing row-spanning cells, but still needs to be specified.
if (cell->IsFirstColumnCollapsed()) {
// Collapsed cells have zero width.
cell->SetLogicalWidth(LayoutUnit());
} else if (cell->ColSpan() > 1) {
// A column-spanning cell may be affected by collapsed columns, so its
// width needs to be adjusted accordingly
int collapsed_width = 0;
cell->SetIsSpanningCollapsedColumn(false);
unsigned end_col = std::min(cell->ColSpan() + c, n_cols);
for (unsigned spanning = c; spanning < end_col; spanning++)
collapsed_width += col_collapsed_width[spanning];
cell->SetLogicalWidth(cell->LogicalWidth() - collapsed_width);
if (collapsed_width != 0)
cell->SetIsSpanningCollapsedColumn(true);
// Recompute overflow in case overflow clipping is necessary.
cell->ComputeLayoutOverflow(cell->ClientLogicalBottom(), false);
DCHECK_GE(cell->LogicalWidth(), 0);
}
}
}
}
int LayoutTableSection::PaginationStrutForRow(LayoutTableRow* row,
LayoutUnit logical_offset) const {
DCHECK(row);
const LayoutTableSection* footer = Table()->Footer();
bool make_room_for_repeating_footer =
footer && footer->IsRepeatingFooterGroup() && row->RowIndex();
if (!make_room_for_repeating_footer &&
row->GetPaginationBreakability() == kAllowAnyBreaks)
return 0;
if (!IsPageLogicalHeightKnown())
return 0;
LayoutUnit page_logical_height = PageLogicalHeightForOffset(logical_offset);
// If the row is too tall for the page don't insert a strut.
LayoutUnit row_logical_height = row->LogicalHeight();
if (row_logical_height > page_logical_height)
return 0;
LayoutUnit remaining_logical_height = PageRemainingLogicalHeightForOffset(
logical_offset, LayoutBlock::kAssociateWithLatterPage);
if (remaining_logical_height >= row_logical_height)
return 0; // It fits fine where it is. No need to break.
LayoutUnit pagination_strut =
CalculatePaginationStrutToFitContent(logical_offset, row_logical_height);
if (pagination_strut == remaining_logical_height &&
remaining_logical_height == page_logical_height) {
// Don't break if we were at the top of a page, and we failed to fit the
// content completely. No point in leaving a page completely blank.
return 0;
}
// Table layout parts only work on integers, so we have to round. Round up, to
// make sure that no fraction ever gets left behind in the previous
// fragmentainer.
return pagination_strut.Ceil();
}
void LayoutTableSection::ComputeVisualOverflowFromDescendants() {
auto old_self_visual_overflow_rect = SelfVisualOverflowRect();
ClearVisualOverflow();
visually_overflowing_cells_.clear();
force_full_paint_ = false;
// These 2 variables are used to balance the memory consumption vs the paint
// time on big sections with overflowing cells:
// 1. For small sections, don't track overflowing cells because for them the
// full paint path is actually faster than the partial paint path.
// 2. For big sections, if overflowing cells are scarce, track overflowing
// cells to enable the partial paint path.
// 3. Otherwise don't track overflowing cells to avoid adding a lot of cells
// to the HashSet, and force the full paint path.
// See TableSectionPainter::PaintObject() for the full paint path and the
// partial paint path.
static const unsigned kMinCellCountToUsePartialPaint = 75 * 75;
static const float kMaxOverflowingCellRatioForPartialPaint = 0.1f;
unsigned total_cell_count = NumRows() * Table()->NumEffectiveColumns();
unsigned max_overflowing_cell_count =
total_cell_count < kMinCellCountToUsePartialPaint
? 0
: kMaxOverflowingCellRatioForPartialPaint * total_cell_count;
#if DCHECK_IS_ON()
bool has_overflowing_cell = false;
#endif
for (auto* row = FirstRow(); row; row = row->NextRow()) {
AddVisualOverflowFromChild(*row);
for (auto* cell = row->FirstCell(); cell; cell = cell->NextCell()) {
if (cell->HasSelfPaintingLayer())
continue;
if (force_full_paint_ || !cell->HasVisualOverflow())
continue;
#if DCHECK_IS_ON()
has_overflowing_cell = true;
#endif
if (visually_overflowing_cells_.size() >= max_overflowing_cell_count) {
force_full_paint_ = true;
// The full paint path does not make any use of the overflowing cells
// info, so don't hold on to the memory.
visually_overflowing_cells_.clear();
continue;
}
visually_overflowing_cells_.insert(cell);
}
}
#if DCHECK_IS_ON()
DCHECK_EQ(has_overflowing_cell, HasVisuallyOverflowingCell());
#endif
// Overflow rect contributes to the visual rect, so if it has changed then we
// need to signal a possible paint invalidation.
if (old_self_visual_overflow_rect != SelfVisualOverflowRect())
SetShouldCheckForPaintInvalidation();
}
void LayoutTableSection::ComputeLayoutOverflowFromDescendants() {
ClearLayoutOverflow();
for (auto* row = FirstRow(); row; row = row->NextRow())
AddLayoutOverflowFromChild(*row);
}
bool LayoutTableSection::RecalcLayoutOverflow() {
if (!ChildNeedsLayoutOverflowRecalc())
return false;
ClearChildNeedsLayoutOverflowRecalc();
unsigned total_rows = grid_.size();
bool children_layout_overflow_changed = false;
for (unsigned r = 0; r < total_rows; r++) {
LayoutTableRow* row_layouter = RowLayoutObjectAt(r);
if (!row_layouter || !row_layouter->ChildNeedsLayoutOverflowRecalc())
continue;
row_layouter->ClearChildNeedsLayoutOverflowRecalc();
bool row_children_layout_overflow_changed = false;
unsigned n_cols = NumCols(r);
for (unsigned c = 0; c < n_cols; c++) {
auto* cell = OriginatingCellAt(r, c);
if (!cell)
continue;
row_children_layout_overflow_changed |= cell->RecalcLayoutOverflow();
}
if (row_children_layout_overflow_changed)
row_layouter->ComputeLayoutOverflow();
children_layout_overflow_changed |= row_children_layout_overflow_changed;
}
if (children_layout_overflow_changed)
ComputeLayoutOverflowFromDescendants();
return children_layout_overflow_changed;
}
void LayoutTableSection::RecalcVisualOverflow() {
SECURITY_CHECK(!needs_cell_recalc_);
unsigned total_rows = grid_.size();
for (unsigned r = 0; r < total_rows; r++) {
LayoutTableRow* row_layouter = RowLayoutObjectAt(r);
if (!row_layouter || (row_layouter->HasLayer() &&
row_layouter->Layer()->IsSelfPaintingLayer()))
continue;
row_layouter->RecalcVisualOverflow();
}
ComputeVisualOverflowFromDescendants();
AddVisualEffectOverflow();
}
void LayoutTableSection::MarkAllCellsWidthsDirtyAndOrNeedsLayout(
LayoutTable::WhatToMarkAllCells what_to_mark) {
for (LayoutTableRow* row = FirstRow(); row; row = row->NextRow()) {
for (LayoutTableCell* cell = row->FirstCell(); cell;
cell = cell->NextCell()) {
cell->SetPreferredLogicalWidthsDirty();
if (what_to_mark == LayoutTable::kMarkDirtyAndNeedsLayout)
cell->SetChildNeedsLayout();
}
}
}
LayoutUnit LayoutTableSection::FirstLineBoxBaseline() const {
DCHECK(!NeedsCellRecalc());
if (!grid_.size())
return LayoutUnit(-1);
LayoutUnit first_line_baseline(grid_[0].baseline);
if (first_line_baseline >= 0)
return first_line_baseline + row_pos_[0];
for (const auto& grid_cell : grid_[0].grid_cells) {
if (const auto* cell = grid_cell.PrimaryCell()) {
first_line_baseline = std::max<LayoutUnit>(
first_line_baseline, cell->LogicalTop() + cell->BorderBefore() +
cell->PaddingBefore() +
cell->ContentLogicalHeight());
}
}
return first_line_baseline;
}
void LayoutTableSection::Paint(const PaintInfo& paint_info) const {
TableSectionPainter(*this).Paint(paint_info);
}
LayoutRect LayoutTableSection::LogicalRectForWritingModeAndDirection(
const LayoutRect& rect) const {
LayoutRect table_aligned_rect(rect);
DeprecatedFlipForWritingMode(table_aligned_rect);
if (!TableStyle().IsHorizontalWritingMode())
table_aligned_rect = table_aligned_rect.TransposedRect();
const Vector<int>& column_pos = Table()->EffectiveColumnPositions();
if (!TableStyle().IsLeftToRightDirection()) {
table_aligned_rect.SetX(column_pos[column_pos.size() - 1] -
table_aligned_rect.MaxX());
}
return table_aligned_rect;
}
void LayoutTableSection::DirtiedRowsAndEffectiveColumns(
const LayoutRect& damage_rect,
CellSpan& rows,
CellSpan& columns) const {
DCHECK(!NeedsCellRecalc());
if (!grid_.size()) {
rows = CellSpan();
columns = CellSpan(1, 1);
return;
}
if (force_full_paint_) {
rows = FullSectionRowSpan();
columns = FullTableEffectiveColumnSpan();
return;
}
rows = SpannedRows(damage_rect);
columns = SpannedEffectiveColumns(damage_rect);
// Expand by one cell in each direction to cover any collapsed borders.
if (Table()->ShouldCollapseBorders()) {
if (rows.Start() > 0)
rows.DecreaseStart();
if (rows.End() < grid_.size())
rows.IncreaseEnd();
if (columns.Start() > 0)
columns.DecreaseStart();
if (columns.End() < Table()->NumEffectiveColumns())
columns.IncreaseEnd();
}
rows.EnsureConsistency(grid_.size());
columns.EnsureConsistency(Table()->NumEffectiveColumns());
if (!has_spanning_cells_)
return;
if (rows.Start() > 0 && rows.Start() < grid_.size()) {
// If there are any cells spanning into the first row, expand |rows| to
// cover the cells.
unsigned n_cols = NumCols(rows.Start());
unsigned smallest_row = rows.Start();
for (unsigned c = columns.Start(); c < std::min(columns.End(), n_cols);
++c) {
for (const auto* cell : GridCellAt(rows.Start(), c).Cells()) {
smallest_row = std::min(smallest_row, cell->RowIndex());
if (!smallest_row)
break;
}
}
rows = CellSpan(smallest_row, rows.End());
}
if (columns.Start() > 0 && columns.Start() < Table()->NumEffectiveColumns()) {
// If there are any cells spanning into the first column, expand |columns|
// to cover the cells.
unsigned smallest_column = columns.Start();
for (unsigned r = rows.Start(); r < rows.End(); ++r) {
const auto& grid_cells = grid_[r].grid_cells;
if (columns.Start() < grid_cells.size()) {
unsigned c = columns.Start();
while (c && grid_cells[c].InColSpan())
--c;
smallest_column = std::min(c, smallest_column);
if (!smallest_column)
break;
}
}
columns = CellSpan(smallest_column, columns.End());
}
}
CellSpan LayoutTableSection::SpannedRows(const LayoutRect& flipped_rect) const {
// Find the first row that starts after rect top.
unsigned next_row = static_cast<unsigned>(
std::upper_bound(row_pos_.begin(), row_pos_.end(), flipped_rect.Y()) -
row_pos_.begin());
// After all rows.
if (next_row == row_pos_.size())
return CellSpan(row_pos_.size() - 1, row_pos_.size() - 1);
unsigned start_row = next_row > 0 ? next_row - 1 : 0;
// Find the first row that starts after rect bottom.
unsigned end_row;
if (row_pos_[next_row] >= flipped_rect.MaxY()) {
end_row = next_row;
} else {
end_row = static_cast<unsigned>(
std::upper_bound(row_pos_.begin() + next_row, row_pos_.end(),
flipped_rect.MaxY()) -
row_pos_.begin());
if (end_row == row_pos_.size())
end_row = row_pos_.size() - 1;
}
return CellSpan(start_row, end_row);
}
CellSpan LayoutTableSection::SpannedEffectiveColumns(
const LayoutRect& flipped_rect) const {
const Vector<int>& column_pos = Table()->EffectiveColumnPositions();
// Find the first column that starts after rect left.
// lower_bound doesn't handle the edge between two cells properly as it would
// wrongly return the cell on the logical top/left.
// upper_bound on the other hand properly returns the cell on the logical
// bottom/right, which also matches the behavior of other browsers.
unsigned next_column = static_cast<unsigned>(
std::upper_bound(column_pos.begin(), column_pos.end(), flipped_rect.X()) -
column_pos.begin());
if (next_column == column_pos.size())
return CellSpan(column_pos.size() - 1,
column_pos.size() - 1); // After all columns.
unsigned start_column = next_column > 0 ? next_column - 1 : 0;
// Find the first column that starts after rect right.
unsigned end_column;
if (column_pos[next_column] >= flipped_rect.MaxX()) {
end_column = next_column;
} else {
end_column = static_cast<unsigned>(
std::upper_bound(column_pos.begin() + next_column, column_pos.end(),
flipped_rect.MaxX()) -
column_pos.begin());
if (end_column == column_pos.size())
end_column = column_pos.size() - 1;
}
return CellSpan(start_column, end_column);
}
void LayoutTableSection::RecalcCells() {
DCHECK(needs_cell_recalc_);
// We reset the flag here to ensure that |addCell| works. This is safe to do
// as fillRowsWithDefaultStartingAtPosition makes sure we match the table's
// columns representation.
needs_cell_recalc_ = false;
c_col_ = 0;
c_row_ = 0;
grid_.clear();
bool resized_grid = false;
for (LayoutTableRow* row = FirstRow(); row; row = row->NextRow()) {
unsigned insertion_row = c_row_;
++c_row_;
c_col_ = 0;
EnsureRows(c_row_);
grid_[insertion_row].row = row;
row->SetRowIndex(insertion_row);
grid_[insertion_row].SetRowLogicalHeightToRowStyleLogicalHeight();
for (LayoutTableCell* cell = row->FirstCell(); cell;
cell = cell->NextCell()) {
// For rowspan, "the value zero means that the cell is to span all the
// remaining rows in the row group." Calculate the size of the full
// row grid now so that we can use it to count the remaining rows in
// ResolvedRowSpan().
if (!cell->ParsedRowSpan() && !resized_grid) {
unsigned c_row = row->RowIndex() + 1;
for (LayoutTableRow* remaining_row = row; remaining_row;
remaining_row = remaining_row->NextRow())
c_row++;
EnsureRows(c_row);
resized_grid = true;
}
AddCell(cell, row);
}
}
grid_.ShrinkToFit();
SetNeedsLayoutAndFullPaintInvalidation(layout_invalidation_reason::kUnknown);
}
// FIXME: This function could be made O(1) in certain cases (like for the
// non-most-constrainive cells' case).
void LayoutTableSection::RowLogicalHeightChanged(LayoutTableRow* row) {
if (NeedsCellRecalc())
return;
unsigned row_index = row->RowIndex();
grid_[row_index].SetRowLogicalHeightToRowStyleLogicalHeight();
for (LayoutTableCell* cell = grid_[row_index].row->FirstCell(); cell;
cell = cell->NextCell())
grid_[row_index].UpdateLogicalHeightForCell(cell);
}
void LayoutTableSection::SetNeedsCellRecalc() {
needs_cell_recalc_ = true;
SetNeedsOverflowRecalc();
if (LayoutTable* t = Table())
t->SetNeedsSectionRecalc();
}
unsigned LayoutTableSection::NumEffectiveColumns() const {
unsigned result = 0;
for (unsigned r = 0; r < grid_.size(); ++r) {
unsigned n_cols = NumCols(r);
for (unsigned c = result; c < n_cols; ++c) {
const auto& grid_cell = GridCellAt(r, c);
if (grid_cell.HasCells() || grid_cell.InColSpan())
result = c;
}
}
return result + 1;
}
LayoutTableCell* LayoutTableSection::OriginatingCellAt(
unsigned row,
unsigned effective_column) {
SECURITY_CHECK(!needs_cell_recalc_);
if (effective_column >= NumCols(row))
return nullptr;
auto& grid_cell = GridCellAt(row, effective_column);
if (grid_cell.InColSpan())
return nullptr;
if (auto* cell = grid_cell.PrimaryCell()) {
if (cell->RowIndex() == row)
return cell;
}
return nullptr;
}
void LayoutTableSection::AppendEffectiveColumn(unsigned pos) {
DCHECK(!needs_cell_recalc_);
for (auto& row : grid_)
row.grid_cells.resize(pos + 1);
}
void LayoutTableSection::SplitEffectiveColumn(unsigned pos, unsigned first) {
DCHECK(!needs_cell_recalc_);
if (c_col_ > pos)
c_col_++;
for (unsigned row = 0; row < grid_.size(); ++row) {
auto& grid_cells = grid_[row].grid_cells;
EnsureCols(row, pos + 1);
grid_cells.insert(pos + 1, TableGridCell());
if (grid_cells[pos].HasCells()) {
grid_cells[pos + 1].Cells().AppendVector(grid_cells[pos].Cells());
LayoutTableCell* cell = grid_cells[pos].PrimaryCell();
DCHECK(cell);
DCHECK_GE(cell->ColSpan(), (grid_cells[pos].InColSpan() ? 1u : 0));
unsigned colleft = cell->ColSpan() - grid_cells[pos].InColSpan();
if (first > colleft)
grid_cells[pos + 1].SetInColSpan(false);
else
grid_cells[pos + 1].SetInColSpan(first || grid_cells[pos].InColSpan());
} else {
grid_cells[pos + 1].SetInColSpan(false);
}
}
}
// Hit Testing
bool LayoutTableSection::NodeAtPoint(
HitTestResult& result,
const HitTestLocation& location_in_container,
const LayoutPoint& accumulated_offset,
HitTestAction action) {
// If we have no children then we have nothing to do.
if (!FirstRow())
return false;
// Table sections cannot ever be hit tested. Effectively they do not exist.
// Just forward to our children always.
LayoutPoint adjusted_location = accumulated_offset + Location();
if (HasOverflowClip() &&
!location_in_container.Intersects(OverflowClipRect(adjusted_location)))
return false;
if (HasVisuallyOverflowingCell()) {
for (LayoutTableRow* row = LastRow(); row; row = row->PreviousRow()) {
// FIXME: We have to skip over inline flows, since they can show up inside
// table rows at the moment (a demoted inline <form> for example). If we
// ever implement a table-specific hit-test method (which we should do for
// performance reasons anyway), then we can remove this check.
if (!row->HasSelfPaintingLayer()) {
LayoutPoint child_point =
FlipForWritingModeForChild(row, adjusted_location);
if (row->NodeAtPoint(result, location_in_container, child_point,
action)) {
UpdateHitTestResult(
result,
ToLayoutPoint(location_in_container.Point() - child_point));
return true;
}
}
}
return false;
}
RecalcCellsIfNeeded();
LayoutRect hit_test_rect = LayoutRect(location_in_container.BoundingBox());
hit_test_rect.MoveBy(-adjusted_location);
LayoutRect table_aligned_rect =
LogicalRectForWritingModeAndDirection(hit_test_rect);
CellSpan row_span = SpannedRows(table_aligned_rect);
CellSpan column_span = SpannedEffectiveColumns(table_aligned_rect);
// Now iterate over the spanned rows and columns.
for (unsigned hit_row = row_span.Start(); hit_row < row_span.End();
++hit_row) {
unsigned n_cols = NumCols(hit_row);
for (unsigned hit_column = column_span.Start();
hit_column < n_cols && hit_column < column_span.End(); ++hit_column) {
auto& grid_cell = GridCellAt(hit_row, hit_column);
// If the cell is empty, there's nothing to do
if (!grid_cell.HasCells())
continue;
for (unsigned i = grid_cell.Cells().size(); i;) {
--i;
LayoutTableCell* cell = grid_cell.Cells()[i];
LayoutPoint cell_point =
FlipForWritingModeForChild(cell, adjusted_location);
if (static_cast<LayoutObject*>(cell)->NodeAtPoint(
result, location_in_container, cell_point, action)) {
UpdateHitTestResult(
result, location_in_container.Point() - ToLayoutSize(cell_point));
return true;
}
}
if (!result.GetHitTestRequest().ListBased())
break;
}
if (!result.GetHitTestRequest().ListBased())
break;
}
return false;
}
LayoutTableSection* LayoutTableSection::CreateAnonymousWithParent(
const LayoutObject* parent) {
scoped_refptr<ComputedStyle> new_style =
ComputedStyle::CreateAnonymousStyleWithDisplay(parent->StyleRef(),
EDisplay::kTableRowGroup);
LayoutTableSection* new_section = new LayoutTableSection(nullptr);
new_section->SetDocumentForAnonymous(&parent->GetDocument());
new_section->SetStyle(std::move(new_style));
return new_section;
}
void LayoutTableSection::SetLogicalPositionForCell(
LayoutTableCell* cell,
unsigned effective_column) const {
LayoutPoint cell_location(0, row_pos_[cell->RowIndex()]);
int16_t horizontal_border_spacing = Table()->HBorderSpacing();
if (!TableStyle().IsLeftToRightDirection()) {
cell_location.SetX(LayoutUnit(
Table()->EffectiveColumnPositions()[Table()->NumEffectiveColumns()] -
Table()->EffectiveColumnPositions()
[Table()->AbsoluteColumnToEffectiveColumn(
cell->AbsoluteColumnIndex() + cell->ColSpan())] +
horizontal_border_spacing));
} else {
cell_location.SetX(
LayoutUnit(Table()->EffectiveColumnPositions()[effective_column] +
horizontal_border_spacing));
}
cell->SetLogicalLocation(cell_location);
}
void LayoutTableSection::RelayoutCellIfFlexed(LayoutTableCell& cell,
int row_index,
int row_height) {
// Force percent height children to lay themselves out again.
// This will cause these children to grow to fill the cell.
// FIXME: There is still more work to do here to fully match WinIE (should
// it become necessary to do so). In quirks mode, WinIE behaves like we
// do, but it will clip the cells that spill out of the table section.
// strict mode, Mozilla and WinIE both regrow the table to accommodate the
// new height of the cell (thus letting the percentages cause growth one
// time only). We may also not be handling row-spanning cells correctly.
//
// Note also the oddity where replaced elements always flex, and yet blocks/
// tables do not necessarily flex. WinIE is crazy and inconsistent, and we
// can't hope to match the behavior perfectly, but we'll continue to refine it
// as we discover new bugs. :)
bool cell_children_flex = false;
bool flex_all_children = CellHasExplicitlySpecifiedHeight(cell) ||
(!Table()->StyleRef().LogicalHeight().IsAuto() &&
row_height != cell.LogicalHeight());
for (LayoutObject* child = cell.FirstChild(); child;
child = child->NextSibling()) {
if (!child->IsText() &&
child->StyleRef().LogicalHeight().IsPercentOrCalc() &&
(flex_all_children || ShouldFlexCellChild(cell, child)) &&
(!child->IsTable() || ToLayoutTable(child)->HasSections())) {
cell_children_flex = true;
break;
}
}
if (!cell_children_flex) {
if (TrackedLayoutBoxListHashSet* percent_height_descendants =
cell.PercentHeightDescendants()) {
for (auto* descendant : *percent_height_descendants) {
if (flex_all_children || ShouldFlexCellChild(cell, descendant)) {
cell_children_flex = true;
break;
}
}
}
}
if (!cell_children_flex)
return;
// Alignment within a cell is based off the calculated height, which becomes
// irrelevant once the cell has been resized based off its percentage.
cell.SetOverrideLogicalHeightFromRowHeight(LayoutUnit(row_height));
cell.ForceLayout();
// If the baseline moved, we may have to update the data for our row. Find
// out the new baseline.
if (cell.IsBaselineAligned()) {
LayoutUnit baseline = cell.CellBaselinePosition();
if (baseline > cell.BorderBefore() + cell.PaddingBefore())
grid_[row_index].baseline = std::max(grid_[row_index].baseline, baseline);
}
}
int LayoutTableSection::LogicalHeightForRow(
const LayoutTableRow& row_object) const {
unsigned row_index = row_object.RowIndex();
DCHECK_LT(row_index, grid_.size());
int logical_height = 0;
for (auto& grid_cell : grid_[row_index].grid_cells) {
const LayoutTableCell* cell = grid_cell.PrimaryCell();
if (!cell || grid_cell.InColSpan())
continue;
unsigned row_span = cell->ResolvedRowSpan();
if (row_span == 1) {
logical_height =
std::max(logical_height, cell->LogicalHeightForRowSizing());
continue;
}
unsigned row_index_for_cell = cell->RowIndex();
if (row_index == grid_.size() - 1 ||
(row_span > 1 && row_index - row_index_for_cell == row_span - 1)) {
// This is the last row of the rowspanned cell. Add extra height if
// needed.
if (LayoutTableRow* first_row_for_cell = grid_[row_index_for_cell].row) {
int min_logical_height = cell->LogicalHeightForRowSizing();
// Subtract space provided by previous rows.
min_logical_height -= row_object.LogicalTop().ToInt() -
first_row_for_cell->LogicalTop().ToInt();
logical_height = std::max(logical_height, min_logical_height);
}
}
}
if (grid_[row_index].logical_height.IsSpecified()) {
LayoutUnit specified_logical_height =
MinimumValueForLength(grid_[row_index].logical_height, LayoutUnit());
// We round here to match computations for row_pos_ in
// CalcRowLogicalHeight().
logical_height = std::max(logical_height, specified_logical_height.Round());
}
return logical_height;
}
int LayoutTableSection::OffsetForRepeatedHeader() const {
LayoutTableSection* header = Table()->Header();
if (header && header != this)
return Table()->RowOffsetFromRepeatingHeader().ToInt();
LayoutState* layout_state = View()->GetLayoutState();
return layout_state->HeightOffsetForTableHeaders().ToInt();
}
void LayoutTableSection::AdjustRowForPagination(LayoutTableRow& row_object,
SubtreeLayoutScope& layouter) {
row_object.SetPaginationStrut(LayoutUnit());
row_object.SetLogicalHeight(LayoutUnit(LogicalHeightForRow(row_object)));
if (!IsPageLogicalHeightKnown())
return;
int pagination_strut =
PaginationStrutForRow(&row_object, row_object.LogicalTop());
bool row_is_at_top_of_column = false;
LayoutUnit offset_from_top_of_page;
if (!pagination_strut) {
LayoutUnit page_logical_height =
PageLogicalHeightForOffset(row_object.LogicalTop());
if (OffsetForRepeatedHeader()) {
offset_from_top_of_page =
page_logical_height -
PageRemainingLogicalHeightForOffset(row_object.LogicalTop(),
kAssociateWithLatterPage);
row_is_at_top_of_column =
!offset_from_top_of_page ||
offset_from_top_of_page <= OffsetForRepeatedHeader() ||
offset_from_top_of_page <= Table()->VBorderSpacing();
}
if (!row_is_at_top_of_column)
return;
}
// We need to push this row to the next fragmentainer. If there are repeated
// table headers, we need to make room for those at the top of the next
// fragmentainer, above this row. Otherwise, this row will just go at the top
// of the next fragmentainer.
// Border spacing from the previous row has pushed this row just past the top
// of the page, so we must reposition it to the top of the page and avoid any
// repeating header.
if (row_is_at_top_of_column && offset_from_top_of_page)
pagination_strut -= offset_from_top_of_page.ToInt();
// If we have a header group we will paint it at the top of each page,
// move the rows down to accommodate it.
int additional_adjustment = OffsetForRepeatedHeader();
// If the table collapses borders, push the row down by the max height of the
// outer half borders to make the whole collapsed borders on the next page.
if (Table()->ShouldCollapseBorders()) {
for (const auto* cell = row_object.FirstCell(); cell;
cell = cell->NextCell()) {
additional_adjustment = std::max<int>(additional_adjustment,
cell->CollapsedOuterBorderBefore());
}
}
pagination_strut += additional_adjustment;
row_object.SetPaginationStrut(LayoutUnit(pagination_strut));
// We have inserted a pagination strut before the row. Adjust the logical top
// and re-lay out. We no longer want to break inside the row, but rather
// *before* it. From the previous layout pass, there are most likely
// pagination struts inside some cell in this row that we need to get rid of.
row_object.SetLogicalTop(row_object.LogicalTop() + pagination_strut);
layouter.SetChildNeedsLayout(&row_object);
row_object.LayoutIfNeeded();
// It's very likely that re-laying out (and nuking pagination struts inside
// cells) gave us a new height.
row_object.SetLogicalHeight(LayoutUnit(LogicalHeightForRow(row_object)));
}
bool LayoutTableSection::GroupShouldRepeat() const {
DCHECK(Table()->Header() == this || Table()->Footer() == this);
if (GetPaginationBreakability() == kAllowAnyBreaks)
return false;
// If we don't know the page height yet, just assume we fit.
if (!IsPageLogicalHeightKnown())
return true;
LayoutUnit page_height = PageLogicalHeightForOffset(LayoutUnit());
LayoutUnit logical_height = LogicalHeight() - OffsetForRepeatedHeader();
if (logical_height > page_height)
return false;
// See https://drafts.csswg.org/css-tables-3/#repeated-headers which says
// a header/footer can repeat if it takes up less than a quarter of the page.
if (logical_height > 0 && page_height / logical_height < 4)
return false;
return true;
}
bool LayoutTableSection::MapToVisualRectInAncestorSpaceInternal(
const LayoutBoxModelObject* ancestor,
TransformState& transform_state,
VisualRectFlags flags) const {
if (ancestor == this)
return true;
// Repeating table headers and footers are painted once per
// page/column. So we need to use the rect for the entire table because
// the repeating headers/footers will appear throughout it.
// This does not go through the regular fragmentation machinery, so we need
// special code to expand the invalidation rect to contain all positions of
// the header in all columns.
// Note that this is in flow thread coordinates, not visual coordinates. The
// enclosing LayoutFlowThread will convert to visual coordinates.
if (IsRepeatingHeaderGroup() || IsRepeatingFooterGroup()) {
transform_state.Flatten();
FloatRect rect = transform_state.LastPlanarQuad().BoundingBox();
rect.SetHeight(Table()->LogicalHeight());
transform_state.SetQuad(FloatQuad(rect));
return Table()->MapToVisualRectInAncestorSpaceInternal(
ancestor, transform_state, flags);
}
return LayoutTableBoxComponent::MapToVisualRectInAncestorSpaceInternal(
ancestor, transform_state, flags);
}
bool LayoutTableSection::PaintedOutputOfObjectHasNoEffectRegardlessOfSize()
const {
// LayoutTableSection paints background from columns.
if (Table()->HasColElements())
return false;
return LayoutTableBoxComponent::
PaintedOutputOfObjectHasNoEffectRegardlessOfSize();
}
} // namespace blink
| [
"sunny.nam@samsung.com"
] | sunny.nam@samsung.com |
bec1fb1042fee051591c0bced71d46fdec45c34f | 7738dc7b139b6841c885c7bd1c199e523507ad11 | /src/ChiJPsiGFinder.cpp | d16020f30b4a3c2064669427782c7d30a5e1bd9d | [] | no_license | magania/b_finder | 8343b44888f70736432dafefa1d8bbaca8a8dc95 | 9f6155530a37009da417de79a2b2ce11d6435a14 | refs/heads/master | 2020-05-19T04:42:40.734515 | 2012-08-24T00:24:39 | 2012-08-24T00:24:39 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,831 | cpp | /*
* ChiJPsiGFinder.cpp
*
* Created on: Aug 31, 2009
* Author: magania
*/
#include "ChiJPsiGFinder.h"
ChiJPsiGFinder::ChiJPsiGFinder(TTree &tree, JPsiFinder& jpsi_finder, GammaFinder& gamma_finder) :
chi_saver("chi",tree, false, false),
vrt_saver("chi_vrt",tree)
{
_jpsi_finder = &jpsi_finder;
_gamma_finder = &gamma_finder;
index = -1;
tree.Branch("chi_index", &index, "chi_index/D");
tree.Branch("chi_mass", &masa, "chi_mass/D");
}
ChiJPsiGFinder::~ChiJPsiGFinder() {
}
void ChiJPsiGFinder::clean(){
chi.clear();
vtx.clear();
jpsi.clear();
gamma.clear();
mass.clear();
_boxp.clear();
_boxv.clear();
}
int ChiJPsiGFinder::find(){
clean();
_jpsi_finder->begin();
_gamma_finder->begin();
while (_jpsi_finder->next())
while (_gamma_finder->next()){
Ptl *jpsi_ptl = &_jpsi_finder->getJPsi();
Ptl *mu_plus_ptl = &_jpsi_finder->getMuPlus();
Ptl *mu_minus_ptl = &_jpsi_finder->getMuMinus();
Ptl *gamma_ptl = &_gamma_finder->getGamma();
Ptl *e_plus_ptl = &_gamma_finder->getEPlus();
Ptl *e_minus_ptl = &_gamma_finder->getEMinus();
if(mu_plus_ptl == e_plus_ptl || mu_minus_ptl == e_minus_ptl)
continue;
/* -- chi vertex -- */
TrkLst track_list;
track_list.push_back(mu_plus_ptl);
track_list.push_back(mu_minus_ptl);
track_list.push_back(gamma_ptl);
Vrt *chi_vrt = _boxv.newVrt();
if (!chi_vrt->fill(_jpsi_finder->getJPsi().decayVertex()->x(), &track_list))
continue;
if (!chi_vrt->filter())
continue;
if (chi_vrt->size() != 3)
continue;
/* -- Construct new particle (Chi) from these 4 tracks -- */
Ptl* chi_ptl = _boxp.newPtl();
if (!chi_ptl->combine(chi_vrt, 0))
continue;
/* -- mass of Chi and uncertainty --*/
vector<PType> types(3);
types[0] = AA::MU_PLUS;
types[1] = AA::MU_MINUS;
types[2] = AA::GAMMA_STAR;
double mchi, vmchi, emchi;
chi_ptl->mass(types, mchi, vmchi);
emchi = sqrt(fabs(vmchi));
/* -- cut on B mass -- */
if ( mchi < MASS_CHI_MIN || MASS_CHI_MAX < mchi)
continue;
chi.push_back(chi_ptl);
vtx.push_back(chi_vrt);
mass.push_back(mchi);
jpsi.push_back(_jpsi_finder->getIndex());
gamma.push_back(_gamma_finder->getIndex());
}
return chi.size();
}
void ChiJPsiGFinder::begin(){
index = -1;
}
bool ChiJPsiGFinder::next(){
if (++index < chi.size())
return true;
else
index=-1;
return false;
}
int ChiJPsiGFinder::getIndex(){
return index;
}
void ChiJPsiGFinder::setIndex(int i){
if ( i > chi.size() || i < 0){
std::cout << "ChiJPsiGFinder: Error seting index " << i << " max: " << chi.size() << std::endl;
exit(EXIT_FAILURE);
} else {
index = i;
}
}
AA::Ptl& ChiJPsiGFinder::getJPsi(){
_jpsi_finder->setIndex(jpsi[index]);
return _jpsi_finder->getJPsi();
}
AA::Ptl& ChiJPsiGFinder::getMuPlus(){
_jpsi_finder->setIndex(jpsi[index]);
return _jpsi_finder->getMuPlus();
}
AA::Ptl& ChiJPsiGFinder::getMuMinus(){
_jpsi_finder->setIndex(jpsi[index]);
return _jpsi_finder->getMuMinus();
}
AA::Ptl& ChiJPsiGFinder::getGamma(){
_gamma_finder->setIndex(gamma[index]);
return _gamma_finder->getGamma();
}
AA::Ptl& ChiJPsiGFinder::getEPlus(){
_gamma_finder->setIndex(gamma[index]);
return _gamma_finder->getEPlus();
}
AA::Ptl& ChiJPsiGFinder::getEMinus(){
_gamma_finder->setIndex(gamma[index]);
return _gamma_finder->getEMinus();
}
AA::Ptl& ChiJPsiGFinder::getChi(){
return *chi[index];
}
AA::Vrt& ChiJPsiGFinder::getVrt(){
return *vtx[index];
}
double ChiJPsiGFinder::getMass(){
return mass[index];
}
void ChiJPsiGFinder::fill(){
_jpsi_finder->setIndex(jpsi[index]);
_gamma_finder->setIndex(gamma[index]);
_jpsi_finder->fill();
_gamma_finder->fill();
chi_saver.fill(getChi());
vrt_saver.fill(getVrt());
masa = getMass();
}
| [
"magania@gmail.com"
] | magania@gmail.com |
a3a0f0da08a6abc7efdc41afe5c62d67a5c60a3a | ee59f750afa7b7b3f2724c07c8d50cd2e3985a89 | /Assignment3/Source/vr02_lag_cpp/Cube.h | 193170b48e5608dd9a3707f84d3b734368abe411 | [] | no_license | bigfabbro/VirtualReality | cd81f2679ad34d72df8517998b57eff872eafd15 | 28adbd0401972250990021fb732d50526312c744 | refs/heads/master | 2020-08-29T12:54:10.032564 | 2019-12-12T14:20:25 | 2019-12-12T14:20:25 | 218,037,232 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 816 | h | // Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "GameFramework/Actor.h"
#include "Cube.generated.h"
UCLASS()
class VR02_LAG_CPP_API ACube : public AActor
{
GENERATED_BODY()
public:
// Sets default values for this actor's properties
ACube();
UPROPERTY(EditAnywhere, BlueprintReadWrite, category= "Movement")
float rangeMin;
UPROPERTY(EditAnywhere, BlueprintReadWrite, category = "Movement")
float rangeMax;
UPROPERTY(EditAnywhere, BlueprintReadWrite, category = "Movement")
float speed;
bool direction;
UStaticMeshComponent* StaticMesh;
protected:
// Called when the game starts or when spawned
virtual void BeginPlay() override;
public:
// Called every frame
virtual void Tick(float DeltaTime) override;
};
| [
"bigfabbro93@gmail.com"
] | bigfabbro93@gmail.com |
1d4d2545f4e9d8750f178fea2bbe0764f3160d11 | e5614c36fd324f2e214ff05aaf2bf7230443e0b5 | /LightOJ/1375 - LCM Extreme.cpp | 4ff19ce18357a88692e1164d5bbac9fd57696ceb | [] | no_license | njrafi/Competitive-Programming-Solutions | a9cd3ceae430e6b672c02076f80ecb94065ff6d8 | 86d167c355813157b0a0a8382b6f8538f29d4599 | refs/heads/master | 2020-07-30T22:18:46.473308 | 2019-10-06T18:12:36 | 2019-10-06T18:12:36 | 210,377,979 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,387 | cpp | #include <bits/stdc++.h>
#ifndef ONLINE_JUDGE
#define gc getchar
#define pc putchar
#else
#define gc getchar_unlocked
#define pc putchar_unlocked
#endif
using namespace std;
#define vi vector<int>
#define si set<int>
#define vs vector<string>
#define pii pair<int, int>
#define vpi vector<pii>
#define pri priority_queue<int>
#define rev_pri priority_queue<int, vector<int>, greater<int>>
#define mpi map<int, int>
#define i64 unsigned long long int
#define endl '\n'
#define pi acos(-1)
#define all(v) v.begin(), v.end()
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define inf INT_MAX / 2
#define infll LLONG_MAX / 3
#define For(i, n) for (int i = 0; i < n; i++)
#define Fre(i, a, b) for (int i = a; i < b; i++)
#define sf(n) scanf("%d", &n)
#define sff(a, b) scanf("%d %d", &a, &b)
#define sfff(a, b, c) scanf("%d %d %d", &a, &b, &c)
#define pfn(n) printf("%d\n", n)
#define pfs(n) printf("%d ", n)
#define eps 1e-8
#define ff first
#define ss second
#define mem(a, b) memset(a, b, sizeof(a))
#define READ freopen("in.txt", "r", stdin)
#define WRITE freopen("out.txt", "w", stdout)
#define sz size()
#define dbg(i) printf("yo %d\n", i)
#define foreach(i, c) for (__typeof((c).begin()) i = (c).begin(); i != (c).end(); i++)
#define sqr(a) (a) * (a)
#define clr clear()
#define CASE(a) printf("Case %d: ", a)
//int dx[] = {0,1,0,-1,1,1,-1,-1};
//int dy[] = {1,0,-1,0,1,-1,-1,1};
//i64 gcd(i64 a,i64 b){if(!b)return a;return gcd(b,a%b);}
inline void fastRead(int *a)
{
register char c = 0;
while (c < 33)
c = gc();
*a = 0;
while (c > 33)
{
*a = *a * 10 + c - '0';
c = gc();
}
}
inline void fastWrite(i64 a)
{
char snum[20];
int i = 0;
do
{
snum[i++] = a % 10 + 48;
a = a / 10;
} while (a != 0);
i = i - 1;
while (i >= 0)
pc(snum[i--]);
pc('\n');
}
//i64 bigmod(i64 num,i64 n){if(n==0)return 1;i64 x=bigmod(num,n/2);x=x*x%mod;if(n%2==1)x=x*num%mod;return x;}
//i64 modinverse(i64 num){return bigmod(num,mod-2)%mod;}
//i64 po(i64 a,i64 b){i64 ans=1;while(b--)ans *= a;return ans;}
//i64 ncr(i64 n,i64 r){if(n==r)return 1;if(r==1)return n;if(dp[n][r]!=-1)return dp[n][r];return dp[n][r]=ncr(n-1,r)+ncr(n-1,r-1);}
// bit manipulations
//bool checkbit(int mask,int bit){return mask & (1<<bit);}
//int setbit(int mask,int bit){ return mask (1<<bit) ; }
//int clearbit(int mask,int bit){return mask & ~(1<<bit);}
//int togglebit(int mask,int bit){return mask ^ (1<<bit);}
#define mxn 3000006
i64 res[mxn];
i64 phi[mxn];
//i64 cum[mxn];
bool ispr[mxn];
void sieve()
{
int gg = 0;
for (int i = 1; i < mxn; i++)
for (int j = i; j < mxn; j += i)
res[j] += phi[i] * i;
res[0] = 0;
Fre(i, 1, mxn)
{
res[i]++;
res[i] /= 2;
res[i] *= (i64)i;
// cout << i << " " << res[i] << " ";
res[i] += res[i - 1] - i;
// cout << res[i] << endl;
}
}
void sievephi()
{
For(i, mxn)
phi[i] = (i64)i;
Fre(i, 2, mxn) if (!ispr[i]) for (int j = i; j < mxn; j += i)
{
ispr[j] = 1;
phi[j] = (phi[j] / i) * (i - 1);
}
}
int main()
{
sievephi();
sieve();
// assert(1==2);
int t, n, cs = 1;
sf(t);
while (t--)
{
fastRead(&n);
CASE(cs++);
fastWrite(res[n]);
}
return 0;
}
| [
"njrafibd@gmail.com"
] | njrafibd@gmail.com |
016ca6090929f3c981e4f1e34d9c17a35a94487f | 054b91080c719c55d0d65ff33c4f92857a3fdfc8 | /introduction_to_C++_programming/day7/zipcode/distance.cpp | 7b996fe34af79db43a7bd146e6b5057e3f99c1f8 | [] | no_license | researcherben/course-notes | 14f7e893b0e7c1001e318d540f6bca77565a65fe | 47475bde72978e34bd26cd80f402d07c4283f22a | refs/heads/master | 2021-01-20T15:44:37.829360 | 2016-08-05T14:27:40 | 2016-08-05T14:27:40 | 60,696,470 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 771 | cpp | #include <cmath>
#define PI 3.14159265
#define RADIUS_OF_EARTH 3963.1 // radius of earth in miles
inline double toRadians (double degrees) {
return degrees * PI / 180.0;
}
// Compute distance in miles between two points on Earth, with
// coordinates specified in degrees.
// Note: West longitudes and South latitudes have negative values
double globeDistance (double lat1, double long1, double lat2, double long2) {
double a1 = toRadians(lat1);
double b1 = toRadians(long1);
double a2 = toRadians(lat2);
double b2 = toRadians(long2);
return acos( cos(a1) * cos(b1) * cos(a2) * cos(b2) +
cos(a1)* sin(b1)* cos(a2)* sin(b2) +
sin(a1) * sin(a2) ) * RADIUS_OF_EARTH;
} | [
"ben.is.located@gmail.com"
] | ben.is.located@gmail.com |
211a5f2e5df4cb9e90471f1ff43b1338a7bd12d3 | 883a861de477922a4559974e759b399770735229 | /src/exe/dummy_to_json.cpp | 5328d7f40c801d3b746a42bc8a74e05de9df82a0 | [
"MIT"
] | permissive | JasonThomasData/neural_net_cpp | 302b17b103d0fcc39ed3cb11cf78e00a7d522d71 | 0d6d042ea00fa778befa488f2e38c914d5f26cdf | refs/heads/master | 2022-05-01T20:32:50.239735 | 2022-03-26T11:16:06 | 2022-03-26T11:16:06 | 86,955,627 | 1 | 1 | null | 2017-08-02T07:52:43 | 2017-04-02T01:52:56 | C++ | UTF-8 | C++ | false | false | 1,166 | cpp | #include <fstream>
#include <iostream>
#include <string>
#include "../../lib/json.hpp"
#include "../data_converter/data_converter.h"
#include "../json_io/json_io.h"
int main(int argc, char** argv)
{
if(argc != 4 || (std::string(argv[3]) != "training" && std::string(argv[3]) != "new_data"))
{
std::cout<< "Parse two file locations to convert and the type of document (training/new_data), like ./convert_data path/to/in path/to/out training"<< std::endl;
std::exit(1);
}
else
{
std::string in_path = std::string(argv[1]);
std::string out_path = std::string(argv[2]);
std::string document_type = std::string(argv[3]);
std::ifstream original_data = DataConverter::read_file(in_path);
nlohmann::json out_data;
if (document_type == "training")
{
out_data = DataConverter::convert_training_data_to_json(original_data);
}
else
{
out_data = DataConverter::convert_new_data_to_json(original_data);
}
JsonIO::save_json_data(out_path, out_data);
std::cout<< "Data saved at "<< out_path<< std::endl;
}
}
| [
"john@john.john"
] | john@john.john |
6b31965565508756316066f07061eb575909827e | ece30e7058d8bd42bc13c54560228bd7add50358 | /DataCollector/mozilla/xulrunner-sdk/include/mozilla/dom/mobilemessage/Types.h | e629a500fc02552d3c96f7d2a27fb13861011cd2 | [
"Apache-2.0"
] | permissive | andrasigneczi/TravelOptimizer | b0fe4d53f6494d40ba4e8b98cc293cb5451542ee | b08805f97f0823fd28975a36db67193386aceb22 | refs/heads/master | 2022-07-22T02:07:32.619451 | 2018-12-03T13:58:21 | 2018-12-03T13:58:21 | 53,926,539 | 1 | 0 | Apache-2.0 | 2022-07-06T20:05:38 | 2016-03-15T08:16:59 | C++ | UTF-8 | C++ | false | false | 3,714 | h | /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef mozilla_dom_mobilemessage_Types_h
#define mozilla_dom_mobilemessage_Types_h
#include "IPCMessageUtils.h"
namespace mozilla {
namespace dom {
namespace mobilemessage {
// For MmsMessageData.state and SmsMessageData.deliveryState
// Please keep the following files in sync with enum below:
// mobile/android/base/GeckoSmsManager.java
enum DeliveryState {
eDeliveryState_Sent = 0,
eDeliveryState_Received,
eDeliveryState_Sending,
eDeliveryState_Error,
eDeliveryState_Unknown,
eDeliveryState_NotDownloaded,
// This state should stay at the end.
eDeliveryState_EndGuard
};
// For {Mms,Sms}MessageData.deliveryStatus.
enum DeliveryStatus {
eDeliveryStatus_NotApplicable = 0,
eDeliveryStatus_Success,
eDeliveryStatus_Pending,
eDeliveryStatus_Error,
eDeliveryStatus_Reject,
eDeliveryStatus_Manual,
// This state should stay at the end.
eDeliveryStatus_EndGuard
};
// For MmsMessageData.readStatus.
enum ReadStatus {
eReadStatus_NotApplicable = 0,
eReadStatus_Success,
eReadStatus_Pending,
eReadStatus_Error,
// This state should stay at the end.
eReadStatus_EndGuard
};
// For {Mms,Sms}MessageData.messageClass.
enum MessageClass {
eMessageClass_Normal = 0,
eMessageClass_Class0,
eMessageClass_Class1,
eMessageClass_Class2,
eMessageClass_Class3,
// This state should stay at the end.
eMessageClass_EndGuard
};
// For ThreadData.
enum MessageType {
eMessageType_SMS = 0,
eMessageType_MMS,
// This state should stay at the end.
eMessageType_EndGuard
};
} // namespace mobilemessage
} // namespace dom
} // namespace mozilla
namespace IPC {
/**
* Delivery state serializer.
*/
template <>
struct ParamTraits<mozilla::dom::mobilemessage::DeliveryState>
: public ContiguousEnumSerializer<
mozilla::dom::mobilemessage::DeliveryState,
mozilla::dom::mobilemessage::eDeliveryState_Sent,
mozilla::dom::mobilemessage::eDeliveryState_EndGuard>
{};
/**
* Delivery status serializer.
*/
template <>
struct ParamTraits<mozilla::dom::mobilemessage::DeliveryStatus>
: public ContiguousEnumSerializer<
mozilla::dom::mobilemessage::DeliveryStatus,
mozilla::dom::mobilemessage::eDeliveryStatus_NotApplicable,
mozilla::dom::mobilemessage::eDeliveryStatus_EndGuard>
{};
/**
* Read status serializer.
*/
template <>
struct ParamTraits<mozilla::dom::mobilemessage::ReadStatus>
: public ContiguousEnumSerializer<
mozilla::dom::mobilemessage::ReadStatus,
mozilla::dom::mobilemessage::eReadStatus_NotApplicable,
mozilla::dom::mobilemessage::eReadStatus_EndGuard>
{};
/**
* Message class serializer.
*/
template <>
struct ParamTraits<mozilla::dom::mobilemessage::MessageClass>
: public ContiguousEnumSerializer<
mozilla::dom::mobilemessage::MessageClass,
mozilla::dom::mobilemessage::eMessageClass_Normal,
mozilla::dom::mobilemessage::eMessageClass_EndGuard>
{};
/**
* MessageType class serializer.
*/
template <>
struct ParamTraits<mozilla::dom::mobilemessage::MessageType>
: public ContiguousEnumSerializer<
mozilla::dom::mobilemessage::MessageType,
mozilla::dom::mobilemessage::eMessageType_SMS,
mozilla::dom::mobilemessage::eMessageType_EndGuard>
{};
} // namespace IPC
#endif // mozilla_dom_mobilemessage_Types_h
| [
"andras.igneczi@doclerholding.com"
] | andras.igneczi@doclerholding.com |
11368118d7e88ad39f99e384e13aeb3e29f04315 | 2a7e77565c33e6b5d92ce6702b4a5fd96f80d7d0 | /fuzzedpackages/anomaly/src/find_best_option.cpp | 06238ddaa5b82bc2d6ea27de52c4b4c4d365067d | [] | no_license | akhikolla/testpackages | 62ccaeed866e2194652b65e7360987b3b20df7e7 | 01259c3543febc89955ea5b79f3a08d3afe57e95 | refs/heads/master | 2023-02-18T03:50:28.288006 | 2021-01-18T13:23:32 | 2021-01-18T13:23:32 | 329,981,898 | 7 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 1,618 | cpp | #include <math.h>
#include <stdlib.h>
#include <float.h>
#include "Functions.h"
namespace anomalymv
{
void find_best_option(struct orderedobservationlist *list, int ii, int n, int p, int l, int minseglength, double *penaltycomponent, double penaltyanomaly, struct position_saving *savingvector)
{
int jj = 0, option = 0, bestcut = 0;
struct orderedobservationlist *current = NULL;
double cost_pt_anom, cost_coll_anom, mincost, extra, obs;
mincost = list[ii].optimalcostofprevious;
current = list[0].next;
while ((current->numberofobservation) < (ii - minseglength + 2) )
{
cost_coll_anom = current->costofstartingsegment;
if (cost_coll_anom < mincost)
{
mincost = cost_coll_anom;
option = 2;
bestcut = current->numberofobservation - 1;
}
current = current->next;
}
cost_pt_anom = list[ii].optimalcostofprevious;
for (jj = 0; jj < p; jj++)
{
obs = list[ii].observationsquared[jj];
if (obs <= DBL_MIN)
{
obs = DBL_MIN;
}
extra = penaltyanomaly + log(obs) + 1 - obs;
if (extra < 0)
{
cost_pt_anom = cost_pt_anom + extra;
}
}
if (cost_pt_anom < mincost)
{
mincost = cost_pt_anom;
option = 1;
}
list[ii].option = option;
list[ii].optimalcost = mincost;
list[ii+1].optimalcostofprevious = mincost;
list[ii].optimalcut = &(list[ii-1]);
if (option == 2)
{
list[ii].optimalcut = &(list[bestcut]);
collective_anom_parameters(list,ii,p,l,minseglength,penaltycomponent,savingvector);
}
if (option == 1)
{
point_anom_parameters(list,ii,p,penaltyanomaly);
}
}
} // namespace anomalymv
| [
"akhilakollasrinu424jf@gmail.com"
] | akhilakollasrinu424jf@gmail.com |
ea14680135c7479d480b2ffd60a87513f453a985 | db938fd7dc8178601adb5b73191ce128d8f4d25d | /helpers/md5/src/md5.hpp | a9bdc7b3523972252d4d15ee983d08eacf973ecb | [
"MIT"
] | permissive | joeferg425/RECTFDEMOS | 8ecfdc39cbab841210e880927aa09ddeee99e7f1 | 0d8ff9f6e17d7d201719dc129a866ee2d0af8915 | refs/heads/main | 2023-08-12T10:36:47.614332 | 2021-10-13T01:12:20 | 2021-10-13T01:12:20 | 372,689,952 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 5,542 | hpp | // originally from https://gist.github.com/creationix/4710780
#ifndef __MD5__
#define __MD5__
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
// #define ROUNDS 1
// leftrotate function definition
#define LEFTROTATE(x, c) (((x) << (c)) | ((x) >> (32 - (c))))
// These vars will contain the hash
void md5(uint8_t *initial_msg, size_t initial_len, uint8_t *hash)
{
// Message (to prepare)
uint8_t *msg = NULL;
// Note: All variables are unsigned 32 bit and wrap modulo 2^32 when calculating
// r specifies the per-round shift amounts
uint32_t r[] =
{
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
};
// Use binary integer part of the sines of integers (in radians) as constants// Initialize variables:
uint32_t k[] =
{
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
};
*(uint32_t*)&hash[ 0] = 0x67452301;
*(uint32_t*)&hash[ 4] = 0xefcdab89;
*(uint32_t*)&hash[ 8] = 0x98badcfe;
*(uint32_t*)&hash[12] = 0x10325476;
// Pre-processing: adding a single 1 bit
//append "1" bit to message
/* Notice: the input bytes are considered as bits strings,
where the first bit is the most significant bit of the byte.[37] */
// Pre-processing: padding with zeros
//append "0" bit until message length in bit ≡ 448 (mod 512)
//append length mod (2 pow 64) to message
int new_len = (((((initial_len + 8) / 64) + 1) * 64) - 8);
// also appends "0" bits
// (we alloc also 64 extra bytes...)
msg = (uint8_t*)calloc((new_len + 64), 1);
memcpy(msg, initial_msg, initial_len);
// write the "1" bit
msg[initial_len] = 128;
// note, we append the len
uint32_t bits_len = (8 * initial_len);
// in bits at the end of the buffer
memcpy(msg + new_len, &bits_len, 4);
// Process the message in successive 512-bit chunks:
//for each 512-bit chunk of message:
int offset;
for(offset = 0; offset < new_len; offset += (512 / 8))
{
// break chunk into sixteen 32-bit words w[j], 0 ≤ j ≤ 15
uint32_t *w = (uint32_t *) (msg + offset);
#ifdef DEBUG
printf("offset: %d %x\n", offset, offset);
int j;
for(j =0; j < 64; j++) printf("%x ", ((uint8_t *) w)[j]);
puts("");
#endif
// Initialize hash value for this chunk:
uint32_t a = *(uint32_t*)&hash[ 0];
uint32_t b = *(uint32_t*)&hash[ 4];
uint32_t c = *(uint32_t*)&hash[ 8];
uint32_t d = *(uint32_t*)&hash[12];
// Main loop:
uint32_t i;
for(i = 0; i < 64; i++)
{
#ifdef ROUNDS
uint8_t *p;
printf("%i: ", i);
p=(uint8_t *)&a;
printf("%2.2X%2.2X%2.2X%2.2X ", p[0], p[1], p[2], p[3], a);
p=(uint8_t *)&b;
printf("%2.2X%2.2X%2.2X%2.2X ", p[0], p[1], p[2], p[3], b);
p=(uint8_t *)&c;
printf("%2.2X%2.2X%2.2X%2.2X ", p[0], p[1], p[2], p[3], c);
p=(uint8_t *)&d;
printf("%2.2X%2.2X%2.2X%2.2X", p[0], p[1], p[2], p[3], d);
puts("");
#endif
uint32_t f, g;
if (i < 16)
{
f = (b & c) | ((~b) & d);
g = i;
}
else if (i < 32)
{
f = (d & b) | ((~d) & c);
g = (5*i + 1) % 16;
}
else if (i < 48)
{
f = b ^ c ^ d;
g = (3*i + 5) % 16;
}
else
{
f = c ^ (b | (~d));
g = (7*i) % 16;
}
#ifdef ROUNDS
printf("f=%x g=%d w[g]=%x\n", f, g, w[g]);
#endif
uint32_t temp = d;
d = c;
c = b;
#ifdef DEBUG
printf("rotateLeft(%x + %x + %x + %x, %d)\n", a, f, k[i], w[g], r[i]);
#endif
b = b + LEFTROTATE((a + f + k[i] + w[g]), r[i]);
a = temp;
}
// Add this chunk's hash to result so far:
*(uint32_t*)&hash[ 0] += a;
*(uint32_t*)&hash[ 4] += b;
*(uint32_t*)&hash[ 8] += c;
*(uint32_t*)&hash[12] += d;
}
// cleanup
free(msg);
}
#endif | [
"57824882+joeferg425@users.noreply.github.com"
] | 57824882+joeferg425@users.noreply.github.com |
a43b3cfc3744cf5fa9ab8845c3b1bba3a79bac30 | cf6ae38d4adf41e3eb219b8ac477aa7ca7c7d18a | /trunk/libs/interprocess/doc/code/doc_named_condition_shared_data.hpp | d61934f4739375f639647c826da07b034e3dafce | [
"LicenseRef-scancode-unknown-license-reference",
"BSL-1.0"
] | permissive | ryppl/boost-history | a560df2bc79ffc7640f09d258599891dbbb8f6d0 | 934c80ff671f3afeb72b38d5fdf4396acc2dc58c | HEAD | 2016-09-07T08:08:33.930543 | 2011-07-10T13:15:08 | 2011-07-10T13:15:08 | 3,539,914 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 687 | hpp | #include <boost/interprocess/sync/interprocess_mutex.hpp>
#include <boost/interprocess/sync/interprocess_condition.hpp>
struct trace_queue
{
enum { LineSize = 100 };
trace_queue()
: message_in(false)
{}
//Mutex to protect access to the queue
boost::interprocess::interprocess_mutex mutex;
//Condition to wait when the queue is empty
boost::interprocess::interprocess_condition cond_empty;
//Condition to wait when the queue is full
boost::interprocess::interprocess_condition cond_full;
//Items to fill
char items[LineSize];
//Is there any message
bool message_in;
};
| [
"doug.gregor@gmail.com"
] | doug.gregor@gmail.com |
21cdd3fb47d2bac7e35c0a1e234c6cbbb73ac7a9 | a8020c6cb6e0b481687ea88b0f1e73d0a2b10a37 | /salarysheet.h | 7af7359fd937443a9f9c79d9eff825a8a727db91 | [] | no_license | sailendraw/MontesorryManagementSystem | 7fdef328d27c325a1d47d32679385ad2de8aaea7 | 210cc8b3868a6e448b538550dbc1ca4d211ccff8 | refs/heads/master | 2016-08-05T02:29:23.506955 | 2014-11-08T12:03:33 | 2014-11-08T12:03:33 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 671 | h | #ifndef SALARYSHEET_H
#define SALARYSHEET_H
#include <QWidget>
#include "qtrpt.h"
namespace Ui {
class salarysheet;
}
class salarysheet : public QWidget
{
Q_OBJECT
public:
explicit salarysheet(QWidget *parent = 0);
void display();
~salarysheet();
private slots:
void on_month_currentTextChanged(const QString &arg1);
void on_month_currentIndexChanged(const QString &arg1);
void on_stafflist_currentIndexChanged(const QString &arg1);
void on_pushButton_3_clicked();
void setValue(int &recNo, QString ¶mName, QVariant ¶mValue, int reportPage);
private:
Ui::salarysheet *ui;
QtRPT *report;
};
#endif // SALARYSHEET_H
| [
"sailendra.mzr@gmail.com"
] | sailendra.mzr@gmail.com |
c55965e7d3385a3571c0d4db0ba464f9e2f6000b | 9eec0e4a53c8fc0a42b22f99fd5ca18233a1c1ff | /socodery/backup/inheritance/inheritBaseMemInit.cpp | ea462e609877a098e74ef0cea082947f7a53d55c | [] | no_license | ansrivas/codes | 1b3139411e879e8b13ae3508f7793beffd1c36bd | 36693d7aaefdc894b200f4d2a9937ac2137f3146 | refs/heads/master | 2021-01-13T01:27:40.877798 | 2013-10-25T09:38:59 | 2013-10-25T09:38:59 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 718 | cpp | #include <iostream>
using namespace std;
class BaseClass {
int i, j;
public:
//BaseClass(){;}
BaseClass(int x, int y) {
cout << "in base constructor\n";
i = x;
j = y;
}
void showij() {
cout << "in base class\n" ;
cout << i << ' ' << j << '\n';
}
};
class DerivedClass : public BaseClass {
int k;
public:
// DerivedClass(){;}
DerivedClass(int a, int b, int c) : k(a), BaseClass(b, c) {
cout << "in derived constructor\n";
k = a;
}
void show() {
cout << k << ' ';
showij();
}
/*void showij() {
cout << "in derived class\n" ;
}*/
};
int main()
{
DerivedClass ob(1, 2, 3);
ob.showij();
//DerivedClass x;
/*
ob.show();
*/
return 0;
}
| [
"best.ankur@gmail.com"
] | best.ankur@gmail.com |
cd86e3757a093a2c50f7c9351ef9b247dcb927bb | 6530fc1675fee3e7d1662f86b6e4e3a2f298eb01 | /PanelBoeing-build-desktop-Qt_4_8_2__System__Release/moc_mcp23017.cpp | 65e39380d9b4d7d63e21d336b396ec744a4d1a95 | [] | no_license | ALGUS-Savunma-ve-Havacilik/PanelBoeing | 6ee7832afbdb1ef638294971e55b409a9400a11f | 9e831f913d91b94c87af633c1b9a4504d03b1193 | refs/heads/master | 2020-04-26T14:52:52.343368 | 2015-02-05T19:18:55 | 2015-02-05T19:18:55 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,337 | cpp | /****************************************************************************
** Meta object code from reading C++ file 'mcp23017.h'
**
** Created: Wed Apr 30 15:12:11 2014
** by: The Qt Meta Object Compiler version 63 (Qt 4.8.2)
**
** WARNING! All changes made in this file will be lost!
*****************************************************************************/
#include "../../Qtraspberrylib/mcp23017.h"
#if !defined(Q_MOC_OUTPUT_REVISION)
#error "The header file 'mcp23017.h' doesn't include <QObject>."
#elif Q_MOC_OUTPUT_REVISION != 63
#error "This file was generated using the moc from 4.8.2. It"
#error "cannot be used with the include files from this version of Qt."
#error "(The moc has changed too much.)"
#endif
QT_BEGIN_MOC_NAMESPACE
static const uint qt_meta_data_Mcp23017[] = {
// content:
6, // revision
0, // classname
0, 0, // classinfo
2, 14, // methods
0, 0, // properties
0, 0, // enums/sets
0, 0, // constructors
0, // flags
2, // signalCount
// signals: signature, parameters, type, tag, flags
9, 29, 35, 35, 0x05,
36, 29, 35, 35, 0x05,
0 // eod
};
static const char qt_meta_stringdata_Mcp23017[] = {
"Mcp23017\0interrupt_A(quint8)\0value\0\0"
"interrupt_B(quint8)\0"
};
void Mcp23017::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id, void **_a)
{
if (_c == QMetaObject::InvokeMetaMethod) {
Q_ASSERT(staticMetaObject.cast(_o));
Mcp23017 *_t = static_cast<Mcp23017 *>(_o);
switch (_id) {
case 0: _t->interrupt_A((*reinterpret_cast< quint8(*)>(_a[1]))); break;
case 1: _t->interrupt_B((*reinterpret_cast< quint8(*)>(_a[1]))); break;
default: ;
}
}
}
const QMetaObjectExtraData Mcp23017::staticMetaObjectExtraData = {
0, qt_static_metacall
};
const QMetaObject Mcp23017::staticMetaObject = {
{ &QObject::staticMetaObject, qt_meta_stringdata_Mcp23017,
qt_meta_data_Mcp23017, &staticMetaObjectExtraData }
};
#ifdef Q_NO_DATA_RELOCATION
const QMetaObject &Mcp23017::getStaticMetaObject() { return staticMetaObject; }
#endif //Q_NO_DATA_RELOCATION
const QMetaObject *Mcp23017::metaObject() const
{
return QObject::d_ptr->metaObject ? QObject::d_ptr->metaObject : &staticMetaObject;
}
void *Mcp23017::qt_metacast(const char *_clname)
{
if (!_clname) return 0;
if (!strcmp(_clname, qt_meta_stringdata_Mcp23017))
return static_cast<void*>(const_cast< Mcp23017*>(this));
return QObject::qt_metacast(_clname);
}
int Mcp23017::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
_id = QObject::qt_metacall(_c, _id, _a);
if (_id < 0)
return _id;
if (_c == QMetaObject::InvokeMetaMethod) {
if (_id < 2)
qt_static_metacall(this, _c, _id, _a);
_id -= 2;
}
return _id;
}
// SIGNAL 0
void Mcp23017::interrupt_A(quint8 _t1)
{
void *_a[] = { 0, const_cast<void*>(reinterpret_cast<const void*>(&_t1)) };
QMetaObject::activate(this, &staticMetaObject, 0, _a);
}
// SIGNAL 1
void Mcp23017::interrupt_B(quint8 _t1)
{
void *_a[] = { 0, const_cast<void*>(reinterpret_cast<const void*>(&_t1)) };
QMetaObject::activate(this, &staticMetaObject, 1, _a);
}
QT_END_MOC_NAMESPACE
| [
"saul_alejandro_r@hotmail.com"
] | saul_alejandro_r@hotmail.com |
08a4b38a8bbb32d55ab4fe43a3e653186f033179 | 3f75df57ae155e3eaada2885b12b78a63bbc43a1 | /source/Geometry/CGA/src/TRKFTDHit.cc | cd3d792873fddc40f8b12c314638ad762cb8563a | [] | no_license | nkxuyin/mokka-cepc | 52bb13455b6fc5961de678ad7cb695f754e49a47 | 61ce9f792a4cb8883f0d1cd1391884444b372dc0 | refs/heads/master | 2021-01-20T10:42:00.982704 | 2015-02-11T12:59:43 | 2015-02-11T12:59:43 | 24,243,983 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 4,790 | cc | #include "TRKFTDHit.hh"
// Basic C
#include <assert.h>
// Basic Mokka classes
#include "Control.hh"
// Geant4 classes
#include "G4VVisManager.hh"
#include "G4VisAttributes.hh"
#include "G4Colour.hh"
#include "G4Circle.hh"
// LCIO classes
#ifdef LCIO_MODE
#include <lcio.h>
#include <IMPL/LCFlagImpl.h>
#include <UTIL/CellIDEncoder.h>
#include <UTIL/ILDConf.h>
#endif
G4Allocator<TRKFTDHit> TRKFTDHitAllocator;
//
// Copy constructor
//
TRKFTDHit::TRKFTDHit(const TRKFTDHit &right)
#ifdef LCIO_MODE
: VHit( LCIO::SIMTRACKERHIT )
#else
: VHit()
#endif
{
_iLayer = right._iLayer;
_iSide = right._iSide;
_iLadder = right._iLadder;
_iSensor = right._iSensor;
_PID = right._PID;
_PDG = right._PDG;
_Pos = right._Pos;
_Momentum = right._Momentum;
_Time = right._Time;
_DepEnergy = right._DepEnergy;
_stepLength= right._stepLength;
}
//
// Operator =
//
const TRKFTDHit& TRKFTDHit::operator=(const TRKFTDHit &right)
{
#ifdef LCIO_MODE
((VHit*)this)->operator=(right);
#endif
_iLayer = right._iLayer;
_iSide = right._iSide;
_iLadder = right._iLadder;
_iSensor = right._iSensor;
_PID = right._PID;
_PDG = right._PDG;
_Pos = right._Pos;
_Momentum = right._Momentum;
_Time = right._Time;
_DepEnergy = right._DepEnergy;
_stepLength= right._stepLength;
return *this;
}
//
// Operator ==
//
int TRKFTDHit::operator==(const TRKFTDHit &right) const
{
return ((_iLayer == right._iLayer ) &&
(_iSide == right._iSide ) &&
(_iLadder == right._iLadder ) &&
(_iSensor == right._iSensor ) &&
(_PID == right._PID ) &&
(_PDG == right._PDG ) &&
(_Pos == right._Pos ) &&
(_Momentum == right._Momentum ) &&
(_Time == right._Time ) &&
(_DepEnergy == right._DepEnergy ) &&
(_stepLength== right._stepLength));
}
//
// Draw a hit
//
void TRKFTDHit::Draw()
{
G4VVisManager* vVisManager = G4VVisManager::GetConcreteInstance();
if(vVisManager)
{
G4Colour colour(((GetPID()%2)+1.)/2.,((GetPID()%3)+1.)/3.,1.);
G4VisAttributes attribs(colour);
G4Circle circle;
circle.SetPosition(G4Point3D(_Pos.getX(),_Pos.getY(),_Pos.getZ()));
circle.SetScreenDiameter (2.0);
circle.SetFillStyle (G4Circle::filled);
circle.SetVisAttributes(attribs);
// vVisManager->Draw(circle);
}
}
//
// Print
//
void TRKFTDHit::Print() {}
//
// Save the hit into a text file
//
void TRKFTDHit::Save(FILE *oFile)
{
if(oFile)
{
fprintf(oFile,"nL:%d hPos[mm]:%7.2f %7.2f %7.2f vecP[GeV]:%7.2f %7.2f %7.2f time[ns]:%7.2f PID:%d PDG:%d depE[keV]:%15e\n",
_iLayer, _Pos.getX()/mm, _Pos.getY()/mm, _Pos.getZ()/mm,
_Momentum.getX()/GeV, _Momentum.getY()/GeV, _Momentum.getZ()/GeV,
_Time/ns, _PID, _PDG, _DepEnergy/keV);
}
}
//
// Load the hit from a text file
//
G4bool TRKFTDHit::Load(FILE *iFile)
{
double X,Y,Z, Px,Py,Pz, Time, EDep;
int iLayer, iSide, iLadder, iSensor, PID, PDG;
G4bool readStatus = 0;
readStatus = (fscanf(iFile,"%d %d %d %d %lf %lf %lf %lf %lf %lf %lf %d %d %lf",
&iLayer, &iSide, &iLadder, &iSensor, &X,&Y,&Z, &Px,&Py,&Pz, &Time, &PID, &PDG, &EDep) == 13);
return readStatus;
}
//
// Save the hit into a lcio file
//
#ifdef LCIO_MODE
void TRKFTDHit::Save(LCCollectionVec* aLCCollectionVec)
{
// Set flag - barrel detectors-- NO
LCFlagImpl aFlag(0);
//aFlag.setBit( LCIO::THBIT_BARREL );
//aLCCollectionVec->setFlag( aFlag.getFlag() );
// Set flag - momentum and step length will be saved
#ifdef MOKKA_SETMOMENTUM
aFlag.setBit( LCIO::THBIT_MOMENTUM );
aLCCollectionVec->setFlag( aFlag.getFlag() );
#endif
// Create cellID encoder
//CellIDEncoder<SimTrackerHitImpl> cellIDEnc( "layer:7,ladder:5,sensor:4" ,aLCCollectionVec ) ;
ILDCellIDEncoder<SimTrackerHitImpl> cellIDEnc( aLCCollectionVec );
// Set hit position
G4double hitPos[3];
hitPos[0] = _Pos.getX()/mm;
hitPos[1] = _Pos.getY()/mm;
hitPos[2] = _Pos.getZ()/mm;
// Create a new LCIO SimTracker hit
SimTrackerHitImpl * hit = new SimTrackerHitImpl;
hit->setEDep(GetEDep()/GeV);
hit->setPosition(hitPos);
hit->setTime(GetTime()/ns);
hit->setMomentum(_Momentum.getX()/GeV,_Momentum.getY()/GeV,_Momentum.getZ()/GeV);
hit->setPathLength(_stepLength/mm);
cellIDEnc[ILDCellID0::subdet] = ILDDetID::FTD;
cellIDEnc[ILDCellID0::side] = _iSide;
cellIDEnc[ILDCellID0::layer] = _iLayer;
cellIDEnc[ILDCellID0::module] = _iLadder;
cellIDEnc[ILDCellID0::sensor] = _iSensor;
cellIDEnc.setCellID(hit);
// Set particle that has interacted in the detector
#ifdef MOKKA_SETMCPART
hit->setMCParticle( dynamic_cast<MCParticle*>(Control::MCParticleMap[_PID]));
#else
hit->setMCParticle(NULL);
#endif
// Put the hit into LCIO collection
aLCCollectionVec->push_back( hit );
}
#endif
| [
"xuyin@nankai.edu.cn"
] | xuyin@nankai.edu.cn |
c53f10c5fe7bf7b90d287980a4e7430164fd376b | e89be39fe4d4f54b1b27d8b4584b24f00594725e | /libraries/SDCard/sdcard.cpp | cc2aceb2a5fbd79f94844fa33f7717f377057a7e | [] | no_license | RobotEdh/RobotMicroControl | 1dddf057cf3f6aa37026ac6b9c0ccafca8374936 | a48b604741dbf3a1e17914e3a12d597cfc00fa81 | refs/heads/master | 2021-06-27T06:36:11.495105 | 2020-10-14T20:32:07 | 2020-10-14T20:32:07 | 161,914,561 | 0 | 2 | null | null | null | null | UTF-8 | C++ | false | false | 2,859 | cpp | #include <sdcard.h>
Sd2Card card; // SD Card
SdVolume volume; // SD Volume
SdFile root; // SD Root
int initSDCard(void){
if (!card.init(SPI_HALF_SPEED, SS_CS_Pin)) //Set SCK rate to F_CPU/4 (mode 1)
{
Serial.println("Error Init SD-Card");
return SDCARD_ERROR;
}
else
{
// initialize a FAT volume
if (!volume.init(&card))
{
Serial.println("Error Init Volume in SD-Card");
return SDCARD_ERROR;
}
else
{
// Open volume
if (!root.openRoot(&volume))
{
Serial.println("Error Open Volume in SD-Card");
return SDCARD_ERROR;
}
else
{
return SUCCESS;
}
}
}
}
int infoSDCard(void){
Serial.print("SD-Card type is ");
switch(card.type()){
case SD_CARD_TYPE_SD1:
Serial.print("SD1");
break;
case SD_CARD_TYPE_SD2:
Serial.print("SD2");
break;
case SD_CARD_TYPE_SDHC:
Serial.print("SDHC");
break;
default:
Serial.println("Unknown");
}
cid_t cid;
if (!card.readCID(&cid))
{
Serial.print("\nError Open read CID of SD-Card");
return SDCARD_ERROR;
}
Serial.print("\nManufacturer ID: ");
Serial.print(cid.mid, HEX);
Serial.print("\nOEM/Application ID: ");
Serial.print(cid.oid[0]);
Serial.print(cid.oid[1]);
Serial.print("\nProduct name: ");
for (uint8_t i = 0; i < 5; i++) {
Serial.print(cid.pnm[i]);
}
Serial.print("\nProduct revision: ");
Serial.print(cid.prv_m, DEC);
Serial.print(".");
Serial.print(cid.prv_n, DEC);
Serial.print("\nProduct serial number: ");
Serial.print(cid.psn);
Serial.print("\nManufacturing date: ");
Serial.print(cid.mdt_month);
Serial.print('/');
Serial.print(2000 + (10*cid.mdt_year_high) + cid.mdt_year_low);
// print the type and size of the first FAT-type volume
Serial.print("\nVolume type is FAT");
Serial.print(volume.fatType(), DEC);
uint32_t volumesize;
volumesize = volume.blocksPerCluster(); // clusters are collections of blocks
volumesize *= volume.clusterCount(); // we'll have a lot of clusters
volumesize /= 2; // SD card blocks are always 512 bytes (2 blocks are 1KB)
Serial.print("Volume size (Kb): ");
Serial.println(volumesize);
Serial.print("Volume size (Mb): ");
volumesize /= 1024;
Serial.println(volumesize);
Serial.print("Volume size (Gb): ");
Serial.println((float)volumesize / 1024.0);
// list all files in the card with date and size
Serial.println("\nFiles found on the card (name, date and size in bytes): ");
root.openRoot(volume);
// list all files in the card with date and size
root.ls(LS_R | LS_DATE | LS_SIZE);
Serial.println("");
return 0;
}
| [
"eric.delahoupliere@free.fr"
] | eric.delahoupliere@free.fr |
8011bc188eeaecee4409c05c678882801aeb6c36 | 71bd19d1587e8736f9645736a1e61552ae0d543a | /src/C_iterate.h | eb794c4e18ee44d41409e364c972fce7ddd26696 | [] | no_license | cran/cnaOpt | 55acd34c2ca18f083abee6d7d7722cca356445a6 | c6e0b904714713f05f6e3d0989ff841d0646f661 | refs/heads/master | 2023-03-18T01:38:03.279181 | 2022-07-08T13:00:11 | 2022-07-08T13:00:11 | 236,573,536 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 430 | h |
// void show(dblIteratorList x);
// void show(std::vector<double> x);
dblIteratorList getStarts(dblList x);
dblIteratorList getEnds(dblList x);
void increase(dblIteratorList& ii, int& changed,
const dblIteratorList& _starts_,
const dblIteratorList& _ends_,
int pos = -1);
bool finished(dblIteratorList ii,
const dblIteratorList _ends_);
long long int ll(dblList x);
| [
"csardi.gabor+cran@gmail.com"
] | csardi.gabor+cran@gmail.com |
f48f5c9ee810e4089bc73e8b093a45911d0f4dd8 | aee5b4d5e176a6d5054d6f1db7df94d4ebfde2ee | /policy_table.cpp | df32d59489d32d7f5d20c095cf4c603cea202324 | [
"Apache-2.0"
] | permissive | rfrandse/ibm-logging | 2b06e02dda92e9b3b3364cded8d2ad35ebe7d870 | 9351665a5d9560e42b2fa42c3f95cd18f9455018 | refs/heads/master | 2020-04-15T13:14:43.544670 | 2018-10-23T15:49:47 | 2018-10-23T15:49:47 | 164,708,462 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,166 | cpp | /**
* Copyright © 2018 IBM Corporation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "policy_table.hpp"
#include <experimental/filesystem>
#include <fstream>
#include <nlohmann/json.hpp>
#include <phosphor-logging/log.hpp>
namespace ibm
{
namespace logging
{
namespace policy
{
namespace fs = std::experimental::filesystem;
using namespace phosphor::logging;
Table::Table(const std::string& jsonFile)
{
if (fs::exists(jsonFile))
{
load(jsonFile);
}
else
{
log<level::INFO>("Policy table JSON file does not exist",
entry("FILE=%s", jsonFile.c_str()));
}
}
void Table::load(const std::string& jsonFile)
{
try
{
std::ifstream file{jsonFile};
auto json = nlohmann::json::parse(file, nullptr, true);
for (const auto& policy : json)
{
DetailsList detailsList;
for (const auto& details : policy["dtls"])
{
Details d;
d.modifier = details["mod"];
d.msg = details["msg"];
d.ceid = details["CEID"];
detailsList.emplace_back(std::move(d));
}
policies.emplace(policy["err"], std::move(detailsList));
}
loaded = true;
}
catch (std::exception& e)
{
log<level::ERR>("Failed loading policy table json file",
entry("FILE=%s", jsonFile.c_str()),
entry("ERROR=%s", e.what()));
loaded = false;
}
}
FindResult Table::find(const std::string& error,
const std::string& modifier) const
{
// First find the entry based on the error, and then find which
// underlying details object it is with the help of the modifier.
auto policy = policies.find(error);
if (policy != policies.end())
{
// If there is no exact modifier match, then look for an entry with
// an empty modifier - it is the catch-all for that error.
auto details = std::find_if(
policy->second.begin(), policy->second.end(),
[&modifier](const auto& d) { return modifier == d.modifier; });
if ((details == policy->second.end()) && !modifier.empty())
{
details =
std::find_if(policy->second.begin(), policy->second.end(),
[](const auto& d) { return d.modifier.empty(); });
}
if (details != policy->second.end())
{
return DetailsReference(*details);
}
}
return {};
}
} // namespace policy
} // namespace logging
} // namespace ibm
| [
"spinler@us.ibm.com"
] | spinler@us.ibm.com |
9a69eb6ed8de686796c2fae701e4c4b86ca1b99d | 75667c69371e560e00846993e0594198ba5b0271 | /lantern/src/math_common.cpp | 4bc780363756125f61b51695845b516d881d092e | [
"MIT"
] | permissive | fredlim/lantern | 028237401f73ccbe30c28dea1d8712c33bb283b8 | ae968506925f6e28498d0b54850030c47e6a7031 | refs/heads/master | 2023-03-18T00:22:15.644336 | 2015-11-21T12:42:51 | 2015-11-21T12:42:51 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 402 | cpp | #include "math_common.h"
using namespace lantern;
float lantern::triangle_2d_area(
float const x0, float const y0,
float const x1, float const y1,
float const x2, float const y2)
{
return std::abs(0.5f * (x0 * (y1 - y2) + x1 * (y2 - y0) + x2 * (y0 - y1)));
}
float lantern::clamp(float const value, float const from, float const to)
{
return (value > to ? to : (value < from ? from : value));
} | [
"loreglean@gmail.com"
] | loreglean@gmail.com |
555ae40cf97a15d12ff0aea6767da175fb5ce4f9 | ea3b88a242669a53d0b8cf475fdd9db3ed22493e | /PWGLF/SPECTRA/ChargedHadrons/dNdPt/AliAnalysisTaskSpectraV0M.cxx | c26f89bf31ae85a702002c5e4fc84c9f6f356dc3 | [] | permissive | ppanasta/AliPhysics | cba8cde2e5f7c718fa7eac78a0681e8c6e147577 | 226101b9595c8c4bad885016e6b8ede56eb9ad9b | refs/heads/master | 2021-01-16T04:59:23.838008 | 2020-02-25T10:51:38 | 2020-02-25T10:51:38 | 242,980,339 | 1 | 0 | BSD-3-Clause | 2020-02-25T11:10:33 | 2020-02-25T11:10:32 | null | UTF-8 | C++ | false | false | 5,978 | cxx | #include <iostream>
#include "TChain.h"
#include "TH1F.h"
#include "TList.h"
#include "TRandom.h"
#include "TRandom3.h"
#include "TGeoGlobalMagField.h"
#include "AliAnalysisTask.h"
#include "AliAnalysisManager.h"
#include "AliESDEvent.h"
#include "AliESDInputHandler.h"
#include "AliESDtrack.h"
#include "AliAODEvent.h"
#include "AliHeader.h"
#include "AliMCEvent.h"
#include "AliGenEventHeader.h"
#include "AliESDtrackCuts.h"
#include "AlidNdPtTools.h"
#include "AliAnalysisTaskMKBase.h"
#include "AliAnalysisTaskSpectraV0M.h"
class AliAnalysisTaskSpectraV0M;
using namespace std;
/// \cond CLASSIMP
ClassImp(AliAnalysisTaskSpectraV0M)
/// \endcond
//_____________________________________________________________________________
AliAnalysisTaskSpectraV0M::AliAnalysisTaskSpectraV0M()
: AliAnalysisTaskMKBase()
, fHistEffCont(0)
, fHistTrack(0)
, fHistEvent(0)
{
// default contructor
}
//_____________________________________________________________________________
AliAnalysisTaskSpectraV0M::AliAnalysisTaskSpectraV0M(const char* name)
: AliAnalysisTaskMKBase(name)
, fHistEffCont(0)
, fHistTrack(0)
, fHistEvent(0)
{
// constructor
}
//_____________________________________________________________________________
AliAnalysisTaskSpectraV0M::~AliAnalysisTaskSpectraV0M()
{
// destructor
}
//_____________________________________________________________________________
void AliAnalysisTaskSpectraV0M::AddOutput()
{
AddAxis("cent");
AddAxis("nAcc","mult6kcoarse");
AddAxis("MCpT","pt");
AddAxis("MCQ",3,-1.5,1.5);
AddAxis("MCpid",10,-0.5,9.5); // 0=e, 1=mu, 2=pi, 3=K, 4=p, 6=sigmaP, 7=sigmaM, 8=xi, 9=omega, 5=other
AddAxis("MCinfo",4,-0.5,3.5); // 0=prim, 1=decay 2=material, 3=genprim
fHistEffCont = CreateHist("fHistEffCont");
fOutputList->Add(fHistEffCont);
AddAxis("cent");
AddAxis("multV0","mult6kfine");
AddAxis("pt");
fHistTrack = CreateHist("fHistTrack");
fOutputList->Add(fHistTrack);
AddAxis("cent");
AddAxis("multV0","mult6kfine");
AddAxis("nAcc","mult6kcoarse");
fHistEvent = CreateHist("fHistEvent");
fOutputList->Add(fHistEvent);
}
//_____________________________________________________________________________
Bool_t AliAnalysisTaskSpectraV0M::IsEventSelected()
{
return fIsAcceptedAliEventCuts;
}
//_____________________________________________________________________________
void AliAnalysisTaskSpectraV0M::AnaEvent()
{
LoopOverAllTracks();
// if (fIsMC) LoopOverAllParticles();
FillHist(fHistEvent, fMultPercentileV0M, fMultV0MmultSelection, fNTracksAcc);
}
//_____________________________________________________________________________
void AliAnalysisTaskSpectraV0M::AnaTrack(Int_t flag)
{
if (!fAcceptTrackM) return;
FillHist(fHistTrack, fMultPercentileV0M, fMultV0MmultSelection, fPt);
}
//_____________________________________________________________________________
void AliAnalysisTaskSpectraV0M::AnaTrackMC(Int_t flag)
{
if (!fAcceptTrackM) return;
if (fMCParticleType==AlidNdPtTools::kOther) { Log("RecTrack.PDG.",fMCPDGCode); }
if (TMath::Abs(fMCQ > 1)) { Log("RecTrack.Q>1.PDG.",fMCPDGCode); }
FillHist(fHistEffCont, fMultPercentileV0M, fNTracksAcc, fMCPt, fMCChargeSign, fMCParticleType, fMCProdcutionType);
}
//_____________________________________________________________________________
void AliAnalysisTaskSpectraV0M::AnaParticleMC(Int_t flag)
{
if (!fMCisPrim) return;
if (!fMCIsCharged) return;
if (TMath::Abs(fMCEta) > 0.8) return;
if (fMCParticleType==AlidNdPtTools::kOther) { Log("GenPrim.PDG.",fMCPDGCode); }
if (TMath::Abs(fMCQ > 1)) { Log("GenPrim.Q>1.PDG.",fMCPDGCode); }
FillHist(fHistEffCont, fMultPercentileV0M, fNTracksAcc, fMCPt, fMCChargeSign, fMCParticleType, 3);
}
//_____________________________________________________________________________
AliAnalysisTaskSpectraV0M* AliAnalysisTaskSpectraV0M::AddTaskSpectraV0M(const char* name, const char* outfile)
{
AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
if (!mgr) {
::Error("AddTaskSpectraV0M", "No analysis manager to connect to.");
return 0;
}
// Check the analysis type using the event handlers connected to the analysis manager.
//==============================================================================
if (!mgr->GetInputEventHandler()) {
::Error("AddTaskSpectraV0M", "This task requires an input event handler");
return NULL;
}
// Setup output file
//===========================================================================
TString fileName = AliAnalysisManager::GetCommonFileName();
fileName += ":";
fileName += name; // create a subfolder in the file
if (outfile) { // if a finename is given, use that one
fileName = TString(outfile);
}
// create the task
//===========================================================================
AliAnalysisTaskSpectraV0M *task = new AliAnalysisTaskSpectraV0M(name);
if (!task) { return 0; }
// configure the task
//===========================================================================
task->SelectCollisionCandidates(AliVEvent::kAnyINT);
task->SetESDtrackCutsM(AlidNdPtTools::CreateESDtrackCuts("defaultEta08"));
// task->SetESDtrackCuts(0,AlidNdPtTools::CreateESDtrackCuts("defaultEta08"));
// attach the task to the manager and configure in and ouput
//===========================================================================
mgr->AddTask(task);
mgr->ConnectInput(task,0,mgr->GetCommonInputContainer());
mgr->ConnectOutput(task,1,mgr->CreateContainer(name, TList::Class(), AliAnalysisManager::kOutputContainer, fileName.Data()));
return task;
} | [
"michael.linus.knichel@cern.ch"
] | michael.linus.knichel@cern.ch |
c6de8fea499f51ddeb9f5d0ab87ac471cddfaa32 | 6f833427da2ae06e12e7cddbe2f275aedd8310de | /Lesson 6 - Inheritance/006 - multiple inheritance/main.cpp | f87e197420a61315c050c34a2772a358698b6724 | [
"MIT"
] | permissive | YuilTripathee/CPP_programming | 2331c770426d0f5ca96582281c2a745556d380f2 | 93301a3b9300605bdc61de2d1c6c2e96d11586a5 | refs/heads/master | 2022-02-28T06:28:12.890300 | 2019-11-02T01:39:38 | 2019-11-02T01:39:38 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 828 | cpp | /*
Academic Sport
|__________|
|
Result
*/
// code:
#include <iostream>
using namespace std;
class Academic
{
protected:
char name[20];
int m1, m2;
public:
void GetData1()
{
cout << "Enter name, mark1 and mark2: ";
cin >> name >> m1 >> m2;
}
};
class Sport
{
protected:
int m3;
public:
void GetData2()
{
cout << "Enter sports mark3: ";
cin >> m3;
}
};
class Result : public Academic, public Sport
{
int tot;
public:
void ShowData()
{
tot = m1 + m2 + m3;
cout << "Name: " << name << endl;
cout << "Total: " << tot << endl;
}
};
main()
{
Result r;
r.GetData1();
r.GetData2();
r.ShowData();
} | [
"yuiltripathee79@gmail.com"
] | yuiltripathee79@gmail.com |
fc5eb2f92f9397e62adfd382def1b767ee5ace11 | 7e824dc4b0044129c95d51480b3514fb9a64acc7 | /QT/tutoriale/68 - QTcpServer using multiple threads/MultiServer/main.cpp | 20a99cf9b4bdab8204002cf3bddab8e4c7825159 | [] | no_license | morariu05/TAP | 3b97964fa3fb687ef7aa9ab13a82086b9458fda4 | 0ac56f91783b68d63134efdd12bf381ccb5639e1 | refs/heads/master | 2023-03-25T01:13:31.470612 | 2021-03-21T21:56:53 | 2021-03-21T21:56:53 | 350,127,947 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 201 | cpp | #include <QtCore/QCoreApplication>
#include "myserver.h"
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
MyServer Server;
Server.StartServer();
return a.exec();
}
| [
"morariumadalina05@gmail.com"
] | morariumadalina05@gmail.com |
ac6f964462121c3c1ce5e1db08eea12c7dd84365 | f2367d2c97b70ab1dd8e72a26f13cf341c9c5df0 | /lab5/Codes/FSSB/FSSB.cpp | dbc9b23f4221a39929106fabbbd797a199166e37 | [] | no_license | MitchellHansen/optimization-algorithms | 85e872c4e2e11a63c1b2df31ac5fd40fd0c5ab9b | d1a836995bf19b475947ab964072243eca9e38fa | refs/heads/main | 2020-06-21T05:54:45.629471 | 2017-01-13T05:13:46 | 2017-01-13T05:13:46 | 74,801,656 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,700 | cpp | /**
* @brief Flow shop with blocking
* @author doc. MSc. Donald Davendra Ph.D.
* @date 3.10.2013
*
* This is a simple class to calculate the makespan of the flowshop with blocking schedule.
*/
/*! \file FSSB.h
\brief A FSSB header file.
*/
#include "FSSB.h"
#include <stdlib.h>
#include <iostream>
#include <fstream>
#include <cmath>
using namespace std;
cFSSB::cFSSB(){
ifstream infile;
infile.open("fss.txt");
if(!infile.is_open()) {
cout << "Error Opening File.\n";
exit(1);
}
else {
infile >> m_Machines;
infile >> m_Jobs;
m_ProcessTime = new float*[m_Machines];
for (int i = 0; i < m_Machines; i++) {
m_ProcessTime[i] = new float[m_Jobs];
}
for (int i = 0; i < (m_Machines); i++) {
for (int j = 0; j < m_Jobs; j++) {
infile >> m_ProcessTime[i][j];
}
}
m_CompletionTime = new float*[m_Machines];
for (int i = 0; i < m_Machines; i++) {
m_CompletionTime[i] = new float[m_Jobs];
}
}
infile.close();
}
cFSSB::~cFSSB(){
for (int i = 0; i < m_Machines; i++) {
delete [] m_ProcessTime[i];
}
delete [] m_ProcessTime;
for (int i = 0; i < m_Machines; i++) {
delete [] m_CompletionTime[i];
}
delete [] m_CompletionTime;
}
int cFSSB::GetMachines(){
return m_Machines;
}
int cFSSB::GetJobs(){
return m_Jobs;
}
float cFSSB::Makespan(int *Schedule){
Initialize();
// Calculate processing time for all jobs on first machine
m_CompletionTime[0][0] = m_ProcessTime[0][Schedule[0]-1];
for (int i = 1; i < m_Machines; i++) {
m_CompletionTime[i][0] = (m_CompletionTime[i-1][0] + m_ProcessTime[i][Schedule[0]-1]);
}
// Calculate for each subsequent job
for (int i = 1; i < m_Jobs; i++) {
for (int j = 0; j < m_Machines; j++) {
if(j == 0){
m_CompletionTime[j][i] = m_CompletionTime[j][i-1] + m_ProcessTime[j][Schedule[i]-1];
}
else{
if(m_CompletionTime[j-1][i] < m_CompletionTime[j][i-1]){
m_CompletionTime[j-1][i] = m_CompletionTime[j][i-1];
}
m_CompletionTime[j][i] = m_CompletionTime[j-1][i] + m_ProcessTime[j][Schedule[i]-1];
}
}
}
// Return the makespan.
return m_CompletionTime[m_Machines-1][m_Jobs-1];
}
void cFSSB::Initialize(){
for (int i = 0; i < m_Machines; i++) {
for (int j = 0; j < m_Jobs; j++) {
m_CompletionTime[i][j] = 0;
}
}
}
| [
"mitchellhansen0@gmail.com"
] | mitchellhansen0@gmail.com |
88def7a1a28c9b0e80a4f380d7ed7aa5c6705b5e | 25566712584db250f7419007954351b63ad8a516 | /History.h | d5f209c61e2a9c98de0e9f0a6d888140af4991a6 | [] | no_license | rjadroncik/Shadow-Studio | 2cd69c29b05a40559a714c96cbc44ea6c01a7c06 | 8df941457f6a7b2890480ad25ee764fad27ce63d | refs/heads/master | 2021-01-18T22:37:09.492427 | 2016-10-20T19:49:33 | 2016-10-20T19:49:33 | 27,828,580 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 482 | h | // History.h: interface for the CHistory class.
//
//////////////////////////////////////////////////////////////////////
#if !defined(AFX_HISTORY_H__07B6E81F_AC2D_4A52_90DB_A3CC08D0BD92__INCLUDED_)
#define AFX_HISTORY_H__07B6E81F_AC2D_4A52_90DB_A3CC08D0BD92__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
class CHistory
{
public:
CHistory();
virtual ~CHistory();
};
#endif // !defined(AFX_HISTORY_H__07B6E81F_AC2D_4A52_90DB_A3CC08D0BD92__INCLUDED_)
| [
"roman.jadroncik@gmail.com"
] | roman.jadroncik@gmail.com |
cfca0b19f0f6e52f75d47c3b59625af16b54481b | 2885e54c807bd70b8eb0cd2bc3ffd5ce51bd66cc | /2007-PIR-Drone Trirotor acrobate/Projet/Informatique/CNES/marmottes-9.8/src/Senseur.cpp | a2bbbaf88ee5d6d87facc79c554bbca9101e02b4 | [] | no_license | crubier/my-personal-projects | 622b09ce6d9c846b905fe135892a178c1a0c554b | 8cd26b212b0c61f3d5bbe2de82d49891f3f3602a | refs/heads/master | 2021-09-12T23:09:14.097634 | 2018-04-22T07:45:42 | 2018-04-22T07:45:42 | 130,488,289 | 1 | 0 | null | null | null | null | ISO-8859-1 | C++ | false | false | 5,876 | cpp | ///////////////////////////////////////////////////////////////////////////////
//$<AM-V1.0>
//
//$Type
// DEF
//
//$Projet
// Marmottes
//
//$Application
// Marmottes
//
//$Nom
//> Senseur.cpp
//
//$Resume
// fichier d'implantation de la classe Senseur
//
//$Description
// Module de définition de la classe
//
//$Contenu
//> class Senseur
//> operator =()
//> respecterMesures()
//> convertirMesures()
//> nouveauRepere()
//> criteresControlabilite()
//> calage()
//> modeliseConsigne()
//
//$Historique
// $Log: Senseur.cpp,v $
// Revision 2.14 2003/02/04 16:37:05 marmottes
// DM-ID 17 Mise à jour de l'extension du fichier dans le bandeau
//
// Revision 2.13 2002/01/17 09:26:19 marmottes
// correction de spécifications throw
//
// Revision 2.12 2001/04/04 12:24:53 luc
// ajout de la méthode criteresControlabilite
//
// Revision 2.11 2000/10/02 13:16:29 luc
// remplacement d'attributs entiers en booléens
//
// Revision 2.10 2000/03/30 17:01:20 luc
// ajout du copyright CNES
//
// Revision 2.9 1999/08/20 07:37:28 filaire
// Correction de certaines erreurs dues au passage aux exceptions
// Changement de signatures des méthodes "throw"
//
// Revision 2.8 1999/08/06 13:32:15 filaire
// Passage à la gestion des erreurs par les exceptions
//
// Revision 2.7 1998/06/24 20:02:34 luc
// élimination des variables statiques RCS
// modification du format des en-têtes
//
// Revision 2.6 1998/04/26 18:25:26 luc
// inversion de la convention de nommage des attributs
//
// Revision 2.5 1997/09/23 09:29:01 luc
// ajout d'une gestion des unités de consigne et de mesure
// interne au senseur
//
// Revision 2.4 1997/08/20 08:41:58 luc
// ajout d'un en-tête de fichier
// utilisation de ChaineSimple
// déplacement de constructeurs dans le .h (simplifiés grâce à ChaineSimple)
// implantation d'une version générique de la méthode modeliseConsigne
//
// Revision 2.3 1997/04/27 19:36:34 luc
// inversion des codes de retour
// changement des règles de nommage
// passage de SCCS à RCS
//
// Revision 2.2 1996/09/11 17:43:04 luc
// ajout du nom du senseur dans l'instance
//
// Revision 2.1 1996/07/31 17:21:34 luc
// ajout d'une possibilité de modifier le repère senseur à l'exécution
//
// Revision 1.1 1994/12/23 11:00:13 luc
// Initial revision
//
//$Version
// $Id: Senseur.cpp,v 2.14 2003/02/04 16:37:05 marmottes Exp $
//
//$Auteur
// L. Maisonobe CNES
// Copyright (C) 2000 CNES
//$<>
///////////////////////////////////////////////////////////////////////////////
#include "marmottes/Senseur.h"
Senseur& Senseur::operator = (const Senseur& s)
{ if (&s != this) // protection contre x = x
{ nom_ = s.nom_;
repereBase_ = s.repereBase_;
repere_ = s.repere_;
axeCalage_ = s.axeCalage_;
precision_ = s.precision_;
convertirConsignes_ = s.convertirConsignes_;
convertirMesures_ = s.convertirMesures_;
valeurConsigne_ = s.valeurConsigne_;
}
return *this;
}
void Senseur::respecterMesures ()
{ // implantation de la méthode virtuelle dans la classe de base
// ATTENTION : bien que cette méthode soit implantée, elle est virtuelle pure
// les classes dérivées DOIVENT fournir également une implantation
// qui peut éventuellement faire appel à cette implantation de base
convertirMesures_ = false;
}
void Senseur::convertirMesures ()
{ // implantation de la méthode virtuelle dans la classe de base
// ATTENTION : bien que cette méthode soit implantée, elle est virtuelle pure
// les classes dérivées DOIVENT fournir également une implantation
// qui peut éventuellement faire appel à cette implantation de base
convertirMesures_ = true;
}
void Senseur::nouveauRepere (const RotDBL& nouveau)
{ // rotation du senseur
// les coordonnées de axeCalage_ sont (et restent en permanence)
// exprimées dans le repère de base : on ne les touche donc pas
// modification du repère courant
repere_ = nouveau;
}
void Senseur::criteresControlabilite (const Etat& etat,
codeAstre *ptrInhibant,
codeAstre *ptrEclipsant,
double *ptrEcartFrontiere,
bool *ptrAmplitudeSignificative)
throw (MarmottesErreurs, CantorErreurs)
{ // calcul des critères de contrôlabilité
// l'implémentation par défaut consiste à dire que tout est parfait
*ptrInhibant = nonSignificatif;
*ptrEclipsant = nonSignificatif;
*ptrEcartFrontiere = +1.0;
*ptrAmplitudeSignificative = false;
}
void Senseur::calage (double c)
throw (MarmottesErreurs)
{ // rotation du senseur autour d'un axe de calage prévu
if (axeCalage_.norme () < 0.5)
throw MarmottesErreurs (MarmottesErreurs::calage_interdit);
// remise à zéro du repère
nouveauRepere (repereBase_);
// prise en compte du calage
nouveauRepere (RotDBL (axeCalage_, -c) (repereBase_));
}
void Senseur::modeliseConsigne (const Etat&, double valeur)
throw (CantorErreurs, MarmottesErreurs)
{ // implantation de la méthode virtuelle dans la classe de base
// ATTENTION : bien que cette méthode soit implantée, elle est virtuelle pure
// les classes dérivées DOIVENT fournir également une implantation
// qui peut éventuellement faire appel à cette implantation de base
valeurConsigne_ = valeur;
}
| [
"vincent.lecrubier@gmail.com"
] | vincent.lecrubier@gmail.com |
4da58027033786eab962e356aecda5ffbbc14d23 | 065e58016a4506e4a5b429a2b77a6f432930a362 | /include/core/Memory.hpp | 6cda09142c9c01df794ffe25ffade635a9d142d9 | [] | no_license | UnsafePointer/shinobu | 380ba84b1dfe122da3f6042da2261bcec5f07abe | 5088e95c3dcd7b0f3e9b226dc768811a6b2ddc4f | refs/heads/master | 2023-01-07T06:31:50.271267 | 2020-09-23T14:00:40 | 2020-09-23T14:00:40 | 265,358,408 | 3 | 0 | null | 2020-09-23T14:00:41 | 2020-05-19T20:28:27 | C++ | UTF-8 | C++ | false | false | 16,065 | hpp | #pragma once
#include <cstdint>
#include <memory>
#include <filesystem>
#include <optional>
#include <vector>
#include <common/Logger.hpp>
#include <chrono>
namespace Core {
namespace Device {
namespace SerialDataTransfer {
class Controller;
};
namespace PictureProcessingUnit {
class Processor;
};
namespace Interrupt {
class Controller;
};
namespace Timer {
class Controller;
};
namespace JoypadInput {
class Controller;
};
namespace Sound {
class Controller;
};
namespace DirectMemoryAccess {
class Controller;
};
}
namespace ROM {
class Cartridge;
namespace BOOT {
class ROM;
}
};
namespace Memory {
class Range {
const uint32_t start;
const uint32_t length;
public:
Range(uint32_t start, uint32_t length);
~Range();
std::optional<uint32_t> contains(uint32_t address) const;
};
// https://gbdev.io/pandocs/#memory-map
const Range ROMBank00 = Range(0x0, 0x4000);
const Range ROMBank01_N = Range(0x4000, 0x4000);
const Range VideoRAM = Range(0x8000, 0x2000);
const Range ExternalRAM = Range(0xA000, 0x2000);
const Range WorkRAMBank00 = Range(0xC000, 0x1000);
const Range WorkRAMBank01_N = Range(0xD000, 0x1000);
const Range EchoRAM = Range(0xE000, 0x1E00);
const Range SpriteAttributeTable = Range(0xFE00, 0xA0);
const Range NotUsable = Range(0xFEA0, 0x60);
const Range I_ORegisters = Range(0xFF00, 0x80);
const Range HighRAM = Range(0xFF80, 0x7F);
namespace SpeedSwitch {
enum PrepareSwitch {
No = 0x0,
Prepare = 0x1,
};
enum Speed {
Normal = 0x0,
Double = 0x1,
};
union KEY1 {
uint8_t _value;
struct {
uint8_t _prepareSwitch : 1;
uint8_t unused : 6;
uint8_t _currentSpeed : 1;
};
KEY1() : _value(0x0) {};
PrepareSwitch prepareSwitch() const { return PrepareSwitch(_prepareSwitch); }
Speed currentSpeed() const { return Speed(_currentSpeed); }
void toggleSpeed() { _prepareSwitch = 0; _currentSpeed = !_currentSpeed; }
};
};
const Range KEY1AddressRange = Range(0xFF4D, 0x1);
union SVBK {
uint8_t _value;
struct {
uint8_t WRAMBank : 3;
uint8_t unused : 5;
};
SVBK() : _value(0x1) {};
};
const Core::Memory::Range SVBKRegisterRange = Core::Memory::Range(0xFF70, 0x1);
class BankController {
protected:
Common::Logs::Logger logger;
std::unique_ptr<Core::ROM::Cartridge> &cartridge;
std::unique_ptr<Core::ROM::BOOT::ROM> &bootROM;
std::vector<uint8_t> WRAMBank;
std::unique_ptr<Core::Device::SerialDataTransfer::Controller> serialCommController;
std::unique_ptr<Core::Device::PictureProcessingUnit::Processor> &PPU;
std::unique_ptr<Core::Device::Sound::Controller> &sound;
std::array<uint8_t, 0x7F> HRAM;
std::vector<uint8_t> externalRAM;
std::unique_ptr<Core::Device::Interrupt::Controller> &interrupt;
std::unique_ptr<Core::Device::Timer::Controller> &timer;
std::unique_ptr<Core::Device::JoypadInput::Controller> &joypad;
std::unique_ptr<Core::Device::DirectMemoryAccess::Controller> &DMA;
SVBK _SVBK;
SpeedSwitch::KEY1 _KEY1;
uint8_t loadInternal(uint16_t address) const;
void storeInternal(uint16_t address, uint8_t value);
public:
BankController(Common::Logs::Level logLevel,
std::unique_ptr<Core::ROM::Cartridge> &cartridge,
std::unique_ptr<Core::ROM::BOOT::ROM> &bootROM,
std::unique_ptr<Core::Device::PictureProcessingUnit::Processor> &PPU,
std::unique_ptr<Core::Device::Sound::Controller> &sound,
std::unique_ptr<Core::Device::Interrupt::Controller> &interrupt,
std::unique_ptr<Core::Device::Timer::Controller> &timer,
std::unique_ptr<Core::Device::JoypadInput::Controller> &joypad,
std::unique_ptr<Core::Device::DirectMemoryAccess::Controller> &DMA);
~BankController();
void loadExternalRAMFromSaveFile();
void saveExternalRAM();
virtual uint8_t load(uint16_t address) const = 0;
virtual void store(uint16_t address, uint8_t value) = 0;
void handleSpeedSwitch();
SpeedSwitch::Speed currentSpeed() const;
};
namespace ROM {
const Range ROMRange = Range(0x0, 0x8000);
class Controller : public BankController {
public:
Controller(Common::Logs::Level logLevel,
std::unique_ptr<Core::ROM::Cartridge> &cartridge,
std::unique_ptr<Core::ROM::BOOT::ROM> &bootROM,
std::unique_ptr<Core::Device::PictureProcessingUnit::Processor> &PPU,
std::unique_ptr<Core::Device::Sound::Controller> &sound,
std::unique_ptr<Core::Device::Interrupt::Controller> &interrupt,
std::unique_ptr<Core::Device::Timer::Controller> &timer,
std::unique_ptr<Core::Device::JoypadInput::Controller> &joypad,
std::unique_ptr<Core::Device::DirectMemoryAccess::Controller> &DMA) : BankController(logLevel, cartridge, bootROM, PPU, sound, interrupt, timer, joypad, DMA) {};
uint8_t load(uint16_t address) const override;
void store(uint16_t address, uint8_t value) override;
};
};
namespace MBC1 {
// https://gbdev.io/pandocs/#mbc1
const Range RAMGRange = Range(0x0, 0x2000);
const Range BANK1Range = Range(0x2000, 0x2000);
const Range BANK2Range = Range(0x4000, 0x2000);
const Range ModeRange = Range(0x6000, 0x2000);
union RAMG {
uint8_t _value;
struct {
uint8_t enableAccess : 4;
uint8_t unused : 4;
};
RAMG() : _value() {}
};
union BANK1 {
uint8_t _value;
struct {
uint8_t bank1 : 5;
uint8_t unused : 3;
};
BANK1() : _value(0x1) {}
};
union BANK2 {
uint8_t _value;
struct {
uint8_t bank2 : 2;
uint8_t unused : 6;
};
BANK2() : _value() {}
};
union Mode {
uint8_t _value;
struct {
uint8_t mode : 1;
uint8_t unused : 7;
};
Mode() : _value() {}
};
class Controller : public BankController {
RAMG _RAMG;
BANK1 _BANK1;
BANK2 _BANK2;
Mode mode;
public:
Controller(Common::Logs::Level logLevel,
std::unique_ptr<Core::ROM::Cartridge> &cartridge,
std::unique_ptr<Core::ROM::BOOT::ROM> &bootROM,
std::unique_ptr<Core::Device::PictureProcessingUnit::Processor> &PPU,
std::unique_ptr<Core::Device::Sound::Controller> &sound,
std::unique_ptr<Core::Device::Interrupt::Controller> &interrupt,
std::unique_ptr<Core::Device::Timer::Controller> &timer,
std::unique_ptr<Core::Device::JoypadInput::Controller> &joypad,
std::unique_ptr<Core::Device::DirectMemoryAccess::Controller> &DMA) : BankController(logLevel, cartridge, bootROM, PPU, sound, interrupt, timer, joypad, DMA) {};
uint8_t load(uint16_t address) const override;
void store(uint16_t address, uint8_t value) override;
};
};
namespace MBC3 {
// https://gbdev.io/pandocs/#mbc3
const Range RAMG_TimerEnableRange = Range(0x0, 0x2000);
const Range ROMBANKRange = Range(0x2000, 0x2000);
const Range RAMBANK_RTCRegisterRange = Range(0x4000, 0x2000);
const Range LatchClockDataRange = Range(0x6000, 0x2000);
union ROMBANK {
uint8_t _value;
struct {
uint8_t bank1 : 7;
uint8_t unused : 1;
};
ROMBANK() : _value(0x1) {}
};
union RAMBANK {
uint8_t _value;
struct {
uint8_t bank2 : 2;
uint8_t unused : 6;
};
RAMBANK() : _value() {}
};
union RTCDH {
uint8_t _value;
struct {
uint8_t dayCounterMSB : 1;
uint8_t unused : 5;
uint8_t halt : 1;
uint8_t dayCounterCarry : 1;
};
RTCDH() : _value() {}
};
class Controller : public BankController {
MBC1::RAMG _RAMG;
ROMBANK _ROMBANK;
RAMBANK _RAMBANK_RTCRegister;
uint8_t latchClockData;
uint8_t _RTCS;
uint8_t _RTCM;
uint8_t _RTCH;
uint8_t _RTCDL;
RTCDH _RTCDH;
std::chrono::time_point<std::chrono::system_clock> lastTimePoint;
std::chrono::milliseconds calculationRemainder;
bool hasRTC;
void calculateTime(bool overrideHalt = false);
public:
Controller(Common::Logs::Level logLevel,
std::unique_ptr<Core::ROM::Cartridge> &cartridge,
std::unique_ptr<Core::ROM::BOOT::ROM> &bootROM,
std::unique_ptr<Core::Device::PictureProcessingUnit::Processor> &PPU,
std::unique_ptr<Core::Device::Sound::Controller> &sound,
std::unique_ptr<Core::Device::Interrupt::Controller> &interrupt,
std::unique_ptr<Core::Device::Timer::Controller> &timer,
std::unique_ptr<Core::Device::JoypadInput::Controller> &joypad,
std::unique_ptr<Core::Device::DirectMemoryAccess::Controller> &DMA, bool hasRTC) : BankController(logLevel, cartridge, bootROM, PPU, sound, interrupt, timer, joypad, DMA),
_RAMG(), _ROMBANK(), _RAMBANK_RTCRegister(), latchClockData(), _RTCS(), _RTCM(), _RTCH(), _RTCDL(), _RTCDH(), lastTimePoint(std::chrono::system_clock::now()), calculationRemainder(), hasRTC(hasRTC) {};
uint8_t load(uint16_t address) const override;
void store(uint16_t address, uint8_t value) override;
// http://bgb.bircd.org/rtcsave.html
std::vector<uint8_t> clockData();
void loadClockData(std::vector<uint8_t> clockData);
};
};
namespace MBC5 {
const Range ROMB0Range = Range(0x2000, 0x1000);
const Range ROMB1Range = Range(0x3000, 0x1000);
const Range RAMBRange = Range(0x4000, 0x2000);
const Range Unmapped = Range(0x6000, 0x2000);
union ROMB1 {
uint8_t _value;
struct {
uint8_t ROMBankNumberMSB : 1;
uint8_t unused : 7;
};
ROMB1() : _value() {}
};
union RAMB {
uint8_t _value;
struct {
uint8_t RAMBankNumber : 4;
uint8_t unused : 4;
};
RAMB() : _value() {}
};
class Controller : public BankController {
uint8_t RAMG;
uint8_t ROMB0;
ROMB1 _ROMB1;
RAMB _RAMB;
public:
Controller(Common::Logs::Level logLevel,
std::unique_ptr<Core::ROM::Cartridge> &cartridge,
std::unique_ptr<Core::ROM::BOOT::ROM> &bootROM,
std::unique_ptr<Core::Device::PictureProcessingUnit::Processor> &PPU,
std::unique_ptr<Core::Device::Sound::Controller> &sound,
std::unique_ptr<Core::Device::Interrupt::Controller> &interrupt,
std::unique_ptr<Core::Device::Timer::Controller> &timer,
std::unique_ptr<Core::Device::JoypadInput::Controller> &joypad,
std::unique_ptr<Core::Device::DirectMemoryAccess::Controller> &DMA) : BankController(logLevel, cartridge, bootROM, PPU, sound, interrupt, timer, joypad, DMA), RAMG(), ROMB0(0x1), _ROMB1() {};
uint8_t load(uint16_t address) const override;
void store(uint16_t address, uint8_t value) override;
};
};
class Controller {
Common::Logs::Logger logger;
std::unique_ptr<Core::ROM::Cartridge> &cartridge;
std::unique_ptr<BankController> bankController;
std::unique_ptr<Core::ROM::BOOT::ROM> bootROM;
std::unique_ptr<Core::Device::PictureProcessingUnit::Processor> &PPU;
std::unique_ptr<Core::Device::Sound::Controller> &sound;
std::unique_ptr<Core::Device::Interrupt::Controller> &interrupt;
std::unique_ptr<Core::Device::Timer::Controller> &timer;
std::unique_ptr<Core::Device::JoypadInput::Controller> &joypad;
std::unique_ptr<Core::Device::DirectMemoryAccess::Controller> &DMA;
uint8_t cyclesCurrentInstruction;
public:
Controller(Common::Logs::Level logLevel,
std::unique_ptr<Core::ROM::Cartridge> &cartridge,
std::unique_ptr<Core::Device::PictureProcessingUnit::Processor> &PPU,
std::unique_ptr<Core::Device::Sound::Controller> &sound,
std::unique_ptr<Core::Device::Interrupt::Controller> &interrupt,
std::unique_ptr<Core::Device::Timer::Controller> &timer,
std::unique_ptr<Core::Device::JoypadInput::Controller> &joypad,
std::unique_ptr<Core::Device::DirectMemoryAccess::Controller> &DMA);
~Controller();
void initialize(bool skipBootROM);
bool hasBootROM() const;
void saveExternalRAM() const;
uint8_t load(uint16_t address, bool shouldStep = true, bool hasPriority = false);
void store(uint16_t address, uint8_t value, bool shouldStep = true, bool hasPriority = false);
uint16_t loadDoubleWord(uint16_t address, bool shouldStep = true);
void storeDoubleWord(uint16_t address, uint16_t value, bool shouldStep = true);
void beginCurrentInstruction();
void step(uint8_t cycles);
uint8_t elapsedCycles() const;
void handleSpeedSwitch();
};
};
};
| [
"renzo@crisostomo.me"
] | renzo@crisostomo.me |
eabd8c7c627f28030078e69dfb3354993b5ae949 | 7924247523ffc4c8ad89f725756a4ec1056f6479 | /LINK_LIST/heap.cpp | b09d724a95b2c20770a91ebb44630d50527ad1c2 | [] | no_license | badhon1512/DataStructure | cacba7268a8de567189da51ad5dca8c6cb4dfd4a | 1d076087944f1b58584824a0a520fed88bbbdbb5 | refs/heads/main | 2023-03-13T13:55:49.905555 | 2021-03-04T12:27:08 | 2021-03-04T12:27:08 | 344,465,494 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,498 | cpp | #include<iostream>
using namespace std;
int left(int i)
{
return 2*i;
}
int right(int i)
{
return 2 * i + 1;
}
int root(int i)
{
return i/2;
}
int maxHeap(int h[], int heapSize)
{
int i,p;
for(i=heapSize;i>1;i--)
{
p=root(i);
cout<<"i= "<<i<<"\n"<<"p= "<<p<<"\n"<<"h[i]= "<<h[i]<<"\n"<<"h[p]= "<<endl;
if(h[p]<h[i])
{
return 0;
}
}
return 1;
}
void maxHeapify(int heap[],int heapSize, int i)
{
int l, r, largest, t;
l=left(i);
r=right(i);
if(l<=heapSize&&heap[l]>heap[i])
{
largest = l;
}
else
{
largest = i;
}
if(r<=heapSize&&heap[r]>heap[largest])
{
largest=r;
}
if(largest!=i)
{
t=heap[i];
heap[i]=heap[largest];
heap[largest]=t;
maxHeapify(heap,heapSize,largest);
}
}
void buildMaxHeap(int heap[],int heapSize)
{
int i;
for(i=heapSize/2;i>=1;i--)
{
maxHeapify(heap,heapSize,i);
}
}
void printHeap(int heap[], int heapSize)
{
int i;
for(i=1;i<=heapSize;i++)
{
cout<<heap[i]<<" ";
}
cout<<"\n"<<endl;
}
int main()
{
int h,i,r;
cout<<"enter size"<<endl;
cin>>h;
int H[h];
for(i=1;i<=h;i++)
{
cin>>H[i];
}
cout<<endl;
for(i=0;i<=h;i++)
{
cout<<H[i]<<" ";
}
cout<<endl;
printHeap(H,h);
//maxHeapify(H,h,3);
buildMaxHeap(H,h);
printHeap(H,h);
return 0;
}
| [
"badhon1512@gmail.com"
] | badhon1512@gmail.com |
1eb481df74005172cfdba7a79d56b4a122062dd9 | 44ab57520bb1a9b48045cb1ee9baee8816b44a5b | /AssistTesting/Code/Editor/ModelEditor/ModelEditorAssistTesting/TestingLib.cpp | 6438cc93932a95dfea8452a79ac4174a09410c59 | [
"BSD-3-Clause"
] | permissive | WuyangPeng/Engine | d5d81fd4ec18795679ce99552ab9809f3b205409 | 738fde5660449e87ccd4f4878f7bf2a443ae9f1f | refs/heads/master | 2023-08-17T17:01:41.765963 | 2023-08-16T07:27:05 | 2023-08-16T07:27:05 | 246,266,843 | 10 | 0 | null | null | null | null | GB18030 | C++ | false | false | 281 | cpp | /// Copyright (c) 2010-2023
/// Threading Core Render Engine
///
/// 作者:彭武阳,彭晔恩,彭晔泽
/// 联系作者:94458936@qq.com
///
/// 标准:std:c++20
/// 版本:0.9.1.2 (2023/07/31 19:55)
#include "System/SystemLib.h"
#include "CoreTools/CoreToolsLib.h"
| [
"94458936@qq.com"
] | 94458936@qq.com |
f01b947ac78a5c294a042d5e637f10640bf3b82e | 7ecf0f2287bd5561d76571d41a51623e4566f75c | /SFML/PauseState.cpp | 8e6fb4eaffc09e32bce959fbf7a7cf1fc8f8b13b | [] | no_license | jeffOttar/SFML | 8794ef2f0ccf95e47cc83e1e10e649fb1fbcc110 | 32ff327505eb475c9b23f54b599e071a805f8302 | refs/heads/master | 2021-09-28T07:38:53.329978 | 2018-10-05T14:23:14 | 2018-10-05T14:23:14 | 151,723,442 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,766 | cpp | /**
* @file
* @author Jeff Ottar-
* @version 1.0
*
*
* @section DESCRIPTION
* < >
*
*
* @section LICENSE
*
*
* Copyright 2018
* Permission to use, copy, modify, and/or distribute this software for
* any purpose with or without fee is hereby granted, provided that the
* above copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
* @section Academic Integrity
* I certify that this work is solely my own and complies with
* NBCC Academic Integrity Policy (policy 1111)
*/
#include "PauseState.h"
#include "Utility.h"
#include "FontManager.h"
PauseState::PauseState(GEX::StateStack & stack, Context context) :
State(stack, context),
_backgroundSprite(),
_pausedText(),
_instructionText()
{
//set up the paused text
_pausedText.setFont(GEX::FontManager::getInstance().get(GEX::FontID::Main));
_pausedText.setString("Game Paused");
_pausedText.setCharacterSize(80);
centerOrigin(_pausedText);
//set up the instruction text
_instructionText.setFont(GEX::FontManager::getInstance().get(GEX::FontID::Main));
_instructionText.setString("(Press Backspace to return to the main menu)");
centerOrigin(_instructionText);
//set position of the text
sf::Vector2f viewSize = context.window->getView().getSize();
_pausedText.setPosition(0.5f * viewSize.x, 0.4f * viewSize.y);
_instructionText.setPosition(0.5f * viewSize.x, 0.6f * viewSize.y);
}
void PauseState::draw()
{
sf::RenderWindow& window = *getContext().window;
window.setView(window.getDefaultView());
sf::RectangleShape backgroundShape;
backgroundShape.setFillColor(sf::Color(0, 0, 0, 150));
backgroundShape.setSize(window.getView().getSize());
window.draw(backgroundShape);
window.draw(_pausedText);
window.draw(_instructionText);
}
bool PauseState::update(sf::Time dt)
{
return false;
}
bool PauseState::handleEvent(const sf::Event & event)
{
if (event.type != sf::Event::KeyPressed)
{
return false;
}
if (event.key.code == sf::Keyboard::Escape)
{
//if you press escape return to the game by popping the stack with the pausestate on it
requestStackPop();
}
if (event.key.code == sf::Keyboard::BackSpace)
{
//clear the stack and go to the menu if backspace pressed
requestStackClear();
requestStackPush(GEX::StateID::Menu);
}
return false;
}
| [
"jeffery1299@hotmail.com"
] | jeffery1299@hotmail.com |
f2c7762da082347263226fa2d891c4999d582798 | b37f97a79555d77f39aff73633bda8a5b469c6fe | /test01/addperson.h | 81375797f5191c98cd49e04cf71428516d0365e7 | [] | no_license | OrangeQing/practice | 1f9b3b49aaa626b7e192e4fae1a7966b0a0e1f93 | 4ce45e2ad838621e1f910c47211ed55da9c0d38b | refs/heads/master | 2022-03-22T21:04:23.379428 | 2019-11-03T00:51:42 | 2019-11-03T00:51:42 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 307 | h | #ifndef ADDPERSON_H
#define ADDPERSON_H
namespace Ui {
class AddPerson;
}
class AddPerson : public QDialog
{
Q_OBJECT
public:
explicit AddPerson(QWidget *parent = 0);
~AddPerson();
private slots:
void on_cancelBtn_clicked();
private:
Ui::AddPerson *ui;
};
#endif // ADDPERSON_H
| [
"1240091086@qq.com"
] | 1240091086@qq.com |
f4cec2218f92a29bfc98e84cf99cce6375ecefca | 7f88f6ef7fe43cdcfe41984a8952f876dec1cd47 | /16927.cpp | 402fcc4b51fa27f2fa41aeb3f43333dcc6109c7b | [] | no_license | skleee/boj-ps | 7498ca4b1fc892caafec6a6620bd9968aff0f6f0 | 818e36754d20c2dccfcf641a7d47dd1f0c087fd1 | refs/heads/master | 2020-07-25T22:14:10.971137 | 2020-03-08T17:11:38 | 2020-03-08T17:11:38 | 208,439,076 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,149 | cpp | #include <iostream>
#include <algorithm>
#pragma warning(disable:4996)
/*
16927. 배열돌리기2
*/
using namespace std;
int N, M, R, map[300][300];
void rotate() {
int group = min(M, N) / 2; // 그룹의 개수
for (int k = 0; k < group; k++) {
int rtcnt = R % ((N + M - 2 - 4 * k) * 2); // 그룹 안 숫자의 개수
while (rtcnt--) {
int tmp = map[k][k];
for (int i = k + 1; i < M - k; i++) {
map[k][i - 1] = map[k][i]; // top
}
for (int i = k + 1; i < N - k; i++) {
map[i - 1][M - k - 1] = map[i][M - k - 1]; // right
}
for (int i = M - k - 2; i >= k; i--) {
map[N - k - 1][i + 1] = map[N - k - 1][i]; // bottom
}
for (int i = N - k - 2; i > k; i--) {
map[i + 1][k] = map[i][k]; // left
}
map[k + 1][k] = tmp;
}
}
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);cout.tie(NULL);
cin >> N >> M >> R;
for (int i = 0; i < N; i++) {
for (int j = 0; j < M; j++) {
int a;
cin >> a;
map[i][j] = a;
}
}
rotate();
for (int i = 0; i < N; i++) {
for (int j = 0; j < M; j++) {
cout << map[i][j] << " ";
}
cout << "\n";
}
cout << "\n";
return 0;
} | [
"leesk1027@gmail.com"
] | leesk1027@gmail.com |
76aa4685ccbf16eec2434cc5df11c69c8b5d76b1 | 8fdea23d0eb541bb076f77f9ba02ebf5446de1a0 | /src/CloudBackground.h | 7b8f98a6e79e0328474cba74f769a80a34df97d1 | [] | no_license | brannondorsey/LEDWallInteractive | 928790a7bf1c54f986df6048c6a42aeff74a95f2 | c8d582061c3811b738ddfe11a06c1d7363ada96e | refs/heads/master | 2021-01-10T14:21:03.476893 | 2016-02-08T18:30:32 | 2016-02-08T18:30:32 | 50,591,829 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,490 | h | #pragma once
#include "ofMain.h"
class CloudBackground
{
public:
float frequency;
ofColor cloudColor;
ofEasyCam camera;
ofShader shader;
ofImage noiseImage;
ofFbo fbo;
int width;
int height;
int minFrequency;
int maxFrequency;
void setup(int width_, int height_)
{
minFrequency = 3.0f;
maxFrequency = 7.0f;
width = width_;
height = height_;
ofSetLogLevel(OF_LOG_VERBOSE);
frequency = minFrequency;
cloudColor = ofColor::black;
shader.load("RayMarchingCloudsVolumeofCamera");
ofDisableArbTex();
noiseImage.loadImage("NoiseForClouds.png");
noiseImage.getTextureReference().setTextureWrap( GL_REPEAT, GL_REPEAT );
ofEnableArbTex();
camera.setAutoDistance( false );
camera.setGlobalPosition( ofVec3f(0.00326601, 4.02035, 0.311073) );
camera.lookAt( ofVec3f(0,0,0) );
camera.setNearClip( 0.0001f );
camera.setFarClip( 1024 );
fbo.allocate(width, height);
fbo.begin();
ofClear(0, 0, 0, 0);
fbo.end();
}
void update()
{
frequency+=0.00051;
}
void draw()
{
ofPushStyle();
fbo.begin();
ofClear(ofColor::white);
camera.begin();
ofEnableAlphaBlending();
shader.begin();
shader.setUniform1f("aspect", (float)width / height );
shader.setUniform1f("fovYScale", tan( ofDegToRad(camera.getFov())/2 ) );
shader.setUniform1f("time", ofGetElapsedTimef() );
shader.setUniform2f("resolution", width*2, height*2 );
shader.setUniformTexture("noiseTexture", noiseImage, 0 );
shader.setUniform1f("frequency", frequency );
ofFloatColor cloudBaseColor = cloudColor;
shader.setUniform4fv("cloudBaseColor", cloudBaseColor.v );
ofRect( -1, -1, 2, 2 );
shader.end();
camera.end();
fbo.end();
ofPopStyle();
fbo.draw(0, 0);
}
};
| [
"brannon@brannondorsey.com"
] | brannon@brannondorsey.com |
6b17791a459279a2756a741f1ed46e4613c5499e | be7ee28aa3149dd6045f74b0fec2ac0b3a855e4e | /1110.delete-nodes-and-return-forest.cpp | 8bdc713577121db817d2afebad0d78df2f76aebb | [] | no_license | Okamoto-001/GoGoGo | a56ee2e6fa055a1a7a6d9497a4af53a04190eb42 | 383a0d05037b239ec3e4b4104dce41733c9aca19 | refs/heads/master | 2020-09-16T19:56:31.892313 | 2020-01-27T04:05:00 | 2020-01-27T04:05:00 | 223,874,412 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,363 | cpp | /*
* @lc app=leetcode id=1110 lang=cpp
*
* [1110] Delete Nodes And Return Forest
*
* https://leetcode.com/problems/delete-nodes-and-return-forest/description/
*
* algorithms
* Medium (64.87%)
* Likes: 593
* Dislikes: 22
* Total Accepted: 31.8K
* Total Submissions: 48.9K
* Testcase Example: '[1,2,3,4,5,6,7]\n[3,5]'
*
* Given the root of a binary tree, each node in the tree has a distinct
* value.
*
* After deleting all nodes with a value in to_delete, we are left with a
* forest (a disjoint union of trees).
*
* Return the roots of the trees in the remaining forest. You may return the
* result in any order.
*
*
* Example 1:
*
*
*
*
* Input: root = [1,2,3,4,5,6,7], to_delete = [3,5]
* Output: [[1,2,null,4],[6],[7]]
*
*
*
* Constraints:
*
*
* The number of nodes in the given tree is at most 1000.
* Each node has a distinct value between 1 and 1000.
* to_delete.length <= 1000
* to_delete contains distinct values between 1 and 1000.
*
*/
// @lc code=start
/**
* Definition for a binary tree node.
* struct TreeNode {
* int val;
* TreeNode *left;
* TreeNode *right;
* TreeNode(int x) : val(x), left(NULL), right(NULL) {}
* };
*/
class Solution {
public:
vector<TreeNode*> delNodes(TreeNode* root, vector<int>& to_delete) {
}
};
// @lc code=end
| [
"xwcheng497@gmail.com"
] | xwcheng497@gmail.com |
7d1c2c751a4f8d9c524f8f827d914cca5c1ce3d7 | 648a0e5429d20c89f22e1d8ae8ee8891f9e09323 | /Joy PS2/PS2/PS2.ino | 83512e070fd4d9201d531be284208a1dcaf045c2 | [] | no_license | napsudtay/aduino | 109f211373ae1afb2385b6e260bebbf506bacc6b | 924e812486aab34a1de17844700a874c70b485e9 | refs/heads/master | 2021-06-16T08:36:48.034828 | 2017-05-02T16:15:50 | 2017-05-02T16:15:50 | 38,966,525 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 7,070 | ino | /*
arduino ติดต่อ JOY PS2 , arduino with JOY PS2
ตัวอย่างนี้ ง่ายกว่าที่คุณคิด มาดูหัวต่อ PS2 กันก่อนนะครับ
สามารถนำไปประยุกต์ไปควบคุมหุ่นยนต์หรืองานด้านอื่นๆ ได้ครับ
จากภาพนะครับมีสายทั้งหมด 8 เส้นนะครับแต่ใช้จริงๆ 6 เล้นนะครับ
เส้นที่ใช้นะครับ
ขา 1 ขา data
ขา2 command
ขา 4 ขา GND
ขา 5 VCC 3.3 V ห้ามจ่าย 5 V นะครับ
ขา 6 ขา acttion
ขา 7 clock
เกิดคำถามว่าแล้วจะต่อกับไมโครยังไง ต้องตัดหัวของ joy ps2 ออกหรือปล่าว
ตอบ นะครับไม่ต้องตัดหัวออกครับ มีadapter แปลงขายเพื่อต่อครับ แต่มีวิธีที่ง่ายกว่านั้นคือต่อสายตัวเมียๆเข้ากับ joyได้เลยมีภาพให้ดูครับ
แล้วอีกฝั่งนึงก็ไปต่อกับ arduino ครับ
ตรงนี้ขาที่จะไปต่อกับ arduino ครับ
ขา 1 ขา data ต่อกับ arduino ขา//12
ขา2 command ต่อกับ arduino ขา //11
ขา 4 ขา GND ต่อกับ arduino ขา GND
ขา 5 VCC 3.3 V ห้ามจ่าย 5 V นะครับ ต่อกับ arduino 3.3V
ขา 6 ขา acttion ต่อกับ arduino ขา //10
ขา 7 clock ต่อกับ arduino ขา//13
*/
#include <math.h>
#include <stdio.h>
#include <avr/io.h>
//#define LED_PIN 13
//#define DELAY(wait) digitalWrite(LED_PIN,LOW); delay(wait); digitalWrite(LED_PIN,HIGH);
/* These are AVR PORTB pins, +8 to convert to Arduino pins */
#define PS2clk 5 //13
#define PS2cmd 3 //11
#define PS2att 2//10
#define PS2dat 4//12
#define PS2PORT PORTB
#define PS2IN PINB
#define CTRL_CLK 20
#define CTRL_BYTE_DELAY 20
//These are our button constants
#define PSB_SELECT 0x01
#define PSB_L3 0x02
#define PSB_R3 0x04
#define PSB_START 0x08
#define PSB_PAD_UP 0x10
#define PSB_PAD_RIGHT 0x20
#define PSB_PAD_DOWN 0x40
#define PSB_PAD_LEFT 0x80
#define PSB_L2 0x100
#define PSB_R2 0x200
#define PSB_L1 0x400
#define PSB_R1 0x800
#define PSB_GREEN 0x1000
#define PSB_RED 0x2000
#define PSB_BLUE 0x4000
#define PSB_PINK 0x8000
#define SET(x,y) (x|=(1<<y))
#define CLR(x,y) (x&=(~(1<<y)))
#define CHK(x,y) (x & (1<<y))
#define TOG(x,y) (x^=(1<<y))
boolean PSButton();
unsigned char PS2data[9];
void read_gamepad();
void config_gampad();
unsigned char get_gamepad_mode();
unsigned char i;
void setup() {
// randomSeed(analogRead(0));
Serial.begin(9600);
// pinMode(LED_PIN,OUTPUT);
// digitalWrite(LED_PIN,HIGH);
pinMode(PS2clk+8,OUTPUT);
pinMode(PS2att+8,OUTPUT);
pinMode(PS2cmd+8,OUTPUT);
pinMode(PS2dat+8,INPUT);
digitalWrite(PS2dat+8,HIGH);
config_gampad();
}
void loop () {
while(1)
{
delay(80) ;
read_gamepad();
readkey () ;
}
}
boolean PSButton(unsigned int button) {
int byte = 3;
if (button >= 0x100) {
byte = 4;
button = button >> 8;
}
if (~PS2data[byte] & button)
return true;
else
return false;
}
unsigned char _gamepad_shiftinout (char byte) {
unsigned char tmp = 0;
for(i=0;i<8;i++) {
if(CHK(byte,i)) SET(PS2PORT,PS2cmd);
else CLR(PS2PORT,PS2cmd);
CLR(PS2PORT,PS2clk);
delayMicroseconds(CTRL_CLK);
if(CHK(PS2IN,PS2dat)) SET(tmp,i);
SET(PS2PORT,PS2clk);
}
SET(PS2PORT,PS2cmd);
delayMicroseconds(CTRL_BYTE_DELAY);
return tmp;
}
void _gamepad_shiftout (char byte) {
for(i=0;i<8;i++) {
if(CHK(byte,i)) SET(PS2PORT,PS2cmd);
else CLR(PS2PORT,PS2cmd);
CLR(PS2PORT,PS2clk);
delayMicroseconds(CTRL_CLK);
SET(PS2PORT,PS2clk);
//delayMicroseconds(CTRL_CLK);
}
SET(PS2PORT,PS2cmd);
delayMicroseconds(CTRL_BYTE_DELAY);
}
unsigned char _gamepad_shiftin() {
unsigned char tmp = 0;
for(i=0;i<8;i++) {
CLR(PS2PORT,PS2cmd);
CLR(PS2PORT,PS2clk);
delayMicroseconds(CTRL_CLK);
if(CHK(PS2IN,PS2dat)) SET(tmp,i);
SET(PS2PORT,PS2clk);
delayMicroseconds(CTRL_CLK);
}
SET(PS2PORT,PS2cmd);
delayMicroseconds(CTRL_BYTE_DELAY);
return tmp;
}
void read_gamepad() {
SET(PS2PORT,PS2cmd);
SET(PS2PORT,PS2clk);
CLR(PS2PORT,PS2att); // low enable joystick
delayMicroseconds(CTRL_BYTE_DELAY);
char dword[9] = {0x01,0x42,0,0,0,0,0,0,0};
for (int i = 0; i<9; i++) {
PS2data[i] = _gamepad_shiftinout(dword[i]);
}
SET(PS2PORT,PS2att); // HI disable joystick
}
unsigned char get_gamepad_mode() {
SET(PS2PORT,PS2cmd);
SET(PS2PORT,PS2clk);
CLR(PS2PORT,PS2att); // low enable joystick
_gamepad_shiftout(0x01);
unsigned char x = _gamepad_shiftin();
SET(PS2PORT,PS2att); // HI disable joystick
return x;
}
void config_gampad() {
SET(PS2PORT,PS2cmd);
SET(PS2PORT,PS2clk);
CLR(PS2PORT,PS2att); // low enable joystick
_gamepad_shiftout(0x01);
_gamepad_shiftout(0x43);
_gamepad_shiftout(0x00);
_gamepad_shiftout(0x01);
_gamepad_shiftout(0x00);
// Lock to Analog Mode on Stick
_gamepad_shiftout(0x01);
_gamepad_shiftout(0x44);
_gamepad_shiftout(0x00);
_gamepad_shiftout(0x01);
_gamepad_shiftout(0x03);
_gamepad_shiftout(0x00);
_gamepad_shiftout(0x00);
_gamepad_shiftout(0x00);
_gamepad_shiftout(0x00);
// Vibration
/*
_gamepad_shiftout(0x01);
_gamepad_shiftout(0x4D);
_gamepad_shiftout(0x00);
_gamepad_shiftout(0x00);
_gamepad_shiftout(0x01);
*/
_gamepad_shiftout(0x01);
_gamepad_shiftout(0x4F);
_gamepad_shiftout(0x00);
_gamepad_shiftout(0xFF);
_gamepad_shiftout(0xFF);
_gamepad_shiftout(0x03);
_gamepad_shiftout(0x00);
_gamepad_shiftout(0x00);
_gamepad_shiftout(0x00);
_gamepad_shiftout(0x01);
_gamepad_shiftout(0x43);
_gamepad_shiftout(0x00);
_gamepad_shiftout(0x00);
_gamepad_shiftout(0x5A);
_gamepad_shiftout(0x5A);
_gamepad_shiftout(0x5A);
_gamepad_shiftout(0x5A);
_gamepad_shiftout(0x5A);
SET(PS2PORT,PS2att);
}
void readkey ()
{
if(PSButton(PSB_PAD_UP))
{
Serial.println("1");
}
else if(PSButton(PSB_SELECT))
{
Serial.println("x");
}
else if(PSButton(PSB_PAD_DOWN))
{
Serial.println("2");
}
else if(PSButton(PSB_PAD_RIGHT))
{
Serial.println("4");
}
else if(PSButton(PSB_PAD_LEFT))
{
Serial.println("3");
}
else if(PSButton(PSB_L3))
{
Serial.println("L3\n");
}
else if(PSButton(PSB_R3))
{
Serial.println("R3\n");
}
else if(PSButton(PSB_L1))
{
Serial.println("a");
}
else if(PSButton(PSB_R1))
{
Serial.println("c");
}
else if(PSButton(PSB_L2))
{
Serial.println("b");
}
else if(PSButton(PSB_R2))
{
Serial.println("d");
}
else if(PSButton(PSB_GREEN))
{
Serial.println("5");
}
else if(PSButton(PSB_RED))
{
Serial.println("8");
}
else if(PSButton(PSB_PINK))
{
Serial.println("7");
}
else if(PSButton(PSB_BLUE))
{
Serial.println("6");
}
else if(PSButton(PSB_START))
{
Serial.println("z");
}
else{ Serial.println("PLS control JOY");}
}
| [
"sudtayonnuam@sudtays-MacBook-Pro.local"
] | sudtayonnuam@sudtays-MacBook-Pro.local |
17b25422643da83450aae79c7035761ed73156f5 | edcfa044f904b2e79a3924972e805694d3e143db | /Mosquitto_esp8266_NodeRED_AWS_With_BLENO_Uploading_Only_11_Aug_/Mosquitto_esp8266_NodeRED_AWS_With_BLENO_Uploading_Only_11_Aug_.ino | 6148a2bafcb2b1b0f57b9c40b40c91ddee6a544b | [] | no_license | xidameng/Arduino-Projects | 6eb18ed15f5775c812068ab102760518d59447dd | 18bb8178b09d6b6ac22843d7f2ee41339e517768 | refs/heads/master | 2020-04-07T01:28:46.522381 | 2018-11-17T02:50:03 | 2018-11-17T02:50:03 | 157,942,687 | 1 | 1 | null | 2018-11-17T02:50:04 | 2018-11-17T02:18:14 | C++ | UTF-8 | C++ | false | false | 4,444 | ino | /*****
All the resources for this project:
http://randomnerdtutorials.com/
THIS IS THE FIRST WORKING PROJECT CREATED BY XI MENG
for real-time uploading sensor data to the cloud
*****/
#include <ESP8266WiFi.h>
#include <PubSubClient.h>
#include <Wire.h>
// Change the credentials below, so your ESP8266 connects to your router
const char* ssid = "SimonMiix320";
const char* password = "82517802";
// Change the variable to your Raspberry Pi IP address, so it connects to your MQTT broker
const char* mqttServer = "13.229.143.144"; //127.0.0.1 is the localhost
const int mqttPort = 1883;
//const char* mqttServer = "m10.cloudmqtt.com";
//const int mqttPort = 18647;
//const char* mqttUser = "xjerpjsc"; //use to access the mqtt account
//const char* mqttPassword = "Fg5cFpOtwf2F"; //^^^^^^^^^^^^^^^^^^^^^^^^^^^
WiFiClient espClient;
PubSubClient client(espClient);
// Don't change the function below. This functions connects your ESP8266 to your router
void setup_wifi() {
delay(10);
// We start by connecting to a WiFi network
Serial.println();
Serial.print("Connecting to ");
Serial.println(ssid);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("");
Serial.print("WiFi connected - ESP IP address: ");
Serial.println(WiFi.localIP());
}
//In "Callback" function, ESP listening for command via WIFI
// This functions is executed when some device publishes a message to a topic that your ESP8266 is subscribed to
// Change the function below to add logic to your program, so when a device publishes a message to a topic that
// your ESP8266 is subscribed you can actually do something
void initialise_MQTT() {
client.setServer(mqttServer, mqttPort);
while (!client.connected()) {
Serial.println("Connecting to MQTT...");
if (client.connect("ESP8266Client")) {
Serial.println("connected");
//strip.setPixelColor(0, 0, 255, 0); // Green, means connected to MQTT server
//strip.show();
} else {
Serial.print("failed with state ");
Serial.print(client.state());
//strip.setPixelColor(0, 255, 255, 0); // Yellow means MQTT connection issue
//strip.show();
delay(2000);
}
}
}
// This functions reconnects your ESP8266 to your MQTT broker
// Change the function below if you want to subscribe to more topics with your ESP8266
void reconnect() {
client.setServer(mqttServer, mqttPort);
// Loop until we're reconnected
while (!client.connected()) {
Serial.print("Attempting MQTT connection...");
// Attempt to connect
if (client.connect("ESP8266Client")) {
Serial.println("connected");
// Subscribe or resubscribe to a topic
// You can subscribe to more topics (to control more LEDs in this example)
client.subscribe("room/lamp");
} else {
Serial.print("failed, rc=");
Serial.print(client.state());
Serial.println(" try again in 5 seconds");
// Wait 5 seconds before retrying
delay(5000);
}
}
}
// The setup function sets your ESP GPIOs to Outputs, starts the serial communication at a baud rate of 115200
void setup() {
Serial.begin(115200);
setup_wifi();
initialise_MQTT();
pinMode(LED_BUILTIN, OUTPUT);
pinMode(A0, INPUT); // Setup for Analog Reading from pin A0
}
double ecg;
void loop() {
if (!client.connected()) {
reconnect();
}
if(!client.loop())
client.connect("ESP8266Client");
if(Serial.available()>0){
ecg = Serial.read();
Serial.println(ecg);
}
else{
Serial.println("waiting for ecg data...");
//blink once and wait for 0.1 second to check for serial buffer
digitalWrite(LED_BUILTIN,HIGH);
delay(100);
digitalWrite(LED_BUILTIN,LOW);
delay(100);
}
char ecgbuffer[7];
dtostrf(ecg,6,0,ecgbuffer);
// Publishes ECG value
//PUBLISHING!!
client.publish("wearable/ecg", ecgbuffer);
Serial.print("T: ");
Serial.println(String(tempAvg,1));//tempAvg is the value(float), the 1 behind mean 1 decimal place
char tempbuffer[7];//A buffer that store the location of each character in the String
dtostrf(tempAvg, 6, 1, tempbuffer);//Convert Float to String, tempAvg store data, 6 is the width(how many bytes), 1 is precision(how many decimal place), tempbuffer is a pointer
// Publishes Temperature value
client.publish("wearable/temp", tempbuffer);
}
| [
"xidameng@gmail.com"
] | xidameng@gmail.com |
0bb43129d94f03d67d8e7d4eb150896631171397 | 11e65430e08a401b27977c263f1523b9c0e9c7f8 | /main.cpp | 3a46bed3abf61d59c8e0689aaf5cc39c028ea064 | [] | no_license | Ga-vin/CanRegConfigurationTool | c5089e2e8a6880db28ad056e1bd53b8d16039027 | b783bd2243d8f3ca498e850d1815a1055cef977d | refs/heads/master | 2021-01-20T19:52:43.779993 | 2016-08-01T16:09:45 | 2016-08-01T16:09:45 | 64,231,138 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 316 | cpp | #include <QApplication>
#include <QTextCodec>
#include "canregdlg.h"
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QTextCodec::setCodecForTr(QTextCodec::codecForName("utf-8"));
/* Todo here */
CanRegDlg *p_window = new CanRegDlg;
p_window->show();
return app.exec();
}
| [
"gavin_8724@163.com"
] | gavin_8724@163.com |
372b13037b81ffa40af4aeb20b7aac9db4667659 | 647d3cf8c301cc4351c5f6b7a3adeb0c294ce849 | /Others/less/old/2021-4-10/P1082.cpp | 5140c27bad5f3939b5147ddc1ebbd001218794c2 | [] | no_license | schtonn/Code | d6157e7d8ee8256159246c4765122e188ecbc48d | ba4e4e4511d37ec8398f4015fddf938f6b9d8852 | refs/heads/master | 2022-08-10T14:37:32.655034 | 2022-07-25T14:36:03 | 2022-07-25T14:36:03 | 243,902,585 | 0 | 0 | null | 2020-03-15T09:50:27 | 2020-02-29T04:13:41 | null | UTF-8 | C++ | false | false | 279 | cpp | #include "bits/stdc++.h"
using namespace std;
void exgcd(int a,int b,int &x,int &y){
if(!b){
x=1,y=0;
return;
}
exgcd(b,a%b,y,x);
y=y-a/b*x;
}
int main(){
int a,b,x,y;
cin>>a>>b;
exgcd(a,b,x,y);
cout<<(x+b)%b<<endl;
return 0;
} | [
"schtonn@163.com"
] | schtonn@163.com |
64ac0041f7df73a4e30916a7bcf1ea01fcb1559a | 491b89427312aa0c026db196235144bfb598cec4 | /Kade-Engine-stable/exportBONEFRIEND/release/windows/obj/src/Alphabet.cpp | d35f8ddf21ccf139fd7ef6a227be5c222865bfda | [
"Apache-2.0"
] | permissive | TrashMonkeyy/VS-Bonefriend-FNF-Source | 667fded8fa68401a9efa4063fd535c7ae1ab025d | a3f96ad52cc0dcf16c64106bfc8feb7c568046c0 | refs/heads/master | 2023-06-28T04:38:39.561357 | 2021-08-02T00:49:44 | 2021-08-02T00:49:44 | 391,771,302 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 25,404 | cpp | #include <hxcpp.h>
#ifndef INCLUDED_AlphaCharacter
#include <AlphaCharacter.h>
#endif
#ifndef INCLUDED_Alphabet
#include <Alphabet.h>
#endif
#ifndef INCLUDED_Paths
#include <Paths.h>
#endif
#ifndef INCLUDED_flixel_FlxBasic
#include <flixel/FlxBasic.h>
#endif
#ifndef INCLUDED_flixel_FlxG
#include <flixel/FlxG.h>
#endif
#ifndef INCLUDED_flixel_FlxObject
#include <flixel/FlxObject.h>
#endif
#ifndef INCLUDED_flixel_FlxSprite
#include <flixel/FlxSprite.h>
#endif
#ifndef INCLUDED_flixel_group_FlxTypedSpriteGroup
#include <flixel/group/FlxTypedSpriteGroup.h>
#endif
#ifndef INCLUDED_flixel_math_FlxMath
#include <flixel/math/FlxMath.h>
#endif
#ifndef INCLUDED_flixel_math_FlxRandom
#include <flixel/math/FlxRandom.h>
#endif
#ifndef INCLUDED_flixel_system_FlxSound
#include <flixel/system/FlxSound.h>
#endif
#ifndef INCLUDED_flixel_system_FlxSoundGroup
#include <flixel/system/FlxSoundGroup.h>
#endif
#ifndef INCLUDED_flixel_system_frontEnds_SoundFrontEnd
#include <flixel/system/frontEnds/SoundFrontEnd.h>
#endif
#ifndef INCLUDED_flixel_util_FlxTimer
#include <flixel/util/FlxTimer.h>
#endif
#ifndef INCLUDED_flixel_util_FlxTimerManager
#include <flixel/util/FlxTimerManager.h>
#endif
#ifndef INCLUDED_flixel_util_IFlxDestroyable
#include <flixel/util/IFlxDestroyable.h>
#endif
#ifndef INCLUDED_haxe_ds_List
#include <haxe/ds/List.h>
#endif
#ifndef INCLUDED_haxe_ds__List_ListNode
#include <haxe/ds/_List/ListNode.h>
#endif
HX_DEFINE_STACK_FRAME(_hx_pos_4c95a0630eaf1443_17_new,"Alphabet","new",0xc4ae3f45,"Alphabet.new","Alphabet.hx",17,0xc2e40fcb)
HX_LOCAL_STACK_FRAME(_hx_pos_4c95a0630eaf1443_76_reType,"Alphabet","reType",0x30c60648,"Alphabet.reType","Alphabet.hx",76,0xc2e40fcb)
HX_LOCAL_STACK_FRAME(_hx_pos_4c95a0630eaf1443_94_addText,"Alphabet","addText",0x712354d3,"Alphabet.addText","Alphabet.hx",94,0xc2e40fcb)
HX_LOCAL_STACK_FRAME(_hx_pos_4c95a0630eaf1443_145_doSplitWords,"Alphabet","doSplitWords",0x060ce215,"Alphabet.doSplitWords","Alphabet.hx",145,0xc2e40fcb)
HX_LOCAL_STACK_FRAME(_hx_pos_4c95a0630eaf1443_163_startTypedText,"Alphabet","startTypedText",0x740816b0,"Alphabet.startTypedText","Alphabet.hx",163,0xc2e40fcb)
HX_LOCAL_STACK_FRAME(_hx_pos_4c95a0630eaf1443_151_startTypedText,"Alphabet","startTypedText",0x740816b0,"Alphabet.startTypedText","Alphabet.hx",151,0xc2e40fcb)
static const int _hx_array_data_faea38d3_8[] = {
(int)0,
};
static const Float _hx_array_data_faea38d3_9[] = {
(Float)0,
};
static const int _hx_array_data_faea38d3_10[] = {
(int)0,
};
HX_LOCAL_STACK_FRAME(_hx_pos_4c95a0630eaf1443_253_update,"Alphabet","update",0xc3c1b444,"Alphabet.update","Alphabet.hx",253,0xc2e40fcb)
void Alphabet_obj::__construct(Float x,Float y,::String __o_text, ::Dynamic __o_bold,::hx::Null< bool > __o_typed,::hx::Null< bool > __o_shouldMove){
::String text = __o_text;
if (::hx::IsNull(__o_text)) text = HX_("",00,00,00,00);
::Dynamic bold = __o_bold;
if (::hx::IsNull(__o_bold)) bold = false;
bool typed = __o_typed.Default(false);
bool shouldMove = __o_shouldMove.Default(false);
HX_GC_STACKFRAME(&_hx_pos_4c95a0630eaf1443_17_new)
HXLINE( 148) this->personTalking = HX_("gf",1f,5a,00,00);
HXLINE( 48) this->pastY = ((Float)0);
HXLINE( 47) this->pastX = ((Float)0);
HXLINE( 45) this->isBold = false;
HXLINE( 43) this->splitWords = ::Array_obj< ::String >::__new(0);
HXLINE( 41) this->listOAlphabets = ::haxe::ds::List_obj::__alloc( HX_CTX );
HXLINE( 39) this->lastWasSpace = false;
HXLINE( 38) this->xPosResetted = false;
HXLINE( 33) this->yMulti = ((Float)1);
HXLINE( 31) this->widthOfWords = ( (Float)(::flixel::FlxG_obj::width) );
HXLINE( 29) this->_curText = HX_("",00,00,00,00);
HXLINE( 28) this->_finalText = HX_("",00,00,00,00);
HXLINE( 26) this->text = HX_("",00,00,00,00);
HXLINE( 24) this->isMenuItem = false;
HXLINE( 23) this->targetY = ((Float)0);
HXLINE( 20) this->paused = false;
HXLINE( 19) this->delay = ((Float)0.05);
HXLINE( 52) this->pastX = x;
HXLINE( 53) this->pastY = y;
HXLINE( 55) super::__construct(x,y,null());
HXLINE( 57) this->_finalText = text;
HXLINE( 58) this->text = text;
HXLINE( 59) this->isBold = ( (bool)(bold) );
HXLINE( 61) if ((text != HX_("",00,00,00,00))) {
HXLINE( 63) if (typed) {
HXLINE( 65) this->startTypedText();
}
else {
HXLINE( 69) this->addText();
}
}
}
Dynamic Alphabet_obj::__CreateEmpty() { return new Alphabet_obj; }
void *Alphabet_obj::_hx_vtable = 0;
Dynamic Alphabet_obj::__Create(::hx::DynamicArray inArgs)
{
::hx::ObjectPtr< Alphabet_obj > _hx_result = new Alphabet_obj();
_hx_result->__construct(inArgs[0],inArgs[1],inArgs[2],inArgs[3],inArgs[4],inArgs[5]);
return _hx_result;
}
bool Alphabet_obj::_hx_isInstanceOf(int inClassId) {
if (inClassId<=(int)0x567b2b93) {
if (inClassId<=(int)0x2c01639b) {
if (inClassId<=(int)0x288ce903) {
return inClassId==(int)0x00000001 || inClassId==(int)0x288ce903;
} else {
return inClassId==(int)0x2c01639b;
}
} else {
return inClassId==(int)0x567b2b93;
}
} else {
return inClassId==(int)0x7ccf8994 || inClassId==(int)0x7dab0655;
}
}
void Alphabet_obj::reType(::String text){
HX_STACKFRAME(&_hx_pos_4c95a0630eaf1443_76_reType)
HXLINE( 77) {
HXLINE( 77) ::haxe::ds::_List::ListNode _g_head = this->listOAlphabets->h;
HXDLIN( 77) while(::hx::IsNotNull( _g_head )){
HXLINE( 77) ::AlphaCharacter val = ( ( ::AlphaCharacter)(_g_head->item) );
HXDLIN( 77) _g_head = _g_head->next;
HXDLIN( 77) ::AlphaCharacter i = val;
HXLINE( 78) this->remove(i,null());
}
}
HXLINE( 79) this->_finalText = text;
HXLINE( 80) this->text = text;
HXLINE( 82) this->lastSprite = null();
HXLINE( 84) this->updateHitbox();
HXLINE( 86) this->listOAlphabets->clear();
HXLINE( 87) this->set_x(this->pastX);
HXLINE( 88) this->set_y(this->pastY);
HXLINE( 90) this->addText();
}
HX_DEFINE_DYNAMIC_FUNC1(Alphabet_obj,reType,(void))
void Alphabet_obj::addText(){
HX_GC_STACKFRAME(&_hx_pos_4c95a0630eaf1443_94_addText)
HXLINE( 95) this->doSplitWords();
HXLINE( 97) Float xPos = ( (Float)(0) );
HXLINE( 98) {
HXLINE( 98) int _g = 0;
HXDLIN( 98) ::Array< ::String > _g1 = this->splitWords;
HXDLIN( 98) while((_g < _g1->length)){
HXLINE( 98) ::String character = _g1->__get(_g);
HXDLIN( 98) _g = (_g + 1);
HXLINE( 104) bool _hx_tmp;
HXDLIN( 104) if ((character != HX_(" ",20,00,00,00))) {
HXLINE( 104) _hx_tmp = (character == HX_("-",2d,00,00,00));
}
else {
HXLINE( 104) _hx_tmp = true;
}
HXDLIN( 104) if (_hx_tmp) {
HXLINE( 106) this->lastWasSpace = true;
}
HXLINE( 109) ::String _hx_tmp1 = ::AlphaCharacter_obj::alphabet;
HXDLIN( 109) if ((_hx_tmp1.indexOf(character.toLowerCase(),null()) != -1)) {
HXLINE( 112) if (::hx::IsNotNull( this->lastSprite )) {
HXLINE( 114) Float xPos1 = this->lastSprite->x;
HXDLIN( 114) xPos = (xPos1 + this->lastSprite->get_width());
}
HXLINE( 117) if (this->lastWasSpace) {
HXLINE( 119) xPos = (xPos + 40);
HXLINE( 120) this->lastWasSpace = false;
}
HXLINE( 124) ::AlphaCharacter letter = ::AlphaCharacter_obj::__alloc( HX_CTX ,xPos,( (Float)(0) ));
HXLINE( 125) this->listOAlphabets->add(letter);
HXLINE( 127) if (this->isBold) {
HXLINE( 128) letter->createBold(character);
}
else {
HXLINE( 131) letter->createLetter(character);
}
HXLINE( 134) this->add(letter);
HXLINE( 136) this->lastSprite = letter;
}
}
}
}
HX_DEFINE_DYNAMIC_FUNC0(Alphabet_obj,addText,(void))
void Alphabet_obj::doSplitWords(){
HX_STACKFRAME(&_hx_pos_4c95a0630eaf1443_145_doSplitWords)
HXDLIN( 145) this->splitWords = this->_finalText.split(HX_("",00,00,00,00));
}
HX_DEFINE_DYNAMIC_FUNC0(Alphabet_obj,doSplitWords,(void))
void Alphabet_obj::startTypedText(){
HX_BEGIN_LOCAL_FUNC_S4(::hx::LocalFunc,_hx_Closure_0, ::Alphabet,_gthis,::Array< Float >,xPos,::Array< int >,loopNum,::Array< int >,curRow) HXARGC(1)
void _hx_run( ::flixel::util::FlxTimer tmr){
HX_GC_STACKFRAME(&_hx_pos_4c95a0630eaf1443_163_startTypedText)
HXLINE( 165) if ((_gthis->_finalText.cca(loopNum->__get(0)) == 10)) {
HXLINE( 167) ::Alphabet _gthis1 = _gthis;
HXDLIN( 167) _gthis1->yMulti = (_gthis1->yMulti + 1);
HXLINE( 168) _gthis->xPosResetted = true;
HXLINE( 169) xPos[0] = ( (Float)(0) );
HXLINE( 170) ::Array< int > curRow1 = curRow;
HXDLIN( 170) int _hx_tmp = 0;
HXDLIN( 170) curRow1[_hx_tmp] = (curRow1->__get(_hx_tmp) + 1);
}
HXLINE( 173) if ((_gthis->splitWords->__get(loopNum->__get(0)) == HX_(" ",20,00,00,00))) {
HXLINE( 175) _gthis->lastWasSpace = true;
}
HXLINE( 179) bool isNumber = (::AlphaCharacter_obj::numbers.indexOf(_gthis->splitWords->__get(loopNum->__get(0)),null()) != -1);
HXLINE( 180) bool isSymbol = (::AlphaCharacter_obj::symbols.indexOf(_gthis->splitWords->__get(loopNum->__get(0)),null()) != -1);
HXLINE( 186) bool _hx_tmp;
HXDLIN( 186) bool _hx_tmp1;
HXDLIN( 186) ::String _hx_tmp2 = ::AlphaCharacter_obj::alphabet;
HXDLIN( 186) if ((_hx_tmp2.indexOf(_gthis->splitWords->__get(loopNum->__get(0)).toLowerCase(),null()) == -1)) {
HXLINE( 186) _hx_tmp1 = isNumber;
}
else {
HXLINE( 186) _hx_tmp1 = true;
}
HXDLIN( 186) if (!(_hx_tmp1)) {
HXLINE( 186) _hx_tmp = isSymbol;
}
else {
HXLINE( 186) _hx_tmp = true;
}
HXDLIN( 186) if (_hx_tmp) {
HXLINE( 190) bool _hx_tmp;
HXDLIN( 190) if (::hx::IsNotNull( _gthis->lastSprite )) {
HXLINE( 190) _hx_tmp = !(_gthis->xPosResetted);
}
else {
HXLINE( 190) _hx_tmp = false;
}
HXDLIN( 190) if (_hx_tmp) {
HXLINE( 192) _gthis->lastSprite->updateHitbox();
HXLINE( 193) ::Array< Float > xPos1 = xPos;
HXDLIN( 193) int _hx_tmp = 0;
HXDLIN( 193) Float xPos2 = xPos1->__get(_hx_tmp);
HXDLIN( 193) xPos1[_hx_tmp] = (xPos2 + (_gthis->lastSprite->get_width() + 3));
}
else {
HXLINE( 199) _gthis->xPosResetted = false;
}
HXLINE( 202) if (_gthis->lastWasSpace) {
HXLINE( 204) ::Array< Float > xPos1 = xPos;
HXDLIN( 204) int _hx_tmp = 0;
HXDLIN( 204) xPos1[_hx_tmp] = (xPos1->__get(_hx_tmp) + 20);
HXLINE( 205) _gthis->lastWasSpace = false;
}
HXLINE( 210) ::AlphaCharacter letter = ::AlphaCharacter_obj::__alloc( HX_CTX ,xPos->__get(0),(( (Float)(55) ) * _gthis->yMulti));
HXLINE( 211) _gthis->listOAlphabets->add(letter);
HXLINE( 212) letter->row = curRow->__get(0);
HXLINE( 213) if (_gthis->isBold) {
HXLINE( 215) letter->createBold(_gthis->splitWords->__get(loopNum->__get(0)));
}
else {
HXLINE( 219) if (isNumber) {
HXLINE( 221) letter->createNumber(_gthis->splitWords->__get(loopNum->__get(0)));
}
else {
HXLINE( 223) if (isSymbol) {
HXLINE( 225) letter->createSymbol(_gthis->splitWords->__get(loopNum->__get(0)));
}
else {
HXLINE( 229) letter->createLetter(_gthis->splitWords->__get(loopNum->__get(0)));
}
}
HXLINE( 232) letter->set_x((letter->x + 90));
}
HXLINE( 235) if ((::flixel::FlxG_obj::random->_hx_float(0,100,null()) < 40)) {
HXLINE( 237) ::String daSound = HX_("GF_",60,1d,36,00);
HXLINE( 238) ::flixel::_hx_system::frontEnds::SoundFrontEnd _hx_tmp = ::flixel::FlxG_obj::sound;
HXDLIN( 238) ::String library = null();
HXDLIN( 238) _hx_tmp->play(::Paths_obj::sound((daSound + ::flixel::FlxG_obj::random->_hx_int(1,4,null())),library),null(),null(),null(),null(),null());
}
HXLINE( 241) _gthis->add(letter).StaticCast< ::flixel::FlxSprite >();
HXLINE( 243) _gthis->lastSprite = letter;
}
HXLINE( 246) ::Array< int > loopNum1 = loopNum;
HXDLIN( 246) int _hx_tmp3 = 0;
HXDLIN( 246) loopNum1[_hx_tmp3] = (loopNum1->__get(_hx_tmp3) + 1);
HXLINE( 248) tmr->time = ::flixel::FlxG_obj::random->_hx_float(((Float)0.04),((Float)0.09),null());
}
HX_END_LOCAL_FUNC1((void))
HX_GC_STACKFRAME(&_hx_pos_4c95a0630eaf1443_151_startTypedText)
HXDLIN( 151) ::Alphabet _gthis = ::hx::ObjectPtr<OBJ_>(this);
HXLINE( 152) this->_finalText = this->text;
HXLINE( 153) this->doSplitWords();
HXLINE( 157) ::Array< int > loopNum = ::Array_obj< int >::fromData( _hx_array_data_faea38d3_8,1);
HXLINE( 159) ::Array< Float > xPos = ::Array_obj< Float >::fromData( _hx_array_data_faea38d3_9,1);
HXLINE( 160) ::Array< int > curRow = ::Array_obj< int >::fromData( _hx_array_data_faea38d3_10,1);
HXLINE( 162) ::flixel::util::FlxTimer_obj::__alloc( HX_CTX ,null())->start(((Float)0.05), ::Dynamic(new _hx_Closure_0(_gthis,xPos,loopNum,curRow)),this->splitWords->length);
}
HX_DEFINE_DYNAMIC_FUNC0(Alphabet_obj,startTypedText,(void))
void Alphabet_obj::update(Float elapsed){
HX_STACKFRAME(&_hx_pos_4c95a0630eaf1443_253_update)
HXLINE( 254) if (this->isMenuItem) {
HXLINE( 256) Float scaledY = ::flixel::math::FlxMath_obj::remapToRange(this->targetY,( (Float)(0) ),( (Float)(1) ),( (Float)(0) ),((Float)1.3));
HXLINE( 258) Float a = this->y;
HXDLIN( 258) this->set_y((a + (((Float)0.30) * (((scaledY * ( (Float)(120) )) + (( (Float)(::flixel::FlxG_obj::height) ) * ((Float)0.48))) - a))));
HXLINE( 259) Float a1 = this->x;
HXDLIN( 259) this->set_x((a1 + (((Float)0.30) * (((this->targetY * ( (Float)(20) )) + 90) - a1))));
}
HXLINE( 262) this->super::update(elapsed);
}
::hx::ObjectPtr< Alphabet_obj > Alphabet_obj::__new(Float x,Float y,::String __o_text, ::Dynamic __o_bold,::hx::Null< bool > __o_typed,::hx::Null< bool > __o_shouldMove) {
::hx::ObjectPtr< Alphabet_obj > __this = new Alphabet_obj();
__this->__construct(x,y,__o_text,__o_bold,__o_typed,__o_shouldMove);
return __this;
}
::hx::ObjectPtr< Alphabet_obj > Alphabet_obj::__alloc(::hx::Ctx *_hx_ctx,Float x,Float y,::String __o_text, ::Dynamic __o_bold,::hx::Null< bool > __o_typed,::hx::Null< bool > __o_shouldMove) {
Alphabet_obj *__this = (Alphabet_obj*)(::hx::Ctx::alloc(_hx_ctx, sizeof(Alphabet_obj), true, "Alphabet"));
*(void **)__this = Alphabet_obj::_hx_vtable;
__this->__construct(x,y,__o_text,__o_bold,__o_typed,__o_shouldMove);
return __this;
}
Alphabet_obj::Alphabet_obj()
{
}
void Alphabet_obj::__Mark(HX_MARK_PARAMS)
{
HX_MARK_BEGIN_CLASS(Alphabet);
HX_MARK_MEMBER_NAME(delay,"delay");
HX_MARK_MEMBER_NAME(paused,"paused");
HX_MARK_MEMBER_NAME(targetY,"targetY");
HX_MARK_MEMBER_NAME(isMenuItem,"isMenuItem");
HX_MARK_MEMBER_NAME(text,"text");
HX_MARK_MEMBER_NAME(_finalText,"_finalText");
HX_MARK_MEMBER_NAME(_curText,"_curText");
HX_MARK_MEMBER_NAME(widthOfWords,"widthOfWords");
HX_MARK_MEMBER_NAME(yMulti,"yMulti");
HX_MARK_MEMBER_NAME(lastSprite,"lastSprite");
HX_MARK_MEMBER_NAME(xPosResetted,"xPosResetted");
HX_MARK_MEMBER_NAME(lastWasSpace,"lastWasSpace");
HX_MARK_MEMBER_NAME(listOAlphabets,"listOAlphabets");
HX_MARK_MEMBER_NAME(splitWords,"splitWords");
HX_MARK_MEMBER_NAME(isBold,"isBold");
HX_MARK_MEMBER_NAME(pastX,"pastX");
HX_MARK_MEMBER_NAME(pastY,"pastY");
HX_MARK_MEMBER_NAME(personTalking,"personTalking");
::flixel::group::FlxTypedSpriteGroup_obj::__Mark(HX_MARK_ARG);
HX_MARK_END_CLASS();
}
void Alphabet_obj::__Visit(HX_VISIT_PARAMS)
{
HX_VISIT_MEMBER_NAME(delay,"delay");
HX_VISIT_MEMBER_NAME(paused,"paused");
HX_VISIT_MEMBER_NAME(targetY,"targetY");
HX_VISIT_MEMBER_NAME(isMenuItem,"isMenuItem");
HX_VISIT_MEMBER_NAME(text,"text");
HX_VISIT_MEMBER_NAME(_finalText,"_finalText");
HX_VISIT_MEMBER_NAME(_curText,"_curText");
HX_VISIT_MEMBER_NAME(widthOfWords,"widthOfWords");
HX_VISIT_MEMBER_NAME(yMulti,"yMulti");
HX_VISIT_MEMBER_NAME(lastSprite,"lastSprite");
HX_VISIT_MEMBER_NAME(xPosResetted,"xPosResetted");
HX_VISIT_MEMBER_NAME(lastWasSpace,"lastWasSpace");
HX_VISIT_MEMBER_NAME(listOAlphabets,"listOAlphabets");
HX_VISIT_MEMBER_NAME(splitWords,"splitWords");
HX_VISIT_MEMBER_NAME(isBold,"isBold");
HX_VISIT_MEMBER_NAME(pastX,"pastX");
HX_VISIT_MEMBER_NAME(pastY,"pastY");
HX_VISIT_MEMBER_NAME(personTalking,"personTalking");
::flixel::group::FlxTypedSpriteGroup_obj::__Visit(HX_VISIT_ARG);
}
::hx::Val Alphabet_obj::__Field(const ::String &inName,::hx::PropertyAccess inCallProp)
{
switch(inName.length) {
case 4:
if (HX_FIELD_EQ(inName,"text") ) { return ::hx::Val( text ); }
break;
case 5:
if (HX_FIELD_EQ(inName,"delay") ) { return ::hx::Val( delay ); }
if (HX_FIELD_EQ(inName,"pastX") ) { return ::hx::Val( pastX ); }
if (HX_FIELD_EQ(inName,"pastY") ) { return ::hx::Val( pastY ); }
break;
case 6:
if (HX_FIELD_EQ(inName,"paused") ) { return ::hx::Val( paused ); }
if (HX_FIELD_EQ(inName,"yMulti") ) { return ::hx::Val( yMulti ); }
if (HX_FIELD_EQ(inName,"isBold") ) { return ::hx::Val( isBold ); }
if (HX_FIELD_EQ(inName,"reType") ) { return ::hx::Val( reType_dyn() ); }
if (HX_FIELD_EQ(inName,"update") ) { return ::hx::Val( update_dyn() ); }
break;
case 7:
if (HX_FIELD_EQ(inName,"targetY") ) { return ::hx::Val( targetY ); }
if (HX_FIELD_EQ(inName,"addText") ) { return ::hx::Val( addText_dyn() ); }
break;
case 8:
if (HX_FIELD_EQ(inName,"_curText") ) { return ::hx::Val( _curText ); }
break;
case 10:
if (HX_FIELD_EQ(inName,"isMenuItem") ) { return ::hx::Val( isMenuItem ); }
if (HX_FIELD_EQ(inName,"_finalText") ) { return ::hx::Val( _finalText ); }
if (HX_FIELD_EQ(inName,"lastSprite") ) { return ::hx::Val( lastSprite ); }
if (HX_FIELD_EQ(inName,"splitWords") ) { return ::hx::Val( splitWords ); }
break;
case 12:
if (HX_FIELD_EQ(inName,"widthOfWords") ) { return ::hx::Val( widthOfWords ); }
if (HX_FIELD_EQ(inName,"xPosResetted") ) { return ::hx::Val( xPosResetted ); }
if (HX_FIELD_EQ(inName,"lastWasSpace") ) { return ::hx::Val( lastWasSpace ); }
if (HX_FIELD_EQ(inName,"doSplitWords") ) { return ::hx::Val( doSplitWords_dyn() ); }
break;
case 13:
if (HX_FIELD_EQ(inName,"personTalking") ) { return ::hx::Val( personTalking ); }
break;
case 14:
if (HX_FIELD_EQ(inName,"listOAlphabets") ) { return ::hx::Val( listOAlphabets ); }
if (HX_FIELD_EQ(inName,"startTypedText") ) { return ::hx::Val( startTypedText_dyn() ); }
}
return super::__Field(inName,inCallProp);
}
::hx::Val Alphabet_obj::__SetField(const ::String &inName,const ::hx::Val &inValue,::hx::PropertyAccess inCallProp)
{
switch(inName.length) {
case 4:
if (HX_FIELD_EQ(inName,"text") ) { text=inValue.Cast< ::String >(); return inValue; }
break;
case 5:
if (HX_FIELD_EQ(inName,"delay") ) { delay=inValue.Cast< Float >(); return inValue; }
if (HX_FIELD_EQ(inName,"pastX") ) { pastX=inValue.Cast< Float >(); return inValue; }
if (HX_FIELD_EQ(inName,"pastY") ) { pastY=inValue.Cast< Float >(); return inValue; }
break;
case 6:
if (HX_FIELD_EQ(inName,"paused") ) { paused=inValue.Cast< bool >(); return inValue; }
if (HX_FIELD_EQ(inName,"yMulti") ) { yMulti=inValue.Cast< Float >(); return inValue; }
if (HX_FIELD_EQ(inName,"isBold") ) { isBold=inValue.Cast< bool >(); return inValue; }
break;
case 7:
if (HX_FIELD_EQ(inName,"targetY") ) { targetY=inValue.Cast< Float >(); return inValue; }
break;
case 8:
if (HX_FIELD_EQ(inName,"_curText") ) { _curText=inValue.Cast< ::String >(); return inValue; }
break;
case 10:
if (HX_FIELD_EQ(inName,"isMenuItem") ) { isMenuItem=inValue.Cast< bool >(); return inValue; }
if (HX_FIELD_EQ(inName,"_finalText") ) { _finalText=inValue.Cast< ::String >(); return inValue; }
if (HX_FIELD_EQ(inName,"lastSprite") ) { lastSprite=inValue.Cast< ::AlphaCharacter >(); return inValue; }
if (HX_FIELD_EQ(inName,"splitWords") ) { splitWords=inValue.Cast< ::Array< ::String > >(); return inValue; }
break;
case 12:
if (HX_FIELD_EQ(inName,"widthOfWords") ) { widthOfWords=inValue.Cast< Float >(); return inValue; }
if (HX_FIELD_EQ(inName,"xPosResetted") ) { xPosResetted=inValue.Cast< bool >(); return inValue; }
if (HX_FIELD_EQ(inName,"lastWasSpace") ) { lastWasSpace=inValue.Cast< bool >(); return inValue; }
break;
case 13:
if (HX_FIELD_EQ(inName,"personTalking") ) { personTalking=inValue.Cast< ::String >(); return inValue; }
break;
case 14:
if (HX_FIELD_EQ(inName,"listOAlphabets") ) { listOAlphabets=inValue.Cast< ::haxe::ds::List >(); return inValue; }
}
return super::__SetField(inName,inValue,inCallProp);
}
void Alphabet_obj::__GetFields(Array< ::String> &outFields)
{
outFields->push(HX_("delay",83,d7,26,d7));
outFields->push(HX_("paused",ae,40,84,ef));
outFields->push(HX_("targetY",e8,f3,67,88));
outFields->push(HX_("isMenuItem",5c,04,de,c6));
outFields->push(HX_("text",ad,cc,f9,4c));
outFields->push(HX_("_finalText",04,c7,73,eb));
outFields->push(HX_("_curText",ce,97,c7,f1));
outFields->push(HX_("widthOfWords",6c,29,47,59));
outFields->push(HX_("yMulti",40,a3,b1,04));
outFields->push(HX_("lastSprite",fb,be,70,8e));
outFields->push(HX_("xPosResetted",80,a7,a1,63));
outFields->push(HX_("lastWasSpace",53,93,45,c9));
outFields->push(HX_("listOAlphabets",ef,fb,db,93));
outFields->push(HX_("splitWords",2f,7e,9f,9d));
outFields->push(HX_("isBold",8f,46,82,5e));
outFields->push(HX_("pastX",46,53,56,bd));
outFields->push(HX_("pastY",47,53,56,bd));
outFields->push(HX_("personTalking",21,d4,8f,27));
super::__GetFields(outFields);
};
#ifdef HXCPP_SCRIPTABLE
static ::hx::StorageInfo Alphabet_obj_sMemberStorageInfo[] = {
{::hx::fsFloat,(int)offsetof(Alphabet_obj,delay),HX_("delay",83,d7,26,d7)},
{::hx::fsBool,(int)offsetof(Alphabet_obj,paused),HX_("paused",ae,40,84,ef)},
{::hx::fsFloat,(int)offsetof(Alphabet_obj,targetY),HX_("targetY",e8,f3,67,88)},
{::hx::fsBool,(int)offsetof(Alphabet_obj,isMenuItem),HX_("isMenuItem",5c,04,de,c6)},
{::hx::fsString,(int)offsetof(Alphabet_obj,text),HX_("text",ad,cc,f9,4c)},
{::hx::fsString,(int)offsetof(Alphabet_obj,_finalText),HX_("_finalText",04,c7,73,eb)},
{::hx::fsString,(int)offsetof(Alphabet_obj,_curText),HX_("_curText",ce,97,c7,f1)},
{::hx::fsFloat,(int)offsetof(Alphabet_obj,widthOfWords),HX_("widthOfWords",6c,29,47,59)},
{::hx::fsFloat,(int)offsetof(Alphabet_obj,yMulti),HX_("yMulti",40,a3,b1,04)},
{::hx::fsObject /* ::AlphaCharacter */ ,(int)offsetof(Alphabet_obj,lastSprite),HX_("lastSprite",fb,be,70,8e)},
{::hx::fsBool,(int)offsetof(Alphabet_obj,xPosResetted),HX_("xPosResetted",80,a7,a1,63)},
{::hx::fsBool,(int)offsetof(Alphabet_obj,lastWasSpace),HX_("lastWasSpace",53,93,45,c9)},
{::hx::fsObject /* ::haxe::ds::List */ ,(int)offsetof(Alphabet_obj,listOAlphabets),HX_("listOAlphabets",ef,fb,db,93)},
{::hx::fsObject /* ::Array< ::String > */ ,(int)offsetof(Alphabet_obj,splitWords),HX_("splitWords",2f,7e,9f,9d)},
{::hx::fsBool,(int)offsetof(Alphabet_obj,isBold),HX_("isBold",8f,46,82,5e)},
{::hx::fsFloat,(int)offsetof(Alphabet_obj,pastX),HX_("pastX",46,53,56,bd)},
{::hx::fsFloat,(int)offsetof(Alphabet_obj,pastY),HX_("pastY",47,53,56,bd)},
{::hx::fsString,(int)offsetof(Alphabet_obj,personTalking),HX_("personTalking",21,d4,8f,27)},
{ ::hx::fsUnknown, 0, null()}
};
static ::hx::StaticInfo *Alphabet_obj_sStaticStorageInfo = 0;
#endif
static ::String Alphabet_obj_sMemberFields[] = {
HX_("delay",83,d7,26,d7),
HX_("paused",ae,40,84,ef),
HX_("targetY",e8,f3,67,88),
HX_("isMenuItem",5c,04,de,c6),
HX_("text",ad,cc,f9,4c),
HX_("_finalText",04,c7,73,eb),
HX_("_curText",ce,97,c7,f1),
HX_("widthOfWords",6c,29,47,59),
HX_("yMulti",40,a3,b1,04),
HX_("lastSprite",fb,be,70,8e),
HX_("xPosResetted",80,a7,a1,63),
HX_("lastWasSpace",53,93,45,c9),
HX_("listOAlphabets",ef,fb,db,93),
HX_("splitWords",2f,7e,9f,9d),
HX_("isBold",8f,46,82,5e),
HX_("pastX",46,53,56,bd),
HX_("pastY",47,53,56,bd),
HX_("reType",0d,d8,09,f4),
HX_("addText",6e,0f,37,89),
HX_("doSplitWords",9a,d5,87,23),
HX_("personTalking",21,d4,8f,27),
HX_("startTypedText",75,b5,ca,1c),
HX_("update",09,86,05,87),
::String(null()) };
::hx::Class Alphabet_obj::__mClass;
void Alphabet_obj::__register()
{
Alphabet_obj _hx_dummy;
Alphabet_obj::_hx_vtable = *(void **)&_hx_dummy;
::hx::Static(__mClass) = new ::hx::Class_obj();
__mClass->mName = HX_("Alphabet",d3,38,ea,fa);
__mClass->mSuper = &super::__SGetClass();
__mClass->mConstructEmpty = &__CreateEmpty;
__mClass->mConstructArgs = &__Create;
__mClass->mGetStaticField = &::hx::Class_obj::GetNoStaticField;
__mClass->mSetStaticField = &::hx::Class_obj::SetNoStaticField;
__mClass->mStatics = ::hx::Class_obj::dupFunctions(0 /* sStaticFields */);
__mClass->mMembers = ::hx::Class_obj::dupFunctions(Alphabet_obj_sMemberFields);
__mClass->mCanCast = ::hx::TCanCast< Alphabet_obj >;
#ifdef HXCPP_SCRIPTABLE
__mClass->mMemberStorageInfo = Alphabet_obj_sMemberStorageInfo;
#endif
#ifdef HXCPP_SCRIPTABLE
__mClass->mStaticStorageInfo = Alphabet_obj_sStaticStorageInfo;
#endif
::hx::_hx_RegisterClass(__mClass->mName, __mClass);
}
| [
"mrcolin35@hotmail.com"
] | mrcolin35@hotmail.com |
94ea07d6eb83f52fa0da7b355b30c423c5da05d0 | 1cc44526fe719ddb807241e873b536c22fa0d1bf | /Src/Representations/Infrastructure/CameraSettingsV6.h | 5edee4aca46cde7663350874182362733c515637 | [
"BSD-2-Clause"
] | permissive | Handsome-Computer-Organization/nao | 55e188276a7ba82631bc6283d18db89f2b688c75 | d7bbac09355e5f8f719acb4b65b39bc7975878ca | refs/heads/main | 2023-04-26T12:24:59.944423 | 2021-05-14T12:53:10 | 2021-05-14T12:53:10 | 367,357,552 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,936 | h | /**
* @file CameraSettingsV6.h
* Declaration of a struct representing the settings of the PDA camera.
* @author <a href="mailto:Thomas.Roefer@dfki.de">Thomas Röfer</a>
*/
#pragma once
#include "Representations/Infrastructure/CameraInfo.h"
#include "Tools/Streams/AutoStreamable.h"
#include "Tools/Enum.h"
#include <array>
struct CameraSettingsV6 : public Streamable
{
ENUM(CameraSetting,
{,
AutoFocus, /*1: Enable continuous automatic focus adjustments, 0: Disable auto focus*/ //New
AutoExposure, /* 1: Use auto exposure, 0: disable auto exposure. */
// AutoExposureAlgorithm,
//BacklightCompensation, /* 0 - 4 */
AutoWhiteBalance, /* 1: Use auto white balance, 0: disable auto white balance. */
Contrast, /* The contrast in range of [16 .. 64]. Gravients from 0.5 (16) to 2.0 (64).*/
Exposure, /**< The exposure time in the range of [0 .. 1000]. Time is measured in increments of 100µs. */
//FadeToBlack, /**< Fade to black under low light conditions. 1: enabled, 0: disabled. */
Gain, /**< The gain level in the range of [0 .. 255]. */
Hue, /* The hue in range [-22 .. 22] */
Saturation, /* The saturation in range of [0 .. 255] */
Sharpness, /* The sharpness in range of [-7 .. 7] */
WhiteBalance, /**< The white balance in Kelvin [2700 .. 6500] */
//Gamma, /* The gamma value in range [100, 280] */
//PowerLineFrequency, /* The local power frequency (1 = 50Hz, 2 = 60Hz) */
//TargetAverageLuma, /* The target average brightness [0 .. 255] */
//TargetAverageLumaDark, /* The target average brightness for dark [0 .. 255] */
//TargetGain, /* The target analog gain [0 .. 65535] */
//MinGain, /* The minimum value for the analog gain that AE Track is permitted to use [0 .. 65535] */
//MaxGain, /* The maximum value for the analog gain that AE Track is permitted to use [0 .. 65535] */
//AeMode, /* AE mode (indoor, ...) [0 .. 255] */
Focus, /*This control sets the focal point of the camera to the specified position in [0,250], in 25 step*/ //New
});
STREAMABLE(CameraRegister,
{
ENUM(RegisterName,
{ ,
aec_ctrl,
aec_ctrl_stable_high,
aec_ctrl_stable_low,
aec_ctrl_unstable_high,
aec_ctrl_unstable_low,
aec_min_exposure,
aec_max_expo_60hz,
aec_max_expo_50hz,
aec_gain_ceiling,
aec_5060hz_ctrl0,
aec_5060hz_ctrl1,
aec_60hz_max_bands,
aec_50hz_max_bands,
timing_tc_reg21,
});
uint16_t getAddress() const
{
switch (reg)
{
case RegisterName::aec_ctrl: return 0x3A00;
case RegisterName::aec_ctrl_stable_high: return 0x3A0F;
case RegisterName::aec_ctrl_stable_low: return 0x3A10;
case RegisterName::aec_ctrl_unstable_high: return 0x3A1B;
case RegisterName::aec_ctrl_unstable_low: return 0x3A1E;
case RegisterName::aec_min_exposure: return 0x3A01;
case RegisterName::aec_max_expo_60hz: return 0x3A02;
case RegisterName::aec_max_expo_50hz: return 0x3A14;
case RegisterName::aec_gain_ceiling: return 0x3A18;
case RegisterName::aec_5060hz_ctrl0: return 0x3C00;
case RegisterName::aec_5060hz_ctrl1: return 0x3C01;
case RegisterName::aec_60hz_max_bands: return 0x3A0D;
case RegisterName::aec_50hz_max_bands: return 0x3A0E;
case RegisterName::timing_tc_reg21: return 0x3821;
default: return 0;
}
}
uint8_t getSize() const
{
switch (reg)
{
case RegisterName::aec_max_expo_60hz: return 2;
case RegisterName::aec_max_expo_50hz: return 2;
case RegisterName::aec_gain_ceiling: return 2;
default: return 1;
}
}
bool operator==(const CameraRegister& other) const
{
return this->reg == other.reg && this->value == other.value;
}
,
(RegisterName)(0) reg,
(int)(0) value,
});
STREAMABLE(V4L2Setting,
{
int command;
private:
int min;
int max;
public:
PROTECT(std::array<CameraSetting, 2>) influencingSettings;
V4L2Setting();
V4L2Setting(int command, int value, int min, int max);
virtual ~V4L2Setting() = default;
V4L2Setting& operator=(const V4L2Setting& other);
bool operator==(const V4L2Setting& other) const;
bool operator!=(const V4L2Setting& other) const;
void enforceBounds(),
(int) value,
});
std::array<V4L2Setting, numOfCameraSettings> settings;
std::vector<CameraRegister> registers;
Vector2s windowPosition;
Vector2s windowSize;
std::array<uint8_t,16> windowWeights;
CameraSettingsV6();
virtual ~CameraSettingsV6() = default;
CameraSettingsV6& operator=(const CameraSettingsV6& other);
bool operator==(const CameraSettingsV6& other) const;
bool operator!=(const CameraSettingsV6& other) const;
void enforceBounds();
virtual void serialize(In* in, Out* out);
};
STREAMABLE_WITH_BASE(CameraSettingsUpperV6, CameraSettingsV6,
{,
});
| [
"handsomeyingyan@github.com"
] | handsomeyingyan@github.com |
742365f4d57f5e2fbfe6ea67326e7f3fc5197464 | 51635684d03e47ebad12b8872ff469b83f36aa52 | /external/gcc-12.1.0/libstdc++-v3/testsuite/21_strings/basic_string_view/types/1.cc | e58a79c5b9b8cfe6a96ac8094f34731eeab1e8e3 | [
"LGPL-2.1-only",
"GPL-3.0-only",
"GCC-exception-3.1",
"GPL-2.0-only",
"LGPL-3.0-only",
"LGPL-2.0-or-later",
"Zlib",
"LicenseRef-scancode-public-domain"
] | permissive | zhmu/ananas | 8fb48ddfe3582f85ff39184fc7a3c58725fe731a | 30850c1639f03bccbfb2f2b03361792cc8fae52e | refs/heads/master | 2022-06-25T10:44:46.256604 | 2022-06-12T17:04:40 | 2022-06-12T17:04:40 | 30,108,381 | 59 | 8 | Zlib | 2021-09-26T17:30:30 | 2015-01-31T09:44:33 | C | UTF-8 | C++ | false | false | 1,175 | cc | //
// Copyright (C) 2013-2022 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, 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 General Public License for more details.
//
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
//
// { dg-do compile { target c++17 } }
#include <string_view>
struct T
{
typedef std::string_view String_view;
typedef String_view::iterator iterator;
typedef String_view::const_iterator const_iterator;
char t(iterator f) { return *f; }
char t(const_iterator f) const { return *f; }
};
void
f()
{
std::string_view s;
T t;
T::const_iterator i = s.begin();
t.t(i);
}
| [
"rink@rink.nu"
] | rink@rink.nu |
12296921e0243ca482f427befca74058e566267f | 512ff8baf337a02d04186950eaaf3f05493f19cc | /贪心/455/main.cpp | 749d961d10c095e0a72f214e09405b0b591bc2a4 | [] | no_license | coderzhongkaikai/exercise | 69cfe5d11c84b21e4702c6f6ed4fa03ba2ce751f | e354698cb9cae39d0f356b3775084341507888d7 | refs/heads/master | 2021-07-08T13:40:29.573399 | 2021-04-30T11:16:31 | 2021-04-30T11:16:31 | 239,304,726 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 642 | cpp | #include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
class Solution{
public:int findContentChild(vector<int>&g,vector<int>&s){
sort(g.begin(),g.end(),greater<int>());
sort(s.begin(),s.end(),greater<int>());
int si=0,gi=0;//分别代表 饼干和小孩
int res=0;
while (gi<g.size()&&si<s.size()){
if(s[si]>=g[gi]){
res++;
si++;
gi++;
}
else{
gi++;
}
}
return res;
}
};
int main() {
std::cout << "Hello, World!" << std::endl;
return 0;
}
| [
"2457169144@qq.com"
] | 2457169144@qq.com |
c032465e1857f7f2467dffb1689b4539575434fe | 0ed54494a51b0c100e4293dc8128b3de371e4608 | /C++ Work/CS163/Hw1/HW1_LLL.cpp | a442916db0564c766eea3f08d9895ba6a7d20a5a | [] | no_license | RyanWritz/Main | b9b33473c5d258377ead36ddd195cd81e442f785 | 3145d2089a16b065d3f32cca1c6f30f65a6e1171 | refs/heads/master | 2023-08-24T17:37:21.813286 | 2021-11-03T20:28:15 | 2021-11-03T20:28:15 | 196,872,221 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 5,617 | cpp | //Ryan W. Writz (c) 2015
//Hw #1 CS163
//HW1_LLL.cpp
//Here the functions for the DIY (Do it yourself) class are implemented
//In order to set up the information from the external data file appropriately
#include "HW1.h"
//Constructor that will set up head and tail pointers appropriately
//fix on a new node. This should make sure no matter you have at least
//a list of one node for both LLLs.
DIY :: DIY()
{ part_temp = part_head = new node;//setting up part LLL
step_temp = step_head = new stepnode;//setting up step LLL
part_head -> next = NULL;
part_temp -> next = NULL;
step_head -> next = NULL;
step_temp -> next = NULL;
part_head -> PartItem.Describe = new char[100];//Adjust so that you use temp arrays
step_temp -> StepItem.PartsNeeded = new int[100];
step_temp -> StepItem.Quantities = new int[100];
ifstream ReadIn;
ReadIn.open("parts.txt");
if(ReadIn.good())//Check to see if the connection to file is good
{ while(!ReadIn.eof()) //Reading in till end of the file
{ //Reading in of all file data into node PartItem's members
ReadIn >> part_temp -> PartItem.PartNum;
ReadIn.ignore(100, ':');
ReadIn.getline( part_temp -> PartItem.Describe, 100, ':');
ReadIn >> part_temp -> PartItem.Quantity;
ReadIn.ignore(100, ':');
ReadIn >> part_temp -> PartItem.StepNumUse;
ReadIn.ignore(100, ':');
part_temp -> PartItem.StepPartUse = new int[part_temp -> PartItem.StepNumUse];
for( int i=0; i < part_temp -> PartItem.StepNumUse; ++i)
{ReadIn >> part_temp -> PartItem.StepPartUse[i];
ReadIn.ignore(100,':');
} ReadIn.ignore(100,'\n');
//sorted LLL insert
part_temp -> next = new node;
part_temp = part_temp -> next;
part_temp -> PartItem.Describe = new char[100];//Adjust so that you use temp arrays
part_temp -> next = NULL;//still needs to sort
}
}
ReadIn.close();
ReadIn.clear();
//Handling conditions for creation fo extra nodes
part_temp = part_head;
while(part_temp -> next -> next != NULL)
part_temp = part_temp -> next;
if(part_temp -> next -> next == NULL)
{delete part_temp -> next;
part_temp -> next = NULL;
part_temp = NULL;
part_temp = part_head;
}
//Assigning local varaibles and realligning part_temp to traverse
/* part_temp = part_head;
int j= 0;
int k= 0;
//Checks for if Step Number in PartItem and StepItem match, when matches found,
//Puts data from Part struct node into Step Struct stepnode, while finding the data
//should also create the Part LLL
while(part_temp -> next != NULL)
{ while( part_temp -> PartItem.StepPartUse[j] != step_temp -> StepItem.StepNum
|| part_temp -> PartItem.StepPartUse[j] != '\n')
{ if( part_temp -> PartItem.StepPartUse[j] == step_temp -> StepItem.StepNum)
seg fault here { step_temp -> StepItem.PartsNeeded[k] = part_temp -> PartItem.StepPartUse[j];
step_temp -> StepItem.Quantities[k] = part_temp -> PartItem.Quantity;
}
if(part_temp -> PartItem.StepPartUse[j] == '\n')
part_temp = part_temp -> next;
else ++j;
}
++k;
step_temp -> next = new stepnode;
step_temp = step_temp -> next;
step_temp -> StepItem.PartsNeeded = new int[100];
step_temp -> StepItem.Quantities = new int[100];
}
*/
}
//Destructor that will dereference all the pointers used
DIY :: ~DIY()
{ delete [] part_head;
delete [] part_temp;
delete [] step_head;
delete [] step_temp;
}
//Displays the part you want to look at as well as its
//description, quantity, the steps that use it and
//the number of steps that use it
int DIY :: Display_Parts()
{ if(!part_head)
return 0;
int i=0;
node * part_current = part_head;
cout << "Here is your Part List.\n";
while(part_current != NULL)//Probably causing problems
{ //if(part_current -> PartItem.PartNum != 0)
{ cout << "Part #"<< part_current -> PartItem.PartNum << ":\n";
cout << "Description:\n" << part_current -> PartItem.Describe << endl;
cout << "\t" << "Quanity- " << part_current -> PartItem.Quantity << endl;
cout << "\t" << "Number of steps that use this part- ";
cout << part_current -> PartItem.StepNumUse << endl;
cout <<"\t" << "Steps that use this part-";
for(int i=0; i < part_current -> PartItem.StepNumUse; ++i)
cout << part_current -> PartItem.StepPartUse[i] <<",";
cout << endl;
}
part_current = part_current -> next;
}
}
//Displays the step you want to look at as well as the
//Parts required and their quantity
int DIY :: Display_Steps()
{ /*step_temp = step_head;
if(!step_head)
return 0;
int a = 0;
int b = 0;
cout << "Step #" << step_temp -> StepItem.StepNum << ":\n";
while(step_temp != NULL)
{ while(step_temp -> StepItem.PartsNeeded[a] != '\n')
{cout << "\t" <<"Part #" << step_temp -> StepItem.PartsNeeded[a];
while( step_temp -> StepItem.Quantities[b] != '\n')
cout << "\t\t\t" << "Quanity- " << step_temp -> StepItem.Quantities[b] << endl;
}
step_temp = step_temp -> next;
} */
}
//Will move to next step/part # when user is prompted
int DIY :: Next_Step()
{ /*char NStep = 'y';
int StepToGo;
if(StepToGo < 0 || StepToGo == 0)
{ cout << "What step number would you like to go to?";
cin >> StepToGo;
}cout << "Here is the information for Part #" << StepToGo<< ":\n";
//Display one step here
if(NStep != 'n')
{ cout << "Would you like to go to the next step?\n";
cin >> NStep;
if( NStep != 'y' && step_temp -> next != NULL)
step_temp = step -> next;
else return 0;
}
return 0;*/
}
| [
"noreply@github.com"
] | RyanWritz.noreply@github.com |
aec83cdc0d4e1fc709528350d827045f61c600c0 | 1190c42cf0e03d8625b3eed9b469bbc5dcbecc4d | /sockets/sockets.h | 0ef1fd1f370d2c9a3bd95b10464126c844f94759 | [] | no_license | ujpv/protei | 0fea4498c3e92978cb78295e5d1d90bdab6998ff | 36d1438f304a33126e862c9a41b07d92f1668737 | refs/heads/master | 2016-09-14T14:45:39.142944 | 2016-05-04T18:18:16 | 2016-05-04T18:18:16 | 57,385,906 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,978 | h | #ifndef SOCKETS_H
#define SOCKETS_H
#include <inttypes.h>
class abstract_socket {
public:
explicit abstract_socket(int fd);
abstract_socket(abstract_socket const &other);
int get_fd() const;
char *get_er_message() const;
bool connect(char const * ip, uint16_t port);
bool disconect();
bool is_valid() const;
void swap(abstract_socket &other);
virtual bool bind(char const * const ip, uint16_t port);
virtual int receive(char *buf, int size) = 0;
virtual int send(char const *buf, int size);
virtual ~abstract_socket();
private:
int m_fd;
int *m_pcount;
};
//====================================================================================================
class socket_UDP: public abstract_socket
{
public:
socket_UDP();
socket_UDP(socket_UDP const &other);
socket_UDP &operator=(socket_UDP const &other);
int receive(char *buf, int size) override;
~socket_UDP();
};
//====================================================================================================
class socket_TCP;
class socket_TCP_listener: public abstract_socket {
public:
explicit socket_TCP_listener(int queue_size);
socket_TCP_listener(socket_TCP_listener const &other);
socket_TCP_listener &operator=(socket_TCP_listener const &other);
int receive(char *, int) override;
int send(char const *, int) override;
bool bind(const char * const ip, uint16_t port) override;
socket_TCP accept();
private:
int m_queue_size;
};
//====================================================================================================
class socket_TCP: public abstract_socket
{
public:
socket_TCP();
socket_TCP(socket_TCP const &other);
socket_TCP &operator=(socket_TCP const &other);
int receive(char *buf, int size) override;
~socket_TCP() override;
friend socket_TCP socket_TCP_listener::accept();
private:
explicit socket_TCP(int f_d);
};
#endif // SOCKETS_H
| [
"ujpv@mail.ru"
] | ujpv@mail.ru |
e1889b22ed801baff046deeeec9f6ee14c26200b | c7979f4f6435fe8d0d07fff7a430da55e3592aed | /aising/test.cpp | 3f181c684756bfc5df72fe6503946084fbd3a44c | [] | no_license | banboooo044/AtCoder | cee87d40bb98abafde19017f4f4e2f984544b9f8 | 7541d521cf0da848ecb5eb10ffea7d75a44cbbb6 | refs/heads/master | 2020-04-14T11:35:24.977457 | 2019-09-17T03:20:27 | 2019-09-17T03:20:27 | 163,818,272 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,536 | cpp | #include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#define REP(i,n) for (long long i=0;i<(n);i++)
#define FOR(i,a,b) for (long long i=(a);i<(b);i++)
#define RREP(i,n) for(long long i=n;i>=0;i--)
#define RFOR(i,a,b) for(long long i=(a);i>(b);i--)
#define dump(x) cerr << #x << " => " << (x) << endl
#define SORT(c) sort((c).begin(),(c).end())
#define MIN(vec) *min_element(vec.begin(), vec.end())
#define MAX(vec) *max_element(vec.begin(), vec.end())
#define UNIQ(vec) vec.erase(unique(vec.begin(), vec.end()),vec.end()) //ソートの必要あり
#define IN(n,m) (!(m.find(n) == m.end()))
#define ENUM(m) for (auto itr = m.begin(); itr != m.end(); ++itr)
#define dump_MAP(m) for(auto itr = m.begin(); itr != m.end(); ++itr) { cerr << itr->first << " --> " << itr->second << endl; }
#define FINDL(vec,x) (lower_bound(vec.begin(),vec.end(),x) - vec.begin())
#define FINDU(vec,x) (upper_bound(vec.begin(),vec.end(),x) - vec.begin())
#define ROUND(N) setprecision(N)
#define ROUND_PRINT(N,val) cout << fixed;cout << setprecision(N) << val << endl
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define INARR(h,w,x,y) (0 <= y && y < h && 0 <= x && x < w)
#define EQ(a,b) (abs(a - b) < 1e-10)
using namespace std;
constexpr int dx[4] = {0,1,0,-1};
constexpr int dy[4] = {1,0,-1,0};
constexpr long double pi = M_PI;
constexpr double eps = 1e-10;
constexpr long mod = 1000000007;
constexpr short shINF = 32767;
constexpr long loINF = 2147483647;
constexpr long long llINF = 9223372036854775807;
typedef long long LL;
typedef vector<LL> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<LL,LL> pr;
typedef vector<bool> VB;
typedef vector<pr> VP;
typedef priority_queue<pr,vector<pr>,greater<pr>> pq;
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
int main(void) {
cin.tie(0);
ios::sync_with_stdio(false);
vector<int> x = { 0, 1, 2, 6,10};
dump(FINDL(x,2));
}
| [
"touhoucrisis7@gmail.com"
] | touhoucrisis7@gmail.com |
d72b27c52a70a3422cd88fa47f9e715e595b1d3c | ffe66d2c0494554c8c917dded6f8cdcf79c651a2 | /MLModels/NeuralNetwork/NNUnitTest.cpp | e35b4dabe0b93b557f73ee931553081e15670818 | [] | no_license | Zhukowych/Rinit | 3f9f149ba3e45545887e777d623255cc7d1052a9 | d9466ae628d31d01a034268727e07602e6e2aba5 | refs/heads/main | 2023-01-22T23:08:58.707963 | 2020-11-29T12:13:04 | 2020-11-29T12:13:04 | 286,224,024 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 615 | cpp | #include "NeuralNetwork.hpp"
#include "../../Containers/Vector.hpp"
Vector<int> CreateNNStructure(){
Vector<int> result(3);
result[0] = 5;
result[1] = 3;
result[2] = 2;
return result;
}
Vector<float> CreateTrainData(){
Vector<float> result(2);
result[0] = 1;
result[1] = 1;
return result;
}
Vector<float> CreateData(){
Vector<float> result(5);
for(int i=0; i<5; i++){
result[i] = i;
}
return result;
}
void Test(){
NeuralNetwork NN(CreateNNStructure());
Vector<float> output =NN.FeedForvard(CreateData());
NN.GradientStep(CreateData(), CreateTrainData());
}
int main(){
Test();
return 0;
}
| [
"mzmzhuk@gmail.com"
] | mzmzhuk@gmail.com |
d754a3c9e2b5fbd14fc963886a66633fc9e4342d | db21d60c742cd1f6b5bbfb9dcf8e6f17eafb3ffd | /TiledReader/Includes/Event/Delegate/Exception/UnboundDelegateException.h | 32c5afe889987e4aba1ccb4366912c2979842e6e | [] | no_license | YvesHenri/TiledPlusPlus | d32a3a8ffcee4097da690590eac0b4a6d46fc219 | 79e1f4f9d75920821f1e3976386811326b094da3 | refs/heads/master | 2021-01-12T00:15:24.693477 | 2017-02-21T17:36:37 | 2017-02-21T17:36:37 | 78,694,413 | 1 | 0 | null | 2017-02-21T17:36:38 | 2017-01-12T01:00:04 | C++ | UTF-8 | C++ | false | false | 591 | h | #ifndef TPP_EVENT_DELEGATE_EXCEPTION_UNBOUNDDELEGATEEXCEPTION_H
#define TPP_EVENT_DELEGATE_EXCEPTION_UNBOUNDDELEGATEEXCEPTION_H
#include <exception>
#include "Macros\API.h"
// non dll - interface class 'std::exception' used as base for dll - interface class 'evt::UnboundDelegateException'
#pragma warning(disable: 4275)
namespace evt
{
class TILEDPP_API UnboundDelegateException final : public std::exception
{
public:
UnboundDelegateException() : std::exception("Unbound delegate")
{}
UnboundDelegateException(const char* message) : std::exception(message)
{}
};
}
#endif | [
"yveshenricalaci@hotmail.com"
] | yveshenricalaci@hotmail.com |
c5515f6f8e69aae95c5b5b0d32aa31d4bfd12306 | 66814bdad378a1d65136dc72ec2c9c6bb33e3c4b | /HTTP_Downloader/login_manager_utilities.cpp | 66e6055d0623756765693c64d6699d5c96b17a68 | [] | no_license | Surfndez/httpdownloader | 8b9fd26725f186d79ac175283049847ba04d2e28 | 9006fbdc2935398083a9140d37d1300030386578 | refs/heads/master | 2020-09-21T09:14:32.120527 | 2019-11-19T05:10:01 | 2019-11-19T05:10:01 | 224,751,759 | 1 | 0 | null | 2019-11-29T01:00:48 | 2019-11-29T01:00:47 | null | UTF-8 | C++ | false | false | 18,598 | cpp | /*
HTTP Downloader can download files through HTTP(S) and FTP(S) connections.
Copyright (C) 2015-2019 Eric Kutcher
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "login_manager_utilities.h"
#include "utilities.h"
#include "file_operations.h"
#include "http_parsing.h"
#include "connection.h"
bool login_list_changed = false;
int GetDomainParts( wchar_t *site, wchar_t *offsets[ 128 ] )
{
int count = 0;
wchar_t *ptr = site;
wchar_t *ptr_s = ptr;
while ( ptr != NULL && count < 127 )
{
if ( *ptr == L'.' )
{
offsets[ count++ ] = ptr_s;
ptr_s = ptr + 1;
}
else if ( *ptr == NULL )
{
offsets[ count++ ] = ptr_s;
break;
}
++ptr;
}
if ( ptr != NULL )
{
offsets[ count ] = ptr; // End of string.
}
return count;
}
int dllrbt_compare_login_info( void *a, void *b )
{
LOGIN_INFO *a1 = ( LOGIN_INFO * )a;
LOGIN_INFO *b1 = ( LOGIN_INFO * )b;
int ret;
if ( a1 == b1 )
{
return 0;
}
// Check the easiest comparisons first.
if ( a1->protocol > b1->protocol )
{
ret = 1;
}
else if ( a1->protocol < b1->protocol )
{
ret = -1;
}
else
{
if ( a1->port > b1->port )
{
ret = 1;
}
else if ( a1->port < b1->port )
{
ret = -1;
}
else
{
wchar_t *host1_offset[ 128 ];
int count1 = GetDomainParts( a1->host, host1_offset );
wchar_t *host2_offset[ 128 ];
int count2 = GetDomainParts( b1->host, host2_offset );
if ( count1 == count2 )
{
for ( int i = count1; i > 0; --i )
{
wchar_t *start1 = host1_offset[ i - 1 ];
wchar_t *start2 = host2_offset[ i - 1 ];
wchar_t *end1 = host1_offset[ i ];
wchar_t *end2 = host2_offset[ i ];
if ( !( ( ( ( end1 - start1 ) == 2 ) && *start1 == L'*' && *( start1 + 1 ) == L'.' ) ||
( ( ( end2 - start2 ) == 2 ) && *start2 == L'*' && *( start2 + 1 ) == L'.' ) ) )
{
wchar_t tmp1 = *end1;
wchar_t tmp2 = *end2;
*end1 = 0;
*end2 = 0;
ret = lstrcmpW( start1, start2 );
*end1 = tmp1; // Restore
*end2 = tmp2; // Restore
if ( ret != 0 )
{
break;
}
}
}
}
else
{
ret = ( count1 > count2 ? 1 : -1 );
}
}
}
return ret;
}
char read_login_info()
{
char ret_status = 0;
_wmemcpy_s( base_directory + base_directory_length, MAX_PATH - base_directory_length, L"\\http_downloader_logins\0", 24 );
base_directory[ base_directory_length + 23 ] = 0; // Sanity.
HANDLE hFile_read = CreateFile( base_directory, GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL );
if ( hFile_read != INVALID_HANDLE_VALUE )
{
DWORD read = 0, total_read = 0, offset = 0, last_entry = 0, last_total = 0;
char *p = NULL;
wchar_t *site;
char *username;
char *password;
wchar_t *w_username;
wchar_t *w_password;
char magic_identifier[ 4 ];
ReadFile( hFile_read, magic_identifier, sizeof( char ) * 4, &read, NULL );
if ( read == 4 && _memcmp( magic_identifier, MAGIC_ID_LOGINS, 4 ) == 0 )
{
DWORD fz = GetFileSize( hFile_read, NULL ) - 4;
char *buf = ( char * )GlobalAlloc( GMEM_FIXED, sizeof( char ) * ( 524288 + 1 ) ); // 512 KB buffer.
while ( total_read < fz )
{
ReadFile( hFile_read, buf, sizeof( char ) * 524288, &read, NULL );
buf[ read ] = 0; // Guarantee a NULL terminated buffer.
// Make sure that we have at least part of the entry. This is the minimum size an entry could be.
// Include 3 wide NULL strings and 3 char NULL strings.
// Include 2 ints for username and password lengths.
// Include 1 unsigned char for range info.
if ( read < ( sizeof( wchar_t ) + ( sizeof( int ) * 2 ) ) )
{
break;
}
total_read += read;
// Prevent an infinite loop if a really really long entry causes us to jump back to the same point in the file.
// If it's larger than our buffer, then the file is probably invalid/corrupt.
if ( total_read == last_total )
{
break;
}
last_total = total_read;
p = buf;
offset = last_entry = 0;
while ( offset < read )
{
site = NULL;
username = NULL;
password = NULL;
w_username = NULL;
w_password = NULL;
// Site
int string_length = lstrlenW( ( wchar_t * )p ) + 1;
offset += ( string_length * sizeof( wchar_t ) );
if ( offset >= read ) { goto CLEANUP; }
site = ( wchar_t * )GlobalAlloc( GMEM_FIXED, sizeof( wchar_t ) * string_length );
_wmemcpy_s( site, string_length, p, string_length );
*( site + ( string_length - 1 ) ) = 0; // Sanity
p += ( string_length * sizeof( wchar_t ) );
// Username
offset += sizeof( int );
if ( offset >= read ) { goto CLEANUP; }
// Length of the string - not including the NULL character.
_memcpy_s( &string_length, sizeof( int ), p, sizeof( int ) );
p += sizeof( int );
offset += string_length;
if ( offset >= read ) { goto CLEANUP; }
if ( string_length > 0 )
{
// string_length does not contain the NULL character of the string.
username = ( char * )GlobalAlloc( GMEM_FIXED, sizeof( char ) * ( string_length + 1 ) );
_memcpy_s( username, string_length, p, string_length );
username[ string_length ] = 0; // Sanity;
decode_cipher( username, string_length );
w_username = UTF8StringToWideString( username, string_length + 1 );
p += string_length;
}
// Password
offset += sizeof( int );
if ( offset > read ) { goto CLEANUP; }
// Length of the string - not including the NULL character.
_memcpy_s( &string_length, sizeof( int ), p, sizeof( int ) );
p += sizeof( int );
offset += string_length;
if ( offset > read ) { goto CLEANUP; }
if ( string_length > 0 )
{
// string_length does not contain the NULL character of the string.
password = ( char * )GlobalAlloc( GMEM_FIXED, sizeof( char ) * ( string_length + 1 ) );
_memcpy_s( password, string_length, p, string_length );
password[ string_length ] = 0; // Sanity;
decode_cipher( password, string_length );
w_password = UTF8StringToWideString( password, string_length + 1 );
p += string_length;
}
last_entry = offset; // This value is the ending offset of the last valid entry.
unsigned int host_length = 0;
unsigned int resource_length = 0;
wchar_t *resource = NULL;
LOGIN_INFO *li = ( LOGIN_INFO * )GlobalAlloc( GPTR, sizeof( LOGIN_INFO ) );
ParseURL_W( site, NULL, li->protocol, &li->host, host_length, li->port, &resource, resource_length, NULL, NULL, NULL, NULL );
GlobalFree( resource );
li->username = username;
li->password = password;
li->w_host = site;
li->w_username = w_username;
li->w_password = w_password;
if ( dllrbt_insert( g_login_info, ( void * )li, ( void * )li ) != DLLRBT_STATUS_OK )
{
GlobalFree( li->w_host );
GlobalFree( li->w_username );
GlobalFree( li->w_password );
GlobalFree( li->host );
GlobalFree( li->username );
GlobalFree( li->password );
GlobalFree( li );
}
continue;
CLEANUP:
GlobalFree( site );
GlobalFree( username );
GlobalFree( password );
GlobalFree( w_username );
GlobalFree( w_password );
// Go back to the last valid entry.
if ( total_read < fz )
{
total_read -= ( read - last_entry );
SetFilePointer( hFile_read, total_read + 4, NULL, FILE_BEGIN ); // Offset past the magic identifier.
}
break;
}
}
GlobalFree( buf );
}
else
{
ret_status = -2; // Bad file format.
}
CloseHandle( hFile_read );
}
else
{
ret_status = -1; // Can't open file for reading.
}
return ret_status;
}
char save_login_info()
{
char ret_status = 0;
_wmemcpy_s( base_directory + base_directory_length, MAX_PATH - base_directory_length, L"\\http_downloader_logins\0", 24 );
base_directory[ base_directory_length + 23 ] = 0; // Sanity.
HANDLE hFile = CreateFile( base_directory, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL );
if ( hFile != INVALID_HANDLE_VALUE )
{
//int size = ( 32768 + 1 );
int size = ( 524288 + 1 );
int pos = 0;
DWORD write = 0;
char *buf = ( char * )GlobalAlloc( GMEM_FIXED, sizeof( char ) * size );
_memcpy_s( buf + pos, size - pos, MAGIC_ID_LOGINS, sizeof( char ) * 4 ); // Magic identifier for the call log history.
pos += ( sizeof( char ) * 4 );
node_type *node = dllrbt_get_head( g_login_info );
while ( node != NULL )
{
LOGIN_INFO *li = ( LOGIN_INFO * )node->val;
if ( li != NULL )
{
// lstrlen is safe for NULL values.
int url_length = ( lstrlenW( li->w_host ) + 1 ) * sizeof( wchar_t );
int username_length = lstrlenA( li->username );
int password_length = lstrlenA( li->password );
// See if the next entry can fit in the buffer. If it can't, then we dump the buffer.
if ( ( signed )( pos + url_length + username_length + password_length + ( sizeof( int ) * 2 ) ) > size )
{
// Dump the buffer.
WriteFile( hFile, buf, pos, &write, NULL );
pos = 0;
}
_memcpy_s( buf + pos, size - pos, li->w_host, url_length );
pos += url_length;
if ( li->username != NULL )
{
_memcpy_s( buf + pos, size - pos, &username_length, sizeof( int ) );
pos += sizeof( int );
_memcpy_s( buf + pos, size - pos, li->username, username_length );
encode_cipher( buf + pos, username_length );
pos += username_length;
}
else
{
_memset( buf + pos, 0, sizeof( int ) );
pos += sizeof( int );
}
if ( li->password != NULL )
{
_memcpy_s( buf + pos, size - pos, &password_length, sizeof( int ) );
pos += sizeof( int );
_memcpy_s( buf + pos, size - pos, li->password, password_length );
encode_cipher( buf + pos, password_length );
pos += password_length;
}
else
{
_memset( buf + pos, 0, sizeof( int ) );
pos += sizeof( int );
}
}
node = node->next;
}
// If there's anything remaining in the buffer, then write it to the file.
if ( pos > 0 )
{
WriteFile( hFile, buf, pos, &write, NULL );
}
GlobalFree( buf );
CloseHandle( hFile );
}
else
{
ret_status = -1; // Can't open file for writing.
}
return ret_status;
}
THREAD_RETURN load_login_list( void *pArguments )
{
// This will block every other thread from entering until the first thread is complete.
EnterCriticalSection( &worker_cs );
in_worker_thread = true;
LVITEM lvi;
_memzero( &lvi, sizeof( LVITEM ) );
lvi.mask = LVIF_PARAM | LVIF_TEXT;
node_type *node = dllrbt_get_head( g_login_info );
while ( node != NULL )
{
LOGIN_INFO *li = ( LOGIN_INFO * )node->val;
if ( li != NULL )
{
lvi.iItem = ( int )_SendMessageW( g_hWnd_login_list, LVM_GETITEMCOUNT, 0, 0 );
lvi.lParam = ( LPARAM )li;
lvi.pszText = li->w_host;
_SendMessageW( g_hWnd_login_list, LVM_INSERTITEM, 0, ( LPARAM )&lvi );
}
node = node->next;
}
// Release the semaphore if we're killing the thread.
if ( worker_semaphore != NULL )
{
ReleaseSemaphore( worker_semaphore, 1, NULL );
}
in_worker_thread = false;
// We're done. Let other threads continue.
LeaveCriticalSection( &worker_cs );
_ExitThread( 0 );
return 0;
}
THREAD_RETURN handle_login_list( void *pArguments )
{
LOGIN_UPDATE_INFO *lui = ( LOGIN_UPDATE_INFO * )pArguments;
// This will block every other thread from entering until the first thread is complete.
EnterCriticalSection( &worker_cs );
in_worker_thread = true;
if ( lui != NULL )
{
if ( lui->update_type == 0 && lui->li != NULL ) // Add
{
LOGIN_INFO *li = lui->li;
unsigned char fail_type = 0;
wchar_t *host = NULL;
wchar_t *resource = NULL;
unsigned int host_length = 0;
unsigned int resource_length = 0;
ParseURL_W( li->w_host, NULL, li->protocol, &host, host_length, li->port, &resource, resource_length, NULL, NULL, NULL, NULL );
if ( li->protocol == PROTOCOL_HTTP ||
li->protocol == PROTOCOL_HTTPS ||
li->protocol == PROTOCOL_FTP ||
li->protocol == PROTOCOL_FTPS ||
li->protocol == PROTOCOL_FTPES )
{
if ( li->protocol == PROTOCOL_HTTP )
{
host_length += 7; // http://
}
else if ( li->protocol == PROTOCOL_HTTPS )
{
host_length += 8; // https://
}
else if ( li->protocol == PROTOCOL_FTP )
{
host_length += 6; // ftp://
}
else if ( li->protocol == PROTOCOL_FTPS )
{
host_length += 7; // ftps://
}
else if ( li->protocol == PROTOCOL_FTPES )
{
host_length += 8; // ftpes://
}
// See if there's a resource at the end of our host. We don't want it.
// Skip the http(s):// and host.
wchar_t *end = _StrChrW( li->w_host + host_length, L'/' );
if ( end != NULL )
{
*end = 0;
host_length = ( unsigned int )( end - li->w_host ) + 1;
wchar_t *w_host = ( wchar_t * )GlobalAlloc( GMEM_FIXED, sizeof( wchar_t ) * host_length );
_wmemcpy_s( w_host, host_length, li->w_host, host_length );
GlobalFree( li->w_host );
li->w_host = w_host;
}
GlobalFree( resource );
int string_length = 0; // Temporary value.
li->host = host;
li->username = WideStringToUTF8String( li->w_username, &string_length );
li->password = WideStringToUTF8String( li->w_password, &string_length );
if ( dllrbt_insert( g_login_info, ( void * )li, ( void * )li ) != DLLRBT_STATUS_OK )
{
fail_type = 1; // Already exits.
}
else
{
LVITEM lvi;
_memzero( &lvi, sizeof( LVITEM ) );
lvi.mask = LVIF_PARAM | LVIF_TEXT;
lvi.iItem = ( int )_SendMessageW( g_hWnd_login_list, LVM_GETITEMCOUNT, 0, 0 );
lvi.lParam = ( LPARAM )li;
lvi.pszText = li->w_host;
_SendMessageW( g_hWnd_login_list, LVM_INSERTITEM, 0, ( LPARAM )&lvi );
login_list_changed = true;
_SendMessageW( g_hWnd_login_manager, WM_PROPAGATE, 0, 0 ); // Clear entry.
}
}
else
{
fail_type = 2; // Bad protocol.
}
if ( fail_type != 0 )
{
GlobalFree( li->w_host );
GlobalFree( li->w_username );
GlobalFree( li->w_password );
GlobalFree( li->host );
GlobalFree( li->username );
GlobalFree( li->password );
GlobalFree( li );
_SendNotifyMessageW( g_hWnd_login_manager, WM_PROPAGATE, fail_type, 0 );
}
}
else if ( lui->update_type == 1 ) // Remove
{
// Prevent the listviews from drawing while freeing lParam values.
skip_login_list_draw = true;
LVITEM lvi;
_memzero( &lvi, sizeof( LVITEM ) );
lvi.mask = LVIF_PARAM;
int item_count = ( int )_SendMessageW( g_hWnd_login_list, LVM_GETITEMCOUNT, 0, 0 );
int sel_count = ( int )_SendMessageW( g_hWnd_login_list, LVM_GETSELECTEDCOUNT, 0, 0 );
int *index_array = NULL;
bool handle_all = false;
if ( item_count == sel_count )
{
handle_all = true;
}
else
{
_SendMessageW( g_hWnd_login_list, LVM_ENSUREVISIBLE, 0, FALSE );
index_array = ( int * )GlobalAlloc( GMEM_FIXED, sizeof( int ) * sel_count );
lvi.iItem = -1; // Set this to -1 so that the LVM_GETNEXTITEM call can go through the list correctly.
_EnableWindow( g_hWnd_login_list, FALSE ); // Prevent any interaction with the listview while we're processing.
// Create an index list of selected items (in reverse order).
for ( int i = 0; i < sel_count; ++i )
{
lvi.iItem = index_array[ sel_count - 1 - i ] = ( int )_SendMessageW( g_hWnd_login_list, LVM_GETNEXTITEM, lvi.iItem, LVNI_SELECTED );
}
_EnableWindow( g_hWnd_login_list, TRUE ); // Allow the listview to be interactive.
item_count = sel_count;
}
// Go through each item, and free their lParam values.
for ( int i = 0; i < item_count; ++i )
{
// Stop processing and exit the thread.
if ( kill_worker_thread_flag )
{
break;
}
if ( handle_all )
{
lvi.iItem = i;
}
else
{
lvi.iItem = index_array[ i ];
}
_SendMessageW( g_hWnd_login_list, LVM_GETITEM, 0, ( LPARAM )&lvi );
LOGIN_INFO *li = ( LOGIN_INFO * )lvi.lParam;
if ( !handle_all )
{
_SendMessageW( g_hWnd_login_list, LVM_DELETEITEM, index_array[ i ], 0 );
}
else if ( i >= ( item_count - 1 ) )
{
_SendMessageW( g_hWnd_login_list, LVM_DELETEALLITEMS, 0, 0 );
}
if ( li != NULL )
{
// Find the login info
dllrbt_iterator *itr = dllrbt_find( g_login_info, ( void * )li, false );
if ( itr != NULL )
{
dllrbt_remove( g_login_info, itr );
}
GlobalFree( li->w_host );
GlobalFree( li->w_username );
GlobalFree( li->w_password );
GlobalFree( li->host );
GlobalFree( li->username );
GlobalFree( li->password );
GlobalFree( li );
}
}
_SendMessageW( g_hWnd_login_manager, WM_PROPAGATE, 3, 0 ); // Disable remove button.
login_list_changed = true;
skip_login_list_draw = false;
}
GlobalFree( lui );
}
_InvalidateRect( g_hWnd_login_list, NULL, FALSE );
// Release the semaphore if we're killing the thread.
if ( worker_semaphore != NULL )
{
ReleaseSemaphore( worker_semaphore, 1, NULL );
}
in_worker_thread = false;
// We're done. Let other threads continue.
LeaveCriticalSection( &worker_cs );
_ExitThread( 0 );
return 0;
}
| [
"defeatthefreak@gmail.com"
] | defeatthefreak@gmail.com |
35b7193cca08c84556ea92478ef8fbf5f4e0931a | 67ea3f01e6cd4b9d3551d5f31184130efe61b471 | /Tests/testFunctions.cpp | a50d14c9e5caf82be40d97d959658239dfa7ca2c | [
"MIT"
] | permissive | ASR-Engineering-Consulting/V3DLib | a4d33c9436aed34eeef412935753252b86c820fc | 393cc112866b64019830f66984663d1731ecb68e | refs/heads/main | 2023-05-07T21:57:54.957983 | 2021-05-31T06:58:28 | 2021-05-31T06:58:28 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,149 | cpp | #include "doctest.h"
#include "Kernel.h"
#include "Source/Functions.h"
using namespace V3DLib;
namespace {
IntExpr hello_int_function() {
return functions::create_function_snippet([] {
Int Q = 42;
functions::Return(Q);
});
}
void hello_int_kernel(Int::Ptr result) {
*result = hello_int_function();
}
FloatExpr hello_float_function() {
return functions::create_float_function_snippet([] {
Float Q = 42;
functions::Return(Q);
});
}
void hello_float_kernel(Float::Ptr result) {
*result = hello_float_function();
}
} // anon namespace
TEST_CASE("Test functions [funcs]") {
SUBCASE("Test hello int function") {
Int::Array result(16);
result.fill(-1);
auto k = compile(hello_int_kernel);
k.load(&result);
k.interpret();
for (int i = 0; i < (int) result.size(); i++) {
REQUIRE(result[i] == 42);
}
}
SUBCASE("Test hello float function") {
Float::Array result(16);
result.fill(-1);
auto k = compile(hello_float_kernel);
k.load(&result);
k.interpret();
for (int i = 0; i < (int) result.size(); i++) {
REQUIRE(result[i] == 42.0f);
}
}
}
| [
"wrijnders@gmail.com"
] | wrijnders@gmail.com |
2b5013f585040c3342a37bef5f06deecb19e914d | 844fc17b4b94fcc455e56b1e8fa87da8be537d23 | /src/spectral/basis/spectral_function/spectral_weight_function.hpp | 55a37de7660662c46637af11fa7ac2958fcc7c1b | [] | no_license | simonpintarelli/2dBoltzmann | be6426564ffd74cd084787fbe1c6590b27a53dcc | bc6b7bbeffa242ce80937947444383b416ba3fc9 | refs/heads/master | 2021-04-12T10:21:50.167296 | 2018-12-16T16:16:43 | 2018-12-16T16:16:43 | 126,182,914 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 848 | hpp | #pragma once
#include "spectral_coord_traits.hpp"
namespace boltzmann {
// --------------------------------------------------------------------------------
template <typename F, bool T>
struct weighted
{};
// --------------------------------------------------------------------------------
template <typename F>
struct weighted<F, true>
{
typename SpectralCoordTraits<F>::return_type weight(
const typename SpectralCoordTraits<F>::coord_type& c) const
{
return static_cast<const F&>(*this).weight(c);
}
};
// --------------------------------------------------------------------------------
template <typename F>
struct weighted<F, false>
{
constexpr typename SpectralCoordTraits<F>::return_type weight(
const typename SpectralCoordTraits<F>::coord_type& c) const
{
return 1;
}
};
} // end namespace boltzmann
| [
"simon.pintarelli@gmail.com"
] | simon.pintarelli@gmail.com |
299c636c95fd72462ceb2080da6c7f95d16c0799 | 9315e24a9046cbde84a5106de6c9473c4197b4c0 | /symbol.cpp | ba28655c96d0a86eb396e81627bbcbcb32912542 | [] | no_license | ristosip/clanky-game-engine | a7b0f6ed336191e2edce8fddc39dcbcc376e1296 | 2d2f40c018d981dd0e0db3bfb8d1eb9d0c8be5e0 | refs/heads/master | 2020-12-06T23:39:53.365750 | 2020-01-13T15:40:51 | 2020-01-13T15:40:51 | 232,581,181 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 1,256 | cpp | #include "symbol.h"
#include "attributesandstates.h"
#include "pixmapitem.h"
#include <QPropertyAnimation>
Symbol::Symbol(int symbol_code, const QString &image_path, qreal image_scale, QGraphicsItem *parent) : GameObject(parent)
{
setRect(0, 0, 10, 10);
m_symbol_code = symbol_code;
PixmapItem *image = new PixmapItem(QPixmap(image_path));
image->setFlag(QGraphicsItem::ItemIgnoresParentOpacity, true);
image->setScale(image_scale);
image->setParentItem(this);
QPropertyAnimation *animation = new QPropertyAnimation(image, "scale");
animation->setStartValue(1.0 * image_scale);
animation->setEndValue(0.9 * image_scale);
animation->setLoopCount(-1);
animation->setEasingCurve(QEasingCurve::SineCurve);
animation->setDuration(750);
animation->start();
m_attribute_mask = 1<<COLLECTIBLE;
m_databank.attributes = 0;
m_databank.attributes = m_databank.attributes | m_attribute_mask;
}
int Symbol::symbolCode()
{
return m_symbol_code;
}
void Symbol::advanceObject(int delta_time, int phase)
{
if(phase == 1){
m_databank.attributes = m_databank.attributes | m_attribute_mask;
}
GameObject::advanceObject(delta_time, phase);
}
| [
"noreply@github.com"
] | ristosip.noreply@github.com |
972e2620002178be4264af959efe3e895e2595ec | f42d648e4d284402ad465efa682c0e36197c4ec1 | /winrt/impl/Windows.Foundation.Metadata.0.h | 0d48afe5aa7ee7348790c756eb78c7b2e1dc4b55 | [] | no_license | kennykerr/modules | 61bb39ae34cefcfec457d815b74db766cb6ea686 | 0faf4cd2fa757739c4a45e296bd24b8e652db490 | refs/heads/master | 2022-12-24T13:38:01.577626 | 2020-10-06T17:02:07 | 2020-10-06T17:02:07 | 301,795,870 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 7,034 | h | // WARNING: Please don't edit this file. It was generated by C++/WinRT v2.3.4.5
#ifndef WINRT_Windows_Foundation_Metadata_0_H
#define WINRT_Windows_Foundation_Metadata_0_H
WINRT_EXPORT namespace winrt::Windows::Foundation::Metadata
{
enum class AttributeTargets : uint32_t
{
All = 0xffffffff,
Delegate = 0x1,
Enum = 0x2,
Event = 0x4,
Field = 0x8,
Interface = 0x10,
Method = 0x40,
Parameter = 0x80,
Property = 0x100,
RuntimeClass = 0x200,
Struct = 0x400,
InterfaceImpl = 0x800,
ApiContract = 0x2000,
};
enum class CompositionType : int32_t
{
Protected = 1,
Public = 2,
};
enum class DeprecationType : int32_t
{
Deprecate = 0,
Remove = 1,
};
enum class FeatureStage : int32_t
{
AlwaysDisabled = 0,
DisabledByDefault = 1,
EnabledByDefault = 2,
AlwaysEnabled = 3,
};
enum class GCPressureAmount : int32_t
{
Low = 0,
Medium = 1,
High = 2,
};
enum class MarshalingType : int32_t
{
None = 1,
Agile = 2,
Standard = 3,
InvalidMarshaling = 0,
};
enum class Platform : int32_t
{
Windows = 0,
WindowsPhone = 1,
};
enum class ThreadingModel : int32_t
{
STA = 1,
MTA = 2,
Both = 3,
InvalidThreading = 0,
};
struct IApiInformationStatics;
struct ApiInformation;
}
namespace winrt::impl
{
template <> struct category<Windows::Foundation::Metadata::IApiInformationStatics>{ using type = interface_category; };
template <> struct category<Windows::Foundation::Metadata::ApiInformation>{ using type = class_category; };
template <> struct category<Windows::Foundation::Metadata::AttributeTargets>{ using type = enum_category; };
template <> struct category<Windows::Foundation::Metadata::CompositionType>{ using type = enum_category; };
template <> struct category<Windows::Foundation::Metadata::DeprecationType>{ using type = enum_category; };
template <> struct category<Windows::Foundation::Metadata::FeatureStage>{ using type = enum_category; };
template <> struct category<Windows::Foundation::Metadata::GCPressureAmount>{ using type = enum_category; };
template <> struct category<Windows::Foundation::Metadata::MarshalingType>{ using type = enum_category; };
template <> struct category<Windows::Foundation::Metadata::Platform>{ using type = enum_category; };
template <> struct category<Windows::Foundation::Metadata::ThreadingModel>{ using type = enum_category; };
template <> inline constexpr auto& name_v<Windows::Foundation::Metadata::ApiInformation> = L"Windows.Foundation.Metadata.ApiInformation";
template <> inline constexpr auto& name_v<Windows::Foundation::Metadata::AttributeTargets> = L"Windows.Foundation.Metadata.AttributeTargets";
template <> inline constexpr auto& name_v<Windows::Foundation::Metadata::CompositionType> = L"Windows.Foundation.Metadata.CompositionType";
template <> inline constexpr auto& name_v<Windows::Foundation::Metadata::DeprecationType> = L"Windows.Foundation.Metadata.DeprecationType";
template <> inline constexpr auto& name_v<Windows::Foundation::Metadata::FeatureStage> = L"Windows.Foundation.Metadata.FeatureStage";
template <> inline constexpr auto& name_v<Windows::Foundation::Metadata::GCPressureAmount> = L"Windows.Foundation.Metadata.GCPressureAmount";
template <> inline constexpr auto& name_v<Windows::Foundation::Metadata::MarshalingType> = L"Windows.Foundation.Metadata.MarshalingType";
template <> inline constexpr auto& name_v<Windows::Foundation::Metadata::Platform> = L"Windows.Foundation.Metadata.Platform";
template <> inline constexpr auto& name_v<Windows::Foundation::Metadata::ThreadingModel> = L"Windows.Foundation.Metadata.ThreadingModel";
template <> inline constexpr auto& name_v<Windows::Foundation::Metadata::IApiInformationStatics> = L"Windows.Foundation.Metadata.IApiInformationStatics";
template <> inline constexpr guid guid_v<Windows::Foundation::Metadata::IApiInformationStatics>{ 0x997439FE,0xF681,0x4A11,{ 0xB4,0x16,0xC1,0x3A,0x47,0xE8,0xBA,0x36 } }; // 997439FE-F681-4A11-B416-C13A47E8BA36
template <> struct abi<Windows::Foundation::Metadata::IApiInformationStatics>
{
struct __declspec(novtable) type : inspectable_abi
{
virtual int32_t __stdcall IsTypePresent(void*, bool*) noexcept = 0;
virtual int32_t __stdcall IsMethodPresent(void*, void*, bool*) noexcept = 0;
virtual int32_t __stdcall IsMethodPresentWithArity(void*, void*, uint32_t, bool*) noexcept = 0;
virtual int32_t __stdcall IsEventPresent(void*, void*, bool*) noexcept = 0;
virtual int32_t __stdcall IsPropertyPresent(void*, void*, bool*) noexcept = 0;
virtual int32_t __stdcall IsReadOnlyPropertyPresent(void*, void*, bool*) noexcept = 0;
virtual int32_t __stdcall IsWriteablePropertyPresent(void*, void*, bool*) noexcept = 0;
virtual int32_t __stdcall IsEnumNamedValuePresent(void*, void*, bool*) noexcept = 0;
virtual int32_t __stdcall IsApiContractPresentByMajor(void*, uint16_t, bool*) noexcept = 0;
virtual int32_t __stdcall IsApiContractPresentByMajorAndMinor(void*, uint16_t, uint16_t, bool*) noexcept = 0;
};
};
template <typename D>
struct consume_Windows_Foundation_Metadata_IApiInformationStatics
{
WINRT_IMPL_AUTO(bool) IsTypePresent(param::hstring const& typeName) const;
WINRT_IMPL_AUTO(bool) IsMethodPresent(param::hstring const& typeName, param::hstring const& methodName) const;
WINRT_IMPL_AUTO(bool) IsMethodPresent(param::hstring const& typeName, param::hstring const& methodName, uint32_t inputParameterCount) const;
WINRT_IMPL_AUTO(bool) IsEventPresent(param::hstring const& typeName, param::hstring const& eventName) const;
WINRT_IMPL_AUTO(bool) IsPropertyPresent(param::hstring const& typeName, param::hstring const& propertyName) const;
WINRT_IMPL_AUTO(bool) IsReadOnlyPropertyPresent(param::hstring const& typeName, param::hstring const& propertyName) const;
WINRT_IMPL_AUTO(bool) IsWriteablePropertyPresent(param::hstring const& typeName, param::hstring const& propertyName) const;
WINRT_IMPL_AUTO(bool) IsEnumNamedValuePresent(param::hstring const& enumTypeName, param::hstring const& valueName) const;
WINRT_IMPL_AUTO(bool) IsApiContractPresent(param::hstring const& contractName, uint16_t majorVersion) const;
WINRT_IMPL_AUTO(bool) IsApiContractPresent(param::hstring const& contractName, uint16_t majorVersion, uint16_t minorVersion) const;
};
template <> struct consume<Windows::Foundation::Metadata::IApiInformationStatics>
{
template <typename D> using type = consume_Windows_Foundation_Metadata_IApiInformationStatics<D>;
};
}
#endif
| [
"kenny.kerr@microsoft.com"
] | kenny.kerr@microsoft.com |
05e5d8954a8a1f0ad78bf503e12f7db8709b0969 | 5a88700bfdaa47e6ed95a3a0b559527c5b31a43a | /framework/simple_scene/src/mm/services/simple_scene.hpp | 3a5cbe0c55b2e7ca24ed4621761b12e25d64b259 | [
"MIT"
] | permissive | ford442/MushMachine | 84cdc07fa1ce63605c9cc87b0586667388e657eb | dc37ad54ec02aa4c1c30cca99d965cd705b3fa2f | refs/heads/master | 2023-08-23T03:17:39.362561 | 2021-10-22T18:49:49 | 2021-10-22T18:49:49 | 425,437,241 | 0 | 0 | NOASSERTION | 2021-11-07T07:43:52 | 2021-11-07T07:12:02 | null | UTF-8 | C++ | false | false | 1,238 | hpp | #pragma once
#include <mm/services/scene_service_interface.hpp>
#include <chrono>
namespace MM::Services {
// provides an implementation for SceneServiceInterface
class SimpleSceneService : public SceneServiceInterface {
private:
std::unique_ptr<Scene> _scene;
std::unique_ptr<Scene> _next_scene; // enqueued next scene
using clock = std::chrono::high_resolution_clock;
long long int _accumulator = 0;
std::chrono::time_point<clock> _last_time;
public:
const float f_delta;
float initial_delta_factor = 1.f;
public:
explicit SimpleSceneService(const float update_delta = 1.f/60.f) : f_delta(update_delta) {}
const char* name(void) override { return "SimpleSceneService"; }
bool enable(Engine& engine, std::vector<UpdateStrategies::TaskInfo>& task_array) override;
void disable(Engine& engine) override;
private:
void sceneFixedUpdate(Engine& engine);
void changeSceneFixedUpdate(Engine& engine);
public:
Scene& getScene(void) override { return *_scene; }
void changeScene(std::unique_ptr<Scene>&& new_scene) override;
// be carefull of that one
void changeSceneNow(std::unique_ptr<Scene>&& new_scene) override;
void resetTime(void);
};
} // MM::Services
| [
"green@g-s.xyz"
] | green@g-s.xyz |
67bf6f3bc9b2045e2690291ebc45b3e709431368 | 7dd6a8554de99377b3bb3eec8958eceb76a84c3c | /Lab08/Chong_2826945_Lab08/MinMax_Heap.h | 272dc37e255d48a5c2834a93636d9844e4c6050c | [] | no_license | PenguinBoyTC/DataStructure_C | 7f0ce17e9d1657699b8373e48e48f8ec24a3c8a4 | 3e6cdf9e377a7b1d7ad1d756449e1127de911d4a | refs/heads/master | 2020-04-30T06:41:42.481021 | 2019-03-20T05:19:38 | 2019-03-20T05:19:38 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,154 | h | #ifndef MINMAX_HEAP_H
#define MINMAX_HEAP_H
#include "HeapInterface.h"
#include <string>
#include <math.h>
//#include <algorithm>
template <typename T>
class MinMax_Heap: public HeapInterface<T>
{
public:
MinMax_Heap(int initialSize);//constructor
MinMax_Heap(const MinMax_Heap<T>& heap); // The copy constructor
MinMax_Heap(int initialSize, std::string filename);
~MinMax_Heap();
void buildheap();
void insert(T newItem);//add a Item to the tree
bool deletemin();
bool deletemax();
T findmin();//return the top Item from the tree
T findmax();
void levelorder(int k_heap);
bool isEmpty();//check if the tree is empty
private:
T* theCompleteBinaryTree;
int sizeOfArray;
int numItemsInHeap;
//helper functions
void insertbuild(int newIndex);
void swapbyMinLevel(int newIndex);
void swapbyMaxLevel(int newIndex);
bool isMaxLevel(int index);
bool isMinLevel(int index);
int Maxchild(int parent);
int Minchild(int parent);
void buildHelper(int parent);//switch the parent with all its child and swap until reach the bottom
int targetgrandChildIndex(int parent);
int targetChildIndex(int parent);
};
#include "MinMax_Heap.hpp"
#endif
| [
"31427334+PenguinBoyTC@users.noreply.github.com"
] | 31427334+PenguinBoyTC@users.noreply.github.com |
7362847df11136a317f15fc3a863b53e594a3a87 | 9310213affdbb681a8141336351bfe52b19a41fe | /linkedlist.hpp | 4caba2da84565529554e8b6db0bd4c62d4efda60 | [] | no_license | dh7qc/CS1510-HW03 | 3fa8a83f7ac4ca812d3877773c4134bb165d5114 | 3aac70d85889fd56f798933a787c91f0e1ef3999 | refs/heads/master | 2021-01-19T18:32:15.997395 | 2017-04-15T17:27:20 | 2017-04-15T17:27:20 | 88,362,880 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,023 | hpp | //Dennis Hahn CS1510 Section B Assignment 3
//LinkedList
#include <iostream>
#include <string>
using namespace std;
template <typename T>
void LinkedList<T>::insert_front(const T& x)
{
LinkedList<T> *tmp = new LinkedList<T>;
tmp-> m_data = this-> m_data;
tmp-> m_next = this-> m_next;
this-> m_data = x;
this-> m_next = tmp;
}
template <typename T>
void LinkedList<T>::insert(const T& x, LinkedList<T>* pos)
{
LinkedList<T> *tmp = new LinkedList<T>;
tmp-> m_data = pos-> m_data;
tmp-> m_next = pos-> m_next;
pos-> m_data = x;
pos-> m_next = tmp;
}
template <typename T>
const LinkedList<T>& LinkedList<T>::operator=(const LinkedList<T>& rhs)
{
if (this != &rhs)
{
clear();
LinkedList<T> *p = this;
const LinkedList<T> *q = &rhs;
while (q -> m_next != NULL)
{
p -> m_data = q -> m_data;
p -> m_next = new LinkedList<T>;
p = p -> m_next;
q = q -> m_next;
}
}
return *this;
}
template <typename T>
LinkedList<T>::LinkedList(const LinkedList<T>& rhs)
{
LinkedList<T> *p = this;
const LinkedList<T> *q = &rhs;
while (q -> m_next != NULL)
{
p -> m_data = q -> m_data;
p -> m_next = new LinkedList<T>;
p = p -> m_next;
q = q -> m_next;
}
}
template <typename T>
int LinkedList<T>::size() const
{
int counter = 0;
const LinkedList<T> *p = this;
while(p-> m_next != NULL)
{
counter++;
p = p->m_next;
}
return counter;
}
template <typename T>
bool LinkedList<T>::isEmpty() const
{
if (m_next == NULL)
return true;
else
return false;
}
template <typename T>
LinkedList<T>* LinkedList<T>::getFirstPtr()
{
if (m_next != NULL)
return this;
else
{
cout << "!!-- ERROR : PANIC in LINKEDLIST.getFirstPtr() - empty list";
cout << endl;
return NULL;
}
}
template <typename T>
LinkedList<T>* LinkedList<T>::getLastPtr()
{
LinkedList<T> *p = this;
if (m_next != NULL)
{
while (p -> m_next != NULL)
{
if (p-> m_next -> m_next != NULL)
p = p-> m_next;
else
return p;
}
}
else
{
cout << "!!-- ERROR : PANIC in LINKEDLIST.getLastPtr() - empty list";
cout << endl;
return NULL;
}
}
template <typename T>
LinkedList<T>* LinkedList<T>::getAtPtr(int i)
{
int counter = 0;
LinkedList<T> *p = this;
if (i < this -> size() && i >= 0)
{
while (p -> m_next != NULL && counter < i)
{
p = p -> m_next;
counter++;
}
return p;
}
else
{
cout << "!!-- ERROR : PANIC in LINKEDLIST.getAtPtr() - invalid index";
cout << endl;
return 0;
}
}
template <typename T>
void LinkedList<T>::clear()
{
while (m_next != NULL)
{
remove(this);
}
}
template <typename T>
void LinkedList<T>::remove(LinkedList<T>* pos)
{
LinkedList<T> *tmp = pos-> m_next;
pos -> m_data = tmp -> m_data;
pos -> m_next = tmp -> m_next;
delete tmp;
}
template <typename T>
bool LinkedList<T>::operator==(const LinkedList<T>& rhs) const
{
const LinkedList<T> *p = this;
const LinkedList<T> *q = &rhs;
bool equal = true;
while (q -> m_next != NULL && p -> m_next != NULL && equal != false)
{
if (q -> m_data != p -> m_data)
{
equal = false;
}
else
{
q = q -> m_next;
p = p -> m_next;
}
}
if ((q -> m_next == NULL && p -> m_next != NULL) ||
((q -> m_next != NULL && p -> m_next == NULL)))
{
equal = false;
}
return equal;
}
template <typename T>
void LinkedList<T>::reverse()
{
LinkedList<T> *p = this;
LinkedList<T> *q;
while (p -> m_next != NULL)
{
q = getLastPtr();
insert(q -> m_data, p);
remove(q);
p = p -> m_next;
}
}
template <typename T>
LinkedList<T>* LinkedList<T>::find(const T& x)
{
LinkedList<T> *p = this;
bool found = false;
while (p -> m_next != NULL && found == false)
{
if (p-> m_data == x)
found = true;
else
p = p -> m_next;
}
if (found == true)
return p;
else
return NULL;
}
template <typename T>
void LinkedList<T>::append(const LinkedList<T>& xlist)
{
const LinkedList<T> *p = &xlist;
while (p -> m_next != NULL)
{
insert(p -> m_data, getLastPtr()->m_next);
p = p -> m_next;
}
}
| [
"dh7qc@mst.edu"
] | dh7qc@mst.edu |
e7782ac5d9e499f80c1e579f236c304f787bd527 | 2a91fa3eb624d07bf763e3390acc4d22610acb3b | /include/Core/QuantumCircuit/QReset.h | e9354445172ed863db0509df323c90192e53a8f5 | [
"Apache-2.0"
] | permissive | YeweiYuan/QPanda-2 | 3ee1ae32695dcd14a55de3257ddbc9daad28b4d4 | 7087f1a002e8248bc46e6c16968fae5071243efd | refs/heads/master | 2023-05-02T04:00:49.875822 | 2021-05-27T03:04:34 | 2021-05-27T03:04:34 | 309,905,736 | 1 | 0 | Apache-2.0 | 2021-05-27T03:04:35 | 2020-11-04T06:07:55 | null | UTF-8 | C++ | false | false | 3,830 | h | /*
Copyright (c) 2017-2020 Origin Quantum Computing. All Right Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
/*! \file QReset.h */
#pragma once
#include "Core/QuantumMachine/QubitFactory.h"
#include "Core/QuantumCircuit/QNode.h"
#include "Core/QuantumCircuit/ClassicalConditionInterface.h"
QPANDA_BEGIN
/**
* @class AbstractQuantumReset
* @brief Quantum Reset basic abstract class
* @ingroup QuantumCircuit
*/
class AbstractQuantumReset
{
public:
/**
* @brief Get the reset qubit
* @return Qubit *
*/
virtual Qubit * getQuBit() const = 0;
virtual ~AbstractQuantumReset() {}
};
/**
* @class QReset
* @brief Quantum Reset basic class
* @ingroup QuantumCircuit
*/
class QReset : public AbstractQuantumReset
{
private:
std::shared_ptr<AbstractQuantumReset> m_reset;
public:
QReset() = delete;
QReset(const QReset &);
QReset(Qubit *);
QReset(std::shared_ptr<AbstractQuantumReset> node);
std::shared_ptr<AbstractQuantumReset> getImplementationPtr();
~QReset();
/**
* @brief Get reset node qubit address
* @return QPanda::Qubit* QuBit address
*/
Qubit * getQuBit() const;
/**
* @brief Get current node type
* @return NodeType current node type
* @see NodeType
*/
NodeType getNodeType() const;
};
typedef AbstractQuantumReset * (*CreateReset)(Qubit *);
/**
* @brief Factory for class AbstractQuantumReset
* @ingroup QuantumCircuit
*/
class QResetFactory
{
public:
void registClass(std::string name, CreateReset method);
AbstractQuantumReset * getQuantumReset(std::string &, Qubit *);
/**
* @brief Get the static instance of factory
* @return QResetFactory &
*/
static QResetFactory & getInstance()
{
static QResetFactory s_Instance;
return s_Instance;
}
private:
std::map<std::string, CreateReset> m_reset_map;
QResetFactory() {};
};
/**
* @brief Quantum reset register action
* @note Provide QResetFactory class registration interface for the outside
*/
class QuantumResetRegisterAction {
public:
QuantumResetRegisterAction(std::string className, CreateReset ptrCreateFn) {
QResetFactory::getInstance().registClass(className, ptrCreateFn);
}
};
#define REGISTER_RESET(className) \
AbstractQuantumReset* objectCreator##className(Qubit * pQubit){ \
return new className(pQubit); \
} \
QuantumResetRegisterAction g_resetCreatorRegister##className( \
#className,(CreateReset)objectCreator##className)
/**
* @brief Implementation class of QReset
* @ingroup QuantumCircuit
*/
class OriginReset : public QNode, public AbstractQuantumReset
{
public:
OriginReset(Qubit *);
~OriginReset() {};
/**
* @brief Get reset node qubit address
* @return QPanda::Qubit* QuBit address
*/
Qubit * getQuBit() const;
/**
* @brief Get current node type
* @return NodeType current node type
* @see NodeType
*/
NodeType getNodeType() const;
private:
OriginReset();
OriginReset(OriginReset &);
NodeType m_node_type;
Qubit * m_target_qubit;
};
/**
* @brief QPanda2 basic interface for creating a quantum Reset node
* @param[in] Qubit* Qubit pointer
* @return QPanda::QReset quantum reset node
* @ingroup QuantumCircuit
*/
QReset Reset(Qubit *);
QPANDA_END | [
"wj@originqc.cn"
] | wj@originqc.cn |
a9785ecb44604e5bd806fdff0cc2b265300c6313 | 1f032ac06a2fc792859a57099e04d2b9bc43f387 | /c6/e7/01/c0/1514a5d42345b6a9bd5ebad0ef490f60d2c8fac8dd9d9ddf2cd0bbd8979460af21b6c59fa60a83248b61142b65e17627993870318a63c0f33b8b8ce5/sw.cpp | b36b5626c16038aba0325eb93f26ab4826a35b30 | [] | no_license | SoftwareNetwork/specifications | 9d6d97c136d2b03af45669bad2bcb00fda9d2e26 | ba960f416e4728a43aa3e41af16a7bdd82006ec3 | refs/heads/master | 2023-08-16T13:17:25.996674 | 2023-08-15T10:45:47 | 2023-08-15T10:45:47 | 145,738,888 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 972 | cpp | void build(Solution &s)
{
auto &t = s.addTarget<LibraryTarget>("amazon.awslabs.crt_cpp", "0.17.11");
t += Git("https://github.com/awslabs/aws-crt-cpp", "v{v}");
t -=
"include/.*"_rr,
"source/.*"_rr;
t += "source/.*"_rr;
if (t.getCompilerType() == CompilerType::MSVC)
t.CompileOptions.push_back("-bigobj");
//else if (s.Settings.Native.CompilerType == CompilerType::GNU)
//t.CompileOptions.push_back("-Wa,-mbig-obj");
t.Private += sw::Shared, "AWS_CRT_CPP_EXPORTS"_d;
t.Public += sw::Shared, "AWS_CRT_CPP_USE_IMPORT_EXPORT"_d;
t.Public += "org.sw.demo.amazon.awslabs.c_auth"_dep;
t.Public += "org.sw.demo.amazon.awslabs.c_event_stream"_dep;
t.Public += "org.sw.demo.amazon.awslabs.c_mqtt"_dep;
t.Public += "org.sw.demo.amazon.awslabs.c_s3"_dep;
t.Variables["AWS_CRT_CPP_VERSION"] = t.Variables["PACKAGE_VERSION"];
t.configureFile("include/aws/crt/Config.h.in", "aws/crt/Config.h");
}
| [
"cppanbot@gmail.com"
] | cppanbot@gmail.com |
4f7a670b56b733c59f6ceba3ed2b9605015eea89 | 19842f800160fdb4f0266e1d13c3e868542d75cb | /include/ext/audio/CClassBuilder.h | 9768659413a142f5d9600308cd1def6520b78b6c | [] | no_license | benjaminhampe/DarkGDK | 3e32b404d9aafb014a08c39324153bc1888771b8 | 32823a6b350caef3c114daf60d954b73994e3517 | refs/heads/master | 2020-06-02T04:05:29.866871 | 2014-02-28T21:33:30 | 2014-02-28T21:33:30 | 17,301,390 | 1 | 2 | null | null | null | null | UTF-8 | C++ | false | false | 9,067 | h | // Copyright (C) 2002-2013 Benjamin Hampe
// This file is part of the "irrlicht-engine"
// For conditions of distribution and use, see copyright notice in irrlicht.h
#ifndef __IRR_EXT_C_CLASS_BUILDER_MANAGER_H__
#define __IRR_EXT_C_CLASS_BUILDER_MANAGER_H__
//#include <sys/stat.h>
//#include <sys/io.h>
//#include <sys/ioctl.h>
//#include <sys/user.h>
//#include <sys/soundcard.h>
//#include <sys/termios.h>
//#include <cstdlib>
//#include <cstdio>
//#include <cmath>
//#include <cstring>
//#include <cstdarg>
#include <irrlicht.h>
#include <cstdio>
#include <stdio.h>
namespace irr{
namespace core{
/// @brief Container == array of stringc
typedef array<stringc> Container;
/// @brief SystemCall to stringc
bool trimLine( stringc& line, u32 loop_count = 3, const c8* char_list = ":./", const u32 char_count = 3 );
/// @brief SystemCall to stringc
stringc SingleSysCall( const stringc& command, const u32 LENGTH = 1024 );
/// @brief SystemCall to Container ( multiline )
Container MultiSysCall( const stringc& command, const u32 LENGTH = 1024 );
/// @brief SystemCall to TextFile ( store shell result to text-file )
bool StoreCall( const stringc& command, const stringc& filename = "./tmp.txt", const u32 LENGTH = 1024 );
/// @brief add output of SystemCall to Container ( ram )
bool AddLines( Container& container, const stringc& command, const u32 LENGTH = 1024 );
/// @brief Container to TextFile ( store ram to hdd )
bool LoadLines( Container& container, const stringc& filename = "./tmp.txt", const u32 LENGTH = 1024 );
/// @brief Container to TextFile ( store ram to hdd )
bool StoreLines( const Container& container, const stringc& filename = "./tmp.txt" );
/// @brief List all files of given extension-list
u32 FindFiles( Container& out, const stringc& rootDir, const Container& fileTypes );
/// @brief Print all lines
void Print( const Container& out );
/// @brief GetDir
stringc GetDir();
/// @brief SetDir
void SetDir( const stringc& new_dir );
enum E_ATTRIBUTES
{
EAOF_NONE = 0,
EAOF_UNKNOWN = 1,
EAOF_PUBLIC = 1<<1,
EAOF_PROTECTED = 1<<2,
EAOF_PRIVATE = 1<<3,
EAOF_STATIC = 1<<4,
EAOF_CONST = 1<<5,
EAOF_VIRTUAL = 1<<6,
EAOF_INLINE = 1<<7
// EAOF_LVALUE = 1<<8
// EAOF_REFERENCE = 1<<9
// EAOF_POINTER = 1<<10
// EAOF_RValue = 1<<11
// EAOF_VARIABLE_DEF = 1<<11
// EAOF_VARIABLE_DECL = 1<<11
// EAOF_FUNCTION_DEF = 1<<11
// EAOF_FUNCTION_DECL = 1<<11
// EAOF_MACRO_DEF = 1<<11
// EAOF_CLASS = 1<<11
// EAOF_STRUCT = 1<<11
// EAOF_INTERFACE = 1<<11
// EAOF_INTERFACE = 1<<11
};
class CClassAttributes
{
public:
u32 Attributes;
//C++:
//Bit setzen: var |= 1<<Bitnummer; /* Bitnr ab 0 */
//Bit loeschen: var &= ~(1<<Bitnummer);
///@brief Default constructor
CClassAttributes()
{
Attributes = (u32)EAOF_NONE;
Attributes |= (u32)EAOF_PUBLIC;
Attributes |= (u32)EAOF_INLINE;
Attributes |= (u32)EAOF_VIRTUAL;
}
///@brief Default constructor
virtual ~CClassAttributes()
{
}
///@brief Clear All Flags
virtual CClassAttributes& clear()
{
Attributes = (u32)EAOF_NONE;
return *this;
}
///@brief Set public
virtual CClassAttributes& setUnknown()
{
Attributes |= (u32)EAOF_UNKNOWN;
return *this;
}
///@brief Set public
virtual CClassAttributes& setPublic()
{
Attributes |= (u32)EAOF_PUBLIC;
Attributes &= ~((u32)EAOF_PRIVATE + (u32)EAOF_PROTECTED + (u32)EAOF_STATIC );
return *this;
}
///@brief Set protected
virtual CClassAttributes& setProtected()
{
Attributes |= (u32)EAOF_PROTECTED;
Attributes &= ~((u32)EAOF_PUBLIC + (u32)EAOF_PRIVATE + (u32)EAOF_STATIC );
return *this;
}
///@brief Set private
virtual CClassAttributes& setPrivate()
{
Attributes |= EAOF_PRIVATE;
Attributes &= ~((u32)EAOF_PUBLIC + (u32)EAOF_PROTECTED + (u32)EAOF_STATIC );
return *this;
}
///@brief Set static
virtual CClassAttributes& setStatic()
{
Attributes |= ((u32)EAOF_PUBLIC + (u32)EAOF_STATIC);
Attributes &= ~((u32)EAOF_PROTECTED + (u32)EAOF_PRIVATE );
return *this;
}
///@brief Set virtual
virtual CClassAttributes& setVirtual()
{
Attributes |= (u32)EAOF_VIRTUAL;
return *this;
}
///@brief Set inline
virtual CClassAttributes& setInline()
{
Attributes |= (u32)EAOF_INLINE;
Attributes &= ~((u32)EAOF_STATIC);
return *this;
}
///@brief Get value member-variable.
virtual bool isPublic() const
{
if ( Attributes & (u32)EAOF_PUBLIC )
return true;
else
return false;
}
///@brief Get value member-variable.
virtual bool isProtected() const
{
if ( Attributes & (u32)EAOF_PROTECTED )
return true;
else
return false;
}
///@brief Get value member-variable.
virtual bool isPrivate() const
{
if ( Attributes & (u32)EAOF_PRIVATE )
return true;
else
return false;
}
///@brief Get value member-variable.
virtual bool isStatic() const
{
if ( Attributes & (u32)EAOF_STATIC )
return true;
else
return false;
}
///@brief Get value member-variable.
virtual bool isVirtual() const
{
if ( Attributes & (u32)EAOF_VIRTUAL )
return true;
else
return false;
}
///@brief Get value member-variable.
virtual bool isInline() const
{
if ( Attributes & (u32)EAOF_INLINE )
return true;
else
return false;
}
};
class CBaseVariable : IReferenceCounted
{
stringc Name;
stringc Type;
stringc InitValue;
CClassAttributes Attributes;
public:
CBaseVariable(
const stringc& name = stringc("Variable_"),
const stringc& type = stringc("u32"),
const stringc& init = stringc("0"),
const CClassAttributes& attribs = CClassAttributes())
: Name(name), Type(type), InitValue(init), Attributes(attribs)
{
}
};
class CBaseFunction : IReferenceCounted
{
stringc Name;
stringc ReturnType;
stringc Visibility; // public, protected, private
CClassAttributes Attributes;
typedef array<CBaseVariable> SParameterList;
SParameterList ParamList;
public:
CBaseFunction(
const stringc& name = stringc("NumberingSomething"), // class IUnknown
const stringc& returntype = stringc("u32"), // types: struct:"struct S", class:"class C", int[erface]:"class I"
const CClassAttributes& attributes = CClassAttributes())
: Name(name)
, ReturnType(returntype)
, Attributes(attributes)
{
}
~CBaseFunction()
{
ParamList.clear();
}
virtual void addParam(
const stringc& name = stringc("Variable_"),
const stringc& type = stringc("u32"),
const stringc& init = stringc("0"),
const CClassAttributes& attribs = CClassAttributes() )
{
ParamList.push_back( CBaseVariable(name, type, init, attribs ) );
}
};
struct CClassVariable : CBaseVariable
{
bool HasGetter;
bool HasConstGetter;
bool HasSetter;
CClassVariable(
const stringc& name = stringc("NumberOfSomething"),
const stringc& type = stringc("u32"),
const stringc& init = stringc("0"),
const CClassAttributes& attribs = CClassAttributes().setVirtual().setInline(),
bool hasGetter = true,
bool hasConstGetter = true,
bool hasSetter = true )
: CBaseVariable( name, type, init, attribs)
, HasGetter(hasGetter), HasConstGetter(hasConstGetter), HasSetter(hasSetter)
{
}
};
class CClassFunction : public CBaseFunction
{
};
class CClass
{
typedef array<CClassAttributes> Attributes;
typedef array<stringc> Lines;
typedef array<CClassVariable> Variables;
typedef array<CClassFunction> Functions;
stringc m_Name;
Attributes m_Attributes;
Lines m_Comments;
Variables m_Variables;
Functions m_Functions;
public:
CClass(
const stringc& name,
const CClass::Attributes& attribs,
const CClass::Variables& vars,
const CClass::Functions& funs );
virtual ~CClass();
virtual void addVariable( const CClassVariable& v )
{
m_Variables.push_back( v );
}
virtual void addFunction( const CClassFunction& f )
{
m_Functions.push_back( f );
}
virtual void addComment( const stringc& comment = "")
{
m_Comments.push_back( comment );
}
virtual void addBlock( const stringc& block_name, bool isFolded = false )
{
// m_Functions.push_back( my_fun );
}
virtual void addMarkDown( const stringc& md_file_or_txt )
{
// m_Functions.push_back( my_fun );
}
};
class CClassBuilder : public IReferenceCounted
{
s32 Argc;
c8** Argv;
array<CClass> Classes;
public:
CClassBuilder ( s32 argc = 0, c8** argv = 0L );
~CClassBuilder ();
///@brief get Pointer to single class.
///@param index Index of class-array.
///@return Pointer to single class.
virtual u32 getClassCount() const
{
return Classes.size();
}
///@brief get Pointer to single clas.
///@param index Index of class-array.
///@return Pointer to single class.
virtual core::CClass& getClass( u32 index = 0 )
{
_IRR_DEBUG_BREAK_IF( index >= getClassCount() )
return Classes[index];
}
///@brief add Class
///@param id Unique identifier of this text-shape
///@param name Name of the ISceneNode
///@return true on success
virtual bool addClass( const core::CClass& other)
{
u32 old_size = Classes.size();
Classes.push_back( other );
return (Classes.size()-old_size>0)?true:false;
}
};
} // end namespace core
} // end namespace irr
#endif // __IRR_EXT_CLASS_BUILDER_H__
| [
"benjaminhampe@gmx.de"
] | benjaminhampe@gmx.de |
fd931fc5abdd90548a4b1c8da4cf25ec8019b5ae | 86b8d7ae67b320f016f8f16ae1a879262050f76c | /Image Morphing/graph.h | edb0d59e039475685fcb44ca44d3b19b04a7c1fe | [] | no_license | tobygameac/Image-Morphing | acb77a8cf0267969b66fd5b5d599e919e4197c17 | 96036405344ff2feb79100f581a30120793b9850 | refs/heads/master | 2021-01-17T09:34:10.296236 | 2016-10-03T07:35:08 | 2016-10-03T07:35:08 | 53,070,607 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,046 | h | #pragma once
#include <utility>
#include <vector>
class Edge {
public:
Edge() {
}
Edge(const std::pair<size_t, size_t> &edge_indices_pair) : edge_indices_pair_(edge_indices_pair) {
}
Edge(const std::pair<size_t, size_t> &edge_indices_pair, double weight) : edge_indices_pair_(edge_indices_pair), weight_(weight) {
}
const bool operator <(const Edge &other) {
if (weight_ != other.weight_) {
return weight_ < other.weight_;
}
if ((edge_indices_pair_.first != other.edge_indices_pair_.first)) {
return edge_indices_pair_.first < other.edge_indices_pair_.first;
}
return edge_indices_pair_.second < other.edge_indices_pair_.second;
}
std::pair<size_t, size_t> edge_indices_pair_;
double weight_;
};
template <class T>
class Graph {
public:
Graph() {
}
Graph(std::vector<T> &vertices, std::vector<Edge> &edges) : vertices_(vertices), edges_(edges) {
}
void Clear() {
vertices_.clear();
edges_.clear();
}
std::vector<T> vertices_;
std::vector<Edge> edges_;
};
| [
"tobyreallygameac@gmail.com"
] | tobyreallygameac@gmail.com |
5532b2566f18270be636e4b94cf42339e917c3d2 | 19194c2f2c07ab3537f994acfbf6b34ea9b55ae7 | /android-30/java/lang/reflect/ReflectPermission.hpp | 63dd381a4cb61ca239afa638fbbc8d9af652129d | [
"GPL-3.0-only"
] | permissive | YJBeetle/QtAndroidAPI | e372609e9db0f96602da31b8417c9f5972315cae | ace3f0ea2678967393b5eb8e4edba7fa2ca6a50c | refs/heads/Qt6 | 2023-08-05T03:14:11.842336 | 2023-07-24T08:35:31 | 2023-07-24T08:35:31 | 249,539,770 | 19 | 4 | Apache-2.0 | 2022-03-14T12:15:32 | 2020-03-23T20:42:54 | C++ | UTF-8 | C++ | false | false | 839 | hpp | #pragma once
#include "../../../JString.hpp"
#include "./ReflectPermission.def.hpp"
namespace java::lang::reflect
{
// Fields
// Constructors
inline ReflectPermission::ReflectPermission(JString arg0)
: java::security::BasicPermission(
"java.lang.reflect.ReflectPermission",
"(Ljava/lang/String;)V",
arg0.object<jstring>()
) {}
inline ReflectPermission::ReflectPermission(JString arg0, JString arg1)
: java::security::BasicPermission(
"java.lang.reflect.ReflectPermission",
"(Ljava/lang/String;Ljava/lang/String;)V",
arg0.object<jstring>(),
arg1.object<jstring>()
) {}
// Methods
} // namespace java::lang::reflect
// Base class headers
#include "../../security/Permission.hpp"
#include "../../security/BasicPermission.hpp"
#ifdef QT_ANDROID_API_AUTOUSE
using namespace java::lang::reflect;
#endif
| [
"yjbeetle@gmail.com"
] | yjbeetle@gmail.com |
98e1c272fbae16c503b1ad51c1fd966c523b69bd | 4a16b421147ba8f1a0e280acec629cf362fafa94 | /include/Sapph/Vector3.h | 8ccd0d887651cf3d29e88b9a78264cf7c5182904 | [] | no_license | tnaselow/Test_Game | 0173a4d895fb77e2d1921ff6eb6f6573cb9a11ca | 90fae3adf699eeb4f6f63693ab06a7aa0396e997 | refs/heads/master | 2021-01-01T05:13:02.153039 | 2016-05-25T23:13:38 | 2016-05-25T23:13:38 | 58,480,060 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 882 | h | #pragma once
#include <iostream>
class Vector3
{
public:
Vector3(float x = 0, float y = 0, float z = 0);
Vector3(const Vector3 &vec);
~Vector3();
void Set(float x, float y, float z);
float Dot(const Vector3 &vec) const;
float Magnitude() const;
Vector3 Cross(const Vector3 &vec) const;
Vector3 &Scale(float scalar);
Vector3 &Normalize();
Vector3 &operator=(const Vector3 &vec);
bool operator==(const Vector3 &vec);
Vector3 &operator /=(float scalar);
Vector3 &operator *=(float scalar);
Vector3 &operator +=(const Vector3 &vec);
Vector3 &operator -=(const Vector3 &vec);
Vector3 operator /(float scalar) const;
Vector3 operator *(float scalar) const;
Vector3 operator +(const Vector3 &vec) const;
Vector3 operator -(const Vector3 &vec) const;
friend std::ostream &operator<<(std::ostream &os, const Vector3 &vec);
float X, Y, Z;
}; | [
"t.naselow@digipen.edu"
] | t.naselow@digipen.edu |
769b6c84ac4f6ddca5aaebaebe8900f0f4cc91da | acbed65c0fae90e223ad18188417009dbc949567 | /Lk_test/lk_demo.cpp | 2fdd65171db4331276d4bb06755c45f7c04d2dd8 | [] | no_license | laokingshineUAV/openCV_1.0 | 11630d33c434e36bd45c80050f655cff7a4e33e2 | b8d56ff0593fe93583f0f1cf4c3d9f4f8ef5c42f | refs/heads/master | 2020-03-16T14:02:01.925042 | 2018-05-10T13:33:54 | 2018-05-10T13:33:54 | 132,705,626 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,267 | cpp | #include "opencv2/video/tracking.hpp"
#include "opencv2/imgproc.hpp"
#include "opencv2/videoio.hpp"
#include "opencv2/highgui.hpp"
#include <iostream>
#include <ctype.h>
using namespace cv;
using namespace std;
static void help()
{
// print a welcome message, and the OpenCV version
cout << "\nThis is a demo of Lukas-Kanade optical flow lkdemo(),\n"
"Using OpenCV version " << CV_VERSION << endl;
cout << "\nIt uses camera by default, but you can provide a path to video as an argument.\n";
cout << "\nHot keys: \n"
"\tESC - quit the program\n"
"\tr - auto-initialize tracking\n"
"\tc - delete all the points\n"
"\tn - switch the \"night\" mode on/off\n"
"To add/remove a feature point click it\n" << endl;
}
Point2f point;
bool addRemovePt = false;
static void onMouse(int event, int x, int y, int /*flags*/, void* /*param*/)
{
if (event == EVENT_LBUTTONDOWN)
{
point = Point2f((float)x, (float)y);
addRemovePt = true;
}
}
int main(int argc, char** argv)
{
VideoCapture cap;
TermCriteria termcrit(TermCriteria::COUNT | TermCriteria::EPS, 20, 0.03);
Size subPixWinSize(10, 10), winSize(31, 31);
const int MAX_COUNT = 500;
bool needToInit = false;
bool nightMode = false;
help();
cv::CommandLineParser parser(argc, argv, "{@input|0|}");
string input = parser.get<string>("@input");
if (input.size() == 1 && isdigit(input[0]))
cap.open(input[0] - '0');
else
cap.open(input);
if (!cap.isOpened())
{
cout << "Could not initialize capturing...\n";
return 0;
}
namedWindow("LK Demo", 1);
setMouseCallback("LK Demo", onMouse, 0);
Mat gray, prevGray, image, frame;
vector<Point2f> points[2];
for (;;)
{
cap >> frame;
if (frame.empty())
break;
frame.copyTo(image);
cvtColor(image, gray, COLOR_BGR2GRAY);
if (nightMode)
image = Scalar::all(0);
if (needToInit)
{
// automatic initialization
goodFeaturesToTrack(gray, points[1], MAX_COUNT, 0.01, 10, Mat(), 3, 0, 0.04);
cornerSubPix(gray, points[1], subPixWinSize, Size(-1, -1), termcrit);
addRemovePt = false;
}
else if (!points[0].empty())
{
vector<uchar> status;
vector<float> err;
if (prevGray.empty())
gray.copyTo(prevGray);
calcOpticalFlowPyrLK(prevGray, gray, points[0], points[1], status, err, winSize,
3, termcrit, 0, 0.001);
size_t i, k;
for (i = k = 0; i < points[1].size(); i++)
{
if (addRemovePt)
{
if (norm(point - points[1][i]) <= 5)
{
addRemovePt = false;
continue;
}
}
if (!status[i])
continue;
points[1][k++] = points[1][i];
circle(image, points[1][i], 3, Scalar(0, 255, 0), -1, 8);
}
points[1].resize(k);
}
if (addRemovePt && points[1].size() < (size_t)MAX_COUNT)
{
vector<Point2f> tmp;
tmp.push_back(point);
cornerSubPix(gray, tmp, winSize, Size(-1, -1), termcrit);
points[1].push_back(tmp[0]);
addRemovePt = false;
}
needToInit = false;
imshow("LK Demo", image);
char c = (char)waitKey(10);
if (c == 27)
break;
switch (c)
{
case 'r':
needToInit = true;
break;
case 'c':
points[0].clear();
points[1].clear();
break;
case 'n':
nightMode = !nightMode;
break;
}
std::swap(points[1], points[0]);
cv::swap(prevGray, gray);
}
return 0;
}
| [
"laokingshine@sjtu.edu.cn"
] | laokingshine@sjtu.edu.cn |
be77f63a34082c869b26e098057e403470e60438 | 9a7e537e2f6ad47302256b7e2ff006b9b7d75d06 | /DirectSoundforUnity/CWindow.cpp | 220a4423f18e976bdaf2777bb12b3c0dfa39f187 | [] | no_license | Taku3939/DirectSoundforUnity | a28cf65488ef35c86f32197366b04a743d1043aa | 7eb63c3b2a74b9f86e728a3e05bf1c0766f4b405 | refs/heads/master | 2021-05-19T19:21:06.114729 | 2020-04-01T05:42:02 | 2020-04-01T05:42:02 | 252,080,786 | 0 | 0 | null | null | null | null | SHIFT_JIS | C++ | false | false | 8,668 | cpp | #pragma once
#pragma warning( disable : 4996 )
#include "CWindow.h"
///////////////////////////////////////////////////////////////////////////////////
// スタティック変数
///////////////////////////////////////////////////////////////////////////////////
HINSTANCE CWindow::hInstance = NULL;
HWND CWindow::hWnd = NULL;
BOOL CWindow::bActive = TRUE;
WCHAR CWindow::mName[256] = L"";
const WCHAR* CWindow::cIconID = IDI_APPLICATION; // デフォルトのアイコン
HMENU CWindow::hMenu = NULL;
DWORD CWindow::dwStyle = WS_POPUP | WS_SYSMENU | WS_CAPTION | WS_MINIMIZEBOX;
DWORD CWindow::dwExStyle = 0;
LPONMSG CWindow::mMsg = NULL;
int CWindow::iMsg = 0;
///////////////////////////////////////////////////////////////////////////////////
// コンストラクタ
///////////////////////////////////////////////////////////////////////////////////
CWindow::CWindow(void)
{
}
///////////////////////////////////////////////////////////////////////////////////
// デストラクタ
///////////////////////////////////////////////////////////////////////////////////
CWindow::~CWindow()
{
}
///////////////////////////////////////////////////////////////////////////////////
// メインウインドウのイベントハンドラ
///////////////////////////////////////////////////////////////////////////////////
LRESULT CALLBACK CWindow::WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
static CWindow* win = NULL;
switch (uMsg)
{
case WM_CREATE:
win = (CWindow*)lParam;
break;
case WM_ACTIVATE:
bActive = LOWORD(wParam) ? TRUE : FALSE; // アクティブ状態変更
break;
case WM_DESTROY: // ALT+F4が押されたら
PostQuitMessage(0);
break;
case WM_MOUSEMOVE:
break;
case WM_SYSCOMMAND:
switch (wParam)
{
case SC_CLOSE:
PostQuitMessage(0);
return 0;
}
break;
case WM_IME_NOTIFY:
switch (wParam)
{
case IMN_SETOPENSTATUS:
HIMC hImc = ImmGetContext(hWnd);
ImmSetOpenStatus(hImc, FALSE);
break;
}
break;
}
// 特殊メッセージ処理
int i;
for (i = 0; i < iMsg; i++) {
if (uMsg == mMsg[i].uiMsg) {
return mMsg[i].cmdProc(hWnd, wParam, lParam); // 特殊メッセージ操作完了なら
}
}
return DefWindowProc(hWnd, uMsg, wParam, lParam); // デフォルトを返す
}
///////////////////////////////////////////////////////////////////////////////////
// ウインドウを生成する
///////////////////////////////////////////////////////////////////////////////////
BOOL CWindow::Create(HINSTANCE hInst, const WCHAR* appName, BOOL show, DWORD w, DWORD h, HWND parent)
{
WNDCLASS wc;
DEVMODE dmMode;
// 画面解像度をチェック
EnumDisplaySettings(NULL, ENUM_CURRENT_SETTINGS, &dmMode);
// 16bit以上の解像度じゃないと起動できない
if (dmMode.dmBitsPerPel < 16) {
MessageBoxW(GetDesktopWindow(), L"16Bit以上の解像度にしてください", L"起動できません", MB_OK);
return FALSE;
}
// セット
hInstance = hInst;
wcscpy(mName, appName);
// ウインドウクラス登録
wc.style = CS_HREDRAW | CS_VREDRAW | CS_BYTEALIGNCLIENT;
wc.lpfnWndProc = WindowProc;
wc.cbClsExtra = 0;
wc.cbWndExtra = sizeof(DWORD);
wc.hInstance = hInstance;
wc.hIcon = LoadIcon(hInstance, cIconID);
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
wc.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
wc.lpszMenuName = MAKEINTRESOURCE(hMenu);
wc.lpszClassName = mName;
if (!RegisterClass(&wc))
return FALSE;
// ウインドウ生成
hWnd = CreateWindowExW(
dwExStyle,
wc.lpszClassName, // Class
mName, // Title bar
dwStyle, // Style
GetSystemMetrics(SM_CXSCREEN) / 2 - w / 2,
GetSystemMetrics(SM_CYSCREEN) / 2 - h / 2,
w, // Init. x pos
h, // Init. y pos
parent, // Parent window
NULL, // Menu handle
hInstance, // Program handle
this // Create parms
);
if (!hWnd)
return FALSE; // 生成に失敗
// フォントの設定
HDC hdc = GetDC(hWnd);
if (hdc) {
SetBkMode(hdc, TRANSPARENT);
ReleaseDC(hWnd, hdc);
}
MoveClientWindowCenter(w, h);
// ウインドウを表示
if (show)
::ShowWindow(hWnd, SW_SHOW);
return TRUE;
}
///////////////////////////////////////////////////////////////////////////////////
// 明示的にウィンドウを削除する
///////////////////////////////////////////////////////////////////////////////////
void CWindow::Delete(void)
{
if (hWnd) {
// 通常のウィンドウなら
::DestroyWindow(hWnd);
// 登録したクラス名を解除
UnregisterClassW(mName, hInstance);
ZeroMemory(&mName, sizeof(mName));
hWnd = NULL;
hInstance = NULL;
}
}
///////////////////////////////////////////////////////////////////////////////////
// カーソルの表示・非表示
///////////////////////////////////////////////////////////////////////////////////
void CWindow::ShowCursor(BOOL bShow)
{
if (bShow)
while (::ShowCursor(TRUE) < 0);
else
while (::ShowCursor(FALSE) >= 0);
}
///////////////////////////////////////////////////////////////////////////////////
// ウインドウの表示・非表示
///////////////////////////////////////////////////////////////////////////////////
void CWindow::ShowWindow(BOOL bShow)
{
// ウインドウの表示
if (bShow)
::ShowWindow(hWnd, SW_SHOW);
else
::ShowWindow(hWnd, SW_HIDE);
}
///////////////////////////////////////////////////////////////////////////////////
// アプリケーションのアイコンの変更
///////////////////////////////////////////////////////////////////////////////////
void CWindow::SetIcon(const WCHAR* icon)
{
cIconID = icon;
}
// 特殊メッセージの追加
BOOL CWindow::AddMsgProc(UINT msg, ONCOMMAND proc)
{
int i;
// 既に存在していないかチェック
for (i = 0; i < iMsg; i++) {
if (mMsg[i].uiMsg == msg) {
// あれば新しいアドレスに更新
mMsg[i].cmdProc = proc;
return TRUE;
}
}
// 追加
iMsg++;
mMsg = (LPONMSG)realloc(mMsg, sizeof(ONMSG) * iMsg);
if (mMsg == NULL) {
free(mMsg);
return FALSE;
}
ZeroMemory(&mMsg[iMsg - 1], sizeof(ONMSG));
mMsg[iMsg - 1].uiMsg = msg;
mMsg[iMsg - 1].cmdProc = proc;
return TRUE;
}
// ウインドウスタイルの変更(動的に変更も可能)
BOOL CWindow::SetWindowStyle(DWORD style)
{
dwStyle = style;
if (hWnd) {
// すでにウインドウが存在する場合は即反映
::SetWindowLong(hWnd, GWL_STYLE, style);
::SetWindowPos(hWnd, 0, 0, 0, 0, 0, SWP_FRAMECHANGED | SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOOWNERZORDER | SWP_NOSIZE | SWP_NOZORDER);
}
return TRUE;
}
// ウインドウの移動
void CWindow::Move(int x, int y)
{
SetWindowPos(hWnd, 0, x, y, 0, 0, SWP_NOSIZE | SWP_NOZORDER);
}
// ウインドウの移動(幅と高さも同時に変更)
void CWindow::Move(int x, int y, int w, int h)
{
MoveWindow(hWnd, x, y, w, h, TRUE);
}
// 指定サイズがクライアント領域になるようにウインドウを配置
BOOL CWindow::MoveClientWindowCenter(int w, int h)
{
RECT Win, Cli;
GetWindowRect(hWnd, &Win); // ウインドウの左上を取得
GetClientRect(hWnd, &Cli); // ウインドウ内のクライアント座標を取得
int frame_w = (Win.right - Win.left) - Cli.right; // フレームの幅
int frame_h = (Win.bottom - Win.top) - Cli.bottom; // フレームの高さ
int scr_w = GetSystemMetrics(SM_CXSCREEN); // スクリーンの幅
int scr_h = GetSystemMetrics(SM_CYSCREEN); // スクリーンの高さ
SetWindowPos(hWnd, 0, (scr_w - (frame_w / 2 + w)) / 2, (scr_h - (frame_h / 2 + h)) / 2, w + frame_w, h + frame_h, SWP_NOZORDER);
return TRUE;
}
// メニューアイテムの変更
BOOL CWindow::SetMenuItem(int menuid, BOOL check, BOOL gray)
{
HMENU menu = GetMenu(hWnd);
if (menu) {
MENUITEMINFO miinfo;
ZeroMemory(&miinfo, sizeof(miinfo));
miinfo.cbSize = sizeof(miinfo);
miinfo.fMask = MIIM_STATE;
if (check)
miinfo.fState |= MFS_CHECKED;
else
miinfo.fState |= MFS_UNCHECKED;
if (gray)
miinfo.fState |= MFS_GRAYED;
else
miinfo.fState |= MFS_ENABLED;
return SetMenuItemInfo(menu, menuid, FALSE, &miinfo);
}
return TRUE;
}
BOOL CWindow::TextOutW(int x, int y, const WCHAR* str, COLORREF col)
{
HDC hdc = GetDC(hWnd);
if (hdc) {
SetTextColor(hdc, col);
::TextOutW(hdc, x, y, str, (int)wcslen(str));
ReleaseDC(hWnd, hdc);
}
return TRUE;
}
///////////////////////////////////////////////////////////////////////////////////
// メニューバーの変更(Createの前に必要)
///////////////////////////////////////////////////////////////////////////////////
void CWindow::SetMenu(HMENU menu)
{
hMenu = menu;
}
| [
"53074461+Taku3939@users.noreply.github.com"
] | 53074461+Taku3939@users.noreply.github.com |
b5db5cf9a62bd5e67c8acc5e482f93628ee467be | b013562927e347376bfd43b57be229fda60cb607 | /ax_core/src/math/axMatrix4x4.cpp | a2bee9891f73ca4e5df8ba0fbd28c5c37d6fbac0 | [] | no_license | Jasonchan35/libax | 82102e2b2fa577f333815f99709ebbb9250ec9f5 | 931f18f8baf46b1e7087ea93a5f0c2ee667a540c | refs/heads/master | 2021-05-04T10:02:13.008748 | 2018-06-23T16:48:21 | 2018-06-23T16:48:21 | 46,000,639 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 13,065 | cpp | /*
* axMatrix4x4f.cpp
*
* Created by jason on 04/Apr/2006.
* Copyright 2006 __MyCompanyName__. All rights reserved.
*
*/
#include <ax/core/math/axMatrix4x4.h>
#include <ax/core/math/axEulerRotation3.h>
#include <ax/core/math/axQuaternion.h>
template<> const axMatrix4x4f axMatrix4x4f::kIdentity( 1,0,0,0,
0,1,0,0,
0,0,1,0,
0,0,0,1 );
template<> const axMatrix4x4d axMatrix4x4d::kIdentity( 1,0,0,0,
0,1,0,0,
0,0,1,0,
0,0,0,1);
template<class T>
void axMatrix4x4<T>::rotate ( const axEulerRotation3<T> &er ) {
operator*=( er.to_Matrix4() );
}
template<class T>
void axMatrix4x4<T>::rotate ( const axQuaternion<T> &qu ) {
operator*=( qu.to_Matrix4() );
}
template<class T>
axMatrix4x4<T> axMatrix4x4<T>::inverse() const {
T wtmp[4][8];
T m0, m1, m2, m3, s;
T *r0, *r1, *r2, *r3;
r0 = wtmp[0], r1 = wtmp[1], r2 = wtmp[2], r3 = wtmp[3];
r0[0] = e(0,0);
r0[1] = e(0,1);
r0[2] = e(0,2);
r0[3] = e(0,3);
r0[4] = 1.0;
r0[5] = r0[6] = r0[7] = 0.0;
r1[0] = e(1,0);
r1[1] = e(1,1);
r1[2] = e(1,2);
r1[3] = e(1,3);
r1[5] = 1.0;
r1[4] = r1[6] = r1[7] = 0.0;
r2[0] = e(2,0);
r2[1] = e(2,1);
r2[2] = e(2,2);
r2[3] = e(2,3);
r2[6] = 1.0;
r2[4] = r2[5] = r2[7] = 0.0;
r3[0] = e(3,0);
r3[1] = e(3,1);
r3[2] = e(3,2);
r3[3] = e(3,3);
r3[7] = 1.0;
r3[4] = r3[5] = r3[6] = 0.0;
/* choose pivot - or die */
if ( ax_abs(r3[0]) > ax_abs(r2[0]) ) ax_swap(r3, r2);
if ( ax_abs(r2[0]) > ax_abs(r1[0]) ) ax_swap(r2, r1);
if ( ax_abs(r1[0]) > ax_abs(r0[0]) ) ax_swap(r1, r0);
if ( 0.0 == r0[0] ) return kIdentity;
/* eliminate first variable */
m1 = r1[0] / r0[0];
m2 = r2[0] / r0[0];
m3 = r3[0] / r0[0];
s = r0[1]; r1[1] -= m1 * s; r2[1] -= m2 * s; r3[1] -= m3 * s;
s = r0[2]; r1[2] -= m1 * s; r2[2] -= m2 * s; r3[2] -= m3 * s;
s = r0[3]; r1[3] -= m1 * s; r2[3] -= m2 * s; r3[3] -= m3 * s;
s = r0[4]; if (s != 0.0) { r1[4] -= m1 * s; r2[4] -= m2 * s; r3[4] -= m3 * s; }
s = r0[5]; if (s != 0.0) { r1[5] -= m1 * s; r2[5] -= m2 * s; r3[5] -= m3 * s; }
s = r0[6]; if (s != 0.0) { r1[6] -= m1 * s; r2[6] -= m2 * s; r3[6] -= m3 * s; }
s = r0[7]; if (s != 0.0) { r1[7] -= m1 * s; r2[7] -= m2 * s; r3[7] -= m3 * s; }
/* choose pivot - or die */
if ( ax_abs(r3[1]) > ax_abs(r2[1]) ) ax_swap(r3, r2);
if ( ax_abs(r2[1]) > ax_abs(r1[1]) ) ax_swap(r2, r1);
if (0.0 == r1[1]) return kIdentity;
/* eliminate second variable */
m2 = r2[1]/r1[1];
m3 = r3[1]/r1[1];
r2[2] -= m2 * r1[2];
r3[2] -= m3 * r1[2];
r2[3] -= m2 * r1[3];
r3[3] -= m3 * r1[3];
s = r1[4]; if (0.0 != s) { r2[4] -= m2 * s; r3[4] -= m3 * s; }
s = r1[5]; if (0.0 != s) { r2[5] -= m2 * s; r3[5] -= m3 * s; }
s = r1[6]; if (0.0 != s) { r2[6] -= m2 * s; r3[6] -= m3 * s; }
s = r1[7]; if (0.0 != s) { r2[7] -= m2 * s; r3[7] -= m3 * s; }
/* choose pivot - or die */
if ( ax_abs(r3[2]) > ax_abs(r2[2]) ) ax_swap(r3, r2);
if (0.0 == r2[2]) return kIdentity;
/* eliminate third variable */
m3 = r3[2]/r2[2];
r3[3] -= m3 * r2[3];
r3[4] -= m3 * r2[4],
r3[5] -= m3 * r2[5];
r3[6] -= m3 * r2[6],
r3[7] -= m3 * r2[7];
/* last check */
if (0.0 == r3[3]) return kIdentity;
s = 1.0f/r3[3]; /* now back substitute row 3 */
r3[4] *= s; r3[5] *= s; r3[6] *= s; r3[7] *= s;
m2 = r2[3]; /* now back substitute row 2 */
s = 1.0f/r2[2];
r2[4] = s * (r2[4] - r3[4] * m2), r2[5] = s * (r2[5] - r3[5] * m2),
r2[6] = s * (r2[6] - r3[6] * m2), r2[7] = s * (r2[7] - r3[7] * m2);
m1 = r1[3];
r1[4] -= r3[4] * m1;
r1[5] -= r3[5] * m1;
r1[6] -= r3[6] * m1;
r1[7] -= r3[7] * m1;
m0 = r0[3];
r0[4] -= r3[4] * m0;
r0[5] -= r3[5] * m0;
r0[6] -= r3[6] * m0;
r0[7] -= r3[7] * m0;
m1 = r1[2]; /* now back substitute row 1 */
s = 1.0f/r1[1];
r1[4] = s * (r1[4] - r2[4] * m1);
r1[5] = s * (r1[5] - r2[5] * m1);
r1[6] = s * (r1[6] - r2[6] * m1);
r1[7] = s * (r1[7] - r2[7] * m1);
m0 = r0[2];
r0[4] -= r2[4] * m0;
r0[5] -= r2[5] * m0;
r0[6] -= r2[6] * m0;
r0[7] -= r2[7] * m0;
m0 = r0[1]; /* now back substitute row 0 */
s = 1.0f/r0[0];
r0[4] = s * (r0[4] - r1[4] * m0);
r0[5] = s * (r0[5] - r1[5] * m0);
r0[6] = s * (r0[6] - r1[6] * m0);
r0[7] = s * (r0[7] - r1[7] * m0);
return axMatrix4x4( r0[4], r0[5], r0[6], r0[7],
r1[4], r1[5], r1[6], r1[7],
r2[4], r2[5], r2[6], r2[7],
r3[4], r3[5], r3[6], r3[7] );
}
template<class T>
void axMatrix4x4<T>::setAimZ_UpY ( const axVec3<T> &eye, const axVec3<T> &aim, const axVec3<T> &up, bool neg_z_aim ) {
axVec3<T> f = ( eye - aim ).normalize();
if( neg_z_aim ) f = -f;
axVec3<T> s = f.cross(up).normalize();
axVec3<T> u = s.cross(f);
cx.set( s.x, s.y, s.z, 0.0 );
cy.set( u.x, u.y, u.z, 0.0 );
cz.set( f.x, f.y, f.z, 0.0 );
cw.set( eye, 1 );
}
template<class T>
void axMatrix4x4<T>::setLookAt ( const axVec3<T> &eye, const axVec3<T> &aim, const axVec3<T> &up ) {
axVec3<T> f = ( aim - eye ).normalize();
axVec3<T> s = f.cross(up).normalize();
axVec3<T> u = s.cross(f);
cx.set( s.x, u.x, -f.x, 0.0 );
cy.set( s.y, u.y, -f.y, 0.0 );
cz.set( s.z, u.z, -f.z, 0.0 );
cw.set( 0, 0, 0, 1 );
translate( -eye );
}
template<class T>
void axMatrix4x4<T>::setOrtho( T left, T right, T bottom, T top, T zNear, T zFar ) {
T w = right - left;
T h = top - bottom;
T d = zFar - zNear;
if( w == 0 || h == 0 || d == 0 ) {
setIdentity();
}else{
set( 2/w, 0, 0, 0,
0, 2/h, 0, 0,
0, 0, -2/d, 0,
-(right+left) / w, -(top+bottom) / h, -(zFar+zNear ) / d, 1 );
}
}
template<class T>
void axMatrix4x4<T>::setPerspective( T fovy_rad, T aspect, T zNear, T zFar ) {
T s, c, deltaZ;
T fov = fovy_rad / 2;
deltaZ = zFar - zNear;
s = sin( fov );
if ((deltaZ == 0) || (s == 0) || (aspect == 0)) {
setIdentity();
return;
}
c = cos(fov) / s;
cx.set( c / aspect, 0, 0, 0 );
cy.set( 0, c, 0, 0 );
cz.set( 0, 0, -(zFar + zNear) / deltaZ, -1 );
cw.set( 0, 0, -2 * zNear * zFar / deltaZ, 0 );
}
//------- inline ------------
template< class T>
axStatus axMatrix4x4<T>::toStringFormat( axStringFormat &f ) const {
f.out("\n");
int i;
for( i=0; i<4; i++ ) {
f.format( "[{?},{?},{?},{?}]\n", e(i,0), e(i,1), e(i,2), e(i,3) );
}
return 0;
}
//=================================================
template<class T>
axMatrix4x4<T>::axMatrix4x4( T v00, T v01, T v02, T v03,
T v10, T v11, T v12, T v13,
T v20, T v21, T v22, T v23,
T v30, T v31, T v32, T v33 )
: cx( v00, v01, v02, v03 ),
cy( v10, v11, v12, v13 ),
cz( v20, v21, v22, v23 ),
cw( v30, v31, v32, v33 ) {}
template<class T>
void axMatrix4x4<T>::set( T v00, T v01, T v02, T v03,
T v10, T v11, T v12, T v13,
T v20, T v21, T v22, T v23,
T v30, T v31, T v32, T v33 )
{
cx.set( v00, v01, v02, v03 );
cy.set( v10, v11, v12, v13 );
cz.set( v20, v21, v22, v23 );
cw.set( v30, v31, v32, v33 );
}
template<class T>
void axMatrix4x4<T>::setTRS ( const axVec3<T> & translate, const axVec3<T> & rotate, const axVec3<T> & scale ) {
T cx = ax_cos(rotate.x), cy = ax_cos(rotate.y), cz = ax_cos(rotate.z);
T sx = ax_sin(rotate.x), sy = ax_sin(rotate.y), sz = ax_sin(rotate.z);
this->cx.set( scale.x * (cy*cz), scale.x * (cy*sz), scale.x * (-sy), 0 );
this->cy.set( scale.y * (sx*sy*cz - cx*sz), scale.y * (cx*cz + sx*sy*sz), scale.y * (sx*cy), 0 );
this->cz.set( scale.z * (sx*sz + cx*sy*cz), scale.z * (cx*sy*sz - sx*cz), scale.z * (cx*cy), 0 );
this->cw.set( translate.x, translate.y, translate.z, 1 );
}
template <class T>
void axMatrix4x4<T>::setRotate ( const axVec3<T> & eulerAngle ) {
T cx = ax_cos(eulerAngle.x), cy = ax_cos(eulerAngle.y), cz = ax_cos(eulerAngle.z);
T sx = ax_sin(eulerAngle.x), sy = ax_sin(eulerAngle.y), sz = ax_sin(eulerAngle.z);
this->cx.set( cy*cz, cy*sz, -sy, 0 );
this->cy.set( sx*sy*cz - cx*sz, cx*cz + sx*sy*sz, sx*cy, 0 );
this->cz.set( sx*sz + cx*sy*cz, cx*sy*sz - sx*cz, cx*cy, 0 );
this->cw.set( 0, 0, 0, 1 );
}
template <class T>
void axMatrix4x4<T>::setTranslate ( const axVec3<T> &v ) {
cx.set( 1, 0, 0, 0 );
cy.set( 0, 1, 0, 0 );
cz.set( 0, 0, 1, 0 );
cw.set( v.x, v.y, v.z, 1 );
}
template <class T>
void axMatrix4x4<T>::translate ( const axVec3<T> &v ) {
axMatrix4x4<T> t; t.setTranslate( v );
operator*=(t);
}
template <class T>
void axMatrix4x4<T>::setRotateX ( T rad ) {
T s = ax_sin ( rad ), c = ax_cos ( rad );
cx.set( 1, 0, 0, 0 );
cy.set( 0, c, s, 0 );
cz.set( 0,-s, c, 0 );
cw.set( 0, 0, 0, 1 );
}
template <class T>
void axMatrix4x4<T>::setRotateY ( T rad ) {
T s = ax_sin ( rad ), c = ax_cos ( rad );
cx.set( c, 0,-s, 0 );
cy.set( 0, 1, 0, 0 );
cz.set( s, 0, c, 0 );
cw.set( 0, 0, 0, 1 );
}
template <class T>
void axMatrix4x4<T>::setRotateZ ( T rad ) {
T s = ax_sin ( rad ), c = ax_cos ( rad );
cx.set( c, s, 0, 0 );
cy.set(-s, c, 0, 0 );
cz.set( 0, 0, 1, 0 );
cw.set( 0, 0, 0, 1 );
}
template <class T>
void axMatrix4x4<T>::setScale ( const axVec3<T> &v ) {
cx.set( v.x, 0, 0, 0 );
cy.set( 0, v.y, 0, 0 );
cz.set( 0, 0, v.z, 0 );
cw.set( 0, 0, 0, 1 );
}
template <class T>
void axMatrix4x4<T>::setShear ( const axVec3<T> &v ) {
const T &xy = v.x;
const T &xz = v.y;
const T &yz = v.z;
cx.set( 1, 0, 0, 0 );
cy.set( xy, 1, 0, 0 );
cz.set( xz,yz, 1, 0 );
cw.set( 0, 0, 0, 1 );
}
template <class T>
axMatrix4x4<T> axMatrix4x4<T>::transpose () const {
return axMatrix4x4( cx.x, cy.x, cz.x, cw.x,
cx.y, cy.y, cz.y, cw.y,
cx.z, cy.z, cz.z, cw.z,
cx.w, cy.w, cz.w, cw.w );
}
template<class T>
void axMatrix4x4<T>::setRotateAxis ( T rad, const axVec3<T> &axis ) {
axVec3<T> a = axis.normalize();
T c = ax_cos( rad );
T i_c = 1-c;
T s = ax_sin( rad );
T &x= a.x;
T &y= a.y;
T &z= a.z;
T xx = x*x, yy = y*y, zz = z*z;
T xy = x*y, xz = x*z, yz = y*z;
T xs = x*s, ys = y*s, zs = z*s;
cx.set( (i_c * xx) + c, (i_c * xy) + zs, (i_c * xz) - ys, 0 );
cy.set( (i_c * xy) - zs, (i_c * yy) + c, (i_c * yz) + xs, 0 );
cz.set( (i_c * xz) + ys, (i_c * yz) - xs, (i_c * zz) + c, 0 );
cw.set( 0, 0, 0, 1 );
}
template<class T>
axMatrix4x4<T> axMatrix4x4<T>::operator* ( const axMatrix4x4<T> &v ) const{
axMatrix4x4<T> out;
T e0,e1,e2,e3;
e0=cx.x, e1=cy.x, e2=cz.x, e3=cw.x;
out.cx.x = e0*v.cx.x + e1*v.cx.y + e2*v.cx.z + e3*v.cx.w;
out.cy.x = e0*v.cy.x + e1*v.cy.y + e2*v.cy.z + e3*v.cy.w;
out.cz.x = e0*v.cz.x + e1*v.cz.y + e2*v.cz.z + e3*v.cz.w;
out.cw.x = e0*v.cw.x + e1*v.cw.y + e2*v.cw.z + e3*v.cw.w;
e0=cx.y, e1=cy.y, e2=cz.y, e3=cw.y;
out.cx.y = e0*v.cx.x + e1*v.cx.y + e2*v.cx.z + e3*v.cx.w;
out.cy.y = e0*v.cy.x + e1*v.cy.y + e2*v.cy.z + e3*v.cy.w;
out.cz.y = e0*v.cz.x + e1*v.cz.y + e2*v.cz.z + e3*v.cz.w;
out.cw.y = e0*v.cw.x + e1*v.cw.y + e2*v.cw.z + e3*v.cw.w;
e0=cx.z, e1=cy.z, e2=cz.z, e3=cw.z;
out.cx.z = e0*v.cx.x + e1*v.cx.y + e2*v.cx.z + e3*v.cx.w;
out.cy.z = e0*v.cy.x + e1*v.cy.y + e2*v.cy.z + e3*v.cy.w;
out.cz.z = e0*v.cz.x + e1*v.cz.y + e2*v.cz.z + e3*v.cz.w;
out.cw.z = e0*v.cw.x + e1*v.cw.y + e2*v.cw.z + e3*v.cw.w;
e0=cx.w, e1=cy.w, e2=cz.w, e3=cw.w;
out.cx.w = e0*v.cx.x + e1*v.cx.y + e2*v.cx.z + e3*v.cx.w;
out.cy.w = e0*v.cy.x + e1*v.cy.y + e2*v.cy.z + e3*v.cy.w;
out.cz.w = e0*v.cz.x + e1*v.cz.y + e2*v.cz.z + e3*v.cz.w;
out.cw.w = e0*v.cw.x + e1*v.cw.y + e2*v.cw.z + e3*v.cw.w;
return out;
}
template<class T>
void axMatrix4x4<T>::operator*=( const axMatrix4x4<T> &v ) {
if( this == &v ) {
axMatrix4x4<T> tmp = v;
this->operator*=( tmp );
return;
}
T e0,e1,e2,e3;
e0=cx.x, e1=cy.x, e2=cz.x, e3=cw.x;
cx.x = e0*v.cx.x + e1*v.cx.y + e2*v.cx.z + e3*v.cx.w;
cy.x = e0*v.cy.x + e1*v.cy.y + e2*v.cy.z + e3*v.cy.w;
cz.x = e0*v.cz.x + e1*v.cz.y + e2*v.cz.z + e3*v.cz.w;
cw.x = e0*v.cw.x + e1*v.cw.y + e2*v.cw.z + e3*v.cw.w;
e0=cx.y, e1=cy.y, e2=cz.y, e3=cw.y;
cx.y = e0*v.cx.x + e1*v.cx.y + e2*v.cx.z + e3*v.cx.w;
cy.y = e0*v.cy.x + e1*v.cy.y + e2*v.cy.z + e3*v.cy.w;
cz.y = e0*v.cz.x + e1*v.cz.y + e2*v.cz.z + e3*v.cz.w;
cw.y = e0*v.cw.x + e1*v.cw.y + e2*v.cw.z + e3*v.cw.w;
e0=cx.z, e1=cy.z, e2=cz.z, e3=cw.z;
cx.z = e0*v.cx.x + e1*v.cx.y + e2*v.cx.z + e3*v.cx.w;
cy.z = e0*v.cy.x + e1*v.cy.y + e2*v.cy.z + e3*v.cy.w;
cz.z = e0*v.cz.x + e1*v.cz.y + e2*v.cz.z + e3*v.cz.w;
cw.z = e0*v.cw.x + e1*v.cw.y + e2*v.cw.z + e3*v.cw.w;
e0=cx.w, e1=cy.w, e2=cz.w, e3=cw.w;
cx.w = e0*v.cx.x + e1*v.cx.y + e2*v.cx.z + e3*v.cx.w;
cy.w = e0*v.cy.x + e1*v.cy.y + e2*v.cy.z + e3*v.cy.w;
cz.w = e0*v.cz.x + e1*v.cz.y + e2*v.cz.z + e3*v.cz.w;
cw.w = e0*v.cw.x + e1*v.cw.y + e2*v.cw.z + e3*v.cw.w;
}
//The explicit instantiation
template class axMatrix4x4<float>;
template class axMatrix4x4<double>;
| [
"jasonchan35@gmail.com"
] | jasonchan35@gmail.com |
7c69256b7d821a738713977592a1852a4abf617d | 9dbeabc73c230cb4d7421f9b01430afffa7a2893 | /test.cpp | 5ca489b136402361d4f2e3e0831ac94bf2ccb21c | [] | no_license | arnavmenon/CPCprep | 3ad4cae9ff3a704135763585ed72cfc2266da740 | dd95216774ea33fd5d327d37513b7ddd96471155 | refs/heads/master | 2023-07-13T13:12:08.076955 | 2021-08-21T21:13:15 | 2021-08-21T21:13:15 | 352,124,288 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,377 | cpp | #include<bits/stdc++.h>
using namespace std;
vector<long long> solve (int N, int Q, vector<int> A, vector<vector<int> > query) {
vector<long long> ans;
vector<long long> prefix(N,0);
prefix[0]=A[0];
for(int i=1;i<N;i++){
prefix[i]= prefix[i-1] + A[i];
}
int qno=0;
vector<int> cur;
while(qno < Q){
cur=query[qno];
int q=cur[0], l=cur[1], r=cur[2];
if(q == 1){
int dif= r - A[l-1];
A[l-1]=r;
for(int i=l-1; i<N; i++){
prefix[i] += dif;
}
}
else{
long long sum=0;
for(int j=l-1; j<=r-1; j++){
sum += A[j] * (prefix[r-1] - prefix[j]);
}
ans.push_back(sum);
}
qno++;
}
return ans;
}
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
int N;
cin >> N;
int Q;
cin >> Q;
vector<int> A(N);
for(int i_A = 0; i_A < N; i_A++)
{
cin >> A[i_A];
}
vector<vector<int> > query(Q, vector<int>(3));
for (int i_query = 0; i_query < Q; i_query++)
{
for(int j_query = 0; j_query < 3; j_query++)
{
cin >> query[i_query][j_query];
}
}
vector<long long> out_;
out_ = solve(N, Q, A, query);
for(int i_out_ = 0; i_out_ < out_.size(); i_out_++)
{
cout << out_[i_out_] << endl;
}
return 0;
} | [
"63289642+arnavmenon@users.noreply.github.com"
] | 63289642+arnavmenon@users.noreply.github.com |
8c4e3f91620f61dd0bbb98784dca1f1a19d29377 | 19907e496cfaf4d59030ff06a90dc7b14db939fc | /POC/oracle_dapp/node_modules/wrtc/third_party/webrtc/include/chromium/src/components/scheduler/child/scheduler_tqm_delegate_impl.h | a41ac676f582cfe1800840f4c185045f56d34068 | [
"BSD-2-Clause"
] | permissive | ATMatrix/demo | c10734441f21e24b89054842871a31fec19158e4 | e71a3421c75ccdeac14eafba38f31cf92d0b2354 | refs/heads/master | 2020-12-02T20:53:29.214857 | 2017-08-28T05:49:35 | 2017-08-28T05:49:35 | 96,223,899 | 8 | 4 | null | 2017-08-28T05:49:36 | 2017-07-04T13:59:26 | JavaScript | UTF-8 | C++ | false | false | 2,054 | h | // 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.
#ifndef COMPONENTS_SCHEDULER_CHILD_SCHEDULER_TQM_DELEGATE_IMPL_H_
#define COMPONENTS_SCHEDULER_CHILD_SCHEDULER_TQM_DELEGATE_IMPL_H_
#include "base/macros.h"
#include "base/message_loop/message_loop.h"
#include "base/time/tick_clock.h"
#include "components/scheduler/child/scheduler_tqm_delegate.h"
#include "components/scheduler/scheduler_export.h"
namespace scheduler {
class SCHEDULER_EXPORT SchedulerTqmDelegateImpl : public SchedulerTqmDelegate {
public:
// |message_loop| is not owned and must outlive the lifetime of this object.
static scoped_refptr<SchedulerTqmDelegateImpl> Create(
base::MessageLoop* message_loop,
scoped_ptr<base::TickClock> time_source);
// SchedulerTqmDelegate implementation
void SetDefaultTaskRunner(
scoped_refptr<base::SingleThreadTaskRunner> task_runner) override;
void RestoreDefaultTaskRunner() override;
bool PostDelayedTask(const tracked_objects::Location& from_here,
const base::Closure& task,
base::TimeDelta delay) override;
bool PostNonNestableDelayedTask(const tracked_objects::Location& from_here,
const base::Closure& task,
base::TimeDelta delay) override;
bool RunsTasksOnCurrentThread() const override;
bool IsNested() const override;
base::TimeTicks NowTicks() override;
protected:
~SchedulerTqmDelegateImpl() override;
private:
SchedulerTqmDelegateImpl(base::MessageLoop* message_loop,
scoped_ptr<base::TickClock> time_source);
// Not owned.
base::MessageLoop* message_loop_;
scoped_refptr<SingleThreadTaskRunner> message_loop_task_runner_;
scoped_ptr<base::TickClock> time_source_;
DISALLOW_COPY_AND_ASSIGN(SchedulerTqmDelegateImpl);
};
} // namespace scheduler
#endif // COMPONENTS_SCHEDULER_CHILD_SCHEDULER_TQM_DELEGATE_IMPL_H_
| [
"steven.jun.liu@qq.com"
] | steven.jun.liu@qq.com |
8d98579719b305545057e4fd152f7eb242b33878 | 84c630facb71846df893e80f49a12ebbe81c26e7 | /STm32F429_Firmware/src/lap_timer.h | 31f8a82c5c7a2c984a919bcd7f3801ad6c04c8bc | [] | no_license | PhilippSchmaelzle/speedoino | 6da484a76f4d74c80fb459545c258f98582b72f5 | 31440cc40cc87308ac21ad0d5b22f2f906a41bbe | refs/heads/master | 2022-06-10T09:57:58.311209 | 2020-05-02T19:21:42 | 2020-05-02T19:21:42 | 260,756,509 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,464 | h | /*
* Lap_Timer.h
*
* Created on: 14.07.2013
* Author: kolja
*/
#ifndef LAP_TIMER_H_
#define LAP_TIMER_H_
class LapTime{
public:
LapTime();
~LapTime();
void race_loop();
void waiting_on_speed_up();
void prepare_race_loop();
void gps_capture_loop();
void initial_draw_gps_capture_screen();
unsigned char* get_active_filename();
int add_sector(uint32_t latitude, uint32_t longitude, unsigned char* filename);
int clear_file(unsigned char* filename);
int reset_times(unsigned char* filename);
bool use_realtime_not_calculated;
private:
uint8_t sector_count;
uint8_t lap;
uint8_t current_sector;
uint8_t last_dist_to_target; // TODO init?
uint32_t sector_end_latitude;
uint32_t sector_end_longitude;
uint32_t best_sector_time_ms;
uint32_t best_lap_time_ms;
uint32_t sector_start_timestamp_ms;
uint32_t lap_start_timestamp_ms;
uint32_t starting_standing_timestamp_ms;
uint32_t total_lap_time_blink_ms;
int32_t delay_ms;
bool delay_calc_active;
bool last_gps_valid;
bool delay_reseted;
unsigned char filename[20]; // "/NAVI/HOCKENHE.SST"
int calc_best_lap_time();
int update_sector_time(uint8_t sector_id, uint32_t sector_time, unsigned char* filename);
int get_sector_data(uint8_t sector_id, uint32_t* latitude,uint32_t* longitude,uint32_t* sector_time, unsigned char* filename);
void update_race_screen(uint8_t level);
void init_race_screen(bool reset_vars);
};
extern LapTime LapTimer;
#endif /* LapTime */
| [
"philipp-schmaelzle@web.de"
] | philipp-schmaelzle@web.de |
05af1df6a7c7876d6afd1eeb0be85f289af0e178 | e879a7a6431bea8758c64e43c64695e1ec0cfcaa | /LeM/144.cpp | 92ea4cf6c107f32b345272e1717470f48b37c6f6 | [] | no_license | Fatnerdfy/Training | 304cebe0997d0eb1de12257c68c157d6c2c9d42e | 838b6f9526e167c6d54341507bb366bf6c1ba947 | refs/heads/master | 2021-07-03T15:17:12.303424 | 2019-01-28T05:53:32 | 2019-01-28T05:53:32 | 133,915,439 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 1,055 | cpp | /**
* Definition for a binary tree node.
* struct TreeNode {
* int val;
* TreeNode *left;
* TreeNode *right;
* TreeNode(int x) : val(x), left(NULL), right(NULL) {}
* };
*/
class Solution {
public:
void preorder(TreeNode *p, vector<int>& result) {
if(p == nullptr) return;
result.push_back(p->val);
preorder(p->left, result);
preorder(p->right, result);
}
vector<int> preorderTraversal(TreeNode* root) {
vector<int> result;
preorder(root, result);
return result;
}
};
//runtime 4ms
class Solution {
public:
vector<int> preorderTraversal(TreeNode* root) {
vector<int> result;
stack<const TreeNode *> s;
if(root != nullptr) s.push(root);
while(!s.empty()) {
const TreeNode *p = s.top();
s.pop();
result.push_back(p->val);
if(p->right != nullptr) s.push(p->right);
if(p->left != nullptr) s.push(p->left);
}
return result;
}
};
// runtime 3ms
| [
"quanfy98@gmail.com"
] | quanfy98@gmail.com |
240c04c7d550394e5dc99d5a0035b5b6b4d859ff | e557ce74c9fe34aa2b68441254b7def699067501 | /src/libtsduck/dtv/descriptors/tsPartialTransportStreamDescriptor.h | b04a01fc70e1fbb028ca6068088eb1edba5f15fb | [
"BSD-2-Clause"
] | permissive | cedinu/tsduck-mod | 53d9b4061d0eab9864d40b1d47b34f5908f99d8a | 6c97507b63e7882a146eee3613d4184b7e535101 | refs/heads/master | 2023-05-10T12:56:33.185589 | 2023-05-02T09:00:57 | 2023-05-02T09:00:57 | 236,732,523 | 0 | 0 | BSD-2-Clause | 2021-09-23T08:36:08 | 2020-01-28T12:41:10 | C++ | UTF-8 | C++ | false | false | 3,425 | h | //----------------------------------------------------------------------------
//
// TSDuck - The MPEG Transport Stream Toolkit
// Copyright (c) 2005-2023, Thierry Lelegard
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// 1. Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
// THE POSSIBILITY OF SUCH DAMAGE.
//
//----------------------------------------------------------------------------
//!
//! @file
//! Representation of a partial_transport_stream_descriptor
//!
//----------------------------------------------------------------------------
#pragma once
#include "tsAbstractDescriptor.h"
#include "tsUString.h"
namespace ts {
//!
//! Representation of a partial_transport_stream_descriptor.
//! @see ETSI EN 300 468, 7.2.1.
//! @ingroup descriptor
//!
class TSDUCKDLL PartialTransportStreamDescriptor : public AbstractDescriptor
{
public:
// PartialTransportStreamDescriptor public members:
uint32_t peak_rate; //!< 22 bits
uint32_t minimum_overall_smoothing_rate; //!< 22 bits
uint16_t maximum_overall_smoothing_buffer; //!< 14 bits
static const uint32_t UNDEFINED_SMOOTHING_RATE = 0x3FFFFF; //!< "undefined" value for @a minimum_overall_smoothing_rate.
static const uint16_t UNDEFINED_SMOOTHING_BUFFER = 0x3FFF; //!< "undefined" value for @a maximum_overall_smoothing_buffer.
//!
//! Default constructor.
//!
PartialTransportStreamDescriptor();
//!
//! Constructor from a binary descriptor
//! @param [in,out] duck TSDuck execution context.
//! @param [in] bin A binary descriptor to deserialize.
//!
PartialTransportStreamDescriptor(DuckContext& duck, const Descriptor& bin);
// Inherited methods
DeclareDisplayDescriptor();
protected:
// Inherited methods
virtual void clearContent() override;
virtual void serializePayload(PSIBuffer&) const override;
virtual void deserializePayload(PSIBuffer&) override;
virtual void buildXML(DuckContext&, xml::Element*) const override;
virtual bool analyzeXML(DuckContext&, const xml::Element*) override;
};
}
| [
"thierry@lelegard.fr"
] | thierry@lelegard.fr |
a7f192af87d4eca359dbe40b806e2656e261eede | b0f76ab27b217a77e36c3b4c6b3f2adeae7c7a28 | /QPAnalyzer/main.cpp | 4e16a91ddd03e62cbdc810e6bd3d452d393dffa6 | [] | no_license | iamgeniuswei/QProtocolAnalyzer | ec3cd8a283102c38ffd50fe27b74dae527b999ef | 5deae48aff83e28d9a389978accd8bda660b8315 | refs/heads/master | 2021-01-18T19:53:21.268694 | 2016-09-29T02:57:11 | 2016-09-29T02:57:11 | 69,648,032 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 225 | cpp | #include <QCoreApplication>
#include <QDebug>
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
qDebug() << "-------------------QProtocolAnalyzer Build 0.01-----------------";
return a.exec();
}
| [
"iamgeniuswei@sina.com"
] | iamgeniuswei@sina.com |
34af1184c256702bb19f5286a78b7f445827d663 | 4ef7465003940b693c46a9606b8bda6684f8f54b | /src/animator.cpp | 74a57bf94f568ce5203d42231465d72af0d6ba8d | [] | no_license | EvilJagaGenius/NetmapSFML | 22d2484fd5b8d3a76a3a5673f68083cacdd984f7 | 2bd760b563a54d8275259484268e4925a73fb6d1 | refs/heads/master | 2021-11-22T16:36:44.669861 | 2019-11-22T18:50:54 | 2019-11-22T18:50:54 | 183,544,102 | 1 | 1 | null | 2020-06-26T23:24:01 | 2019-04-26T02:41:05 | C++ | UTF-8 | C++ | false | false | 910 | cpp | #include "animator.h"
Animator::Animator()
{
//ctor
}
Animator::~Animator()
{
//dtor
}
void Animator::addAnimation(string id, Animation anim) {
this->animations.insert({{id, anim}});
}
void Animator::playAnimation(string id, bool loop) {
this->loop = loop;
this->progress = 0;
this->currentAnim = this->animations[id];
this->loopTime = this->currentAnim.totalTime;
}
void Animator::update(sf::Time dt) {
// Do something similar to the float version of this
}
void Animator::update(float progress) {
this->progress += progress;
if (this->loop) {
while (this->progress >= this->loopTime) {
this->progress -= this->loopTime;
}
}
}
void Animator::animate(sf::Sprite* target, float progress) {
currentAnim.animate(target, progress);
}
void Animator::animate(sf::Sprite* target) {
currentAnim.animate(target, this->progress);
}
| [
"EvilJagaGenius@users.noreply.github.com"
] | EvilJagaGenius@users.noreply.github.com |
839fc1d5c97640c058c05f07973afb5172e89cdf | f3b79eacc2cf461a8732d1375f9ec52de3a48851 | /tests/quote_test.cc | 44804974acf4b67d1d1d44e3e472f1832f409280 | [
"MIT"
] | permissive | aokellermann/iex | e104ec291764e3c44825273a5c39c25c8475d53d | d8988aa0b2523a06e7448b6acfc59f068fc3e6af | refs/heads/master | 2023-06-14T14:34:13.158021 | 2021-07-11T13:30:58 | 2021-07-11T13:30:58 | 264,305,982 | 3 | 1 | MIT | 2021-07-11T13:30:59 | 2020-05-15T21:50:49 | C++ | UTF-8 | C++ | false | false | 6,648 | cc | /**
* @file quote_test.cc
* @author Antony Kellermann
* @copyright 2020 Antony Kellermann
*/
#include <gtest/gtest.h>
#include "iex/iex.h"
static const iex::Endpoint::OptionsObject kOptions{{}, {}, iex::DataType::SANDBOX};
TEST(Quote, Get)
{
const auto quote = iex::Get<iex::Endpoint::Type::QUOTE>(iex::Symbol("tsla"), kOptions);
EXPECT_NE(quote, nullptr);
}
TEST(Quote, AllFields)
{
const char* json_s =
"{\n"
" \"symbol\": \"AAPL\",\n"
" \"companyName\": \"Apple, Inc.\",\n"
" \"primaryExchange\": \"NASDAQ\",\n"
" \"calculationPrice\": \"tops\",\n"
" \"open\": 350.25,\n"
" \"openTime\": 1592320822921,\n"
" \"openSource\": \"official\",\n"
" \"close\": 350.25,\n"
" \"closeTime\": 1592320822921,\n"
" \"closeSource\": \"official\",\n"
" \"high\": 350.25,\n"
" \"highTime\": 1592320822921,\n"
" \"highSource\": \"15 minute delayed price\",\n"
" \"low\": 350.25,\n"
" \"lowTime\": 1592319692468,\n"
" \"lowSource\": \"15 minute delayed price\",\n"
" \"latestPrice\": 350.25,\n"
" \"latestSource\": \"IEX real time price\",\n"
" \"latestTime\": \"11:35:05 AM\",\n"
" \"latestUpdate\": 1592321705202,\n"
" \"latestVolume\": 20567140,\n"
" \"iexRealtimePrice\": 350.25,\n"
" \"iexRealtimeSize\": 27,\n"
" \"iexLastUpdated\": 1592321705202,\n"
" \"delayedPrice\": 350.25,\n"
" \"delayedPriceTime\": 1592321705202,\n"
" \"oddLotDelayedPrice\": 350.25,\n"
" \"oddLotDelayedPriceTime\": 1592321705202,\n"
" \"extendedPrice\": 350.25,\n"
" \"extendedChange\": 350.25,\n"
" \"extendedChangePercent\": 0.02117,\n"
" \"extendedPriceTime\": 1592321705202,\n"
" \"previousClose\": 342.99,\n"
" \"previousVolume\": 34702230,\n"
" \"change\": 7.26,\n"
" \"changePercent\": 0.02117,\n"
" \"volume\": 110533,\n"
" \"iexMarketPercent\": 0.006061888374230089,\n"
" \"iexVolume\": 110533,\n"
" \"avgTotalVolume\": 34010007,\n"
" \"iexBidPrice\": 333,\n"
" \"iexBidSize\": 100,\n"
" \"iexAskPrice\": 356,\n"
" \"iexAskSize\": 100,\n"
" \"iexOpen\": 350.25,\n"
" \"iexOpenTime\": 1592321705202,\n"
" \"iexClose\": 350.25,\n"
" \"iexCloseTime\": 1592321705202,\n"
" \"marketCap\": 1518102585000,\n"
" \"peRatio\": 27.23,\n"
" \"week52High\": 354.77,\n"
" \"week52Low\": 190.3,\n"
" \"ytdChange\": 0.17897,\n"
" \"lastTradeTime\": 1592321705202,\n"
" \"isUSMarketOpen\": true\n"
"}";
iex::json::Json json = iex::json::Json::parse(json_s);
iex::Quote quote(iex::json::JsonStorage{json});
using MemberType = iex::Quote::MemberType;
EXPECT_TRUE(quote.Get<MemberType::COMPANY_NAME>().has_value());
EXPECT_TRUE(quote.Get<MemberType::PRIMARY_EXCHANGE>().has_value());
EXPECT_TRUE(quote.Get<MemberType::CALCULATION_PRICE>().has_value());
EXPECT_TRUE(quote.Get<MemberType::OPEN_PRICE>().has_value());
EXPECT_TRUE(quote.Get<MemberType::OPEN_TIME>().has_value());
EXPECT_TRUE(quote.Get<MemberType::OPEN_SOURCE>().has_value());
EXPECT_TRUE(quote.Get<MemberType::CLOSE_PRICE>().has_value());
EXPECT_TRUE(quote.Get<MemberType::CLOSE_TIME>().has_value());
EXPECT_TRUE(quote.Get<MemberType::CLOSE_SOURCE>().has_value());
EXPECT_TRUE(quote.Get<MemberType::HIGH_PRICE>().has_value());
EXPECT_TRUE(quote.Get<MemberType::HIGH_TIME>().has_value());
EXPECT_TRUE(quote.Get<MemberType::HIGH_SOURCE>().has_value());
EXPECT_TRUE(quote.Get<MemberType::LOW_PRICE>().has_value());
EXPECT_TRUE(quote.Get<MemberType::LOW_TIME>().has_value());
EXPECT_TRUE(quote.Get<MemberType::LOW_SOURCE>().has_value());
EXPECT_TRUE(quote.Get<MemberType::LATEST_PRICE>().has_value());
EXPECT_TRUE(quote.Get<MemberType::LATEST_UPDATE>().has_value());
EXPECT_TRUE(quote.Get<MemberType::LATEST_SOURCE>().has_value());
EXPECT_TRUE(quote.Get<MemberType::LATEST_VOLUME>().has_value());
EXPECT_TRUE(quote.Get<MemberType::IEX_REALTIME_PRICE>().has_value());
EXPECT_TRUE(quote.Get<MemberType::IEX_REALTIME_SIZE>().has_value());
EXPECT_TRUE(quote.Get<MemberType::IEX_LAST_UPDATED>().has_value());
EXPECT_TRUE(quote.Get<MemberType::DELAYED_PRICE>().has_value());
EXPECT_TRUE(quote.Get<MemberType::DELAYED_TIME>().has_value());
EXPECT_TRUE(quote.Get<MemberType::ODD_LOT_DELAYED_PRICE>().has_value());
EXPECT_TRUE(quote.Get<MemberType::ODD_LOT_DELAYED_TIME>().has_value());
EXPECT_TRUE(quote.Get<MemberType::EXTENDED_PRICE>().has_value());
EXPECT_TRUE(quote.Get<MemberType::EXTENDED_TIME>().has_value());
EXPECT_TRUE(quote.Get<MemberType::EXTENDED_CHANGE>().has_value());
EXPECT_TRUE(quote.Get<MemberType::EXTENDED_CHANGE_PERCENT>().has_value());
EXPECT_TRUE(quote.Get<MemberType::PREVIOUS_CLOSE>().has_value());
EXPECT_TRUE(quote.Get<MemberType::PREVIOUS_VOLUME>().has_value());
EXPECT_TRUE(quote.Get<MemberType::CHANGE>().has_value());
EXPECT_TRUE(quote.Get<MemberType::CHANGE_PERCENT>().has_value());
EXPECT_TRUE(quote.Get<MemberType::VOLUME>().has_value());
EXPECT_TRUE(quote.Get<MemberType::IEX_MARKET_PERCENT>().has_value());
EXPECT_TRUE(quote.Get<MemberType::IEX_VOLUME>().has_value());
EXPECT_TRUE(quote.Get<MemberType::AVERAGE_TOTAL_VOLUME>().has_value());
EXPECT_TRUE(quote.Get<MemberType::IEX_BID_PRICE>().has_value());
EXPECT_TRUE(quote.Get<MemberType::IEX_BID_SIZE>().has_value());
EXPECT_TRUE(quote.Get<MemberType::IEX_ASK_PRICE>().has_value());
EXPECT_TRUE(quote.Get<MemberType::IEX_ASK_SIZE>().has_value());
EXPECT_TRUE(quote.Get<MemberType::IEX_OPEN_PRICE>().has_value());
EXPECT_TRUE(quote.Get<MemberType::IEX_OPEN_TIME>().has_value());
EXPECT_TRUE(quote.Get<MemberType::IEX_CLOSE_PRICE>().has_value());
EXPECT_TRUE(quote.Get<MemberType::IEX_CLOSE_TIME>().has_value());
EXPECT_TRUE(quote.Get<MemberType::MARKET_CAP>().has_value());
EXPECT_TRUE(quote.Get<MemberType::PE_RATIO>().has_value());
EXPECT_TRUE(quote.Get<MemberType::WEEK_52_HIGH>().has_value());
EXPECT_TRUE(quote.Get<MemberType::WEEK_52_LOW>().has_value());
EXPECT_TRUE(quote.Get<MemberType::YTD_CHANGE>().has_value());
EXPECT_TRUE(quote.Get<MemberType::LAST_TRADE_TIME>().has_value());
EXPECT_TRUE(quote.Get<MemberType::IS_US_MARKET_OPEN>().has_value());
}
TEST(Quote, DisplayPercentOption)
{
iex::Endpoint::OptionsObject options = kOptions;
options.options = {iex::Quote::DisplayPercentOption()};
const auto quote = iex::Get<iex::Endpoint::Type::QUOTE>(iex::Symbol("tsla"), options);
EXPECT_NE(quote, nullptr);
}
| [
"noreply@github.com"
] | aokellermann.noreply@github.com |
0c06a6c9e3a4a89db9e7c566268cab241fb05fc7 | 2bf7a08d3cac39411c52d89514fda014e9228466 | /1week_intro/intro/day3/calculation.h | ea7ed7b93e021f7d855d0c1adaae1a9f2d88c21f | [] | no_license | meshidenn/cpp_practice | d5d831c8f29ac7194c48f8b99534c683b2fb31d6 | 2559c272a92fde5c77468974f72619e162cdc9de | refs/heads/master | 2021-09-05T21:04:14.657755 | 2018-01-31T01:44:35 | 2018-01-31T01:44:35 | 114,694,038 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 327 | h | #ifndef _CALCULATION_H_
#define _CALCULATION_H_
#include <iostream>
#include <string>
using namespace std;
class Calculation{
private:
int c_num1;
int c_num2;
public:
void setNumber1(int n);
void setNumber2(int n);
int getNumber1();
int getNumber2();
int add();
int sub();
};
#endif // Calculation_H
| [
"hiroki-iida@mbp-2016-h-iida.local"
] | hiroki-iida@mbp-2016-h-iida.local |
0ee13876796f7192c1adcb49c43b6c4bec355952 | 08b8cf38e1936e8cec27f84af0d3727321cec9c4 | /data/crawl/git/new_hunk_4111.cpp | 123a70dc5c610e618af1c8eb7a97b8c3c056f3ef | [] | no_license | ccdxc/logSurvey | eaf28e9c2d6307140b17986d5c05106d1fd8e943 | 6b80226e1667c1e0760ab39160893ee19b0e9fb1 | refs/heads/master | 2022-01-07T21:31:55.446839 | 2018-04-21T14:12:43 | 2018-04-21T14:12:43 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 184 | cpp | DIFF_OPT_SET(&revs->diffopt, NO_INDEX);
revs->max_count = -2;
diff_setup_done(&revs->diffopt);
setup_diff_pager(&revs->diffopt);
DIFF_OPT_SET(&revs->diffopt, EXIT_WITH_STATUS);
| [
"993273596@qq.com"
] | 993273596@qq.com |
fee8c16be466b69a6e030dca7df0e0320274d32e | 58fbf4229a79250b01946c35f375d7da17fbdac4 | /fsw/unit_test/vm_testrunner.cpp | ec33cd8895c5460be44c4b3d8f3d3d74259ad2cc | [
"BSD-3-Clause"
] | permissive | WindhoverLabs/vm | 32add255779636b62adcac38499f1b96e080401c | f7a39de2a043ff26fc6873a379b2570538184463 | refs/heads/master | 2023-02-18T17:04:10.869676 | 2023-02-02T05:21:17 | 2023-02-02T05:21:17 | 202,190,043 | 1 | 0 | BSD-3-Clause | 2021-01-29T19:58:00 | 2019-08-13T17:09:40 | C++ | UTF-8 | C++ | false | false | 1,974 | cpp | /****************************************************************************
*
* Copyright (c) 2017 Windhover Labs, L.L.C. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* 3. Neither the name Windhover Labs nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
*****************************************************************************/
#include "uttest.h"
#include "vm_app_test.h"
#include "vm_cmds_test.h"
#include "vm_config_tbl_test.h"
int main(void)
{
VM_App_Test_AddTestCases();
VM_Cmds_Test_AddTestCases();
VM_Config_Tbl_Test_AddTestCases();
return(UtTest_Run());
}
| [
"mbenson@windhoverlabs.com"
] | mbenson@windhoverlabs.com |
1ebfa85030f59aeadaadab689ddc3f498e51da2a | a5dae2688270528dee632eba4dec883f5f542f8e | /database.cpp | 83882d28233127ea9881e28e57f2ca5e4ca90c8b | [] | no_license | aishwaryar7/CPP | 812ec7fe86b7cd023586d3938b0922ab31906352 | 08f8d4d54309b606f36a8530bc8f1c3a7ccfbb8b | refs/heads/master | 2020-03-18T05:04:51.621075 | 2018-05-24T23:11:12 | 2018-05-24T23:11:12 | 134,323,200 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 5,365 | cpp | #include "stdafx.h"
#include <iostream>
#include <list>
#include <map>
#include <string>
using namespace std;
class course {
public:
string name;
int section;
int credits;
course() {}
course(string n, int s, int c) { name = n; section = s; credits = c; }
bool operator<(const course &c) { return (name < c.name); }
bool operator==(const course &c) { return (name == c.name); }
};
void add_student(map<int, map<int, list<course *> * > *> &DB, int id);
void remove_student(map<int, map<int, list<course *> * > *> &DB, int id);
void add_course(map<int, map<int, list<course *> * > *> &DB, int semester, int id, course c);
void drop_course(map<int, map<int, list<course *> * > *> &DB, int semester, int id, course c);
void print_student_semester_courses(map<int, map<int, list<course *> * > *> &DB, int semester, int id);
void print_student_all_courses(map<int, map<int, list<course *> * > *> &DB, int id);
void print_DB(map<int, map<int, list<course *> * > *> &DB);
int main() {
map<int, map<int, list<course *> *> *> DB;
add_student(DB, 11111);
course C1("CIS554", 1, 3), C2("CSE674", 1, 3), C3("MAT296", 8, 4), C4("WRT205", 5, 3);
add_course(DB, 20171, 11111, C1);
add_course(DB, 20171, 11111, C4);
add_course(DB, 20171, 11111, C3);
add_course(DB, 20171, 11111, C2);
print_student_semester_courses(DB, 20171, 11111);
drop_course(DB, 20171, 11111, C1);
print_student_semester_courses(DB, 20171, 11111);
add_course(DB, 20172, 11111, C2);
add_course(DB, 20172, 11111, C4);
add_course(DB, 20172, 11111, C3);
add_course(DB, 20172, 11111, C1);
print_student_all_courses(DB, 11111);
add_student(DB, 11112);
add_course(DB, 20171, 11112, C2);
add_course(DB, 20171, 11112, C4);
add_course(DB, 20171, 11112, C3);
add_course(DB, 20171, 11112, C1);
print_student_semester_courses(DB, 20171, 11112);
add_course(DB, 20172, 11112, C2);
add_course(DB, 20172, 11112, C4);
add_course(DB, 20172, 11112, C3);
add_course(DB, 20172, 11112, C1);
print_student_semester_courses(DB, 20172, 11112);
print_student_all_courses(DB, 11112);
print_DB(DB);
remove_student(DB, 11111);
print_DB(DB);
getchar();
getchar();
return 0;
}
void add_student(map<int, map<int, list<course *> * > *> &DB, int id) {
auto it1 = DB.find(id);
if (it1 == DB.end())
{
DB[id] = new map<int, list<course *> * >;
return;
}
}
void remove_student(map<int, map<int, list<course *> * > *> &DB, int id) {
auto it1 = DB.find(id);
auto it2 = (*DB[id]).begin();
while (it2 != (*DB[id]).end())
{
auto it3 = it2->second->begin();
while(it3 != it2->second->end())
{
delete *it3;
it3++;
}
delete it2->second;
it2++;
}
delete it1->second;
DB.erase(it1);
}
void add_course(map<int, map<int, list<course *> * > *> &DB, int semester, int id, course c) {
if (DB.empty() == true) return;
auto it1 = DB.find(id);
if (it1 == DB.end()) return;
auto it2 = (*DB[id]).find(semester);
if (it2 == (*DB[id]).end())
{
(*(DB)[id])[semester] = new list<course *>;
(*(DB)[id])[semester]->push_back(new course(c));
return;
}
auto it3 = (*DB[id])[semester]->begin();
while (it3 != (*DB[id])[semester]->end())
{
if (c.name == (*it3)->name && c.credits == (*it3)->credits && c.section == (*it3)->section)
return;
it3++;
}
(*(DB)[id])[semester]->push_back(new course(c));
}
void drop_course(map<int, map<int, list<course *> * > *> &DB, int semester, int id, course c) {
auto it1 = ((*DB[id])[semester])->begin();
while (it1 != ((*DB[id])[semester])->end())
{
if ((*it1)->name == c.name)
{
delete *it1;
(*DB[id])[semester]->erase(it1);
return;
}
it1++;
}
}
void print_student_semester_courses(map<int, map<int, list<course *> * > *> &DB, int semester, int id) {
auto it1 = DB.find(id);
cout << endl;
cout << endl;
cout << "Student id = " << it1->first << endl;
auto it2 = (*DB[id]).find(semester);
if (it2 != (*DB[id]).end())
{
cout << "Semester = " << it2->first << endl;
auto it3 = (*DB[id])[semester]->begin();
while (it3 != (*DB[id])[semester]->end())
{
cout << (*it3)->name << " " << (*it3)->section << " " << (*it3)->credits << " ";
it3++;
}
cout << endl;
}
}
void print_student_all_courses(map<int, map<int, list<course *> * > *> &DB, int id) {
auto it1 = DB.find(id);
cout << endl;
cout << endl;
cout << "Student id = " << id << endl;
auto it2 = (*DB[id]).begin();
while (it2 != (*DB[id]).end())
{
cout << "Semester = " << it2->first << endl;
auto it3 = it2->second->begin();
while (it3 != it2->second->end())
{
cout << (*it3)->name << " " << (*it3)->section << " " << (*it3)->credits << " ";
it3++;
}
cout << endl;
it2++;
}
}
void print_DB(map<int, map<int, list<course *> * > *> &DB) {
cout << endl;
cout << endl;
auto it1 = DB.begin();
while (it1 != DB.end())
{
cout << "Student id = " << it1->first << endl;
auto it2 = it1->second->begin();
while (it2 != it1->second->end())
{
cout << "Semester = " << it2->first << endl;
auto it3 = it2->second->begin();
while (it3 != it2->second->end())
{
cout << (*it3)->name << " " << (*it3)->section << " " << (*it3)->credits << " ";
it3++;
}
cout << endl;
it2++;
}
it1++;
}
}
| [
"noreply@github.com"
] | aishwaryar7.noreply@github.com |
a0ddd8b4f7bc78f83e32c8725595691bfe671c7b | 26701cd4cdc0df75de09d2ffa6c9d2c6ec72c433 | /loo/tests/graphic/header/graphicapp.h | 1cf483cdc1574947d5ae4ac007fcc25a322778fb | [] | no_license | ifeuille/looengine | 6ec30fc459684e5abf25e9e3739ab882ec12b7a5 | f0bbbe6e2b518dcbb9d75937084cab29d2f12347 | refs/heads/master | 2022-04-11T01:01:28.429955 | 2020-03-29T01:34:20 | 2020-03-29T01:34:20 | 226,991,555 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,164 | h | #include "config.h"
#include "core/application/application.h"
#include "vkfg/vulkan/framework/vulkandeviceext.h"
#include "vkfg/vkfg.h"
#include "global/algorithms/stringutils.h"
namespace loo
{
namespace vkfg
{
class VPipelineCompiler;
}
}
class GraphicApp :public loo::core::Application
{
// types
private:
using TestFunc_t = bool (GraphicApp::*) ();
using TestQueue_t = loo::Deque<loo::Pair< TestFunc_t, loo::uint >>;
using DebugReport = loo::vkfg::VulkanDeviceExt::DebugReport;
using VPipelineCompilerPtr = loo::SharedPtr< class loo::vkfg::VPipelineCompiler >;
// variables
private:
loo::vkfg::VulkanDeviceExt _vulkan;
loo::vkfg::FrameGraph _frameGraph;
VPipelineCompilerPtr _pplnCompiler;
loo::vkfg::SwapchainID _swapchainId;
TestQueue_t _tests;
loo::uint _testInvocations = 0;
loo::uint _testsPassed = 0;
loo::uint _testsFailed;
// helpers
private:
bool Visualize (loo::StringView name) const;
bool CompareDumps (loo::StringView filename) const;
bool SavePNG (const loo::String &filename, const loo::vkfg::ImageView &imageData) const;
template <typename Arg0, typename ...Args>
inline void DeleteResources (Arg0 &arg0, Args& ...args);
ND_ loo::Array<uint8_t> CreateData (loo::BytesU size) const;
ND_ static loo::String GetFuncName (loo::StringView src);
// implementation tests
private:
bool Test_Draw1 ();
public:
GraphicApp (const std::string& name,uint32_t appid, loo::core::ContextConfig setting);
virtual ~GraphicApp ();
virtual bool OnCreate ();
virtual bool OnDestroy ();
virtual bool OnSuspend ();
virtual bool OnResume ();
virtual bool OnRefresh ();
virtual bool OnResize (uint32_t width, uint32_t height);
virtual bool DoUpdateOverlay () ;
virtual uint32_t DoUpdate (uint64_t pass);
private:
};
template <typename Arg0, typename ...Args>
inline void GraphicApp::DeleteResources (Arg0 &arg0, Args& ...args)
{
_frameGraph->ReleaseResource (INOUT arg0);
//constexpr bool cb = loo::CountOf<Args...> () != 0;
if constexpr (loo::CountOf<Args...> () != 0)
DeleteResources (std::forward<Args&> (args)...);
}
# define TEST_NAME GetFuncName( LOO_FUNCTION_NAME )
| [
"770829892@qq.com"
] | 770829892@qq.com |
e7084c91e0bcf8a6e8161648aa5f12550d1bebdd | de6f2e1b2ac6e769d9c93ffc5d3fae2af1fbb956 | /triangle.cpp | 0bf0b181e02a53f7d428ae62753bdedb3b820236 | [] | no_license | DaraganArtem/----homework | 59293bc2e61fd5e5e1b44909b416062182684033 | fbf259809efeda130fd4bff4c62a3b546005d339 | refs/heads/main | 2023-04-01T18:54:58.807600 | 2021-04-04T18:12:37 | 2021-04-04T18:12:37 | 343,233,839 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 168 | cpp | #include <iostream>
#include <math.h>
int main()
{
double x;
double y;
std::cin >> x;
std::cin >> y;
double z = sqrt(x * x + y * y);
std::cout << z;
return 0;
} | [
"noreply@github.com"
] | DaraganArtem.noreply@github.com |
843ef0404c6a0041993a3b85e810b5220dcc784b | 0889271b6334a92d5062f1bcee2bb1c468be02ff | /threads/system.cc | 3b88ca67c9426eb83659c1bfff0421cf12b2e8bb | [
"MIT-Modern-Variant"
] | permissive | MikeXuPku/OSpractice | 2b5ae8985ce808c119db7d08cd42323a602e4329 | 439b265d8ca5517cde4cf1e74d0ed22436de483d | refs/heads/master | 2020-04-22T19:25:14.815671 | 2015-06-02T13:21:49 | 2015-06-02T13:21:49 | 34,568,858 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 5,830 | cc | // system.cc
// Nachos initialization and cleanup routines.
//
// Copyright (c) 1992-1993 The Regents of the University of California.
// All rights reserved. See copyright.h for copyright notice and limitation
// of liability and disclaimer of warranty provisions.
#include "copyright.h"
#include "system.h"
// This defines *all* of the global data structures used by Nachos.
// These are all initialized and de-allocated by this file.
Thread *currentThread; // the thread we are running now
Thread *threadToBeDestroyed; // the thread that just finished
Scheduler *scheduler; // the ready list
Interrupt *interrupt; // interrupt status
Statistics *stats; // performance metrics
Timer *timer; // the hardware timer device,
// for invoking context switches
Table *thread_slot;
#ifdef FILESYS_NEEDED
FileSystem *fileSystem;
int *referCount;
#endif
#ifdef FILESYS
SynchDisk *synchDisk;
#endif
#ifdef USER_PROGRAM // requires either FILESYS or FILESYS_STUB
Machine *machine; // user program memory and registers
#endif
#ifdef NETWORK
PostOffice *postOffice;
#endif
// External definition, to allow us to take a pointer to this function
extern void Cleanup();
//----------------------------------------------------------------------
// TimerInterruptHandler
// Interrupt handler for the timer device. The timer device is
// set up to interrupt the CPU periodically (once every TimerTicks).
// This routine is called each time there is a timer interrupt,
// with interrupts disabled.
//
// Note that instead of calling Yield() directly (which would
// suspend the interrupt handler, not the interrupted thread
// which is what we wanted to context switch), we set a flag
// so that once the interrupt handler is done, it will appear as
// if the interrupted thread called Yield at the point it is
// was interrupted.
//
// "dummy" is because every interrupt handler takes one argument,
// whether it needs it or not.
//----------------------------------------------------------------------
static void
TimerInterruptHandler(int dummy)
{
if (interrupt->getStatus() != IdleMode)
interrupt->YieldOnReturn();
}
//----------------------------------------------------------------------
// Initialize
// Initialize Nachos global data structures. Interpret command
// line arguments in order to determine flags for the initialization.
//
// "argc" is the number of command line arguments (including the name
// of the command) -- ex: "nachos -d +" -> argc = 3
// "argv" is an array of strings, one for each command line argument
// ex: "nachos -d +" -> argv = {"nachos", "-d", "+"}
//----------------------------------------------------------------------
void
Initialize(int argc, char **argv)
{
int argCount;
char* debugArgs = "";
bool randomYield = FALSE;
#ifdef USER_PROGRAM
bool debugUserProg = FALSE; // single step user program
#endif
#ifdef FILESYS_NEEDED
bool format = FALSE; // format disk
referCount = new int [1024];
for(int i = 0;i<1024;++i)referCount[i] = 0;
#endif
#ifdef NETWORK
double rely = 1; // network reliability
int netname = 0; // UNIX socket name
#endif
for (argc--, argv++; argc > 0; argc -= argCount, argv += argCount) {
argCount = 1;
if (!strcmp(*argv, "-d")) {
if (argc == 1)
debugArgs = "+"; // turn on all debug flags
else {
debugArgs = *(argv + 1);
argCount = 2;
}
} else if (!strcmp(*argv, "-rs")) {
ASSERT(argc > 1);
RandomInit(atoi(*(argv + 1))); // initialize pseudo-random
// number generator
randomYield = TRUE;
argCount = 2;
}
#ifdef USER_PROGRAM
if (!strcmp(*argv, "-s"))
debugUserProg = TRUE;
#endif
#ifdef FILESYS_NEEDED
if (!strcmp(*argv, "-f"))
format = TRUE;
#endif
#ifdef NETWORK
if (!strcmp(*argv, "-l")) {
ASSERT(argc > 1);
rely = atof(*(argv + 1));
argCount = 2;
} else if (!strcmp(*argv, "-m")) {
ASSERT(argc > 1);
netname = atoi(*(argv + 1));
argCount = 2;
}
#endif
}
DebugInit(debugArgs); // initialize DEBUG messages
stats = new Statistics(); // collect statistics
interrupt = new Interrupt; // start up interrupt handling
scheduler = new Scheduler(); // initialize the ready queue
thread_slot = new Table(MAX_THREADS); // initialize the thread_slot
if (randomYield) // start the timer (if needed)
timer = new Timer(TimerInterruptHandler, 0, randomYield);
threadToBeDestroyed = NULL;
// We didn't explicitly allocate the current thread we are running in.
// But if it ever tries to give up the CPU, we better have a Thread
// object to save its state.
currentThread = new Thread("main");
currentThread->tid_ = thread_slot->Alloc(currentThread); //main thread allocated in thread_slot
currentThread->setStatus(RUNNING);
interrupt->Enable();
CallOnUserAbort(Cleanup); // if user hits ctl-C
#ifdef USER_PROGRAM
machine = new Machine(debugUserProg); // this must come first
#endif
#ifdef FILESYS
synchDisk = new SynchDisk("DISK");
#endif
#ifdef FILESYS_NEEDED
fileSystem = new FileSystem(format);
#endif
#ifdef NETWORK
postOffice = new PostOffice(netname, rely, 10);
#endif
}
//----------------------------------------------------------------------
// Cleanup
// Nachos is halting. De-allocate global data structures.
//----------------------------------------------------------------------
void
Cleanup()
{
printf("\nCleaning up...\n");
#ifdef NETWORK
delete postOffice;
#endif
#ifdef USER_PROGRAM
delete machine;
#endif
#ifdef FILESYS_NEEDED
delete fileSystem;
delete referCount;
#endif
#ifdef FILESYS
delete synchDisk;
#endif
delete timer;
delete scheduler;
delete interrupt;
delete thread_slot;
Exit(0);
}
| [
"mikepkucs@gmail.com"
] | mikepkucs@gmail.com |
96294d49f53e43db48454fd5e6b86517364038cb | 0406299c340374e0ff01a774c4be153bc875412f | /Course_1/week1/helloworld.cpp | 4bda9e65fd2d0db24a36f75c5e1a5b7d4eeb2a2a | [] | no_license | devlipe/Ccourse | f8e9f821e5297a550a58a636477c9c6ca6b5e5e4 | 22238a0e991679c182661d0fb4d7717892fb1c14 | refs/heads/master | 2023-06-04T17:06:51.941139 | 2021-06-19T14:49:27 | 2021-06-19T14:49:27 | 297,957,411 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 146 | cpp | // hello world for compiler test
#include<iostream>
using namespace std;
int main()
{
cout << "Hello World!\n" ;
return 0;
}
| [
"felipe.p.ferreira@ufv.br"
] | felipe.p.ferreira@ufv.br |
c50b7df063c4bc1b97e7b7974868610eabd22c2f | dc47a95abe1e689ed63dd5b2e75862af30115ee0 | /Color.h | 360ce736f012678248b957342b607ce247d91fda | [] | no_license | dcheesman/RGBeatDown | 6d0663e5c3a78a8bbf12e2c7619f75b31e19655c | 3708c1d45e7613915dac8fa09d582bd9c0ae5618 | refs/heads/master | 2021-01-20T08:46:08.988601 | 2015-08-27T22:58:49 | 2015-08-27T22:58:49 | 37,363,143 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 238 | h | #ifndef Color_h
#define Color_h
#include "Arduino.h"
class Color {
private:
int score;
public:
int red;
int green;
int blue;
void init();
void randomize();
int calculateColorScore(Color* c2);
};
#endif
| [
"dcheesman@gmail.com"
] | dcheesman@gmail.com |
bae64d03378d32a2a223b0cf3fb73c4d9723830f | afa8675e536666df43653ca8fe3850998d1935a9 | /A - Lucky Division.cpp | 5d6a751429bba3af5b30a2821ba130953e321a4c | [] | no_license | Saurav-Paul/Codeforces-Problem-Solution-By-Saurav-Paul | 0b7fdabaf87c30ac9e9e6f6e8ee4f36435a9f77e | e9cba8190d562061f1b4c26e76005b79e335d4d9 | refs/heads/master | 2022-10-21T18:40:31.822162 | 2022-09-14T15:44:26 | 2022-09-14T15:44:26 | 122,532,942 | 93 | 37 | null | 2020-10-03T09:45:07 | 2018-02-22T20:42:53 | C++ | UTF-8 | C++ | false | false | 358 | cpp | #include<iostream>
using namespace std;
int main()
{
int lucky[]={4,7,47,74,477,747,774,447,444,777,77,44};
int input,i,flag=0;
cin>>input;
for(i=0;i<12;i++)
{
if(input%lucky[i]==0)
{
flag=1;
break;
}
}
if(flag)
cout<<"YES\n";
else
cout<<"NO\n";
return 0;
}
| [
"noreply@github.com"
] | Saurav-Paul.noreply@github.com |
d7dac169ab8a578f0145525d1321c1944dc590a6 | 08a3abfcb7395b67b745807e264e03630c3356fe | /BattleTanks/Source/BattleTanks/Private/Projectile.cpp | e49d03bfe7c57d26d9f426293477e49ce4b77b0d | [] | no_license | ronman234/Battle_Tanks | 5735f3b6bf0b3a92b525fadba345b9be9fda48cd | adaf0ffcc2ca14c4967f33b37b6b4641158e75ca | refs/heads/master | 2020-03-22T13:46:42.802825 | 2018-08-16T21:55:33 | 2018-08-16T21:55:33 | 140,131,203 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,390 | cpp | // Fill out your copyright notice in the Description page of Project Settings.
#include "Projectile.h"
// Sets default values
AProjectile::AProjectile()
{
// Set this actor to call Tick() every frame. You can turn this off to improve performance if you don't need it.
PrimaryActorTick.bCanEverTick = false;
CollisionMesh = CreateDefaultSubobject<UStaticMeshComponent>(FName("Collision Mesh"));
SetRootComponent(CollisionMesh);
CollisionMesh->SetNotifyRigidBodyCollision(true);
CollisionMesh->SetVisibility(false);
LaunchBlast = CreateDefaultSubobject<UParticleSystemComponent>(FName("Launch Blast"));
LaunchBlast->AttachToComponent(RootComponent, FAttachmentTransformRules::KeepRelativeTransform);
ProjectileMovement = CreateDefaultSubobject<UProjectileMovementComponent>(FName("Projectile Movement Component"));
ProjectileMovement->bAutoActivate = false;
ImpactBlast = CreateDefaultSubobject<UParticleSystemComponent>(FName("Impact Blast"));
ImpactBlast->AttachToComponent(RootComponent, FAttachmentTransformRules::KeepRelativeTransform);
ImpactBlast->bAutoActivate = false;
ExplosionForce = CreateDefaultSubobject<URadialForceComponent>(FName("Explosion Force"));
ExplosionForce->AttachToComponent(RootComponent, FAttachmentTransformRules::KeepRelativeTransform);
}
// Called when the game starts or when spawned
void AProjectile::BeginPlay()
{
Super::BeginPlay();
CollisionMesh->OnComponentHit.AddDynamic(this, &AProjectile::OnHit);
}
// Called every frame
void AProjectile::Tick(float DeltaTime)
{
Super::Tick(DeltaTime);
}
void AProjectile::LaunchProjectile(float LaunchSpeed)
{
ProjectileMovement->SetVelocityInLocalSpace(FVector::ForwardVector * LaunchSpeed);
ProjectileMovement->Activate();
}
void AProjectile::OnHit(UPrimitiveComponent* HitComponent, AActor* OtherActor, UPrimitiveComponent* OtherComponent, FVector NormalImpulse, const FHitResult& Hit)
{
LaunchBlast->Deactivate();
ImpactBlast->Activate();
ExplosionForce->FireImpulse();
SetRootComponent(ImpactBlast);
CollisionMesh->DestroyComponent();
UGameplayStatics::ApplyRadialDamage(this, ProjectileDamage, GetActorLocation(), ExplosionForce->Radius, UDamageType::StaticClass(), TArray<AActor*>());
FTimerHandle Timer;
GetWorld()->GetTimerManager().SetTimer(Timer, this, &AProjectile::OnTimerExpire, DestroyDelay, false);
}
void AProjectile::OnTimerExpire()
{
Destroy();
} | [
"rgoennier@gmail.com"
] | rgoennier@gmail.com |
9cf7bd8d613d24f027e6f7943c67162503616f84 | 2dcad0f53d080ea354a8dbe7a7a7c441af80b460 | /Icelos/include/icelos_engine.hpp | 73affad6ab97d38ab4819009cf113a4712facae5 | [] | no_license | dxcloud/project-c | 77d2d7b8519499b675e470a5f0151084d4da03aa | b2883aecda5d6518a3d471529b631259de1ff9cb | refs/heads/master | 2021-01-23T08:15:19.296423 | 2014-07-04T15:35:28 | 2014-07-04T15:35:28 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,471 | hpp | ////////////////////////////////////////////////////////////////////////////////
/// @file icelos_engine.hpp
/// @brief Provides Engine class.
/// @date 2014-05-14
/// @version 0.1 (alpha)
/// @author Chengwu Huang <chengwhuang@gmail.com>
////////////////////////////////////////////////////////////////////////////////
#ifndef ICELOS_ENGINE_HPP
#define ICELOS_ENGINE_HPP
// icelos include
#include <icelos_type.hpp>
namespace icelos
{
class InputManager;
/// @class Engine
/// @brief The Engine class manages the application's control flow.
/// @details
/// The following example shows the minimum lines needed to run
/// an application.
/// @code
/// int main(int argc, char* argv[])
/// {
/// icelos::Engine app(argc, argv);
/// return app.run();
/// }
/// @endcode
class Engine
{
public:
/// @brief Public default constructor.
Engine();
/// @brief Public override constructor.
Engine(int argc, char* argv[]);
/// @brief Public destructor.
~Engine();
/// @brief Start engine.
/// @return Status code.
/// - @b STATUS_SUCCESS
/// - @b STATUS_ERROR
status_t run();
private:
/// @brief Initialize engine.
status_t initialize();
/// @brief Cleanup
void cleanup();
/// @brief Start game loop
void game_loop();
public:
/// @brief Static method
static void quit();
private:
static state_t m_engine_state;
int m_argc;
char** m_argv;
};
}
#endif // ICELOS_ENGINE_HPP
| [
"chengwhuang@gmail.com"
] | chengwhuang@gmail.com |
4c20a8de2cb5f55abe373016009f7ca00e18cee3 | 2780081bb046866b1449519cbe4dd78fbbf0719e | /XUL.framework/Versions/2.0/include/nsIAuthInformation.h | 4f4dde3886e6d373c1fdf77c0f7ab390be734645 | [] | no_license | edisonlee55/gluezilla-mac | d8b6535d2b36fc900eff837009372f033484a63f | 45d559edad7b5191430e139629d2aee918aa6654 | refs/heads/master | 2022-09-23T19:57:18.853517 | 2020-06-03T03:57:37 | 2020-06-03T03:57:37 | 267,499,676 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 10,145 | h | /*
* DO NOT EDIT. THIS FILE IS GENERATED FROM /builds/slave/rel-2.0-xr-osx64-bld/build/netwerk/base/public/nsIAuthInformation.idl
*/
#ifndef __gen_nsIAuthInformation_h__
#define __gen_nsIAuthInformation_h__
#ifndef __gen_nsISupports_h__
#include "nsISupports.h"
#endif
/* For IDL files that don't want to include root IDL files. */
#ifndef NS_NO_VTABLE
#define NS_NO_VTABLE
#endif
/* starting interface: nsIAuthInformation */
#define NS_IAUTHINFORMATION_IID_STR "0d73639c-2a92-4518-9f92-28f71fea5f20"
#define NS_IAUTHINFORMATION_IID \
{0x0d73639c, 0x2a92, 0x4518, \
{ 0x9f, 0x92, 0x28, 0xf7, 0x1f, 0xea, 0x5f, 0x20 }}
/**
* A object that hold authentication information. The caller of
* nsIAuthPrompt2::promptUsernameAndPassword or
* nsIAuthPrompt2::promptPasswordAsync provides an object implementing this
* interface; the prompt implementation can then read the values here to prefill
* the dialog. After the user entered the authentication information, it should
* set the attributes of this object to indicate to the caller what was entered
* by the user.
*/
class NS_NO_VTABLE NS_SCRIPTABLE nsIAuthInformation : public nsISupports {
public:
NS_DECLARE_STATIC_IID_ACCESSOR(NS_IAUTHINFORMATION_IID)
/** @name Flags */
/**
* This dialog belongs to a network host.
*/
enum { AUTH_HOST = 1U };
/**
* This dialog belongs to a proxy.
*/
enum { AUTH_PROXY = 2U };
/**
* This dialog needs domain information. The user interface should show a
* domain field, prefilled with the domain attribute's value.
*/
enum { NEED_DOMAIN = 4U };
/**
* This dialog only asks for password information. Authentication prompts
* SHOULD NOT show a username field. Attempts to change the username field
* will have no effect. nsIAuthPrompt2 implementations should, however, show
* its initial value to the user in some form. For example, a paragraph in
* the dialog might say "Please enter your password for user jsmith at
* server intranet".
*
* This flag is mutually exclusive with #NEED_DOMAIN.
*/
enum { ONLY_PASSWORD = 8U };
/**
* We have already tried to log in for this channel
* (with auth values from a previous promptAuth call),
* but it failed, so we now ask the user to provide a new, correct login.
*
* @see also RFC 2616, Section 10.4.2
*/
enum { PREVIOUS_FAILED = 16U };
/**
* Flags describing this dialog. A bitwise OR of the flag values
* above.
*
* It is possible that neither #AUTH_HOST nor #AUTH_PROXY are set.
*
* Auth prompts should ignore flags they don't understand; especially, they
* should not throw an exception because of an unsupported flag.
*/
/* readonly attribute unsigned long flags; */
NS_SCRIPTABLE NS_IMETHOD GetFlags(PRUint32 *aFlags) = 0;
/**
* The server-supplied realm of the authentication as defined in RFC 2617.
* Can be the empty string if the protocol does not support realms.
* Otherwise, this is a human-readable string like "Secret files".
*/
/* readonly attribute AString realm; */
NS_SCRIPTABLE NS_IMETHOD GetRealm(nsAString & aRealm) = 0;
/**
* The authentication scheme used for this request, if applicable. If the
* protocol for this authentication does not support schemes, this will be
* the empty string. Otherwise, this will be a string such as "basic" or
* "digest". This string will always be in lowercase.
*/
/* readonly attribute AUTF8String authenticationScheme; */
NS_SCRIPTABLE NS_IMETHOD GetAuthenticationScheme(nsACString & aAuthenticationScheme) = 0;
/**
* The initial value should be used to prefill the dialog or be shown
* in some other way to the user.
* On return, this parameter should contain the username entered by
* the user.
* This field can only be changed if the #ONLY_PASSWORD flag is not set.
*/
/* attribute AString username; */
NS_SCRIPTABLE NS_IMETHOD GetUsername(nsAString & aUsername) = 0;
NS_SCRIPTABLE NS_IMETHOD SetUsername(const nsAString & aUsername) = 0;
/**
* The initial value should be used to prefill the dialog or be shown
* in some other way to the user.
* The password should not be shown in clear.
* On return, this parameter should contain the password entered by
* the user.
*/
/* attribute AString password; */
NS_SCRIPTABLE NS_IMETHOD GetPassword(nsAString & aPassword) = 0;
NS_SCRIPTABLE NS_IMETHOD SetPassword(const nsAString & aPassword) = 0;
/**
* The initial value should be used to prefill the dialog or be shown
* in some other way to the user.
* On return, this parameter should contain the domain entered by
* the user.
* This attribute is only used if flags include #NEED_DOMAIN.
*/
/* attribute AString domain; */
NS_SCRIPTABLE NS_IMETHOD GetDomain(nsAString & aDomain) = 0;
NS_SCRIPTABLE NS_IMETHOD SetDomain(const nsAString & aDomain) = 0;
};
NS_DEFINE_STATIC_IID_ACCESSOR(nsIAuthInformation, NS_IAUTHINFORMATION_IID)
/* Use this macro when declaring classes that implement this interface. */
#define NS_DECL_NSIAUTHINFORMATION \
NS_SCRIPTABLE NS_IMETHOD GetFlags(PRUint32 *aFlags); \
NS_SCRIPTABLE NS_IMETHOD GetRealm(nsAString & aRealm); \
NS_SCRIPTABLE NS_IMETHOD GetAuthenticationScheme(nsACString & aAuthenticationScheme); \
NS_SCRIPTABLE NS_IMETHOD GetUsername(nsAString & aUsername); \
NS_SCRIPTABLE NS_IMETHOD SetUsername(const nsAString & aUsername); \
NS_SCRIPTABLE NS_IMETHOD GetPassword(nsAString & aPassword); \
NS_SCRIPTABLE NS_IMETHOD SetPassword(const nsAString & aPassword); \
NS_SCRIPTABLE NS_IMETHOD GetDomain(nsAString & aDomain); \
NS_SCRIPTABLE NS_IMETHOD SetDomain(const nsAString & aDomain);
/* Use this macro to declare functions that forward the behavior of this interface to another object. */
#define NS_FORWARD_NSIAUTHINFORMATION(_to) \
NS_SCRIPTABLE NS_IMETHOD GetFlags(PRUint32 *aFlags) { return _to GetFlags(aFlags); } \
NS_SCRIPTABLE NS_IMETHOD GetRealm(nsAString & aRealm) { return _to GetRealm(aRealm); } \
NS_SCRIPTABLE NS_IMETHOD GetAuthenticationScheme(nsACString & aAuthenticationScheme) { return _to GetAuthenticationScheme(aAuthenticationScheme); } \
NS_SCRIPTABLE NS_IMETHOD GetUsername(nsAString & aUsername) { return _to GetUsername(aUsername); } \
NS_SCRIPTABLE NS_IMETHOD SetUsername(const nsAString & aUsername) { return _to SetUsername(aUsername); } \
NS_SCRIPTABLE NS_IMETHOD GetPassword(nsAString & aPassword) { return _to GetPassword(aPassword); } \
NS_SCRIPTABLE NS_IMETHOD SetPassword(const nsAString & aPassword) { return _to SetPassword(aPassword); } \
NS_SCRIPTABLE NS_IMETHOD GetDomain(nsAString & aDomain) { return _to GetDomain(aDomain); } \
NS_SCRIPTABLE NS_IMETHOD SetDomain(const nsAString & aDomain) { return _to SetDomain(aDomain); }
/* Use this macro to declare functions that forward the behavior of this interface to another object in a safe way. */
#define NS_FORWARD_SAFE_NSIAUTHINFORMATION(_to) \
NS_SCRIPTABLE NS_IMETHOD GetFlags(PRUint32 *aFlags) { return !_to ? NS_ERROR_NULL_POINTER : _to->GetFlags(aFlags); } \
NS_SCRIPTABLE NS_IMETHOD GetRealm(nsAString & aRealm) { return !_to ? NS_ERROR_NULL_POINTER : _to->GetRealm(aRealm); } \
NS_SCRIPTABLE NS_IMETHOD GetAuthenticationScheme(nsACString & aAuthenticationScheme) { return !_to ? NS_ERROR_NULL_POINTER : _to->GetAuthenticationScheme(aAuthenticationScheme); } \
NS_SCRIPTABLE NS_IMETHOD GetUsername(nsAString & aUsername) { return !_to ? NS_ERROR_NULL_POINTER : _to->GetUsername(aUsername); } \
NS_SCRIPTABLE NS_IMETHOD SetUsername(const nsAString & aUsername) { return !_to ? NS_ERROR_NULL_POINTER : _to->SetUsername(aUsername); } \
NS_SCRIPTABLE NS_IMETHOD GetPassword(nsAString & aPassword) { return !_to ? NS_ERROR_NULL_POINTER : _to->GetPassword(aPassword); } \
NS_SCRIPTABLE NS_IMETHOD SetPassword(const nsAString & aPassword) { return !_to ? NS_ERROR_NULL_POINTER : _to->SetPassword(aPassword); } \
NS_SCRIPTABLE NS_IMETHOD GetDomain(nsAString & aDomain) { return !_to ? NS_ERROR_NULL_POINTER : _to->GetDomain(aDomain); } \
NS_SCRIPTABLE NS_IMETHOD SetDomain(const nsAString & aDomain) { return !_to ? NS_ERROR_NULL_POINTER : _to->SetDomain(aDomain); }
#if 0
/* Use the code below as a template for the implementation class for this interface. */
/* Header file */
class nsAuthInformation : public nsIAuthInformation
{
public:
NS_DECL_ISUPPORTS
NS_DECL_NSIAUTHINFORMATION
nsAuthInformation();
private:
~nsAuthInformation();
protected:
/* additional members */
};
/* Implementation file */
NS_IMPL_ISUPPORTS1(nsAuthInformation, nsIAuthInformation)
nsAuthInformation::nsAuthInformation()
{
/* member initializers and constructor code */
}
nsAuthInformation::~nsAuthInformation()
{
/* destructor code */
}
/* readonly attribute unsigned long flags; */
NS_IMETHODIMP nsAuthInformation::GetFlags(PRUint32 *aFlags)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
/* readonly attribute AString realm; */
NS_IMETHODIMP nsAuthInformation::GetRealm(nsAString & aRealm)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
/* readonly attribute AUTF8String authenticationScheme; */
NS_IMETHODIMP nsAuthInformation::GetAuthenticationScheme(nsACString & aAuthenticationScheme)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
/* attribute AString username; */
NS_IMETHODIMP nsAuthInformation::GetUsername(nsAString & aUsername)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP nsAuthInformation::SetUsername(const nsAString & aUsername)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
/* attribute AString password; */
NS_IMETHODIMP nsAuthInformation::GetPassword(nsAString & aPassword)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP nsAuthInformation::SetPassword(const nsAString & aPassword)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
/* attribute AString domain; */
NS_IMETHODIMP nsAuthInformation::GetDomain(nsAString & aDomain)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP nsAuthInformation::SetDomain(const nsAString & aDomain)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
/* End of implementation class template. */
#endif
#endif /* __gen_nsIAuthInformation_h__ */
| [
"edisonlee@edisonlee55.com"
] | edisonlee@edisonlee55.com |
1adc10cc2da6eebdf2ff526410ec7428ff213cdb | 84ff9d3de0cb8041e5f7e0e4826704ac89a6b1f5 | /include/trm/complex.h | a48cf7e848c1223d35fdd62131544e629cbbbab8 | [] | no_license | trmrsh/cpp-subs | 927c1f969a1021a9446b06b6882df0faf450bbb3 | af93d2c33b5ee797535c790844586c12a9a41f2a | refs/heads/master | 2021-05-02T07:57:16.293461 | 2019-01-11T22:49:01 | 2019-01-11T22:49:01 | 11,352,292 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,016 | h | #include "trm/subs.h"
namespace Subs {
/** Class representing complex numbers
*/
class Complex {
public:
//! Default constructor. No initialisation
Complex() : real_(), imag_() {}
//! Sets complex number from a pure real number
Complex(double real) : real_(real), imag_(0.) {}
//! General constructor
Complex(double real, double imag) : real_(real), imag_(imag) {}
//! Modulus of a complex number
double modulus() const {return sqrt(sqr(real_) + sqr(imag_));}
double real() const {return real_;}
double imag() const {return imag_;}
//! Multiplication in place
void operator*=(const Complex& c){
real_ = real_*c.real_ - imag_*c.imag_;
imag_ = real_*c.imag_ + imag_*c.real_;
}
//! Multiplication in place
void operator*=(double c){
real_ = real_*c;
imag_ = imag_*c;
}
friend Complex operator*(const Complex& c1, const Complex& c2);
private:
double real_;
double imag_;
};
Complex operator*(const Complex& c1, const Complex& c2);
};
| [
"t.r.marsh@warwick.ac.uk"
] | t.r.marsh@warwick.ac.uk |
0899515982a09931aa014b4eeff1671aecc7b404 | bd7486a56e71b520d0016f170aafa9633d44f05b | /multiwinia/contrib/systemiv/lib/netlib/net_lib_linux.h | c2598eb8065f292480aa80621f56a5742812b9ad | [] | no_license | bsella/Darwinia-and-Multiwinia-Source-Code | 3bf1d7117f1be48a7038e2ab9f7d385bf82852d1 | 22f2069b9228a02c7e2953ace1ea63c2ef534e41 | refs/heads/master | 2022-05-31T18:35:59.264774 | 2022-04-24T22:40:30 | 2022-04-24T22:40:30 | 290,299,680 | 0 | 0 | null | 2020-08-25T19:02:29 | 2020-08-25T19:02:29 | null | UTF-8 | C++ | false | false | 1,745 | h | #ifndef INCLUDED_NET_LIB_LINUX_H
#define INCLUDED_NET_LIB_LINUX_H
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <fcntl.h>
#include <unistd.h>
#include <string.h>
#include <netdb.h>
#include <errno.h>
#include <pthread.h>
#include <semaphore.h>
class NetUdpPacket;
typedef void * (*NetCallBack)(NetUdpPacket *data);
typedef void * (*NetThreadFunc)(void *ptr);
// Define portable names for Linux functions
#define NetGetLastError() errno
#define NetSleep(a) usleep(a*1000)
#define NetCloseSocket ::close
#define NetGetHostByName gethostbyname // Should eventually be getaddrinfo (?)
#define NetSetSocketNonBlocking(a) fcntl(m_sockfd, F_SETFL, fcntl(a,F_GETFD) | O_NONBLOCK)
// Define portable names for Linux types
#define NetSocketLenType socklen_t
#define NetSocketHandle int
#define NetHostDetails struct hostent
#define NetThreadHandle pthread_t
#define NetCallBackRetType void *
#define NetPollObject fd_set
#define NetMutexHandle pthread_mutex_t
#define NetSemaphoreHandle sem_t
#define NetThreadId pthread_t
struct NetEventHandle {
pthread_mutex_t mutex;
pthread_cond_t cond;
bool signalled;
};
// Define portable names for Linux constants
#define NET_SOCKET_ERROR -1
#define NCSD_SEND 1
#define NCSD_READ 0
// Define portable ways to test various conditions
#define NetIsAddrInUse (errno != EADDRINUSE)
#define NetIsSocketError(a) (a == -1)
#define NetIsBlockingError(a) ((a == EALREADY) || (a == EINPROGRESS) || (a == EAGAIN))
#define NetIsConnected(a) 0
#define NetIsReset(a) ((a == EPIPE) || (a == ECONNRESET))
#endif
| [
"root@9244cb4f-d52e-49a9-a756-7d4e53ad8306"
] | root@9244cb4f-d52e-49a9-a756-7d4e53ad8306 |
d0c397aa99aa53c2180702f58f1d168061a85dc0 | cc3444543e771b14a4d71fa4e887c0d3ebf4eb87 | /Common/D3DEnum.cpp | 37deea64d0e642989bad87217c3d7601fcb29dff | [
"Unlicense"
] | permissive | zetsumi/ATools | 12102721ae17c4f11bb4c990645bc5a349812087 | 4e831b2b05de2c28f27a4fccde6d7e48126fb5c5 | refs/heads/master | 2023-07-17T11:35:11.208292 | 2021-05-24T19:57:50 | 2021-05-24T19:57:50 | 272,903,560 | 3 | 4 | Unlicense | 2020-06-25T20:00:11 | 2020-06-17T07:10:43 | C++ | UTF-8 | C++ | false | false | 16,332 | cpp | ///////////
// This file is a part of the ATools project
// Some parts of code are the property of Microsoft, Qt or Aeonsoft
// The rest is released without license and without any warranty
///////////
#include <stdafx.h>
#include "D3DEnum.h"
using namespace D3D;
bool DeviceCombo::SupportsMultiSampleType(D3DMULTISAMPLE_TYPE multisamples)
{
if (MSTypes.Find(multisamples) == -1)
return false;
DSMSConflict c;
if (DSFormats.Find(D3DFMT_D24X8) != -1)
c.fmt = D3DFMT_D24X8;
else if (DSFormats.Find(D3DFMT_D16) != -1)
c.fmt = D3DFMT_D16;
else
c.fmt = (D3DFORMAT)DSFormats[DSFormats.Length() - 1];
c.mst = multisamples;
return DSMSConflicts.Find(c) == -1;
}
//-----------------------------------------------------------------------------
// SortModesCallback(): sort callback comparing two D3DDISPLAYMODEs
//-----------------------------------------------------------------------------
static int __cdecl SortModesCallback(const void* arg1, const void* arg2)
{
D3DDISPLAYMODE* pdm1 = (D3DDISPLAYMODE*)arg1;
D3DDISPLAYMODE* pdm2 = (D3DDISPLAYMODE*)arg2;
// the wider display modes sink down, the thinner bubble up
if (pdm1->Width > pdm2->Width) return +1;
if (pdm1->Width < pdm2->Width) return -1;
// the taller display modes sink down, the shorter bubble up
if (pdm1->Height > pdm2->Height) return +1;
if (pdm1->Height < pdm2->Height) return -1;
// the more colorful display modes sink down
if (RGBBITS(pdm1->Format) > RGBBITS(pdm2->Format)) return +1;
if (RGBBITS(pdm1->Format) < RGBBITS(pdm2->Format)) return -1;
// the faster display modes sink down
if (pdm1->RefreshRate > pdm2->RefreshRate) return +1;
if (pdm1->RefreshRate < pdm2->RefreshRate) return -1;
// the two display modes are identical
return 0;
}
//-----------------------------------------------------------------------------
// CEnum(): constructor, sets up app constraints
//-----------------------------------------------------------------------------
CEnum::CEnum()
{
AppMinFullscreenWidth = 640;
AppMinFullscreenHeight = 480;
AppMinRGBBits = 5;
AppMinAlphaBits = 0;
AppMinDepthBits = 15;
AppMinStencilBits = 0;
AppUsesDepthBuffer = true;
AppUsesMixedVP = true;
// we will allow every possible display mode format by default;
// they indicate how many bits are dedicated to each channel (Alpha, Red,
// Green and Blue), with X standing for unused.
// take care to maintain consistency between the format list and the
// 'AppMinRGBBits' and 'AppMinAlphaBits' constraints above.
// Also notice the 10-bit format is only available in fullscreen modes.
AppDisplayFormats.Append(D3DFMT_R5G6B5); // 16-bit, 6 for green
AppDisplayFormats.Append(D3DFMT_X1R5G5B5); // 16-bit, 5 per channel
AppDisplayFormats.Append(D3DFMT_A1R5G5B5); // 16-bit, 1 for alpha
AppDisplayFormats.Append(D3DFMT_X8R8G8B8); // 32-bit, 8 per channel
AppDisplayFormats.Append(D3DFMT_A8R8G8B8); // 32-bit, 8 for alpha
AppDisplayFormats.Append(D3DFMT_A2R10G10B10); // 32-bit, 2 for alpha
// we will allow every backbuffer format by default
AppBackBufferFormats.Append(D3DFMT_R5G6B5);
AppBackBufferFormats.Append(D3DFMT_X1R5G5B5);
AppBackBufferFormats.Append(D3DFMT_A1R5G5B5);
AppBackBufferFormats.Append(D3DFMT_X8R8G8B8);
AppBackBufferFormats.Append(D3DFMT_A8R8G8B8);
AppBackBufferFormats.Append(D3DFMT_A2R10G10B10);
// we will allow every depth/stencil format by default; obviously, D is
// for depth S for stencil, and X unused.
AppDepthStencilFormats.Append(D3DFMT_D16);
AppDepthStencilFormats.Append(D3DFMT_D15S1);
AppDepthStencilFormats.Append(D3DFMT_D24X8);
AppDepthStencilFormats.Append(D3DFMT_D24X4S4);
AppDepthStencilFormats.Append(D3DFMT_D24S8);
AppDepthStencilFormats.Append(D3DFMT_D32);
// we will allow every multisampling type by default, even the nonmaskable,
// to enable the quality levels
AppMultiSamplingTypes.Append(D3DMULTISAMPLE_NONE);
AppMultiSamplingTypes.Append(D3DMULTISAMPLE_NONMASKABLE);
AppMultiSamplingTypes.Append(D3DMULTISAMPLE_2_SAMPLES);
AppMultiSamplingTypes.Append(D3DMULTISAMPLE_3_SAMPLES);
AppMultiSamplingTypes.Append(D3DMULTISAMPLE_4_SAMPLES);
AppMultiSamplingTypes.Append(D3DMULTISAMPLE_5_SAMPLES);
AppMultiSamplingTypes.Append(D3DMULTISAMPLE_6_SAMPLES);
AppMultiSamplingTypes.Append(D3DMULTISAMPLE_7_SAMPLES);
AppMultiSamplingTypes.Append(D3DMULTISAMPLE_8_SAMPLES);
AppMultiSamplingTypes.Append(D3DMULTISAMPLE_9_SAMPLES);
AppMultiSamplingTypes.Append(D3DMULTISAMPLE_10_SAMPLES);
AppMultiSamplingTypes.Append(D3DMULTISAMPLE_11_SAMPLES);
AppMultiSamplingTypes.Append(D3DMULTISAMPLE_12_SAMPLES);
AppMultiSamplingTypes.Append(D3DMULTISAMPLE_13_SAMPLES);
AppMultiSamplingTypes.Append(D3DMULTISAMPLE_14_SAMPLES);
AppMultiSamplingTypes.Append(D3DMULTISAMPLE_15_SAMPLES);
AppMultiSamplingTypes.Append(D3DMULTISAMPLE_16_SAMPLES);
}
//-----------------------------------------------------------------------------
// EnumerateDSFormats(): add depth/stencil formats compatible with the device
// and the app to the given device combo
//-----------------------------------------------------------------------------
void CEnum::EnumerateDSFormats(DeviceCombo* pdc)
{
D3DFORMAT fmt;
// traverse the app defined depth/stencil formats
for (UINT i = 0; i < AppDepthStencilFormats.Length(); i++)
{
fmt = (D3DFORMAT)AppDepthStencilFormats[i];
// check the format against app requirements
if (DEPTHBITS(fmt) < AppMinDepthBits) continue;
if (STENCILBITS(fmt) < AppMinStencilBits) continue;
// is the format available for a depth/stencil surface resource on
// this device?
if (FAILED(m_pd3d->CheckDeviceFormat(pdc->AdapterOrdinal,
pdc->DevType,
pdc->DisplayFormat,
D3DUSAGE_DEPTHSTENCIL,
D3DRTYPE_SURFACE,
fmt)))
continue;
// does it match both the display and back buffer formats?
if (FAILED(m_pd3d->CheckDepthStencilMatch(pdc->AdapterOrdinal,
pdc->DevType,
pdc->DisplayFormat,
pdc->BackBufferFormat,
fmt)))
continue;
// yes, yes!
pdc->DSFormats.Append(fmt);
}
}
//-----------------------------------------------------------------------------
// EnumerateMSTypes(): add multisample types that are compatible with the
// device and the app to the given device combo
//-----------------------------------------------------------------------------
void CEnum::EnumerateMSTypes(DeviceCombo* pdc)
{
D3DMULTISAMPLE_TYPE msType;
DWORD msQuality;
// traverse the types and check for support
for (UINT i = 0; i < AppMultiSamplingTypes.Length(); i++)
{
msType = (D3DMULTISAMPLE_TYPE)AppMultiSamplingTypes[i];
if (FAILED(m_pd3d->CheckDeviceMultiSampleType(pdc->AdapterOrdinal,
pdc->DevType,
pdc->BackBufferFormat,
pdc->Windowed,
msType,
&msQuality)))
continue;
// supported
pdc->MSTypes.Append(msType);
// important! presentation parameters quality levels are zero-based,
// and the API call returns the number of levels, so we will store
// the maximum value that can be used in other Direct3D API calls,
// i.o., the number of levels. Also notice that both these lists must
// always be accessed with indices in synch.
if (msQuality != 0)
msQuality -= 1;
pdc->MSQualityLevels.Append(msQuality);
}
}
//-----------------------------------------------------------------------------
// EnumerateDSMSConflicts(): find any conflicts between the depth/stencil
// formats and multisample types in the given device combo
//-----------------------------------------------------------------------------
void CEnum::EnumerateDSMSConflicts(DeviceCombo* pdc)
{
DSMSConflict con;
D3DFORMAT fmt;
D3DMULTISAMPLE_TYPE mst;
// traverse formats
for (UINT i = 0; i < pdc->DSFormats.Length(); i++)
{
fmt = (D3DFORMAT)pdc->DSFormats[i];
// check against multisample types
for (UINT j = 0; j < pdc->MSTypes.Length(); j++)
{
mst = (D3DMULTISAMPLE_TYPE)pdc->MSTypes[j];
// failure to support the combination indicates a conflict; save it
if (FAILED(m_pd3d->CheckDeviceMultiSampleType(pdc->AdapterOrdinal,
pdc->DevType,
fmt,
pdc->Windowed,
mst,
NULL)))
{
con.fmt = fmt;
con.mst = mst;
pdc->DSMSConflicts.Append(con);
}
}
}
}
//-----------------------------------------------------------------------------
// EnumerateVPTypes(): add vertex processing types that are compatible with the
// device and the app to the given device combo
//-----------------------------------------------------------------------------
void CEnum::EnumerateVPTypes(DeviceInfo* pdi, DeviceCombo* pdc)
{
// by default, every VP type is allowed, even the mixed one; your
// application may have different requirements, i.e. the need for
// a pure hardware device to test a graphics card...
if ((pdi->Caps.DevCaps & D3DDEVCAPS_HWTRANSFORMANDLIGHT) != 0
&& pdi->Caps.VertexShaderVersion >= D3DVS_VERSION(1, 1))
{
if ((pdi->Caps.DevCaps & D3DDEVCAPS_PUREDEVICE) != 0)
pdc->VPTypes.Append(PURE_VP);
pdc->VPTypes.Append(HARD_VP);
if (AppUsesMixedVP)
pdc->VPTypes.Append(MIXD_VP);
}
pdc->VPTypes.Append(SOFT_VP);
}
//-----------------------------------------------------------------------------
// EnumeratePIntervals(): query device caps to add the presentation intervals
// that may deal with flicker or other artifacts.
//-----------------------------------------------------------------------------
void CEnum::EnumeratePIntervals(DeviceInfo* pdi, DeviceCombo* pdc)
{
// the default interval (the same as D3DPRESENT_INTERVAL_ONE) is always
// available; we will put it at the top, to avoid mouse flicker in windowed
//apps
pdc->PresentIntervals.Append(D3DPRESENT_INTERVAL_DEFAULT);
// the immediate interval is always available, but is worth checking...
if ((pdi->Caps.PresentationIntervals & D3DPRESENT_INTERVAL_IMMEDIATE) != 0)
pdc->PresentIntervals.Append(D3DPRESENT_INTERVAL_IMMEDIATE);
// the rest are truly hardware-dependant
if ((pdi->Caps.PresentationIntervals & D3DPRESENT_INTERVAL_TWO) != 0)
pdc->PresentIntervals.Append(D3DPRESENT_INTERVAL_TWO);
if ((pdi->Caps.PresentationIntervals & D3DPRESENT_INTERVAL_THREE) != 0)
pdc->PresentIntervals.Append(D3DPRESENT_INTERVAL_THREE);
if ((pdi->Caps.PresentationIntervals & D3DPRESENT_INTERVAL_FOUR) != 0)
pdc->PresentIntervals.Append(D3DPRESENT_INTERVAL_FOUR);
}
//-----------------------------------------------------------------------------
// EnumerateDeviceCombos(): for a particular device
//-----------------------------------------------------------------------------
HRESULT CEnum::EnumerateDeviceCombos(DeviceInfo* pdi,
DWORDARRAY* pDisplayFormats)
{
D3DFORMAT fmt;
D3DFORMAT bbfmt;
// traverse the passed-in display formats
for (UINT i = 0; i < pDisplayFormats->Length(); i++)
{
fmt = (D3DFORMAT)(*pDisplayFormats)[i];
// traverse the app allowed backbuffer formats
for (UINT j = 0; j < AppBackBufferFormats.Length(); j++)
{
bbfmt = (D3DFORMAT)AppBackBufferFormats[j];
// check each against the app constraint
if (ALPHABITS(bbfmt) < AppMinAlphaBits)
continue;
// we'll check if the device supports a display mode-backbuffer
// formats combination, once for windowed display modes,
// once for fullscreen modes
for (UINT k = 0; k < 2; k++)
{
// check for system support
if (FAILED(m_pd3d->CheckDeviceType(pdi->AdapterOrdinal,
pdi->DevType,
fmt,
bbfmt,
k % 2 == 0)))
continue;
// at this point we have a DeviceCombo supported by the system,
// but we still need to confirm that it is compatible with
// other app constraints; we'll fill in a device combo with
// what we know so far
DeviceCombo dc;
dc.Windowed = k % 2 == 0;
dc.AdapterOrdinal = pdi->AdapterOrdinal;
dc.DevType = pdi->DevType;
dc.DisplayFormat = fmt;
dc.BackBufferFormat = bbfmt;
// enumerate VP types (software VP should always be available)
EnumerateVPTypes(pdi, &dc);
// enumerate presentation intervals (the default should always
// be available)
EnumeratePIntervals(pdi, &dc);
// check for multisampling requirements
EnumerateMSTypes(&dc);
if (dc.MSTypes.Length() == 0)
continue;
// check the depth/stencil requirements
if (AppUsesDepthBuffer)
{
EnumerateDSFormats(&dc);
if (dc.DSFormats.Length() == 0)
continue;
// gather depth/stecil-multisampling conflicts
EnumerateDSMSConflicts(&dc);
}
// met every requirement!
pdi->DeviceCombos.Append(dc);
}
}
}
return S_OK;
}
//-----------------------------------------------------------------------------
// EnumerateDevices(): Enumerates D3D devices for a particular adapter
//-----------------------------------------------------------------------------
HRESULT CEnum::EnumerateDevices(AdapterInfo* pai, DWORDARRAY* pDisplayFormats)
{
HRESULT hr;
DeviceInfo di;
// traverse the device types, there are only three, namely, a HAL device, a
// reference device and a software device, defined by the D3DDEVTYPE enum
// with values 1, 2 and 3 respectively
for (UINT i = 1; i < 4; i++)
{
// save members of this device info
di.AdapterOrdinal = pai->AdapterOrdinal;
di.DevType = (D3DDEVTYPE)i;
// retrieve and store device capabilities in this device
// info for inspection later
if (FAILED(m_pd3d->GetDeviceCaps(di.AdapterOrdinal,
di.DevType,
&di.Caps)))
continue;
// get info for each device combo on this device info
if (FAILED(hr = EnumerateDeviceCombos(&di, pDisplayFormats)))
return hr;
if (di.DeviceCombos.Length() == 0)
continue;
// if at least one device combo for this device was found,
// add it to the corresponding list
pai->DeviceInfos.Append(di);
}
return S_OK;
}
//-----------------------------------------------------------------------------
// Enumerate(): available D3D adapters, devices, modes, etc. for the passed-in
// D3D object, a reference to which is mantained by the class.
//-----------------------------------------------------------------------------
bool CEnum::Enumerate(LPDIRECT3D9 pD3D)
{
// we need a valid D3D object to continue
if (pD3D == NULL)
return false;
// keep a local reference to it
m_pd3d = pD3D;
HRESULT hr;
AdapterInfo ai;
DWORDARRAY formats;
// traverse adapters (usually just one)
for (UINT i = 0; i < m_pd3d->GetAdapterCount(); i++)
{
// identify this adapter (retrieve and store a description)
ai.AdapterOrdinal = i;
m_pd3d->GetAdapterIdentifier(i, 0, &ai.AdapterIdentifier);
D3DFORMAT fmt;
D3DDISPLAYMODE dm;
// we will check adapter modes for compatibility with each of the
// app defined display formats, resolution and color depth,
// setup in the constructor
for (UINT j = 0; j < AppDisplayFormats.Length(); j++)
{
// get one of the application defined formats
fmt = (D3DFORMAT)AppDisplayFormats[j];
// get a list of modes for this adapter that support it
for (UINT k = 0; k < m_pd3d->GetAdapterModeCount(i, fmt); k++)
{
// retrieve a display mode with an enumeration call
m_pd3d->EnumAdapterModes(i, fmt, k, &dm);
// check the display mode for resolution, color and
// alpha bit depth
if (dm.Width < AppMinFullscreenWidth ||
dm.Height < AppMinFullscreenHeight ||
RGBBITS(dm.Format) < AppMinRGBBits ||
ALPHABITS(dm.Format) < AppMinAlphaBits)
continue;
// it meets the requirements, so the current adapter info
// inherits it, for it is compatible with the app
ai.DisplayModes.Append(dm);
// append the format to the temp list that we'll use to
// enumerate devices, if not already there
if (formats.Find(dm.Format) == -1)
formats.Append(dm.Format);
}
}
// sort the display modes list so that the smallest and fastest
// gets to the top of the list (see SortModesCallback)
ai.DisplayModes.Sort(SortModesCallback);
// get info for each device on this adapter, providing the formats
// that met the application requirements
if (FAILED(hr = EnumerateDevices(&ai, &formats)))
{
qCritical("Can't enumerate Direct3D devices.");
return false;
}
// if at least one device on this adapter is available and compatible
// with the app, add the adapterInfo to the list
if (ai.DeviceInfos.Length() != 0)
AdapterInfos.Append(ai);
// clear the format list for the next adapter
formats.Clear();
}
return true;
}
| [
"loicsaos@gmail.com"
] | loicsaos@gmail.com |
407ca302c9522fe78868e24ea4ce9e5cc988514d | f080a40fe93b20d9de93c75f2cb5b53b841a4668 | /CodeForces/Nirvarna.cpp | 041bfc184de84f7245899afb5ac6f3f0a2f5cd07 | [] | no_license | samueljrz/Competitive-Programing | a88e2a52b4640b7094dc979d1c3fd204e8de7f59 | 5de2655725e9beccfc5320b89334fd2d1b8adf19 | refs/heads/master | 2021-07-17T06:51:35.346238 | 2020-09-21T00:22:14 | 2020-09-21T00:22:14 | 214,507,466 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 885 | cpp | #include <bits/stdc++.h>
using namespace std;
int n, ans=1, tst, anstst=1, j=0;
vector<int> v;
vector<int> vtst;
bool ver = false;
int main () {
cin >> n;
tst = n;
while(tst) {
if(tst < 10 and tst > 0) {
vtst.push_back(tst%10);
j++;
break;
}
//if(tst%10 != 9) {
tst = tst - (tst%10) - 1;
//}else
if((tst%10) > 0) {
j++;
}
vtst.push_back(tst%10);
tst /= 10;
}
if(n < 10) {
cout << n << endl;
return 0;
}else {
if(n%10) {
while(n) {
v.push_back(n%10);
n /= 10;
}
}else {
n -= 1;
while(n) {
v.push_back(n%10);
n /= 10;
}
}
}
for(int i=0; i<v.size(); i++) {
ans *= v[i];
if(j--) {
anstst *= vtst[i];
cout << vtst[i] << " ";
}
}
if(ans < 9 and anstst < 9) {
cout << '9' << endl;
}else
if(anstst > ans) {
cout << anstst << endl;
}else {
cout << ans << endl;
}
return 0;
} | [
"samuelevangelista.ti@gmail.com"
] | samuelevangelista.ti@gmail.com |
8d468c6dc394af2e30bb77e8833e51863ce1c846 | 51e9012435503b693a7811301c6af4332033a1a3 | /TAPCON/TAPCON.cpp | 508da3d5a9d7417e6b46052b0fefdfa2bcd7a47c | [] | no_license | phutruonnttn/CPP_Code_Giai_Thuat | e7e3312ae70cee9ade33994de0cc3a1f17fbf0f1 | 8081d346aa0348d1a6bef546036e5a498e7b2ee5 | refs/heads/master | 2020-07-02T04:29:51.910768 | 2019-08-09T07:16:37 | 2019-08-09T07:16:37 | 201,412,551 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,095 | cpp | #include <bits/stdc++.h>
#define nmax 70
using namespace std;
long long n,a[nmax];
long long mu(long m)
{
return 1ll<<m;
}
long long timstt(long long k)
{
long long res=k,ct=0;
for (long long i=1; i<=k; i++)
{
//if (i<k) res--;
for (long j=a[i-n]+1; j<=a[i]-1; j++)
res+=mu(n-j);
}
return res;
}
void timxau(long long t)
{
a[0]=0;
long dem=0;
for (long i=1; i<=n; i++)
{
if (t==1) break;
t--;
for (long j=a[i-1]+1; j<=n; j++)
if (t>mu(n-j)) t-=mu(n-j);
else {
a[++dem]=j;
break;
}
}
for (long i=1; i<=dem; i++)
cout << a[i] << " ";
cout << '\n';
}
int main()
{
ios_base::sync_with_stdio(0);
freopen("TAPCON.inp","r",stdin);
freopen("TAPCON.out","w",stdout);
cin >> n;
cout << mu(n)-1 << '\n';
a[1]=1; a[2]=2; a[3]=3;
cout << timstt(3);
//for (long i=1 ; i<=n+1; i++) timxau(i);
/*long long tv;
while (cin>>tv)
{
}*/
}
| [
"truongnguyen@MacBook-Pro-cua-TruongNP.local"
] | truongnguyen@MacBook-Pro-cua-TruongNP.local |
bd652d943de923267d64511a226d54a297d5ff65 | 85a5c11d85dbfffefede19f651fa167ca7155f68 | /TST.h | 00814e035492f9e2c64b78f72825d027e30d43e4 | [] | no_license | skiteskopes/cs130a_project1 | 7747b45ae4470b0f08b9e940c8313e49924c8001 | a398cf78b85c585005c2c87f08be656f6dddb84b | refs/heads/master | 2022-12-26T23:44:56.380772 | 2020-10-11T08:01:39 | 2020-10-11T08:01:39 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 131 | h | #ifndef TST_H
#define TST_H
class TST{
public:
TST();
~TST();
private:
TST_node * head;
};
#endif
| [
"bill_zhang@csilvm-01.cs.ucsb.edu"
] | bill_zhang@csilvm-01.cs.ucsb.edu |
ccd9a910b3a6dadb8f2f9117fc82ef2a4e3d554e | 93b611a35328b9204a8edff4675cb11a8c529684 | /Export/macos/obj/src/openfl/media/SoundLoaderContext.cpp | f0f96c2ba67b35d9e16b19e236adb01b851dcca1 | [] | no_license | dmoa/firstHaxeGame | b5db96619cb8dc3d7ce38d6ba4adf29c4b6dca3c | fbed7991277168a57b22d220c5ccc15f01e467a0 | refs/heads/master | 2020-06-29T11:36:20.971915 | 2019-08-04T17:39:57 | 2019-08-04T17:39:57 | 200,523,232 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | true | 4,625 | cpp | // Generated by Haxe 3.4.4
#include <hxcpp.h>
#ifndef INCLUDED_openfl_media_SoundLoaderContext
#include <openfl/media/SoundLoaderContext.h>
#endif
HX_DEFINE_STACK_FRAME(_hx_pos_baeaab40d0a56ac0_148_new,"openfl.media.SoundLoaderContext","new",0xafd95147,"openfl.media.SoundLoaderContext.new","openfl/media/SoundLoaderContext.hx",148,0x79afda07)
namespace openfl{
namespace media{
void SoundLoaderContext_obj::__construct(hx::Null< Float > __o_bufferTime,hx::Null< bool > __o_checkPolicyFile){
Float bufferTime = __o_bufferTime.Default(1000);
bool checkPolicyFile = __o_checkPolicyFile.Default(false);
HX_STACKFRAME(&_hx_pos_baeaab40d0a56ac0_148_new)
HXLINE( 149) this->bufferTime = bufferTime;
HXLINE( 150) this->checkPolicyFile = checkPolicyFile;
}
Dynamic SoundLoaderContext_obj::__CreateEmpty() { return new SoundLoaderContext_obj; }
void *SoundLoaderContext_obj::_hx_vtable = 0;
Dynamic SoundLoaderContext_obj::__Create(hx::DynamicArray inArgs)
{
hx::ObjectPtr< SoundLoaderContext_obj > _hx_result = new SoundLoaderContext_obj();
_hx_result->__construct(inArgs[0],inArgs[1]);
return _hx_result;
}
bool SoundLoaderContext_obj::_hx_isInstanceOf(int inClassId) {
return inClassId==(int)0x00000001 || inClassId==(int)0x44beed41;
}
SoundLoaderContext_obj::SoundLoaderContext_obj()
{
}
hx::Val SoundLoaderContext_obj::__Field(const ::String &inName,hx::PropertyAccess inCallProp)
{
switch(inName.length) {
case 10:
if (HX_FIELD_EQ(inName,"bufferTime") ) { return hx::Val( bufferTime ); }
break;
case 15:
if (HX_FIELD_EQ(inName,"checkPolicyFile") ) { return hx::Val( checkPolicyFile ); }
}
return super::__Field(inName,inCallProp);
}
hx::Val SoundLoaderContext_obj::__SetField(const ::String &inName,const hx::Val &inValue,hx::PropertyAccess inCallProp)
{
switch(inName.length) {
case 10:
if (HX_FIELD_EQ(inName,"bufferTime") ) { bufferTime=inValue.Cast< Float >(); return inValue; }
break;
case 15:
if (HX_FIELD_EQ(inName,"checkPolicyFile") ) { checkPolicyFile=inValue.Cast< bool >(); return inValue; }
}
return super::__SetField(inName,inValue,inCallProp);
}
void SoundLoaderContext_obj::__GetFields(Array< ::String> &outFields)
{
outFields->push(HX_HCSTRING("bufferTime","\x2d","\x35","\x0d","\x9e"));
outFields->push(HX_HCSTRING("checkPolicyFile","\x76","\x1e","\x96","\xaf"));
super::__GetFields(outFields);
};
#if HXCPP_SCRIPTABLE
static hx::StorageInfo SoundLoaderContext_obj_sMemberStorageInfo[] = {
{hx::fsFloat,(int)offsetof(SoundLoaderContext_obj,bufferTime),HX_HCSTRING("bufferTime","\x2d","\x35","\x0d","\x9e")},
{hx::fsBool,(int)offsetof(SoundLoaderContext_obj,checkPolicyFile),HX_HCSTRING("checkPolicyFile","\x76","\x1e","\x96","\xaf")},
{ hx::fsUnknown, 0, null()}
};
static hx::StaticInfo *SoundLoaderContext_obj_sStaticStorageInfo = 0;
#endif
static ::String SoundLoaderContext_obj_sMemberFields[] = {
HX_HCSTRING("bufferTime","\x2d","\x35","\x0d","\x9e"),
HX_HCSTRING("checkPolicyFile","\x76","\x1e","\x96","\xaf"),
::String(null()) };
static void SoundLoaderContext_obj_sMarkStatics(HX_MARK_PARAMS) {
HX_MARK_MEMBER_NAME(SoundLoaderContext_obj::__mClass,"__mClass");
};
#ifdef HXCPP_VISIT_ALLOCS
static void SoundLoaderContext_obj_sVisitStatics(HX_VISIT_PARAMS) {
HX_VISIT_MEMBER_NAME(SoundLoaderContext_obj::__mClass,"__mClass");
};
#endif
hx::Class SoundLoaderContext_obj::__mClass;
void SoundLoaderContext_obj::__register()
{
hx::Object *dummy = new SoundLoaderContext_obj;
SoundLoaderContext_obj::_hx_vtable = *(void **)dummy;
hx::Static(__mClass) = new hx::Class_obj();
__mClass->mName = HX_HCSTRING("openfl.media.SoundLoaderContext","\xd5","\xa1","\xdf","\x8d");
__mClass->mSuper = &super::__SGetClass();
__mClass->mConstructEmpty = &__CreateEmpty;
__mClass->mConstructArgs = &__Create;
__mClass->mGetStaticField = &hx::Class_obj::GetNoStaticField;
__mClass->mSetStaticField = &hx::Class_obj::SetNoStaticField;
__mClass->mMarkFunc = SoundLoaderContext_obj_sMarkStatics;
__mClass->mStatics = hx::Class_obj::dupFunctions(0 /* sStaticFields */);
__mClass->mMembers = hx::Class_obj::dupFunctions(SoundLoaderContext_obj_sMemberFields);
__mClass->mCanCast = hx::TCanCast< SoundLoaderContext_obj >;
#ifdef HXCPP_VISIT_ALLOCS
__mClass->mVisitFunc = SoundLoaderContext_obj_sVisitStatics;
#endif
#ifdef HXCPP_SCRIPTABLE
__mClass->mMemberStorageInfo = SoundLoaderContext_obj_sMemberStorageInfo;
#endif
#ifdef HXCPP_SCRIPTABLE
__mClass->mStaticStorageInfo = SoundLoaderContext_obj_sStaticStorageInfo;
#endif
hx::_hx_RegisterClass(__mClass->mName, __mClass);
}
} // end namespace openfl
} // end namespace media
| [
"44374106+dmoa@users.noreply.github.com"
] | 44374106+dmoa@users.noreply.github.com |
d96d428db311b71702ed8a6f980a47cb80058841 | 20b8ca079df2d5c97231624a8659b30d1a00c6db | /test/frame/test_macros.h | 91464b1d97c837e97771c5bee7c00516cbd97c1a | [
"MIT"
] | permissive | tangzhenquan/atframe_utils | 6a9eddf3ff4ff65958627442d93178ca29d7c2a6 | 94a41a89cbc65a62102a8ac0f98b4b340b2bb8ef | refs/heads/master | 2020-12-03T16:04:51.184493 | 2020-03-12T13:23:19 | 2020-03-12T13:23:19 | 231,382,899 | 0 | 0 | MIT | 2020-01-02T13:00:08 | 2020-01-02T13:00:07 | null | UTF-8 | C++ | false | false | 5,397 | h | /*
* test_macros.h
*
* Created on: 2014年3月11日
* Author: owent
*
* Released under the MIT license
*/
#ifndef TEST_MACROS_H_
#define TEST_MACROS_H_
#pragma once
#include <iostream>
#include <sstream>
#include <cstdio>
#ifdef _MSC_VER
#include <Windows.h>
#endif
#ifdef UTILS_TEST_MACRO_TEST_ENABLE_GTEST
#include "gtest/gtest.h"
#define CASE_TEST(test_name, case_name) TEST(test_name, case_name)
#define CASE_EXPECT_TRUE(c) EXPECT_TRUE(c)
#define CASE_EXPECT_FALSE(c) EXPECT_FALSE(c)
#define CASE_EXPECT_EQ(l, r) EXPECT_EQ(l, r)
#define CASE_EXPECT_NE(l, r) EXPECT_NE(l, r)
#define CASE_EXPECT_LT(l, r) EXPECT_LT(l, r)
#define CASE_EXPECT_LE(l, r) EXPECT_LE(l, r)
#define CASE_EXPECT_GT(l, r) EXPECT_GT(l, r)
#define CASE_EXPECT_GE(l, r) EXPECT_GE(l, r)
#else
#include "test_manager.h"
#define test_case_func_name(test_name, case_name) test_func_test_##test_name##_case_##case_name
#define test_case_obj_name(test_name, case_name) test_obj_test_##test_name##_case_##case_name##_obj
#define CASE_TEST(test_name, case_name) \
static void test_case_func_name(test_name, case_name) (); \
static test_case_base test_case_obj_name(test_name, case_name) (#test_name, #case_name, test_case_func_name(test_name, case_name)); \
void test_case_func_name(test_name, case_name) ()
#ifdef UTILS_TEST_MACRO_TEST_ENABLE_BOOST_TEST
#define CASE_EXPECT_TRUE(c) BOOST_CHECK(c)
#define CASE_EXPECT_FALSE(c) BOOST_CHECK(!(c))
#define CASE_EXPECT_EQ(l, r) BOOST_CHECK_EQUAL(l, r)
#define CASE_EXPECT_NE(l, r) BOOST_CHECK_NE(l, r)
#define CASE_EXPECT_LT(l, r) BOOST_CHECK_LT(l, r)
#define CASE_EXPECT_LE(l, r) BOOST_CHECK_LE(l, r)
#define CASE_EXPECT_GT(l, r) BOOST_CHECK_GT(l, r)
#define CASE_EXPECT_GE(l, r) BOOST_CHECK_GE(l, r)
#else
#define CASE_EXPECT_TRUE(c) test_manager::me().expect_true((c), #c, __FILE__, __LINE__)
#define CASE_EXPECT_FALSE(c) test_manager::me().expect_false((c), #c, __FILE__, __LINE__)
#define CASE_EXPECT_EQ(l, r) test_manager::me().expect_eq((l), (r), #l, #r, __FILE__, __LINE__)
#define CASE_EXPECT_NE(l, r) test_manager::me().expect_ne((l), (r), #l, #r, __FILE__, __LINE__)
#define CASE_EXPECT_LT(l, r) test_manager::me().expect_lt((l), (r), #l, #r, __FILE__, __LINE__)
#define CASE_EXPECT_LE(l, r) test_manager::me().expect_le((l), (r), #l, #r, __FILE__, __LINE__)
#define CASE_EXPECT_GT(l, r) test_manager::me().expect_gt((l), (r), #l, #r, __FILE__, __LINE__)
#define CASE_EXPECT_GE(l, r) test_manager::me().expect_ge((l), (r), #l, #r, __FILE__, __LINE__)
#endif
#endif
// 前景色: BLACK,RED,GREEN,YELLOW,BLUE,MAGENTA,CYAN,WHITE
#define CASE_MSG_FCOLOR(x) util::cli::shell_font_style::SHELL_FONT_COLOR_##x
// 背景色: BLACK,RED,GREEN,YELLOW,BLUE,MAGENTA,CYAN,WHITE
#define CASE_MSG_BCOLOR(x) util::cli::shell_font_style::SHELL_FONT_BACKGROUND_COLOR_##x
// 字体格式: BOLD,UNDERLINE,FLASH,DARK
#define CASE_MSG_STYLE(x) util::cli::shell_font_style::SHELL_FONT_SPEC_##x
#define CASE_MSG_INFO() util::cli::shell_stream(std::cout)()<< "[ RUNNING ] "
#define CASE_MSG_ERROR() util::cli::shell_stream(std::cerr)()<< "[ RUNNING ] "
// 测试中休眠
#if (defined(__cplusplus) && __cplusplus >= 201103L) || (defined(_MSC_VER) && _MSC_VER >= 1800)
#include <thread>
#define CASE_THREAD_SLEEP_MS(x) std::this_thread::sleep_for(std::chrono::milliseconds(x))
#define CASE_THREAD_YIELD() std::this_thread::yield()
#elif defined(_MSC_VER)
#include <Windows.h>
#define CASE_THREAD_SLEEP_MS(x) Sleep(x)
#define CASE_THREAD_YIELD() YieldProcessor()
#else
#include <unistd.h>
#define CASE_THREAD_SLEEP_MS(x) ((x > 1000)? sleep(x / 1000): usleep(0)); usleep((x % 1000) * 1000)
#if defined(__linux__) || defined(__unix__)
#include <sched.h>
#define CASE_THREAD_YIELD() sched_yield()
#elif defined(__GNUC__) || defined(__clang__)
#if defined(__i386__) || defined(__x86_64__)
/**
* See: Intel(R) 64 and IA-32 Architectures Software Developer's Manual V2
* PAUSE-Spin Loop Hint, 4-57
* http://www.intel.com/content/www/us/en/architecture-and-technology/64-ia-32-architectures-software-developer-instruction-set-reference-manual-325383.html?wapkw=instruction+set+reference
*/
#define CASE_THREAD_YIELD() __asm__ __volatile__("pause")
#elif defined(__ia64__) || defined(__ia64)
/**
* See: Intel(R) Itanium(R) Architecture Developer's Manual, Vol.3
* hint - Performance Hint, 3:145
* http://www.intel.com/content/www/us/en/processors/itanium/itanium-architecture-vol-3-manual.html
*/
#define CASE_THREAD_YIELD() __asm__ __volatile__ ("hint @pause")
#elif defined(__arm__) && !defined(__ANDROID__)
/**
* See: ARM Architecture Reference Manuals (YIELD)
* http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.subset.architecture.reference/index.html
*/
#define CASE_THREAD_YIELD() __asm__ __volatile__ ("yield")
#else
#define CASE_THREAD_YIELD()
#endif
#else
#define CASE_THREAD_YIELD()
#endif
#endif
#endif /* TEST_MACROS_H_ */
| [
"owt5008137@live.com"
] | owt5008137@live.com |
a351faf1177cbfc909b25acb8ee868953e705799 | ee1423adcd4bfeb2703464996171d103542bad09 | /dali-adaptor/adaptors/tizen/internal/common/ecore-x/ecore-x-render-surface-factory.cpp | ed0e17f84d015aaa922c05029838562d33c9003b | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-warranty-disclaimer",
"LicenseRef-scancode-flora-1.1"
] | permissive | sak0909/Dali | 26ac61a521ab1de26a7156c51afd3cc839cb705a | 0b383fc316b8b57afcf9a9e8bac6e24a4ba36e49 | refs/heads/master | 2020-12-30T12:10:51.930311 | 2017-05-16T21:56:24 | 2017-05-16T21:57:14 | 91,505,804 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 1,670 | cpp | //
// Copyright (c) 2014 Samsung Electronics Co., Ltd.
//
// Licensed under the Flora License, Version 1.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://floralicense.org/license/
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an AS IS BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
#include "ecore-x-render-surface.h"
#include "pixmap-render-surface.h"
#include "native-buffer-render-surface.h"
namespace Dali
{
namespace Internal
{
namespace Adaptor
{
namespace ECoreX
{
DALI_EXPORT_API RenderSurface* CreatePixmapSurface(
PositionSize positionSize,
Any surface,
Any display,
const std::string& name,
bool isTransparent )
{
return new PixmapRenderSurface( positionSize, surface, display, name, isTransparent );
}
DALI_EXPORT_API RenderSurface* CreateNativeBufferSurface(
native_buffer_provider* provider,
native_buffer_pool* pool,
unsigned int maxBufferCount,
PositionSize positionSize,
Any surface,
Any display,
const std::string& name,
bool isTransparent )
{
return new NativeBufferRenderSurface( provider, pool, maxBufferCount, positionSize,
surface, display, name, isTransparent);
}
}// ECoreX
}// Adaptor
}// Internal
}// Dali
| [
"sak0909@outlook.com"
] | sak0909@outlook.com |
196e3933397fd732151b04b7175599de73396401 | 8d7fb608f0768825b6f74e9b2b3f2fd67a58ad88 | /baekjoon/17143.cpp | cc8d4570c1551bf62dce9e6bf7a263da964f0007 | [] | no_license | changjunpyo/algorithmPS | 12b0dd13ab9c2512bcf66d3cab0f29c5c10532ce | 6f44b582d2f17a9803cd0b2dbccfe97a55da6213 | refs/heads/master | 2021-06-30T20:28:01.263743 | 2021-05-20T14:50:08 | 2021-05-20T14:50:08 | 239,674,217 | 2 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 2,551 | cpp | #include <cstdio>
#include <vector>
using namespace std;
const int dr[4] = {-1,1,0,0};
const int dc[4] = {0,0,1,-1};
int map[101][101];
class Shark{
public:
Shark(int _r, int _c, int _d, int _s, int _z){
r=_r;
c=_c;
d=_d;
s=_s;
z=_z;
die = false;
}
int r;
int c;
int d;
int s;
int z;
bool die;
void move(int R, int C){
int moving_r = s %(2*R-2);
int moving_c = s %(2*C-2);
if (d == 1){
if (moving_r <= R-r){
r += moving_r;
}
else if (moving_r <= R-r+ R-1){
r += R-r -((moving_r - (R-r)));
d= 0;
}
else
r = moving_r-(2*R-r-1) +1;
}
else if (d == 2){
if (moving_c <= C-c){
c += moving_c;
}
else if (moving_c <= 2*C-c-1){
c += C-c-(moving_c -(C-c));
d =3;
}
else
c = moving_c - (2*C-c-1) +1 ;
}
else if (d == 3){
if ( c > moving_c )
c -= moving_c;
else if (moving_c <= C+c-2){
c -= c -(moving_c -(c-1) +1);
d = 2;
}
else
c = (2*C-2)-moving_c + c ;
}
else {
if ( r > moving_r )
r -= moving_r;
else if (moving_r <= R+r-2){
r -= r -(moving_r -(r-1)+1);
d = 1;
}
else
r = (2*R-2)-moving_r +r ;
}
// 방향만 잡자
}
};
int main(){
int R,C,M;
scanf("%d %d %d",&R,&C,&M);
vector<Shark> v;
v.reserve(M);
int fishman_c = 0;
int ans=0;
memset(map, -1, sizeof(map));
for (int i=0; i<M; i++){
int r,c,s,d,z;
scanf("%d %d %d %d %d",&r,&c,&s,&d,&z);
Shark shark(r,c,d-1,s,z);
map[r][c] = i;
v[i] = shark;
}
while(fishman_c <=C){
// 낚시왕 움직 step1
fishman_c++;
// 낚시함
int catch_r=-1;
// find shark
for (int i=1; i<=R; i++){
if (map[i][fishman_c] >=0){
catch_r=i;
map[i][fishman_c]=-1;
break;
}
}
// catch shark
if (catch_r != -1){
for (int i=0; i<M; i++){
if (v[i].die)
continue;
if (v[i].r == catch_r && v[i].c == fishman_c){
ans+= v[i].z;
v[i].die = true;
}
}
}
// 상어 움직임
int moved_map[101][101]={0,};
memset(moved_map, -1, sizeof(moved_map));
for (int i=0; i<M; i++){
if (v[i].die)
continue;
v[i].move(R,C);
if (moved_map[v[i].r][v[i].c] >= 0){
int other = moved_map[v[i].r][v[i].c];
if (v[i].z > v[other].z){
moved_map[v[i].r][v[i].c] = i;
v[other].die = true;
}
else
v[i].die=true;
}
else
moved_map[v[i].r][v[i].c] = i;
}
for (int i=1; i<=R; i++){
for (int j=1; j<=C; j++)
map[i][j] = moved_map[i][j];
}
}
printf("%d\n",ans);
} | [
"junpyojang@junpyos-MacBook-Pro.local"
] | junpyojang@junpyos-MacBook-Pro.local |
6456491da997d4bda865d6a3d597e2414e0be504 | 9d9e8fc7bbac19aaaebf66a625518f071b0ce7f8 | /ITP2/ITP2_1_D.cpp | dac5540188b296278f3d1a01f9b6e561cc788964 | [] | no_license | jiji4000/Aizu_online_judge | 3963dbd8e9c09e557f0baaeb0216ec9b7451ed78 | a0223ae5ad19b9d78929442e6f859da3ed1bffda | refs/heads/master | 2021-05-01T03:22:33.385922 | 2020-06-10T07:50:32 | 2020-06-10T07:50:32 | 121,191,869 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,012 | cpp | //
// ITP2_1_D.cpp
// AizuOnlineJudge
//
// Created by jiji on 2019/11/08.
// Copyright © 2019 jiji4000. All rights reserved.
//
#include <iostream>
#include <vector>
using namespace std;
#define MAX 10000
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
int n,q,command,t,x;
vector<int> vec[MAX];
cin >> n >> q;
for (int i = 0;i < q;++i) {
cin >> command >> t;
switch(command){
// push back
case 0:
cin >> x;
vec[t].push_back(x);
break;
// dump
case 1:
for(int i = 0;i < vec[t].size();++i){
cout << vec[t].at(i);
if(i + 1 < vec[t].size()){
cout << " ";
}
}
cout << endl;
break;
// clear
case 2:
vec[t].clear();
break;
}
}
}
| [
"jiji4000alpha@gmail.com"
] | jiji4000alpha@gmail.com |
09b2fde0d4aa806ddc225e78e838863d6d60f73e | 675dde2b1ece857cc5bc0e3cca9f1346bdc6c7ea | /iotexplorer/src/v20190423/model/DeleteProjectRequest.cpp | 4289f0d5e434b529d91449172691d343e69856b2 | [
"Apache-2.0"
] | permissive | jackrambor/tencentcloud-sdk-cpp | 7ec86b31df6a9d37c3966b136a14691c2088bf55 | 71ce9e62893f8d3110c20e051897f55137ea4699 | refs/heads/master | 2020-06-25T18:44:19.397792 | 2019-07-29T03:34:29 | 2019-07-29T03:34:29 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,883 | cpp | /*
* Copyright (c) 2017-2019 THL A29 Limited, a Tencent company. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <tencentcloud/iotexplorer/v20190423/model/DeleteProjectRequest.h>
#include <tencentcloud/core/utils/rapidjson/document.h>
#include <tencentcloud/core/utils/rapidjson/writer.h>
#include <tencentcloud/core/utils/rapidjson/stringbuffer.h>
using namespace TencentCloud::Iotexplorer::V20190423::Model;
using namespace rapidjson;
using namespace std;
DeleteProjectRequest::DeleteProjectRequest() :
m_projectIdHasBeenSet(false)
{
}
string DeleteProjectRequest::ToJsonString() const
{
Document d;
d.SetObject();
Document::AllocatorType& allocator = d.GetAllocator();
if (m_projectIdHasBeenSet)
{
Value iKey(kStringType);
string key = "ProjectId";
iKey.SetString(key.c_str(), allocator);
d.AddMember(iKey, m_projectId, allocator);
}
StringBuffer buffer;
Writer<StringBuffer> writer(buffer);
d.Accept(writer);
return buffer.GetString();
}
int64_t DeleteProjectRequest::GetProjectId() const
{
return m_projectId;
}
void DeleteProjectRequest::SetProjectId(const int64_t& _projectId)
{
m_projectId = _projectId;
m_projectIdHasBeenSet = true;
}
bool DeleteProjectRequest::ProjectIdHasBeenSet() const
{
return m_projectIdHasBeenSet;
}
| [
"jimmyzhuang@tencent.com"
] | jimmyzhuang@tencent.com |
b0bfa1bc8afc5fcef2c7163a718c179d39897060 | 0cf886b9cc9b6af538cfbb08e0dc495ea342762c | /game/src/XDButton.cpp | 8ad4c59260bde326eb95d64fd5d992e840fe3866 | [] | no_license | xedixermawan/proximity-game-clone2-dx | 3bfd584e552188b773148276e5386f1cd9597ecb | a4149241e381b4fc4b22e183634da4575cacaba9 | refs/heads/master | 2021-01-18T18:35:01.321364 | 2014-05-13T07:17:40 | 2014-05-13T07:17:40 | 32,908,322 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,669 | cpp | /*
* (c) 2013-2014 XediXermawan < edi.ermawan@gmail.com >
*/
#include "pch.h"
#include "XDButton.h"
#include "XDGameState.h"
extern XDSystem* debugSystemPtr;
#include "XDChecker.h"
#include "XDFuncUtils.h"
namespace gui {
Button::Button(const std::shared_ptr< XDSprite >& sharedptrSpr) :ElementBase(sharedptrSpr) {
m_Anim->SetAnimLoop(XDAnimObject::ANIMLOOP::ONCE);
m_Anim->ShowAfterFinish(true);
m_FrameHover = 1;
m_HoverState = 0;
m_ClickedState= 0;
}
Button::Button() : ElementBase(nullptr) {
m_HoverState = 0;
m_ClickedState= 0;
}
Button::~Button() {
}
bool Button::IsIntersect(const int& posx, const int& posy) {
if( ( posx > m_PosX ) && ( posx < (m_PosX + m_Width) ) &&
( posy > m_PosY ) && ( posy < (m_PosY + m_Height)) ) {
XDChecker::Console(" inside ");
return true;
}
return false;
}
void Button::OnClicked(const int& posx, const int& posy) {
if( IsIntersect(posx,posy) ) {
if( m_CallBackFunction )
m_CallBackFunction(this);
m_ClickedState=1;
}
}
void Button::OnClickReleased(const int& posx, const int& posy) {
if( IsIntersect(posx,posy) ) {
m_ClickedState=1;
}
}
void Button::OnHover(const int& posx, const int& posy) {
if( IsIntersect(posx,posy) ) {
m_Anim->SetFinishFrame(m_FrameHover);
m_HoverState=1;
} else {
m_Anim->SetFinishFrame(0);
m_HoverState=0;
}
}
void Button::Render() {
//m_Anim->Render();
if( m_HoverState ) {
debugSystemPtr->Renderer->DrawRect( XMFLOAT2(m_PosX-4,m_PosY-4),XMFLOAT2(m_Width+8,m_Height+8) );
} else {
debugSystemPtr->Renderer->DrawRect( XMFLOAT2(m_PosX,m_PosY),XMFLOAT2(m_Width,m_Height) );
}
if(m_ClickedState>0 && m_ClickedState < 20) {
int r_v = RandomRange(2,20);
debugSystemPtr->Renderer->DrawRect( XMFLOAT2(m_PosX-r_v,m_PosY-r_v),XMFLOAT2(m_Width+2*r_v,m_Height+2*r_v) );
m_ClickedState++;
}
}
void Button::Update(const double delta_time) {
//m_Anim->Update(delta_time);
}
int Button::GetUID() {
return 0; // todo
}
void Button::SetPos(int vposx,int vposy) {
m_PosX = vposx;
m_PosY = vposy;
m_Anim->SetPos(vposx,vposy);
}
void Button::GetWidthHeight(int& gwidth, int& gheight ) {
gwidth = m_Width;
gheight = m_Height;
}
void Button::SetWidthHeight(int gwidth, int gheight ) {
m_Width = gwidth;
m_Height = gheight;
}
void Button::SetCallBack(std::function< void(void* sender) >& function) {
m_CallBackFunction = function;
}
} | [
"edi.ermawan@gmail.com@46f14409-37b9-1770-7b49-ba1cd2439d2f"
] | edi.ermawan@gmail.com@46f14409-37b9-1770-7b49-ba1cd2439d2f |
ff5d9bf13e68fafd325c4374011a6cfdd8f3c3d5 | a1ce1c416e8cd75b51fc0a05e8483dfbc8eab79e | /Engine/source/gui/game/guiProgressCtrl.cpp | df7801bd130d6949d909f621aa6f1077a2e54404 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | wwhitehead/OmniEngine.Net | 238da56998ac5473c3d3b9f0da705c7c08c0ee17 | b52de3ca5e15a18a6320ced6cbabc41d6fa6be86 | refs/heads/master | 2020-12-26T04:16:46.475080 | 2015-06-18T00:16:45 | 2015-06-18T00:16:45 | 34,730,441 | 0 | 0 | null | 2015-04-28T12:57:08 | 2015-04-28T12:57:08 | null | UTF-8 | C++ | false | false | 5,620 | cpp | //-----------------------------------------------------------------------------
// Copyright (c) 2012 GarageGames, LLC
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to
// deal in the Software without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
// IN THE SOFTWARE.
//-----------------------------------------------------------------------------
#include "platform/platform.h"
#include "gui/game/guiProgressCtrl.h"
#include "console/console.h"
#include "console/consoleTypes.h"
#include "gfx/gfxDrawUtil.h"
#include "console/engineAPI.h"
IMPLEMENT_CONOBJECT(GuiProgressCtrl);
ConsoleDocClass( GuiProgressCtrl,
"@brief GUI Control which displays a horizontal bar which increases as the progress value of 0.0 - 1.0 increases.\n\n"
"@tsexample\n"
" new GuiProgressCtrl(JS_statusBar)\n"
" {\n"
" //Properties not specific to this control have been omitted from this example.\n"
" };\n\n"
"// Define the value to set the progress bar"
"%value = \"0.5f\"\n\n"
"// Set the value of the progress bar, from 0.0 - 1.0\n"
"%thisGuiProgressCtrl.setValue(%value);\n"
"// Get the value of the progress bar.\n"
"%progress = %thisGuiProgressCtrl.getValue();\n"
"@endtsexample\n\n"
"@see GuiTextCtrl\n"
"@see GuiControl\n\n"
"@ingroup GuiValues\n"
);
GuiProgressCtrl::GuiProgressCtrl()
{
mProgress = 0.0f;
mHorizontalFill = true;
mInvertFill = true;
}
const char* GuiProgressCtrl::getScriptValue()
{
static const U32 bufSize = 64;
char * ret = Con::getReturnBuffer(bufSize);
dSprintf(ret, bufSize, "%g", mProgress);
return ret;
}
void GuiProgressCtrl::setScriptValue(const char *value)
{
//set the value
if (! value)
mProgress = 0.0f;
else
mProgress = dAtof(value);
//validate the value
mProgress = mClampF(mProgress, 0.f, 1.f);
setUpdate();
}
void GuiProgressCtrl::onPreRender()
{
const char * var = getVariable();
if(var)
{
F32 value = mClampF(dAtof(var), 0.f, 1.f);
if(value != mProgress)
{
mProgress = value;
setUpdate();
}
}
}
// updated OnRender function
void GuiProgressCtrl::onRender(Point2I offset, const RectI &updateRect)
{
RectI ctrlRect(offset, getExtent());
//draw the progress
// check the boolean if we want it horizontal or not (set by the user, defaults to true)
if (mHorizontalFill)
{
// the default horizontal code
// horizontal
S32 width = (S32)((F32)(getWidth()) * mProgress);
if (width > 0)
{
if (mInvertFill) // default left to right if true
{
RectI progressRect = ctrlRect;
progressRect.extent.x = width;
GFX->getDrawUtil()->drawRectFill(progressRect, mProfile->mFillColor);
}
else // to fill right to left
{
RectI progressRect( ( ctrlRect.point.x + ctrlRect.extent.x ), ctrlRect.point.y, -ctrlRect.extent.x, ctrlRect.extent.y);
progressRect.extent.x = -width;
GFX->getDrawUtil()->drawRectFill(progressRect, mProfile->mFillColor);
}
}
}
else
{
// new code to check if we want it vertical
// vertical
S32 height = (S32)((F32)getHeight() * mProgress);
if (height > 0)
{
if (mInvertFill) // default down to up if true
{
RectI progressRect(ctrlRect.point.x, ( ctrlRect.point.y + ctrlRect.extent.y ), ctrlRect.extent.x, -ctrlRect.extent.y);
progressRect.extent.y = -height;
GFX->getDrawUtil()->drawRectFill(progressRect, mProfile->mFillColor);
}
else // to fill down to up
{
RectI progressRect = ctrlRect;
progressRect.extent.y = height;
GFX->getDrawUtil()->drawRectFill(progressRect, mProfile->mFillColor);
}
}
}
//now draw the border
if (mProfile->mBorder)
GFX->getDrawUtil()->drawRect(ctrlRect, mProfile->mBorderColor);
Parent::onRender( offset, updateRect );
//render the children
renderChildControls(offset, updateRect);
}
// add the fields to GuiProgressCtrl
void GuiProgressCtrl::initPersistFields()
{
// add the horizontal field
addField("horizontalFill", TypeBool, Offset(mHorizontalFill, GuiProgressCtrl),
"True if you want the GuiProgressCtrl to be horizontal. Defaults to true. " );
addField("invertFill", TypeBool, Offset(mInvertFill, GuiProgressCtrl),
"True if you want the GuiProgressCtrl to fill Left to Right (when horizontalFill = true)"
"or Down to Up (when horizontalFill = false). Defaults to true. " );
Parent::initPersistFields();
}
| [
"vgee@winterleafentertainment.com"
] | vgee@winterleafentertainment.com |
55ab23daf86a0ac018937eaec15243f84a745e82 | fb82c37173782c58866be5f1bb2ea83ea7b2cba9 | /src/ntk/v3NtkInput.cpp | 42f7f33aa361606c3c81635ed397c7340c018c5b | [] | no_license | ckmarkoh/101_2_SOCV_pa3 | 7d6a446bbdd54e2a256965a16530132191117255 | 68558259ea9dc10b5e56f61adb942486f92fa1ed | refs/heads/master | 2016-09-02T03:27:59.541944 | 2013-05-27T13:18:03 | 2013-05-27T13:18:03 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,033 | cpp | /****************************************************************************
FileName [ v3NtkInput.cpp ]
PackageName [ v3/src/ntk ]
Synopsis [ Base Input Handler for V3 Ntk. ]
Author [ Cheng-Yin Wu ]
Copyright [ Copyright(c) 2012 LaDs(III), GIEE, NTU, Taiwan ]
****************************************************************************/
#ifndef V3_NTK_INPUT_C
#define V3_NTK_INPUT_C
#include "v3Msg.h"
#include "v3NtkUtil.h"
#include "v3NtkInput.h"
/* -------------------------------------------------- *\
* Class V3Parser Implementations
\* -------------------------------------------------- */
// Constructor and Destructor
V3NtkInput::V3NtkInput(const bool& isAig, const string& name) : V3NtkHandler(0, createV3Ntk(!isAig)), _ntkName(name) {
assert (_ntk); _nameHash.clear(); _netHash.clear(); _outName.clear();
_nameHash.insert(make_pair("0", V3NetId::makeNetId(0))); _netHash.insert(make_pair(0, "0"));
}
V3NtkInput::~V3NtkInput() {
_nameHash.clear(); _netHash.clear();
}
// I/O Ancestry Functions
const string
V3NtkInput::getInputName(const uint32_t& index) const {
assert (_ntk); if (index >= _ntk->getInputSize()) return "";
return reinterpret_cast<const V3NtkHandler* const>(this)->getNetName(_ntk->getInput(index));
}
const string
V3NtkInput::getOutputName(const uint32_t& index) const {
assert (_ntk); if (index >= _ntk->getOutputSize()) return "";
return (index < _outName.size()) ? _outName[index] : "";
}
const string
V3NtkInput::getInoutName(const uint32_t& index) const {
assert (_ntk); if (index >= _ntk->getInoutSize()) return "";
return reinterpret_cast<const V3NtkHandler* const>(this)->getNetName(_ntk->getInout(index));
}
// Net Ancestry Functions
void
V3NtkInput::getNetName(V3NetId& id, string& name) const {
if (V3NetUD == id || id.cp) { assert (!name.size()); return; }
V3NetStrHash::const_iterator it = _netHash.find(id.id);
name = (it == _netHash.end()) ? "" : it->second;
}
// Ntk Input Naming Functions
const bool
V3NtkInput::resetNetName(const uint32_t& index, const string& name) {
assert (index < _ntk->getNetSize()); assert (name.size());
if (existNet(name)) {
Msg(MSG_ERR) << "Net Name \"" << name << "\" Already Exists !!" << endl;
return false;
}
V3NetStrHash::const_iterator it = _netHash.find(index);
if ((_netHash.end() != it) && it->second.size()) {
_nameHash.erase(_nameHash.find(it->second)); assert (!existNet(it->second));
}
_nameHash.insert(make_pair(name, V3NetId::makeNetId(index))); assert (existNet(name));
_netHash[index] = name; return true;
}
void
V3NtkInput::recordOutName(const uint32_t& index, const string& name) {
assert (index < _ntk->getOutputSize()); assert (name.size());
for (uint32_t i = _outName.size(); i < _ntk->getOutputSize(); ++i) _outName.push_back("");
assert (index < _outName.size()); _outName[index] = name;
}
const V3NetId
V3NtkInput::createNet(const string& netName, uint32_t width) {
assert (width);
V3NetId id = (netName.size()) ? getNetId(netName) : V3NetUD;
if (id == V3NetUD) {
id = _ntk->createNet(width); assert (V3NetUD != id);
if (netName.size()) {
_nameHash.insert(make_pair(netName, id));
_netHash.insert(make_pair(id.id, netName));
}
return id;
}
else if (width == _ntk->getNetWidth(id)) return id;
Msg(MSG_ERR) << "Existing net \"" << netName << "\" has width = " << _ntk->getNetWidth(id) << " != " << width << endl;
return V3NetUD;
}
const V3NetId
V3NtkInput::getNetId(const string& netName) const {
V3StrNetHash::const_iterator it = _nameHash.find(netName);
return (it != _nameHash.end()) ? it->second : V3NetUD;
}
// Extended Helper Functions
void
V3NtkInput::renderFreeNetAsInput() {
V3NetId id = V3NetId::makeNetId(1); assert (!_ntk->getInputSize());
for (uint32_t i = 1; i < _ntk->getNetSize(); ++i, ++id.id) {
if (V3_PI != _ntk->getGateType(id)) continue;
assert (i == id.id); _ntk->createInput(id);
}
}
#endif
| [
"mark23456@hotmail.com"
] | mark23456@hotmail.com |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.