blob_id
stringlengths
40
40
directory_id
stringlengths
40
40
path
stringlengths
4
201
content_id
stringlengths
40
40
detected_licenses
listlengths
0
85
license_type
stringclasses
2 values
repo_name
stringlengths
7
100
snapshot_id
stringlengths
40
40
revision_id
stringlengths
40
40
branch_name
stringclasses
260 values
visit_date
timestamp[us]
revision_date
timestamp[us]
committer_date
timestamp[us]
github_id
int64
11.4k
681M
star_events_count
int64
0
209k
fork_events_count
int64
0
110k
gha_license_id
stringclasses
17 values
gha_event_created_at
timestamp[us]
gha_created_at
timestamp[us]
gha_language
stringclasses
80 values
src_encoding
stringclasses
28 values
language
stringclasses
1 value
is_vendor
bool
1 class
is_generated
bool
2 classes
length_bytes
int64
8
9.86M
extension
stringclasses
52 values
content
stringlengths
8
9.86M
authors
listlengths
1
1
author
stringlengths
0
119
bd032b97dd48ab7419baee84ffa109bbe3210c38
3a17a51a60e4e5905a783cf3c3f453963606ee50
/src/explore/include/KDTree.hpp
b8e212625150a3fa104f8ffb0f771d3e27c4c944
[]
no_license
Gxx-5/Visual_Explore
eb5151529e84ccf75832fd0f2e27db1a5d8f305f
632d99f7b074a4451644edb4b7efb14c0741b535
refs/heads/master
2023-04-24T00:19:45.763238
2021-05-20T09:02:22
2021-05-20T09:02:22
327,626,575
1
0
null
null
null
null
UTF-8
C++
false
false
3,055
hpp
#pragma once /* * file: KDTree.hpp * author: J. Frederico Carvalho * * This is an adaptation of the KD-tree implementation in rosetta code * https://rosettacode.org/wiki/K-d_tree * It is a reimplementation of the C code using C++. * It also includes a few more queries than the original * */ #include <algorithm> #include <functional> #include <memory> #include <vector> using point_t = std::vector< double >; using indexArr = std::vector< size_t >; using pointIndex = typename std::pair< std::vector< double >, size_t >; class KDNode { public: using KDNodePtr = std::shared_ptr< KDNode >; size_t index; point_t x; KDNodePtr left; KDNodePtr right; // initializer KDNode(); KDNode(const point_t &, const size_t &, const KDNodePtr &, const KDNodePtr &); KDNode(const pointIndex &, const KDNodePtr &, const KDNodePtr &); ~KDNode(); // getter double coord(const size_t &); // conversions explicit operator bool(); explicit operator point_t(); explicit operator size_t(); explicit operator pointIndex(); }; using KDNodePtr = std::shared_ptr< KDNode >; KDNodePtr NewKDNodePtr(); // square euclidean distance inline double dist2(const point_t &, const point_t &); inline double dist2(const KDNodePtr &, const KDNodePtr &); // euclidean distance inline double dist(const point_t &, const point_t &); inline double dist(const KDNodePtr &, const KDNodePtr &); // Need for sorting class comparer { public: size_t idx; explicit comparer(size_t idx_); inline bool compare_idx( const std::pair< std::vector< double >, size_t > &, // const std::pair< std::vector< double >, size_t > & // ); }; using pointIndexArr = typename std::vector< pointIndex >; inline void sort_on_idx(const pointIndexArr::iterator &, // const pointIndexArr::iterator &, // size_t idx); using pointVec = std::vector< point_t >; class KDTree { KDNodePtr root; KDNodePtr leaf; KDNodePtr make_tree(const pointIndexArr::iterator &begin, // const pointIndexArr::iterator &end, // const size_t &length, // const size_t &level // ); public: KDTree() = default; explicit KDTree(pointVec point_array); private: KDNodePtr nearest_( // const KDNodePtr &branch, // const point_t &pt, // const size_t &level, // const KDNodePtr &best, // const double &best_dist // ); // default caller KDNodePtr nearest_(const point_t &pt); public: point_t nearest_point(const point_t &pt); size_t nearest_index(const point_t &pt); pointIndex nearest_pointIndex(const point_t &pt); private: pointIndexArr neighborhood_( // const KDNodePtr &branch, // const point_t &pt, // const double &rad, // const size_t &level // ); public: pointIndexArr neighborhood( // const point_t &pt, // const double &rad); pointVec neighborhood_points( // const point_t &pt, // const double &rad); indexArr neighborhood_indices( // const point_t &pt, // const double &rad); };
[ "943658034@qq.com" ]
943658034@qq.com
dd51f72c4888f67ea1fb313467df460a153e5638
8e690c04fe10fb043c54f8174671897f752588bf
/c++/src/Exception.cpp
89438742eef84d096b027c9bd43ef0a8fbc5469e
[]
no_license
SHTYKOVYCH/gnome-wallpaper-changer
fab0028f1b9e2faa7fcb60c7da46c463a9419443
1d169bcca6327a4b928a4a1c5357156940320352
refs/heads/master
2023-08-25T13:09:38.913498
2021-10-26T16:07:21
2021-10-26T16:07:21
399,171,829
0
0
null
2021-09-25T09:05:36
2021-08-23T16:20:13
C++
UTF-8
C++
false
false
179
cpp
#include <string> #include "Exception.hpp" using namespace std; Exception::Exception( string msg ) { this->msg = msg; } string Exception::getMessage() { return this->msg; }
[ "ya.Dimonus.net@yandex.ru" ]
ya.Dimonus.net@yandex.ru
8982c5de0598b55f684940a816a57ba77ebed845
0b66e8133c28fd50e2ffddba741710bdc7756cb4
/10.DynamicProgramming/115. Distinct Subsequences.cc
24d7c12781985f624f7cffc287439be30295b438
[]
no_license
tonyxwz/leetcode
21abed951622ed3606fc89c580cd32cda7b84a2f
1b7d06e638c0ff278c62d3bae27076b0881b5fde
refs/heads/master
2023-04-05T07:10:18.342010
2021-04-13T11:45:58
2021-04-13T11:45:58
71,467,875
0
0
null
null
null
null
UTF-8
C++
false
false
424
cc
#include "leetcode.h" class Solution { public: int numDistinct(string s, string t) { const int m = s.length(), n = t.length(); vector<vector<long>> dp(n + 1, vector<long>(m + 1, 0)); fill(begin(dp[0]), end(dp[0]), 1); for (int i = 1; i <= n; ++i) // t for (int j = 1; j <= m; ++j) // s dp[i][j] = dp[i][j - 1] + (t[i - 1] == s[j - 1] ? dp[i - 1][j - 1] : 0); return dp[n][m]; } };
[ "tonyxwz@yahoo.com" ]
tonyxwz@yahoo.com
4fb06bccfde4fea44d4b70911225fa083ffbc391
5b1a8110e8caa78125b3c31b1b42e979f8626193
/devel/include/kinova_msgs/ArmPoseFeedback.h
0ab1396960e9064215e59bccc210072a822f96b6
[]
no_license
RRameshwar/HandsTeleop
9cbfdf65f840961420d33743aa692c3406739639
3f15f85c6c6cfbaa1e3b5f7e3f86f6108a6673df
refs/heads/master
2020-03-18T22:23:44.657190
2018-05-29T20:22:42
2018-05-29T20:22:42
135,342,774
0
0
null
null
null
null
UTF-8
C++
false
false
7,134
h
// Generated by gencpp from file kinova_msgs/ArmPoseFeedback.msg // DO NOT EDIT! #ifndef KINOVA_MSGS_MESSAGE_ARMPOSEFEEDBACK_H #define KINOVA_MSGS_MESSAGE_ARMPOSEFEEDBACK_H #include <string> #include <vector> #include <map> #include <ros/types.h> #include <ros/serialization.h> #include <ros/builtin_message_traits.h> #include <ros/message_operations.h> #include <geometry_msgs/PoseStamped.h> namespace kinova_msgs { template <class ContainerAllocator> struct ArmPoseFeedback_ { typedef ArmPoseFeedback_<ContainerAllocator> Type; ArmPoseFeedback_() : pose() { } ArmPoseFeedback_(const ContainerAllocator& _alloc) : pose(_alloc) { (void)_alloc; } typedef ::geometry_msgs::PoseStamped_<ContainerAllocator> _pose_type; _pose_type pose; typedef boost::shared_ptr< ::kinova_msgs::ArmPoseFeedback_<ContainerAllocator> > Ptr; typedef boost::shared_ptr< ::kinova_msgs::ArmPoseFeedback_<ContainerAllocator> const> ConstPtr; }; // struct ArmPoseFeedback_ typedef ::kinova_msgs::ArmPoseFeedback_<std::allocator<void> > ArmPoseFeedback; typedef boost::shared_ptr< ::kinova_msgs::ArmPoseFeedback > ArmPoseFeedbackPtr; typedef boost::shared_ptr< ::kinova_msgs::ArmPoseFeedback const> ArmPoseFeedbackConstPtr; // constants requiring out of line definition template<typename ContainerAllocator> std::ostream& operator<<(std::ostream& s, const ::kinova_msgs::ArmPoseFeedback_<ContainerAllocator> & v) { ros::message_operations::Printer< ::kinova_msgs::ArmPoseFeedback_<ContainerAllocator> >::stream(s, "", v); return s; } } // namespace kinova_msgs namespace ros { namespace message_traits { // BOOLTRAITS {'IsFixedSize': False, 'IsMessage': True, 'HasHeader': False} // {'std_msgs': ['/opt/ros/indigo/share/std_msgs/cmake/../msg'], 'geometry_msgs': ['/opt/ros/indigo/share/geometry_msgs/cmake/../msg'], 'actionlib_msgs': ['/opt/ros/indigo/share/actionlib_msgs/cmake/../msg'], 'kinova_msgs': ['/home/srl-jacoarm/Desktop/SRL-JacoArm/src/kinova-ros/kinova_msgs/msg', '/home/srl-jacoarm/Desktop/SRL-JacoArm/devel/share/kinova_msgs/msg']} // !!!!!!!!!!! ['__class__', '__delattr__', '__dict__', '__doc__', '__eq__', '__format__', '__getattribute__', '__hash__', '__init__', '__module__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__', '_parsed_fields', 'constants', 'fields', 'full_name', 'has_header', 'header_present', 'names', 'package', 'parsed_fields', 'short_name', 'text', 'types'] template <class ContainerAllocator> struct IsFixedSize< ::kinova_msgs::ArmPoseFeedback_<ContainerAllocator> > : FalseType { }; template <class ContainerAllocator> struct IsFixedSize< ::kinova_msgs::ArmPoseFeedback_<ContainerAllocator> const> : FalseType { }; template <class ContainerAllocator> struct IsMessage< ::kinova_msgs::ArmPoseFeedback_<ContainerAllocator> > : TrueType { }; template <class ContainerAllocator> struct IsMessage< ::kinova_msgs::ArmPoseFeedback_<ContainerAllocator> const> : TrueType { }; template <class ContainerAllocator> struct HasHeader< ::kinova_msgs::ArmPoseFeedback_<ContainerAllocator> > : FalseType { }; template <class ContainerAllocator> struct HasHeader< ::kinova_msgs::ArmPoseFeedback_<ContainerAllocator> const> : FalseType { }; template<class ContainerAllocator> struct MD5Sum< ::kinova_msgs::ArmPoseFeedback_<ContainerAllocator> > { static const char* value() { return "3f8930d968a3e84d471dff917bb1cdae"; } static const char* value(const ::kinova_msgs::ArmPoseFeedback_<ContainerAllocator>&) { return value(); } static const uint64_t static_value1 = 0x3f8930d968a3e84dULL; static const uint64_t static_value2 = 0x471dff917bb1cdaeULL; }; template<class ContainerAllocator> struct DataType< ::kinova_msgs::ArmPoseFeedback_<ContainerAllocator> > { static const char* value() { return "kinova_msgs/ArmPoseFeedback"; } static const char* value(const ::kinova_msgs::ArmPoseFeedback_<ContainerAllocator>&) { return value(); } }; template<class ContainerAllocator> struct Definition< ::kinova_msgs::ArmPoseFeedback_<ContainerAllocator> > { static const char* value() { return "# ====== DO NOT MODIFY! AUTOGENERATED FROM AN ACTION DEFINITION ======\n\ # Feedback message\n\ geometry_msgs/PoseStamped pose\n\ \n\ \n\ ================================================================================\n\ MSG: geometry_msgs/PoseStamped\n\ # A Pose with reference coordinate frame and timestamp\n\ Header header\n\ Pose pose\n\ \n\ ================================================================================\n\ MSG: std_msgs/Header\n\ # Standard metadata for higher-level stamped data types.\n\ # This is generally used to communicate timestamped data \n\ # in a particular coordinate frame.\n\ # \n\ # sequence ID: consecutively increasing ID \n\ uint32 seq\n\ #Two-integer timestamp that is expressed as:\n\ # * stamp.sec: seconds (stamp_secs) since epoch (in Python the variable is called 'secs')\n\ # * stamp.nsec: nanoseconds since stamp_secs (in Python the variable is called 'nsecs')\n\ # time-handling sugar is provided by the client library\n\ time stamp\n\ #Frame this data is associated with\n\ # 0: no frame\n\ # 1: global frame\n\ string frame_id\n\ \n\ ================================================================================\n\ MSG: geometry_msgs/Pose\n\ # A representation of pose in free space, composed of postion and orientation. \n\ Point position\n\ Quaternion orientation\n\ \n\ ================================================================================\n\ MSG: geometry_msgs/Point\n\ # This contains the position of a point in free space\n\ float64 x\n\ float64 y\n\ float64 z\n\ \n\ ================================================================================\n\ MSG: geometry_msgs/Quaternion\n\ # This represents an orientation in free space in quaternion form.\n\ \n\ float64 x\n\ float64 y\n\ float64 z\n\ float64 w\n\ "; } static const char* value(const ::kinova_msgs::ArmPoseFeedback_<ContainerAllocator>&) { return value(); } }; } // namespace message_traits } // namespace ros namespace ros { namespace serialization { template<class ContainerAllocator> struct Serializer< ::kinova_msgs::ArmPoseFeedback_<ContainerAllocator> > { template<typename Stream, typename T> inline static void allInOne(Stream& stream, T m) { stream.next(m.pose); } ROS_DECLARE_ALLINONE_SERIALIZER }; // struct ArmPoseFeedback_ } // namespace serialization } // namespace ros namespace ros { namespace message_operations { template<class ContainerAllocator> struct Printer< ::kinova_msgs::ArmPoseFeedback_<ContainerAllocator> > { template<typename Stream> static void stream(Stream& s, const std::string& indent, const ::kinova_msgs::ArmPoseFeedback_<ContainerAllocator>& v) { s << indent << "pose: "; s << std::endl; Printer< ::geometry_msgs::PoseStamped_<ContainerAllocator> >::stream(s, indent + " ", v.pose); } }; } // namespace message_operations } // namespace ros #endif // KINOVA_MSGS_MESSAGE_ARMPOSEFEEDBACK_H
[ "rrameshwar@wpi.edu" ]
rrameshwar@wpi.edu
f975939394c1947a2b55d3fcf428b9e59a528a41
1f8a3c36135a5192d502663477af49b26de94a8b
/imooc/cpp/cpp封装下/d6开篇案例/MazeMap/MazeMap.h
1af701c109c0f98155aec50db12c4bf4c683a643
[]
no_license
Gzmbw/coding
18095ca80b59e3859864b3ece06a033047c57dc0
85b4b62f4f204312f2d746ec46fc38e5b0c46311
refs/heads/master
2021-01-23T05:51:07.557296
2017-09-18T01:19:25
2017-09-18T01:19:25
102,480,179
0
0
null
null
null
null
UTF-8
C++
false
false
891
h
#ifndef MAZEMAP_H #define MAZEMAP_H #define WALL 1 #define ROAD 0 class MazeMap { public: MazeMap(); MazeMap(const MazeMap &_mazemap); ~MazeMap(); void setMazeMap(int *map,int row,int col);//设置指向地图二维数组的指针 void setMazeWall(char _wall);//设置墙壁字符表示 void drawMap();//打印地图 int **getMap();//获取地图二维数组的指针 int getCol();//获得二维数组的列数 int getRow();//获得二维数组的行数 void setExitPosition(COORD coo);//设置出口位置 COORD getExitPosition();//获取出口位置 private: char m_cWall;//代表墙的字符 char m_cRoad;//代表路的字符 int m_iMapRow;//二维数组的行数 int m_iMapCol;//二维数组的列数 int **m_pMap;//指向地图二维数组的指针 COORD m_ExitPosition;//迷宫出口坐标 }; #endif // MAZEMAP_H
[ "unbroken1127@gmail.com" ]
unbroken1127@gmail.com
deb97a8f7c45dedda7af26e9c81e750558f79f8d
3a01d6f6e9f7db7428ae5dc286d6bc267c4ca13e
/unittests/libtests/feassemble/data/GeomDataQuad3D.hh
953b656f0aca241e22a800b804e1120964012872
[ "MIT" ]
permissive
youngsolar/pylith
1ee9f03c2b01560706b44b4ccae99c3fb6b9fdf4
62c07b91fa7581641c7b2a0f658bde288fa003de
refs/heads/master
2020-12-26T04:04:21.884785
2014-10-06T21:42:42
2014-10-06T21:42:42
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,801
hh
// -*- C++ -*- // // ====================================================================== // // Brad T. Aagaard, U.S. Geological Survey // Charles A. Williams, GNS Science // Matthew G. Knepley, University of Chicago // // This code was developed as part of the Computational Infrastructure // for Geodynamics (http://geodynamics.org). // // Copyright (c) 2010-2014 University of California, Davis // // See COPYING for license information. // // ====================================================================== // #if !defined(pylith_meshio_geomdataquad3d_hh) #define pylith_meshio_geomdataquad3d_hh #include "CellGeomData.hh" namespace pylith { namespace feassemble { class GeomDataQuad3D; } // feassemble } // pylith class pylith::feassemble::GeomDataQuad3D : public CellGeomData { // PUBLIC METHODS /////////////////////////////////////////////////////// public: /// Constructor GeomDataQuad3D(void); /// Destructor ~GeomDataQuad3D(void); // PRIVATE MEMBERS ////////////////////////////////////////////////////// private: static const int _cellDim; ///< Number of dimensions associated with cell static const int _spaceDim; ///< Number of dimensions in vertex coordinates static const int _numCorners; ///< Number of vertices in cell static const int _numLocs; ///< Number of locations for computing Jacobian static const PylithScalar _gravityVec[]; ///< Constant gravity vector static const PylithScalar _vertices[]; ///< Coordinates of cell's vertices static const PylithScalar _locations[]; ///< Locations to compute Jacobian static const PylithScalar _jacobian[]; ///< Jacobian at locations static const PylithScalar _jacobianDet[]; ///< Determinant of Jacobian at locations }; #endif // pylith_meshio_geomdataquad3d_hh // End of file
[ "baagaard@usgs.gov" ]
baagaard@usgs.gov
5eea1b6e2615f3b8e8fb3644f1c2fdc2a75a03d3
1576048c9fc9f6adb0041a6d3e8edd58daeb08a4
/Day 11/q1.cpp
ae3c10c47fbb813d08ad792dc934b70f83491365
[]
no_license
SarthakBhatt22601/DS-A-Assignments
6c886ff5e7383d5fdbbfd87a2ced81f9c55eebe2
665aa654ad43f7861136a45f7f6679cd97c93fc1
refs/heads/main
2023-06-25T10:11:40.411718
2021-07-27T18:21:02
2021-07-27T18:21:02
382,944,587
0
0
null
null
null
null
UTF-8
C++
false
false
1,223
cpp
class Solution { public: vector<string> findWords(vector<string>& words) { set<char> s1{'q','w','e','r','t','y','u','i','o','p'}; set<char> s2{'a','s','d','f','g','h','j','k','l'}; set<char> s3{'z','x','c','v','b','n','m'}; vector<string> res; int flag = 0; for(auto word:words) { if(s1.find(tolower(word[0])) != s1.end()) flag = 1; else if(s2.find(tolower(word[0])) != s2.end()) flag = 2; else flag = 3; for(int i=0;i<word.size();i++) { if(flag == 1 && s1.find(tolower(word[i])) == s1.end()) { flag = 0; break; } else if(flag == 2 && s2.find(tolower(word[i])) == s2.end()) { flag = 0; break; } else if(flag == 3 && s3.find(tolower(word[i])) == s3.end()) { flag = 0; break; } } if(flag != 0) res.push_back(word); } return res; } };
[ "sarthakbhatt22601@gmail.com" ]
sarthakbhatt22601@gmail.com
19f41410d7517e25a4f1eb7b9a3a3376d183b0bf
a1b047edaa76f5a81d8b64fc22d5889deddefc00
/LeetCode/0116.Populating Next Right Pointers in Each Node/main.cpp
3045eaff96318b4db9ca93eeabe870b22fe8d98f
[]
no_license
Shaofa/Algorithm
45c0b2483e3efd6876299e6bf98c7f57c880140f
23ad046b89d610bc72e05267df6969969ef7d39e
refs/heads/master
2021-01-22T02:59:10.276167
2016-01-09T02:22:10
2016-01-09T02:22:10
38,855,648
0
0
null
null
null
null
UTF-8
C++
false
false
2,322
cpp
/********************************************************************************************* * Given a binary tree * struct TreeLinkNode { TreeLinkNode *left; TreeLinkNode *right; TreeLinkNode *next; } * Populate each next pointer to point to its next right node. * If there is no next right node, the next pointer should be set to NULL. * Initially, all next pointers are set to NULL. * Note: * You may only use constant extra space. * You may assume that it is a perfect binary tree(ie, all leaves are at the same level, * and every parent has two children). * For example, * Given the following perfect binary tree, * 1 * / \ * 2 3 * / \ / \ * 4 5 6 7 * After calling your function, the tree should look like : * 1->NULL * / \ * 2 -> 3->NULL * / \ / \ * 4->5->6->7->NULL *******************************************************************************************/ #include <iostream> #include <vector> using namespace std; struct TreeLinkNode { int val; TreeLinkNode *left, *right, *next; TreeLinkNode(int x): val(x), left(NULL), right(NULL), next(NULL) {} }; void connect(TreeLinkNode *root) { if (root) { if (root->left != NULL) { root->left->next = root->right; } if (root->right != NULL && root->next != NULL) { root->right->next = root->next->left; } connect(root->left); connect(root->right); } } vector<int> rst; vector<int> preorderTraversal(TreeLinkNode* root) { if (root != NULL) { cout << root->val << '\t'; if (root->next == NULL) cout << "->\tNULL" << endl; else cout << "->\t" << root->next->val << endl; preorderTraversal(root->left); preorderTraversal(root->right); } return rst; } int main(void) { TreeLinkNode root(0); TreeLinkNode node1(1), node2(2), node3(3), node4(4), node5(5), node6(6), node7(7); TreeLinkNode node8(8), node9(9), node10(10), node11(11), node12(12), node13(13), node14(14); root.left = &node1; root.right = &node2; node1.left = &node3; node1.right = &node4; node2.left = &node5; node2.right = &node6; node3.left = &node7; node3.right = &node8; node4.left = &node9; node4.right = &node10; node5.left = &node11; node5.right = &node12; preorderTraversal(&root); connect(&root); cout << endl; preorderTraversal(&root); return 0; }
[ "laishaofa@gmail.com" ]
laishaofa@gmail.com
262d4935abbe437597e4b804b4f0ab524ec7bf24
fc9891d39d5d33d394a3c5d712afcac15b0818f6
/menuReportes.cpp
34b1144a9479c29009b3efe98ef031cf528fc64d
[]
no_license
Ornellabnchr/Agencia-Vehiculos
7fa18d124fe3763e3fd7f39565b230d985842d40
847f67461db26e110cb171a25bf124a4a36829ae
refs/heads/master
2023-08-30T11:16:28.025683
2021-10-27T23:10:02
2021-10-27T23:10:02
null
0
0
null
null
null
null
UTF-8
C++
false
false
11,010
cpp
#ifndef MENUREPORTES_CPP_INCLUDED #define MENUREPORTES_CPP_INCLUDED #include <iostream> #include <cstdlib> #include <cstdio> #include <cstring> #include <iomanip> using namespace std; #include "rlutil.h" using namespace rlutil; #include "funciones.h" #include "clsOperacion.h" #include "menuVendedores.h" #include "menuVehiculos.h" #include "menuReportes.h" #include "validations.h" enum MENU_REPORTES{ OPCION_SALIR_DE_MENUREPORTES, OPCION_MOSTRAR_REPORTE_VENTAS, OPCION_RANKING_VENDEDORES, OPCION_RANKING_VEHICULOS, OPCION_ESTADISTICA_EDAD_Y_CREDITOS }; int menuReportes(){ int opc; while(true){ cls(); gotoxy(55,4); cout << "MENU REPORTES" << endl; LINEA_EN_X(40,86,6,7); LINEA_EN_X(40,86,16,7); LINEA_EN_Y(6,17,39,7); LINEA_EN_Y(6,17,86,7); gotoxy(45,8); cout << "1. Reporte de ventas mes a mes" << endl; gotoxy(45,9); cout << "2. Ranking de Vendedores" << endl; gotoxy(45,10); cout << "3. Ranking de Vehiculos mas vendidos" << endl; gotoxy(45,11); cout << "4. Estadistica entre edad y credito"<<endl; gotoxy(45,12); cout << "0. Volver al menu anterior" << endl; gotoxy(50,19); cout << "SELECCIONE UNA OPCION: " << endl; gotoxy(72,19); cin>>opc; cls(); switch(opc){ case OPCION_MOSTRAR_REPORTE_VENTAS: { cout<<"------------------------------------------------------------------------" <<endl; cout<<"------------------VENTAS MES A MES (2019/2020/2021) -------------------- "<<endl; cout<<"------------------------------------------------------------------------" <<endl; int anio; cout<<"Ingrese el anio que desea ver: "; cin>>anio;"\n"; int indexAnio = getIndexAnio(anio); while (indexAnio==-1){ cout<<"Error!!! Ingrese un anio de actividad de la concesionaria (2019/2020/2021): "; cin>>anio; "\n"; } ventasPorMes(anio, indexAnio); break; } case OPCION_RANKING_VENDEDORES: { cout<<"------------------------------------------------------------------------" <<endl; cout<<"------------------RANKING MEJORES VENDEDORES -------------------------- "<<endl; cout<<"------------------------------------------------------------------------" <<endl; mostrarRankingVendedores(); } break; case OPCION_RANKING_VEHICULOS: { cout<<"------------------------------------------------------------------------" <<endl; cout<<"------------------RANKING VEHICULOS MÁS VENDIDOS -----------------------"<<endl; cout<<"------------------------------------------------------------------------" <<endl; mostrarRankingVehiculos(); } break; case OPCION_ESTADISTICA_EDAD_Y_CREDITOS: { cout<<"------------------------------------------------------------------------" <<endl; cout<<"------------------ESTADÍSTICAS DE CRÉDITOS SOLICITADOS------------------"<<endl; cout<<"------------------------------------------------------------------------" <<endl; mostrarEstadisticaCreditoEdad(); } break; case OPCION_SALIR_DE_MENUREPORTES: return 0; break; default: cout<<" OPCION INCORRECTA"<<endl; break; } cout<<endl; system("pause"); } return 0; } void ventasPorMes(int anio,int indexAnio){ Operacion regOperacion; bool huboVentas=false; int ventasMeses[12][3]={0}; FILE *p; p=fopen("Operaciones.dat","rb"); if(p==NULL) return; while(fread(&regOperacion,sizeof (Operacion),1,p)==1){ if (regOperacion.getVentaCompleta()==true && regOperacion.getFechaDeFin().getAnio()== anio){ huboVentas=true; int mesDeOperacion = regOperacion.getFechaDeFin().getMes(); ventasMeses[mesDeOperacion-1][indexAnio]++; } } if (huboVentas==false){ cout<< endl<<"No hay registradas ventas ese anio"; return; } for (int i=0;i<12;i++){ cout<< getNombreDeMes(i+1) << ": "<<ventasMeses[i][indexAnio]<<endl; } fclose(p); cout<<endl<<endl; cout<<"Ingrese numero de mes para ver el detalle o 0 (cero) para salir: "; int rta; cin >> rta; if (rta==0) return; rta = validateMes(rta,anio); system("cls"); mostrarVentasPorMes(rta,anio); } void mostrarVentasPorMes(int mes,int anio){ Operacion regOperacion; Cliente regCliente; Vendedor regVendedor; Vehiculo regVehiculo; FILE *p; p=fopen("Operaciones.dat","rb"); cout<<setw(5)<<"ID"<<setw(31)<<"Apellido del cliente"<<setw(31)<<"Apellido del vendedor"<<setw(10)<<"Monto"<<setw(15)<<"Marca"<<setw(20)<<"Modelo"<<endl; while (fread(&regOperacion, sizeof (Operacion),1,p) == 1){ if (regOperacion.getFechaDeFin().getAnio()==anio && regOperacion.getFechaDeFin().getMes() == mes){ cout<<setw(5)<<regOperacion.getIdOperacion(); int pos; pos=buscarPosCliente(regOperacion.getDniCliente()); regCliente.leerDeDisco(pos); cout<<setw(31)<<regCliente.getApellido(); pos=buscarPosVendedor(regOperacion.getDniVendedor()); regVendedor.leerDeDisco(pos); cout<<setw(31)<<regVendedor.getApellido(); cout<<setw(10)<<"$"<<regOperacion.getMonto(); pos=buscarPosVehiculo(regOperacion.getIdVehiculo()); regVehiculo.leerDeDisco(pos); cout<<setw(15)<<regVehiculo.getMarca(); cout<<setw(20)<<regVehiculo.getModelo(); } } fclose(p); } char* getNombreDeMes(int nroDeMes){ switch(nroDeMes){ case 1: return "Enero"; case 2: return "Febrero"; case 3: return "Marzo"; case 4: return "Abril"; case 5: return "Mayo"; case 6: return "Junio"; case 7: return "Julio"; case 8: return "Agosto"; case 9: return "Septiembre"; case 10: return "Octubre"; case 11: return "Noviembre"; case 12: return "Diciembre"; } } int getIndexAnio(int anio){ switch(anio){ case 2019: return 0; case 2020: return 1; case 2021: return 2; } return -1; } float calculateCantMontos(int dn){ Operacion regOperacion; int cantVentas=0; int pos=0; while(regOperacion.leerDeDisco(pos++)){ if(regOperacion.getDniVendedor()==dn && regOperacion.getVentaCompleta()==true){ cantVentas+=regOperacion.getMonto(); } } return cantVentas; } void mostrarMontosVendedores(Vendedor *vecV, int cant){ Vendedor reg; int pos=0; for(int i=0;i<cant;i++){ float montos=calculateCantMontos(vecV[i].getDni()); cout<<i+1<<"-"<<vecV[i].getNombre()<<" "<<vecV[i].getApellido()<<": "<< vecV[i].calculateCantVentasRealizadas()<<" | Monto Total Recaudado (Comisiones): "<< ((montos*vecV[i].getComisionPorcentaje())/ 100)<<endl; } } void mostrarRankingVendedores(){ int cant = cantDeVendedores(); FILE *p; p=fopen("Vendedores.dat","rb"); if (p==NULL || cant==-1 ){ cout<<endl<<"El archivo de vendedores no existe"; return; } Vendedor *vecVendedores; vecVendedores = new Vendedor[cant]; fread(vecVendedores,sizeof (Vendedor),cant,p); for (int i=0;i<cant;i++){ for(int j=i+1;j<cant;j++){ if (vecVendedores[i].calculateCantVentasRealizadas()<vecVendedores[j].calculateCantVentasRealizadas()){ Vendedor aux; aux = vecVendedores[j]; vecVendedores[j]=vecVendedores[i]; vecVendedores[i]=aux; } } } /* for (int k=0;k<cant;k++){ cout<<k+1<<"-"<<vecVendedores[k].getNombre()<<" "<<vecVendedores[k].getApellido()<<": "<< vecVendedores[k].calculateCantVentasRealizadas()<<endl; }*/ mostrarMontosVendedores(vecVendedores,cant); fclose(p); delete vecVendedores; } void mostrarRankingVehiculos(){ int cant = cantDeVehiculos(); FILE *p; p=fopen("Vehiculos.dat","rb"); if (p==NULL || cant==-1){ cout<<endl<<"El archivo de vehiculos no existe"; return; } Vehiculo *vecVehiculos; vecVehiculos = new Vehiculo[cant]; fread(vecVehiculos,sizeof (Vehiculo),cant,p); for (int i=0;i<cant;i++){ for(int j=i+1;j<cant;j++){ if (vecVehiculos[i].calculateCantVendidos()<vecVehiculos[j].calculateCantVendidos()){ Vehiculo aux; aux = vecVehiculos[j]; vecVehiculos[j]=vecVehiculos[i]; vecVehiculos[i]=aux; } } } for (int k=0;k<cant;k++){ cout<<k+1<<"-"<<vecVehiculos[k].getMarca()<<" "<<vecVehiculos[k].getModelo()<<": "<< vecVehiculos[k].calculateCantVendidos()<<endl; } fclose(p); } void mostrarEstadisticaCreditoEdad(){ Cliente regCliente; Operacion regOperacion; int ventasJoven=0,ventasMedia=0, ventasMayor=0; int cantConCredito=0; float porcentajeJoven=0,porcentajeMedia=0,porcentajeMayor=0; FILE *p; p=fopen("Operaciones.dat","rb"); if (p==NULL){ cout<<"No se pudo leer el archivo"<<endl; return; } while (fread(&regOperacion,sizeof (Operacion),1,p)==1){ int pos=buscarPosCliente(regOperacion.getDniCliente()); regCliente.leerDeDisco(pos); if(regCliente.getPidioCredito()==true){ cantConCredito++; int edad=regCliente.calculateEdad(); if(edad>45) ventasMayor++; else if (edad<=45 && edad>=31) ventasMedia++; else ventasJoven++; } } fclose(p); porcentajeJoven=float(ventasJoven)/float(cantConCredito); porcentajeMedia=float(ventasMedia)/float(cantConCredito); porcentajeMayor=float(ventasMayor)/float(cantConCredito); cout<<"Porcentaje de ventas con crédito: "<<endl; cout<<"Clientes jóvenes (entre 18 y 30 años inclusive): "<<porcentajeJoven << " ("<<ventasJoven<<" ventas)"<<endl; cout<<"Clientes de edad media (entre 30 y 45 años inclusive): "<<porcentajeMedia << " ("<<ventasMedia<<" ventas)"<<endl; cout<<"Clientes de mayores (más de 45 años): "<<porcentajeMayor << " ("<<ventasMayor<<" ventas)"<<endl; } #endif // MENUREPORTES_CPP_INCLUDED
[ "ornebanchero@hotmail.com" ]
ornebanchero@hotmail.com
08e22ec10467dbc2a74d0fbd2e7e26a5c8a517ed
baeceebf6fe0c1bf746f8e2b45a2469802fac679
/include/nanoalgorithm.h
16d8ecb61abe4920789ce7e661380ab5845307fb
[ "MIT" ]
permissive
killvxk/nanostl
212cfabee97b85d5d7bedb44698eb455ddbdeee6
9f5f79faaddd7789db2536c069e92567ae5edc7c
refs/heads/master
2020-04-05T20:53:29.961231
2017-12-22T06:01:47
2017-12-22T06:01:47
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,486
h
/* * The MIT License (MIT) * * Copyright (c) 2017 Light Transport Entertainment, Inc. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ #ifndef NANOSTL_ALGORITHM_H_ #define NANOSTL_ALGORITHM_H_ namespace nanostl { template <class T> const T& min(const T& a, const T& b) { return !(b < a) ? a : b; } template <class T> const T& max(const T& a, const T& b) { return !(b > a) ? a : b; } } // namespace nanostl #endif // NANOSTL_ALGORITHM_H_
[ "syoyo@lighttransport.com" ]
syoyo@lighttransport.com
3633f12564f6b97543b257966a708fa2be61757b
49eacb5dd4611a295b6ef3010839f31f6d6e5568
/twoPhases/phase2.cpp
cf45c3aac74ef1a1c32b94f566a2d4eb667ce272
[]
no_license
luishpmendes/PCDCP
310608dd60250a70dca5bfda986959003efefd27
efaa97075c638106a2f82bcc43ed83f0139c2523
refs/heads/master
2020-04-04T05:31:23.325446
2017-04-02T01:06:46
2017-04-02T01:06:46
54,665,674
0
0
null
null
null
null
UTF-8
C++
false
false
11,774
cpp
#include "gurobi_c++.h" #include <iostream> #include <vector> #include <list> #include <queue> #include <set> #include <sstream> #include <map> #include <string> #include <algorithm> #include <iomanip> #include <cmath> #include <chrono> #include <fstream> using namespace std; typedef long int lint; typedef unsigned long int ulint; string itos (ulint i) { stringstream s; s << i; return s.str(); } class subtourelim: public GRBCallback { public : vector <GRBVar> y; vector <GRBVar> x; ulint n; ulint m; vector < pair < pair <ulint, ulint> , ulint> > E; map < pair <ulint, ulint>, ulint> mE; ulint root; subtourelim (vector <GRBVar> _y, vector <GRBVar> _x, ulint _n, ulint _m, vector < pair < pair <ulint, ulint>, ulint> > _E, map < pair <ulint, ulint>, ulint> _mE, ulint _root) { y = _y; x = _x; n = _n; m = _m; E = _E; mE = _mE; root = _root; } protected : // let C be the cycle that contains u, with n1 vertices // let S = n - n1 // the sum of the edges that are not in C must be less than S-1 void callback () { try { if (where == GRB_CB_MIPSOL) { // find subtour containing vertex u, and add constraint to edges not in the tour vector < list < pair <ulint, ulint> > > adj (n); // build graph from solution vertices for (ulint e = 0; e < m; e++) { if (getSolution(x[e]) >= 0.5) { ulint a = E[e].first.first; ulint b = E[e].first.second; ulint c = E[e].second; adj[a].push_back(make_pair(b, c)); adj[b].push_back(make_pair(a, c)); } } vector <ulint> visitedVertices (n, 0); vector <ulint> visitedEdges (m, 0); queue <ulint> Q; Q.push(root); while (!Q.empty()) { ulint u = Q.front(); Q.pop(); for (list < pair <ulint, ulint> > :: iterator it = adj[u].begin(); it != adj[u].end(); it++) { ulint v = it->first; if (visitedVertices[v] == 0 && getSolution(y[v]) >= 0.5) { visitedVertices[v] = 1; ulint e = mE[make_pair(u, v)]; visitedEdges[e] = 1; Q.push(v); } } } ulint nUnvisitedVertices = 0; for (ulint v = 0; v < n; v++) { if (visitedVertices[v] == 0 && getSolution(y[v]) >= 0.5) { nUnvisitedVertices++; } } if (nUnvisitedVertices > 0) { GRBLinExpr expr = 0; for (ulint e = 0; e < m; e++) { if (visitedEdges[e] == 0 && getSolution(x[e]) >= 0.5) { if (visitedVertices[E[e].first.first] == 0 && getSolution(y[E[e].first.first]) >= 0.5 && visitedVertices[E[e].first.second] == 0 && getSolution(y[E[e].first.second]) >= 0.5) expr += x[e]; } } addLazy(expr <= nUnvisitedVertices - 1); } } } catch (GRBException e) { cout << "Error number: " << e.getErrorCode() << endl; cout << "Error message: " << e.getMessage() << endl; } catch (...) { cout << "Error during callback" << endl; } } }; int main (int argc, char * argv[]) { chrono :: steady_clock :: time_point tBegin = chrono :: steady_clock :: now(); string I ("0"); ulint timeLimit = 10; if (argc >= 2) { I = string (argv[1]); } if (argc >= 3) { timeLimit = atoi(argv[2]); } ulint nComplete, k, t, n, m, root; double d; cin >> nComplete >> d >> k >> t >> n >> m >> root; vector <ulint> penalty (nComplete); // vector with de penalties of each vectex vector < list < pair <ulint, ulint> > > adj (nComplete); // adjacency lists for the graph for (ulint v = 0; v < nComplete; v++) { cin >> penalty[v]; } vector <ulint> solutionV (nComplete, 0); // reading solution vertices for (ulint i = 0; i < n; i++) { ulint v; cin >> v; solutionV[v] = 1; } vector < pair < pair <ulint, ulint> , ulint> > E (m); // vector of edges with the format ((u, v), w) map < pair <ulint, ulint>, ulint> mE; // map an edge to its ID vector < vector <ulint> > paths (m); // reading graph for (ulint e = 0; e < m; e++) { ulint u, v, w, pathSize; cin >> u >> v >> w >> pathSize; adj[u].push_back(make_pair(v, w)); adj[v].push_back(make_pair(u, w)); E[e] = make_pair(make_pair(u, v), w); mE[make_pair(u, v)] = e; mE[make_pair(v, u)] = e; paths[e] = vector <ulint> (pathSize); for (ulint i = 0; i < pathSize; i++) { cin >> paths[e][i]; } } try { string N = itos(nComplete); stringstream ssD; ssD << fixed << setprecision(1) << d; string D = ssD.str(); D.erase(remove(D.begin(), D.end(), '.'), D.end()); string K = itos(k); string T = itos(t); ifstream remainingTimeFile ("./output/N" + N + "D" + D + "K" + K + "T" + T + "I" + I + "/remainingTime.txt"); lint remainingTime = 0; if (remainingTimeFile.is_open()) { remainingTimeFile >> remainingTime; } if (remainingTime > 0) { timeLimit += remainingTime; } GRBEnv env = GRBEnv(); env.set(GRB_IntParam_LazyConstraints, 1); env.set(GRB_IntParam_LogToConsole, 0); env.set(GRB_StringParam_LogFile, "./output/N" + N + "D" + D + "K" + K + "T" + T + "I" + I + "/log2.txt"); env.set(GRB_DoubleParam_TimeLimit, ((double) timeLimit)); GRBModel model = GRBModel(env); model.getEnv().set(GRB_IntParam_LazyConstraints, 1); model.getEnv().set(GRB_IntParam_LogToConsole, 0); model.getEnv().set(GRB_StringParam_LogFile, "./output/N" + N + "D" + D + "K" + K + "T" + T + "I" + I + "/log2.txt"); model.getEnv().set(GRB_DoubleParam_TimeLimit, ((double) timeLimit)); vector <GRBVar> y (nComplete); // ∀ v ∈ V for (ulint v = 0; v < nComplete; v++) { // y_v ∈ {0.0, 1.0} y[v] = model.addVar(0.0, 1.0, 0.0, GRB_BINARY, "y_" + itos(v)); } vector <GRBVar> x (m); // ∀ e ∈ E for (ulint e = 0; e < m; e++) { ulint u, v; u = E[e].first.first; v = E[e].first.second; // y_e ∈ {0.0, 1.0} x[e] = model.addVar(0.0, 1.0, 0.0, GRB_BINARY, "x_" + itos(u) + "_" + itos(v)); } model.update(); GRBLinExpr obj = 0.0; // obj = ∑ ce * xe for (ulint e = 0; e < m; e++) { ulint w; w = E[e].second; obj += w * x[e]; } // obj += ∑ πv * (1 - yv) for (ulint v = 0; v < nComplete; v++) { obj += penalty[v] * (1.0 - y[v]); } model.setObjective(obj, GRB_MINIMIZE); // yu == 1 model.addConstr(y[root] == 1.0, "c_0"); // dominance // ∀ v ∈ V for (ulint v = 0; v < nComplete; v++) { if (solutionV[v] == 1) { GRBLinExpr constr = 0.0; constr += y[v]; model.addConstr(constr == 1, "c_1_" + itos(v)); } } // each vertex must have exactly two edges adjacent to itself // ∀ v ∈ V for (ulint v = 0; v < nComplete; v++) { // ∑ xe == 2 * yv , e ∈ δ({v}) GRBLinExpr constr = 0.0; for (list < pair <ulint, ulint> > :: iterator it = adj[v].begin(); it != adj[v].end(); it++) { ulint w = (*it).first; // destination ulint e = mE[make_pair(v, w)]; constr += x[e]; } model.addConstr(constr == 2.0 * y[v], "c_2_" + itos(v)); } subtourelim cb = subtourelim(y, x, nComplete, m, E, mE, root); model.setCallback(&cb); model.optimize(); if (model.get(GRB_IntAttr_SolCount) > 0) { ulint solutionCost = 0; set <ulint> solutionVectices; vector < pair <ulint, ulint> > solutionEdges; solutionCost = round(model.get(GRB_DoubleAttr_ObjVal)); for (ulint v = 0; v < nComplete; v++) { if (y[v].get(GRB_DoubleAttr_X) >= 0.5) { solutionVectices.insert(v); } } for (ulint e = 0; e < m; e++) { if (x[e].get(GRB_DoubleAttr_X) >= 0.5) { for (ulint i = 0; i < paths[e].size() - 1; i++) { pair <ulint, ulint> edge; if (paths[e][i] < paths[e][i + 1]) { edge.first = paths[e][i]; edge.second = paths[e][i + 1]; } else { edge.first = paths[e][i + 1]; edge.second = paths[e][i]; } solutionEdges.push_back(edge); } } } cout << solutionVectices.size() << ' ' << solutionEdges.size() << ' ' << solutionCost << endl; for (set <ulint> :: iterator it = solutionVectices.begin(); it != solutionVectices.end(); it++) { ulint v = *it; cout << v << endl; } for (vector < pair <ulint, ulint> > :: iterator it = solutionEdges.begin(); it != solutionEdges.end(); it++) { pair <ulint, ulint> e = *it; cout << e.first << " " << e.second << endl; } } else { cout << "0 0 0" << endl; } // exporting model model.write("./output/N" + N + "D" + D + "K" + K + "T" + T + "I" + I + "/model2.lp"); ofstream objValFile ("./output/N" + N + "D" + D + "K" + K + "T" + T + "I" + I + "/objVal2.txt", ofstream :: out); objValFile << model.get(GRB_DoubleAttr_ObjVal); objValFile.close(); ofstream gapFile ("./output/N" + N + "D" + D + "K" + K + "T" + T + "I" + I + "/gap2.txt", ofstream :: out); gapFile << model.get(GRB_DoubleAttr_MIPGap); gapFile.close(); chrono :: steady_clock :: time_point tEnd = chrono :: steady_clock :: now(); chrono :: nanoseconds elapsedTime = chrono :: duration_cast <chrono :: nanoseconds> (tEnd - tBegin); ofstream elapsedTimeFile ("./output/N" + N + "D" + D + "K" + K + "T" + T + "I" + I + "/elapsedTime2.txt", ofstream :: out); elapsedTimeFile << elapsedTime.count(); elapsedTimeFile.close(); } catch (GRBException e) { cout << "Error code = " << e.getErrorCode() << endl; cout << e.getMessage() << endl; } catch (...) { cout << "Exception during opstimisation" << endl; } return 0; }
[ "luishpmendes@gmail.com" ]
luishpmendes@gmail.com
e4b6a66e56076c4b913175af22da474919af6e4b
ed5973c6d7a374d7ddf383213574e328b3d66880
/third_party/blink/renderer/core/loader/web_bundle/script_web_bundle.cc
59f46c2c36f8e6b42b55e770b2931bba5702eb0a
[ "BSD-3-Clause", "LGPL-2.0-or-later", "LicenseRef-scancode-warranty-disclaimer", "LGPL-2.1-only", "GPL-1.0-or-later", "GPL-2.0-only", "LGPL-2.0-only", "BSD-2-Clause", "LicenseRef-scancode-other-copyleft", "Apache-2.0", "MIT" ]
permissive
dyg540/chromium
7b49ef79e555c4aac9adcd019b551a74bd1f15c0
b579df91e79efc75addb8a11097cc1af7b81bb75
refs/heads/main
2023-08-26T15:45:08.346269
2021-11-03T12:25:32
2021-11-03T12:25:32
424,226,175
1
0
BSD-3-Clause
2021-11-03T13:04:14
2021-11-03T13:04:13
null
UTF-8
C++
false
false
9,230
cc
// Copyright 2021 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "third_party/blink/renderer/core/loader/web_bundle/script_web_bundle.h" #include "third_party/blink/renderer/core/dom/document.h" #include "third_party/blink/renderer/core/execution_context/execution_context.h" #include "third_party/blink/renderer/core/html/cross_origin_attribute.h" #include "third_party/blink/renderer/core/html/html_script_element.h" #include "third_party/blink/renderer/core/inspector/console_message.h" #include "third_party/blink/renderer/core/loader/web_bundle/script_web_bundle_rule.h" #include "third_party/blink/renderer/core/loader/web_bundle/web_bundle_loader.h" #include "third_party/blink/renderer/platform/bindings/microtask.h" #include "third_party/blink/renderer/platform/loader/cors/cors.h" #include "third_party/blink/renderer/platform/loader/fetch/resource_fetcher.h" #include "third_party/blink/renderer/platform/loader/fetch/subresource_web_bundle_list.h" #include "third_party/blink/renderer/platform/weborigin/kurl.h" #include "third_party/blink/renderer/platform/wtf/casting.h" #include "third_party/blink/renderer/platform/wtf/cross_thread_functional.h" #include "third_party/blink/renderer/platform/wtf/text/wtf_string.h" namespace blink { // MicroTask which is used to release a webbundle resource. class ScriptWebBundle::ReleaseResourceTask { public: explicit ReleaseResourceTask(ScriptWebBundle& script_web_bundle) : script_web_bundle_(&script_web_bundle) {} void Run() { if (script_web_bundle_->WillBeReleased()) { script_web_bundle_->ReleaseBundleLoaderAndUnregister(); } } private: Persistent<ScriptWebBundle> script_web_bundle_; }; ScriptWebBundle* ScriptWebBundle::CreateOrReuseInline( ScriptElementBase& element, const String& source_text) { Document& document = element.GetDocument(); auto rule = ScriptWebBundleRule::ParseJson(source_text, document.BaseURL()); if (!rule) { return nullptr; } ResourceFetcher* resource_fetcher = document.Fetcher(); if (!resource_fetcher) { return nullptr; } SubresourceWebBundleList* active_bundles = resource_fetcher->GetOrCreateSubresourceWebBundleList(); if (SubresourceWebBundle* found = active_bundles->FindSubresourceWebBundleWhichWillBeReleased( rule->source_url(), rule->credentials_mode())) { // Re-use the ScriptWebBundle if it has the same bundle URL and is being // released. DCHECK(found->IsScriptWebBundle()); ScriptWebBundle* reused_script_web_bundle = To<ScriptWebBundle>(found); reused_script_web_bundle->ReusedWith(element, std::move(*rule)); return reused_script_web_bundle; } return MakeGarbageCollected<ScriptWebBundle>(element, document, *rule); } ScriptWebBundle::ScriptWebBundle(ScriptElementBase& element, Document& element_document, const ScriptWebBundleRule& rule) : element_(&element), element_document_(&element_document), rule_(rule) { CreateBundleLoaderAndRegister(); } void ScriptWebBundle::Trace(Visitor* visitor) const { visitor->Trace(element_); visitor->Trace(element_document_); visitor->Trace(bundle_loader_); SubresourceWebBundle::Trace(visitor); } bool ScriptWebBundle::CanHandleRequest(const KURL& url) const { if (WillBeReleased()) return false; if (!url.IsValid()) return false; if (!rule_.ResourcesOrScopesMatch(url)) return false; if (url.Protocol() == "urn" || url.Protocol() == "uuid-in-package") return true; DCHECK(bundle_loader_); if (!bundle_loader_->GetSecurityOrigin()->IsSameOriginWith( SecurityOrigin::Create(url).get())) { OnWebBundleError(url.ElidedString() + " cannot be loaded from WebBundle " + bundle_loader_->url().ElidedString() + ": bundled resource must be same origin with the bundle."); return false; } if (!url.GetString().StartsWith(bundle_loader_->url().BaseAsString())) { OnWebBundleError( url.ElidedString() + " cannot be loaded from WebBundle " + bundle_loader_->url().ElidedString() + ": bundled resource path must contain the bundle's path as a prefix."); return false; } return true; } const KURL& ScriptWebBundle::GetBundleUrl() const { return rule_.source_url(); } const base::UnguessableToken& ScriptWebBundle::WebBundleToken() const { return bundle_loader_->WebBundleToken(); } String ScriptWebBundle::GetCacheIdentifier() const { DCHECK(bundle_loader_); return bundle_loader_->url().GetString(); } void ScriptWebBundle::OnWebBundleError(const String& message) const { // |element_document_| might not be alive here. if (element_document_) { ExecutionContext* context = element_document_->GetExecutionContext(); if (!context) return; context->AddConsoleMessage(MakeGarbageCollected<ConsoleMessage>( mojom::blink::ConsoleMessageSource::kOther, mojom::blink::ConsoleMessageLevel::kWarning, message)); } } // |bundle_loader_| can be null here, if the script element // is removed from the document and the microtask already // cleaned up the pointer to the loader. // TODO(crbug/1263783): Add a test for the divergent behaviour // between <link> and <script> API when the element is removed. void ScriptWebBundle::NotifyLoadingFinished() { if (!element_ || !bundle_loader_) return; if (bundle_loader_->HasLoaded()) { element_->DispatchLoadEvent(); } else if (bundle_loader_->HasFailed()) { element_->DispatchErrorEvent(); } else { NOTREACHED(); } } bool ScriptWebBundle::IsScriptWebBundle() const { return true; } bool ScriptWebBundle::WillBeReleased() const { return will_be_released_; } network::mojom::CredentialsMode ScriptWebBundle::GetCredentialsMode() const { return rule_.credentials_mode(); } void ScriptWebBundle::CreateBundleLoaderAndRegister() { DCHECK(!bundle_loader_); DCHECK(element_document_); bundle_loader_ = MakeGarbageCollected<WebBundleLoader>( *this, *element_document_, rule_.source_url(), rule_.credentials_mode()); ResourceFetcher* resource_fetcher = element_document_->Fetcher(); if (!resource_fetcher) return; SubresourceWebBundleList* active_bundles = resource_fetcher->GetOrCreateSubresourceWebBundleList(); active_bundles->Add(*this); } void ScriptWebBundle::ReleaseBundleLoaderAndUnregister() { if (bundle_loader_) { // Clear receivers explicitly here, instead of waiting for Blink GC. bundle_loader_->ClearReceivers(); bundle_loader_ = nullptr; } // element_document_ might not be alive. if (!element_document_) return; ResourceFetcher* resource_fetcher = element_document_->Fetcher(); if (!resource_fetcher) return; SubresourceWebBundleList* active_bundles = resource_fetcher->GetOrCreateSubresourceWebBundleList(); active_bundles->Remove(*this); } void ScriptWebBundle::WillReleaseBundleLoaderAndUnregister() { // We don't release webbundle resources synchronously here. Instead, enqueue a // microtask which will release webbundle resources later. // The motivation is that we want to update a mapping rule dynamically without // releasing webbundle resources. // // For example, if we remove <script type=webbundle>, and then add another // <script type=webbundle> with the same bundle URL, but with a new mapping // rule, within the same microtask scope, the new one can re-use the webbundle // resources, instead of releasing them. In other words, we don't fetch the // same bundle twice. // // Tentative spec: // https://docs.google.com/document/d/1GEJ3wTERGEeTG_4J0QtAwaNXhPTza0tedd00A7vPVsw/edit#heading=h.y88lpjmx2ndn will_be_released_ = true; element_ = nullptr; auto task = std::make_unique<ReleaseResourceTask>(*this); Microtask::EnqueueMicrotask( WTF::Bind(&ReleaseResourceTask::Run, std::move(task))); } // This function updates the WebBundleRule, element_ and cancels the release // of a reused WebBundle. Also if the reused bundle fired load/error events, // fire them again as we reuse the bundle. // TODO(crbug/1263783): Explore corner cases of WebBundle reusing and how // load/error events should be handled then. void ScriptWebBundle::ReusedWith(ScriptElementBase& element, ScriptWebBundleRule rule) { DCHECK_EQ(element_document_, element.GetDocument()); DCHECK(will_be_released_); DCHECK(!element_); rule_ = std::move(rule); will_be_released_ = false; element_ = element; DCHECK(bundle_loader_); if (bundle_loader_->HasLoaded()) { element_document_->GetTaskRunner(TaskType::kDOMManipulation) ->PostTask(FROM_HERE, WTF::Bind(&ScriptElementBase::DispatchLoadEvent, WrapPersistent(element_.Get()))); } else if (bundle_loader_->HasFailed()) { element_document_->GetTaskRunner(TaskType::kDOMManipulation) ->PostTask(FROM_HERE, WTF::Bind(&ScriptElementBase::DispatchErrorEvent, WrapPersistent(element_.Get()))); } } } // namespace blink
[ "chromium-scoped@luci-project-accounts.iam.gserviceaccount.com" ]
chromium-scoped@luci-project-accounts.iam.gserviceaccount.com
039d7eeebba8df1d407e781b79fef7fd10f3267e
202306e250194e8d56cc50e9f9538e96c33cd654
/ConvWx/src/include/ConvWx/GridDistToNonMissing.hh
d9574267f6c08c446aeb57337587dcdf350772ca
[]
no_license
AdrianoPereira/ral-libs-shared
f9d34023b0994def083292cca39ec2dacc33b7fc
9e3644604cb9c08e1bac6f45c149e22060d59170
refs/heads/master
2022-03-22T16:36:02.804926
2019-12-11T22:23:49
2019-12-11T22:23:49
null
0
0
null
null
null
null
UTF-8
C++
false
false
5,288
hh
/** * @file GridDistToNonMissing.hh * @brief Keep track of the distance from every point where data is missing * to the nearest point where data is not missing * @class GridDistToNonMissing * @brief Keep track of the distance from every point where data is missing * to the nearest point where data is not missing * * Search the neighborhood of grid point with coordinates (x,y) for non * missing data. The search is conducted along edges of a square with center * (x,y). If a valid data value is found, the distance assigned is the * shortest distance to an edge of the search region. If a valid data value * is not found, then the shortest distance to the edge of the search * region is increased by '_searchScale' grid points. A widening * search may continue until a user defined maximum distance is reached and * the maximum distance is assigned to the grid point. */ # ifndef GRID_DIST_TO_NONMISSING_HH # define GRID_DIST_TO_NONMISSING_HH #include <ConvWx/GridData.hh> #include <vector> class GridDistToNonMissing { public: /** * @param[in] maxSearch Maximum number of gridpoints away from a * point where data is missing to search for * data that is not missing * * @param[in] searchScale The resolution of the search in number of * gridpoints (1, 2, ...) */ GridDistToNonMissing(int maxSearch, int searchScale); /** * Destructor */ virtual ~GridDistToNonMissing (void); /** * @return the searchScale value */ inline int getSearchScale(void) const { return pSearchScale; } /** * update using input grid * * @param[in] g Grid with data to use */ void update(const GridData &g); /** * Return the index to the nearest point that was not missing, * @param[in] x Index to a point * @param[in] y Index to a point * @param[out] nearX index to nearest point where data is not missing, * if there is such a point * @param[out] nearY index to nearest point where data is not missing, * if there is such a point * @return true if index was set to nearby point, false if no point was set * because there is no nearby point. * * @note that nearX, nearY = x, y when data is not missing at x,y */ bool nearestPoint(int x, int y, int &nearX, int &nearY) const; /** * For a given in put data grid and a projection, fill in two output * grids, one with distances to nearest non-missing data and one with * data values at the nearest non-missing data point * * @param[in] proj Projection to use to compute actual distances * @param[in] data Data grid to evaluate * @param[out] distOut At each point the value is set to the distance * (taxicab metric) to the nearest point at which * data is not missing. The value is set to missing * at points where there is no data near enough to use * @param[out] valOut At each point the value is set to the data value at * the nearest point where data is not missing, or * missing if no such point is found. * * @return true for success, false for error * * This method updates the internal state by calling the update() method * as needed. */ bool distanceToNonMissing(const ParmProjection &proj, const GridData &data, GridData &distOut, GridData &valOut); protected: private: /** * @enum SpecialValue_t * @brief Special values to put in to index grids */ typedef enum { HAS_DATA = -1, /**< Good data at a point */ MISSING = -2 /**< Missing data value */ } SpecialValue_t; int pMaxSearch; /**< Search radius (# of gridpoints) */ int pSearchScale; /**< resolution of search (# of gridpoints) */ int pNx; /**< Grid dimension x */ int pNy; /**< Grid dimension y */ /** * At points where data is missing, the X grid index location of the nearest * non-missing data, or MISSING if no non missing data up to max search * distance. * At points where the input data is not missing (distance=0), _xIndex is * set to HAS_DATA */ GridData pXIndex; /** * At points where data is missing, the Y grid index location of the nearest * non-missing data, or MISSING if no non missing data up to max search * distance. * At points where the input data is not missing (distance=0), _xIndex is * set to HAS_DATA */ GridData pYIndex; /** * @return true if the set of points with missing data value in the local * state is different than that of the input grid * @param[in] g Grid to compare to */ bool pMissingChanged(const GridData &g) const; /** * Completely rebuild the local state using input data * @param[in] g Data to use */ void pRebuild(const GridData &g); /** * Rebuild local state at a point * * @param[in] r Radius in number of pixels * @param[in] x Center point * @param[in] y Center point * @param[in] g Grid to use * * @return number of changes made */ int pRebuild1(int r, int x, int y, const GridData &g); }; #endif
[ "mccabe@ucar.edu" ]
mccabe@ucar.edu
c6dc84eb9c01ecb8fa28db4a96f1ba6d168fa755
a568d13304fad8f44b1a869837b99ca29687b7d8
/Code_16/Camp_2/Graph_1/48_Fight.cpp
c973721d9406ac5e4fa64c1925c5aeebd6cc1f58
[]
no_license
MasterIceZ/Code_CPP
ded570ace902c57e2f5fc84e4b1055d191fc4e3d
bc2561484e58b3a326a5f79282f1e6e359ba63ba
refs/heads/master
2023-02-20T14:13:47.722180
2021-01-21T06:15:03
2021-01-21T06:15:03
331,527,248
0
0
null
2021-01-21T05:51:49
2021-01-21T05:43:59
null
UTF-8
C++
false
false
1,034
cpp
/* TASK:48_Fight LANG: CPP AUTHOR: Wichada SCHOOL: RYW */ #include<bits/stdc++.h> using namespace std; struct A{ int v,t; }; vector< A > g[100010]; int color[100010],mid; int dfs(int i,int col){ if(color[i] && color[i]==col) return 1; if(color[i] && color[i]!=col) return 0; color[i]=col; for(auto x: g[i]){ if(x.t>mid)continue; if(!dfs(x.v,3-col)) return 0; } return 1; } int main() { int n,m,a,b,ch; scanf("%d %d",&n,&m); for(int i=1;i<=m;i++){ scanf("%d %d",&a,&b); g[a].push_back({b,i}); g[b].push_back({a,i}); } int l=0,r=m; while(l<r){ mid=(l+r+1)/2; ch=0; for(int i=1;i<=n;i++){ if(!color[i]){ if(!dfs(i,1)){ ch=1; break; } } } // printf("%d %d\n",mid,ch); memset(color,0,sizeof color); if(ch)r=mid-1; else l=mid; } printf("%d\n",l+1); return 0; }
[ "w.wichada26@gmail.com" ]
w.wichada26@gmail.com
4b99d02c4922597e761813a47e440770dcfdc011
f2308b7afff535131d28fb63812f46253f592d20
/scraps/derive.cpp
3ef85e5f8388695771b1c2bccc6582dd8de848be
[]
no_license
NRDavis/NRDavis_CPlusPlus
d5009863394071754181f43ae3fd47bb11198165
e0034e0a8309119050232f474d2b38cc5e48c51f
refs/heads/master
2021-02-04T10:22:18.977611
2020-06-24T01:36:19
2020-06-24T01:36:19
243,656,509
0
0
null
null
null
null
UTF-8
C++
false
false
367
cpp
#include <iostream> using namespace std; class polygon { protected: int height; int width; public: void setVals(int a, int b){ height = a; width = b; } }; class rect : public polygon { public: int area(){ return height * width; } }; int main() { rect r; r.setVals(2,4); cout<<r.area()<<endl; return 0; }
[ "noreply@github.com" ]
noreply@github.com
3c683c0354be145470ab8b9041d27887e08c3d8a
0b45aa221f069d9cd781dafa14bc2099b20fb03e
/tags/2.24.0/sdk/tests/test_performance/source/test_int.cpp
16fa50dff081fa8be6223fe84bb6acdc49c92beb
[]
no_license
svn2github/angelscript
f2d16c2f32d89a364823904d6ca3048222951f8d
6af5956795e67f8b41c6a23d20e369fe2c5ee554
refs/heads/master
2023-09-03T07:42:01.087488
2015-01-12T00:00:30
2015-01-12T00:00:30
19,475,268
0
1
null
null
null
null
UTF-8
C++
false
false
3,943
cpp
// // Test author: Andreas Jonsson // #include "utils.h" namespace TestInt { #define TESTNAME "TestInt" static const char *script = "int N; \n" " \n" "void ifunc5() \n" "{ \n" " N += Average( N, N ); \n" "} \n" " \n" "void ifunc4() \n" "{ \n" " N += 2 * Average( N + 1, N + 2 ); \n" "} \n" " \n" "void ifunc3() \n" "{ \n" " N *= 2 * N; \n" "} \n" " \n" "void ifunc2() \n" "{ \n" " N /= 3; \n" "} \n" " \n" "void iRecursion( int nRec ) \n" "{ \n" " if ( nRec >= 1 ) \n" " iRecursion( nRec - 1 ); \n" " \n" " if ( nRec == 5 ) \n" " ifunc5(); \n" " else if ( nRec == 4 ) \n" " ifunc4(); \n" " else if ( nRec == 3 ) \n" " ifunc3(); \n" " else if ( nRec == 2 ) \n" " ifunc2(); \n" " else \n" " N *= 2; \n" "} \n" " \n" "int TestInt() \n" "{ \n" " N = 0; \n" " int i = 0; \n" " \n" " for ( i = 0; i < 250000; i++ ) \n" " { \n" " Average( i, i ); \n" " iRecursion( 5 ); \n" " \n" " if ( N > 100 ) N = 0; \n" " } \n" " \n" " return 0; \n" "} \n"; int Average(int a, int b) { return (a+b)/2; } void Test(double *testTime) { asIScriptEngine *engine = asCreateScriptEngine(ANGELSCRIPT_VERSION); COutStream out; engine->SetMessageCallback(asMETHOD(COutStream,Callback), &out, asCALL_THISCALL); engine->RegisterGlobalFunction("int Average(int, int)", asFUNCTION(Average), asCALL_CDECL); asIScriptModule *mod = engine->GetModule(0, asGM_ALWAYS_CREATE); mod->AddScriptSection(TESTNAME, script, strlen(script), 0); engine->SetEngineProperty(asEP_BUILD_WITHOUT_LINE_CUES, true); mod->Build(); asIScriptContext *ctx = engine->CreateContext(); ctx->Prepare(mod->GetFunctionIdByDecl("int TestInt()")); double time = GetSystemTimer(); int r = ctx->Execute(); time = GetSystemTimer() - time; if( r != 0 ) { printf("Execution didn't terminate with asEXECUTION_FINISHED\n", TESTNAME); if( r == asEXECUTION_EXCEPTION ) { printf("Script exception\n"); asIScriptFunction *func = ctx->GetExceptionFunction(); printf("Func: %s\n", func->GetName()); printf("Line: %d\n", ctx->GetExceptionLineNumber()); printf("Desc: %s\n", ctx->GetExceptionString()); } } else *testTime = time; ctx->Release(); engine->Release(); } } // namespace
[ "angelcode@404ce1b2-830e-0410-a2e2-b09542c77caf" ]
angelcode@404ce1b2-830e-0410-a2e2-b09542c77caf
272886ba8fdc4acfcb6344bfd4d9a71eab1648d9
39e72c72b8eeb341627d28dec8e9df390a362da6
/src/PeakSynthesize.cpp
00eee23a40e8f88c746a98b69b5f7e42ea73fc7c
[]
no_license
JerryTom121/loudia
68342dd3683b1db0546aa2a3d53eb48a2afec89b
4253d80fa45928df311f9ab6b48a7956eb016650
refs/heads/master
2021-01-20T08:14:11.506111
2014-07-28T11:46:21
2014-07-28T11:46:21
null
0
0
null
null
null
null
UTF-8
C++
false
false
3,483
cpp
/* ** Copyright (C) 2008, 2009 Ricard Marxer <email@ricardmarxer.com> ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 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, write to the Free Software ** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. */ #include "Typedefs.h" #include "Debug.h" #include "PeakSynthesize.h" #include "Utils.h" using namespace std; using namespace Eigen; PeakSynthesize::PeakSynthesize(int windowSize, int fftSize, Window::WindowType windowType) : _windowSize( windowSize ), _windowType( windowType ), _fftSize( fftSize ) { LOUDIA_DEBUG("PEAKSYNTHESIZE: Constructor"); setup(); LOUDIA_DEBUG("PEAKSYNTHESIZE: Constructed"); } PeakSynthesize::~PeakSynthesize() {} void PeakSynthesize::setup(){ // Prepare the buffers LOUDIA_DEBUG("PEAKSYNTHESIZE: Setting up..."); reset(); LOUDIA_DEBUG("PEAKSYNTHESIZE: Finished set up..."); } void PeakSynthesize::process(const MatrixXR& trajPositions, const MatrixXR& trajMagnitudes, MatrixXR* spectrum){ LOUDIA_DEBUG("PEAKSYNTHESIZE: Processing"); spectrum->resize(trajPositions.rows(), (int)ceil(_fftSize/2.0)); spectrum->setZero(); MatrixXR trajMags; dbToMag(trajMagnitudes, &trajMags); for ( int row = 0 ; row < spectrum->rows(); row++ ) { for ( int i = 0; i < trajPositions.cols(); i++ ) { // If the position is -1 do nothing since it means it is nothing if( trajPositions(row, i) != -1 ){ MatrixXR windowTransform; int begin, end; switch(_windowType){ case Window::RECTANGULAR: // TODO: Implement this window transform case Window::HANN: case Window::HANNING: hannTransform(trajPositions(row, i), trajMags(row, i), _windowSize, _fftSize, &windowTransform, &begin, &end); break; case Window::HAMMING: hammingTransform(trajPositions(row, i), trajMags(row, i), _windowSize, _fftSize, &windowTransform, &begin, &end); break; default: LOUDIA_DEBUG("ERROR: Unknown type of window"); // Throw ValueError unknown window type break; } spectrum->block(0, begin, 1, windowTransform.cols()) += windowTransform.row(0); } } } LOUDIA_DEBUG("PEAKSYNTHESIZE: Finished Processing"); } void PeakSynthesize::reset(){ // Initial values }
[ "email@ricardmarxer.com" ]
email@ricardmarxer.com
59f007dc80aa7a36779eca2ffc1ae6f6c25b0634
759c6913ebc844e031470b2c9309932f0b044e33
/VisualizationBase/src/shapes/SvgShape.h
3ac05e4177a88b1388d92032440b295574986651
[ "BSD-3-Clause" ]
permissive
patrick-luethi/Envision
7a1221960ad1adde2e53e83359992d5e6af97574
9104d8a77e749a9f00ff5eef52ff4a1ea77eac88
refs/heads/master
2021-01-15T11:30:56.335586
2013-05-30T08:51:05
2013-05-30T08:51:05
15,878,040
0
0
null
null
null
null
UTF-8
C++
false
false
2,487
h
/*********************************************************************************************************************** ** ** Copyright (c) 2011, 2013 ETH Zurich ** All rights reserved. ** ** Redistribution and use in source and binary forms, with or without modification, are permitted provided that the ** following conditions are met: ** ** * Redistributions of source code must retain the above copyright notice, this list of conditions and the ** following disclaimer. ** * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the ** following disclaimer in the documentation and/or other materials provided with the distribution. ** * Neither the name of the ETH Zurich nor the names of its contributors may be used to endorse or promote products ** derived from this software without specific prior written permission. ** ** ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, ** INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ** DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR ** SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, ** WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ** **********************************************************************************************************************/ #pragma once #include "../visualizationbase_api.h" #include "Shape.h" #include "SvgShapeStyle.h" namespace Visualization { class VISUALIZATIONBASE_API SvgShape : public Super<Shape> { SHAPE_COMMON(SvgShape) public: SvgShape(Item *parent, StyleType *style = itemStyles().get()); virtual void update(); virtual int contentLeft(); virtual int contentTop(); virtual QSize innerSize(QSize outterSize) const; virtual QSize outterSize(QSize innerSize) const; virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget); private: qreal svgWidth; qreal svgHeight; }; } /* namespace Visualization */
[ "dimitar.asenov@inf.ethz.ch" ]
dimitar.asenov@inf.ethz.ch
1e507507f42c9a6ec4eb3385e9bb797ebcd6acc0
35e9f19ced95c3a481cabeadc50a6f3452713c41
/2018-09-15-xiaohongshu/2_reverse_sub_chain.cpp
1dc21a633d42a152a94b8379cf99c186a9d9aaf1
[]
no_license
Arjen0130/online_test
f62cbb5d5187c21a8a862aecaaafd537c2928124
99ddbf47ba7288a5293866affe6a14e86ea2e070
refs/heads/master
2020-03-28T08:58:49.087683
2018-10-21T10:37:30
2018-10-21T10:37:30
148,004,339
0
0
null
null
null
null
UTF-8
C++
false
false
2,822
cpp
#include <iostream> #include <vector> using namespace std; /* 题目: 给出一个链表,每 k 个节点一组进行翻转,并返回翻转后的链表。 k 是一个正整数,它的值小于或等于链表的长度。 如果节点总数不是 k 的整数倍,那么将最后剩余节点保持原有顺序。 说明: 1. 你需要自行定义链表结构,将输入的数据保存到你的链表中; 2. 你不能只是单纯的改变节点内部的值,而是需要实际的进行节点交换; 3. 你的算法只能使用常数的额外空间。 输入: 第一行输入是链表的值; 第二行输入是 k 的值,k 是大于或等于1的整数; 示例: 输入: 1 2 3 4 5 2 输出: 2 1 4 3 5 */ struct ListNode { int val; struct ListNode *next; ListNode(int x) : val(x), next(NULL) { } }; class Solution { public: void reverseSubChain(int k, int len, ListNode * head) { if (len <= 1) return; if (len < k) return; int num = len / k; ListNode * pre_head = NULL; ListNode * head_tmp = head; ListNode * rear_tmp = NULL; ListNode * rear_next = NULL; for (int i = 0; i < num; i++) { rear_tmp = head_tmp; for (int i = 1; i < k; i++) rear_tmp = rear_tmp->next; rear_next = rear_tmp->next; help(pre_head, head_tmp, rear_tmp, rear_next); pre_head = head_tmp; head_tmp = rear_next; } } private: void help(ListNode * pre_head, ListNode * head, ListNode * rear, ListNode * rear_next) { if (NULL == head) return; ListNode * read_tmp = head; ListNode * rear_tmp = head; while(read_tmp != rear) { ListNode * tmp = read_tmp; read_tmp = read_tmp->next; tmp->next = head; head = tmp; } if (NULL != read_tmp) { read_tmp->next = head; head = read_tmp; } if (NULL != pre_head) { pre_head->next = head; } rear_tmp = rear_next; } }; int main() { Solution solution; int val; cin >> val; ListNode * head = new ListNode(val); int len = 1; ListNode * preNode = head; while(getchar() != '\n') { len++; cin >> val; ListNode * newNode = new ListNode(val); preNode ->next = newNode; preNode = newNode; } int k; cin >> k; solution.reverseSubChain(k, len, head); ListNode * tmp = head; while(NULL != tmp) { cout << tmp->val <<" "; tmp = tmp->next; } cout << endl; return 0; }
[ "zhangrunjie@bytedance.com" ]
zhangrunjie@bytedance.com
f5837248fb671aa221e855aa3283fba363b79d18
b1e844fcdc8a86af21b70608210ab663d5cf71ac
/Shared/TypedDataAccessors.h
5bd486c105e014ff04002bc222288a6ce52a4c9c
[ "Apache-2.0", "LicenseRef-scancode-proprietary-license", "LicenseRef-scancode-generic-cla" ]
permissive
cdessanti/mapd-core
f6b00d0174a03ff02835ad0affb0e72d59544346
8cb912d9a19e03116fcd00b31a03d302d25269b2
refs/heads/master
2021-06-24T03:11:14.461300
2019-02-25T09:05:17
2019-02-25T09:05:17
99,815,884
0
0
Apache-2.0
2018-12-04T13:20:37
2017-08-09T14:11:33
C++
UTF-8
C++
false
false
11,709
h
/* * Copyright 2017 MapD Technologies, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef H_TypedDataAccessors__ #define H_TypedDataAccessors__ #include <math.h> #include <string.h> #include "Shared/DateConverters.h" #include "Shared/sqltypes.h" #ifndef CHECK // if not collide with the one in glog/logging.h #include "always_assert.h" #endif namespace { template <typename LHT, typename RHT> inline void value_truncated(const LHT& lhs, const RHT& rhs) { std::ostringstream os; os << "Value " << rhs << " would be truncated to " << (std::is_same<LHT, uint8_t>::value || std::is_same<LHT, int8_t>::value ? (int64_t)lhs : lhs); throw std::runtime_error(os.str()); }; template <typename T> inline bool is_null(const T& v, const SQLTypeInfo& t) { if (std::is_floating_point<T>::value) return v == inline_fp_null_value<T>(); switch (t.get_logical_size()) { case 1: return v == inline_int_null_value<int8_t>(); case 2: return v == inline_int_null_value<int16_t>(); case 4: return v == inline_int_null_value<int32_t>(); case 8: return v == inline_int_null_value<int64_t>(); default: abort(); } } template <typename LHT, typename RHT> inline bool integer_setter(LHT& lhs, const RHT& rhs, const SQLTypeInfo& t) { const int64_t r = is_null(rhs, t) ? inline_int_null_value<LHT>() : rhs; if ((lhs = r) != r) value_truncated(lhs, r); return true; } inline int get_element_size(const SQLTypeInfo& t) { if (t.is_string_array()) return sizeof(int32_t); if (!t.is_array()) return t.get_size(); return SQLTypeInfo(t.get_subtype(), t.get_dimension(), t.get_scale(), false, t.get_compression(), t.get_comp_param(), kNULLT) .get_size(); } inline bool is_null_string_index(const int size, const int32_t sidx) { switch (size) { case 1: return sidx == inline_int_null_value<uint8_t>(); case 2: return sidx == inline_int_null_value<uint16_t>(); case 4: return sidx == inline_int_null_value<int32_t>(); default: abort(); } } inline int32_t get_string_index(void* ptr, const int size) { switch (size) { case 1: return *(uint8_t*)ptr; case 2: return *(uint16_t*)ptr; case 4: return *(int32_t*)ptr; default: abort(); } } inline bool set_string_index(void* ptr, const SQLTypeInfo& etype, int32_t sidx) { switch (get_element_size(etype)) { case 1: return integer_setter(*(uint8_t*)ptr, sidx, etype); break; case 2: return integer_setter(*(uint16_t*)ptr, sidx, etype); break; case 4: return integer_setter(*(int32_t*)ptr, sidx, etype); break; default: abort(); } } template <typename T> static void put_scalar(void* ndptr, const SQLTypeInfo& etype, const int esize, const T oval) { // round floating oval to nearest integer auto rval = oval; if (std::is_floating_point<T>::value) if (etype.is_integer() || etype.is_time() || etype.is_timeinterval() || etype.is_decimal()) rval = round(rval); switch (etype.get_type()) { case kBOOLEAN: case kTIME: case kTIMESTAMP: case kDATE: case kTINYINT: case kSMALLINT: case kINT: case kBIGINT: case kINTERVAL_DAY_TIME: case kINTERVAL_YEAR_MONTH: case kNUMERIC: case kDECIMAL: switch (esize) { case 1: integer_setter(*(int8_t*)ndptr, rval, etype); break; case 2: integer_setter(*(int16_t*)ndptr, rval, etype); break; case 4: integer_setter(*(int32_t*)ndptr, rval, etype); break; case 8: integer_setter(*(int64_t*)ndptr, rval, etype); break; default: abort(); } break; case kFLOAT: *(float*)ndptr = rval; break; case kDOUBLE: *(double*)ndptr = rval; break; default: if (etype.is_string() && !etype.is_varlen()) set_string_index(ndptr, etype, rval); else abort(); break; } } inline double decimal_to_double(const SQLTypeInfo& otype, int64_t oval) { return oval / pow(10, otype.get_scale()); } template <typename T> inline void put_scalar(void* ndptr, const SQLTypeInfo& ntype, const T oval, const std::string col_name, const SQLTypeInfo* otype = nullptr) { const auto& etype = ntype.is_array() ? SQLTypeInfo(ntype.get_subtype(), ntype.get_dimension(), ntype.get_scale(), ntype.get_notnull(), ntype.get_compression(), ntype.get_comp_param(), kNULLT) : ntype; const auto esize = get_element_size(etype); const auto isnull = is_null(oval, etype); if (etype.get_notnull() && isnull) throw std::runtime_error("NULL value on NOT NULL column '" + col_name + "'"); switch (etype.get_type()) { case kNUMERIC: case kDECIMAL: if (otype && otype->is_decimal()) put_scalar<int64_t>(ndptr, etype, esize, isnull ? inline_int_null_value<int64_t>() : convert_decimal_value_to_scale(oval, *otype, etype)); else put_scalar<T>(ndptr, etype, esize, isnull ? inline_int_null_value<int64_t>() : oval * pow(10, etype.get_scale())); break; case kDATE: // For small dates, we store in days but decode in seconds // therefore we have to scale the decoded value in order to // make value storable. // Should be removed when we refactor code to use DateConverterFactory // from TargetValueConverterFactories so that we would // have everything in one place. if (etype.is_date_in_days()) { put_scalar<T>(ndptr, etype, get_element_size(etype), isnull ? inline_int_null_value<int64_t>() : DateConverters::get_epoch_days_from_seconds( static_cast<int64_t>(oval))); } else { put_scalar<T>(ndptr, etype, get_element_size(etype), oval); } break; default: if (otype && otype->is_decimal()) put_scalar<double>(ndptr, etype, decimal_to_double(*otype, oval), col_name); else put_scalar<T>(ndptr, etype, get_element_size(etype), oval); break; } } inline void put_null(void* ndptr, const SQLTypeInfo& ntype, const std::string col_name) { if (ntype.get_notnull()) throw std::runtime_error("NULL value on NOT NULL column '" + col_name + "'"); switch (ntype.get_type()) { case kBOOLEAN: case kTINYINT: case kSMALLINT: case kINT: case kBIGINT: case kTIME: case kTIMESTAMP: case kDATE: case kINTERVAL_DAY_TIME: case kINTERVAL_YEAR_MONTH: case kNUMERIC: case kDECIMAL: switch (ntype.get_size()) { case 1: *(int8_t*)ndptr = inline_int_null_value<int8_t>(); break; case 2: *(int16_t*)ndptr = inline_int_null_value<int16_t>(); break; case 4: *(int32_t*)ndptr = inline_int_null_value<int32_t>(); break; case 8: *(int64_t*)ndptr = inline_int_null_value<int64_t>(); break; default: abort(); } break; case kFLOAT: *(float*)ndptr = inline_fp_null_value<float>(); break; case kDOUBLE: *(double*)ndptr = inline_fp_null_value<double>(); break; default: //! this f is currently only for putting fixed-size data in place //! this f is not yet for putting var-size or dict-encoded data CHECK(false); } } template <typename T> inline bool get_scalar(void* ndptr, const SQLTypeInfo& ntype, T& v) { switch (ntype.get_type()) { case kBOOLEAN: case kTINYINT: case kSMALLINT: case kINT: case kBIGINT: case kTIME: case kTIMESTAMP: case kDATE: case kINTERVAL_DAY_TIME: case kINTERVAL_YEAR_MONTH: case kNUMERIC: case kDECIMAL: switch (ntype.get_size()) { case 1: return inline_int_null_value<int8_t>() == (v = *(int8_t*)ndptr); case 2: return inline_int_null_value<int16_t>() == (v = *(int16_t*)ndptr); case 4: return inline_int_null_value<int32_t>() == (v = *(int32_t*)ndptr); case 8: return inline_int_null_value<int64_t>() == (v = *(int64_t*)ndptr); break; default: abort(); } break; case kFLOAT: return inline_fp_null_value<float>() == (v = *(float*)ndptr); case kDOUBLE: return inline_fp_null_value<double>() == (v = *(double*)ndptr); case kTEXT: v = get_string_index(ndptr, ntype.get_size()); return is_null_string_index(ntype.get_size(), v); default: abort(); } } template <typename T> inline T get_null_sentinel_for_type(SQLTypeInfo const& ti, T const& tag); template <> inline int64_t get_null_sentinel_for_type<int64_t>(SQLTypeInfo const& ti, int64_t const& tag) { if (ti.is_string()) { if (ti.get_compression() == kENCODING_DICT) { return inline_fixed_encoding_null_val(ti); } else { return 0; // For NONE-Encoded strings } } else { return inline_fixed_encoding_null_val(ti); } } template <> inline double get_null_sentinel_for_type<double>(SQLTypeInfo const& ti, double const& tag) { return inline_fp_null_val(ti); } template <typename T> inline void set_minmax(T& min, T& max, T const val) { if (val < min) { min = val; } if (val > max) { max = val; } } template <typename T> inline void set_minmax(T& min, T& max, int8_t& null_flag, T const val, T null_sentinel) { if (val == null_sentinel) { null_flag |= true; } else { if (val < min) { min = val; } if (val > max) { max = val; } } } template <typename TYPE_INFO, typename T> inline void tabulate_metadata(TYPE_INFO const& ti, T& min, T& max, int8_t& null_flag, T const val) { if (ti.get_notnull()) { set_minmax(min, max, val); } else { set_minmax(min, max, null_flag, val, get_null_sentinel_for_type(ti.get_type(), std::decay_t<T>())); } } } // namespace #endif
[ "dev@aas.io" ]
dev@aas.io
3042be60b62f79109dfae2d558443b49b4e2eecf
a91e52771ee2d33cbc1edf7f926238b5f811f721
/screen_table_empresas.h
a49a6fd929927df00ef7605762f09ed976149480
[]
no_license
lreyesm/MiRutaDesktopClients
9e95917f464e13ab7b9165e2cb1c8241d089f90a
48badeebfbecd59999ed5f8d1f99826adf8cde6e
refs/heads/main
2023-03-08T11:18:12.060521
2021-02-26T00:53:15
2021-02-26T00:53:15
337,887,417
0
0
null
null
null
null
UTF-8
C++
false
false
1,429
h
#ifndef SCREEN_TABLE_EMPRESAS_H #define SCREEN_TABLE_EMPRESAS_H #include <QMainWindow> #include "empresa.h" #include <QStandardItemModel> #include "database_comunication.h" namespace Ui { class Screen_Table_Empresas; } class Screen_Table_Empresas : public QMainWindow { Q_OBJECT public: explicit Screen_Table_Empresas(QWidget *parent = nullptr, bool show = true); ~Screen_Table_Empresas(); void getEmpresasFromServer(bool view = true); signals: void empresasReceived(database_comunication::serverRequestType); void script_excecution_result(int); public slots: void fixModelForTable(QJsonArray); void populateTable(database_comunication::serverRequestType tipo); private slots: void on_pb_nueva_clicked(); void serverAnswer(QByteArray byte_array, database_comunication::serverRequestType tipo); void on_tableView_doubleClicked(const QModelIndex &index); void on_sectionClicked(int logicalIndex); private: Ui::Screen_Table_Empresas *ui; database_comunication database_com; Empresa *oneEmpresaScreen; QStandardItemModel* model = nullptr; bool serverAlredyAnswered =false, connected_header_signal=false; QJsonArray jsonArrayAllEmpresas; void setTableView(); QJsonArray ordenarPor(QJsonArray jsonArray, QString field, QString type); QJsonArray ordenarPor(QJsonArray jsonArray, QString field, int type); }; #endif // SCREEN_TABLE_EMPRESAS_H
[ "elautomaticon@gmail.com" ]
elautomaticon@gmail.com
d00f4a1e8b417a86f3a41b38c443e55cb26aee83
e9f3369247da3435cd63f2d67aa95c890912255c
/problem90.cpp
ea9db8c149a1849e03eb3a08ee1c7b88b8079cdb
[]
no_license
panthitesh6410/problem-solving-C-
27b31a141669b91eb36709f0126be05f241dfb13
24b72fc795b7b5a44e22e5f6ca9faad462a097fb
refs/heads/master
2021-11-15T21:52:33.523503
2021-10-17T16:20:58
2021-10-17T16:20:58
248,523,681
0
0
null
null
null
null
UTF-8
C++
false
false
363
cpp
// GeeksforGeeks : Count Sorted Rows (Samsung) #include<iostream> using namespace std; int main() { int t; cin>>t; for(int i=1;i<=t;i++) { int m, n; cin>>m>>n; int mat[m][n]; for(int j=0;j<m;j++) { for(int k=0;k<n;k++) cin>>mat[j][k]; } } return 0; }
[ "panthitesh6410@gmail.com" ]
panthitesh6410@gmail.com
1c85ed565a77cc8e7b32397b1514125adc72d00a
c55d8939ddcda04afea19bf52e65686e1d48ebf4
/프로그래머스/Level2/소수 만들기/main.cpp
aaab1321f2101303826f7ebe71b308da33708cf1
[]
no_license
LeeKyuTae/Kyugorithm
964c43b55dfd9c78a1aa86d379046ac4c3079e6a
8bb0cb914d04232e73aadbe8562ae88d24747a8a
refs/heads/master
2020-12-04T11:29:59.694417
2020-03-23T14:45:52
2020-03-23T14:45:52
231,747,621
1
0
null
null
null
null
UTF-8
C++
false
false
1,058
cpp
#include <vector> #include <iostream> #include <algorithm> using namespace std; int solution(vector<int> nums) { int answer = 0; int max = 0; // arr[index] == false => primeNumber for(int i=0; i<nums.size(); i++) max += nums[i]; vector<bool>arr(max+1); arr[0] = true; arr[1] = false; for(int i=2; i<=max; i++){ if(arr[i] == false){ for(int j=i*2; j<=max; j += i) arr[j] = true; } } vector<int> combination(nums.size()-3); for(int i=0; i<3; i++) combination.push_back(1); sort(combination.begin(), combination.end()); do{ int result = 0; int count = 0; for(int i=0; i<combination.size(); i++){ if(combination[i] >= 1){ result += nums[i]; count ++; } if(count ==3) break; } if(arr[result] == false) answer ++; }while(next_permutation(combination.begin(), combination.end())); return answer; }
[ "crown0403@khu.ac.kr" ]
crown0403@khu.ac.kr
994e60799a24989247f07db376927938913e7cfd
ea51b10b1137b7dad2b4e5a8240e25b77daf849b
/observer-pattern/consumer.cpp
3a3d168703ee7ae5e88f54f9b0e1ff82c56922f7
[]
no_license
wangxiaoq/design-pattern
fdd04d4ae92d287e169b3931d3fcf678df5b3010
5081c3d2f2ec7d1cc2cb93ae8315c611fc194199
refs/heads/master
2020-03-24T09:49:52.068687
2018-08-08T02:14:32
2018-08-08T02:14:32
142,638,820
0
0
null
null
null
null
UTF-8
C++
false
false
220
cpp
#include <iostream> #include "consumer.h" #include "agent.h" void Consumer::update(void) { Agent *agent = (Agent *)subject; agent->clear_new_house(); std::cout << "receive notify from agent" << std::endl; }
[ "wang_xiaoq@126.com" ]
wang_xiaoq@126.com
708da90ee8a530df97c6950c6a1d865a3f61f8aa
7ec3d49be2387cf50ad7075665487e0ba875213c
/thirdparty/NoesisGUI/Include/NsDrawing/Color.inl
24b128a24a37287f1b1462b1bbf8d435289f7f4f
[]
no_license
mrerro/2D-Game
7a7fc6838dd7b7b76ef1476a06bf5b5997b39ce1
c9697404466783b5489a3366e7bd36ba330b292f
refs/heads/master
2023-01-24T06:34:43.066033
2020-11-20T02:23:09
2020-11-20T02:23:09
null
0
0
null
null
null
null
UTF-8
C++
false
false
6,813
inl
//////////////////////////////////////////////////////////////////////////////////////////////////// // NoesisGUI - http://www.noesisengine.com // Copyright (c) 2013 Noesis Technologies S.L. All Rights Reserved. //////////////////////////////////////////////////////////////////////////////////////////////////// #include <NsCore/Math.h> namespace Noesis { //////////////////////////////////////////////////////////////////////////////////////////////////// inline Color::Color(): r(0.0f), g(0.0f), b(0.0f), a(1.0f) { } //////////////////////////////////////////////////////////////////////////////////////////////////// inline Color::Color(float rr, float gg, float bb, float aa): r(rr), g(gg), b(bb), a(aa) { } //////////////////////////////////////////////////////////////////////////////////////////////////// inline Color::Color(int rr, int gg, int bb, int aa): r(rr / 255.0f), g(gg / 255.0f), b(bb / 255.0f), a(aa / 255.0f) { } //////////////////////////////////////////////////////////////////////////////////////////////////// inline Color Color::FromPackedBGRA(uint32_t color) { return Color(((color >> 16) & 255) / 255.0f, ((color >> 8) & 255) / 255.0f, (color & 255) / 255.0f, (color >> 24) / 255.0f); } //////////////////////////////////////////////////////////////////////////////////////////////////// inline Color Color::FromPackedRGBA(uint32_t color) { return Color((color & 255) / 255.0f, ((color >> 8) & 255) / 255.0f, ((color >> 16) & 255) / 255.0f, (color >> 24) / 255.0f); } //////////////////////////////////////////////////////////////////////////////////////////////////// inline Color Color::FromLinearRGB(float r, float g, float b, float a) { return Color(LinearToSRGB(r), LinearToSRGB(g), LinearToSRGB(b), a); } //////////////////////////////////////////////////////////////////////////////////////////////////// inline uint32_t Color::GetPackedColorBGRA() const { return Noesis::GetPackedColorBGRA(r, g, b, a); } //////////////////////////////////////////////////////////////////////////////////////////////////// inline uint32_t Color::GetPackedColorRGBA() const { return Noesis::GetPackedColorRGBA(r, g, b, a); } //////////////////////////////////////////////////////////////////////////////////////////////////// inline bool Color::operator==(const Color& color) const { return r == color.r && g == color.g && b == color.b && a == color.a; } //////////////////////////////////////////////////////////////////////////////////////////////////// inline bool Color::operator!=(const Color& color) const { return !(*this == color); } //////////////////////////////////////////////////////////////////////////////////////////////////// inline Color Color::Black() { return Color::FromPackedBGRA(0xFF000000); } //////////////////////////////////////////////////////////////////////////////////////////////////// inline Color Color::Blue() { return Color::FromPackedBGRA(0xFF0000FF); } //////////////////////////////////////////////////////////////////////////////////////////////////// inline Color Color::Cyan() { return Color::FromPackedBGRA(0xFF00FFFF); } //////////////////////////////////////////////////////////////////////////////////////////////////// inline Color Color::DarkGray() { return Color::FromPackedBGRA(0xFFA9A9A9); } //////////////////////////////////////////////////////////////////////////////////////////////////// inline Color Color::Gray() { return Color::FromPackedBGRA(0xFF808080); } //////////////////////////////////////////////////////////////////////////////////////////////////// inline Color Color::Green() { return Color::FromPackedBGRA(0xFF00FF00); } //////////////////////////////////////////////////////////////////////////////////////////////////// inline Color Color::LightGray() { return Color::FromPackedBGRA(0xFFD3D3D3); } //////////////////////////////////////////////////////////////////////////////////////////////////// inline Color Color::Magenta() { return Color::FromPackedBGRA(0xFFFF00FF); } //////////////////////////////////////////////////////////////////////////////////////////////////// inline Color Color::Orange() { return Color::FromPackedBGRA(0xFFFFA500); } //////////////////////////////////////////////////////////////////////////////////////////////////// inline Color Color::Pink() { return Color::FromPackedBGRA(0xFFFFC0CB); } //////////////////////////////////////////////////////////////////////////////////////////////////// inline Color Color::Red() { return Color::FromPackedBGRA(0xFFFF0000); } //////////////////////////////////////////////////////////////////////////////////////////////////// inline Color Color::White() { return Color::FromPackedBGRA(0xFFFFFFFF); } //////////////////////////////////////////////////////////////////////////////////////////////////// inline Color Color::Yellow() { return Color::FromPackedBGRA(0xFFFFFF00); } //////////////////////////////////////////////////////////////////////////////////////////////////// inline float SRGBToLinear(float v_) { // http://chilliant.blogspot.com/2012/08/srgb-approximations-for-hlsl.html float v = Clip(v_, 0.0f, 1.0f); return v * (v * (v * 0.305306011f + 0.682171111f) + 0.012522878f); } //////////////////////////////////////////////////////////////////////////////////////////////////// inline float LinearToSRGB(float v_) { // http://chilliant.blogspot.com/2012/08/srgb-approximations-for-hlsl.html float v = Clip(v_, 0.0f, 1.0f); float s1 = sqrtf(v); float s2 = sqrtf(s1); float s3 = sqrtf(s2); return Max(0.585122381f * s1 + 0.783140355f * s2 - 0.368262736f * s3, 0.0f); } //////////////////////////////////////////////////////////////////////////////////////////////////// inline uint32_t GetPackedColorBGRA(float r, float g, float b, float a) { uint32_t red = Clip(Trunc(r * 255.0f), 0, 255); uint32_t green = Clip(Trunc(g * 255.0f), 0, 255); uint32_t blue = Clip(Trunc(b * 255.0f), 0, 255); uint32_t alpha = Clip(Trunc(a * 255.0f), 0, 255); return (alpha << 24) | (red << 16) | (green << 8) | blue; } //////////////////////////////////////////////////////////////////////////////////////////////////// inline uint32_t GetPackedColorRGBA(float r, float g, float b, float a) { uint32_t red = Clip(Trunc(r * 255.0f), 0, 255); uint32_t green = Clip(Trunc(g * 255.0f), 0, 255); uint32_t blue = Clip(Trunc(b * 255.0f), 0, 255); uint32_t alpha = Clip(Trunc(a * 255.0f), 0, 255); return (alpha << 24) | (blue << 16) | (green << 8) | red; } }
[ "jfranciscoguio@gmail.com" ]
jfranciscoguio@gmail.com
abaec5dae82a627566e546fed8cf857f3241c3b8
4cea00f74490cc8397686c7c241f9f1c4e7ff3ff
/Proyecto Base/Proyecto/Source/Game.cpp
aaef425893abf95b748082ee8b6aedf0d56263d0
[]
no_license
UrielAcosta7AV/ProyectoFinal9noEq3
b031a976dc5a630dfe42f943cf913a6fc5dea875
c616c21353cb32fe258ec6213b34b439eedfd7d8
refs/heads/master
2021-01-17T05:53:41.976872
2015-08-26T03:21:06
2015-08-26T03:21:06
38,863,073
1
1
null
null
null
null
UTF-8
C++
false
false
15,042
cpp
#include <stdio.h> #include <stdlib.h> #include "Game.h" #include "Config.h" #include <SDL.h> CGame::CGame(){ estadoJuego = ESTADO_INICIANDO; tiempoFrameInicial = CERO; tick = CERO; atexit(SDL_Quit); //////////////////////////////// //animacion de inicio //translate_nave_x = -800; translate_nave_y = 450; translate_nave_z = -5.f; rotate_nave_x = -95.f; rotate_nave_y = 0.f; rotate_nave_z = 0.f; ///////////////// //translate_naveE_x = -800; translate_naveE_y = 0; translate_naveE_z = -5.f; rotate_naveE_x = -95.f; rotate_naveE_y = 0.f; rotate_naveE_z = 0.f; ///////////////////// } void CGame::IniciandoVideo() { SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3); SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 2); SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE); if (SDL_Init(SDL_INIT_VIDEO) < 0) { SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "Video Init: ", (const char *)SDL_GetError(), NULL); SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Unable to initialize SDL: %s\n", SDL_GetError()); exit(EXIT_FAILURE); } window = SDL_CreateWindow(VERSION, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, WIDTH_SCREEN, HEIGHT_SCREEN, SDL_WINDOW_OPENGL); if (!window) { SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "Windows OpenGL Init: ", (const char *)SDL_GetError(), NULL); SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Unable to create OpenGL window: %s\n", SDL_GetError()); SDL_Quit(); exit(2); } gContext = SDL_GL_CreateContext(window); if (!gContext) { SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "OpenGL Context Init: ", (const char *)SDL_GetError(), NULL); SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Unable to create OpenGL context: %s\n", SDL_GetError()); SDL_Quit(); exit(2); } openGlImplement.setSDLWindow(window); } void CGame::CargandoObjetos() { menuFondo = new Sprite(&openGlImplement, "Menu", -480, 0); textoTitulo = new Sprite(&openGlImplement, "Texto_Titulo", 0, 0); textoNombre = new Sprite(&openGlImplement, "Texto_Nombre", 0, 0); textoOpcion1 = new Sprite(&openGlImplement, "Texto_Opcion1", 0, 0); textoOpcion2 = new Sprite(&openGlImplement, "Texto_Opcion2", 0, 0); textoOpcion1Sel = new Sprite(&openGlImplement, "Texto_Opcion1Sel", 0, 0); textoOpcion2Sel = new Sprite(&openGlImplement, "Texto_Opcion2Sel", 0, 0); nave = new Nave(&openGlImplement, "MiNave", (WIDTH_SCREEN / 2), (HEIGHT_SCREEN - 80), NAVE_PROPIA); jugandoFondo = new Sprite(&openGlImplement, "Jugando", -380, 0);////IMAGEN DE FONDO ANIMACION ganasteFondo = new Sprite(&openGlImplement, "Menu", -480, 0);////IMAGEN DE FONDO ANIMACION GANASTE/PERDISTE perdisteFondo = new Sprite(&openGlImplement, "Menu", -480, 0);////IMAGEN DE FONDO ANIMACION /PERDISTE imgperdiste = new Sprite(&openGlImplement, "fin", 0, 0);////IMAGEN ANIMACION /PERDISTE NAVE ENEMIGO imgfon = new Sprite(&openGlImplement, "fon", 0, 640);////IMAGEN BASUARA ESPACIAL EN JUGANDO img1 = new Sprite(&openGlImplement, "img1", 0, -340);////IMAGEN BASUARA ESPACIAL2 EN JUGANDO youwin = new Sprite(&openGlImplement, "win", 210, 80);///////IMAGEN DE GANASTE youlost = new Sprite(&openGlImplement, "youlost", 210, 80);///TEXTO youlost enter = new Sprite(&openGlImplement, "Enter", 150, 500);///TEXTO ENTER imgganasteNEVE = new Sprite(&openGlImplement, "MiNave", 0, 0);///IMAGEN ANIMACION /PERDISTE NAVE propia basura3 = new Sprite(&openGlImplement, "imgbasura3", 0, 320);////IMAGEN BASUARA ESPACIAL3 EN JUGANDO for (int i = 0; i < MAXIMO_DE_ENEMIGOS; i++) { enemigoArreglo[i] = new Nave(&openGlImplement, "Enemigo", i * 2, 0, NAVE_ENEMIGA); enemigoArreglo[i]->GetNaveObjeto()->SetAutoMovimiento(false); enemigoArreglo[i]->GetNaveObjeto()->SetPasoLimite(4); } opcionSeleccionada = MENU_OPCION1; } // Con esta función eliminaremos todos los elementos en pantalla void CGame::Finalize(){ delete menuFondo; delete textoTitulo; delete textoNombre; delete textoOpcion1; delete textoOpcion2; delete textoOpcion1Sel; delete textoOpcion2Sel; delete nave; delete jugandoFondo; delete ganasteFondo; delete perdisteFondo; delete youlost; delete youwin; delete img1; delete imgfon; delete imgperdiste; delete enter; delete imgganasteNEVE; openGlImplement.QuitShaders(); } bool CGame::Start() { // Esta variable nos ayudara a controlar la salida del juego... int salirJuego = false; while (salirJuego == false){ openGlImplement.DrawStart(); keys = (Uint8*)SDL_GetKeyboardState(NULL); //Maquina de estados switch (estadoJuego){ case Estado::ESTADO_INICIANDO: IniciandoVideo(); openGlImplement.InitGL(); openGlImplement.InitShaders(); CargandoObjetos(); InicializandoStage(); estadoJuego = Estado::ESTADO_MENU; break; case Estado::ESTADO_MENU: MenuActualizar(); MenuPintar(); break; case Estado::ESTADO_PRE_JUGANDO: nivelActual = CERO; vida = UNO; enemigosEliminados = CERO; estadoJuego = ESTADO_JUGANDO; juegoGanado = false; IniciarEnemigo(); IniciarNave(); break; case Estado::ESTADO_JUGANDO: JugandoActualizar(); JugandoPintar(); break; case Estado::ESTADO_FINALIZANDO: salirJuego = true; break; case Estado::ESTADO_TERMINANDO: TerminadoPintar(); TerminadoActualizar(); break; }; openGlImplement.DrawEnd(); while (SDL_PollEvent(&event))//Aqui sdl creara una lista de eventos ocurridos { if (event.type == SDL_QUIT) { salirJuego = true; } //si se detecta una salida del sdl o..... if (event.type == SDL_KEYDOWN) {} } //Calculando fps tiempoFrameFinal = SDL_GetTicks(); while (tiempoFrameFinal < (tiempoFrameInicial + FPS_DELAY)) { tiempoFrameFinal = SDL_GetTicks(); SDL_Delay(1); } tiempoFrameInicial = tiempoFrameFinal; tick++; } return true; } bool CGame::LimitePantalla(Sprite*objeto, int bandera) { if (bandera & BORDE_IZQUIERDO) if (objeto->GetX() <= 0) return true; if (bandera & BORDE_SUPERIOR) if (objeto->GetY() <= 0) return true; if (bandera & BORDE_DERECHO) if (objeto->GetX() >= (WIDTH_SCREEN - objeto->GetW())) return true; if (bandera & BORDE_INFERIOR) if (objeto->GetY() >= HEIGHT_SCREEN - objeto->GetH()) return true; return false; }//Termina LimitePantalla void CGame::MoverEnemigo(){ for (int i = 0; i < nivel[nivelActual].Enemigos_VisiblesAlMismoTiempo; i++) { if (enemigoArreglo[i]->GetNaveObjeto()->ObtenerPasoActual() == 0) if (!LimitePantalla(enemigoArreglo[i]->GetNaveObjeto(), BORDE_DERECHO)) enemigoArreglo[i]->GetNaveObjeto()->MoverLados(nivel[nivelActual].Enemigo_Velocidad);//Derecha else{ enemigoArreglo[i]->GetNaveObjeto()->IncrementarPasoActual(); }//fin else derecho if (enemigoArreglo[i]->GetNaveObjeto()->ObtenerPasoActual() == 1) if (!LimitePantalla(enemigoArreglo[i]->GetNaveObjeto(), BORDE_INFERIOR)) enemigoArreglo[i]->GetNaveObjeto()->MoverArribaAbajo(nivel[nivelActual].Enemigo_Velocidad);//Abajo else{ enemigoArreglo[i]->GetNaveObjeto()->IncrementarPasoActual(); }//Fn else inferior if (enemigoArreglo[i]->GetNaveObjeto()->ObtenerPasoActual() == 2) if (!LimitePantalla(enemigoArreglo[i]->GetNaveObjeto(), BORDE_IZQUIERDO)) enemigoArreglo[i]->GetNaveObjeto()->MoverLados(-nivel[nivelActual].Enemigo_Velocidad);//Izquierda else{ enemigoArreglo[i]->GetNaveObjeto()->IncrementarPasoActual(); }//fin else izquierda if (enemigoArreglo[i]->GetNaveObjeto()->ObtenerPasoActual() == 3) if (!LimitePantalla(enemigoArreglo[i]->GetNaveObjeto(), BORDE_SUPERIOR)) enemigoArreglo[i]->GetNaveObjeto()->MoverArribaAbajo(-nivel[nivelActual].Enemigo_Velocidad);//Arriba else{ enemigoArreglo[i]->GetNaveObjeto()->IncrementarPasoActual(); }//fin else arriba } }//Termina MoverEnemigo void CGame::JugandoPintar(){ ///// ///// jugandoFondo->Draw(); jugandoFondo->translate_x += 1; if (jugandoFondo->translate_x >= 4) { jugandoFondo->translate_x = -380; } /////////////////////////////////////// ///BASURA ESPACIAL img1->Draw(); img1->ScaleXYZ(150.f, 150.f, 150.f); img1->translate_x += 5; img1->translate_y += 2; img1->RotateXYZ(360.f, 360.f, 360.f); if (img1->translate_x >= 1300) { img1->translate_x = 0; img1->translate_y = 0; } imgfon->Draw(); imgfon->ScaleXYZ(30.f, 30.f, 30.f); imgfon->RotateXYZ(rotate_nave_x, rotate_nave_y, rotate_nave_z); imgfon->translate_x += 5; imgfon->translate_y -= 3; if (imgfon->translate_x >= 1800) { imgfon->translate_x = 0; imgfon->translate_y = 640; } /////// basura3->Draw(); basura3->ScaleXYZ(30.f, 30.f, 30.f); basura3->RotateXYZ(rotate_nave_x, rotate_nave_y, rotate_nave_z); basura3->translate_x += 5; /*basura3->translate_y -= 3;*/ if (basura3->translate_x >= 1800) { basura3->translate_x = -100; basura3->translate_y = 320; } ///FIN DE BASURA ESPACIAL /////////////////////////////////////// //////////////////////////////////////// //////// CONTROL DE COLISIONES ///////// for (int i = 0; i < nivel[nivelActual].Enemigos_VisiblesAlMismoTiempo; i++) { if (enemigoArreglo[i]->Colision(nave, Nave::TipoColision::NAVE) || enemigoArreglo[i]->Colision(nave, Nave::TipoColision::BALA))//Nave vs Nave Enemigo vida--; if (nave->Colision(enemigoArreglo[i], Nave::TipoColision::BALA)){//Nave vs Naves Bala enemigoArreglo[i]->setVisible(false); enemigosEliminados++; if (enemigosEliminados < nivel[nivelActual].Enemigo_EliminarPorNivel) { enemigoArreglo[i]->crearNuevo(rand() % (WIDTH_SCREEN - 64)); } } } ///////////////////////////////////////// if (enemigosEliminados >= nivel[nivelActual].Enemigo_EliminarPorNivel) { if (nivelActual < (MAXIMO_DE_NIVELES-1)) nivelActual++; else{ juegoGanado = true; estadoJuego = ESTADO_TERMINANDO; } } if (vida <= CERO) estadoJuego = ESTADO_TERMINANDO; nave->Draw(); for (int i = 0; i < nivel[nivelActual].Enemigos_VisiblesAlMismoTiempo; i++) { enemigoArreglo[i]->Draw(); enemigoArreglo[i]->AutoDisparar(nivel[nivelActual].Enemigo_VelocidadBala); } } void CGame::JugandoActualizar(){ keys = (Uint8 *)SDL_GetKeyboardState(NULL); for (int i = 0; i < nivel[nivelActual].Enemigos_VisiblesAlMismoTiempo; i++) { enemigoArreglo[i]->GetNaveObjeto()->Actualizar(); } MoverEnemigo(); if (keys[SDL_SCANCODE_UP]) { if (!LimitePantalla(nave->GetNaveObjeto(), BORDE_SUPERIOR)) nave->MoverArriba(nivel[nivelActual].Nave_Velocidad); } if (keys[SDL_SCANCODE_DOWN]) { if (!LimitePantalla(nave->GetNaveObjeto(), BORDE_INFERIOR)) nave->MoverAbajo(nivel[nivelActual].Nave_Velocidad); } if (keys[SDL_SCANCODE_LEFT]) { if (!LimitePantalla(nave->GetNaveObjeto(), BORDE_IZQUIERDO)) nave->MoverIzquierda(nivel[nivelActual].Nave_Velocidad); } if (keys[SDL_SCANCODE_RIGHT]) { if (!LimitePantalla(nave->GetNaveObjeto(), BORDE_DERECHO)) nave->MoverDerecha(nivel[nivelActual].Nave_Velocidad); } if (keys[SDL_SCANCODE_ESCAPE]) { estadoJuego = Estado::ESTADO_MENU; } if (keys[SDL_SCANCODE_SPACE]) { nave->Disparar(nivel[nivelActual].Nave_BalasMaximas); } if (keys[SDL_SCANCODE_C]){//nuestra bala / nave enemigo int enemigoAEliminar = rand() % nivel[nivelActual].Enemigos_VisiblesAlMismoTiempo; //enemigoArreglo[enemigoAEliminar]->simularColision(true); } if (keys[SDL_SCANCODE_V]){//nuestra nave / nave enemigo } } void CGame::MenuActualizar() { if (keys[SDL_SCANCODE_UP]) { opcionSeleccionada = MENU_OPCION1; } if (keys[SDL_SCANCODE_DOWN]) { opcionSeleccionada = MENU_OPCION2; } if (keys[SDL_SCANCODE_RETURN]) { if (opcionSeleccionada == MENU_OPCION1) { estadoJuego = Estado::ESTADO_PRE_JUGANDO; } if (opcionSeleccionada == MENU_OPCION2) { estadoJuego = Estado::ESTADO_FINALIZANDO; } }// SDL_SCANCODE__return } void CGame::MenuPintar() { menuFondo->Draw(); menuFondo->translate_x += 1; if (menuFondo->translate_x >= 5) { menuFondo->translate_x = -480; } ////// textoTitulo->TranslateXYDraw(WIDTH_SCREEN / 3, 0); /////////////////////////////////////////////////// //animacion de inicio //textoNombre->TranslateXY( WIDTH_SCREEN / 3, 450 -2.f);//570 textoNombre->TranslateXY( WIDTH_SCREEN / 5, 450);//570>>>>>>> .r6 textoNombre->Draw(); /////////////// ////////////// ///////////////// textoOpcion1->TranslateXYDraw(240, 220); textoOpcion2->TranslateXYDraw(240, 220 + 30); if (opcionSeleccionada == MENU_OPCION1){ //textoOpcion1Sel->TranslateXYDraw(320, 220); textoOpcion1Sel->TranslateXYDraw(-32, 0); textoOpcion1Sel->TranslateXYZ(translate_nave_x, translate_nave_y, translate_nave_z);//570 textoOpcion1Sel->ScaleXYZ(30.f, 30.f, 30.f); textoOpcion1Sel->RotateXYZ(rotate_nave_x, rotate_nave_y, rotate_nave_z = 0);//======= //textoNombre->TranslateXY( WIDTH_SCREEN / 3, 450);//570>>>>>>> .r6 textoOpcion1Sel->Draw(); } else textoOpcion2Sel->TranslateXYDraw(-32, 120); //textoOpcion2Sel->TranslateXYDraw(300, 200 ); textoOpcion2Sel->TranslateXYZ(translate_nave_x, translate_nave_y, translate_nave_z);//570 textoOpcion2Sel->ScaleXYZ(30.f, 30.f, 30.f); textoOpcion2Sel->RotateXYZ(rotate_nave_x, rotate_nave_y, rotate_nave_z);//======= }//void void CGame::IniciarEnemigo(){ for (int i = 0; i < nivel[nivelActual].Enemigos_VisiblesAlMismoTiempo; i++) enemigoArreglo[i]->crearNuevo(rand() % (WIDTH_SCREEN - 64)); } void CGame::IniciarNave(){ nave->crearNuevo(WIDTH_SCREEN / 2); } void CGame::TerminadoPintar(){ if (juegoGanado) { ganasteFondo->Draw(); youwin->Draw(); enter->Draw(); ganasteFondo->translate_x += 1; if (ganasteFondo->translate_x >= 4) { ganasteFondo->translate_x = -480; } imgganasteNEVE->TranslateXYDraw(450, 320); imgganasteNEVE->TranslateXYZ(translate_nave_x, translate_nave_y, translate_nave_z); imgganasteNEVE->ScaleXYZ(100.f, 100.f, 100.f); imgganasteNEVE->RotateXYZ(rotate_nave_x, rotate_nave_y, rotate_nave_z); imgganasteNEVE->Draw(); } else perdisteFondo->Draw(); youlost->Draw(); enter->Draw(); perdisteFondo->translate_x += 1; if (perdisteFondo->translate_x >= 4) { perdisteFondo->translate_x = -480; } imgperdiste->TranslateXYDraw(450, 320); imgperdiste->TranslateXYZ(translate_nave_x, translate_nave_y, translate_nave_z); imgperdiste->ScaleXYZ(180.f, 180.f, 180.f); imgperdiste->RotateXYZ(rotate_nave_x, rotate_nave_y, rotate_nave_z); imgperdiste->Draw(); } void CGame::TerminadoActualizar(){ if (keys[SDL_SCANCODE_RETURN]){ estadoJuego = Estado::ESTADO_MENU; } }
[ "uriel_3777@hotmail.com" ]
uriel_3777@hotmail.com
a6d167a1e2ab58ae1f31da8728e30c296ded0aa3
7bb6396040762172fa68873f893f95bab6382393
/src/aes.cpp
9c5f4ae4f4b3364d764edf9efc7195892a42cc10
[ "MIT", "LicenseRef-scancode-warranty-disclaimer" ]
permissive
7thSamurai/steganography
29ac00508aeb5e55f22c0805d6877e8b14dbf6ec
6ba5d96e4a3fd1768697239197df2dc058054b80
refs/heads/main
2022-12-20T11:59:42.574192
2022-10-29T20:06:41
2022-10-29T20:06:41
553,771,946
882
45
MIT
2022-10-29T19:46:28
2022-10-18T18:40:17
C++
UTF-8
C++
false
false
9,331
cpp
#include <iomanip> #include <algorithm> #include <cassert> #include "aes.hpp" #include "utils.hpp" // Rijndael S-box static std::uint8_t sbox[256]; static std::uint8_t inv_sbox[256]; static std::uint8_t mul2 [256]; static std::uint8_t mul3 [256]; static std::uint8_t mul9 [256]; static std::uint8_t mul11[256]; static std::uint8_t mul13[256]; static std::uint8_t mul14[256]; static std::uint8_t rcon[256]; static std::uint8_t gmul(std::uint8_t a, std::uint8_t b) { std::uint8_t p = 0; for (int i = 0; i < 8; i++) { if (b & 1) p ^= a; bool hi_bit_set = a & 0x80; a <<= 1; if (hi_bit_set) a ^= 0x1b; b >>= 1; } return p; } static void build_tables() { static bool built_tables = false; if (built_tables) return; built_tables = true; // Build the S-box std::uint8_t p = 1, q = 1; do { p = p ^ (p << 1) ^ (p & 0x80 ? 0x1B : 0x00); q ^= q << 1; q ^= q << 2; q ^= q << 4; q ^= q & 0x80 ? 0x09 : 0x00; std::uint8_t xformed = (q ^ rotl(q, 1) ^ rotl(q, 2) ^ rotl(q, 3) ^ rotl(q, 4)) ^ 0x63; sbox[p] = xformed; inv_sbox[xformed] = p; } while(p != 1); sbox [0x00] = 0x63; inv_sbox[0x63] = 0x00; // Multiplication Tables for (int i = 0; i < 256; i++) { mul2 [i] = gmul(i, 2); mul3 [i] = gmul(i, 3); mul9 [i] = gmul(i, 9); mul11[i] = gmul(i, 11); mul13[i] = gmul(i, 13); mul14[i] = gmul(i, 14); } for (int i = 1; i < 256; i++) { rcon[i] = 1; for (int j = i; j != 1; j--) rcon[i] = gmul(rcon[i], 2); } } AES::AES(const std::uint8_t *key, const std::uint8_t *iv) { build_tables(); expand_key(key); std::copy_n(iv, block_len, this->iv); } void AES::cbc_encrypt(void *data, std::size_t size, void *result) { assert(size % block_len == 0); auto in = static_cast<std::uint8_t*>(data); auto out = static_cast<std::uint8_t*>(result); std::uint8_t *iv = this->iv; for (std::size_t i = 0; i < size; i += block_len) { xor_with_iv(in, iv); encrypt_block(in, out); iv = out; in += block_len; out += block_len; } std::copy_n(iv, block_len, this->iv); } void AES::cbc_decrypt(void *data, std::size_t size, void *result) { assert(size % block_len == 0); auto in = static_cast<std::uint8_t*>(data); auto out = static_cast<std::uint8_t*>(result); std::uint8_t *iv = this->iv; for (std::size_t i = 0; i < size; i += block_len) { decrypt_block(in, out); xor_with_iv(out, iv); iv = in; in += block_len; out += block_len; } std::copy_n(iv, block_len, this->iv); } inline void AES::add_round_key(State state, const State round_key, int round) { for (int i = 0; i < 0x10; i++) state[i] ^= round_key[(round * 16) + i]; } inline void AES::sub_bytes(State state) { for (int i = 0; i < 0x10; i++) state[i] = sbox[state[i]]; } inline void AES::shift_rows(State state) { State tmp; // Column 1 tmp[0x00] = state[0x00]; tmp[0x01] = state[0x05]; tmp[0x02] = state[0x0a]; tmp[0x03] = state[0x0f]; // Column 2 tmp[0x04] = state[0x04]; tmp[0x05] = state[0x09]; tmp[0x06] = state[0x0e]; tmp[0x07] = state[0x03]; // Column 3 tmp[0x08] = state[0x08]; tmp[0x09] = state[0x0d]; tmp[0x0a] = state[0x02]; tmp[0x0b] = state[0x07]; // Column 4 tmp[0x0c] = state[0x0c]; tmp[0x0d] = state[0x01]; tmp[0x0e] = state[0x06]; tmp[0x0f] = state[0x0b]; std::copy_n(tmp, block_len, state); } inline void AES::mix_columns(State state) { State tmp; // Column 1 tmp[0x00] = mul2[state[0]] ^ mul3[state[1]] ^ state[2] ^ state[3]; tmp[0x01] = state[0] ^ mul2[state[1]] ^ mul3[state[2]] ^ state[3]; tmp[0x02] = state[0] ^ state[1] ^ mul2[state[2]] ^ mul3[state[3]]; tmp[0x03] = mul3[state[0]] ^ state[1] ^ state[2] ^ mul2[state[3]]; // Column 2 tmp[0x04] = mul2[state[4]] ^ mul3[state[5]] ^ state[6] ^ state[7]; tmp[0x05] = state[4] ^ mul2[state[5]] ^ mul3[state[6]] ^ state[7]; tmp[0x06] = state[4] ^ state[5] ^ mul2[state[6]] ^ mul3[state[7]]; tmp[0x07] = mul3[state[4]] ^ state[5] ^ state[6] ^ mul2[state[7]]; // Column 3 tmp[0x08] = mul2[state[8]] ^ mul3[state[9]] ^ state[10] ^ state[11]; tmp[0x09] = state[8] ^ mul2[state[9]] ^ mul3[state[10]] ^ state[11]; tmp[0x0a] = state[8] ^ state[9] ^ mul2[state[10]] ^ mul3[state[11]]; tmp[0x0b] = mul3[state[8]] ^ state[9] ^ state[10] ^ mul2[state[11]]; // Column 4 tmp[0x0c] = mul2[state[12]] ^ mul3[state[13]] ^ state[14] ^ state[15]; tmp[0x0d] = state[12] ^ mul2[state[13]] ^ mul3[state[14]] ^ state[15]; tmp[0x0e] = state[12] ^ state[13] ^ mul2[state[14]] ^ mul3[state[15]]; tmp[0x0f] = mul3[state[12]] ^ state[13] ^ state[14] ^ mul2[state[15]]; std::copy_n(tmp, block_len, state); } inline void AES::inverse_sub_bytes(State state) { for (int i = 0; i < 0x10; i++) state[i] = inv_sbox[state[i]]; } inline void AES::inverse_shift_rows(State state) { State tmp; // Column 1 tmp[0x00] = state[0x00]; tmp[0x01] = state[0x0d]; tmp[0x02] = state[0x0a]; tmp[0x03] = state[0x07]; // Column 2 tmp[0x04] = state[0x04]; tmp[0x05] = state[0x01]; tmp[0x06] = state[0x0e]; tmp[0x07] = state[0x0b]; // Column 3 tmp[0x08] = state[0x08]; tmp[0x09] = state[0x05]; tmp[0x0a] = state[0x02]; tmp[0x0b] = state[0x0f]; // Column 4 tmp[0x0c] = state[0x0c]; tmp[0x0d] = state[0x09]; tmp[0x0e] = state[0x06]; tmp[0x0f] = state[0x03]; std::copy_n(tmp, block_len, state); } inline void AES::inverse_mix_columns(State state) { State tmp; tmp[0x00] = mul14[state[0]] ^ mul11[state[1]] ^ mul13[state[2]] ^ mul9[state[3]]; tmp[0x01] = mul9[state[0]] ^ mul14[state[1]] ^ mul11[state[2]] ^ mul13[state[3]]; tmp[0x02] = mul13[state[0]] ^ mul9[state[1]] ^ mul14[state[2]] ^ mul11[state[3]]; tmp[0x03] = mul11[state[0]] ^ mul13[state[1]] ^ mul9[state[2]] ^ mul14[state[3]]; tmp[0x04] = mul14[state[4]] ^ mul11[state[5]] ^ mul13[state[6]] ^ mul9[state[7]]; tmp[0x05] = mul9[state[4]] ^ mul14[state[5]] ^ mul11[state[6]] ^ mul13[state[7]]; tmp[0x06] = mul13[state[4]] ^ mul9[state[5]] ^ mul14[state[6]] ^ mul11[state[7]]; tmp[0x07] = mul11[state[4]] ^ mul13[state[5]] ^ mul9[state[6]] ^ mul14[state[7]]; tmp[0x08] = mul14[state[8]] ^ mul11[state[9]] ^ mul13[state[10]] ^ mul9[state[11]]; tmp[0x09] = mul9[state[8]] ^ mul14[state[9]] ^ mul11[state[10]] ^ mul13[state[11]]; tmp[0x0a] = mul13[state[8]] ^ mul9[state[9]] ^ mul14[state[10]] ^ mul11[state[11]]; tmp[0x0b] = mul11[state[8]] ^ mul13[state[9]] ^ mul9[state[10]] ^ mul14[state[11]]; tmp[0x0c] = mul14[state[12]] ^ mul11[state[13]] ^ mul13[state[14]] ^ mul9[state[15]]; tmp[0x0d] = mul9[state[12]] ^ mul14[state[13]] ^ mul11[state[14]] ^ mul13[state[15]]; tmp[0x0e] = mul13[state[12]] ^ mul9[state[13]] ^ mul14[state[14]] ^ mul11[state[15]]; tmp[0x0f] = mul11[state[12]] ^ mul13[state[13]] ^ mul9[state[14]] ^ mul14[state[15]]; std::copy_n(tmp, block_len, state); } inline void AES::xor_with_iv(std::uint8_t *data, const std::uint8_t *iv) { for (std::size_t i = 0; i < block_len; i++) data[i] ^= iv[i]; } void AES::encrypt_block(const std::uint8_t *in, std::uint8_t *out) { State state; std::copy_n(in, block_len, state); add_round_key(state, expanded_key, 0); for (int i = 0; i < 13; i++) { sub_bytes(state); shift_rows(state); mix_columns(state); add_round_key(state, expanded_key, i+1); } sub_bytes(state); shift_rows(state); add_round_key(state, expanded_key, 14); std::copy_n(state, block_len, out); } void AES::decrypt_block(const std::uint8_t *in, std::uint8_t *out) { State state; std::copy_n(in, block_len, state); add_round_key(state, expanded_key, 14); for (int i = 12; i >= 0; i--) { inverse_shift_rows(state); inverse_sub_bytes(state); add_round_key(state, expanded_key, i+1); inverse_mix_columns(state); } inverse_shift_rows(state); inverse_sub_bytes(state); add_round_key(state, expanded_key, 0); std::copy_n(state, block_len, out); } void AES::schedule_core(std::uint8_t *in, unsigned int i) { std::uint8_t t = in[0]; in[0] = in[1]; in[1] = in[2]; in[2] = in[3]; in[3] = t; in[0] = sbox[in[0]]; in[1] = sbox[in[1]]; in[2] = sbox[in[2]]; in[3] = sbox[in[3]]; in[0] ^= rcon[i]; } void AES::expand_key(const std::uint8_t *in) { std::copy_n(in, 32, expanded_key); std::uint8_t t[4]; std::uint8_t c = 32; std::uint8_t i = 1; while (c < 240) { for (int a = 0; a < 4; a++) t[a] = expanded_key[a + c - 4]; if ((c & 31) == 0) schedule_core(t, i++); if ((c & 31) == 16) { for (int a = 0; a < 4; a++) t[a] = sbox[t[a]]; } for (int a = 0; a < 4; a++) { expanded_key[c] = expanded_key[c - 32] ^ t[a]; c++; } } }
[ "programmer255@pm.me" ]
programmer255@pm.me
9cd43eeb36f006ae0f197c758572e016086f21e3
ac518a66983f1a8080ca6b4beab7b17eeb706fe7
/zmq+protobuf/include/Publisher.h
cf7a06bc7db5d3533b70d989619bcb8f1e976f23
[]
no_license
EgalYue/comm_performance_compare
db752b13c2fb64ea3e1f245ba78e01b601e08f19
57916a414f9d1632cd36f01b9dc716d74d031525
refs/heads/master
2022-06-10T14:32:18.994599
2020-05-13T09:21:55
2020-05-13T09:21:55
263,582,022
0
0
null
null
null
null
UTF-8
C++
false
false
499
h
// // Created by yuehu on 2020/4/14. // #ifndef SEGWAY_ROS_SAMPLE_PUBLISHER_H #define SEGWAY_ROS_SAMPLE_PUBLISHER_H #include <iostream> #include <vector> #include <string> #include "util.h" #include <zmq.h> class Publisher { public: Publisher(); ~Publisher(); void init(const char* endpoint); int pubFrame(FrameImage *frame); private: void *m_context; void *m_publisher; char m_endpoint[100]; zmq_msg_t m_pub_msg; }; #endif //SEGWAY_ROS_SAMPLE_PUBLISHER_H
[ "yue.hu@ninebot.com" ]
yue.hu@ninebot.com
693a27a7b8733408ee563e229a07e10cbe7cff09
278efcf294e827aed58fb1439ed2d217c4f84d0e
/task3/Laptop.h
1ced288b6710438145abf0383605289422454a5b
[ "MIT" ]
permissive
fobo66/OOPLabs
e1f9e38158aef30259d63b12a8e57454de0c38dd
795495766e42c6b46ab0ab70c938f3498eb851d6
refs/heads/master
2021-01-19T16:47:15.351147
2017-05-26T10:49:17
2017-05-26T10:49:17
88,287,295
0
0
null
null
null
null
UTF-8
C++
false
false
812
h
#pragma once #include "Portative.h" namespace comp { class Laptop : public Portative { private: std::string vendor; std::string model; public: Laptop() {}; Laptop(int year, std::string os, float weight, bool touch, std::string vendor, std::string model) : Portative(year, os, weight, touch) { this->vendor = vendor; this->model = model; }; std::string getVendor(); std::string getModel(); void setVendor(std::string); void setModel(std::string); bool operator>(const Laptop &); bool operator<(const Laptop &); bool operator>=(const Laptop &); bool operator<=(const Laptop &); bool operator==(const Laptop &); bool operator!=(const Laptop &); void header(); void show(); friend std::istream & operator>>(std::istream &, Laptop &); ~Laptop() {}; }; }
[ "fobo66@protonmail.com" ]
fobo66@protonmail.com
2eade392682645ef01d0a48a2ebccfd0aaafc681
877fff5bb313ccd23d1d01bf23b1e1f2b13bb85a
/app/src/main/cpp/dir7941/dir7942/dir8062/dir8063/dir12766/dir12767/dir13029/dir15097/dir15260/dir15321/dir17491/file17611.cpp
5fb19e27cc1f0c2b0788139aeabfe67dfde1bf3e
[]
no_license
tgeng/HugeProject
829c3bdfb7cbaf57727c41263212d4a67e3eb93d
4488d3b765e8827636ce5e878baacdf388710ef2
refs/heads/master
2022-08-21T16:58:54.161627
2020-05-28T01:54:03
2020-05-28T01:54:03
267,468,475
0
0
null
null
null
null
UTF-8
C++
false
false
115
cpp
#ifndef file17611 #error "macro file17611 must be defined" #endif static const char* file17611String = "file17611";
[ "tgeng@google.com" ]
tgeng@google.com
9ff5a133bfb0309901843c577ac44d5804cb7f80
948d555823c2d123601ff6c149869be377521282
/SDK/SOT_BP_IslandStorageBarrel_Single_01_a_parameters.hpp
a7d12fb102b2e6b4986a074e0908c48b1551f5d6
[]
no_license
besimbicer89/SoT-SDK
2acf79303c65edab01107ab4511e9b9af8ab9743
3a4c6f3b77c1045b7ef0cddd064350056ef7d252
refs/heads/master
2022-04-24T01:03:37.163407
2020-04-27T12:45:47
2020-04-27T12:45:47
null
0
0
null
null
null
null
UTF-8
C++
false
false
534
hpp
#pragma once // SeaOfThieves (1.6.4) SDK #ifdef _MSC_VER #pragma pack(push, 0x8) #endif #include "../SDK.hpp" namespace SDK { //--------------------------------------------------------------------------- //Parameters //--------------------------------------------------------------------------- // Function BP_IslandStorageBarrel_Single_01_a.BP_IslandStorageBarrel_Single_01_a_C.UserConstructionScript struct ABP_IslandStorageBarrel_Single_01_a_C_UserConstructionScript_Params { }; } #ifdef _MSC_VER #pragma pack(pop) #endif
[ "getpeyton@gmail.com" ]
getpeyton@gmail.com
85c4f01015dee9e0ba4e1dc0ea7b4047c4df9dcd
64a71ce005efd1733bfcf8268ea1455f6f6c05ea
/Neural Net/AttributeDialog.h
6b177d72c48f9992cfaea1465d38e8b865dff07c
[]
no_license
sdiersen/Neural-Net
28b924b1645b4880d329e6a66ec9f5e86a892c70
297c0c5a8fec644220b407530fab21d733b0f7a9
refs/heads/master
2023-03-04T22:01:01.922211
2021-02-12T23:30:11
2021-02-12T23:30:11
334,412,152
0
0
null
null
null
null
UTF-8
C++
false
false
863
h
#pragma once #include "afxwin.h" // CAttributeDialog dialog class CAttributeDialog : public CDialogEx { DECLARE_DYNAMIC(CAttributeDialog) public: CAttributeDialog(CWnd* pParent = NULL); // standard constructor virtual ~CAttributeDialog(); // Dialog Data enum { IDD = IDD_ENTERATTRIBUTEDLG }; protected: virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support DECLARE_MESSAGE_MAP() public: CEdit nameControl; CEdit minControl; CEdit maxControl; CEdit friControl; CEdit errorControl; CButton validateControl; CButton okControl; CString name; double minRange; double maxRange; double fri; CString error; afx_msg void OnEnChangeEaAttributename(); afx_msg void OnEnChangeEaAttributemin(); afx_msg void OnEnChangeEaAttributemax(); afx_msg void OnEnChangeEaAttributefri(); afx_msg void OnBnClickedEaAttributevalidate(); };
[ "srdiersen@gmail.com" ]
srdiersen@gmail.com
643bca4228a044248a6e7f1e08792214c0caf6cf
85314b20f215749013aa76fa6eefdf3a14810369
/mp32wav/src/MpegDecoderImpl.cpp
975c5e90fdc5c3eba4ba17dffa3b01398123f064
[ "MIT" ]
permissive
dissabte/mp32wav
1f3a8e3ab2011493698f4cdfd339555eecbebf52
6b3e8e08f94df0db84ff99fe4bdf5f6aa92c7cee
refs/heads/master
2020-12-03T06:53:38.221867
2016-09-01T07:19:21
2016-09-01T16:04:26
66,386,551
3
0
null
null
null
null
UTF-8
C++
false
false
9,929
cpp
#include "MpegDecoderImpl.h" #include "AudioUtililty.h" #include <limits> #include <algorithm> #include <cstring> #include <iostream> const uint32_t MpegDecoder::Implementation::kDefaultNumberOfSamples = std::numeric_limits<uint32_t>::max(); MpegDecoder::Implementation::Implementation() : _globalFlags(nullptr) , _hipGlobalFlags(nullptr) , _mp3data{} { initializeLame(); } MpegDecoder::Implementation::~Implementation() { } void MpegDecoder::Implementation::initializeLame() { if (_globalFlags != nullptr) { std::cerr << "Lame is already initialized\n"; return; } _globalFlags = lame_init(); if (_globalFlags == nullptr) { std::cerr << "Couldn't initialize libmp3lame\n"; return; } // TODO: setup output //hip_set_msgf(global.hip, global_ui_config.silent < 10 ? &frontend_msgf : 0); //hip_set_errorf(global.hip, global_ui_config.silent < 10 ? &frontend_errorf : 0); //hip_set_debugf(global.hip, &frontend_debugf); } bool MpegDecoder::Implementation::openFile(const std::string& fileName) { if (_globalFlags == nullptr) { std::cerr << "openMpegFile: lame is not initialized\n"; return false; } lame_set_num_samples(_globalFlags, kDefaultNumberOfSamples); // TODO: take care of unicode filenames etc., pass filename here _inputFile.setPath(fileName); if (!_inputFile.open(AudioFile::ReadOnly)) return false; while (mpegFrameHeaderFound(_inputFile)) { if (decodeMp3Frame(_inputFile, _mp3data)) { if (-1 == lame_set_num_channels(_globalFlags, _mp3data.stereo)) { std::cerr << "Unsupported number of channels: " << _mp3data.stereo << std::endl; return false; } lame_set_in_samplerate(_globalFlags, _mp3data.samplerate); lame_set_num_samples(_globalFlags, _mp3data.nsamp); if (lame_get_num_samples(_globalFlags) == kDefaultNumberOfSamples) { const double fileSize = static_cast<double>(_inputFile.size()); if (fileSize >= 0) { // try file size, assume 2 bytes per sample if (_mp3data.bitrate > 0) { const double totalseconds = (fileSize * 8.0 / (1000.0 * _mp3data.bitrate)); const unsigned long tmp_num_samples = static_cast<unsigned long>(totalseconds * lame_get_in_samplerate(_globalFlags)); lame_set_num_samples(_globalFlags, tmp_num_samples); _mp3data.nsamp = tmp_num_samples; } } } // libmp3lame note: // turn off automatic writing of ID3 tag data into mp3 stream // we have to call it before 'lame_init_params', because that // function would spit out ID3v2 tag data. lame_set_write_id3tag_automatic(_globalFlags, 0); // libmp3lame note: // Now that all the options are set, lame needs to analyze them and // set some more internal options and check for problems int returnValue = lame_init_params(_globalFlags); if (returnValue < 0) { std::cerr << "Fatal error during Lame initialization (" << returnValue << ")\n"; return false; } return true; } } return false; } bool MpegDecoder::Implementation::mpegFrameHeaderFound(AudioFile& file) { if (!readId3v2Tag(file, _id3v2Tag)) return false; if (!skipAlbumIDHeader(file)) return false; if (!anySaneMpegFrameFound(file)) return false; return true; } bool MpegDecoder::Implementation::readId3v2Tag(AudioFile& file, std::vector<char>& id3v2Tag) { const size_t kHeaderSize = 10; char header[kHeaderSize] = {}; file.seek(0); id3v2Tag.clear(); if (kHeaderSize != file.read(header, kHeaderSize)) return false; bool tagAlreadyFound = false; while (header[0] == 'I' && header[1] == 'D' && header[2] == '3') { const size_t tagSize = id3v2TagLength(&header[6]); if (tagAlreadyFound) { file.seek(tagSize, File::SeekFromCurrent); } else { id3v2Tag.insert(std::begin(id3v2Tag), header, header + kHeaderSize); id3v2Tag.resize(kHeaderSize + tagSize); if (tagSize != static_cast<size_t>(file.read(&id3v2Tag[kHeaderSize], tagSize))) return false; tagAlreadyFound = true; } if (kHeaderSize != file.read(header, kHeaderSize)) return false; } file.seek(-kHeaderSize, File::SeekFromCurrent); return true; } bool MpegDecoder::Implementation::skipAlbumIDHeader(AudioFile& file) { const size_t kHeaderSize = 6; char header[kHeaderSize] = {}; if (kHeaderSize != file.read(header, kHeaderSize)) return false; if (0 == std::memcmp(header, "AiD\1", 4)) { const size_t headerDataSize = static_cast<unsigned char>(header[4]) + 256 * static_cast<unsigned char>(header[5]); if (!file.seek(headerDataSize, File::SeekFromCurrent)) return false; } else { file.seek(-kHeaderSize, File::SeekFromCurrent); } return true; } bool MpegDecoder::Implementation::anySaneMpegFrameFound(AudioFile& file) { const size_t kMpegFrameHeaderSize = 4; const size_t kBufferSize = kMpegFrameHeaderSize * 2; const size_t kSizeToRead = kBufferSize - kMpegFrameHeaderSize; // consequent reads size const size_t kOffsetLimit = kSizeToRead - 1; // to know when to read next headers char mpegFrameHeaders[kBufferSize]; if (kBufferSize != file.read(mpegFrameHeaders, kBufferSize)) return false; size_t frameStartOffset = 0; while(!mpegFrameIsSane(mpegFrameHeaders + frameStartOffset)) { if (frameStartOffset == kOffsetLimit) { frameStartOffset = 0; std::memcpy(mpegFrameHeaders, mpegFrameHeaders + kSizeToRead, kMpegFrameHeaderSize); if (kSizeToRead != file.read(mpegFrameHeaders + kMpegFrameHeaderSize, kSizeToRead)) return false; } else { frameStartOffset++; } } file.seek(-kMpegFrameHeaderSize, File::SeekFromCurrent); return true; } bool MpegDecoder::Implementation::mpegFrameIsSane(const char* buffer) { const unsigned char* frame = reinterpret_cast<const unsigned char*>(buffer); // frame sync, 11 bits, all must be 1 if ((frame[0] & 0b11111111) != 0b11111111) return false; if ((frame[1] & 0b11100000) != 0b11100000) return false; // version id, 2 bits, valid values are 00, 10, 11. unsigned char versionId = (frame[1] & 0b00011000) >> 3; switch(versionId) { case 0b00: _version = MPEG2_5; break; case 0b10: _version = MPEG2; break; case 0b11: _version = MPEG1; break; case 0b01: default: return false; } // layer id, 2 bits, valid values are 01, 10, 11 const unsigned char layerId = (frame[1] & 0b00000110) >> 1; switch (layerId) { default: case 0b00: return false; case 0b01: _layer = 3; break; case 0b10: _layer = 2; break; case 0b11: _layer = 1; break; } // bitrate index, 4 bits, value 1111 is not used, 0000 means free format const unsigned char bitrateIndex = (frame[2] & 0b11110000) >> 4; if (bitrateIndex == 0b1111) return false; _freeFormat = bitrateIndex == 0x0000; // check allowed mode/bitrate for MPEG v1 Layer 2 if (versionId == 0b11 && layerId == 0b10) { // channel mode, 2 bits, 00 - stereo, 01 - joint stereo, 10 - dual channel, 11 - single channel const unsigned char channelMode = (frame[3] & 0b11000000) >> 6; enum ChannelModeGroup { Mono, Stereo, All }; const ChannelModeGroup channelModeGroup = (channelMode == 0b11) ? Mono : Stereo; // TODO: is free format counted? (bitrate index == 0) const ChannelModeGroup allowedModesForLayer2[16] = {All, Mono, Mono, Mono, All, Mono, All, All, All, All, All, Stereo, Stereo, Stereo, Stereo, Stereo}; const bool channelModeAllowed = allowedModesForLayer2[bitrateIndex] == channelModeGroup || allowedModesForLayer2[bitrateIndex] == All; if (!channelModeAllowed) return false; } // sampling frequency index, 2 bits, value 11 is reserved unsigned char samplingFrequency = (frame[2] & 0b00001100) >> 2; if (samplingFrequency == 0b11) return false; // emphasis mode, 2 bits, value 10 is reserved unsigned char emphasisMode = frame[3] & 0b11; if (emphasisMode == 0b10) return false; return true; } bool MpegDecoder::Implementation::decodeMp3Frame(AudioFile& file, mp3data_struct& mp3data) { if (_hipGlobalFlags != nullptr) { hip_decode_exit(_hipGlobalFlags); } _hipGlobalFlags = hip_decode_init(); // libmp3lame note: // now parse the current buffer looking for MP3 headers. // (as of 11/00: mpglib modified so that for the first frame where // headers are parsed, no data will be decoded. // However, for freeformat, we need to decode an entire frame, // so mp3data->bitrate will be 0 until we have decoded the first // frame. Cannot decode first frame here because we are not // yet prepared to handle the output. const size_t kMpegHeaderSize = 4; const size_t kBufferSize = 100; unsigned char buffer[kBufferSize] = {}; if (kMpegHeaderSize != file.read(reinterpret_cast<char*>(buffer), kMpegHeaderSize)) return false; short int pcm_l[1152] = {}; short int pcm_r[1152] = {}; int enc_delay = 0; int enc_padding = 0; int returnValue = hip_decode1_headersB(_hipGlobalFlags, buffer, kMpegHeaderSize, pcm_l, pcm_r, &mp3data, &enc_delay, &enc_padding); if (-1 == returnValue) return false; // repeat until we decode a valid mp3 header. while (!mp3data.header_parsed) { if (kBufferSize != file.read(reinterpret_cast<char*>(buffer), kBufferSize)) return false; returnValue = hip_decode1_headersB(_hipGlobalFlags, buffer, kBufferSize, pcm_l, pcm_r, &mp3data, &enc_delay, &enc_padding); if (-1 == returnValue) return false; } if (mp3data.bitrate == 0 && !_freeFormat) { return false; } if (mp3data.totalframes > 0) { // mpglib found a Xing VBR header and computed nsamp & totalframes } else { mp3data.nsamp = kDefaultNumberOfSamples; } return true; } size_t MpegDecoder::Implementation::id3v2TagLength(const char* buffer) { size_t b0 = static_cast<unsigned char>(buffer[0]) & 0b01111111; size_t b1 = static_cast<unsigned char>(buffer[1]) & 0b01111111; size_t b2 = static_cast<unsigned char>(buffer[2]) & 0b01111111; size_t b3 = static_cast<unsigned char>(buffer[3]) & 0b01111111; return (((((b0 << 7) + b1) << 7) + b2) << 7) + b3; }
[ "dissabte@gmail.com" ]
dissabte@gmail.com
217a6e744b2cb60e76d4be8664e4ae347abcf491
68c8eead2f74f6acfe1dfd25aca5d4c09d2c9c92
/src/vision.hpp
cbf9d537495fa4e350209b1a4b0785ac7c54b467
[]
no_license
rmeesters/GnomeVision-2020
22379dea5968954c88d261a76f5d1e8d6a494856
0ddce4ddcbe55ae5bbad9bf3496e7a5d2135e86e
refs/heads/master
2020-12-18T13:26:23.932184
2020-02-09T17:36:43
2020-02-09T17:36:43
235,399,387
0
0
null
null
null
null
UTF-8
C++
false
false
2,687
hpp
#ifndef VISION_HPP #define VISION_HPP #include <opencv2/core/core.hpp> #include <opencv2/imgproc/imgproc.hpp> #include <vector> #include <iostream> #include <utility> #include "helper.hpp" using namespace std; struct VisionResultsPackage { i64 timestamp; bool valid; double xOffset; double zOffset; double tgtangle; double distToTarget; cv::Point midPoint; cv::Point ul, ur, ll, lr; double upperWidth, lowerWidth; double leftHeight, rightHeight; int sampleHue, sampleSat, sampleVal; // double ury = ur.y; // double lry = lr.y; static string createCSVHeader () { return "Timestamp," "Valid," "XOffset," "ZOffset," "tgtangle," "DistToTgt," "MidPoint_x, MidPoint_y" "UL_x,UL_y," "UR_x,UR_y," "LL_x,LL_y," "LR_x,LR_y"; } string createCSVLine () { stringstream ss; ss << timestamp << ","; ss << valid << ","; //either 0 or 1 ss << xOffset << ","; ss << zOffset << ","; ss << tgtangle << ","; ss << distToTarget << ","; ss << midPoint.x << "," << midPoint.y << ","; ss << ul.x << "," << ul.y << ","; ss << ur.x << "," << ur.y << ","; ss << ll.x << "," << ll.y << ","; ss << lr.x << "," << lr.y; return ss.str(); } }; typedef std::vector<cv::Point> contour_type; const int RES_X = 640, RES_Y = 480; const int MIN_HUE = 50, MAX_HUE = 90; // Original Value 55-65 const int MIN_SAT = 0, MAX_SAT = 255; // Original Value 0-255 - 100,255 const int MIN_VAL = 100, MAX_VAL = 255; //Original Value 50-255 - 100,255 const double MIN_AREA = 0.001, MAX_AREA = 1000000, MIN_WIDTH = 0, MAX_WIDTH = 100000, //rectangle width MIN_HEIGHT = 0, MAX_HEIGHT = 100000, //rectangle height MIN_RECT_RAT = 1.5, MAX_RECT_RAT = 5, //rect height / rect width - original 1.5,8 - good, 1.75:5 MIN_AREA_RAT = 0.85, MAX_AREA_RAT = 100; //cvxhull area / contour area /** * Processes the raw image provided in order to determine interesting values * from the image. The OpenCV image pipeline (thresholding, etc) is performed on * processedImage so this may be sent back to the driver station laptop for * debugging purposes. Results package is returned in a struct. * @param bgr raw image to do processing on * @param processedImage results of OpenCV image pipeline * @return results of vision processing (e.g location of target, timestamp) */ VisionResultsPackage calculate(const cv::Mat &bgr, cv::Mat &processedImage); void drawOnImage (cv::Mat &img, VisionResultsPackage info); VisionResultsPackage processingFailurePackage(ui64 time); #endif
[ "meesters.rich@gmail.com" ]
meesters.rich@gmail.com
4591f30bd7f0d4e7d3d8dbce92318890dab21e90
600b35b2d892eec613499fd5ddad1b44ee6decae
/test/dijkstra.test.cpp
23a60f06f319b3afa7ad49a7045bd30694707114
[]
no_license
soraiemame/library-cpp-test
dd130969ff9f14837dd09e9b2d57807dd4f224e9
0ace1359ea2f80059dbe0ba6f5718a00bc9eee19
refs/heads/main
2023-03-30T13:00:54.435297
2021-03-28T04:45:54
2021-03-28T04:45:54
352,294,520
0
0
null
null
null
null
UTF-8
C++
false
false
570
cpp
#define PROBLEM "https://onlinejudge.u-aizu.ac.jp/courses/library/5/GRL/1/GRL_1_A" #include <iostream> #include <vector> #include "../graph/dijkstra.hpp" int main(){ int N,M,S; std::cin >> N >> M >> S; std::vector<std::vector<edge>> G(N); for(int i = 0;i < M;i++){ int a,b;e_t c; std::cin >> a >> b >> c; G[a].push_back({b,c}); } const e_t INF = 1LL << 60; auto ans = dijkstra(G,{S},INF); for(int i = 0;i < N;i++){ if(ans[i] == INF)std::cout << "INF\n"; else std::cout << ans[i] << "\n"; } }
[ "funasou46@yahoo.co.jp" ]
funasou46@yahoo.co.jp
2577fe829e38dd8921b710e0cbdb2e20a381bddb
c372de5b46eb92a812d8fa3dd32f1ff7117ec485
/mge_v18_student_version/src/game/Player.h
722f397582c3c3da15e4413da98973b57086fc0f
[]
no_license
igli15/Project-Third-Person
c8e1382bed2dbd157335cd7b4c092f2909f7f18e
85275be445bdceb21084314c9bc93e32c8e26ee1
refs/heads/master
2022-01-16T09:38:12.086260
2019-05-30T12:10:55
2019-05-30T12:10:55
168,693,712
1
0
null
null
null
null
UTF-8
C++
false
false
520
h
#pragma once #include "../mge/core/GameObject.hpp" #include "components/PlayerMovementComponent.h" #include "../mge/components/RigidBody.h" #include "../mge/components/CircleCollider.h" #include "components/PlayerDataComponent.h" class Player :public GameObject { public: Player(); ~Player(); void Load(); void Start(); void SetPlayerNumber(int playerNumber); private: PlayerMovementComponent* m_movementComponent; RigidBody* m_rigidBody; CircleCollider* m_circleCollider; MeshRenderer* m_meshRenderer; };
[ "issatayev.ilyas@gmail.com" ]
issatayev.ilyas@gmail.com
960fd6bd4dbcd7c7a42660fbec20d428b3f533ab
b22588340d7925b614a735bbbde1b351ad657ffc
/athena/InnerDetector/InDetDetDescr/SCT_GeoModel/SCT_GeoModel/SCT_OuterSide.h
cd458f9324e238d6cf970148d535f9c77dedcb1f
[]
no_license
rushioda/PIXELVALID_athena
90befe12042c1249cbb3655dde1428bb9b9a42ce
22df23187ef85e9c3120122c8375ea0e7d8ea440
refs/heads/master
2020-12-14T22:01:15.365949
2020-01-19T03:59:35
2020-01-19T03:59:35
234,836,993
1
0
null
null
null
null
UTF-8
C++
false
false
1,916
h
/* Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration */ #ifndef SCT_GEOMODEL_SCT_OUTERSIDE_H #define SCT_GEOMODEL_SCT_OUTERSIDE_H #include "SCT_GeoModel/SCT_ComponentFactory.h" #include "CLHEP/Vector/ThreeVector.h" #include <string> class GeoMaterial; class GeoVPhysVol; class GeoLogVol; class GeoTransform; class SCT_Identifier; class SCT_Hybrid; class SCT_Pigtail; class SCT_Sensor; class SCT_OuterSide: public SCT_UniqueComponentFactory { public: SCT_OuterSide(const std::string & name); ~SCT_OuterSide(); //Explicitly disallow copy, assign to appease coverity SCT_OuterSide(const SCT_OuterSide &) = delete; SCT_OuterSide & operator=(const SCT_OuterSide &) = delete; virtual GeoVPhysVol * build(SCT_Identifier id) const; public: double thickness() const {return m_thickness;} double width() const {return m_width;} double length() const {return m_length;} CLHEP::Hep3Vector * env1RefPointVector() const {return m_env1RefPointVector;} CLHEP::Hep3Vector * env2RefPointVector() const {return m_env2RefPointVector;} const SCT_Hybrid * hybrid() const {return m_hybrid;} const SCT_Pigtail * pigtail() const {return m_pigtail;} const SCT_Sensor * sensor() const {return m_sensor;} double hybridOffsetX() const {return m_hybridOffsetX;} double hybridOffsetZ() const {return m_hybridOffsetZ;} private: void getParameters(); virtual const GeoLogVol * preBuild(); double m_thickness; double m_width; double m_length; double m_hybridOffsetX; double m_hybridOffsetZ; double m_safety; SCT_Hybrid * m_hybrid; SCT_Pigtail * m_pigtail; SCT_Sensor * m_sensor; GeoTransform * m_hybridPos; GeoTransform * m_pigtailPos; GeoTransform * m_sensorPos; CLHEP::Hep3Vector * m_env1RefPointVector; CLHEP::Hep3Vector * m_env2RefPointVector; }; #endif // SCT_GEOMODEL_SCT_OUTERSIDE_H
[ "rushioda@lxplus754.cern.ch" ]
rushioda@lxplus754.cern.ch
404cb7708d093c441b2f0e7b67fa5636bbc7d462
866078aa7dca474d75f8b5563e9e59457d51db4a
/Source/Communication/WebInterface/Webpart/request.h
9b49ab38527aec5c72a799fc708338ce8ee48423
[ "Unlicense" ]
permissive
phisn/DigitalDetectives
e78e2febc094f96fca7ce6356048641b38940fe9
2f279b4856cea0ce1933301c24683a2c0f34a2f8
refs/heads/master
2022-08-30T03:58:58.044986
2020-05-28T20:18:40
2020-05-28T20:18:40
267,678,133
2
0
null
null
null
null
UTF-8
C++
false
false
892
h
#pragma once #define COMMUNICATION_WEBPART_REQUEST R"__( <script language="javascript"> function setCookie(){ var pidHex=document.getElementById('pid').value; document.cookie="pid=" + parseInt(pidHex, 16); window.location="/"; } </script> <body> <div class="container"> <h2>Request PlayerID</h2> <select id="pid"> <option value="ff">Black (0)</option> <option value="e6">Red (1)</option> <option value="78">Green (2)</option> <option value="59">Blue (3)</option> <option value="ca">Purple (4)</option> <option value="1e">Yellow (5)</option> </select> <input type="submit" value="Request" formmethod="post" onClick="setCookie()"> </div> </body>)__" namespace Communication { namespace Webpart { const char* const request = PROGMEM COMMUNICATION_WEBPART_REQUEST; const size_t request_size = sizeof(COMMUNICATION_WEBPART_REQUEST); } }
[ "phisn@outlook.de" ]
phisn@outlook.de
a7966b929aee5c2499d16b2f02955a4b6c0c1a5e
7ce91a98ae434dbb48099699b0b6bcaa705ba693
/TestModule/HK1/Users/20133007/BAI3.CPP
10054e383c22a28aa053aa68b2b2f6c205ebe543
[]
no_license
ngthvan1612/OJCore
ea2e33c1310c71f9375f7c5cd0a7944b53a1d6bd
3ec0752a56c6335967e5bb4c0617f876caabecd8
refs/heads/master
2023-04-25T19:41:17.050412
2021-05-12T05:29:40
2021-05-12T05:29:40
357,612,534
0
0
null
null
null
null
UTF-8
C++
false
false
310
cpp
#include <stdio.h> void main() { int n,A[200],kt=-1,tam; scanf("%d",&n); tam=-1; for(int i=0;i<n;i++) { scanf("%d",&A[i]); if (tam!=A[i]%2) tam=A[i]%2; else kt=0; } tam=-1; if (kt!=-1) for (int j=0;j<n;j++) { if (tam!=A[j]%2) tam=A[j]%2; else { kt=j; break; } } printf("%d",kt); }
[ "Nguyen Van@DESKTOP-8HI58DE" ]
Nguyen Van@DESKTOP-8HI58DE
3e0af1325b788fc4f71fd56bd9ed9beec53252aa
969987a50394a9ebab0f8cce0ff22f6e2cfd7fb2
/devel/athenasub/src/format_manager.cpp
45be13712faa37d65f26b7692098fa56483a000e
[]
no_license
jeeb/aegisub-historical
67bd9cf24e05926f1979942594e04d6b1ffce40c
b81be20fd953bd61be80bfe4c8944f1757605995
refs/heads/master
2021-05-28T03:49:26.880613
2011-09-02T00:03:40
2011-09-02T00:03:40
null
0
0
null
null
null
null
UTF-8
C++
false
false
5,398
cpp
// Copyright (c) 2008, Rodrigo Braz Monteiro // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are met: // // * Redistributions of source code must retain the above copyright notice, // this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright notice, // this list of conditions and the following disclaimer in the documentation // and/or other materials provided with the distribution. // * Neither the name of the Aegisub Group 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. // // ----------------------------------------------------------------------------- // // AEGISUB/ATHENASUB // // Website: http://www.aegisub.net // Contact: mailto:amz@aegisub.net // #include "format_manager.h" #include "formats/format_ass.h" #include "reader.h" #include "text_reader.h" #include <wx/string.h> #include <algorithm> using namespace Athenasub; /////////// // Statics std::vector<Format> FormatManager::formats; bool FormatManager::formatsInitialized = false; //////////////// // Add a format void FormatManager::AddFormat(Format format) { // Abort if there is already a format with this name String name = format->GetName(); for (size_t i=0;i<formats.size();i++) { if (formats[i]->GetName() == name) return; } // Add formats.push_back(format); } /////////////////////////////////// // Initialize all built-in formats void FormatManager::InitializeFormats() { if (!formatsInitialized) { AddFormat(Format(new FormatASS())); AddFormat(Format(new FormatSSA())); AddFormat(Format(new FormatASS2())); formatsInitialized = true; } } /////////////////////// // Removes all formats void FormatManager::ClearFormats() { formats.clear(); formatsInitialized = false; } ///////////////////// // Number of formats int FormatManager::GetFormatCount() { return (int) formats.size(); } //////////// // By index Format FormatManager::GetFormatByIndex(const int index) { try { return formats.at(index); } catch (std::out_of_range &e) { (void) e; return Format(); } } /////////////// // By filename Format FormatManager::GetFormatFromFilename(const String &filename,bool read) { size_t len = formats.size(); for (size_t i=0;i<len;i++) { StringArray exts; if (read) exts = formats[i]->GetReadExtensions(); else exts = formats[i]->GetWriteExtensions(); size_t extn = exts.size(); for (size_t j=0;j<extn;j++) { if (filename.EndsWith(exts[j])) return formats[i]; } } return Format(); } ////////////////// // By format name Format FormatManager::GetFormatFromName(const String &name) { size_t len = formats.size(); for (size_t i=0;i<len;i++) { if (name == formats[i]->GetName()) return formats[i]; } return Format(); } /////////////////////////////////////////////////////// // Get a list of all formats compatible with this file std::vector<Format> FormatManager::GetCompatibleFormatList(Reader reader) { // Find all compatible formats and store them with their certainty std::vector<std::pair<float,Format> > results; size_t len = formats.size(); for (size_t i=0;i<len;i++) { // Reset reader reader->Rewind(); // Check how certain it is that it can read the format float certainty = formats[i]->CanReadFile(reader); // Compare to extension StringArray exts = formats[i]->GetReadExtensions(); for (size_t j=0;j<exts.size();j++) { if (reader->GetFileName().EndsWith(exts[j],false)) { certainty *= 2.0f; break; } } // If it thinks that it can read the format, add to list. if (certainty > 0.0f) { results.push_back(std::pair<float,Format>(certainty,formats[i])); } } // Functor to sort them struct Comp { bool operator() (const std::pair<float,Format> &p1,const std::pair<float,Format> &p2) { return p1.first > p2.first; } }; // Sort results and store them sort(results.begin(),results.end(),Comp()); len = results.size(); std::vector<Format> finalResults; for (size_t i=0;i<len;i++) { finalResults.push_back(results[i].second); } // Reset reader again and return results reader->Rewind(); return finalResults; } ////////////////////////////////////// // Same as above, but from a filename std::vector<Format> FormatManager::GetCompatibleFormatList(const String &filename,const String &encoding) { return GetCompatibleFormatList(Reader(new CReader(filename,encoding))); }
[ "verm@93549f3f-7f0a-0410-a4b3-e966c9c94f04" ]
verm@93549f3f-7f0a-0410-a4b3-e966c9c94f04
111019d0f60af452bc4e42e13954a893b49bcf29
b4aee1d85320b398555b3782e872773044d4d685
/sample/12.9/12.0.cpp
fae05cb839c94dc6853b50c002b7110925ba066b
[]
no_license
crazyqipython/Cpp-primer-plus
5a455ef0e16d461d963d659ff28a61eb27374269
0ebfe6feec17c5e920ff56b658464685cef26af1
refs/heads/master
2021-01-09T06:23:22.692388
2016-08-29T13:09:53
2016-08-29T13:09:53
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,206
cpp
#include <iostream> #include <string> #include <new> using namespace std; const int BUF = 512; class JustTesting { private: string words; int number; public: JustTesting(const string &s = "Just Testing", int n = 0) {words = s; number = n; cout << words << " constructed\n";} ~JustTesting() {cout << words << "destroyed\n";} void Show() const {cout << words << ", " << number << endl;} }; int main() { char *buffer = new char[BUF]; JustTesting *pc1, *pc2; pc1 = new (buffer) JustTesting; pc2 = new JustTesting("Heap1", 20); cout << "Memory block address:\n" << "buffer: " << (void *) buffer << " heap: " << pc2 << endl; cout << "Memory contents:\n"; cout << pc1 << ": "; pc1->Show(); cout << pc2 << ": "; pc2->Show(); JustTesting *pc3, *pc4; pc3 = new (buffer + sizeof (JustTesting)) JustTesting("Better Idea", 6); pc4 = new JustTesting("Heap2", 10); cout << "Memory contents:\n"; cout << pc3 << ": "; pc3->Show(); cout << pc4 << ": "; pc4->Show(); delete pc2; delete pc4; pc3->~JustTesting(); pc1->~JustTesting(); delete [] buffer; cout << "Done\n"; return 0; }
[ "hblee12294@gmail.com" ]
hblee12294@gmail.com
3198d790458b77c4aa6954e61da6b0509728b2cc
b74ab935ddb76799371bea35aa3ba6d29bcfe44b
/255_Verify Preorder Sequence in Binary Search Tree/main.cpp
f6497b3c1bb8f0f08d451d24d1a8ded8bd3c1658
[]
no_license
ColinBin/leetcode
b2d28411876f6e2a7fc48fd0d76aee433e396c70
a2e70b3e86d8acf8f0459485012097ae66dc4b48
refs/heads/master
2021-09-20T18:34:54.323626
2018-08-14T05:08:03
2018-08-14T05:08:03
112,900,082
1
0
null
null
null
null
UTF-8
C++
false
false
637
cpp
// // main.cpp // 255_Verify Preorder Sequence in Binary Search Tree // // Created by Colin on 19/12/2017. // Copyright © 2017 Colin. All rights reserved. // #include <iostream> #include <vector> #include <stack> using namespace std; bool verifyPreorder(vector<int>& preorder) { stack<int> stk; int low = INT_MIN; for(const int ele : preorder) { if(ele < low) return false; while(!stk.empty() && stk.top() < ele) { low = stk.top(); stk.pop(); } stk.push(ele); } return true; } int main(int argc, const char * argv[]) { return 0; }
[ "1413278796@qq.com" ]
1413278796@qq.com
7329c4f9165f0676b66094633cfefc16a0c7a864
5456502f97627278cbd6e16d002d50f1de3da7bb
/chrome/browser/ui/app_list/fast_show_pickler.h
1345cd705c96a14a53a69e75ccd0568f68870bcb
[ "BSD-3-Clause" ]
permissive
TrellixVulnTeam/Chromium_7C66
72d108a413909eb3bd36c73a6c2f98de1573b6e5
c8649ab2a0f5a747369ed50351209a42f59672ee
refs/heads/master
2023-03-16T12:51:40.231959
2017-12-20T10:38:26
2017-12-20T10:38:26
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,853
h
// Copyright 2013 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef CHROME_BROWSER_UI_APP_LIST_FAST_SHOW_PICKLER_H_ #define CHROME_BROWSER_UI_APP_LIST_FAST_SHOW_PICKLER_H_ #include <memory> #include <string> #include "base/pickle.h" #include "ui/app_list/app_list_model.h" // Functions for pickling/unpickling AppListModel for fast show. Fast show is // where the app list is put on the screen using data retrieved from a cache // before the extension system has loaded. class FastShowPickler { public: // The version that this pickler understands. static const int kVersion; // Pickles a subset of the data in |model| that is useful for doing a fast // show of the app list. static std::unique_ptr<base::Pickle> PickleAppListModelForFastShow( app_list::AppListModel* model); // Given a Pickle created by PickleAppListModelForFastShow(), this creates an // AppListModel that represents it. static std::unique_ptr<app_list::AppListModel> UnpickleAppListModelForFastShow(base::Pickle* pickle); // Copies parts that are needed to show the app list quickly on startup from // |src| to |dest|. static void CopyOver( app_list::AppListModel* src, app_list::AppListModel* dest); private: // Private static methods allow friend access to AppListItem methods. static std::unique_ptr<app_list::AppListItem> UnpickleAppListItem( base::PickleIterator* it); static bool PickleAppListItem(base::Pickle* pickle, app_list::AppListItem* item); static void CopyOverItem(app_list::AppListItem* src_item, app_list::AppListItem* dest_item); }; #endif // CHROME_BROWSER_UI_APP_LIST_FAST_SHOW_PICKLER_H_
[ "lixiaodonglove7@aliyun.com" ]
lixiaodonglove7@aliyun.com
517c2ba0092c76900bab023da4501d850d343022
21f8cdc85aa65b20c94e77b56d26966a80e183b3
/Source/SwordFly/GamePlay/GameMode/SwordFlyGameModeBase.h
056d8fb57a319f919a48fdb87aa1cf603b670e0b
[]
no_license
hpyyangnone/SwordFly
5de3f7d18b8e03693c9b81ecff97a1e1a44fe11d
d398c9d00c770bff0bdc59ce5fce0f4ee8b0284f
refs/heads/master
2022-12-26T01:41:15.025960
2020-10-15T09:57:22
2020-10-15T09:57:22
null
0
0
null
null
null
null
UTF-8
C++
false
false
319
h
// Copyright Epic Games, Inc. All Rights Reserved. #pragma once #include "CoreMinimal.h" #include "GameFramework/GameModeBase.h" #include "SwordFlyGameModeBase.generated.h" /** * */ UCLASS() class SWORDFLY_API ASwordFlyGameModeBase : public AGameModeBase { GENERATED_BODY() public: ASwordFlyGameModeBase(); };
[ "974805475@qq.com" ]
974805475@qq.com
36e308d554f19ccf82dd840e1a4b2066542b15ca
6f69c6d6071a89dfe863e110273862b7e23eea75
/Problema_02/problema02.cpp
f492a4135677207a638835b071f31c71f3017fc7
[]
no_license
mruizvela/UVM
55825ba9eab190a7226eb9a765035294c46c067f
58a44fc224aa969ef239e54d3f9ced83840da32c
refs/heads/master
2020-12-30T16:58:36.502539
2017-05-19T20:19:49
2017-05-19T20:19:49
91,040,549
0
0
null
null
null
null
UTF-8
C++
false
false
399
cpp
#include <math.h> #include <stdio.h> #include <string.h> #include <stdlib.h> #include <assert.h> #include <limits.h> #include <stdbool.h> int main(){ int n, sum = 0; scanf("%d", &n); int arr[n]; for(int arr_i = 0; arr_i < n; arr_i++){ scanf("%d",&arr[arr_i]); } for(int arr_i = 0; arr_i < n; arr_i++){ sum = sum + arr[arr_i]; } printf("%d", sum); }
[ "marisa.ruiz-velasco@hpe.com" ]
marisa.ruiz-velasco@hpe.com
a73a8a55b6ff797ea4ddea3a55315ca409a9e2f1
fefebea3de45192c29149980efc1430244fae426
/NWNBaseLib/BaseTypes.h
039dcde87a484d3c72ac7b51565f7a808e5c38d5
[]
no_license
fantasydr/nwn2dev
4ba8f02ec39a7a6155a9bc9018170fdd359e9059
be9b06435beb04e385c0b032426e3915f4de2271
refs/heads/master
2020-05-16T18:25:24.169263
2014-02-16T03:35:53
2014-02-16T03:35:53
16,663,693
3
0
null
null
null
null
UTF-8
C++
false
false
8,673
h
/*++ Copyright (c) Ken Johnson (Skywing). All rights reserved. Module Name: BaseTypes.h Abstract: This module defines the base types used in the NWN game system and which are used in data files and over the network as basic components for composite structures. --*/ #ifndef _SOURCE_PROGRAMS_NWNBASELIB_BASETYPES_H #define _SOURCE_PROGRAMS_NWNBASELIB_BASETYPES_H #ifdef _MSC_VER #pragma once #endif namespace NWN { // // Define game object ids and player ids. // typedef unsigned long OBJECTID; typedef unsigned long PLAYERID; // // Define the resource type code and associated resource type IDs. // These type IDs are assigned by BioWare and come from the BioWare // Aurora engine documentation as well as NWN2 game files. // typedef unsigned short ResType; static const ResType ResBMP = 1; static const ResType ResTGA = 3; static const ResType ResWAV = 4; static const ResType ResPLT = 6; static const ResType ResINI = 7; static const ResType ResBMU = 8; static const ResType ResTXT = 10; static const ResType ResMDL = 2002; static const ResType ResNSS = 2009; static const ResType ResNCS = 2010; static const ResType ResARE = 2012; static const ResType ResSET = 2013; static const ResType ResIFO = 2014; static const ResType ResBIC = 2015; static const ResType ResWOK = 2016; static const ResType Res2DA = 2017; static const ResType ResTXI = 2022; static const ResType ResGIT = 2023; static const ResType ResUTI = 2025; static const ResType ResUTC = 2027; static const ResType ResDLG = 2029; static const ResType ResITP = 2030; static const ResType ResUTT = 2032; static const ResType ResDDS = 2033; static const ResType ResUTS = 2035; static const ResType ResLTR = 2036; static const ResType ResGFF = 2037; static const ResType ResFAC = 2038; static const ResType ResUTE = 2040; static const ResType ResUTD = 2042; static const ResType ResUTP = 2044; static const ResType ResDFT = 2045; static const ResType ResGIC = 2046; static const ResType ResGUI = 2047; static const ResType ResUTM = 2051; static const ResType ResDWK = 2052; static const ResType ResPWK = 2053; static const ResType ResJRL = 2056; static const ResType ResUTW = 2058; static const ResType ResSSF = 2060; static const ResType ResNDB = 2064; static const ResType ResPTM = 2065; static const ResType ResPTT = 2066; static const ResType ResUSC = 3001; static const ResType ResTRN = 3002; static const ResType ResUTR = 3003; static const ResType ResUEN = 3004; static const ResType ResULT = 3005; static const ResType ResSEF = 3006; static const ResType ResPFX = 3007; static const ResType ResCAM = 3008; static const ResType ResUPE = 3011; static const ResType ResPFB = 3015; static const ResType ResBBX = 3018; static const ResType ResWLK = 3020; static const ResType ResXML = 3021; static const ResType ResTRX = 3035; static const ResType ResTRn = 3036; static const ResType ResTRx = 3037; static const ResType ResMDB = 4000; static const ResType ResSPT = 4002; static const ResType ResGR2 = 4003; static const ResType ResFXA = 4004; static const ResType ResJPG = 4007; static const ResType ResPWC = 4008; static const ResType ResINVALID = 0xFFFF; // // Define 32-byte and 16-byte RESREFs. NWN1 uses 16-byte RESREFs, whereas // NWN2 uses 32-byte RESREFs. // struct ResRef32 { char RefStr[ 32 ]; }; struct ResRef16 { char RefStr[ 16 ]; }; // // Define the on-network format of a localizable string which may contain // either a raw string or a STRREF. // struct ExoLocString { bool IsStrRef; std::string String; bool Flag; ULONG StrRef; }; // // Define the on-network format of a 3-tuple of floats typically, though not // always, used to represent three spatial coordinates. // struct Vector3 { float x; float y; float z; }; C_ASSERT( sizeof( Vector3 ) == 3 * sizeof( float ) ); // // Define the on-network format of a 2-tuple of floats typically, though not // always, used to represent two spatial coordinates. // struct Vector2 { float x; float y; }; C_ASSERT( sizeof( Vector2 ) == 2 * sizeof( float ) ); // // Define a 4x4 matrix (raw data only). // struct Matrix44 { float _00; float _01; float _02; float _03; float _10; float _11; float _12; float _13; float _20; float _21; float _22; float _23; float _30; float _31; float _32; float _33; const static Matrix44 IDENTITY; }; // // Define a 3x3 matrix (raw data only). // struct Matrix33 { float _00; float _01; float _02; float _10; float _11; float _12; float _20; float _21; float _22; const static Matrix33 IDENTITY; }; C_ASSERT( sizeof( Matrix44 ) == 16 * sizeof( float ) ); // // Define the wire format of a Quaternion. // struct Quaternion { float x; float y; float z; float w; }; C_ASSERT( sizeof( Quaternion ) == 4 * sizeof( float ) ); // // Define simple float-based rectangle and triangle types. // struct Rect { float left; float top; float right; float bottom; }; struct Triangle { NWN::Vector2 points[ 3 ]; }; // // Define the on-network representation of color values (range 0.0f..1.0f). // struct NWNCOLOR // D3DXCOLOR { float r; float g; float b; float a; }; // // Define the on-network representation of alphaless color value (range // 0.0f..1.0f). // struct NWNRGB { float r; float g; float b; }; // // Define scroll parameters for a UVScroll property as represented over the // network. // struct NWN2_UVScrollSet { bool Scroll; float U; float V; }; // // Define tint parameters for a TintSet property as represented over the // network. // struct NWN2_TintSet { NWNCOLOR Colors[ 3 ]; }; // // Armor accessory set and associated components. // struct NWN2_ArmorAccessory { unsigned char Variation; NWN2_TintSet Tint; NWN2_UVScrollSet UVScroll; }; struct NWN2_ArmorPiece { unsigned char Variation; unsigned char VisualType; NWN2_TintSet Tint; }; // // N.B. Class layout is assumed such that the armor piece header comes // before the accessory parameter block. // struct NWN2_ArmorPieceWithAccessories : public NWN2_ArmorPiece { // // N.B. Accessories indexed by NWN2_Accessory. // NWN2_ArmorAccessory Accessories[ 22 ]; }; // // Define the base armor accessory set, which represents the visual // parameters for an item (model variation ids, visual types, flags for // whether certain model pieces are present in the model, as well as // tinting parameters). struct NWN2_ArmorAccessorySet { NWN2_ArmorPieceWithAccessories Chest; NWN2_ArmorPiece Helm; NWN2_ArmorPiece Gloves; NWN2_ArmorPiece Boots; NWN2_ArmorPiece Belt; NWN2_ArmorPiece Cloak; unsigned char HasHelm; unsigned char HasGloves; unsigned char HasBoots; unsigned char HasBelt; unsigned char HasCloak; }; // // Define the flexible DataElement type which is used to store and retrieve // data of customized formats on the server. It is currently used to save // hotbar parameters server-side. // struct NWN2_DataElement { std::vector< bool> Bools; std::vector< int > Ints; std::vector< float > Floats; std::vector< unsigned long > StrRefs; std::vector< std::string > Strings; std::vector< ExoLocString > LocStrings; std::vector< OBJECTID > ObjectIds; }; // // Item property data. // struct NWItemProperty { unsigned short PropertyName; unsigned short SubType; unsigned short CostTableValue; unsigned char ChanceOfAppearing; }; // // Location data. // struct ObjectLocation { NWN::OBJECTID Area; NWN::Vector3 Orientation; NWN::Vector3 Position; }; struct NWN2_LightIntensityPair { NWN::NWNCOLOR DiffuseColor; NWN::NWNCOLOR SpecularColor; NWN::NWNCOLOR AmbientColor; float Intensity; }; } #endif
[ "fantasydr.gg@gmail.com" ]
fantasydr.gg@gmail.com
625706ac82d8de807a253d3231a6c3ba561b89b2
74c016e1421270e7c6d9b5ad70a0c702c93e3922
/Nanpy/UltrasonicWrapper.h
a3639c65521f34d680a8c8b2b46e427a28f3fdca
[]
no_license
bobosse86/python-arduino
b82f6033200aeb78c82487c84b35fccff711c7a9
105cc8c971b05fa2af1e8cf78f98acb97b3e1b07
refs/heads/main
2023-05-03T03:21:15.436808
2021-05-13T11:21:38
2021-05-13T11:21:38
null
0
0
null
null
null
null
UTF-8
C++
false
false
230
h
namespace nanpy { class UltrasonicWrapper { private: int echo, trig, conversionFactor; public: UltrasonicWrapper(int echoPin, int trigPin, bool useInches); float getDistance(); int getDuration(); }; }
[ "noreply@github.com" ]
noreply@github.com
4795f0bc89e249ae33b4547f5fb6dc2db05fba9b
9fdd262273c4071240b25815ba2cd623876b09c9
/threads/system.cc
01fc7c467b0b8a87ba449ee373f9d200d43af633
[ "MIT-Modern-Variant" ]
permissive
Zachary-ZS/Nachos-Code
f4e5acc0b0b2cae7008f8d416e02cbb28df49736
c492a08b6e296db416c226ac820bdb1fe53d8c21
refs/heads/master
2020-03-30T15:16:52.174267
2018-12-11T10:22:44
2018-12-11T10:22:44
151,356,175
0
0
null
null
null
null
UTF-8
C++
false
false
5,945
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 //----------------------------------------------------------------------------- int tid_used[128]; // Mark wether TID_x was used //----------------------------------------------------------------------------- #ifdef FILESYS_NEEDED FileSystem *fileSystem; #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; //----------------------------------------------------------------------------- // Initialize the tid_used vector for(int i=0; i < 128; i++){ tid_used[i] = 0; } //----------------------------------------------------------------------------- #ifdef USER_PROGRAM bool debugUserProg = FALSE; // single step user program #endif #ifdef FILESYS_NEEDED bool format = FALSE; // format disk #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 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->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; #endif #ifdef FILESYS delete synchDisk; #endif delete timer; delete scheduler; delete interrupt; Exit(0); }
[ "caoyuhezs@outlook.com" ]
caoyuhezs@outlook.com
781d94e7581c52ad7ef11fc282f4e82413143d51
56d0f02555b098cd393f22dbe00cf85509b41596
/cpp/0429.cpp
0f6e2bab0977552ae055843c4766a9e87d6eb0a1
[]
no_license
xfmeng17/leetcode
05cca36038d111f53d8f1d541607ea365ded2dfb
534ff8ef5617d230897d2bf0e1c0c7405bb309f9
refs/heads/master
2022-12-05T17:00:53.850397
2022-12-05T02:06:29
2022-12-05T02:06:29
121,209,775
0
0
null
2018-03-29T10:47:21
2018-02-12T06:37:18
C++
UTF-8
C++
false
false
1,456
cpp
/* // Definition for a Node. class Node { public: int val = NULL; vector<Node*> children; Node() {} Node(int _val, vector<Node*> _children) { val = _val; children = _children; } }; */ class Solution { public: vector<vector<int>> levelOrder(Node *root) { // return func1(root); return func2(root); } // ** recursion vector<vector<int>> func1(Node *root) { vector<vector<int>> res; helper(root, 0, res); return res; } void helper(Node *root, int level, vector<vector<int>> &res) { if (root == NULL) { return; } if (res.size() <= level) { vector<int> row = {root->val}; res.push_back(row); } else { res[level].push_back(root->val); } for (auto child : root->children) { helper(child, level + 1, res); } } // ** queue with pair<Node*, level> vector<vector<int>> func2(Node *root) { vector<vector<int>> res; queue<pair<Node *, int>> queue; if (root) { queue.push(make_pair(root, 0)); } while (queue.size()) { Node *curr = queue.front().first; int level = queue.front().second; if (res.size() <= level) { vector<int> row = {curr->val}; res.push_back(row); } else { res[level].push_back(curr->val); } queue.pop(); for (auto child : curr->children) { queue.push(make_pair(child, level + 1)); } } return res; } };
[ "xfmeng17@foxmail.com" ]
xfmeng17@foxmail.com
aff22d5ad90a7ce934b1787de0b10888b7f71357
0bd1265abbec9fa8b1ecca2b2e9bd48572ffaffc
/include/llvm/CodeGen/ExpandReductions.h
af13d20acf5fa680ab0e102d868433bb6b10a0ab
[]
no_license
BenQuickDeNN/Kaleidoscope
2daa74aaa1ec82866d4c4e8b72c68dd5a7ce803a
573b769ecc1b78f1ad9d2fd0a68978028b528e14
refs/heads/master
2022-10-06T21:51:10.741879
2020-06-11T02:19:48
2020-06-11T02:19:48
208,954,736
0
0
null
null
null
null
UTF-8
C++
false
false
749
h
//===----- ExpandReductions.h - Expand experimental reduction intrinsics --===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// #ifndef LLVM_CODEGEN_EXPANDREDUCTIONS_H #define LLVM_CODEGEN_EXPANDREDUCTIONS_H #include "llvm/IR/PassManager.h" namespace llvm { class ExpandReductionsPass : public PassInfoMixin<ExpandReductionsPass> { public: PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM); }; } // end namespace llvm #endif // LLVM_CODEGEN_EXPANDREDUCTIONS_H
[ "benquickdenn@foxmail.com" ]
benquickdenn@foxmail.com
ad308c91abbc56031ad9033f0c30b37ac78e2866
f3a52a8832519729d65c5c3c436db2000217703c
/Source/FSD/Public/FSDFriendsAndInvites.h
3fd0a039205da8caeb4131c767cc2f7d0fe02b48
[]
no_license
NicolasAubinet/virtual-rock-galactic
50be56c6548cfd44b3187cb41e4e03847b2093e7
e82ce900f1f88c7db0abdb1d69c2de31650ca628
refs/heads/main
2023-07-22T08:04:59.552029
2023-07-15T08:16:22
2023-07-15T08:16:22
425,605,229
22
3
null
null
null
null
UTF-8
C++
false
false
1,180
h
#pragma once #include "CoreMinimal.h" #include "BlueprintFriend.h" #include "EmptyFriendDelegateDelegate.h" #include "UObject/Object.h" #include "FSDFriendsAndInvites.generated.h" UCLASS(Blueprintable) class UFSDFriendsAndInvites : public UObject { GENERATED_BODY() public: UPROPERTY(BlueprintAssignable, BlueprintCallable, BlueprintReadWrite, EditAnywhere, meta=(AllowPrivateAccess=true)) FEmptyFriendDelegate OnFriendsChanged; UPROPERTY(BlueprintAssignable, BlueprintCallable, BlueprintReadWrite, EditAnywhere, meta=(AllowPrivateAccess=true)) FEmptyFriendDelegate OnFriendInvitesChanged; UPROPERTY(BlueprintAssignable, BlueprintCallable, BlueprintReadWrite, EditAnywhere, meta=(AllowPrivateAccess=true)) FEmptyFriendDelegate OnRequestRefresh; UPROPERTY(BlueprintReadWrite, EditAnywhere, Transient, meta=(AllowPrivateAccess=true)) TArray<FBlueprintFriend> Friends; UPROPERTY(BlueprintReadWrite, EditAnywhere, Transient, meta=(AllowPrivateAccess=true)) TArray<FBlueprintFriend> FriendInvites; UFSDFriendsAndInvites(); UFUNCTION(BlueprintCallable, BlueprintImplementableEvent) void Init(); };
[ "n.aubinet@gmail.com" ]
n.aubinet@gmail.com
36dbd1dfa4dd2409e24c56e42ce6869a4de94e8f
60f154a9a97153c0ac92f0730172039305c9b8e3
/MyRobot/MyRobot.ino
f6f6df443a37df1174f08cb94355a38a431b461f
[]
no_license
cdesp/Arduino-Projects
78fbd3fc702c876696b89100d062ba3b92ca27aa
4c37b7c2d1784d039dc71605041688884709ae7f
refs/heads/master
2022-06-11T10:52:24.314043
2022-06-06T13:31:21
2022-06-06T13:31:21
110,843,428
1
0
null
null
null
null
UTF-8
C++
false
false
2,262
ino
#include <Servo.h> #include "desp_hand.h" Hand rightHand(8); void setup() { rightHand.Setup(3,5,6,4,7,8); Serial.begin(115200); Serial.println("OK"); } void gest1(){ // rightHand.moveFinger(4,fingOpen); // rightHand.moveFinger(3,fingOpen); // rightHand.moveFinger(2,fingClose); // rightHand.moveFinger(1,fingClose); // rightHand.moveFinger(0,fingClose); rightHand.setPosfingers(fC,fC,fC,fO,fO); } void gest2(){ //rightHand.moveFinger(4,fingOpen); // rightHand.moveFinger(3,fingOpen); // rightHand.moveFinger(2,fingClose); // rightHand.moveFinger(1,fingClose); // rightHand.moveFinger(0,fingOpen); rightHand.setPosfingers(fO,fC,fC,fO,fO); } void gest3(){ // rightHand.moveFinger(4,fingOpen); // rightHand.moveFinger(3,fingClose); // rightHand.moveFinger(2,fingClose); // rightHand.moveFinger(1,fingClose); // rightHand.moveFinger(0,fingClose); rightHand.setPosfingers(fC,fC,fC,fC,fO); } void gest4(){ rightHand.moveFinger(4,fingClose); rightHand.moveFinger(3,fingClose); rightHand.moveFinger(2,fingOpen); rightHand.moveFinger(1,fingClose); rightHand.moveFinger(0,fingClose); //rightHand.setPosfingers(fC,fC,fO,fC,fC); } void allopen(){ // for (int i=0;i<5;i++) // rightHand.moveFinger(i,fingOpen); rightHand.setPosfingers(fO,fO,fO,fO,fO); } void allclose(){ // for (int i=0;i<5;i++) // rightHand.moveFinger(i,fingClose); rightHand.setPosfingers(fC,fC,fC,fC,fC); } void wristleft(){ rightHand.moveWrist(180); } void wristnorm(){ rightHand.moveWrist(90); } void wristright(){ rightHand.moveWrist(0); } void loop() { allopen(); wristnorm(); while (true) { rightHand.movAllfingers(); if (Serial.available() > 0) { // read the incoming byte: String s=Serial.readString(); int turn=s.toInt(); // myservo1.write(turn); delay(15); switch(turn){ case 0:allclose();break; case 1:gest1();break; case 2:gest2();break; case 3:gest3();break; case 4:gest4();break; case 6:wristleft();break; case 7:wristnorm();break; case 8:wristright();break; default: allopen(); } Serial.println(turn); } } }
[ "cdesp72@gmail.com" ]
cdesp72@gmail.com
dc4a18b7ab1a946f0d1b6765847ef89989b3720a
a7053519b6f4b1b6e998dc821b644dd57abc6320
/TOJ/toj43.cpp
0d398b9d66409fcf5cda8e867665feec7b38cb65
[]
no_license
Koios1143/Algorithm-Code-Saved
97c7360e1928bbea12307524a8562b3f1c72d89d
38706e0c08750ebdd0384534baa3226f850fb8b7
refs/heads/master
2023-02-08T00:33:56.881228
2020-12-12T05:09:16
2020-12-12T05:09:16
297,377,067
0
0
null
null
null
null
UTF-8
C++
false
false
930
cpp
#include<iostream> #include<vector> #include<queue> using namespace std; struct dot{ int val; int me,next; dot(int m,int n,int v) { me=m; next=n; val=v; } }; int main() { int n,m; cin>>n>>m; vector<dot> arr[n]; int dis[n]; for(int i=0 ; i<n ; i++) { dis[i]=2147483647; } for(int j=0,a,b,l ; j<m ; j++) { cin>>a>>b>>l; dot d1(a,b,l); arr[a].push_back(d1); dot d2(b,a,l); arr[b].push_back(d2); } int start,end; cin>>start>>end; dis[start]=0; queue<int>q; q.push(start); while(!q.empty()) { int size=arr[q.front()].size(); for(int i=0 ; i<size ; i++) { if(dis[(arr[q.front()][i]).next]>dis[(arr[q.front()][i]).me]+(arr[q.front()][i]).val) { dis[(arr[q.front()][i]).next]=dis[(arr[q.front()][i]).me]+(arr[q.front()][i]).val; q.push((arr[q.front()][i]).next); } } q.pop(); } cout<<dis[end]<<"\n"; return 0 ; }
[ "ken1357924681010@gmail.com" ]
ken1357924681010@gmail.com
23f249696fdddf2268810c55a89487bcaa6be41b
5bd2afeded6a39311403641533f9a8798582b5c6
/atcoder/abc151/F.cpp
9d8126b0025819f5627c34c50b82d79de9931154
[]
no_license
ShahjalalShohag/ProblemSolving
19109c35fc1a38b7a895dbc4d95cbb89385b895b
3df122f13808681506839f81b06d507ae7fc17e0
refs/heads/master
2023-02-06T09:28:43.118420
2019-01-06T11:09:00
2020-12-27T14:35:25
323,168,270
31
16
null
null
null
null
UTF-8
C++
false
false
26,517
cpp
#pragma comment(linker, "/stack:200000000") #pragma GCC optimize("Ofast") #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") #pragma GCC optimize("unroll-loops") #include<bits/stdc++.h> #include<ext/pb_ds/assoc_container.hpp> #include<ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; using namespace std; #define ll long long #define ull unsigned long long #define ld long double #define pii pair<int,int> #define pll pair<ll,ll> #define vi vector<int> #define vll vector<ll> #define vc vector<char> #define vs vector<string> #define vpll vector<pll> #define vpii vector<pii> #define umap unordered_map #define uset unordered_set #define PQ priority_queue #define printa(a,L,R) for(int i=L;i<R;i++) cout<<a[i]<<(i==R-1?'\n':' ') #define printv(a) printa(a,0,a.size()) #define print2d(a,r,c) for(int i=0;i<r;i++) for(int j=0;j<c;j++) cout<<a[i][j]<<(j==c-1?'\n':' ') #define pb push_back #define eb emplace_back #define mt make_tuple #define fbo find_by_order #define ook order_of_key #define MP make_pair #define UB upper_bound #define LB lower_bound #define SQ(x) ((x)*(x)) #define issq(x) (((ll)(sqrt((x))))*((ll)(sqrt((x))))==(x)) #define F first #define S second #define mem(a,x) memset(a,x,sizeof(a)) #define inf 1e18 #define E 2.71828182845904523536 #define gamma 0.5772156649 #define nl "\n" #define lg(r,n) (int)(log2(n)/log2(r)) #define pf printf #define sf scanf #define sf1(a) scanf("%d",&a) #define sf2(a,b) scanf("%d %d",&a,&b) #define sf3(a,b,c) scanf("%d %d %d",&a,&b,&c) #define pf1(a) printf("%d\n",a); #define pf2(a,b) printf("%d %d\n",a,b) #define pf3(a,b,c) printf("%d %d %d\n",a,b,c) #define sf1ll(a) scanf("%lld",&a) #define sf2ll(a,b) scanf("%I64d %I64d",&a,&b) #define sf3ll(a,b,c) scanf("%I64d %I64d %I64d",&a,&b,&c) #define pf1ll(a) printf("%lld\n",a); #define pf2ll(a,b) printf("%I64d %I64d\n",a,b) #define pf3ll(a,b,c) printf("%I64d %I64d %I64d\n",a,b,c) #define _ccase printf("Case %lld: ",++cs) #define _case cout<<"Case "<<++cs<<": " #define by(x) [](const auto& a, const auto& b) { return a.x < b.x; } #define asche cerr<<"Ekhane asche\n"; #define rev(v) reverse(v.begin(),v.end()) #define srt(v) sort(v.begin(),v.end()) #define grtsrt(v) sort(v.begin(),v.end(),greater<ll>()) #define all(v) v.begin(),v.end() #define mnv(v) *min_element(v.begin(),v.end()) #define mxv(v) *max_element(v.begin(),v.end()) #define toint(a) atoi(a.c_str()) #define fast ios_base::sync_with_stdio(false) #define valid(tx,ty) (tx>=0&&tx<n&&ty>=0&&ty<m) #define one(x) __builtin_popcount(x) #define Unique(v) v.erase(unique(all(v)),v.end()) #define stree ll l=(n<<1),r=l+1,mid=b+(e-b)/2 #define fout(x) fixed<<setprecision(x) string tostr(int n) {stringstream rr;rr<<n;return rr.str();} template <typename T> using o_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; //ll dx[]={1,0,-1,0,1,-1,-1,1}; //ll dy[]={0,1,0,-1,1,1,-1,-1}; #define debug(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); deb(_it, args); } void deb(istream_iterator<string> it) {} template<typename T, typename... Args> void deb(istream_iterator<string> it, T a, Args... args) { cerr << *it << " = " << a << endl; deb(++it, args...); } const int mod=1e9+7; const int N=3e5+9; const double eps=1e-9; const double PI=acos(-1.0); const int mxp=2100; //ll gcd(ll a,ll b){while(b){ll x=a%b;a=b;b=x;}return a;} //ll lcm(ll a,ll b){return a/gcd(a,b)*b;} //ll qpow(ll n,ll k) {ll ans=1;assert(k>=0);n%=mod;while(k>0){if(k&1) ans=(ans*n)%mod;n=(n*n)%mod;k>>=1;}return ans%mod;} int sign(double d) { if (fabs(d)<eps)return 0; return d>eps?1:-1; } inline double sqr(double x){return x*x;} struct PT { double x,y; PT() {} PT(double x, double y) : x(x), y(y) {} PT(const PT &p) : x(p.x), y(p.y) {} void in() { sf("%lf %lf",&x,&y); } void out() { pf("%.10f %.10f\n",x,y); } PT operator + (const PT &a) const{ return PT(x+a.x,y+a.y); } PT operator - (const PT &a) const{ return PT(x-a.x,y-a.y); } PT operator * (const double a) const{ return PT(x*a,y*a); } friend PT operator * (const double &a, const PT &b) { return PT(a * b.x, a * b.y); } PT operator / (const double a) const{ return PT(x/a,y/a); } bool operator==(PT a)const { return sign(a.x-x)==0&&sign(a.y-y)==0; } bool operator<(PT a)const { return sign(a.x-x)==0?sign(y-a.y)<0:x<a.x; } bool operator>(PT a)const { return sign(a.x-x)==0?sign(y-a.y)>0:x>a.x; } double val() { return sqrt(x*x+y*y); } double val2() { return (x*x+y*y); } double arg() { return atan2(y,x); } //return point that is truncated the distance from center to r PT trunc(double r){ double l=val(); if (!sign(l)) return *this; r/=l; return PT(x*r,y*r); } }; istream& operator >> (istream& is,PT &a) { return is>>a.x>>a.y; } ostream& operator << (ostream& os,const PT &a) { return os<<fixed<<setprecision(10)<<a.x<<' '<<a.y; } double dist(PT a,PT b) { return sqrt(sqr(a.x-b.x)+sqr(a.y-b.y)); } double dist2(PT a,PT b) { return sqr(a.x-b.x)+sqr(a.y-b.y); } double dot(PT a,PT b) { return a.x*b.x+a.y*b.y; } double cross(PT a,PT b) { return a.x*b.y-a.y*b.x; } PT rotateccw90(PT a) { return PT(-a.y,a.x); } PT rotatecw90(PT a) { return PT(a.y,-a.x); } PT rotateccw(PT a,double th) { return PT(a.x*cos(th)-a.y*sin(th),a.x*sin(th)+a.y*cos(th)); } PT rotatecw(PT a,double th) { return PT(a.x*cos(th)+a.y*sin(th),-a.x*sin(th)+a.y*cos(th)); } double angle_between_vectors(PT a, PT b) { double costheta=dot(a,b)/a.val()/b.val(); return acos(fmax(-1.0,fmin(1.0,costheta))); } double rad_to_deg(double r) { return (r * 180.0 / PI); } double deg_to_rad(double d) { return (d * PI / 180.0); } // a line is defined by two points struct line { PT a,b; line(){} line(PT _a,PT _b) { a=_a; b=_b; } //ax+by+c=0 line(double _a,double _b,double _c) { if (sign(_a)==0) { a=PT(0,-_c/_b); b=PT(1,-_c/_b); } else if (sign(_b)==0) { a=PT(-_c/_a,0); b=PT(-_c/_a,1); } else { a=PT(0,-_c/_b); b=PT(1,(-_c-_a)/_b); } } void in() { a.in(); b.in(); } PT vec() const { return (b-a); } bool operator==(line v) { return (a==v.a)&&(b==v.b); } PT cross_point(line v){ double a1=cross(v.b-v.a,a-v.a); double a2=cross(v.b-v.a,b-v.a); return PT((a.x*a2-b.x*a1)/(a2-a1),(a.y*a2-b.y*a1)/(a2-a1)); } ///ax+by+c=0 pair<pair<double,double>,double> abc() { return MP(MP(a.y-b.y,b.x-a.x),-a.x*(a.y-b.y)+a.y*(a.x-b.x)); } }; istream &operator>>(istream &is, line &a) { return is >> a.a >> a.b; } ostream &operator<<(ostream &os, line &p) { return os << p.a << " to " << p.b; } // find a point from 'a' through 'b' with distance d PT point_along_line(PT a,PT b,double d) { return a + (((b-a) / (b-a).val()) * d); } // projection point c onto line through a and b assuming a != b PT project_from_point_to_line(PT a, PT b, PT c) { return a + (b-a)*dot(c-a, b-a)/(b-a).val2(); } // reflection point c onto line through a and b assuming a != b PT reflection_from_point_to_line(PT a, PT b, PT c) { PT p=project_from_point_to_line(a,b,c); return point_along_line(c,p,2*dist(c,p)); } //minimum distance from point c to line through a and b double dist_from_point_to_line(PT a,PT b,PT c) { return fabs(cross(b-a,c-a)/(b-a).val()); } //return 1 if point c is on line segment ab bool is_point_on_seg(PT a,PT b,PT c) { double d1=dist(a,c)+dist(c,b); double d2=dist(a,b); if(fabs(d1-d2)<eps) return 1; else return 0; } //minimum distance point from point c to segment ab that lies on segment ab PT project_from_point_to_seg(PT a, PT b, PT c) { double r = dist2(a,b); if (fabs(r) < eps) return a; r = dot(c-a, b-a)/r; if (r < 0) return a; if (r > 1) return b; return a + (b-a)*r; } //minimum distance from point c to to segment ab double dist_from_point_to_seg(PT a, PT b, PT c) { return dist(c, project_from_point_to_seg(a, b, c)); } //returns a parallel line of line ab in counterclockwise direction with d distance from ab line get_parallel_line(PT a,PT b,double d) { return line(point_along_line(a,rotateccw90(b-a)+a,d),point_along_line(b,rotatecw90(a-b)+b,d)); } //Return a tangent line of line ab which intersects //with it at point c in counterclockwise direction line get_perpendicular_line(PT a,PT b,PT c) { return line(c+rotateccw90(a-c),c+rotateccw90(b-c)); } //relation of point p with line ab //return //1 if point is ccw with line //2 if point is cw with line //3 if point is on the line int point_line_relation(PT a,PT b,PT p){ int c=sign(cross(p-a,b-a)); if (c<0)return 1; if (c>0)return 2; return 3; } //return //0 if not parallel //1 if parallel //2 if collinear bool is_parallel(PT a,PT b,PT c,PT d) { double k=fabs(cross(b-a,d-c)); if(k<eps){ if(fabs(cross(a-b,a-c))<eps&&fabs(cross(c-d,c-a))<eps) return 2; else return 1; } else return 0; } double area_of_triangle(PT a,PT b,PT c) { return fabs(cross(b-a,c-a)/2.0); } //radian angle of <bac double angle(PT b,PT a,PT c) { return angle_between_vectors(b-a,c-a); } //orientation of point a,b,c double orient(PT a,PT b,PT c) { return cross(b-a,c-a); } //is point p within angle <bac bool is_point_in_angle(PT b,PT a,PT c,PT p) { assert(fabs(orient(a,b,c)-0.0)>0); if(orient(a,c,b)<0) swap(b,c); return orient(a,c,p)>=0&&orient(a,b,p)<=0; } //equation of bisector line of <bac line bisector(PT b,PT a,PT c) { PT unit_ab=(b-a)/(b-a).val(); PT unit_ac=(c-a)/(c-a).val(); PT l=unit_ab+unit_ac; return line(l.y,-l.x,l.x*a.y-l.y*a.x); } //sort points in counterclockwise; bool half(PT p) { return p.y>0.0||(p.y==0.0&&p.x<0.0); } void polar_sort(vector<PT>&v) { sort(all(v),[](PT a,PT b){return make_tuple(half(a),0.0)<make_tuple(half(b),cross(a,b));}); } //intersection point between ab and cd //assuming unique intersection exists bool line_line_intersection(PT a,PT b,PT c,PT d,PT &out) { double a1=a.y-b.y; double b1=b.x-a.x; double c1=cross(a,b); double a2=c.y-d.y; double b2=d.x-c.x; double c2=cross(c,d); double det=a1*b2-a2*b1; if(det==0) return 0; out=PT((b1*c2-b2*c1)/det,(c1*a2-a1*c2)/det); return 1; } //intersection point between segment ab and segment cd //assuming unique intersection exists bool seg_seg_intersection(PT a,PT b,PT c,PT d,PT &out) { double oa=orient(c,d,a); double ob=orient(c,d,b); double oc=orient(a,b,c); double od=orient(a,b,d); //proper intersection exists iff opposite tmps if(oa*ob<0&&oc*od<0){ out=(a*ob-b*oa)/(ob-oa); return 1; } else return 0; } //intersection point between segment ab and segment cd //assuming unique intersection may not exists //se.size()==0 means no intersection //se.size()==1 means one intersection //se.size()==2 means range intersection set<PT> seg_seg_intersection_inside(PT a, PT b, PT c, PT d) { PT out; if (seg_seg_intersection(a,b,c,d,out)) return {out}; set<PT> se; if (is_point_on_seg(c,d,a)) se.insert(a); if (is_point_on_seg(c,d,b)) se.insert(b); if (is_point_on_seg(a,b,c)) se.insert(c); if (is_point_on_seg(a,b,d)) se.insert(d); return se; } //intersection between segment ab and line cd //return //0 if do not intersect //1 if proper intersect //2 if segment intersect int seg_line_relation(PT a,PT b,PT c,PT d) { double p=orient(c,d,a); double q=orient(c,d,b); if(sign(p)==0&&sign(q)==0) return 2; //proper intersection exists iff opposite tmps else if(p*q<0) return 1; else return 0; } //minimum distance from segment ab to segment cd double dist_from_seg_to_seg(PT a,PT b,PT c,PT d) { PT dummy; if(seg_seg_intersection(a,b,c,d,dummy)) return 0.0; else return min({dist_from_point_to_seg(a,b,c), dist_from_point_to_seg(a,b,d), dist_from_point_to_seg(c,d,a), dist_from_point_to_seg(c,d,b)}); } //minimum distance from point c to ray (starting point a and direction vector b) double dist_from_point_to_ray(PT a, PT b, PT c) { b=a+b; double r = dot(c-a, b-a); if(r<0.0) return dist(c,a); return dist_from_point_to_line(a,b,c); } //starting point as and direction vector ad bool ray_ray_intersection(PT as,PT ad,PT bs,PT bd) { double dx = bs.x - as.x; double dy = bs.y - as.y; double det = bd.x * ad.y - bd.y * ad.x; if(fabs(det)<eps) return 0; double u = (dy * bd.x - dx * bd.y) / det; double v = (dy * ad.x - dx * ad.y) / det; debug(u,v); if(sign(u)>=0&&sign(v)>=0) return 1; else return 0; } double ray_ray_distance(PT as,PT ad,PT bs,PT bd) { if(ray_ray_intersection(as,ad,bs,bd)) return 0.0; double ans=dist_from_point_to_ray(as,ad,bs); ans=fmin(ans,dist_from_point_to_ray(bs,bd,as)); return ans; } //a circle is defined by a center and radius struct circle { PT p; double r; circle(){} circle(PT _p,double _r): p(_p),r(_r){}; //center (x,y) and radius r circle(double x,double y,double _r): p(PT(x,y)),r(_r){}; //compute circle given three points i.e. circumcircle of a triangle circle(PT a,PT b,PT c){ b=(a+b)/2.0; c=(a+c)/2.0; line_line_intersection(b,b+rotatecw90(a-b),c,c+rotatecw90(a-c),p); r=dist(a,p); } circle(PT a,PT b,PT c,bool t){ line u,v; double m=atan2(b.y-a.y,b.x-a.x),n=atan2(c.y-a.y,c.x-a.x); u.a=a; u.b=u.a+(PT(cos((n+m)/2.0),sin((n+m)/2.0))); v.a=b; m=atan2(a.y-b.y,a.x-b.x),n=atan2(c.y-b.y,c.x-b.x); v.b=v.a+(PT(cos((n+m)/2.0),sin((n+m)/2.0))); line_line_intersection(u.a,u.b,v.a,v.b,p); r=dist_from_point_to_seg(a,b,p); } void in(){ p.in();scanf("%lf",&r); } void out(){ printf("%.10f %.10f %.10f\n",p.x,p.y,r); } bool operator==(circle v){ return ((p==v.p)&&sign(r-v.r)==0); } bool operator<(circle v)const{ return ((p<v.p)||(p==v.p)&&sign(r-v.r)<0); } double area(){return PI*sqr(r);} double circumference(){return 2.0*PI*r;} }; istream &operator>>(istream &is, circle &a) { return is >> a.p >> a.r; } ostream &operator<<(ostream &os, circle &a) { return os << a.p <<" "<< a.r; } //if point is inside circle //return //0 outside //1 on circumference //2 inside circle int circle_point_relation(PT p,double r,PT b) { double dst=dist(p,b); if (sign(dst-r)<0)return 2; if (sign(dst-r)==0)return 1; return 0; } //if segment is inside circle //return //0 outside //1 on circumference //2 inside circle int circle_seg_relation(PT p,double r,PT a,PT b) { double dst=dist_from_point_to_seg(a,b,p); if (sign(dst-r)<0)return 2; if (sign(dst-r)==0)return 1; return 0; } //if line cross circle //return //0 outside //1 on circumference //2 inside circle int circle_line_relation(PT p,double r,PT a,PT b) { double dst=dist_from_point_to_line(a,b,p); if (sign(dst-r)<0)return 2; if (sign(dst-r)==0)return 1; return 0; } //compute intersection of line through points a and b with //circle centered at c with radius r > 0 vector<PT> circle_line_intersection(PT c, double r ,PT a, PT b) { vector<PT> ret; b = b-a; a = a-c; double A = dot(b, b); double B = dot(a, b); double C = dot(a, a) - r*r; double D = B*B - A*C; if (D < -eps) return ret; ret.pb(c+a+b*(-B+sqrt(D+eps))/A); if (D > eps) ret.pb(c+a+b*(-B-sqrt(D))/A); return ret; } //return //5 - outside and do not intersect //4 - intersect outside in one point //3 - intersect in 2 points //2 - intersect inside in one point //1 - inside and do not intersect int circle_circle_relation(PT a,double r,PT b,double R) { double d=dist(a,b); if (sign(d-r-R)>0) return 5; if (sign(d-r-R)==0) return 4; double l=fabs(r-R); if (sign(d-r-R)<0&&sign(d-l)>0) return 3; if (sign(d-l)==0) return 2; if (sign(d-l)<0) return 1; } // compute intersection of circle centered at a with radius r // with circle centered at b with radius R vector<PT> circle_circle_intersection(PT a,double r,PT b,double R) { if(a==b&&sign(r-R)==0) return {PT(1e18,1e18)}; vector<PT> ret; double d = sqrt(dist2(a, b)); if (d > r+R || d+min(r, R) < max(r, R)) return ret; double x = (d*d-R*R+r*r)/(2*d); double y = sqrt(r*r-x*x); PT v = (b-a)/d; ret.pb(a+v*x + rotateccw90(v)*y); if (y > 0) ret.pb(a+v*x - rotateccw90(v)*y); return ret; } // returns two circle c1,c2 through points a,b of radius r // returns 0 if there is no such circle // 1 if one circle // 2 if two circle int getcircle(PT a,PT b,double r,circle &c1,circle &c2) { vector<PT> v=circle_circle_intersection(a,r,b,r); int t=v.size(); if(!t) return 0; c1.p=v[0],c1.r=r; if(t==2) c2.p=v[1],c2.r=r; return t; } // returns two circle c1,c2 which is tangent to line u, goes through // point q and has radius r1 // returns 0 for no circle ,1 if c1=c2 ,2 if c1!=c2 int getcircle(line u,PT q,double r1,circle &c1,circle &c2) { double dis=dist_from_point_to_line(u.a,u.b,q); if (sign(dis-r1*2)>0) return 0; if (sign(dis)==0) { c1.p=(q+rotateccw90(u.vec())).trunc(r1); c2.p=(q+rotatecw90(u.vec())).trunc(r1); c1.r=c2.r=r1; return 2; } line u1=line((u.a+rotateccw90(u.vec())).trunc(r1),(u.b+rotateccw90(u.vec())).trunc(r1)); line u2=line((u.a+rotatecw90(u.vec())).trunc(r1),(u.b+rotatecw90(u.vec())).trunc(r1)); circle cc=circle(q,r1); PT p1,p2; vector<PT>v; v=circle_line_intersection(q,r1,u1.a,u1.b); if (!v.size()) v=circle_line_intersection(q,r1,u2.a,u2.b); v.eb(v[0]); p1=v[0],p2=v[1]; c1=circle(p1,r1); if (p1==p2) { c2=c1; return 1; } c2=circle(p2,r1); return 2; } //returns area of intersection between two circles double circle_circle_area(PT a,double r1,PT b,double r2) { circle u(a,r1),v(b,r2); int rel=circle_circle_relation(a,r1,b,r2); if (rel>=4) return 0.0; if (rel<=2) return min(u.area(),v.area()); double d=dist(u.p,v.p); double hf=(u.r+v.r+d)/2.0; double ss=2*sqrt(hf*(hf-u.r)*(hf-v.r)*(hf-d)); double a1=acos((u.r*u.r+d*d-v.r*v.r)/(2.0*u.r*d)); a1=a1*u.r*u.r; double a2=acos((v.r*v.r+d*d-u.r*u.r)/(2.0*v.r*d)); a2=a2*v.r*v.r; return a1+a2-ss; } //tangent lines i.e. sporshoks from point q to circle with center p and radius r int tangent_lines_from_point(PT p,double r,PT q,line &u,line &v) { int x=circle_point_relation(p,r,q); if (x==2) return 0; if (x==1) { u=line(q,q+rotateccw90(q-p)); v=u; return 1; } double d=dist(p,q); double l=sqr(r)/d; double h=sqrt(sqr(r)-sqr(l)); u=line(q,p+((q-p).trunc(l)+(rotateccw90(q-p).trunc(h)))); v=line(q,p+((q-p).trunc(l)+(rotatecw90(q-p).trunc(h)))); return 2; } //returns outer tangents line of two circles // if inner==1 it returns inner tangent lines int tangents_lines_from_circle(PT c1, double r1, PT c2, double r2, bool inner, line &u,line &v) { if (inner) r2 = -r2; PT d = c2-c1; double dr = r1-r2, d2 = d.val(), h2 = d2-dr*dr; if (d2 == 0 || h2 < 0) { assert(h2 != 0); return 0; } vector<pair<PT,PT>>out; for (int tmp :{-1,1}){ PT v = (d*dr + rotateccw90(d)*sqrt(h2)*tmp)/d2; out.pb({c1 + v*r1, c2 + v*r2}); } u=line(out[0].F,out[0].S); if(out.size()==2) v=line(out[1].F,out[1].S); return 1 + (h2 > 0); } //a polygon is defined by n points //here l[] array stores lines of the polygon struct polygon { int n; PT p[mxp]; line l[mxp]; void in(int _n){ n=_n; for (int i=0;i<n;i++) p[i].in(); } void add(PT q){p[n++]=q;} void getline(){ for (int i=0;i<n;i++) l[i]=line(p[i],p[(i+1)%n]); } double getcircumference() { double sum=0; int i; for (i=0;i<n;i++) { sum+=dist(p[i],p[(i+1)%n]); } return sum; } double getarea() { double sum=0; int i; for (i=0;i<n;i++) { sum+=cross(p[i],p[(i+1)%n]); } return fabs(sum)/2; } //returns 0 for cw, 1 for ccw bool getdir() { double sum=0; int i; for (i=0;i<n;i++) { sum+=cross(p[i],p[(i+1)%n]); } if (sign(sum)>0)return 1; return 0; } struct cmp{ PT p; cmp(const PT &p0){p=p0;} bool operator()(const PT &aa,const PT &bb){ PT a=aa,b=bb; int d=sign(cross(a-p,b-p)); if (d==0) return sign(dist(a,p)-dist(b,p))<0; return d>0; } }; //sorting in convex_hull order void norm(){ PT mi=p[0]; for (int i=1;i<n;i++)mi=min(mi,p[i]); sort(p,p+n,cmp(mi)); } //returns convex hull in convex (monotone chain) void getconvex(polygon &convex) { int i,j,k; sort(p,p+n); convex.n=n; for (i=0;i<min(n,2);i++) { convex.p[i]=p[i]; } if (n<=2)return; int &top=convex.n; top=1; for (i=2;i<n;i++) { while (top&&cross(convex.p[top]-p[i],convex.p[top-1]-p[i])<=0) top--; convex.p[++top]=p[i]; } int temp=top; convex.p[++top]=p[n-2]; for (i=n-3;i>=0;i--) { while (top!=temp&&cross(convex.p[top]-p[i],convex.p[top-1]-p[i])<=0) top--; convex.p[++top]=p[i]; } } //checks if convex bool isconvex() { bool s[3]; memset(s,0,sizeof(s)); int i,j,k; for (i=0;i<n;i++) { j=(i+1)%n; k=(j+1)%n; s[sign(cross(p[j]-p[i],p[k]-p[i]))+1]=1; if (s[0]&&s[2])return 0; } return 1; } //used for later function double xmult(PT a, PT b, PT c) { return cross(b - a,c - a); } // returns // 3 - if q is a vertex // 2 - if on a side // 1 - if inside // 0 - if outside int relation_point(PT q){ int i,j; for (i=0;i<n;i++){ if (p[i]==q)return 3; } getline(); for (i=0;i<n;i++){ if (is_point_on_seg(l[i].a,l[i].b,q))return 2; } int cnt=0; for (i=0;i<n;i++){ j=(i+1)%n; int k=sign(cross(q-p[j],p[i]-p[j])); int u=sign(p[i].y-q.y); int v=sign(p[j].y-q.y); if (k>0&&u<0&&v>=0)cnt++; if (k<0&&v<0&&u>=0)cnt--; } return cnt!=0; } //returns minimum enclosing circle void find_(int st,PT tri[],circle &c){ if (!st) c=circle(PT(0,0),-2); if (st==1) c=circle(tri[0],0); if (st==2) c=circle((tri[0]+tri[1])/2.0,dist(tri[0],tri[1])/2.0); if (st==3) c=circle(tri[0],tri[1],tri[2]); } void solve(int cur,int st,PT tri[],circle &c){ find_(st,tri,c); if (st==3)return; int i; for (i=0;i<cur;i++){ if (sign(dist(p[i],c.p)-c.r)>0){ tri[st]=p[i]; solve(i,st+1,tri,c); } } } circle minimum_enclosing_circle(){ random_shuffle(p,p+n); PT tri[4]; circle c; solve(n,0,tri,c); return c; } }; //stores some polygons struct polygons { vector<polygon>p; polygons(){p.clear();} void clear(){p.clear();} void push(polygon q){if (sign(q.getarea()))p.pb(q);} vector<pair<double,int> >e; //used for later use void ins(PT s,PT t,PT X,int i){ double r=fabs(t.x-s.x)>eps?(X.x-s.x)/(t.x-s.x):(X.y-s.y)/(t.y-s.y); r=fmin(r,1.0);r=fmax(r,0.0); e.pb(MP(r,i)); } double polyareaunion(){ double ans=0.0; int c0,c1,c2,i,j,k,w; for (i=0;i<p.size();i++) if (p[i].getdir()==0)reverse(p[i].p,p[i].p+p[i].n); for (i=0;i<p.size();i++){ for (k=0;k<p[i].n;k++){ PT &s=p[i].p[k],&t=p[i].p[(k+1)%p[i].n]; if (!sign(cross(s,t)))continue; e.clear(); e.pb(MP(0.0,1)); e.pb(MP(1.0,-1)); for (j=0;j<p.size();j++)if (i!=j){ for (w=0;w<p[j].n;w++){ PT a=p[j].p[w],b=p[j].p[(w+1)%p[j].n],c=p[j].p[(w-1+p[j].n)%p[j].n]; c0=sign(cross(t-s,c-s)); c1=sign(cross(t-s,a-s)); c2=sign(cross(t-s,b-s)); if (c1*c2<0)ins(s,t,line(s,t).cross_point(line(a,b)),-c2); else if (!c1&&c0*c2<0)ins(s,t,a,-c2); else if (!c1&&!c2){ int c3=sign(cross(t-s,p[j].p[(w+2)%p[j].n]-s)); int dp=sign(dot(t-s,b-a)); if (dp&&c0)ins(s,t,a,dp>0?c0*((j>i)^(c0<0)):-(c0<0)); if (dp&&c3)ins(s,t,b,dp>0?-c3*((j>i)^(c3<0)):c3<0); } } } sort(e.begin(),e.end()); int ct=0; double tot=0.0,last; for (j=0;j<e.size();j++){ if (ct==2)tot+=e[j].first-last; ct+=e[j].second; last=e[j].first; } ans+=cross(s,t)*tot; } } return fabs(ans)*0.5; } }; int main() { fast; int n; cin>>n; polygon p; for(int i=0; i<n; i++) { PT m; cin>>m ; p.add(m); } cout<<fout(10)<<p.minimum_enclosing_circle().r<<nl; return 0; }
[ "shahjalalshohag2014@gmail.com" ]
shahjalalshohag2014@gmail.com
955f47324e6745535cb8bdff437197ceb40cbe21
055653087007b1ed0772b49c8abe0374730a9a1c
/app/showtrimmedfromstart.cpp
ffc84dcaa7c7dbc87f4cc70f0df7424464b49a02
[]
no_license
nfilin480/task2_po
ec42c0099c06d84bb5b634e69cb81defca009548
3c61553b2b4667f8cc156321637ae753011efdb6
refs/heads/master
2022-05-26T22:32:57.417263
2020-04-29T16:46:46
2020-04-29T16:46:46
258,138,575
0
0
null
null
null
null
UTF-8
C++
false
false
1,175
cpp
/** * showtrimmedfromstart.cpp -- реализует команду вывода хранимого текста на экран * * Copyright (c) 2020, Filin Nikolay <nfilin@petrsu.ru> * * This code is licensed under a MIT-style license. */ #include "load.h" #include "text/text.h" #include <cctype> #include <string.h> #include <iostream> #include <assert.h> static void showfromstart_line(int index, string contents, int cursor, void *data); void showfromstart(text txt) { /*Применяем функцию showfromstart_line к каждой строке*/ process_forward(txt, showfromstart_line, NULL); } static void showfromstart_line(int index, string contents, int cursor, void *data) { /*Получаем всегда существующую строку*/ assert(!(contents.empty())); /* Декларируем неиспользуемые параметры */ UNUSED(index); UNUSED(cursor); UNUSED(data); /*Обрабатываем строку*/ int i = 0; while(isspace(contents[i]) != 0) i++; /* Выводим строку на экран */ cout << contents.substr(i, contents.size()); }
[ "nfilin@cs.petrsu.ru" ]
nfilin@cs.petrsu.ru
560e1a0dd0e4cac757236c14962888a6ef4c7a0b
929f3d51da17a3a81581a9a7575055516d1dbaee
/notify_test/notificationwidget.h
d20be7a2423fd342110e37a74ed184b1d1711554
[]
no_license
saibi/rk3399_qt
616c015395dd56be7ba7a3894852052b9081b813
a04e4611f1744b0eca58a672d62b49fd67beb039
refs/heads/master
2021-06-17T03:33:39.045685
2021-04-13T06:05:51
2021-04-13T06:05:51
195,921,660
0
0
null
null
null
null
UTF-8
C++
false
false
504
h
#ifndef NOTIFICATIONWIDGET_H #define NOTIFICATIONWIDGET_H #include <QWidget> namespace Ui { class NotificationWidget; } class NotificationWidget : public QWidget { Q_OBJECT public: explicit NotificationWidget(QWidget *parent = 0); ~NotificationWidget(); void setText(const QString& text); QString text(); protected: virtual void showEvent(QShowEvent *); virtual void mousePressEvent(QMouseEvent *); private slots: private: Ui::NotificationWidget *ui; }; #endif // NOTIFICATIONWIDGET_H
[ "ymkim@huvitz.com" ]
ymkim@huvitz.com
c0237061602a6c1dff506244c8701167bf81be32
a2fc06cf458f896d2217592ac92098863e755a9c
/src/program/imagery/download_imagery.cpp
149b3a407b46cf5ae85addc408000211b06470bf
[]
no_license
MrBrood/Stanford-Junior-self-driving-car
ba3f2a07a9366d3566def59fd25f90bad55748d2
d999e94bb287933666dac82129cad6702923a8e1
refs/heads/master
2023-07-18T04:56:02.055754
2020-08-21T01:31:46
2020-08-21T01:31:46
null
0
0
null
null
null
null
UTF-8
C++
false
false
13,400
cpp
#include <roadrunner.h> #include <curl/curl.h> #include <curl/types.h> #include <curl/easy.h> #include <lltransform.h> #include "terraserver.h" #define RADIUS_OF_EARTH 6378100.0 #define NUM_THREADS 3 using namespace vlr; /* array of URL fetching threads */ pthread_t *thread = NULL; int *thread_num; long int *total_bytes; /* filename and URL to capture */ char filename_to_get[1000]; char url_to_get[1000]; int quit_flag = 0; double start_time; int assignment_ready = 0; pthread_mutex_t ready_mutex; pthread_cond_t ready_cond; int assignment_accepted = 0; pthread_mutex_t accepted_mutex; pthread_cond_t accepted_cond; int read_boundary_file(char *filename, double *lat_min, double *lon_min, double *lat_max, double *lon_max) { FILE *fp; fp = fopen(filename, "r"); if(fp == NULL) return -1; fscanf(fp, "%lf\n%lf\n%lf\n%lf\n", lat_min, lon_min, lat_max, lon_max); fclose(fp); return 0; } typedef struct { double lat, lon; } latlon_t, *latlon_p; int read_list_file(char *filename, latlon_p *list, int *list_length) { char line[1000], *err; int max_length = 0; FILE *fp; *list = NULL; *list_length = 0; fp = fopen(filename, "r"); if(fp == NULL) return -1; do { err = fgets(line, 1000, fp); if(err != NULL) { if(*list_length == max_length) { max_length += 100; *list = (latlon_p)realloc(*list, max_length * sizeof(latlon_t)); dgc_test_alloc(*list); } sscanf(line, "%lf %lf", &((*list)[*list_length].lat), &((*list)[*list_length].lon)); (*list_length)++; } } while(err != NULL); fclose(fp); return 0; } inline int fetch_url(CURL *curl_handle, char *url, char *filename, int thread_num) { FILE *out_fp; int err; out_fp = fopen(filename, "w"); if(out_fp == NULL) { fprintf(stderr, "Error: could not open file %s for writing.\n", filename); return -1; } curl_easy_setopt(curl_handle, CURLOPT_URL, url); curl_easy_setopt(curl_handle, CURLOPT_WRITEDATA, (void *)out_fp); curl_easy_setopt(curl_handle, CURLOPT_USERAGENT, "libcurl-agent/1.0"); err = curl_easy_perform(curl_handle); fclose(out_fp); if(err != 0) return -1; total_bytes[thread_num] += dgc_file_size(filename); return 0; } void child_wait_for_assignment(char *url, char *filename, int *quit) { /* wait for the assignment condition variable to go true */ pthread_mutex_lock(&ready_mutex); while(!assignment_ready && !quit_flag) pthread_cond_wait(&ready_cond, &ready_mutex); /* copy global URL and filename to thread */ strcpy(url, url_to_get); strcpy(filename, filename_to_get); *quit = quit_flag; assignment_ready = 0; pthread_mutex_unlock(&ready_mutex); /* tell the parent we have accepted the assignment */ pthread_mutex_lock(&accepted_mutex); assignment_accepted = 1; pthread_cond_signal(&accepted_cond); pthread_mutex_unlock(&accepted_mutex); } void parent_wait_for_assignment(void) { /* wait until someone accepts it */ pthread_mutex_lock(&accepted_mutex); while(!assignment_accepted) pthread_cond_wait(&accepted_cond, &accepted_mutex); assignment_accepted = 0; pthread_mutex_unlock(&accepted_mutex); } void *fetch_thread(void *arg) { int thread_num = *((int *)arg); char url[256], filename[256]; CURL *curl_handle; int quit = 0; thread_num = thread_num; curl_handle = curl_easy_init(); do { /* get an assignment from parent thread */ child_wait_for_assignment(url, filename, &quit); if(quit) return NULL; /* do it */ fetch_url(curl_handle, url, filename, thread_num); } while(1); return NULL; curl_easy_cleanup(curl_handle); } void create_threads(void) { int i; /* create mutex and condition variables */ assignment_ready = 0; pthread_mutex_init(&ready_mutex, NULL); pthread_cond_init(&ready_cond, NULL); assignment_accepted = 0; pthread_mutex_init(&accepted_mutex, NULL); pthread_cond_init(&accepted_cond, NULL); /* spawn N threads */ thread = (pthread_t *)calloc(NUM_THREADS, sizeof(pthread_t)); dgc_test_alloc(thread); thread_num = (int *)calloc(NUM_THREADS, sizeof(int)); dgc_test_alloc(thread_num); total_bytes = (long int *)calloc(NUM_THREADS, sizeof(long int)); dgc_test_alloc(total_bytes); for(i = 0; i < NUM_THREADS; i++) pthread_create(&thread[i], NULL, fetch_thread, &thread_num[i]); } void stop_threads(void) { int i; if(thread != NULL) { pthread_mutex_lock(&ready_mutex); quit_flag = 1; pthread_cond_signal(&ready_cond); pthread_mutex_unlock(&ready_mutex); for(i = 0; i < NUM_THREADS; i++) pthread_join(thread[i], NULL); } } void fetch_terraserver_url(int terra_res_code, int terra_easting, int terra_northing, int zone_num, int image_type, char *filename) { static int first = 1; if(first) { create_threads(); first = 0; } /* make a new work assignment available */ pthread_mutex_lock(&ready_mutex); terraserver_url(terra_res_code, terra_easting, terra_northing, zone_num, image_type, url_to_get); strcpy(filename_to_get, filename); assignment_ready = 1; pthread_cond_signal(&ready_cond); pthread_mutex_unlock(&ready_mutex); parent_wait_for_assignment(); } void download_terraserver_area(double lon1, double lat1, double lon2, double lat2, int image_type, double image_resolution, char *dirname, int no_count) { double easting1, northing1, easting2, northing2; char zone1[10], zone2[10]; int zone_num1, terra_easting1, terra_northing1, terra_res_code; int zone_num2, terra_easting2, terra_northing2; char filename[200], dir2name[200]; int x, y, count = 1; double kpersec; int i, bytes = 0; latLongToUtm(lat1, lon1, &easting1, &northing1, zone1); latLongToUtm(lat2, lon2, &easting2, &northing2, zone2); terra_coords(easting1, northing1, zone1, image_resolution, &terra_res_code, &terra_easting1, &terra_northing1, &zone_num1); terra_coords(easting2, northing2, zone2, image_resolution, &terra_res_code, &terra_easting2, &terra_northing2, &zone_num2); if(zone_num1 != zone_num2) dgc_die("Error: entire boundary must lie within one UTM zone.\n" "Zones %s %s\n", zone1, zone2); if(!no_count) fprintf(stderr, " Resolution %.2f : Download %d images\n", image_resolution, (terra_easting2 - terra_easting1 + 1) * (terra_northing2 - terra_northing1 + 1)); /* make subdirectories */ sprintf(dir2name, "%s/%d", dirname, image_type); if(!dgc_file_exists(dir2name)) mkdir(dir2name, 0755); sprintf(dir2name, "%s/%d/%d", dirname, image_type, terra_res_code); if(!dgc_file_exists(dir2name)) mkdir(dir2name, 0755); for(x = terra_easting1; x <= terra_easting2; x++) { sprintf(dir2name, "%s/%d/%d/%d", dirname, image_type, terra_res_code, x); if(!dgc_file_exists(dir2name)) mkdir(dir2name, 0755); for(y = terra_northing1; y <= terra_northing2; y++) { if(image_type == TOPO_IMAGE) { if(image_resolution == 4.0 || image_resolution == 16.0 || image_resolution == 64.0 || image_resolution == 128.0 || image_resolution == 256.0) sprintf(filename, "%s/%d/%d/%d/usgs-%d-%d-%d-%d.jpg", dirname, image_type, terra_res_code, x, terra_res_code, x, y, zone_num1); else sprintf(filename, "%s/%d/%d/%d/usgs-%d-%d-%d-%d.gif", dirname, image_type, terra_res_code, x, terra_res_code, x, y, zone_num1); } else { sprintf(filename, "%s/%d/%d/%d/usgs-%d-%d-%d-%d.jpg", dirname, image_type, terra_res_code, x, terra_res_code, x, y, zone_num1); } bytes = 0; if(total_bytes != NULL) for(i = 0; i < NUM_THREADS; i++) bytes += total_bytes[i]; kpersec = bytes / 1024.0 / (dgc_get_time() - start_time); if(!dgc_file_exists(filename)) { if(no_count) fprintf(stderr, "\r Image : %d, %d (%.1fK/s) DOWNLOADING ", x, y, kpersec); else fprintf(stderr, "\r Image %d : %d, %d (%.2f%%) (%.1fK/s) DOWNLOADING ", count, x, y, count / (float)((terra_easting2 - terra_easting1 + 1) * (terra_northing2 - terra_northing1 + 1)) * 100.0, kpersec); fetch_terraserver_url(terra_res_code, x, y, zone_num1, image_type, filename); } else if(dgc_file_size(filename) == 0) { if(!no_count) { fprintf(stderr, "\nfile %s file size 0\n", filename); // exit(0); if(no_count) fprintf(stderr, "\r Image : %d, %d (%.1fK/s) REDOWNLOADING ", x, y, kpersec); else fprintf(stderr,"\r Image %d : %d, %d (%.2f%%) (%.1fK/s) REDOWNLOADING ", count, x, y, count / (float)((terra_easting2 - terra_easting1 + 1) * (terra_northing2 - terra_northing1 + 1)) * 100.0, kpersec); fetch_terraserver_url(terra_res_code, x, y, zone_num1, image_type, filename); } } else { if(no_count) fprintf(stderr, "\r Image : %d, %d (%.1fK/s) SKIPPING ", x, y, kpersec); else fprintf(stderr,"\r Image %d : %d, %d (%.2f%%) (%.1fK/s) SKIPPING ", count, x, y, count / (float)((terra_easting2 - terra_easting1 + 1) * (terra_northing2 - terra_northing1 + 1)) * 100.0, kpersec); } count++; } } if(!no_count) fprintf(stderr, "\n"); } int main(int argc, char **argv) { int from_list = 0, have_color = 0, want_topo = 0, list_length = 0, i, i2, n; double lat_min, lon_min, lat_max, lon_max, resolution, r, x1, x2, y1, y2; double l, u, x, y, lat, lon; char dirname[100], dir2name[100], response[1000], zone1[10], zone2[10]; latlon_p list = NULL; if(argc < 3) dgc_die("Error: not enough arguments.\n" "Usage: %s boundary-file imagery-dir or\n" " %s latlon-list-file imagery-dir [radius-miles]\n", argv[0], argv[0]); /* boundary file must end in .txt */ if(strcmp(argv[1] + strlen(argv[1]) - 4, ".txt") == 0) from_list = 0; else if(strcmp(argv[1] + strlen(argv[1]) - 5, ".list") == 0) { from_list = 1; } else dgc_die("Error: filename must end in .txt or .list"); strcpy(dirname, argv[2]); fprintf(stderr, "boundary file : %s\n", argv[1]); fprintf(stderr, "imagery dir : %s\n", dirname); /* make sure we have a usgs sub-directory */ strcpy(dir2name, dirname); strcat(dir2name, "/usgs"); if(!dgc_file_exists(dir2name)) mkdir(dir2name, 0755); /* ask if we have color imagery */ do { fprintf(stderr, "Does this area have color imagery (yes/no): "); fgets(response, 1000, stdin); } while(strlen(response) < 1 || (response[0] != 'y' && response[0] != 'Y' && response[0] != 'n' && response[0] != 'N')); have_color = (response[0] == 'y' || response[0] == 'Y'); /* ask if we want topo imagery */ do { fprintf(stderr, "Do you want topo imagery? (yes/no): "); fgets(response, 1000, stdin); } while(strlen(response) < 1 || (response[0] != 'y' && response[0] != 'Y' && response[0] != 'n' && response[0] != 'N')); want_topo = (response[0] == 'y' || response[0] == 'Y'); start_time = dgc_get_time(); if(from_list) { if(read_list_file(argv[1], &list, &list_length) < 0) dgc_die("Error: could not read list file %s\n", argv[1]); r = dgc_miles2meters(0.25); if(argc >= 4) r = dgc_miles2meters(atof(argv[3])); for(i = 0; i < list_length; i++) { fprintf(stderr, "at waypoint %d of %d\n", i, list_length); i2 = i + 1; if(i2 >= list_length) i2 = list_length - 1; latLongToUtm(list[i].lat, list[i].lon, &x1, &y1, zone1); latLongToUtm(list[i2].lat, list[i2].lon, &x2, &y2, zone2); l = hypot(x2 - x1, y2 - y1); n = (int)floor(l / 50.0) + 1; for(u = 0; u <= n; u++) { x = x1 + u / (double)n * (x2 - x1); y = y1 + u / (double)n * (y2 - y1); utmToLatLong(x, y, zone1, &lat, &lon); /* download imagery inside boundary */ if(have_color) { for(resolution = 0.25; resolution < 257.0; resolution *= 2) download_terraserver_area(lon - dgc_r2d(r / RADIUS_OF_EARTH) * cos(lat), lat - dgc_r2d(r / RADIUS_OF_EARTH), lon + dgc_r2d(r / RADIUS_OF_EARTH) * cos(lat), lat + dgc_r2d(r / RADIUS_OF_EARTH), COLOR_IMAGE, resolution, dir2name, 1); } } } exit(0); } else { /* read boundary */ if(read_boundary_file(argv[1], &lat_min, &lon_min, &lat_max, &lon_max) < 0) dgc_die("Error: could not read boundary file %s\n", argv[1]); /* download imagery inside boundary */ if(have_color) { fprintf(stderr, "Downloading color imagery:\n"); for(resolution = 256.0; resolution > 0.24; resolution /= 2.0) download_terraserver_area(lon_min, lat_min, lon_max, lat_max, COLOR_IMAGE, resolution, dir2name, 0); } else { fprintf(stderr, "Downloading bw imagery:\n"); start_time = dgc_get_time(); for(resolution = 1; resolution < 257.0; resolution *= 2) download_terraserver_area(lon_min, lat_min, lon_max, lat_max, BW_IMAGE, resolution, dir2name, 0); } if(want_topo) { fprintf(stderr, "Downloading topo imagery:\n"); start_time = dgc_get_time(); for(resolution = 2; resolution < 257.0; resolution *= 2) download_terraserver_area(lon_min, lat_min, lon_max, lat_max, TOPO_IMAGE, resolution, dir2name, 0); } } stop_threads(); return 0; }
[ "6959037@qq.com" ]
6959037@qq.com
c3b71e0b56788646f5ae83732cf968e8f05370fb
618e6e8e37de621d291d85dbedf2b77e890f2de1
/LibXenoverse/LibXenoverse/EMA.h
4c21b9e8d5fd0987a5b6107bc4b60d8ecc9117d5
[]
no_license
hut518/LibXenoverse2
708e5c2138b55592f387316113ca9f193fefeb2a
8414e2c923eebe501ca83ea654cdf54552e65525
refs/heads/master
2021-07-19T17:55:31.661214
2017-10-16T13:56:38
2017-10-16T13:56:38
null
0
0
null
null
null
null
UTF-8
C++
false
false
9,888
h
#ifndef __EMAFILE_H__ #define __EMAFILE_H__ // From emoTools of Eternity #include <vector> #include "EMO_common.h" #include "EMO_Skeleton.h" #include "EMO.h" // "#EMA" #define EMA_SIGNATURE 0x414D4523 #ifdef _MSC_VER #pragma pack(push,1) #endif namespace LibXenoverse { typedef struct { uint32_t signature; // 0 uint16_t endianess_check; // 4 uint16_t header_size; // 6 uint16_t unk_08; // 8 non-zero uint16_t unk_0A; // A, zero uint32_t skeleton_offset; // 0xC uint16_t anim_count; // 0x10 uint16_t unk_12; // 0x12 uint32_t unk_14[3]; // 0x14 probably just padding // size 0x20 } PACKED EMAHeader; static_assert(sizeof(EMAHeader) == 0x20, "Incorrect structure size."); typedef struct { uint16_t duration; // 0 uint16_t cmd_count; // 2 uint32_t value_count; // 4 uint32_t unk_08; // 8 uint32_t name_offset; // 0xC uint32_t values_offset; // 0x10 uint32_t cmd_offsets[1]; // 0x14 // remaining cmd_offsets } PACKED EMAAnimationHeader; static_assert(sizeof(EMAAnimationHeader) == 0x18, "Incorrect structure size."); typedef struct { uint16_t bone_idx; // 0 uint8_t transform; // 2 // 0 -> translation, 1 -> rotation, 2 -> scale uint8_t transformComponent; // 3 //4bits : ? / 2bits: transform component ( a record has 0, the next 1, then 2 ) // 0 -> x, 1 -> y, 2 -> z. // so rotations is Euler angles (no 4 quaternions componentes) uint16_t step_count; // 4 uint16_t indices_offset; // 6 } PACKED EMAAnimationCommandHeader; static_assert(sizeof(EMAAnimationCommandHeader) == 8, "Incorrect structure size."); #ifdef _MSC_VER #pragma pack(pop) #endif class EMA; class EmaAnimation; struct EmaStep { uint16_t time; uint32_t index; void Decompile(TiXmlNode *root, const std::vector<float> &values) const; bool Compile(const TiXmlElement *root); inline bool operator==(const EmaStep &rhs) const { return (this->time == rhs.time && this->index == rhs.index); } inline bool operator!=(const EmaStep &rhs) const { return !(*this == rhs); } }; class EmaCommand { friend class EMA; friend class EmaAnimation; friend class EMA_Material_Animation; private: EMO_Bone *bone; uint8_t transform; uint8_t transformComponent; uint8_t timesByteSize; uint8_t indexesByteSize; std::vector<EmaStep> steps; public: void readEANKeyframedAnimation(EANKeyframedAnimation* ean, std::vector<float> &values, size_t currComponent); void writeEANKeyframe(EANKeyframe* ean, std::vector<float> &values, size_t frame); inline EMO_Bone *GetBone() { return bone; } inline uint16_t GetNumSteps() const { return steps.size(); } inline bool RemoveStep(uint16_t id) { if (id >= steps.size()) return false; steps.erase(steps.begin() + id); return true; } void Decompile(TiXmlNode *root, uint32_t id, const std::vector<float> &values) const; bool Compile(const TiXmlElement *root, EMO_Skeleton &skl); inline bool operator==(const EmaCommand &rhs) const { if (!this->bone) { if (rhs.bone) return false; } else if (!rhs.bone) { return false; } if((this->bone)&& (this->bone->GetName() != rhs.bone->GetName())) return false; return (this->transform == rhs.transform && this->transformComponent == rhs.transformComponent && this->steps == rhs.steps); } inline bool operator!=(const EmaCommand &rhs) const { return !(*this == rhs); } inline EmaStep &operator[](size_t n) { return steps[n]; } inline const EmaStep &operator[](size_t n) const { return steps[n]; } inline std::vector<EmaStep>::iterator begin() { return steps.begin(); } inline std::vector<EmaStep>::iterator end() { return steps.end(); } inline std::vector<EmaStep>::const_iterator begin() const { return steps.begin(); } inline std::vector<EmaStep>::const_iterator end() const { return steps.end(); } }; class EmaAnimation { friend class EMA; friend class EMA_Material_Animation; private: std::string name; uint16_t duration; std::vector<float> values; std::vector<EmaCommand> commands; uint32_t unk_08; public: void readEANAnimation(EANAnimation* ean, ESK* esk, EMO_Skeleton* emoSkeleton); void writeEANAnimation(EANAnimation* ean, ESK* esk); inline std::string GetName() const { return name; } inline void SetName(const std::string &name) { this->name = name; } inline uint16_t GetDuration() const { return duration; } inline void SetDuration(uint16_t duration) { this->duration = duration; } inline uint16_t GetNumCommands() const { return commands.size(); } inline bool RemoveCommand(uint16_t id) { if (id >= commands.size()) return false; commands.erase(commands.begin() + id); return true; } void Decompile(TiXmlNode *root, uint32_t id) const; bool Compile(const TiXmlElement *root, EMO_Skeleton &skl); inline bool operator==(const EmaAnimation &rhs) const { return (this->name == rhs.name && this->duration == rhs.duration && this->values == rhs.values && this->commands == rhs.commands); } inline bool operator!=(const EmaAnimation &rhs) const { return !(*this == rhs); } inline EmaCommand &operator[](size_t n) { return commands[n]; } inline const EmaCommand &operator[](size_t n) const { return commands[n]; } inline std::vector<EmaCommand>::iterator begin() { return commands.begin(); } inline std::vector<EmaCommand>::iterator end() { return commands.end(); } inline std::vector<EmaCommand>::const_iterator begin() const { return commands.begin(); } inline std::vector<EmaCommand>::const_iterator end() const { return commands.end(); } }; class EMA : public EMO_Skeleton { friend class EMA_Material; private: std::vector<EmaAnimation> animations; uint16_t unk_08; uint16_t unk_12; void Copy(const EMA &other); void Reset(); unsigned int CalculateFileSize() const; protected: virtual void RebuildSkeleton(const std::vector<EMO_Bone *> &old_bones_ptr) override; public: EMA(); EMA(const EMO &other) : EMO_Skeleton() { Copy(other); } virtual ~EMA(); void readEAN(EAN* ean); void readEsk(ESK* esk); void writeEsk(ESK* esk); //need read esk before the rest, because of pointer void writeEAN(EAN* ean); void writeEsk__recursive(EMO_Bone* emoBone, std::vector<EMO_Bone> &bones, EskTreeNode* treeNode, std::vector<EskTreeNode*> &listTreeNode); inline uint16_t GetNumAnimations() const { return animations.size(); } inline bool HasSkeleton() const { return (bones.size() > 0); } inline EmaAnimation *GetAnimation(uint16_t idx) { if (idx >= animations.size()) return nullptr; return &animations[idx]; } inline const EmaAnimation *GetAnimation(uint16_t idx) const { if (idx >= animations.size()) return nullptr; return &animations[idx]; } inline EmaAnimation *GetAnimation(const std::string &name) { for (EmaAnimation &a : animations) if (a.name == name) return &a; return nullptr; } inline const EmaAnimation *GetAnimation(const std::string &name) const { for (const EmaAnimation &a : animations) if (a.name == name) return &a; return nullptr; } inline bool AnimationExists(uint16_t idx) const { return (GetAnimation(idx) != nullptr); } inline bool AnimationExists(const std::string &name) const { return (GetAnimation(name) != nullptr); } inline uint16_t FindAnimation(const std::string &name) const { for (size_t i = 0; i < animations.size(); i++) { if (animations[i].name == name) return i; } return 0xFFFF; } inline bool RemoveAnimation(uint16_t idx) { if (idx >= animations.size()) return false; animations.erase(animations.begin() + idx); } inline bool RemoveAnimation(const std::string &name) { for (auto it = animations.begin(); it != animations.end(); ++it) { if ((*it).name == name) { animations.erase(it); return true; } } return false; } bool LinkAnimation(EmaAnimation &anim, EMO_Bone **not_found = nullptr); uint16_t AppendAnimation(const EmaAnimation &animation); uint16_t AppendAnimation(const EMA &other, const std::string &name); virtual bool Load(const uint8_t *buf, unsigned int size) override; virtual uint8_t *CreateFile(unsigned int *psize) override; virtual TiXmlDocument *Decompile() const override; virtual bool Compile(TiXmlDocument *doc, bool big_endian = false) override; virtual bool DecompileToFile(const std::string &path, bool show_error = true, bool build_path = false) override; virtual bool CompileFromFile(const std::string &path, bool show_error = true, bool big_endian = false) override; inline EMA &operator=(const EMA &other) { if (this == &other) return *this; Copy(other); return *this; } bool operator==(const EMA &rhs) const; inline bool operator!=(const EMA &rhs) const { return !(*this == rhs); } inline EmaAnimation &operator[](size_t n) { return animations[n]; } inline const EmaAnimation &operator[](size_t n) const { return animations[n]; } inline EmaAnimation &operator[](const std::string &name) { EmaAnimation *a = GetAnimation(name); if (!a) throw std::out_of_range("Animation " + name + " doesn't exist."); return *a; } inline const EmaAnimation &operator[](const std::string &name) const { const EmaAnimation *a = GetAnimation(name); if (!a) throw std::out_of_range("Animation " + name + " doesn't exist."); return *a; } inline const EMA operator+(const EmaAnimation &animation) const { EMA new_ema = *this; new_ema.AppendAnimation(animation); return new_ema; } inline EMA &operator+=(const EmaAnimation &animation) { this->AppendAnimation(animation); return *this; } inline std::vector<EmaAnimation>::iterator begin() { return animations.begin(); } inline std::vector<EmaAnimation>::iterator end() { return animations.end(); } inline std::vector<EmaAnimation>::const_iterator begin() const { return animations.begin(); } inline std::vector<EmaAnimation>::const_iterator end() const { return animations.end(); } }; } #endif
[ "Olganix@hotmail.fr" ]
Olganix@hotmail.fr
4ed89766b2aeecf53518580f98130db4a6b94720
5e77f66c7eb2500a578b1651ea72856e52b78eec
/Game model/Building.cpp
030ec9391ea9e70250d1e60eae5b0f5631da36f7
[]
no_license
sus-scrofa/SKIRMISH_WARS
724d4c7d2ba4e4ba38761f977fd9a7b218ab16c6
adf49e1f9da17a2a3980a3dadbbcf1a8d5f6a011
refs/heads/master
2020-12-02T21:02:27.721991
2018-08-01T20:26:22
2018-08-01T20:26:22
96,247,020
0
1
null
null
null
null
UTF-8
C++
false
false
1,348
cpp
#include "Building.h" #define CP_PER_TURN 2 #define RED_CP_PER_TURN 1 //reduced capture points void setCapturePoints(building_t type, unsigned int& cp); Building::Building(building_t type, player_t player) : type(type) { this->player = player; setCapturePoints(type, capturePoints); } Building :: ~Building() { ; } building_t Building::getType() { return type; } player_t Building::getPlayer() { return player; } player_t Building::capture(bool isReduced, player_t player) { unsigned int lostCps; player_t capturedFrom = N_PLAYERS; if (player != this->player) { if (isReduced) lostCps = RED_CP_PER_TURN; else lostCps = CP_PER_TURN; if (lostCps < capturePoints) { capturePoints -= lostCps; } else { setCapturePoints(type, capturePoints); capturedFrom = this->player; this->player = player; } } return capturedFrom; } void Building::uncapture() { setCapturePoints(type, capturePoints); } unsigned int Building::getCapturePoints() { return capturePoints; } bool Building::isBeingCaptured() { unsigned int maxCp = 0; setCapturePoints(type, maxCp); return (capturePoints != maxCp); } void setCapturePoints(building_t type, unsigned int& cp) { if (type == HEADQUARTERS) cp = CP_HQ; else cp = CP_DEFAULT; }
[ "noreply@github.com" ]
noreply@github.com
9103354c1c49e355cc70929822ce318b88fc039f
bad489aef94ee3bfcf6e5424cd83de5641b4515e
/worker/include/worker.hpp
de89aa5e8f9c56002e3e3c58c8d9f2ad6052c2a3
[]
no_license
ya0guang/sgx-tasks
e40f45d3a393091990caae6a7eede09a01f6dc2f
9edf4501de0c5a554f995b678a7f9dab8e830af7
refs/heads/master
2023-03-25T00:51:35.592470
2021-03-08T23:48:18
2021-03-08T23:48:18
null
0
0
null
null
null
null
UTF-8
C++
false
false
848
hpp
#ifndef BCEF8E54_DCF8_411B_93BD_B438AA05E830 #define BCEF8E54_DCF8_411B_93BD_B438AA05E830 #include <functional> #include <string> #include <zmq.hpp> #include "messages.hpp" #include "spdlog/spdlog.h" namespace tasker { class Worker { private: std::string SPACE = " "; zmq::socket_t *socket; const std::string id; const std::string type; std::function<void(std::string)> on_message; int64_t ping_interval = 10000; public: Worker(const std::string &id,const std::string &type); void OnMessage(const std::function<void(std::string)> &on_message); void Send(const std::string &cmd, const std::string &msg = "") const; int Start(std::string &driver_address); const std::string &GetId(); int64_t GetPingInterval(); }; } // namespace tasker #endif /* BCEF8E54_DCF8_411B_93BD_B438AA05E830 */
[ "chathurawidanage@gmail.com" ]
chathurawidanage@gmail.com
c0ecb5fa0e1f4f7a72a523b5c4cde03002ba0d44
5bae8e9c4a043d7f5d4662892a3ed81f39b2c81f
/MS5/iProduct.h
a7a5206d35d7756a2c245a3e5d0297d47655b816
[]
no_license
mmhaque7/OOP244
00bbc306207f088193c3ce8efc4bc27a4c0534d3
c22afd97576417d513fc361aae0d43cfd193a602
refs/heads/master
2020-05-20T16:54:56.858347
2019-05-08T20:47:04
2019-05-08T20:47:04
148,095,301
1
1
null
null
null
null
UTF-8
C++
false
false
1,084
h
/* * Mehedi Haque * 154908172 * Milestone 5 * April 8 2019 * Section A * */ #ifndef MS4_IPRODUCT_H #define MS4_IPRODUCT_H #include <fstream> #include <iostream> namespace ama { const int max_length_label = 30; const int max_length_sku = 7; const int max_length_name = 75; const int max_length_unit = 10; const int write_table = 1; const double tax_rate = 0.13; const int write_human = 2; const int write_condensed = 0; class iProduct { public: virtual ~iProduct() {} virtual std::ostream &write(std::ostream &os, int writeMode) const = 0; virtual std::istream &read(std::istream &is, bool interractive) = 0; virtual bool operator==(const char *sku) const = 0; virtual int qtyAvailable() const = 0; virtual int qtyNeeded() const = 0; virtual const char *name() const = 0; virtual double total_cost() const = 0; virtual bool operator>(const iProduct &other) const = 0; virtual int operator+=(int qty) = 0; }; } #endif //MS4_IPRODUCT_H
[ "mmhaque7@myseneca.ca" ]
mmhaque7@myseneca.ca
347352348b067156bec3d5986d4e8c965f762f42
ec69cc4bc5df21b1a31720fb4645756e274c2ff8
/ai_car_vs/MyUtils.h
b079fba45ec42bc1903d5f9c71e1f3c558894f5c
[]
no_license
xiongzebao/smart_cleaner
1541b3e001acd042f380a5bdc382f8f8a3ea9de4
f50defa7b81701b862188aaea8d5dc51b2d54d71
refs/heads/main
2023-02-13T16:20:26.571188
2021-01-10T14:51:21
2021-01-10T14:51:21
328,409,286
0
0
null
null
null
null
GB18030
C++
false
false
1,730
h
// MyUtils.h #ifndef _MYUTILS_h #define _MYUTILS_h #if defined(ARDUINO) && ARDUINO >= 100 #include "arduino.h" #else #include "WProgram.h" #endif // Utils.h #ifndef _UTILS_h #define _UTILS_h #if defined(ARDUINO) && ARDUINO >= 100 #include "arduino.h" #else #include "WProgram.h" #endif #include "MotorController.h" #include"Constant.h" class MyMotorClass; class VelometerClass; #endif class MyUtilsClass { public : //第一次开机检测电机最大转速并设置最大转速,耗时5s static void testMotorMaxSpeed(MotorControllerClass* const ctrlor) { //ctrlor->openLeftMotorMaxSpeed();//开启前左轮电机最大功率 ctrlor->setSpeed(300); ctrlor->forward(); delay(100); ctrlor->setSpeed(500); delay(3000); int speed = ctrlor->getSpeed().leftSpeed;//获取当前左轮电机速度 //Serial.println(ctrlor->velometer.rightSum); //Serial.println(ctrlor->velometer.leftSum); //Serial.println("max speed:"); //Serial.println(speed); //ctrlor->stopDetectSpeed(); //ctrlor->stop(); } public: bool isDigit(String str) { for (int i = 0; i < str.length(); i++) { char c = str.charAt(i); if (48 > c ||c> 57) { return false; } } return true; } void println(String s) { if (Constant::isDebug==true) { Serial.println(s); Serial.flush(); } } void println(int i) { if (Constant::isDebug == true) { Serial.println(i); Serial.flush(); } } void print(int i) { if (Constant::isDebug == true) { Serial.print(i); Serial.flush(); } } void print(String i) { if (Constant::isDebug == true) { Serial.print(i); Serial.flush(); } } public: void init(); }; extern MyUtilsClass MyUtils; #endif
[ "923450980@qq.com" ]
923450980@qq.com
cca635e42326f22e0983e598c7bd3d80d25c7892
2c3ba7dfcabb54dc0a604f24961dfeaef1c056cf
/1074.cpp
736c6990a080194706cdcbc6b827563542a638fc
[]
no_license
AbdullahJabir/uri_problem_solution
54323d7e7ca24e3189b70daaf5bf5aeb564ca1f9
6539cdacb95c5e2bfc63b6cf1473287b1df0cfab
refs/heads/master
2020-09-26T03:48:47.057328
2019-12-05T17:42:31
2019-12-05T17:42:31
226,157,588
0
0
null
null
null
null
UTF-8
C++
false
false
640
cpp
#include<bits/stdc++.h> using namespace std; int main(){ int x, a; cin >> x; for(int i = 0; i < x; i++){ cin >> a; if(a == 0){ cout << "NULL\n"; } else{ if(a>0) { if(a%2==0) cout<<"EVEN POSITIVE"<<endl; else cout<<"ODD POSITIVE"<<endl; } else if(a<0) { if(a%2==0) cout<<"EVEN NEGATIVE\n"; else cout<<"ODD NEGATIVE\n"; } } } return 0; }
[ "jabiralgazi94@gmail.com" ]
jabiralgazi94@gmail.com
f9a64166d9990f0bed8fda9684d3739e06c98a18
3f16c5f65e444efbcd17f03c710d9529913e11b1
/software/firmware/software_firmware_bz_firmware_bz_firmware.ino
3b270ef02dbb5539d44aacb8cbb8f3278a6719c1
[]
no_license
aerospike2/BZComputation
198dbf0ea3cc4fbcab3c97a44990def6495b64aa
516eab1cb568c009fcd577de6e1120e1c3271eb0
refs/heads/master
2023-03-19T02:55:42.809718
2021-03-12T10:25:29
2021-03-12T10:25:29
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,814
ino
/* https://learn.adafruit.com/adafruit-motor-shield-v2-for-arduino Code based on the above adafruit lib It doesn't have callbacks or error checking, so the user must be sure everything sent here is OK beforehand. The commands are like A_ M_ D_ S_ Each argument starts with a capital letter, followed by numbers (value of arg) Each argument is separated by 1 space A means Adafruit board. Depends on the assembly, at the moment 7 (0 to 6) (max is 32) M means motor. Each adafruit board can hold 4 motors. [1-4] D meand direction. Either 0 or 1. S means speed, which will define the PWM signal. Max in 255 Commands must end with '\n' Example: "A4 M2 D0 S100\n" */ #include <Wire.h> #include <Adafruit_MotorShield.h> #define BUFFER_SIZE 200 // Init adafruit boards const int n_shields = 12; //not sure whether it starts from 0 or 1, put it at 11 just in case Adafruit_MotorShield AFMS[n_shields]; // Pointer to motor that will be reused for each motor Adafruit_DCMotor *myMotor; // This function only reads from serial and stores the data read in buffer int read_command(char *buffer) { static int pos = 0; int rpos; if (Serial.available() > 0) { char readch = Serial.read(); switch (readch) { case '\n': rpos = pos; pos = 0; // Reset position index ready for next time return rpos; default: if (pos < BUFFER_SIZE -1) { buffer[pos++] = readch; buffer[pos] = '\0'; } else { Serial.println("666"); //buffer overflow } } } // no end line or char found, return -1 return -1; } void parse_command(char* command) { char* parameter; parameter = strtok(command, " "); long shield, motor, direction, speed; while (parameter != NULL) { switch(parameter[0]) { case 'A': shield = strtol(parameter+1, NULL, 10); break; case 'M': motor = strtol(parameter+1, NULL, 10); myMotor = AFMS[shield].getMotor(motor); break; case 'D': direction = strtol(parameter+1, NULL, 10); if (direction==0) { myMotor->run(BACKWARD); } else{ myMotor->run(FORWARD); } break; case 'S': speed = strtol(parameter+1, NULL, 10); myMotor->setSpeed(speed); if (speed == 0) { myMotor->run(RELEASE); } break; } parameter = strtok(NULL, " "); } for (int x=0; x < BUFFER_SIZE; x++) command[x] = '\0'; } void setup() { Serial.begin(9600); Serial.flush(); uint8_t base = 0x60; for (int i=0; i<n_shields; i++){ AFMS[i] = Adafruit_MotorShield(base+i); AFMS[i].begin(); } } void loop() { static char buffer[BUFFER_SIZE]; if (read_command(buffer) > 0) parse_command(buffer); }
[ "2109430n@student.gla.ac.uk" ]
2109430n@student.gla.ac.uk
e8ac6ef74bf405829f7f20d9438e1eccfeae0ae0
6f39b5a868371c53cc43f12f8769b7bcee863d31
/Lab4-2/Source.cpp
631405e6080435acc0f43e73c0e8d9242c730e86
[]
no_license
dknowuser/OSlab4-2
0eb606ee503cb591649af57d6a1094982469b051
ef838e00fc192a6b03b1d32e3f6c89e580461316
refs/heads/master
2022-11-20T04:18:00.504719
2020-07-26T13:03:08
2020-07-26T13:03:08
282,651,107
0
0
null
null
null
null
WINDOWS-1251
C++
false
false
24,728
cpp
#include <Windows.h> #include <iostream> void main(void) { setlocale(LC_ALL, "Russian"); char InputChar = '\0'; while (InputChar != '0') { std::cout << std::endl << "Меню:" << std::endl << std::endl; std::cout << "1 - получение информации о вычислительной системе;" << std::endl << std::endl; std::cout << "2 - определение статуса виртуальной памяти;" << std::endl << std::endl; std::cout << "3 - определение состояния конкретного участка памяти\nпо заданному с клавиатуры адресу;" << std::endl << std::endl; std::cout << "4 - резервирование региона в автоматическом режиме\nи в режиме ввода адреса начала региона;" << std::endl << std::endl; std::cout << "5 - резервирование региона и передача ему физической\nпамяти в автоматическом режиме и в режиме ввода адреса начала региона;" << std::endl << std::endl; std::cout << "6 - запись данных в ячейки памяти по заданным с клавиатуры адресам;" << std::endl << std::endl; std::cout << "7 - установка защиты доступа для заданного с клавиатуры\nрегиона памяти и её проверка;" << std::endl << std::endl; std::cout << "8 - возврат физической памяти и освобождение региона\nадресного пространства, заданного с клавиатуры;" << std::endl << std::endl; std::cout << "0 - выход;" << std::endl << std::endl; std::cout << ">> "; std::cin >> InputChar; unsigned int Temp = 0; unsigned int Counter = 0; unsigned short Cell = 0; DWORD ProtectSet = 0; DWORD ProtectGet = 0; LPVOID BaseAddress = 0; LPVOID lpTemp = 0; switch (InputChar) { case '1': SYSTEM_INFO info; GetSystemInfo(&info); //Выводим информацию о вычислительной системе std::cout << "Архитектура процессора: "; switch (info.wProcessorArchitecture) { case 0: std::cout << "x86." << std::endl; break; case 5: std::cout << "ARM." << std::endl; break; case 6: std::cout << "Intel Itanium-based." << std::endl; break; case 9: std::cout << "x64 (AMD or Intel)." << std::endl; break; case 65535: std::cout << "Неизвестная архитектура." << std::endl; break; default: std::cout << "Ошибка при получении информации об архитектуре процессора." << std::endl; break; }; std::cout << std::endl; std::cout << "Размер страницы: " << info.dwPageSize << std::endl << std::endl; std::cout << "Указатель на наименьший адрес памяти, доступный приложениям\nи библиотекам динамической компоновки (DLL): " << info.lpMinimumApplicationAddress << std::endl << std::endl; std::cout << "Указатель на наибольший адрес памяти, доступный приложениям\nи библиотекам динамической компоновки (DLL): " << info.lpMaximumApplicationAddress << std::endl << std::endl; std::cout << "Набор процессоров в вычислительной системе:" << std::endl; Temp = info.dwActiveProcessorMask; Counter = 0; while (Temp) { if (Temp & 1) std::cout << "Процессор " << Counter << std::endl; Counter++; Temp >>= 1; }; std::cout << std::endl; std::cout << "Число логических процессоров в текущей группе: " << info.dwNumberOfProcessors << std::endl << std::endl; std::cout << "Гранулярность начального адреса, по которому\nможно выделить виртуальную память: " << info.dwAllocationGranularity << std::endl << std::endl; std::cout << "Архитектурно-зависимый процессорный уровень: " << info.wProcessorLevel << std::endl << std::endl; std::cout << "Версия процессора, зависящая от архитектуры: " << info.wProcessorRevision << std::endl << std::endl; std::cout << std::endl; break; case '2': MEMORYSTATUS meminfo; GlobalMemoryStatus(&meminfo); //Определяем статус виртуальной памяти std::cout << "Размер структуры данных MEMORYSTATUS: " << meminfo.dwLength << std::endl << std::endl; std::cout << "Приблизительный процент используемой физической памяти: " << meminfo.dwMemoryLoad << std::endl << std::endl; std::cout << "Размер физической памяти в байтах: " << meminfo.dwTotalPhys << std::endl << std::endl; std::cout << "Размер доступной физической памяти в байтах: " << meminfo.dwAvailPhys << std::endl << std::endl; std::cout << "Текущее ограничение выделения памяти в байтах: " << meminfo.dwTotalPageFile << std::endl << std::endl; std::cout << "Максимальный размер памяти, который текущий процесс\nможет выделить, в байтах: " << meminfo.dwAvailPageFile << std::endl << std::endl; std::cout << "Размер пользовательской части виртуального адресного\nпространства вызывающего процесса в байтах: " << meminfo.dwTotalVirtual << std::endl << std::endl; std::cout << "Размер незарезервированной и невыделенной памяти\nпользовательской части виртуального адресного пространства\nвызывающего процесса в байтах: " << meminfo.dwAvailVirtual << std::endl << std::endl; std::cout << std::endl; break; case '3': MEMORY_BASIC_INFORMATION minfo; std::cout << "Введите адрес участка памяти, состояние которого нужно определить: " << std::endl; std::cin >> Temp; if (!VirtualQuery(&Temp, &minfo, sizeof(minfo))) { std::cout << "Ошибка при определении состояния конкретного\n участка памяти." << std::endl; std::cin.clear(); std::cin.sync(); break; }; //Выводим состояние указанного участка памяти std::cout << "Указатель на базовый адрес региона страниц: " << minfo.BaseAddress << std::endl << std::endl; std::cout << "Указатель на базовый адрес диапазона страниц,\nвыделенных функцией VirtualAlloc: " << minfo.AllocationBase << std::endl << std::endl; std::cout << "Параметр защиты памяти при первоначальном\nвыделении региона: " << std::endl; if(minfo.AllocationProtect & 0x10) std::cout << "Разрешение доступа выполнения к выделенной области\nстраниц. Попытка записи в выделенный регион приводит к\nнарушению доступа." << std::endl; if (minfo.AllocationProtect & 0x20) std::cout << "Разрешение доступа выполнения или чтения к выделенной области\nстраниц. Попытка записи в выделенный регион приводит к\nнарушению доступа." << std::endl; if (minfo.AllocationProtect & 0x40) std::cout << "Разрешение доступа выполнения, чтения или чтения и записи к выделенной области\nстраниц." << std::endl; if (minfo.AllocationProtect & 0x80) std::cout << "Разрешение доступа выполнения, чтения или копирования во время записи к сопоставленному\nпредставлению файлового объекта." << std::endl; if (minfo.AllocationProtect & 0x1) std::cout << "Запрет доступа к выделенной области страниц." << std::endl; if (minfo.AllocationProtect & 0x2) std::cout << "Разрешение доступа чтения к выделенной области страниц. Попытка записи в выделенный регион приводит к\nнарушению доступа." << std::endl; if (minfo.AllocationProtect & 0x4) std::cout << "Разрешение доступа чтения или чтения и записи к выделенной области страниц." << std::endl; if (minfo.AllocationProtect & 0x8) std::cout << "Разрешение доступа чтения или копирования при записи к\nсопоставленному представлению файлового объекта." << std::endl; if (minfo.AllocationProtect & 0x40000000) std::cout << "Все расположения на страницах установлены как недопустимые\nцелевые объекты для cfg." << std::endl; if (minfo.AllocationProtect & 0x100) std::cout << "Охраняемые страницы в регионе." << std::endl; if (minfo.AllocationProtect & 0x200) std::cout << "Наборы всех страниц некэшируемые." << std::endl; if (minfo.AllocationProtect & 0x400) std::cout << "Наборы всех страниц смешанно записываемые." << std::endl; std::cout << std::endl; std::cout << "Размер области, начинающейся с базового адреса, в которой\nвсе страницы имеют одинаковые атрибуты, в байтах: " << minfo.RegionSize << std::endl << std::endl; std::cout << "Состояние страниц региона: " << std::endl; if(minfo.State & 0x1000) std::cout << "Страницы, для которых выделено физическое хранилище\nлибо в памяти, либо в файле подкачки на диске." << std::endl; if (minfo.State & 0x10000) std::cout << "Свободные страницы, недоступные для процесса вызова\nи доступные для выделения." << std::endl; if (minfo.State & 0x2000) std::cout << "Зарезервированные страницы, где диапазон виртуального\nадресного пространства процесса резервируется без какого-либо физического выделения." << std::endl; std::cout << std::endl; std::cout << "Защита доступа к страницам региона: " << minfo.Protect << std::endl << std::endl; std::cout << "Тип страниц региона: " << std::endl; if(minfo.Type & 0x1000000) std::cout << "Страницы памяти в пределах области сопоставляются\nв представление раздела изображения." << std::endl; if (minfo.Type & 0x40000) std::cout << "Страницы памяти в области преобразуются в вид участка." << std::endl; if (minfo.Type & 0x20000) std::cout << "Страницы памяти в регионе являются закрытыми." << std::endl; std::cout << std::endl; break; case '4': InputChar = '\0'; Temp = 0; std::cout << "Введите размер региона в байтах: "; std::cin >> Temp; std::cout << "Введите a, чтобы зарезервировать регион в автоматическом режиме,\nили i, чтобы зарезервировать регион в режиме ввода адреса начала региона: "; std::cin >> InputChar; if ((InputChar == 'a') || (InputChar == 'A')) { if ((BaseAddress = VirtualAlloc(NULL, Temp, MEM_RESERVE, PAGE_READWRITE)) == NULL) { std::cout << "Ошибка при резервировании заданного региона." << std::endl; std::cin.clear(); std::cin.sync(); break; }; std::cout << "Регион с базовым адресом " << BaseAddress << " успешно зарезервирован." << std::endl << std::endl; } else { if ((InputChar == 'i') || (InputChar == 'I')) { BaseAddress = 0; std::cout << "Введите адрес начала региона: "; std::cin >> BaseAddress; if ((BaseAddress = VirtualAlloc(BaseAddress, Temp, MEM_RESERVE, PAGE_READWRITE)) == NULL) { std::cout << "Ошибка при резервировании заданного региона." << std::endl; std::cin.clear(); std::cin.sync(); break; }; std::cout << "Регион с базовым адресом " << BaseAddress << " успешно зарезервирован." << std::endl << std::endl; } else { std::cout << "Ошибка! Введён неверный параметр при выборе пункта меню." << std::endl; std::cin.clear(); std::cin.sync(); break; }; }; break; case '5': InputChar = '\0'; Temp = 0; std::cout << "Введите размер региона в байтах: "; std::cin >> Temp; std::cout << "Введите a, чтобы зарезервировать регион и передать ему физическую память\nв автоматическом режиме, или i, чтобы зарезервировать регион в режиме\nввода адреса начала региона: "; std::cin >> InputChar; if ((InputChar == 'a') || (InputChar == 'A')) { if ((BaseAddress = VirtualAlloc(NULL, Temp, MEM_RESERVE|MEM_COMMIT, PAGE_READWRITE)) == NULL) { std::cout << "Ошибка при резервировании заданного региона." << std::endl; std::cin.clear(); std::cin.sync(); break; }; //Заполняем регион нулями ZeroMemory(BaseAddress, Temp); if (!VirtualProtect(BaseAddress, Temp, PAGE_READONLY, &ProtectGet)) { std::cout << "Ошибка при установке параметров защиты заданного региона." << std::endl; std::cin.clear(); std::cin.sync(); break; }; std::cout << "Регион с базовым адресом " << BaseAddress << " успешно зарезервирован." << std::endl << std::endl; } else { if ((InputChar == 'i') || (InputChar == 'I')) { BaseAddress = 0; std::cout << "Введите адрес начала региона: "; std::cin >> BaseAddress; if ((BaseAddress = VirtualAlloc(BaseAddress, Temp, MEM_RESERVE|MEM_COMMIT, PAGE_READWRITE)) == NULL) { std::cout << "Ошибка при резервировании заданного региона." << std::endl; std::cin.clear(); std::cin.sync(); break; }; //Заполняем регион нулями ZeroMemory(BaseAddress, Temp); if (!VirtualProtect(BaseAddress, Temp, PAGE_READONLY, &ProtectGet)) { std::cout << "Ошибка при установке параметров защиты заданного региона." << std::endl; std::cin.clear(); std::cin.sync(); break; }; std::cout << "Регион с базовым адресом " << BaseAddress << " успешно зарезервирован." << std::endl << std::endl; } else { std::cout << "Ошибка! Введён неверный параметр при выборе пункта меню." << std::endl; std::cin.clear(); std::cin.sync(); break; }; }; break; case '6': lpTemp = 0; Cell = 0; std::cout << "Введите адрес ячейки памяти, куда будет производиться запись: "; std::cin >> lpTemp; std::cout << "Введите записываемое значение (от 0 до 65535): "; std::cin >> Cell; *(unsigned long long*)lpTemp = Cell; std::cout << "Заданное значение успешно записано." << std::endl; break; case '7': MEMORY_BASIC_INFORMATION minfo1; BaseAddress = 0; Counter = 0; ProtectSet = 0; ProtectGet = 0; std::cout << "Введите начальный адрес региона: "; std::cin >> BaseAddress; std::cout << "Введите размер региона в байтах: "; std::cin >> Counter; std::cout << "Введите устанавливаемые параметры защиты региона: "; std::cin >> ProtectSet; if (!VirtualProtect(BaseAddress, Counter, ProtectSet, &ProtectGet)) { std::cout << "Ошибка при установке параметров защиты заданного региона." << std::endl; std::cin.clear(); std::cin.sync(); break; }; std::cout << std::endl; std::cout << "Проверка состояния заданного участка памяти:" << std::endl; //Проверяем установленные параметры защиты региона if (!VirtualQuery(&BaseAddress, &minfo1, sizeof(minfo1))) { std::cout << "Ошибка при определении состояния конкретного\n участка памяти." << std::endl; std::cin.clear(); std::cin.sync(); break; }; //Выводим состояние указанного участка памяти std::cout << "Указатель на базовый адрес региона страниц: " << minfo1.BaseAddress << std::endl << std::endl; std::cout << "Указатель на базовый адрес диапазона страниц,\nвыделенных функцией VirtualAlloc: " << minfo1.AllocationBase << std::endl << std::endl; std::cout << "Параметр защиты памяти при первоначальном\nвыделении региона: " << std::endl; if (minfo1.AllocationProtect & 0x10) std::cout << "Разрешение доступа выполнения к выделенной области\nстраниц. Попытка записи в выделенный регион приводит к\nнарушению доступа." << std::endl; if (minfo1.AllocationProtect & 0x20) std::cout << "Разрешение доступа выполнения или чтения к выделенной области\nстраниц. Попытка записи в выделенный регион приводит к\nнарушению доступа." << std::endl; if (minfo1.AllocationProtect & 0x40) std::cout << "Разрешение доступа выполнения, чтения или чтения и записи к выделенной области\nстраниц." << std::endl; if (minfo1.AllocationProtect & 0x80) std::cout << "Разрешение доступа выполнения, чтения или копирования во время записи к сопоставленному\nпредставлению файлового объекта." << std::endl; if (minfo1.AllocationProtect & 0x1) std::cout << "Запрет доступа к выделенной области страниц." << std::endl; if (minfo1.AllocationProtect & 0x2) std::cout << "Разрешение доступа чтения к выделенной области страниц. Попытка записи в выделенный регион приводит к\nнарушению доступа." << std::endl; if (minfo1.AllocationProtect & 0x4) std::cout << "Разрешение доступа чтения или чтения и записи к выделенной области страниц." << std::endl; if (minfo1.AllocationProtect & 0x8) std::cout << "Разрешение доступа чтения или копирования при записи к\nсопоставленному представлению файлового объекта." << std::endl; if (minfo1.AllocationProtect & 0x40000000) std::cout << "Все расположения на страницах установлены как недопустимые\nцелевые объекты для cfg." << std::endl; if (minfo1.AllocationProtect & 0x100) std::cout << "Охраняемые страницы в регионе." << std::endl; if (minfo1.AllocationProtect & 0x200) std::cout << "Наборы всех страниц некэшируемые." << std::endl; if (minfo1.AllocationProtect & 0x400) std::cout << "Наборы всех страниц смешанно записываемые." << std::endl; std::cout << std::endl; std::cout << "Размер области, начинающейся с базового адреса, в которой\nвсе страницы имеют одинаковые атрибуты, в байтах: " << minfo1.RegionSize << std::endl << std::endl; std::cout << "Состояние страниц региона: " << std::endl; if (minfo1.State & 0x1000) std::cout << "Страницы, для которых выделено физическое хранилище\nлибо в памяти, либо в файле подкачки на диске." << std::endl; if (minfo1.State & 0x10000) std::cout << "Свободные страницы, недоступные для процесса вызова\nи доступные для выделения." << std::endl; if (minfo1.State & 0x2000) std::cout << "Зарезервированные страницы, где диапазон виртуального\nадресного пространства процесса резервируется без какого-либо физического выделения." << std::endl; std::cout << std::endl; std::cout << "Защита доступа к страницам региона: " << minfo1.Protect << std::endl << std::endl; std::cout << "Тип страниц региона: " << std::endl; if (minfo1.Type & 0x1000000) std::cout << "Страницы памяти в пределах области сопоставляются\nв представление раздела изображения." << std::endl; if (minfo1.Type & 0x40000) std::cout << "Страницы памяти в области преобразуются в вид участка." << std::endl; if (minfo1.Type & 0x20000) std::cout << "Страницы памяти в регионе являются закрытыми." << std::endl; std::cout << std::endl; break; case '8': BaseAddress = 0; Counter = 0; std::cout << "Введите начальный адрес региона: "; std::cin >> BaseAddress; std::cout << "Введите размер региона в байтах: "; std::cin >> Counter; if (!VirtualFree(BaseAddress, Counter, MEM_DECOMMIT)) { std::cout << "Ошибка при возврате физической памяти заданного региона." << std::endl; std::cin.clear(); std::cin.sync(); //break; }; if (!VirtualFree(BaseAddress, NULL, MEM_RELEASE)) { std::cout << "Ошибка при освобождении заданного региона." << std::endl; std::cin.clear(); std::cin.sync(); break; }; break; case '0': break; default: std::cout << "Ошибка! Введён неверный параметр при выборе пункта меню." << std::endl; std::cin.clear(); std::cin.sync(); break; }; }; };
[ "maro4uk@yandex.ru" ]
maro4uk@yandex.ru
f03ed0455636cf102f92db9fa6c4797ed55b9b85
a4fa50c7af93f09b2ddf463ddacd82ed404615f9
/include/ast/types/UInt32Type.h
22486b0d6ac1f4311b57ee3c63dd5940598352b8
[]
no_license
hadley-siqueira/hdc
4cd0ab8b98afbc6ee207fc963443e5b89aa0a458
4df9e3f8d4070139de292fd98de93d8afbd659b2
refs/heads/master
2021-07-08T12:04:59.211561
2020-12-28T02:20:46
2020-12-28T02:20:46
136,125,618
3
0
null
null
null
null
UTF-8
C++
false
false
457
h
#ifndef HDC_UINT32_TYPE_H #define HDC_UINT32_TYPE_H #include "token/Token.h" #include "ast/types/PrimitiveType.h" namespace hdc { class UInt32Type : public PrimitiveType { private: Token token; public: UInt32Type(); UInt32Type(Token& token); public: Type* clone(); int getRank(); public: virtual void accept(Visitor* visitor); }; } #endif
[ "hadley.siqueira@gmail.com" ]
hadley.siqueira@gmail.com
f9faabe88942ec0d1b8f7b807a9c9ad8ffb7a7b0
f252f75a66ff3ff35b6eaa5a4a28248eb54840ee
/external/opencore/engines/2way/src/pv_2way_proxy_factory.cpp
a8ed112634cf7d42e5d126cb1ed44d5bf7891a57
[ "MIT", "LicenseRef-scancode-other-permissive", "Artistic-2.0", "LicenseRef-scancode-philippe-de-muyter", "Apache-2.0", "LicenseRef-scancode-mpeg-iso", "LicenseRef-scancode-unknown-license-reference" ]
permissive
abgoyal-archive/OT_4010A
201b246c6f685cf35632c9a1e1bf2b38011ff196
300ee9f800824658acfeb9447f46419b8c6e0d1c
refs/heads/master
2022-04-12T23:17:32.814816
2015-02-06T12:15:20
2015-02-06T12:15:20
30,410,715
0
1
null
2020-03-07T00:35:22
2015-02-06T12:14:16
C
UTF-8
C++
false
false
1,049
cpp
#include "pv_2way_proxy_factory.h" #include "pv_2way_engine_factory.h" #include "pv_2way_proxy_adapter.h" #include "pv_2way_engine.h" OSCL_EXPORT_REF void CPV2WayProxyFactory::Init() { CPV2WayEngineFactory::Init(); } OSCL_EXPORT_REF void CPV2WayProxyFactory::Cleanup() { CPV2WayEngineFactory::Cleanup(); } OSCL_EXPORT_REF CPV2WayInterface *CPV2WayProxyFactory::CreateTerminal(TPVTerminalType aTerminalType, PVCommandStatusObserver* aCmdStatusObserver, PVInformationalEventObserver *aInfoEventObserver, PVErrorEventObserver *aErrorEventObserver) { if (aTerminalType == PV_324M) { return CPV2WayProxyAdapter::New(aTerminalType, aCmdStatusObserver, aInfoEventObserver, aErrorEventObserver); } else { return NULL; } } OSCL_EXPORT_REF void CPV2WayProxyFactory::DeleteTerminal(CPV2WayInterface* terminal) { OSCL_DELETE((CPV2WayProxyAdapter*)terminal); }
[ "abgoyal@gmail.com" ]
abgoyal@gmail.com
040d45584e05e1479bf28ac80d6a1ad3e98eda63
ba1e90ae6ea9f8f74d9b542e159825341c717712
/2020/cf619B.cpp
7e7f48a44d16cdb3a4b4fda4a644019257d43470
[]
no_license
sailesh2/CompetitiveCode
b384687a7caa8980ab9b9c9deef2488b0bfe9cd9
5671dac08216f4ce75d5992e6af8208fa2324d12
refs/heads/master
2021-06-24T22:39:11.396049
2020-11-27T05:22:17
2020-11-27T05:22:17
161,877,355
0
0
null
null
null
null
UTF-8
C++
false
false
1,971
cpp
#include<bits/stdc++.h> using namespace std; long long int getDiff(long long int* arr, long long int n){ long long int maxi=0; for(long long int i=0;i<n;i++){ if(i>0 && arr[i]!=-1 && arr[i-1]!=-1){ maxi=max(maxi,abs(arr[i]-arr[i-1])); } } return maxi; } long long int getDiff(long long int* arr, long long int n, long long int e){ long long int brr[n]; for(long long int i=0;i<n;i++){ if(arr[i]==-1){ brr[i]=e; }else{ brr[i]=arr[i]; } } long long int maxi=0; for(long long int i=0;i<n;i++){ if(i>0) maxi=max(maxi,abs(brr[i]-brr[i-1])); } return maxi; } int main(){ long long int t; cin>>t; long long int n; for(long long int i=0;i<t;i++){ cin>>n; long long int arr[n]; for(long long int j=0;j<n;j++){ cin>>arr[j]; } long long int diff=getDiff(arr,n); long long int s=0,ctr=0; long long int maxi=0,mini=1000000009; set<long long int> st; for(long long int j=0;j<n;j++){ if(arr[j]>=0){ if((j-1>=0 && arr[j-1]==-1) || (j+1<n && arr[j+1]==-1)){ if(st.count(arr[j])==0){ st.insert(arr[j]); s=s+arr[j]; ctr++; maxi=max(maxi,arr[j]); mini=min(mini,arr[j]); } } } } if(ctr==0){ cout<<diff<<" 1\n"; }else{ long long int diff1=getDiff(arr,n,(maxi+mini)/2); long long int diff2=getDiff(arr,n,(maxi+mini)/2+1); if(diff1<diff2) cout<<max(diff,diff1)<<" "<<(maxi+mini)/2<<"\n"; else cout<<max(diff,diff2)<<" "<<1+(maxi+mini)/2<<"\n"; } } return 0; }
[ "sailesh.ku.upadhyaya@gmail.com" ]
sailesh.ku.upadhyaya@gmail.com
246513fa02987f827f384668f39f4baee8fc3d80
99b25caa1cfda5625ae3f8d468f08f8918b4a173
/2term/Programming/2.1/21.cpp
ead008446f2369858b7f66591c4aa2059ae5a505
[ "Apache-2.0" ]
permissive
nik-sergeson/bsuir-informatics-labs
c00b0a11b1135715a56ea27157edd16722279680
14805fb83b8e2324580b6253158565068595e804
refs/heads/main
2023-04-22T07:13:50.497231
2021-02-08T09:35:37
2021-04-29T12:59:22
321,606,512
0
0
null
null
null
null
UTF-8
C++
false
false
2,550
cpp
#include <stdio.h> #include <conio.h> #include <windows.h> #include <math.h> const int NCAR=15,VES1CAR=20,MAXLENGTH=4000,MINVES=50,TARIF=2;double INSUR=0.05; double EVes(void); double ELength(void); void Count(double Ves, double Length,bool Adopt); bool Analize(double Ves, double Length); void Author(void); void OrderDecision(bool Adopt); void SysDialog(void); void CountOutput(int Cars,double SInsur,double Summ); int main() { int choice=0; double Ves=0,Length=0; bool Adopt=false; while (choice!=6) { printf("Menu:\n 1)Enter ves\n 2)Enter length\n 3)Analize\n 4)Count\n 5)Author\n 6)Quit\n"); choice=getch(); switch (choice) { case '1': Ves=EVes(); break; case '2': Length=ELength(); break; case '3': Adopt=Analize(Ves,Length); break; case '4': Count(Ves,Length,Adopt); break; case '5': Author(); break; case '6': choice=6; break; default: printf("Illegal"); } } return 0; } double EVes(void) { double Mass; system("cls"); printf("Enter ves\n"); scanf("%lf",&Mass); printf("Ves entered,press any button to continue\n"); getch(); system("cls"); return Mass; } double ELength(void) { double Length; system("cls"); printf("Enter length\n"); scanf("%lf",&Length); printf("Length entered,press any button to continue\n"); getch(); system("cls"); return Length; } bool Analize(double Ves,double Length) { bool bl; system("cls"); if ((Ves<=MINVES) || (Ves>NCAR*VES1CAR) ||(Length>MAXLENGTH)){ bl=false; OrderDecision(bl); } else{ bl=true; OrderDecision(bl); } SysDialog(); return bl; } void Count(double Ves,double Length,bool Adopt) { double Summ,SInsur; int Cars; system("cls"); if (Adopt){ Cars=((int)Ves+1)/VES1CAR; if (Cars*VES1CAR-Ves<0) Cars++; SInsur=Length*TARIF*Cars*INSUR; Summ=Length*TARIF*Cars+SInsur; CountOutput(Cars,SInsur,Summ); } else OrderDecision(Adopt); SysDialog(); } void Author(void) { system("cls"); printf("Student, BSUIR\n"); SysDialog(); } void OrderDecision(bool Adopt) { if (Adopt) printf("Order adopted\n"); else printf("Order wasn't adopted\n"); } void SysDialog(void) { printf("Press any button to continue\n"); getch(); system("cls"); } void CountOutput(int Cars,double SInsur,double Summ) { printf("We need %d cars, insurance will cost %.2lf$, summ, you need to pay is %.2lf$\n",Cars,SInsur,Summ); }
[ "13019846+nik-sergeson@users.noreply.github.com" ]
13019846+nik-sergeson@users.noreply.github.com
6072198757d9074c2df3c5685632cf6c45ea594e
e782c47af0b5d5759de534e532cbe10f13da2515
/New/Classes/Model/Brick/AccelerateBrick.h
ad91147b2f5ad80dc3d6ea1a4f3fc34d4f4b5dc0
[]
no_license
ambroseL/Architecture_Pattern
44ef9b39ca83a46e6a93958b11fa4f1ebdec8dd7
8d30fa2ef0ac0517b10ba2247a4410c42de03d3d
refs/heads/master
2021-01-18T22:23:13.719029
2016-12-07T03:19:48
2016-12-07T03:19:48
72,494,363
1
1
null
2016-12-06T14:20:41
2016-11-01T01:55:15
C++
GB18030
C++
false
false
852
h
#ifndef _AccelerateBrick_H_ #define _AccelerateBrick_H_ #include "BrickObj.h" /** *加速砖块类 * *#include "BrickObj.h" <BR> *-llib * * 砖块实体类的子类,被击碎后产生速度包裹 * * @seesomething */ class AccelerateBrick :public BrickObj { public: // 类的生命周期控制函数,包括构造和析构 /** *默认构造函数 */ AccelerateBrick(); /** *含参构造函数 * *@param physicsComponent 物理部件 *@param graphicsComponent 图像部件 *@param id 物体ID *@param iHP 砖块生命值,默认为1 */ AccelerateBrick(PhysicsComponent* physicsComponent, GraphicsComponent* graphicsComponent, std::string* id, int iHP = 1); /** *析构函数 */ ~AccelerateBrick(); /** *克隆函数,深拷贝 */ EntityObj* Clone() override; }; #endif
[ "ambrose2015@icloud.com" ]
ambrose2015@icloud.com
60dda1fb698d5d22fc58828580fa8ba58dafc15c
6c5072187b2bed9bc4d970e541972383c4db0db4
/src/game/Guild.h
31a1a596f79767c339fb8f4ed49cabd435426473
[]
no_license
ErYayo/StrawberryCore
957bd096741c46d7506aedea237237d914b9b4a9
5f01ac82ae66dd953c725995012727e27ac62a77
refs/heads/master
2021-01-18T07:46:24.615180
2012-10-09T17:38:13
2012-10-09T17:38:13
null
0
0
null
null
null
null
UTF-8
C++
false
false
19,193
h
/* * Copyright (C) 2010-2012 Strawberry-Pr0jcts <http://strawberry-pr0jcts.com/> * Copyright (C) 2005-2011 MaNGOS <http://getmangos.com/> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef STRAWBERRYSERVER_GUILD_H #define STRAWBERRYSERVER_GUILD_H #define WITHDRAW_MONEY_UNLIMITED 0xFFFFFFFF #define WITHDRAW_SLOT_UNLIMITED 0xFFFFFFFF #include "Common.h" #include "Item.h" #include "ObjectAccessor.h" #include "SharedDefines.h" class Item; #define GUILD_RANKS_MIN_COUNT 3 #define GUILD_RANKS_MAX_COUNT 10 enum GuildDefaultRanks { //these ranks can be modified, but they cannot be deleted GR_GUILDMASTER = 0, GR_OFFICER = 1, GR_VETERAN = 2, GR_MEMBER = 3, GR_INITIATE = 4, //When promoting member server does: rank--;! //When demoting member server does: rank++;! }; enum GuildRankRights { GR_RIGHT_EMPTY = 0x00000040, GR_RIGHT_GCHATLISTEN = 0x00000041, GR_RIGHT_GCHATSPEAK = 0x00000042, GR_RIGHT_OFFCHATLISTEN = 0x00000044, GR_RIGHT_OFFCHATSPEAK = 0x00000048, GR_RIGHT_PROMOTE = 0x000000C0, GR_RIGHT_DEMOTE = 0x00000140, GR_RIGHT_INVITE = 0x00000050, GR_RIGHT_REMOVE = 0x00000060, GR_RIGHT_SETMOTD = 0x00001040, GR_RIGHT_EPNOTE = 0x00002040, GR_RIGHT_VIEWOFFNOTE = 0x00004040, GR_RIGHT_EOFFNOTE = 0x00008040, GR_RIGHT_MODIFY_GUILD_INFO = 0x00010040, GR_RIGHT_WITHDRAW_GOLD_LOCK = 0x00020000, // remove money withdraw capacity GR_RIGHT_WITHDRAW_REPAIR = 0x00040040, // withdraw for repair GR_RIGHT_WITHDRAW_GOLD = 0x00080000, // withdraw gold GR_RIGHT_CREATE_GUILD_EVENT = 0x00100040, // wotlk GR_RIGHT_REQUIRE_AUTHENTICATOR = 0x00200040, GR_RIGHT_REMOVE_GUILD_EVENT = 0x00800040, GR_RIGHT_ALL = 0x00DDFFBF }; enum Typecommand { GUILD_CREATE_S = 0x00, GUILD_INVITE_S = 0x01, GUILD_QUIT_S = 0x03, // 0x05? GUILD_FOUNDER_S = 0x0E, GUILD_UNK1 = 0x13, GUILD_UNK2 = 0x14 }; enum CommandErrors { ERR_PLAYER_NO_MORE_IN_GUILD = 0x00, ERR_GUILD_INTERNAL = 0x01, ERR_ALREADY_IN_GUILD = 0x02, ERR_ALREADY_IN_GUILD_S = 0x03, ERR_INVITED_TO_GUILD = 0x04, ERR_ALREADY_INVITED_TO_GUILD_S = 0x05, ERR_GUILD_NAME_INVALID = 0x06, ERR_GUILD_NAME_EXISTS_S = 0x07, ERR_GUILD_LEADER_LEAVE = 0x08, ERR_GUILD_PERMISSIONS = 0x08, ERR_GUILD_PLAYER_NOT_IN_GUILD = 0x09, ERR_GUILD_PLAYER_NOT_IN_GUILD_S = 0x0A, ERR_GUILD_PLAYER_NOT_FOUND_S = 0x0B, ERR_GUILD_NOT_ALLIED = 0x0C, ERR_GUILD_RANK_TOO_HIGH_S = 0x0D, ERR_GUILD_RANK_TOO_LOW_S = 0x0E, ERR_GUILD_RANKS_LOCKED = 0x11, ERR_GUILD_RANK_IN_USE = 0x12, ERR_GUILD_IGNORING_YOU_S = 0x13, ERR_GUILD_UNK1 = 0x14, ERR_GUILD_WITHDRAW_LIMIT = 0x19, ERR_GUILD_NOT_ENOUGH_MONEY = 0x1A, ERR_GUILD_BANK_FULL = 0x1C, ERR_GUILD_ITEM_NOT_FOUND = 0x1D }; enum GuildEvents { GE_PROMOTION = 0x01, GE_DEMOTION = 0x02, GE_MOTD = 0x03, GE_JOINED = 0x04, GE_LEFT = 0x05, GE_REMOVED = 0x06, GE_LEADER_IS = 0x07, GE_LEADER_CHANGED = 0x08, GE_DISBANDED = 0x09, GE_TABARDCHANGE = 0x0A, GE_UNK1 = 0x0B, // string, string EVENT_GUILD_ROSTER_UPDATE tab content change? GE_UPDATE_ROSTER = 0x0C, // EVENT_GUILD_ROSTER_UPDATE GE_SIGNED_ON = 0x10, // ERR_FRIEND_ONLINE_SS GE_SIGNED_OFF = 0x11, // ERR_FRIEND_OFFLINE_S GE_GUILDBANKBAGSLOTS_CHANGED = 0x12, // EVENT_GUILDBANKBAGSLOTS_CHANGED GE_BANKTAB_PURCHASED = 0x13, // EVENT_GUILDBANK_UPDATE_TABS GE_UNK5 = 0x14, // EVENT_GUILDBANK_UPDATE_TABS GE_GUILDBANK_UPDATE_MONEY = 0x15, // EVENT_GUILDBANK_UPDATE_MONEY, string 0000000000002710 is 1 gold GE_GUILD_BANK_MONEY_WITHDRAWN = 0x16, // MSG_GUILD_BANK_MONEY_WITHDRAWN GE_GUILDBANK_TEXT_CHANGED = 0x17 // EVENT_GUILDBANK_TEXT_CHANGED }; enum PetitionTurns { PETITION_TURN_OK = 0, PETITION_TURN_ALREADY_IN_GUILD = 2, PETITION_TURN_NEED_MORE_SIGNATURES = 4, }; enum PetitionSigns { PETITION_SIGN_OK = 0, PETITION_SIGN_ALREADY_SIGNED = 1, PETITION_SIGN_ALREADY_IN_GUILD = 2, PETITION_SIGN_CANT_SIGN_OWN = 3, PETITION_SIGN_NOT_SERVER = 4, }; enum GuildBankRights { GUILD_BANK_RIGHT_VIEW_TAB = 0x01, GUILD_BANK_RIGHT_PUT_ITEM = 0x02, GUILD_BANK_RIGHT_UPDATE_TEXT = 0x04, GUILD_BANK_RIGHT_DEPOSIT_ITEM = GUILD_BANK_RIGHT_VIEW_TAB | GUILD_BANK_RIGHT_PUT_ITEM, GUILD_BANK_RIGHT_FULL = 0xFF, }; enum GuildBankEventLogTypes { GUILD_BANK_LOG_DEPOSIT_ITEM = 1, GUILD_BANK_LOG_WITHDRAW_ITEM = 2, GUILD_BANK_LOG_MOVE_ITEM = 3, GUILD_BANK_LOG_DEPOSIT_MONEY = 4, GUILD_BANK_LOG_WITHDRAW_MONEY = 5, GUILD_BANK_LOG_REPAIR_MONEY = 6, GUILD_BANK_LOG_MOVE_ITEM2 = 7, GUILD_BANK_LOG_UNK1 = 8, GUILD_BANK_LOG_UNK2 = 9, }; enum GuildEventLogTypes { GUILD_EVENT_LOG_INVITE_PLAYER = 1, GUILD_EVENT_LOG_JOIN_GUILD = 2, GUILD_EVENT_LOG_PROMOTE_PLAYER = 3, GUILD_EVENT_LOG_DEMOTE_PLAYER = 4, GUILD_EVENT_LOG_UNINVITE_PLAYER = 5, GUILD_EVENT_LOG_LEAVE_GUILD = 6, }; enum GuildEmblem { ERR_GUILDEMBLEM_SUCCESS = 0, ERR_GUILDEMBLEM_INVALID_TABARD_COLORS = 1, ERR_GUILDEMBLEM_NOGUILD = 2, ERR_GUILDEMBLEM_NOTGUILDMASTER = 3, ERR_GUILDEMBLEM_NOTENOUGHMONEY = 4, ERR_GUILDEMBLEM_INVALIDVENDOR = 5 }; inline uint32 GetGuildBankTabPrice(uint8 Index) { switch(Index) { case 0: return 100; case 1: return 250; case 2: return 500; case 3: return 1000; case 4: return 2500; case 5: return 5000; default: return 0; } } struct GuildEventLogEntry { uint8 EventType; uint32 PlayerGuid1; uint32 PlayerGuid2; uint8 NewRank; uint64 TimeStamp; }; struct GuildBankEventLogEntry { uint8 EventType; uint32 PlayerGuid; uint32 ItemOrMoney; uint8 ItemStackCount; uint8 DestTabId; uint64 TimeStamp; bool isMoneyEvent() const { return EventType == GUILD_BANK_LOG_DEPOSIT_MONEY || EventType == GUILD_BANK_LOG_WITHDRAW_MONEY || EventType == GUILD_BANK_LOG_REPAIR_MONEY; } }; struct GuildBankTab { GuildBankTab() { memset(Slots, 0, GUILD_BANK_MAX_SLOTS * sizeof(Item*)); } Item* Slots[GUILD_BANK_MAX_SLOTS]; std::string Name; std::string Icon; std::string Text; }; struct GuildItemPosCount { GuildItemPosCount(uint8 _slot, uint32 _count) : Slot(_slot), Count(_count) {} bool isContainedIn(std::vector<GuildItemPosCount> const& vec) const; uint8 Slot; uint32 Count; }; typedef std::vector<GuildItemPosCount> GuildItemPosCountVec; struct MemberSlot { void SetMemberStats(Player* player); void UpdateLogoutTime(); void SetPNOTE(std::string pnote); void SetOFFNOTE(std::string offnote); void ChangeRank(uint32 newRank); ObjectGuid guid; uint32 accountId; std::string Name; uint32 RankId; uint8 Level; uint8 Class; uint32 ZoneId; uint64 LogoutTime; std::string Pnote; std::string OFFnote; uint32 BankResetTimeMoney; uint32 BankRemMoney; uint32 BankResetTimeTab[GUILD_BANK_MAX_TABS]; uint32 BankRemSlotsTab[GUILD_BANK_MAX_TABS]; }; struct RankInfo { RankInfo(const std::string& _name, uint32 _rights, uint32 _money) : Name(_name), Rights(_rights), BankMoneyPerDay(_money) { for(uint8 i = 0; i < GUILD_BANK_MAX_TABS; ++i) { TabRight[i] = 0; TabSlotPerDay[i] = 0; } } std::string Name; uint32 Rights; uint32 BankMoneyPerDay; uint32 TabRight[GUILD_BANK_MAX_TABS]; uint32 TabSlotPerDay[GUILD_BANK_MAX_TABS]; }; class Guild { public: Guild(); ~Guild(); bool Create(Player* leader, std::string gname); void CreateDefaultGuildRanks(int locale_idx); void Disband(); void DeleteGuildBankItems(bool alsoInDB = false); typedef UNORDERED_MAP<uint32, MemberSlot> MemberList; typedef std::vector<RankInfo> RankList; uint32 GetId(){ return m_Id; } ObjectGuid GetLeaderGuid() const { return m_LeaderGuid; } std::string const& GetName() const { return m_Name; } std::string const& GetMOTD() const { return MOTD; } std::string const& GetGINFO() const { return GINFO; } time_t GetCreatedDate() const { return m_CreatedDate; } uint32 GetEmblemStyle() const { return m_EmblemStyle; } uint32 GetEmblemColor() const { return m_EmblemColor; } uint32 GetBorderStyle() const { return m_BorderStyle; } uint32 GetBorderColor() const { return m_BorderColor; } uint32 GetBackgroundColor() const { return m_BackgroundColor; } void SetLeader(ObjectGuid guid); bool AddMember(ObjectGuid plGuid, uint32 plRank); bool DelMember(ObjectGuid guid, bool isDisbanding = false); //lowest rank is the count of ranks - 1 (the highest rank_id in table) uint32 GetLowestRank() const { return m_Ranks.size() - 1; } void SetMOTD(std::string motd); void SetGINFO(std::string ginfo); void SetEmblem(uint32 emblemStyle, uint32 emblemColor, uint32 borderStyle, uint32 borderColor, uint32 backgroundColor); uint32 GetMemberSize() const { return members.size(); } uint32 GetAccountsNumber(); bool LoadGuildFromDB(QueryResult *guildDataResult); bool CheckGuildStructure(); bool LoadRanksFromDB(QueryResult *guildRanksResult); bool LoadMembersFromDB(QueryResult *guildMembersResult); void BroadcastToGuild(WorldSession *session, const std::string& msg, uint32 language = LANG_UNIVERSAL); void BroadcastToOfficers(WorldSession *session, const std::string& msg, uint32 language = LANG_UNIVERSAL); void BroadcastPacketToRank(WorldPacket *packet, uint32 rankId); void BroadcastPacket(WorldPacket *packet); void BroadcastEvent(GuildEvents event, ObjectGuid guid, char const* str1 = NULL, char const* str2 = NULL, char const* str3 = NULL); void BroadcastEvent(GuildEvents event, char const* str1 = NULL, char const* str2 = NULL, char const* str3 = NULL) { BroadcastEvent(event, ObjectGuid(), str1, str2, str3); } template<class Do> void BroadcastWorker(Do& _do, Player* except = NULL) { for(MemberList::iterator itr = members.begin(); itr != members.end(); ++itr) if(Player *player = ObjectAccessor::FindPlayer(ObjectGuid(HIGHGUID_PLAYER, itr->first))) if(player != except) _do(player); } void CreateRank(std::string name,uint32 rights); void DelRank(); std::string GetRankName(uint32 rankId); uint32 GetRankRights(uint32 rankId); uint32 GetRanksSize() const { return m_Ranks.size(); } void SendGuildRankInfo(WorldSession* session); void SetRankName(uint32 rankId, std::string name); void SetRankRights(uint32 rankId, uint32 rights); bool HasRankRight(uint32 rankId, uint32 right) { return ((GetRankRights(rankId) & right) != GR_RIGHT_EMPTY) ? true : false; } int32 GetRank(ObjectGuid guid) { MemberSlot* slot = GetMemberSlot(guid); return slot ? slot->RankId : -1; } MemberSlot* GetMemberSlot(ObjectGuid guid) { MemberList::iterator itr = members.find(guid.GetCounter()); return itr != members.end() ? &itr->second : NULL; } MemberSlot* GetMemberSlot(const std::string& name) { for(MemberList::iterator itr = members.begin(); itr != members.end(); ++itr) if(itr->second.Name == name) return &itr->second; return NULL; } void Roster(WorldSession *session = NULL); // NULL = broadcast void Query(WorldSession *session); // Guild EventLog void LoadGuildEventLogFromDB(); void DisplayGuildEventLog(WorldSession *session); void LogGuildEvent(uint8 EventType, ObjectGuid playerGuid1, ObjectGuid playerGuid2 = ObjectGuid(), uint8 newRank = 0); // ** Guild bank ** // Content & item deposit/withdraw void DisplayGuildBankContent(WorldSession *session, uint8 TabId); void DisplayGuildBankMoneyUpdate(WorldSession *session); void SwapItems( Player * pl, uint8 BankTab, uint8 BankTabSlot, uint8 BankTabDst, uint8 BankTabSlotDst, uint32 SplitedAmount); void MoveFromBankToChar( Player * pl, uint8 BankTab, uint8 BankTabSlot, uint8 PlayerBag, uint8 PlayerSlot, uint32 SplitedAmount); void MoveFromCharToBank( Player * pl, uint8 PlayerBag, uint8 PlayerSlot, uint8 BankTab, uint8 BankTabSlot, uint32 SplitedAmount); // Tabs void DisplayGuildBankTabsInfo(WorldSession *session); void CreateNewBankTab(); void SetGuildBankTabText(uint8 TabId, std::string text); void SendGuildBankTabText(WorldSession *session, uint8 TabId); void SetGuildBankTabInfo(uint8 TabId, std::string name, std::string icon); uint8 GetPurchasedTabs() const { return m_TabListMap.size(); } uint32 GetBankRights(uint32 rankId, uint8 TabId) const; bool IsMemberHaveRights(uint32 LowGuid, uint8 TabId,uint32 rights) const; bool CanMemberViewTab(uint32 LowGuid, uint8 TabId) const; // Load void LoadGuildBankFromDB(); // Money deposit/withdraw void SendMoneyInfo(WorldSession *session, uint32 LowGuid); bool MemberMoneyWithdraw(uint32 amount, uint32 LowGuid); uint64 GetGuildBankMoney() { return m_GuildBankMoney; } void SetBankMoney(int64 money); // per days bool MemberItemWithdraw(uint8 TabId, uint32 LowGuid); uint32 GetMemberSlotWithdrawRem(uint32 LowGuid, uint8 TabId); uint32 GetMemberMoneyWithdrawRem(uint32 LowGuid); void SetBankMoneyPerDay(uint32 rankId, uint32 money); void SetBankRightsAndSlots(uint32 rankId, uint8 TabId, uint32 right, uint32 SlotPerDay, bool db); uint32 GetBankMoneyPerDay(uint32 rankId); uint32 GetBankSlotPerDay(uint32 rankId, uint8 TabId); // rights per day bool LoadBankRightsFromDB(QueryResult *guildBankTabRightsResult); // Guild Bank Event Logs void LoadGuildBankEventLogFromDB(); void DisplayGuildBankLogs(WorldSession *session, uint8 TabId); void LogBankEvent(uint8 EventType, uint8 TabId, uint32 PlayerGuidLow, uint32 ItemOrMoney, uint8 ItemStackCount=0, uint8 DestTabId=0); bool AddGBankItemToDB(uint32 GuildId, uint32 BankTab , uint32 BankTabSlot , uint32 GUIDLow, uint32 Entry ); protected: void AddRank(const std::string& name,uint32 rights,uint32 money); uint32 m_Id; std::string m_Name; ObjectGuid m_LeaderGuid; std::string MOTD; std::string GINFO; time_t m_CreatedDate; uint32 m_EmblemStyle; uint32 m_EmblemColor; uint32 m_BorderStyle; uint32 m_BorderColor; uint32 m_BackgroundColor; uint32 m_accountsNumber; // 0 used as marker for need lazy calculation at request RankList m_Ranks; MemberList members; typedef std::vector<GuildBankTab*> TabListMap; TabListMap m_TabListMap; /** These are actually ordered lists. The first element is the oldest entry.*/ typedef std::list<GuildEventLogEntry> GuildEventLog; typedef std::list<GuildBankEventLogEntry> GuildBankEventLog; GuildEventLog m_GuildEventLog; GuildBankEventLog m_GuildBankEventLog_Money; GuildBankEventLog m_GuildBankEventLog_Item[GUILD_BANK_MAX_TABS]; uint32 m_GuildEventLogNextGuid; uint32 m_GuildBankEventLogNextGuid_Money; uint32 m_GuildBankEventLogNextGuid_Item[GUILD_BANK_MAX_TABS]; uint64 m_GuildBankMoney; private: void UpdateAccountsNumber() { m_accountsNumber = 0;}// mark for lazy calculation at request in GetAccountsNumber void _ChangeRank(ObjectGuid guid, MemberSlot* slot, uint32 newRank); // used only from high level Swap/Move functions Item* GetItem(uint8 TabId, uint8 SlotId); InventoryResult CanStoreItem( uint8 tab, uint8 slot, GuildItemPosCountVec& dest, uint32 count, Item *pItem, bool swap = false) const; Item* StoreItem( uint8 tab, GuildItemPosCountVec const& pos, Item *pItem ); void RemoveItem(uint8 tab, uint8 slot ); void DisplayGuildBankContentUpdate(uint8 TabId, int32 slot1, int32 slot2 = -1); void DisplayGuildBankContentUpdate(uint8 TabId, GuildItemPosCountVec const& slots); // internal common parts for CanStore/StoreItem functions void AppendDisplayGuildBankSlot( WorldPacket& data, GuildBankTab const *tab, int32 slot ); InventoryResult _CanStoreItem_InSpecificSlot( uint8 tab, uint8 slot, GuildItemPosCountVec& dest, uint32& count, bool swap, Item *pSrcItem ) const; InventoryResult _CanStoreItem_InTab( uint8 tab, GuildItemPosCountVec& dest, uint32& count, bool merge, Item *pSrcItem, uint8 skip_slot ) const; Item* _StoreItem( uint8 tab, uint8 slot, Item *pItem, uint32 count, bool clone ); }; #endif
[ "fabian@arctium.org" ]
fabian@arctium.org
e0855494c28197296c9e08935073570d60336ee1
24df49d2d2c6afe3196d4f2f24736794c67443e6
/412_fizz_buzz.cpp
bc01c081a63efca8ef9b0c4bfe041b91037430d4
[]
no_license
manishkhilnani2911/leetcode
87ba15aeac250a25dd256a36663271a30a2c9229
1d8e91af0ddf114aa72da38f933928c9b800a467
refs/heads/master
2021-01-20T15:49:26.187533
2019-03-25T19:09:58
2019-03-25T19:09:58
64,050,280
0
0
null
null
null
null
UTF-8
C++
false
false
1,117
cpp
/*Write a program that outputs the string representation of numbers from 1 to n. But for multiples of three it should output “Fizz” instead of the number and for the multiples of five output “Buzz”. For numbers which are multiples of both three and five output “FizzBuzz”. Example: n = 15, Return: [ "1", "2", "Fizz", "4", "Buzz", "Fizz", "7", "8", "Fizz", "Buzz", "11", "Fizz", "13", "14", "FizzBuzz" ]*/ class Solution { //Ap_Go_Mi_Bl_Fa_Qu_Li_IBM_Ad_Am_vm_Ya_Or_Pa_Eb_SA public: vector<string> fizzBuzz(int n) { int i=1; vector<string> res; if (n==0) { return res; } int x = 3, y = 5; while(i<=n) { x--; y--; if (x==0 && y==0) { res.push_back("FizzBuzz"); x=3; y=5; } else if (x == 0) { res.push_back("Fizz"); x=3; } else if (y == 0) { res.push_back("Buzz"); y=5; } else { res.push_back(to_string(i)); } i++; } return res; } };
[ "manishkhilnani2911@gmail.com" ]
manishkhilnani2911@gmail.com
32306221eff7b8ae40898afe07ea6749f5a022f5
240ddcd33387d42ee4cdd138ba31f3583d3ca543
/byond-extools/src/monstermos/monstermos_exports.cpp
6603d17694415b2cf9e77cf2014c8f3953310ef6
[ "MIT" ]
permissive
yogstation13/extools
166d5962df3fc4108fbb0d3ce2970314b8103ca1
3b8a5a4c11b6a637ef57e897b46cf30a943fe100
refs/heads/master
2023-07-19T20:07:12.174262
2023-07-15T01:57:19
2023-07-15T01:57:19
243,310,002
3
13
MIT
2023-05-13T19:56:44
2020-02-26T16:27:04
C++
UTF-8
C++
false
false
224
cpp
#include "../core/core.h" #include "monstermos.h" extern "C" EXPORT const char* init_monstermos(int n_args, const char** args) { if (!Core::initialize()) { return "Extools Init Failed"; } return enable_monstermos(); }
[ "mnmaxim@gmail.com" ]
mnmaxim@gmail.com
633a2c51bf73596b917a4ed2dfcd294b63048fd2
d0c44dd3da2ef8c0ff835982a437946cbf4d2940
/cmake-build-debug/programs_tiling/function13767/function13767_no_schedule/function13767_no_schedule_wrapper.cpp
6d135ec8f1db408e02a6afb2fb0bb0b5900777ed
[]
no_license
IsraMekki/tiramisu_code_generator
8b3f1d63cff62ba9f5242c019058d5a3119184a3
5a259d8e244af452e5301126683fa4320c2047a3
refs/heads/master
2020-04-29T17:27:57.987172
2019-04-23T16:50:32
2019-04-23T16:50:32
176,297,755
1
2
null
null
null
null
UTF-8
C++
false
false
1,053
cpp
#include "Halide.h" #include "function13767_no_schedule_wrapper.h" #include "tiramisu/utils.h" #include <cstdlib> #include <iostream> #include <time.h> #include <fstream> #include <chrono> #define MAX_RAND 200 int main(int, char **){ Halide::Buffer<int32_t> buf00(256); Halide::Buffer<int32_t> buf01(256); Halide::Buffer<int32_t> buf02(256); Halide::Buffer<int32_t> buf0(262144, 256); init_buffer(buf0, (int32_t)0); auto t1 = std::chrono::high_resolution_clock::now(); function13767_no_schedule(buf00.raw_buffer(), buf01.raw_buffer(), buf02.raw_buffer(), buf0.raw_buffer()); auto t2 = std::chrono::high_resolution_clock::now(); std::chrono::duration<double> diff = t2 - t1; std::ofstream exec_times_file; exec_times_file.open("../data/programs/function13767/function13767_no_schedule/exec_times.txt", std::ios_base::app); if (exec_times_file.is_open()){ exec_times_file << diff.count() * 1000000 << "us" <<std::endl; exec_times_file.close(); } return 0; }
[ "ei_mekki@esi.dz" ]
ei_mekki@esi.dz
3b7794c9311068e0950d339e176a6ad71da259d3
9b1ad74d4aeddffe57df71b550fa1075eb980808
/difficultyandspeedselectwindow.h
6e1dc2aaf6499f0fde48fb56871921126c7c3b26
[]
no_license
TwinIsland-CCC/RhythmGame_Project_1_00
85f99d9167af08b5ecc29cdd47d881c7becceed6
cbf2e06e89fe53e8a4a190fdefac2822ed073b1c
refs/heads/main
2023-04-24T02:31:35.979145
2021-05-09T17:07:49
2021-05-09T17:07:49
359,840,823
2
0
null
null
null
null
UTF-8
C++
false
false
744
h
#ifndef DIFFICULTYANDSPEEDSELECTWINDOW_H #define DIFFICULTYANDSPEEDSELECTWINDOW_H #include <QMainWindow> #include "source.h" #include "gamewindow.h" #include "mythread.h" namespace Ui { class DifficultyAndSpeedSelectWindow; } class DifficultyAndSpeedSelectWindow : public QMainWindow { Q_OBJECT public: explicit DifficultyAndSpeedSelectWindow(QWidget *parent = nullptr); ~DifficultyAndSpeedSelectWindow(); void init(); QThread* loadthread; mythread* myload; Gamewindow* game; private: Ui::DifficultyAndSpeedSelectWindow *ui; protected: void keyPressEvent(QKeyEvent *event); signals: void backbtnpushed(); void Re_Select(); void Music_Stop(); }; #endif // DIFFICULTYANDSPEEDSELECTWINDOW_H
[ "593312487@qq.com" ]
593312487@qq.com
ff68fd454755324a9966eba9fa580c70eaf26882
5c3e98971ca36aac7ab96660032dc8f1eebefcc8
/UE4_YellowProject/Source/UE4_YellowProject/Private/PipeTrap.cpp
43f0c6cab4da52361de647032770ac857eede268
[]
no_license
jordyAjanohoun/UE4-Yellow-Project-MAIN-4
215c6444cbd55eeab501a3dd5a339c7c44e3cd00
ee257f283d287d58bdfda4bc9ec9e5ffcd14c549
refs/heads/master
2020-04-13T23:05:34.083859
2019-01-30T06:07:22
2019-01-30T06:07:22
163,497,115
0
0
null
null
null
null
UTF-8
C++
false
false
1,395
cpp
// Fill out your copyright notice in the Description page of Project Settings. #include "PipeTrap.h" // Sets default values APipeTrap::APipeTrap() { // 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; // Set the Skin/shape of this character interactable element (this actor) auto ShapePipeMeshAssetFromEditor = ConstructorHelpers::FObjectFinder<UStaticMesh>(TEXT("StaticMesh'/Game/StarterContent/Shapes/Shape_Pipe.Shape_Pipe'")); // If the object was found, set the Skin/shape if (ShapePipeMeshAssetFromEditor.Object) { TheStaticMeshComponent_p->SetStaticMesh(ShapePipeMeshAssetFromEditor.Object); } // Set the trigger capsule TriggerCapsule_p = CreateDefaultSubobject<UCapsuleComponent>(TEXT("Trigger Capsule")); TriggerCapsule_p->InitCapsuleSize(42.f, 96.0f); TriggerCapsule_p->SetCollisionProfileName(TEXT("Trigger")); TriggerCapsule_p->SetupAttachment(RootComponent); // Precise function called on overlap begin event TriggerCapsule_p->OnComponentBeginOverlap.AddDynamic(this, &APipeTrap::OnOverlapBegin); } // Called when the game starts or when spawned void APipeTrap::BeginPlay() { Super::BeginPlay(); TriggerCapsule_p->SetRelativeLocation(FVector(0.0f, 0.0f, 7.0f)); } // Called every frame void APipeTrap::Tick(float DeltaTime) { Super::Tick(DeltaTime); }
[ "jordy.ajanohoun@hotmail.fr" ]
jordy.ajanohoun@hotmail.fr
f4f3e0f92ee4013b62f680de69b197df2e6dec82
20faef09e34ec943fc1662f66474dd3d238c3d3b
/Source/AdvancedLocomotionSystem/Public/CameraAnimInstance.h
d28b750bfce908f897e09e64e6aa18cbcf160b0a
[]
no_license
bumbumisnuts/AdvancedLocomotion
2bcb2831466a354f118ce579d69ad0b59a37483e
22e9dd1745ec2a14a843574ff28e3f40daad2adf
refs/heads/main
2023-08-18T01:47:32.740035
2021-10-15T11:00:59
2021-10-15T11:00:59
416,071,672
0
0
null
null
null
null
UTF-8
C++
false
false
454
h
#pragma once #include "CoreMinimal.h" #include "Animation/AnimInstance.h" #include "CameraAnimInstance.generated.h" UCLASS() class ADVANCEDLOCOMOTIONSYSTEM_API UCameraAnimInstance : public UAnimInstance { GENERATED_BODY() public: virtual void NativeUpdateAnimation(float DeltaSeconds) override; void UpdateCharacterInfo(); UPROPERTY() APawn* ControlledPawn = nullptr; UPROPERTY() APlayerController* PLayerControllerRef = nullptr; };
[ "reza.mahdi1394@gmail.com" ]
reza.mahdi1394@gmail.com
141db6761816241715e335c9f3d533891871935b
fef58dcd0c1434724a0a0a82e4c84ae906200289
/usages/0x6E575D6A898AB852.cpp
f421ad6c18ffc686930e6384b6e740832d9fb4f8
[]
no_license
DottieDot/gta5-additional-nativedb-data
a8945d29a60c04dc202f180e947cbdb3e0842ace
aea92b8b66833f063f391cb86cbcf4d58e1d7da3
refs/heads/main
2023-06-14T08:09:24.230253
2021-07-11T20:43:48
2021-07-11T20:43:48
380,364,689
1
0
null
null
null
null
UTF-8
C++
false
false
537
cpp
// agency_prep2amb.ysc @ L10612 int func_212() { if (PED::IS_PED_IN_ANY_TAXI(PLAYER::PLAYER_PED_ID())) { if ((VEHICLE::GET_PED_IN_VEHICLE_SEAT(PED::GET_VEHICLE_PED_IS_IN(PLAYER::PLAYER_PED_ID(), 0), 0, 0) == PLAYER::PLAYER_PED_ID() || VEHICLE::GET_PED_IN_VEHICLE_SEAT(PED::GET_VEHICLE_PED_IS_IN(PLAYER::PLAYER_PED_ID(), 0), 1, 0) == PLAYER::PLAYER_PED_ID()) || VEHICLE::GET_PED_IN_VEHICLE_SEAT(PED::GET_VEHICLE_PED_IS_IN(PLAYER::PLAYER_PED_ID(), 0), 2, 0) == PLAYER::PLAYER_PED_ID()) { return 1; } } return 0; }
[ "tvangroenigen@outlook.com" ]
tvangroenigen@outlook.com
2b84d26fb6306afffd86e5f3044483f570242652
879681c994f1ca9c8d2c905a4e5064997ad25a27
/root-2.3.0/run/tutorials/multiphase/twoPhaseEulerFoam/RAS/fluidisedBed/1.38/pMean
ecee67e64e113de059e127db22644a58a319bd00
[]
no_license
MizuhaWatanabe/OpenFOAM-2.3.0-with-Ubuntu
3828272d989d45fb020e83f8426b849e75560c62
daeb870be81275e8a81f5cbac4ca1906a9bc69c0
refs/heads/master
2020-05-17T16:36:41.848261
2015-04-18T09:29:48
2015-04-18T09:29:48
34,159,882
1
0
null
null
null
null
UTF-8
C++
false
false
46,374
/*--------------------------------*- C++ -*----------------------------------*\ | ========= | | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | | \\ / O peration | Version: 2.3.0 | | \\ / A nd | Web: www.OpenFOAM.org | | \\/ M anipulation | | \*---------------------------------------------------------------------------*/ FoamFile { version 2.0; format ascii; class volScalarField; location "1.38"; object pMean; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // dimensions [1 -1 -2 0 0 0 0]; internalField nonuniform List<scalar> 6000 ( 106415 106415 106413 106411 106410 106409 106409 106408 106408 106409 106410 106410 106409 106409 106411 106413 106413 106413 106413 106413 106413 106413 106413 106413 106413 106415 106417 106417 106417 106418 106346 106345 106343 106340 106339 106339 106338 106338 106337 106339 106339 106338 106338 106338 106339 106340 106341 106341 106341 106341 106340 106340 106339 106338 106340 106343 106345 106347 106347 106349 106295 106294 106292 106291 106291 106290 106290 106290 106290 106291 106291 106290 106289 106289 106289 106291 106293 106294 106294 106293 106292 106290 106288 106287 106289 106293 106296 106297 106297 106298 106240 106238 106236 106237 106238 106238 106238 106238 106239 106240 106240 106239 106238 106237 106238 106240 106242 106243 106243 106242 106240 106237 106235 106234 106236 106239 106242 106243 106243 106244 106184 106182 106181 106182 106183 106184 106185 106187 106188 106188 106188 106188 106187 106188 106189 106191 106193 106193 106192 106190 106188 106185 106184 106183 106184 106186 106188 106189 106189 106190 106128 106127 106127 106127 106129 106131 106133 106135 106136 106137 106137 106137 106138 106140 106142 106144 106143 106142 106141 106139 106137 106136 106135 106133 106132 106132 106134 106135 106136 106137 106075 106074 106073 106073 106076 106079 106082 106084 106085 106086 106086 106088 106091 106093 106095 106095 106093 106093 106092 106090 106089 106088 106086 106085 106083 106081 106081 106083 106084 106087 106024 106023 106021 106021 106025 106030 106033 106035 106035 106036 106037 106040 106043 106046 106047 106046 106044 106043 106042 106041 106041 106040 106040 106038 106036 106034 106034 106035 106037 106040 105975 105973 105970 105972 105977 105982 105986 105988 105988 105988 105990 105993 105996 105998 105999 105997 105995 105995 105994 105994 105994 105995 105995 105994 105992 105990 105989 105991 105994 105997 105928 105925 105923 105925 105930 105935 105940 105942 105942 105942 105944 105948 105950 105951 105951 105949 105948 105948 105948 105948 105949 105950 105951 105950 105948 105947 105947 105949 105953 105956 105882 105879 105878 105880 105884 105889 105895 105898 105898 105898 105899 105903 105904 105905 105904 105903 105903 105903 105903 105903 105905 105906 105905 105905 105904 105904 105905 105908 105913 105915 105837 105835 105834 105835 105838 105843 105850 105854 105854 105853 105854 105857 105858 105859 105858 105858 105858 105859 105858 105859 105860 105859 105859 105859 105859 105860 105862 105867 105872 105875 105794 105793 105791 105792 105794 105798 105804 105808 105810 105809 105809 105810 105812 105813 105813 105813 105814 105814 105813 105813 105813 105813 105811 105811 105812 105815 105819 105824 105830 105834 105752 105751 105750 105749 105751 105755 105759 105763 105765 105765 105764 105764 105766 105768 105768 105769 105769 105769 105768 105768 105767 105765 105763 105762 105764 105768 105774 105780 105786 105789 105711 105710 105709 105708 105709 105712 105715 105719 105721 105721 105719 105718 105720 105723 105724 105724 105724 105723 105723 105721 105720 105717 105714 105713 105715 105721 105727 105734 105739 105741 105670 105669 105668 105668 105668 105670 105672 105675 105677 105677 105675 105674 105675 105677 105678 105679 105679 105678 105677 105675 105672 105669 105666 105665 105667 105673 105679 105684 105689 105691 105628 105628 105628 105628 105627 105628 105630 105631 105633 105634 105632 105630 105631 105632 105633 105634 105634 105633 105632 105629 105625 105622 105619 105618 105621 105626 105631 105635 105638 105640 105586 105586 105587 105587 105587 105587 105588 105589 105590 105591 105589 105588 105587 105587 105588 105589 105589 105588 105586 105583 105579 105575 105572 105572 105575 105578 105582 105585 105587 105589 105544 105544 105546 105546 105546 105546 105547 105547 105547 105547 105547 105545 105544 105543 105543 105543 105543 105542 105540 105537 105532 105528 105526 105526 105528 105530 105533 105535 105537 105539 105501 105501 105503 105504 105504 105504 105504 105504 105503 105503 105504 105502 105501 105500 105499 105498 105497 105496 105494 105490 105485 105482 105481 105480 105481 105483 105485 105487 105488 105489 105457 105458 105460 105461 105462 105462 105461 105461 105460 105459 105460 105459 105458 105456 105455 105453 105451 105450 105447 105443 105439 105437 105436 105435 105435 105436 105438 105440 105441 105442 105414 105415 105416 105417 105418 105419 105418 105417 105416 105415 105416 105416 105415 105413 105411 105408 105406 105404 105401 105396 105393 105392 105391 105390 105389 105390 105392 105394 105395 105395 105372 105372 105373 105375 105376 105376 105374 105373 105372 105372 105372 105372 105372 105371 105368 105364 105362 105359 105355 105350 105347 105346 105345 105344 105344 105344 105345 105347 105348 105348 105330 105330 105331 105332 105333 105333 105331 105329 105329 105329 105328 105329 105329 105327 105325 105321 105317 105314 105308 105303 105300 105299 105298 105298 105297 105298 105299 105301 105301 105300 105288 105288 105289 105291 105292 105290 105287 105286 105286 105286 105286 105286 105286 105284 105281 105278 105273 105268 105261 105256 105252 105250 105250 105250 105250 105250 105251 105252 105251 105250 105246 105246 105247 105249 105249 105247 105244 105243 105243 105243 105243 105243 105242 105240 105238 105234 105229 105222 105215 105209 105206 105204 105202 105202 105201 105201 105201 105201 105199 105198 105205 105204 105205 105206 105206 105204 105201 105200 105200 105200 105201 105201 105199 105197 105195 105191 105184 105177 105170 105165 105161 105160 105158 105156 105154 105153 105152 105150 105148 105147 105162 105162 105162 105162 105161 105160 105158 105157 105157 105158 105158 105158 105156 105153 105151 105147 105140 105134 105128 105122 105118 105116 105115 105113 105109 105107 105104 105102 105100 105099 105119 105118 105118 105117 105117 105116 105115 105114 105114 105115 105116 105115 105113 105110 105107 105103 105098 105092 105087 105080 105076 105073 105071 105068 105064 105062 105058 105055 105053 105052 105076 105074 105074 105072 105072 105071 105071 105071 105071 105072 105073 105072 105070 105067 105063 105059 105055 105051 105045 105038 105033 105030 105027 105023 105019 105016 105013 105010 105008 105007 105032 105030 105029 105027 105027 105028 105027 105027 105028 105029 105029 105029 105027 105024 105020 105016 105013 105009 105002 104995 104989 104985 104981 104977 104973 104971 104967 104965 104963 104962 104988 104986 104985 104983 104983 104984 104984 104984 104984 104985 104986 104986 104984 104981 104977 104973 104970 104966 104959 104951 104945 104940 104936 104931 104928 104925 104922 104920 104918 104918 104943 104942 104941 104940 104940 104941 104941 104941 104942 104942 104943 104942 104941 104938 104934 104930 104926 104922 104915 104907 104901 104896 104891 104886 104883 104881 104879 104876 104874 104874 104898 104897 104897 104896 104897 104898 104898 104898 104899 104899 104899 104899 104898 104895 104891 104887 104882 104877 104869 104863 104857 104852 104847 104843 104841 104839 104836 104834 104832 104831 104853 104852 104852 104853 104853 104855 104855 104856 104857 104857 104856 104855 104854 104851 104847 104843 104838 104832 104825 104819 104814 104809 104804 104802 104801 104798 104795 104792 104789 104789 104807 104807 104807 104808 104810 104812 104813 104814 104814 104814 104813 104812 104810 104807 104803 104798 104793 104787 104780 104775 104770 104766 104763 104762 104761 104758 104753 104749 104747 104746 104761 104761 104762 104764 104766 104769 104771 104771 104771 104770 104769 104767 104765 104762 104757 104753 104747 104742 104736 104731 104727 104724 104723 104722 104720 104716 104711 104706 104704 104703 104716 104717 104717 104719 104722 104726 104728 104728 104727 104726 104724 104722 104720 104716 104712 104707 104702 104697 104693 104688 104684 104683 104682 104682 104678 104673 104667 104663 104661 104660 104672 104673 104674 104675 104678 104682 104684 104684 104683 104681 104680 104678 104675 104671 104667 104663 104658 104653 104649 104645 104642 104641 104641 104640 104636 104629 104623 104620 104618 104618 104629 104629 104630 104631 104633 104637 104640 104640 104638 104636 104635 104633 104630 104627 104622 104618 104614 104609 104605 104602 104600 104600 104600 104598 104592 104586 104580 104577 104576 104576 104586 104585 104586 104587 104589 104593 104596 104596 104594 104592 104590 104588 104585 104582 104578 104574 104570 104565 104561 104559 104557 104558 104557 104555 104549 104543 104538 104535 104534 104534 104542 104541 104541 104543 104546 104549 104551 104551 104549 104547 104546 104544 104541 104538 104534 104530 104526 104521 104518 104516 104515 104515 104514 104511 104506 104501 104497 104494 104493 104493 104497 104496 104497 104499 104502 104505 104507 104506 104505 104502 104501 104499 104496 104492 104489 104485 104481 104477 104475 104473 104472 104472 104471 104468 104464 104459 104456 104453 104452 104452 104453 104452 104454 104456 104458 104461 104462 104461 104460 104457 104456 104453 104450 104447 104443 104440 104437 104433 104431 104430 104430 104429 104427 104425 104421 104418 104415 104413 104412 104411 104409 104409 104411 104413 104415 104416 104417 104416 104415 104412 104410 104408 104404 104401 104397 104394 104391 104389 104387 104387 104387 104386 104384 104382 104379 104376 104374 104372 104371 104371 104366 104366 104368 104370 104371 104372 104372 104371 104369 104367 104364 104362 104358 104354 104351 104348 104346 104344 104342 104343 104343 104342 104340 104339 104337 104335 104333 104332 104331 104331 104324 104324 104326 104327 104328 104327 104327 104325 104323 104321 104317 104314 104311 104307 104304 104301 104299 104298 104297 104298 104298 104298 104297 104296 104294 104293 104291 104291 104290 104291 104282 104282 104283 104284 104284 104283 104281 104279 104276 104273 104269 104266 104262 104259 104256 104254 104253 104252 104252 104252 104253 104253 104253 104252 104251 104250 104249 104249 104249 104249 104239 104239 104240 104240 104239 104237 104235 104232 104228 104223 104219 104216 104213 104210 104208 104207 104206 104206 104206 104207 104207 104208 104208 104208 104206 104205 104205 104206 104206 104206 104195 104196 104195 104194 104193 104190 104187 104182 104177 104172 104168 104164 104162 104161 104160 104160 104160 104160 104160 104162 104162 104162 104162 104162 104161 104160 104161 104162 104162 104162 104151 104150 104149 104147 104145 104142 104137 104131 104124 104119 104115 104113 104112 104112 104112 104113 104113 104114 104115 104116 104116 104115 104114 104114 104114 104114 104116 104117 104118 104118 104103 104102 104100 104098 104095 104091 104086 104078 104070 104065 104064 104063 104064 104065 104065 104065 104066 104068 104070 104070 104068 104067 104066 104066 104067 104068 104070 104072 104073 104073 104052 104050 104048 104046 104043 104039 104033 104025 104018 104015 104014 104016 104017 104018 104018 104019 104019 104021 104023 104023 104020 104018 104017 104018 104020 104022 104024 104026 104027 104027 103999 103997 103995 103993 103991 103988 103982 103975 103969 103968 103969 103970 103972 103972 103972 103972 103973 103974 103974 103974 103971 103969 103969 103970 103973 103976 103978 103980 103981 103981 103948 103946 103944 103943 103941 103938 103933 103928 103925 103925 103926 103927 103927 103927 103926 103926 103925 103925 103925 103924 103921 103920 103921 103923 103926 103930 103932 103935 103935 103935 103898 103897 103896 103894 103893 103890 103887 103884 103882 103882 103883 103884 103883 103882 103881 103879 103877 103874 103874 103873 103871 103871 103873 103876 103880 103884 103887 103889 103890 103890 103851 103850 103850 103848 103847 103845 103843 103841 103841 103840 103841 103840 103839 103838 103836 103833 103829 103825 103824 103823 103822 103823 103826 103830 103835 103839 103841 103843 103845 103845 103807 103805 103804 103803 103802 103802 103801 103800 103799 103798 103798 103797 103795 103793 103790 103786 103782 103778 103776 103776 103776 103777 103780 103785 103790 103794 103796 103798 103800 103801 103763 103761 103760 103759 103758 103759 103760 103759 103758 103756 103755 103753 103751 103748 103745 103740 103736 103734 103732 103731 103731 103733 103737 103742 103746 103749 103751 103753 103755 103756 103719 103717 103716 103715 103715 103717 103718 103718 103717 103714 103712 103710 103707 103703 103700 103696 103693 103691 103689 103688 103688 103691 103695 103699 103703 103706 103707 103708 103710 103711 103674 103672 103671 103671 103672 103674 103676 103676 103675 103672 103669 103666 103662 103659 103656 103652 103650 103648 103647 103645 103646 103649 103654 103658 103662 103663 103664 103664 103665 103667 103627 103627 103626 103626 103627 103630 103632 103632 103631 103629 103625 103622 103618 103615 103612 103609 103607 103605 103604 103603 103604 103608 103613 103617 103620 103621 103621 103621 103621 103622 103579 103579 103579 103580 103581 103584 103587 103588 103587 103585 103581 103578 103574 103571 103568 103566 103564 103562 103562 103561 103563 103567 103571 103575 103578 103578 103578 103578 103578 103578 103530 103530 103531 103532 103534 103537 103540 103541 103541 103540 103536 103533 103529 103526 103523 103521 103520 103519 103519 103519 103521 103525 103529 103533 103535 103535 103534 103534 103534 103534 103480 103480 103481 103483 103485 103488 103491 103492 103493 103492 103489 103486 103483 103481 103478 103477 103476 103475 103475 103476 103478 103482 103485 103488 103490 103489 103488 103488 103488 103487 103429 103429 103431 103432 103434 103437 103439 103441 103441 103441 103439 103436 103434 103433 103432 103431 103430 103430 103431 103432 103435 103437 103440 103442 103443 103442 103440 103440 103439 103439 103379 103379 103379 103381 103382 103384 103387 103388 103388 103388 103387 103385 103383 103382 103383 103383 103384 103384 103386 103387 103389 103391 103393 103394 103394 103392 103391 103389 103389 103389 103329 103328 103328 103328 103330 103332 103333 103334 103334 103334 103333 103332 103331 103330 103332 103333 103335 103337 103338 103340 103341 103343 103343 103344 103344 103342 103340 103338 103337 103338 103278 103277 103276 103276 103277 103278 103279 103279 103279 103278 103278 103277 103276 103277 103279 103282 103285 103287 103289 103290 103291 103292 103293 103293 103293 103291 103289 103287 103286 103286 103228 103227 103226 103225 103225 103225 103225 103224 103223 103222 103221 103221 103221 103222 103225 103229 103233 103236 103238 103238 103240 103241 103242 103243 103242 103241 103238 103236 103234 103234 103177 103176 103175 103174 103173 103172 103171 103168 103166 103165 103164 103164 103164 103166 103170 103175 103179 103183 103184 103185 103187 103189 103191 103192 103192 103190 103188 103185 103183 103183 103124 103124 103123 103122 103120 103119 103116 103113 103109 103106 103105 103105 103107 103110 103114 103120 103125 103128 103130 103131 103133 103136 103139 103142 103142 103141 103139 103136 103133 103133 103069 103070 103070 103068 103066 103064 103061 103057 103052 103048 103046 103047 103050 103054 103059 103065 103069 103073 103075 103077 103080 103083 103088 103091 103093 103093 103091 103088 103086 103085 103012 103013 103013 103012 103011 103009 103006 103001 102995 102991 102990 102992 102995 103000 103006 103011 103015 103019 103021 103023 103026 103030 103036 103041 103044 103045 103044 103042 103039 103038 102954 102954 102955 102954 102953 102952 102949 102945 102940 102938 102938 102940 102944 102949 102954 102959 102962 102966 102968 102970 102973 102977 102984 102990 102994 102997 102997 102996 102994 102993 102896 102896 102896 102896 102896 102895 102892 102889 102886 102886 102888 102891 102895 102900 102905 102909 102912 102914 102915 102917 102920 102924 102931 102938 102944 102948 102949 102949 102948 102947 102838 102838 102839 102839 102839 102838 102837 102835 102835 102837 102840 102844 102848 102853 102857 102861 102863 102864 102865 102866 102868 102872 102878 102885 102892 102897 102899 102901 102900 102899 102783 102783 102784 102784 102784 102784 102784 102784 102786 102789 102793 102797 102802 102806 102810 102814 102816 102816 102817 102817 102819 102821 102826 102833 102839 102844 102847 102849 102850 102849 102730 102730 102731 102732 102732 102733 102734 102736 102739 102743 102747 102752 102757 102761 102765 102767 102769 102770 102770 102770 102772 102774 102777 102782 102787 102792 102794 102795 102797 102797 102679 102679 102680 102681 102682 102683 102686 102690 102694 102698 102703 102708 102712 102715 102718 102721 102722 102723 102723 102724 102726 102728 102730 102732 102736 102740 102741 102742 102743 102744 102628 102628 102629 102631 102633 102635 102638 102643 102649 102654 102659 102663 102666 102669 102671 102672 102673 102675 102676 102678 102680 102682 102683 102684 102686 102689 102690 102690 102689 102689 102578 102578 102579 102582 102585 102587 102590 102596 102602 102608 102613 102616 102618 102620 102622 102623 102624 102626 102628 102630 102632 102634 102636 102636 102637 102638 102638 102638 102636 102636 102527 102527 102529 102532 102536 102538 102542 102548 102554 102560 102565 102568 102570 102572 102573 102574 102576 102577 102579 102582 102584 102586 102588 102588 102587 102586 102586 102585 102584 102583 102475 102476 102478 102481 102485 102490 102494 102500 102505 102511 102515 102519 102522 102524 102525 102526 102527 102529 102531 102533 102535 102537 102538 102537 102535 102534 102533 102532 102530 102530 102423 102424 102427 102430 102434 102439 102444 102450 102455 102460 102465 102469 102472 102475 102476 102477 102478 102480 102482 102483 102485 102486 102486 102485 102483 102482 102479 102477 102476 102475 102371 102373 102375 102378 102382 102386 102391 102398 102404 102409 102413 102417 102421 102424 102426 102428 102429 102430 102432 102432 102433 102433 102434 102433 102431 102429 102426 102424 102422 102421 102319 102321 102323 102326 102329 102333 102338 102345 102351 102356 102361 102365 102369 102372 102375 102377 102379 102380 102380 102380 102381 102381 102381 102380 102378 102376 102374 102371 102369 102368 102267 102269 102271 102273 102276 102279 102285 102292 102298 102304 102309 102313 102316 102320 102323 102326 102327 102327 102327 102328 102328 102328 102328 102327 102325 102323 102321 102318 102316 102315 102213 102215 102217 102219 102221 102225 102231 102239 102246 102252 102257 102261 102264 102268 102271 102273 102273 102273 102274 102275 102276 102276 102276 102274 102273 102271 102268 102265 102263 102262 102159 102160 102162 102164 102166 102170 102178 102185 102192 102198 102203 102207 102210 102213 102216 102218 102218 102219 102220 102222 102224 102225 102225 102223 102221 102218 102215 102212 102209 102208 102104 102105 102106 102108 102112 102118 102125 102132 102139 102144 102149 102153 102156 102158 102160 102162 102163 102164 102167 102170 102174 102175 102174 102172 102169 102166 102162 102159 102157 102156 102049 102049 102051 102053 102058 102066 102073 102079 102085 102090 102094 102098 102100 102102 102105 102107 102108 102111 102114 102118 102122 102123 102122 102120 102117 102113 102109 102107 102105 102104 101993 101994 101996 101999 102005 102013 102020 102026 102031 102036 102039 102042 102045 102047 102049 102051 102054 102057 102061 102065 102068 102070 102070 102068 102064 102060 102057 102055 102054 102053 101938 101939 101941 101945 101951 101960 101967 101972 101977 101981 101983 101986 101988 101991 101993 101995 101998 102002 102006 102010 102013 102015 102015 102013 102010 102006 102004 102002 102002 102002 101884 101885 101887 101890 101897 101905 101912 101918 101922 101925 101928 101929 101931 101934 101936 101939 101942 101947 101951 101955 101958 101960 101960 101958 101956 101953 101950 101949 101949 101949 101830 101830 101832 101835 101841 101849 101856 101862 101867 101870 101871 101872 101873 101875 101878 101881 101885 101890 101895 101900 101903 101904 101904 101904 101902 101899 101896 101895 101895 101895 101776 101776 101777 101781 101787 101794 101801 101807 101811 101814 101816 101816 101816 101816 101818 101822 101827 101833 101839 101844 101847 101848 101849 101848 101847 101844 101842 101840 101839 101838 101722 101722 101724 101728 101734 101741 101747 101753 101757 101759 101761 101761 101760 101760 101760 101763 101768 101774 101781 101787 101790 101792 101793 101792 101791 101789 101785 101782 101780 101778 101670 101670 101672 101677 101683 101689 101695 101700 101704 101706 101707 101707 101706 101705 101705 101706 101710 101716 101723 101729 101733 101735 101735 101735 101734 101731 101726 101722 101719 101716 101620 101621 101624 101629 101634 101640 101645 101650 101653 101655 101656 101656 101655 101654 101654 101654 101655 101659 101665 101672 101676 101678 101679 101679 101677 101673 101667 101662 101658 101654 101574 101575 101579 101584 101589 101594 101598 101602 101605 101607 101608 101607 101607 101607 101606 101605 101605 101607 101611 101617 101621 101624 101624 101623 101620 101616 101610 101604 101599 101596 101530 101531 101535 101539 101545 101549 101553 101556 101557 101559 101560 101560 101560 101560 101560 101559 101558 101557 101560 101564 101567 101569 101569 101567 101564 101559 101553 101548 101543 101540 101486 101487 101490 101495 101500 101504 101507 101509 101510 101511 101512 101513 101513 101514 101514 101513 101512 101510 101511 101512 101514 101515 101515 101513 101509 101503 101497 101492 101489 101487 101441 101443 101446 101451 101455 101458 101461 101463 101464 101464 101464 101465 101465 101466 101467 101467 101465 101464 101462 101462 101462 101462 101461 101458 101454 101448 101442 101438 101436 101437 101397 101398 101401 101405 101409 101412 101414 101416 101417 101417 101416 101416 101416 101417 101418 101418 101417 101416 101414 101412 101411 101410 101408 101405 101400 101394 101389 101386 101386 101386 101352 101353 101355 101359 101362 101364 101366 101368 101369 101368 101367 101365 101365 101365 101366 101366 101366 101365 101365 101363 101360 101358 101356 101353 101348 101343 101340 101338 101338 101337 101306 101307 101309 101312 101315 101316 101318 101320 101320 101319 101316 101314 101312 101311 101312 101313 101313 101313 101313 101312 101309 101307 101304 101302 101299 101295 101293 101292 101291 101290 101260 101261 101263 101264 101267 101268 101269 101270 101269 101267 101264 101261 101259 101258 101258 101259 101259 101260 101260 101259 101258 101256 101254 101253 101251 101249 101248 101247 101246 101245 101215 101215 101216 101216 101218 101219 101218 101218 101217 101214 101211 101209 101208 101207 101207 101207 101207 101208 101207 101206 101207 101206 101205 101204 101204 101204 101204 101203 101201 101201 101169 101168 101168 101168 101168 101167 101165 101164 101162 101161 101160 101159 101159 101160 101159 101159 101159 101159 101158 101157 101157 101157 101157 101156 101156 101157 101158 101158 101157 101157 101123 101121 101120 101119 101117 101114 101111 101110 101110 101110 101111 101112 101113 101114 101114 101114 101114 101113 101112 101111 101110 101110 101110 101109 101109 101109 101111 101112 101112 101113 101074 101073 101070 101068 101065 101062 101060 101060 101061 101063 101065 101067 101069 101070 101071 101071 101071 101070 101068 101066 101064 101064 101064 101063 101062 101061 101061 101063 101065 101066 101024 101023 101020 101017 101014 101013 101012 101014 101016 101019 101021 101024 101026 101028 101029 101029 101029 101027 101025 101022 101020 101019 101019 101018 101017 101015 101013 101014 101016 101018 100973 100973 100970 100968 100967 100968 100968 100970 100974 100977 100979 100982 100984 100986 100987 100987 100986 100984 100981 100978 100975 100974 100974 100974 100973 100971 100968 100967 100967 100969 100924 100924 100923 100922 100923 100925 100927 100930 100933 100936 100938 100940 100942 100944 100945 100945 100944 100942 100938 100935 100932 100930 100929 100930 100929 100928 100926 100924 100923 100923 100878 100879 100879 100879 100881 100884 100888 100891 100893 100895 100897 100899 100901 100902 100902 100902 100901 100898 100895 100891 100888 100885 100885 100885 100885 100885 100883 100881 100880 100879 100837 100837 100837 100838 100841 100846 100849 100852 100854 100856 100856 100857 100858 100859 100859 100858 100856 100854 100851 100847 100844 100841 100840 100840 100840 100840 100840 100838 100836 100834 100797 100797 100796 100798 100802 100807 100811 100813 100814 100815 100815 100816 100816 100816 100815 100814 100812 100809 100806 100802 100799 100796 100794 100793 100793 100794 100793 100792 100791 100788 100757 100757 100757 100758 100762 100767 100770 100773 100774 100774 100774 100773 100773 100772 100771 100769 100767 100764 100760 100757 100754 100751 100748 100746 100745 100745 100745 100744 100743 100741 100716 100716 100717 100718 100720 100725 100729 100731 100732 100731 100731 100730 100729 100728 100727 100724 100722 100718 100715 100711 100708 100705 100701 100699 100697 100696 100695 100694 100694 100694 100674 100675 100675 100676 100677 100682 100686 100688 100688 100688 100688 100687 100686 100685 100683 100680 100677 100673 100670 100667 100664 100660 100656 100652 100650 100648 100647 100646 100646 100646 100633 100633 100634 100634 100635 100638 100642 100644 100645 100645 100645 100644 100643 100642 100640 100637 100633 100630 100626 100624 100621 100617 100613 100608 100606 100604 100602 100601 100600 100601 100594 100593 100593 100593 100594 100596 100599 100602 100603 100603 100602 100602 100601 100600 100598 100595 100592 100588 100585 100582 100579 100576 100572 100567 100564 100562 100560 100558 100557 100558 100555 100554 100554 100554 100554 100555 100558 100560 100561 100562 100562 100561 100560 100559 100557 100555 100551 100548 100545 100542 100540 100537 100533 100529 100525 100523 100520 100519 100517 100518 100518 100517 100516 100515 100515 100516 100518 100520 100521 100522 100523 100522 100522 100521 100519 100516 100513 100510 100507 100505 100503 100500 100497 100492 100488 100486 100483 100481 100480 100480 100482 100480 100479 100478 100478 100478 100479 100481 100483 100484 100485 100485 100484 100484 100482 100480 100477 100474 100471 100469 100467 100465 100462 100457 100453 100450 100447 100445 100444 100445 100446 100445 100443 100442 100440 100440 100441 100443 100446 100448 100449 100449 100449 100448 100447 100445 100442 100440 100437 100434 100432 100431 100428 100424 100419 100416 100413 100411 100410 100411 100411 100409 100407 100405 100404 100404 100405 100408 100410 100413 100414 100415 100415 100414 100413 100411 100409 100406 100404 100401 100398 100397 100394 100390 100386 100382 100380 100379 100378 100379 100376 100375 100372 100370 100369 100370 100372 100375 100378 100381 100383 100384 100384 100383 100382 100380 100378 100375 100372 100369 100366 100364 100362 100359 100354 100351 100349 100347 100347 100348 100342 100341 100339 100338 100337 100338 100341 100345 100349 100352 100354 100355 100355 100354 100353 100352 100350 100346 100343 100339 100335 100333 100331 100328 100324 100321 100320 100319 100318 100318 100310 100309 100308 100308 100308 100309 100312 100316 100320 100324 100326 100328 100328 100327 100326 100325 100323 100319 100315 100311 100307 100303 100301 100299 100297 100294 100293 100291 100290 100288 100280 100280 100280 100280 100281 100282 100285 100289 100294 100298 100301 100302 100303 100302 100301 100300 100297 100294 100289 100285 100280 100276 100273 100271 100270 100269 100267 100265 100262 100260 100254 100254 100254 100254 100255 100256 100259 100264 100269 100273 100276 100278 100279 100278 100277 100276 100273 100269 100265 100260 100255 100251 100247 100244 100243 100242 100240 100237 100235 100233 100229 100228 100228 100229 100230 100232 100236 100240 100246 100250 100253 100255 100256 100256 100255 100254 100251 100247 100242 100237 100232 100227 100223 100219 100217 100214 100212 100210 100209 100208 100205 100204 100204 100205 100207 100210 100214 100219 100224 100228 100231 100234 100235 100235 100234 100232 100230 100225 100221 100215 100210 100205 100201 100196 100192 100189 100187 100186 100187 100187 100182 100182 100182 100184 100186 100189 100193 100198 100203 100207 100211 100213 100214 100214 100214 100212 100209 100205 100200 100195 100190 100185 100180 100175 100170 100166 100164 100165 100166 100167 100162 100162 100163 100165 100168 100171 100175 100180 100185 100188 100191 100194 100195 100195 100194 100193 100190 100186 100182 100177 100171 100166 100161 100156 100151 100147 100145 100146 100148 100149 100145 100145 100146 100148 100151 100154 100158 100163 100168 100171 100174 100177 100178 100178 100177 100175 100173 100169 100165 100160 100155 100150 100145 100140 100135 100131 100129 100130 100131 100131 100129 100129 100131 100133 100135 100139 100143 100148 100152 100156 100158 100161 100162 100162 100161 100159 100156 100153 100149 100145 100140 100135 100130 100125 100121 100117 100115 100115 100116 100115 100116 100115 100117 100119 100122 100125 100128 100133 100137 100141 100143 100145 100147 100147 100145 100143 100141 100138 100135 100131 100126 100121 100117 100112 100108 100105 100103 100103 100102 100102 100104 100104 100105 100107 100109 100112 100115 100118 100123 100127 100129 100131 100132 100132 100131 100129 100127 100125 100121 100118 100113 100109 100104 100100 100097 100094 100093 100092 100091 100090 100093 100093 100094 100095 100097 100099 100101 100105 100109 100113 100115 100117 100118 100118 100117 100115 100114 100112 100108 100105 100100 100097 100093 100090 100087 100084 100083 100081 100080 100079 100083 100083 100083 100083 100085 100087 100089 100092 100096 100099 100102 100104 100105 100105 100104 100103 100101 100099 100096 100092 100088 100085 100082 100079 100076 100074 100072 100071 100069 100069 100073 100073 100072 100073 100074 100076 100077 100080 100083 100087 100089 100091 100092 100092 100091 100090 100089 100086 100083 100080 100077 100073 100071 100068 100066 100064 100062 100060 100059 100059 100063 100063 100063 100063 100064 100066 100067 100069 100072 100075 100077 100079 100080 100080 100079 100078 100077 100074 100071 100068 100065 100062 100060 100058 100055 100053 100051 100050 100049 100049 100054 100054 100053 100054 100055 100056 100058 100059 100061 100064 100066 100067 100068 100068 100068 100067 100065 100063 100060 100057 100055 100052 100050 100047 100045 100043 100042 100041 100040 100040 100045 100045 100045 100045 100046 100048 100050 100051 100052 100054 100056 100057 100057 100057 100056 100055 100054 100051 100049 100047 100045 100042 100040 100038 100036 100035 100033 100032 100032 100032 100038 100037 100037 100037 100039 100040 100042 100043 100044 100045 100046 100047 100047 100046 100045 100044 100043 100041 100038 100037 100035 100034 100032 100030 100029 100027 100026 100025 100024 100025 100031 100030 100030 100031 100032 100033 100035 100036 100037 100038 100038 100038 100038 100037 100036 100035 100033 100031 100029 100028 100027 100026 100025 100023 100022 100021 100019 100018 100018 100018 100025 100024 100024 100025 100026 100027 100028 100029 100030 100031 100031 100031 100031 100030 100029 100028 100026 100025 100023 100021 100020 100019 100019 100018 100017 100016 100014 100013 100013 100013 100019 100019 100019 100019 100020 100021 100022 100023 100024 100025 100025 100025 100025 100024 100023 100023 100021 100020 100018 100016 100015 100014 100014 100013 100012 100011 100010 100009 100009 100009 100014 100013 100014 100014 100015 100016 100017 100018 100019 100019 100020 100020 100020 100019 100019 100018 100017 100016 100014 100013 100012 100011 100010 100010 100009 100009 100008 100007 100007 100007 100009 100009 100010 100010 100011 100012 100012 100013 100014 100015 100015 100016 100016 100015 100015 100014 100013 100012 100012 100011 100010 100009 100008 100008 100007 100007 100006 100005 100005 100005 100006 100007 100007 100008 100008 100009 100009 100010 100011 100012 100012 100012 100012 100012 100012 100011 100011 100010 100010 100009 100008 100007 100007 100006 100006 100005 100005 100005 100004 100004 100005 100005 100005 100006 100007 100007 100007 100008 100009 100009 100010 100010 100010 100010 100010 100009 100009 100008 100008 100007 100007 100006 100006 100006 100005 100005 100004 100004 100004 100004 100004 100004 100004 100005 100005 100006 100006 100007 100007 100007 100008 100008 100008 100008 100008 100008 100007 100007 100007 100006 100006 100006 100005 100005 100005 100004 100004 100004 100004 100004 100003 100003 100003 100004 100004 100005 100005 100006 100006 100006 100006 100006 100007 100007 100007 100006 100006 100006 100006 100005 100005 100005 100005 100004 100004 100004 100004 100004 100003 100004 100003 100003 100003 100003 100003 100004 100004 100005 100005 100005 100005 100005 100005 100006 100005 100005 100005 100005 100005 100005 100005 100004 100004 100004 100004 100003 100003 100003 100003 100003 100002 100002 100002 100002 100003 100003 100003 100004 100004 100004 100004 100004 100005 100005 100005 100005 100004 100004 100004 100004 100004 100004 100004 100003 100003 100003 100003 100003 100003 100003 100002 100002 100002 100002 100002 100003 100003 100003 100003 100003 100004 100004 100004 100004 100004 100004 100004 100004 100004 100004 100003 100003 100003 100003 100003 100002 100002 100002 100002 100003 100002 100002 100002 100002 100002 100002 100002 100002 100003 100003 100003 100003 100003 100003 100003 100003 100003 100003 100003 100003 100003 100003 100003 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 ) ; boundaryField { inlet { type calculated; value nonuniform List<scalar> 30 ( 106415 106415 106414 106412 106410 106409 106409 106408 106408 106409 106410 106410 106410 106409 106411 106413 106414 106413 106413 106413 106413 106413 106413 106413 106413 106415 106417 106417 106417 106418 ) ; } outlet { type calculated; value uniform 100000; } walls { type calculated; value nonuniform List<scalar> 400 ( 106415 106346 106295 106240 106184 106128 106075 106024 105975 105928 105882 105837 105794 105752 105711 105670 105628 105586 105544 105501 105457 105414 105372 105330 105288 105246 105205 105162 105119 105076 105032 104988 104943 104898 104853 104807 104761 104716 104672 104629 104586 104542 104497 104453 104409 104366 104324 104282 104239 104195 104151 104103 104052 103999 103948 103898 103851 103807 103763 103719 103674 103627 103579 103530 103480 103429 103379 103329 103278 103228 103177 103124 103069 103012 102954 102896 102838 102783 102730 102679 102628 102578 102527 102475 102423 102371 102319 102267 102213 102159 102104 102049 101993 101938 101884 101830 101776 101722 101670 101620 101574 101530 101486 101441 101397 101352 101306 101260 101215 101169 101123 101074 101024 100973 100924 100878 100837 100797 100757 100716 100674 100633 100594 100555 100518 100482 100446 100411 100376 100342 100310 100280 100254 100229 100205 100182 100162 100145 100129 100116 100104 100093 100083 100073 100063 100054 100045 100038 100031 100025 100019 100014 100009 100006 100005 100004 100003 100003 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100000 100000 100000 100000 100000 100000 100000 100000 100000 106418 106349 106298 106244 106190 106137 106087 106040 105997 105956 105915 105875 105834 105789 105741 105691 105640 105589 105539 105489 105442 105395 105348 105300 105250 105198 105147 105099 105052 105007 104962 104918 104874 104831 104789 104746 104703 104660 104618 104576 104534 104493 104452 104411 104371 104331 104291 104249 104206 104162 104118 104073 104027 103981 103935 103890 103845 103801 103756 103711 103667 103622 103578 103534 103487 103439 103389 103338 103286 103234 103183 103133 103085 103038 102993 102947 102899 102849 102797 102744 102689 102636 102583 102530 102475 102421 102368 102315 102262 102208 102156 102104 102053 102002 101949 101895 101838 101778 101716 101654 101596 101540 101487 101437 101386 101337 101290 101245 101201 101157 101113 101066 101018 100969 100923 100879 100834 100788 100741 100694 100646 100601 100558 100518 100480 100445 100411 100379 100348 100318 100288 100260 100233 100208 100187 100167 100149 100131 100115 100102 100090 100079 100069 100059 100049 100040 100032 100025 100018 100013 100009 100007 100005 100004 100004 100004 100004 100003 100003 100003 100002 100002 100002 100002 100002 100002 100002 100002 100002 100002 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100001 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 ) ; } frontAndBackPlanes { type empty; } } // ************************************************************************* //
[ "mizuha.watanabe@gmail.com" ]
mizuha.watanabe@gmail.com
7e9fae53d31403c4d04d272dfc14f9751cec6dd7
18e7bbf8a046be2c3a2d0f58da4ab8d9e93aa445
/src/qt/managenamespage.h
8d54b1813e2c6f2eb31004d7855b6737a3d7f131
[ "MIT" ]
permissive
kurrency/namecoin-core
12516631820b589757b2a59fae7e68304a33a9dd
5d526c4566c1e2a961687232e794bf1a1d2eb1cc
refs/heads/master
2021-01-20T00:45:30.087557
2017-02-03T16:33:40
2017-02-03T16:34:28
89,180,018
0
1
null
2017-04-23T23:48:07
2017-04-23T23:48:07
null
UTF-8
C++
false
false
1,255
h
#ifndef MANAGENAMESPAGE_H #define MANAGENAMESPAGE_H #include "platformstyle.h" #include <QWidget> class WalletModel; class NameTableModel; namespace Ui { class ManageNamesPage; } QT_BEGIN_NAMESPACE class QTableView; class QItemSelection; class QSortFilterProxyModel; class QMenu; class QModelIndex; QT_END_NAMESPACE /** Page for managing names */ class ManageNamesPage : public QWidget { Q_OBJECT public: explicit ManageNamesPage(const PlatformStyle *platformStyle, QWidget *parent = 0); ~ManageNamesPage(); void setModel(WalletModel *walletModel); private: const PlatformStyle *platformStyle; Ui::ManageNamesPage *ui; NameTableModel *model; WalletModel *walletModel; QSortFilterProxyModel *proxyModel; QMenu *contextMenu; public Q_SLOTS: void exportClicked(); private Q_SLOTS: void on_submitNameButton_clicked(); bool eventFilter(QObject *object, QEvent *event); void selectionChanged(); /** Spawn contextual menu (right mouse menu) for name table entry */ void contextualMenu(const QPoint &point); void onCopyNameAction(); void onCopyValueAction(); void on_configureNameButton_clicked(); void on_renewNameButton_clicked(); }; #endif // MANAGENAMESPAGE_H
[ "brandon@bxroberts.org" ]
brandon@bxroberts.org
cbd0c0e27867ec23e42c6865f733df4def75ae5c
2f10f807d3307b83293a521da600c02623cdda82
/deps/boost/win/debug/include/boost/spirit/home/support/detail/pow10.hpp
8625d3bc3c0a12a8dc6d4be859f6529314c8e5fc
[]
no_license
xpierrohk/dpt-rp1-cpp
2ca4e377628363c3e9d41f88c8cbccc0fc2f1a1e
643d053983fce3e6b099e2d3c9ab8387d0ea5a75
refs/heads/master
2021-05-23T08:19:48.823198
2019-07-26T17:35:28
2019-07-26T17:35:28
null
0
0
null
null
null
null
UTF-8
C++
false
false
129
hpp
version https://git-lfs.github.com/spec/v1 oid sha256:d79ecc9ba653bd7874dc305fd7311d448931bbf8b2b4138c6685e85bd0f430c9 size 4808
[ "YLiLarry@gmail.com" ]
YLiLarry@gmail.com
ad8c1a3e04b596f6beb0d844c415bd09144d32f7
11111216d72b941f5907a8ebba7b463ededb1e55
/omnetpp-5.1.1/src/qtenv/moc_objecttreeinspector.cpp
4b02eacfe9d8b03a878f86e0fd7e216cf9db381c
[]
no_license
kevinc-303/Final-Year-Project
4b1e40af0773bb53e8ffa78cdd55dd42ed1a579d
18f4b57bfba8f7638385d694c6ec34d2f74f6b55
refs/heads/main
2023-04-14T01:34:57.714629
2021-04-27T21:34:38
2021-04-27T21:34:38
362,257,257
0
0
null
null
null
null
UTF-8
C++
false
false
4,376
cpp
/**************************************************************************** ** Meta object code from reading C++ file 'objecttreeinspector.h' ** ** Created by: The Qt Meta Object Compiler version 67 (Qt 5.5.1) ** ** WARNING! All changes made in this file will be lost! *****************************************************************************/ #include "objecttreeinspector.h" #include <QtCore/qbytearray.h> #include <QtCore/qmetatype.h> #if !defined(Q_MOC_OUTPUT_REVISION) #error "The header file 'objecttreeinspector.h' doesn't include <QObject>." #elif Q_MOC_OUTPUT_REVISION != 67 #error "This file was generated using the moc from 5.5.1. It" #error "cannot be used with the include files from this version of Qt." #error "(The moc has changed too much.)" #endif QT_BEGIN_MOC_NAMESPACE struct qt_meta_stringdata_omnetpp__qtenv__ObjectTreeInspector_t { QByteArrayData data[7]; char stringdata0[87]; }; #define QT_MOC_LITERAL(idx, ofs, len) \ Q_STATIC_BYTE_ARRAY_DATA_HEADER_INITIALIZER_WITH_OFFSET(len, \ qptrdiff(offsetof(qt_meta_stringdata_omnetpp__qtenv__ObjectTreeInspector_t, stringdata0) + ofs \ - idx * sizeof(QByteArrayData)) \ ) static const qt_meta_stringdata_omnetpp__qtenv__ObjectTreeInspector_t qt_meta_stringdata_omnetpp__qtenv__ObjectTreeInspector = { { QT_MOC_LITERAL(0, 0, 35), // "omnetpp::qtenv::ObjectTreeIns..." QT_MOC_LITERAL(1, 36, 7), // "onClick" QT_MOC_LITERAL(2, 44, 0), // "" QT_MOC_LITERAL(3, 45, 5), // "index" QT_MOC_LITERAL(4, 51, 13), // "onDoubleClick" QT_MOC_LITERAL(5, 65, 17), // "createContextMenu" QT_MOC_LITERAL(6, 83, 3) // "pos" }, "omnetpp::qtenv::ObjectTreeInspector\0" "onClick\0\0index\0onDoubleClick\0" "createContextMenu\0pos" }; #undef QT_MOC_LITERAL static const uint qt_meta_data_omnetpp__qtenv__ObjectTreeInspector[] = { // content: 7, // revision 0, // classname 0, 0, // classinfo 3, 14, // methods 0, 0, // properties 0, 0, // enums/sets 0, 0, // constructors 0, // flags 0, // signalCount // slots: name, argc, parameters, tag, flags 1, 1, 29, 2, 0x08 /* Private */, 4, 1, 32, 2, 0x08 /* Private */, 5, 1, 35, 2, 0x0a /* Public */, // slots: parameters QMetaType::Void, QMetaType::QModelIndex, 3, QMetaType::Void, QMetaType::QModelIndex, 3, QMetaType::Void, QMetaType::QPoint, 6, 0 // eod }; void omnetpp::qtenv::ObjectTreeInspector::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id, void **_a) { if (_c == QMetaObject::InvokeMetaMethod) { ObjectTreeInspector *_t = static_cast<ObjectTreeInspector *>(_o); Q_UNUSED(_t) switch (_id) { case 0: _t->onClick((*reinterpret_cast< QModelIndex(*)>(_a[1]))); break; case 1: _t->onDoubleClick((*reinterpret_cast< QModelIndex(*)>(_a[1]))); break; case 2: _t->createContextMenu((*reinterpret_cast< QPoint(*)>(_a[1]))); break; default: ; } } } const QMetaObject omnetpp::qtenv::ObjectTreeInspector::staticMetaObject = { { &Inspector::staticMetaObject, qt_meta_stringdata_omnetpp__qtenv__ObjectTreeInspector.data, qt_meta_data_omnetpp__qtenv__ObjectTreeInspector, qt_static_metacall, Q_NULLPTR, Q_NULLPTR} }; const QMetaObject *omnetpp::qtenv::ObjectTreeInspector::metaObject() const { return QObject::d_ptr->metaObject ? QObject::d_ptr->dynamicMetaObject() : &staticMetaObject; } void *omnetpp::qtenv::ObjectTreeInspector::qt_metacast(const char *_clname) { if (!_clname) return Q_NULLPTR; if (!strcmp(_clname, qt_meta_stringdata_omnetpp__qtenv__ObjectTreeInspector.stringdata0)) return static_cast<void*>(const_cast< ObjectTreeInspector*>(this)); return Inspector::qt_metacast(_clname); } int omnetpp::qtenv::ObjectTreeInspector::qt_metacall(QMetaObject::Call _c, int _id, void **_a) { _id = Inspector::qt_metacall(_c, _id, _a); if (_id < 0) return _id; if (_c == QMetaObject::InvokeMetaMethod) { if (_id < 3) qt_static_metacall(this, _c, _id, _a); _id -= 3; } else if (_c == QMetaObject::RegisterMethodArgumentMetaType) { if (_id < 3) *reinterpret_cast<int*>(_a[0]) = -1; _id -= 3; } return _id; } QT_END_MOC_NAMESPACE
[ "kevinodonovan970@gmail.com" ]
kevinodonovan970@gmail.com
dc11333f45177a12ca6406ae9a10295cbae70d34
6f3801a334461219be84b4d21aa8e8bf99c5401d
/coctree/main.cpp
a379277187cb5749d9caf1476984957937e4af71
[]
no_license
robert00700/Kinect-Scanner
e95d8db773ecb0ed70060cd49537a227d68bfee8
0a71e72b73ed3b3c72a6fd8305dd1a0c8235ecb8
refs/heads/master
2016-09-10T03:30:46.477555
2012-01-28T10:22:35
2012-01-28T10:22:35
2,569,610
0
0
null
null
null
null
UTF-8
C++
false
false
558
cpp
#import <iostream> #import "ScanTypes.h" #include "Coctree.h" #include <vector> #include <pcl/io/pcd_io.h> #define log(X) std::cout << X << std::endl; int main(int argc, char ** argv) { if(argc != 2) { log("Usage: coctreetest [filename]"); return 1; } else { std::string file(argv[1]); pcl::PCDReader read; PointCloud cloud; if(!read.read(file, cloud)) { PointCloud cloud2; Coctree t(0.25, 0.4, cloud); log(t.searchClosestIndex(cloud[0], 0.001)); //log(out[0]); } else { log("Read error"); return 1; } } }
[ "rob@rob-desktop.(none)" ]
rob@rob-desktop.(none)
514512cdb37b24174c1ba6a60984b88f9f570aa2
2c735496a6d67a6cdec85b31fb78ae489cf16fbb
/BCPNN/backend/full_cuda_backend/helpers_cuda.h
cfbeb43eeab662392a89563df8f5419f3776c414
[ "BSD-2-Clause", "LicenseRef-scancode-unknown-license-reference", "BSD-2-Clause-Views" ]
permissive
chris4540/StreamBrain
2cb1eb64768d163393d2d4a530b8215244532ace
cf75e328f7ebb24da8c780b33b1dc6cb76edf2bc
refs/heads/master
2022-11-14T09:48:24.397751
2020-07-09T17:00:14
2020-07-09T17:00:14
null
0
0
null
null
null
null
UTF-8
C++
false
false
3,995
h
#pragma once #include <cuda.h> #include <cublas_v2.h> #include <curand.h> #define CUDA_CALL(x) do { if((x)!=cudaSuccess) { \ printf("Error at %s:%d\n",__FILE__,__LINE__);\ exit(EXIT_FAILURE);}} while(0) #define CURAND_CALL(x) do { if((x)!=CURAND_STATUS_SUCCESS) { \ printf("Error at %s:%d\n",__FILE__,__LINE__);\ exit(EXIT_FAILURE);}} while(0) #define CUBLAS_CALL(x) do { if((x)!=CUBLAS_STATUS_SUCCESS) { \ printf("Error at %s:%d\n",__FILE__,__LINE__);\ exit(EXIT_FAILURE);}} while(0) namespace bcpnn { namespace helpers { namespace cuda { template<typename REAL> cublasStatus_t cublasgemm( cublasHandle_t handle, cublasOperation_t transa, cublasOperation_t transb, int m, int n, int k, const REAL *alpha, const REAL *A, int lda, const REAL *B, int ldb, const REAL *beta, REAL *C, int ldc ) { } template<> cublasStatus_t cublasgemm<float>( cublasHandle_t handle, cublasOperation_t transa, cublasOperation_t transb, int m, int n, int k, const float *alpha, const float *A, int lda, const float *B, int ldb, const float *beta, float *C, int ldc ); template<> cublasStatus_t cublasgemm<double>( cublasHandle_t handle, cublasOperation_t transa, cublasOperation_t transb, int m, int n, int k, const double *alpha, const double *A, int lda, const double *B, int ldb, const double *beta, double *C, int ldc ); template<typename T> curandStatus_t CURANDAPI TcurandGenerateUniform(curandGenerator_t generator,T* outputPtr, size_t num) {} template<> curandStatus_t CURANDAPI TcurandGenerateUniform<float>(curandGenerator_t generator, float* outputPtr, size_t num); template<> curandStatus_t CURANDAPI TcurandGenerateUniform<double>(curandGenerator_t generator, double* outputPtr, size_t num); template<typename T> curandStatus_t CURANDAPI TcurandGenerateNormal( curandGenerator_t generator, T* outputPtr, size_t n, T mean, T stddev ) {} template<> curandStatus_t CURANDAPI TcurandGenerateNormal<float>( curandGenerator_t generator, float* outputPtr, size_t n, float mean, float stddev ); template<> curandStatus_t CURANDAPI TcurandGenerateNormal<double>( curandGenerator_t generator, double* outputPtr, size_t n, double mean, double stddev ); template<typename REAL> __global__ void kernel_initialize(REAL * p, REAL value, size_t n) { size_t i = blockDim.x * blockIdx.x + threadIdx.x; if (i < n) { p[i] = value; } } template<typename REAL> void cuda_initialize_array(REAL * p, REAL value, size_t n) { kernel_initialize<<<(n + 256 - 1)/256, 256>>>(p, value, n); } template<typename REAL> __global__ void kernel_scale_array(REAL * p, REAL factor, size_t n) { size_t i = blockDim.x * blockIdx.x + threadIdx.x; if (i < n) { p[i] *= factor; } } template<typename REAL> void cuda_scale_array(REAL * p, REAL factor, size_t n) { kernel_scale_array<<<(n + 256 - 1)/256, 256>>>(p, factor, n); } template<typename REAL> __global__ void kernel_correct_predictions(int * correct_count, REAL * predictions, REAL * one_hot_labels, size_t n, size_t m) { int correct = 0; for (size_t i = blockDim.x * blockIdx.x + threadIdx.x; i < n; i += gridDim.x * blockDim.x) { size_t jmax = 0; REAL vmax = predictions[i * m + 0]; for (size_t j = 1; j < m; ++j) { if (predictions[i * m + j] > vmax) { jmax = j; vmax = predictions[i * m + j]; } } if (one_hot_labels[i * m + jmax] > 0.5) { // if (one_hot_labels[i * m + jmax] == 1) { correct += 1; } } for (size_t d = 16; d > 0; d /= 2) { correct += __shfl_down_sync(~0, correct, d); } if (threadIdx.x % 32 == 0) { atomicAdd(correct_count, correct); } } template<typename REAL> void cuda_correct_predictions(int * correct_count, REAL * predictions, REAL * one_hot_labels, size_t n, size_t m) { kernel_correct_predictions<<<(n + 64 - 1)/64, 64>>>(correct_count, predictions, one_hot_labels, n, m); } } // namespace cuda } // namespace helpers } // namespace bcpnn
[ "wdchien@kth.se" ]
wdchien@kth.se
28f8f8da10fcc93e67c20e3f1e57d513a26f482d
60bd79d18cf69c133abcb6b0d8b0a959f61b4d10
/libraries/ML8511/examples/ML8511_minimal/ML8511_minimal.ino
a235029e7ac716515918ef3bd3541585f82b7b17
[ "MIT" ]
permissive
RobTillaart/Arduino
e75ae38fa6f043f1213c4c7adb310e91da59e4ba
48a7d9ec884e54fcc7323e340407e82fcc08ea3d
refs/heads/master
2023-09-01T03:32:38.474045
2023-08-31T20:07:39
2023-08-31T20:07:39
2,544,179
1,406
3,798
MIT
2022-10-27T08:28:51
2011-10-09T19:53:59
C++
UTF-8
C++
false
false
784
ino
// // FILE: ML8511_minimal.ino // AUTHOR: Rob Tillaart // PURPOSE: demo UV sensor // DATE: 2020-02-17 // URL: https://github.com/RobTillaart/ML8511 // // BREAKOUT // +-------+--+ // VIN |o +-+| mounting hole // 3V3 |o +-+| // GND |o | // OUT |o | // EN |o S | Sensor // +----------+ // EN = ENABLE #include <Arduino.h> #include <ML8511.h> #define ANALOGPIN A0 // Connect EN to 3V3 to explicitly // enable the sensor continuously ML8511 light(ANALOGPIN); void setup() { Serial.begin(115200); Serial.println(__FILE__); Serial.println("UV UltraViolet ML8511"); } void loop() { float UV = light.getUV(); Serial.print(UV, 4); Serial.println(" mW cm^2"); delay(1000); } // -- END OF FILE --
[ "rob.tillaart@gmail.com" ]
rob.tillaart@gmail.com
1f0b0010496b6813cb539cb9b8956c27f291684c
5de4c4471ef8513ddbffe2d8b588ce42fbb9f8d9
/Matrix/q2.cpp
413d73792f367caa6522b1bd07279dae11ad7f3b
[]
no_license
ayushgarg2702/CompitativePrograming
e89a608b08627fef5a31be3294cbf01fe5d3c831
a6ad5f4b56b8bbb9e3efe1d1cfcf567c5958de33
refs/heads/master
2023-07-08T21:00:14.503515
2021-08-19T19:16:22
2021-08-19T19:16:22
391,043,787
0
0
null
null
null
null
UTF-8
C++
false
false
1,150
cpp
// Search in sorted 2d array #include<bits/stdc++.h> using namespace std; int binarysearch(int arr[], int size, int search, int left, int right){ int mid = left + (right - left) / 2; if (right <= left){ return -1; } if( arr[mid] == search){ return mid; } if( arr[mid] < search){ return binarysearch(arr,size,search,mid+1,right); } else{ return binarysearch(arr,size,search,left,mid); } } int Search(int arr[], int size, int element){ int value = binarysearch(arr,size,element,0,size); if ( value < size && value >= 0){ return value; } return -1; } int main(){ int arr[][4] = {{1,2,3,7},{9,11,15,16},{21,22,25,26},{30,34,35,38}}; int l = sizeof(arr[0])/sizeof(int); int h = sizeof(arr) / (l * sizeof(int)); int L = -1; int search = 38; int i = 0; for(i = 0; i < h; i++){ if ( arr[i][0] <= search && arr[i][l-1] >= search ){ L = Search(arr[i], l, search); break; } } if ( L == -1){ cout<< "Not found"; } else{ cout<< "Found "<<i+1 << " " <<L + 1; } }
[ "ayush.garg1@celebaltech.com" ]
ayush.garg1@celebaltech.com
2a8c3061ee18952facbd06951ec2afec0f58fd19
7031de2fe4430dedb0ae42de9c22207c64b2b8d9
/Assignment2/stephen1/ast.h
de9977face938d9c4702774a8bcfd65a4fedaaad
[]
no_license
skrapmi/CPSC-323
e840298c4f774b26b5aed852c1a55cf95824c430
8160bcb7479a9f419847b2a86294038d9b4d2a46
refs/heads/master
2020-12-02T11:23:42.319495
2017-08-04T23:02:46
2017-08-04T23:02:46
96,634,596
0
0
null
null
null
null
UTF-8
C++
false
false
1,141
h
#ifndef AST_H_ #define AST_H_ #include <list> #include <map> class JsonValue { public: virtual void Print() = 0; }; class JsonObject : public JsonValue { private: std::map<std::string, JsonValue*> pairs; public: virtual void Print(); void Add(std::string name, JsonValue* value); }; class JsonArray : public JsonValue { private: std::list<JsonValue*> values; public: virtual void Print(); void Add(JsonValue *v); }; class JsonString : public JsonValue { private: std::string value; public: JsonString(std::string s) : value(s) { }; virtual void Print(); }; class JsonNumber : public JsonValue { private: double value; public: JsonNumber(double d) : value(d) { }; virtual void Print(); }; class JsonBoolean : public JsonValue { private: bool value; public: JsonBoolean(bool b) : value(b) { }; virtual void Print(); }; class JsonNull : public JsonValue { public: virtual void Print(); }; //void Print() : public JsonValue{}; #endif // AST_H_
[ "stephencordasco@gmail.com" ]
stephencordasco@gmail.com
8f5603de2cfb9a6b4e6010771f392018aac15e71
5c864308b0510c13e51b538ba0855985b76f2023
/ComputerVisionThesisSolution/ScenceSimulateProj/Core/SanString.cpp
12333e654f0fe821c443cdc638621af0c3fdd532
[ "MIT" ]
permissive
zxyinz/ComputerVisionThesis
f660aaa57333d820164c848fb12995e793252177
081cadc6b9d2b05bd42f0ff0ba9d084c1da4faa2
refs/heads/master
2020-06-04T17:15:42.698161
2015-10-14T05:34:26
2015-10-14T05:34:26
34,825,050
0
0
null
null
null
null
UTF-8
C++
false
false
8,719
cpp
#include"SanString.h" using namespace std; using namespace San; swchar San::gloAToW(const sachar Data) { return gloAToW((const sachar*)&Data,1)[0]; } wstring San::gloAToW(const SStringA &strString) { return ::gloAToW(strString.c_str(),strString.length()); } wstring San::gloAToW(const sachar* pString,int StringLength) { wstring strDestString; if (StringLength == -1) { StringLength = ::MultiByteToWideChar(CP_ACP, 0, pString, -1, nullptr, 0); } if(StringLength==0) { return strDestString; } swchar *pBuffer = new swchar[StringLength + 1]; ::gloMemSet(pBuffer, 0, sizeof(pBuffer)); ::MultiByteToWideChar(CP_ACP, 0, pString, -1, pBuffer, StringLength + 1); strDestString=pBuffer; delete[] pBuffer; pBuffer=nullptr; return strDestString; } sachar San::gloWToA(const swchar Data,const sachar DefaultChar) { return gloWToA((const swchar*)&Data,1,DefaultChar)[0]; } string San::gloWToA(const SStringW &strString,const sachar DefaultChar) { return ::gloWToA(strString.c_str(),strString.length(),DefaultChar); } string San::gloWToA(const swchar* pString,int StringLength,const sachar DefaultChar) { string strDestString; int bUseDefaultChar=true; if (StringLength == -1) { StringLength = ::WideCharToMultiByte(CP_ACP, 0, pString, -1, nullptr, 0, &DefaultChar, &bUseDefaultChar); } if(StringLength==0) { return strDestString; } sachar *pBuffer = new sachar[StringLength + 1]; ::gloMemSet(pBuffer,0,sizeof(pBuffer)); ::WideCharToMultiByte(CP_ACP, 0, pString, -1, pBuffer, StringLength + 1, &DefaultChar, &bUseDefaultChar); strDestString=pBuffer; delete[] pBuffer; pBuffer=nullptr; return strDestString; } schar San::gloAToT(const sachar Data) { #ifndef _UNICODE return Data; #else return gloAToW((const sachar*)&Data,1)[0]; #endif } SString San::gloAToT(const SStringA &strString) { #ifndef _UNICODE return strString; #else return gloAToW(strString.c_str(),strString.length()); #endif } SString San::gloAToT(const sachar* pString,int StringLength) { #ifndef _UNICODE return pString; #else return gloAToW(pString,StringLength); #endif } schar San::gloWToT(const swchar Data,const sachar DefaultChar) { #ifndef _UNICODE return gloWToA((const swchar*)&Data,1,DefaultChar)[0]; #else return Data; #endif } SString San::gloWToT(const SStringW &strString,const sachar DefaultChar) { #ifndef _UNICODE return gloWToA(strString.c_str(),strString.length(),DefaultChar); #else return strString; #endif } SString San::gloWToT(const swchar* pString,int StringLength,const sachar DefaultChar) { #ifndef _UNICODE return gloWToA(pString,StringLength,DefaultChar); #else return pString; #endif } sachar San::gloTToA(const schar Data,const sachar DefaultChar) { #ifndef _UNICODE return Data; #else return gloWToA((const schar*)Data,1,DefaultChar)[0]; #endif } string San::gloTToA(const SString &strString,const sachar DefaultChar) { #ifndef _UNICODE return strString; #else return ::gloWToA(strString.c_str(),strString.length(),DefaultChar); #endif } string San::gloTToA(const schar* pString,int StringLength,const sachar DefaultChar) { #ifndef _UNICODE return pString; #else return ::gloWToA(pString,StringLength,DefaultChar); #endif } swchar San::gloTToW(const schar Data) { #ifndef _UNICODE return gloAToW((const schar*)&Data,1)[0]; #else return Data; #endif } wstring San::gloTToW(const SString &strString) { #ifndef _UNICODE return gloAToW(strString.c_str(),strString.length()); #else return strString; #endif } wstring San::gloTToW(const schar* pString,int StringLength) { #ifndef _UNICODE return gloAToW(pString,StringLength); #else return pString; #endif } bool San::operator==(const SStringA &strStringA,const SStringA &strStringB) { return (((int)strStringA.find(strStringB.c_str()))==0&&(strStringA.size()==strStringB.size())); } bool San::operator!=(const SStringA &strStringA,const SStringA &strStringB) { return !(((int)strStringA.find(strStringB.c_str())==0)&&(strStringA.size()==strStringB.size())); } SStringA San::operator+(const SStringA &strStringA,const SStringA &strStringB) { sachar *pschar=nullptr; size_t Size=strStringA.size()+strStringB.size(); if(Size==0) { pschar=new sachar[1]; pschar[0]='\0'; } else { pschar=new sachar[Size+1]; unsigned int StrASize=strStringA.size(); for(size_t seeka=0;seeka<StrASize;seeka=seeka+1) { pschar[seeka]=strStringA[seeka]; } for(size_t seekb=0;seekb<strStringB.size();seekb=seekb+1) { pschar[seekb+StrASize]=strStringB[seekb]; } pschar[Size]='\0'; } SStringA strDestString=pschar; delete[] pschar; return strDestString; } bool San::operator==(const SStringW &strStringA,const SStringW &strStringB) { return (((int)strStringA.find(strStringB.c_str())==0)&&(strStringA.size()==strStringB.size())); } bool San::operator!=(const SStringW &strStringA,const SStringW &strStringB) { int Index=strStringA.find(strStringB.c_str()); return !(((int)strStringA.find(strStringB.c_str())==0)&&(strStringA.size()==strStringB.size())); } SStringW San::operator+(const SStringW &strStringA,const SStringW &strStringB) { swchar *pschar=nullptr; size_t Size=strStringA.size()+strStringB.size(); if(Size==0) { pschar=new swchar[1]; pschar[0]=L'\0'; } else { pschar=new swchar[Size+1]; unsigned int StrASize=strStringA.size(); for(size_t seeka=0;seeka<StrASize;seeka=seeka+1) { pschar[seeka]=strStringA[seeka]; } for(size_t seekb=0;seekb<strStringB.size();seekb=seekb+1) { pschar[seekb+StrASize]=strStringB[seekb]; } pschar[Size]=L'\0'; } SStringW strDestString=pschar; delete[] pschar; return strDestString; } SString San::gloIToS(const long long &Data, const unsigned int Radix) { schar String[512]; #ifndef _UNICODE ::_itoa(Data, String, Radix); #else ::_itow(Data, String, Radix); #endif return String; } long long San::gloSToI(const SString &strString, const unsigned int Radix) { switch (Radix) { case 2: { long long Data = 0; for (unsigned int seek = 0; seek < strString.size(); seek = seek + 1) { if (strString[seek] == _SSTR('0')) { Data = Data << 1; continue; } if (strString[seek] == _SSTR('1')) { Data = Data << 1 + 1; continue; } Data = 0; return Data; } return Data; } break; case 10: #ifndef _UNICODE return ::atoi(strString.c_str()); #else return ::_wtoi(strString.c_str()); #endif break; case 16: { long long Data; std::stringstream strStream; strStream << std::hex << strString.c_str(); strStream >> Data; return Data; } break; default: return 0; break; } return 0; } SString San::gloFToS(const double &Data, SString strFormat) { schar string[512]; strFormat = _SSTR("%") + strFormat + _SSTR("f"); #ifndef _UNICODE ::sprintf_s(string, 128, strFormat.c_str(), Data); #else ::swprintf_s(string, 128, strFormat.c_str(), Data); #endif return string; } double San::gloSToF(const SString &strString) { #ifndef _UNICODE return ::atof(strString.c_str()); #else return ::_wtof(strString.c_str()); #endif } vector<SStringA> San::gloGetStringItemsA(const SStringA &strString, SStringA strStringMark) { vector<SStringA> SubStringList; SubStringList.clear(); if (strString.empty()) { return SubStringList; } if (strStringMark.empty()) { strStringMark = " \n\t"; } SStringA strTarget = strString + strStringMark[0]; size_t StrLength = strTarget.length(); size_t MarkSize = strStringMark.length(); size_t SubStringBegin = 0; for (size_t seek = 0; seek < StrLength; seek = seek + 1) { for (size_t seek_mark = 0; seek_mark < MarkSize; seek_mark = seek_mark + 1) { if (strTarget[seek] == strStringMark[seek_mark]) { if (seek != SubStringBegin) { SubStringList.insert(SubStringList.end(), strTarget.substr(SubStringBegin, seek - SubStringBegin)); } SubStringBegin = seek + 1; continue; } } } return SubStringList; } vector<SStringW> San::gloGetStringItemsW(const SStringW &strString, SStringW strStringMark) { vector<SStringW> SubStringList; SubStringList.clear(); if (strString.empty()) { return SubStringList; } if (strStringMark.empty()) { strStringMark = L" \n\t"; } SStringW strTarget = strString + strStringMark[0]; size_t StrLength = strTarget.length(); size_t MarkSize = strStringMark.length(); size_t SubStringBegin = 0; for (size_t seek = 0; seek < StrLength; seek = seek + 1) { for (size_t seek_mark = 0; seek_mark < MarkSize; seek_mark = seek_mark + 1) { if (strTarget[seek] == strStringMark[seek_mark]) { if (seek != SubStringBegin) { SubStringList.insert(SubStringList.end(), strTarget.substr(SubStringBegin, seek - SubStringBegin)); } SubStringBegin = seek + 1; continue; } } } return SubStringList; }
[ "zxyinz@gmail.com" ]
zxyinz@gmail.com
a3a679186b823bcf19c40f0ace193f467bf72e25
dde319d3e542b189b4f2f443de0e32e76fcafeea
/ivutils/include/cvector_3.h
25bc5ee05a307e73a3111c91661d056b0e8ff4c2
[ "MIT" ]
permissive
deinega/microvolt
9990b3060ff1a579ff798db11b9ee94ce9d6c058
dfce0297966c18242922751b696ba36bf62448ce
refs/heads/master
2021-01-19T18:36:52.132557
2017-04-15T20:19:41
2017-04-15T20:19:41
88,371,125
0
1
null
null
null
null
UTF-8
C++
false
false
4,744
h
# ifndef __CVECTOR_3_H # define __CVECTOR_3_H /// \en @file vector_3.h \brief complex N-dimensional vectors and some vector operations. # include "vector_3.h" # include <complex> using namespace std; typedef complex<vec_type> cvec_type; ///\en complex N-dimensional vector of type T with some useful operations template <class T, size_t N> struct cVector_Nt { typedef Vector_Nt<T,N> vector_t; typedef complex<T> ctype; vector_t V[2]; cVector_Nt(const vector_t &re=vector_t(), const vector_t &im=vector_t()) { V[0]=re; V[1]=im; } inline vector_t& re() { return this->V[0]; } inline vector_t& im() { return this->V[1]; } inline vector_t& real() { return this->V[0]; } inline vector_t& imag() { return this->V[1]; } inline const vector_t& real() const { return this->V[0]; } inline const vector_t& imag() const { return this->V[1]; } inline vector_t mod() const { vector_t v; for(int i=0;i<N;i++) v[i]=sqrt(V[0][i]*V[0][i]+V[1][i]*V[1][i]); return v; } inline cVector_Nt conj() const { return cVector_Nt(V[0],-V[1]); } inline ctype operator[](int i) const { return ctype(V[0][i],V[1][i]); } inline void set(int i, const ctype &val){ V[0][i]=val.real(); V[1][i]=val.imag(); } inline int operator==(const cVector_Nt &cvect) const{ return (V[0]==cvect.V[0] && V[1]==cvect.V[1]); } inline int operator!=(const cVector_Nt &cvect) const{ return (!(*this==cvect)); } inline cVector_Nt operator+(const cVector_Nt& cvect) const{ return cVector_Nt(V[0]+cvect.V[0], V[1]+cvect.V[1]); } inline cVector_Nt operator-(const cVector_Nt &cvect) const { return cVector_Nt(V[0]-cvect.V[0], V[1]-cvect.V[1]); } inline cVector_Nt& operator+=(const cVector_Nt &cvect){ V[0]+=cvect.V[0]; V[1]+=cvect.V[1]; return *this; } inline ctype operator*(const cVector_Nt &cvect) const { return ctype(V[0]*cvect.V[0]-V[1]*cvect.V[1], V[0]*cvect.V[1]+V[1]*cvect.V[0]); } inline cVector_Nt operator %(const cVector_Nt &cvect) const{ return cVector_Nt(V[0]%cvect.V[0]-V[1]%cvect.V[1], V[0]%cvect.V[1]+V[1]%cvect.V[0]); } inline cVector_Nt operator %(const vector_t &vect) const{ return cVector_Nt(V[0]%vect, V[1]%vect); } inline cVector_Nt operator*(const T &coeff) const { return cVector_Nt(V[0]*coeff, V[1]*coeff); } inline cVector_Nt operator*(const ctype &coeff) const { return cVector_Nt(V[0]*coeff.real() - V[1]*coeff.imag(), V[1]*coeff.real() + V[0]*coeff.imag()); } inline cVector_Nt operator/(const ctype &coeff) const { return operator* (1./coeff); } inline cVector_Nt operator/(const T &coeff){ return cVector_Nt(V[0]/coeff, V[1]/coeff); } inline cVector_Nt operator-(){ return cVector_Nt(-V[0], -V[1]); } inline cVector_Nt& operator*=(const T &coeff){ V[0]*=coeff; V[1]*=coeff; return *this; } inline cVector_Nt& operator*=(const ctype &coeff){ *this=operator *(coeff); return *this; } T norm2() const{ return V[0].norm2()+V[1].norm2(); } T norm() const { return sqrt(norm2()); } T normalize() { T norm=this->norm(); if(norm>=VEC_ZERO){ V[0]/=norm; V[1]/=norm; } return norm; } ctype cnorm2() const{ ctype result=0; for (int i=0; i<3; i++){ ctype val=ctype(V[0][i],V[1][i]); result+=val*val; } return result; } ctype cnorm() const { return sqrt(cnorm2()); } ctype cnormalize() { ctype cnorm=this->cnorm(); T norm=this->norm(); if(cnorm.real()>=VEC_ZERO || cnorm.imag()>=VEC_ZERO){ for (int i=0; i<3; i++){ ctype val=cvec_type(V[0][i],V[1][i]); val/=cnorm; V[0][i]=val.real(); V[1][i]=val.imag(); } } ctype ctest=this->cnorm(); T test=this->norm(); return cnorm; } }; template<class T, size_t N> cVector_Nt<T, N> operator*(const T &coeff,const cVector_Nt<T, N> &vec){ return vec*coeff; } template<class T, class T2, size_t N> cVector_Nt<T, N> operator*(const T2 &coeff,const cVector_Nt<T, N> &vec){ return vec*coeff; } template<class T, size_t N> cVector_Nt<T, N> conj(const cVector_Nt<T, N> &vec){ return vec.conj(); } typedef cVector_Nt<vec_type, 3> cVector_3; template<class T, int N> Vector_Nt<T, N> real_value(const cVector_Nt<T, N> &a){ return a.real(); } template<class T, int N> struct real_t<const cVector_Nt<T, N> >{ typedef Vector_Nt<T, N> data; }; # endif
[ "poblizosti@mail.ru" ]
poblizosti@mail.ru
65a91f7ce8d56ea75370edcbc55cf85f7ca924c4
e173e8fd6d50f0c3191c9395a8c342516f651ebd
/include/Tools/Algo/Bit_packer.hxx
2976006da9d8e2519aa49b2fa38d64068ec67f8a
[ "MIT" ]
permissive
aff3ct/aff3ct
e11e0ac440b96849f73348dc6fb4a15611f807ec
8fa65a3ca9b0dcdd3d544363bc692d4f85f6f718
refs/heads/master
2023-07-19T06:59:41.908384
2022-04-21T08:34:08
2022-04-21T08:34:08
60,615,913
417
150
MIT
2022-09-14T11:09:54
2016-06-07T13:37:47
C++
UTF-8
C++
false
false
12,653
hxx
#ifndef _USE_MATH_DEFINES #define _USE_MATH_DEFINES #endif #include <algorithm> #include <sstream> #include <cmath> #include "Tools/Exception/exception.hpp" #include "Tools/Algo/Bit_packer.hpp" namespace aff3ct { namespace tools { template <typename B, class AB, typename S, class AS> void Bit_packer ::pack(const std::vector<B,AB> &vec_in, std::vector<S,AS> &vec_out, const int n_frames, const bool msb_to_lsb, const bool pack_per_byte, const int Nbps) { if (n_frames <= 0) { std::stringstream message; message << "'n_frames' has to be greater than 0 ('n_frames' = " << n_frames << ")."; throw invalid_argument(__FILE__, __LINE__, __func__, message.str()); } if (vec_in.size() % n_frames) { std::stringstream message; message << "'vec_in.size()' has to be divisible by 'n_frames' ('vec_in.size()' = " << vec_in.size() << ", 'n_frames' = " << n_frames << ")."; throw length_error(__FILE__, __LINE__, __func__, message.str()); } if (pack_per_byte) { if ((vec_out.size() * sizeof(S) * Nbps) < vec_in.size()) { std::stringstream message; message << "'vec_out.size()' has to be equal or greater than ('vec_in.size()' / 'sizeof(S)' / 'Nbps') " << "('vec_out.size()' = " << vec_out.size() << ", 'vec_in.size()' = " << vec_in.size() << ", 'sizeof(S)' = " << sizeof(S) << ", 'Nbps' = " << Nbps << ")."; throw length_error(__FILE__, __LINE__, __func__, message.str()); } Bit_packer::pack(vec_in.data(), (unsigned char*)vec_out.data(), (int)(vec_in.size() / n_frames), n_frames, msb_to_lsb, Nbps); } else { if ((vec_out.size() * Nbps) < vec_in.size()) { std::stringstream message; message << "'vec_out.size()' has to be equal or greater than ('vec_in.size()' / 'Nbps') " << "('vec_out.size()' = " << vec_out.size() << ", 'vec_in.size()' = " << vec_in.size() << ", 'Nbps' = " << Nbps << ")."; throw length_error(__FILE__, __LINE__, __func__, message.str()); } Bit_packer::pack(vec_in.data(), vec_out.data(), (int)(vec_in.size() / n_frames), n_frames, msb_to_lsb, Nbps); } } template <typename B, typename S> void Bit_packer ::pack(const B *vec_in, S *vec_out, const int n_bits_per_frame, const int n_frames, const bool msb_to_lsb, const int Nbps) { if (Nbps > (int)(sizeof(S) * CHAR_BIT) || Nbps <= 0) { std::stringstream message; message << "'Nbps' must be between 1 and (sizeof(S) * CHAR_BIT). ('Nbps' = " << Nbps << ", 'sizeof(S)' = " << sizeof(S) << ", 'CHAR_BIT' = " << CHAR_BIT << ")."; throw invalid_argument(__FILE__, __LINE__, __func__, message.str()); } const auto n_symbols_per_frame = static_cast<int>(std::ceil((float)n_bits_per_frame / Nbps)); for (auto f = 0; f < n_frames; f++) Bit_packer::_pack(vec_in + f * n_bits_per_frame, vec_out + f * n_symbols_per_frame, n_bits_per_frame, msb_to_lsb, Nbps); } template <typename B, class AB> void Bit_packer ::pack(std::vector<B,AB> &vec, const int n_frames, const bool msb_to_lsb, const int Nbps) { if (n_frames <= 0) { std::stringstream message; message << "'n_frames' has to be greater than 0 ('n_frames' = " << n_frames << ")."; throw invalid_argument(__FILE__, __LINE__, __func__, message.str()); } if (vec.size() % n_frames) { std::stringstream message; message << "'vec.size()' has to be divisible by 'n_frames' ('vec.size()' = " << vec.size() << ", 'n_frames' = " << n_frames << ")."; throw length_error(__FILE__, __LINE__, __func__, message.str()); } Bit_packer::pack(vec.data(), (int)(vec.size() / n_frames), n_frames, msb_to_lsb, Nbps); } template <typename B> void Bit_packer ::pack(B *vec, const int n_bits_per_frame, const int n_frames, const bool msb_to_lsb, const int Nbps) { if (Nbps > (int)CHAR_BIT || Nbps <= 0) { std::stringstream message; message << "'Nbps' must be between 1 and CHAR_BIT. ('Nbps' = " << Nbps << ")."; throw invalid_argument(__FILE__, __LINE__, __func__, message.str()); } const auto n_symbs_per_frame = static_cast<int>(std::ceil((float)n_bits_per_frame / Nbps)); unsigned char* symbs_out = (unsigned char*)vec; for (auto f = 0; f < n_frames; f++) Bit_packer::_pack(vec + f * n_bits_per_frame, symbs_out + f * n_symbs_per_frame, n_bits_per_frame, msb_to_lsb, Nbps); } template <typename B, class AB, typename S, class AS> void Bit_packer ::unpack(const std::vector<S,AS> &vec_in, std::vector<B,AB> &vec_out, const int n_frames, const bool msb_to_lsb, const bool unpack_per_byte, const int Nbps) { if (n_frames <= 0) { std::stringstream message; message << "'n_frames' has to be greater than 0 ('n_frames' = " << n_frames << ")."; throw invalid_argument(__FILE__, __LINE__, __func__, message.str()); } if (vec_out.size() % n_frames) { std::stringstream message; message << "'vec_out.size()' has to be divisible by 'n_frames' ('vec_out.size()' = " << vec_out.size() << ", 'n_frames' = " << n_frames << ")."; throw length_error(__FILE__, __LINE__, __func__, message.str()); } if (unpack_per_byte) { if ((vec_in.size() * sizeof(B) * Nbps) < vec_out.size()) { std::stringstream message; message << "('vec_in.size()' * 'sizeof(B)' * 'Nbps') has to be equal or greater than 'vec_out.size()' " << "('vec_in.size()' = " << vec_in.size() << ", 'vec_out.size()' = " << vec_out.size() << ", 'sizeof(B)' = " << sizeof(B) << ", 'Nbps' = " << Nbps << ")."; throw length_error(__FILE__, __LINE__, __func__, message.str()); } Bit_packer::unpack((unsigned char*)vec_in.data(), vec_out.data(), (int)(vec_out.size() / n_frames), n_frames, msb_to_lsb, Nbps); } else { if ((vec_in.size() * Nbps) < vec_out.size()) { std::stringstream message; message << "('vec_in.size()' * 'Nbps') has to be equal or greater than 'vec_out.size()' " << "('vec_in.size()' = " << vec_in.size() << ", 'vec_out.size()' = " << vec_out.size() << ", 'Nbps' = " << Nbps << ")."; throw length_error(__FILE__, __LINE__, __func__, message.str()); } Bit_packer::unpack(vec_in.data(), vec_out.data(), (int)(vec_out.size() / n_frames), n_frames, msb_to_lsb, Nbps); } } template <typename B, typename S> void Bit_packer ::unpack(const S *vec_in, B *vec_out, const int n_bits_per_frame, const int n_frames, const bool msb_to_lsb, const int Nbps) { if (Nbps > (int)(sizeof(S) * CHAR_BIT) || Nbps <= 0) { std::stringstream message; message << "'Nbps' must be between 1 and (sizeof(S) * CHAR_BIT). ('Nbps' = " << Nbps << ", 'sizeof(S)' = " << sizeof(S) << ", 'CHAR_BIT' = " << CHAR_BIT << ")."; throw invalid_argument(__FILE__, __LINE__, __func__, message.str()); } const auto n_symbs_per_frame = static_cast<int>(std::ceil((float)n_bits_per_frame / Nbps)); for (auto f = 0; f < n_frames; f++) Bit_packer::_unpack(vec_in + f * n_symbs_per_frame, vec_out + f * n_bits_per_frame, n_bits_per_frame, msb_to_lsb, Nbps); } template <typename B, class AB> void Bit_packer ::unpack(std::vector<B,AB> &vec, const int n_frames, const bool msb_to_lsb, const int Nbps) { if (n_frames <= 0) { std::stringstream message; message << "'n_frames' has to be greater than 0 ('n_frames' = " << n_frames << ")."; throw invalid_argument(__FILE__, __LINE__, __func__, message.str()); } if (vec.size() % n_frames) { std::stringstream message; message << "'vec.size()' has to be divisible by 'n_frames' ('vec.size()' = " << vec.size() << ", 'n_frames' = " << n_frames << ")."; throw length_error(__FILE__, __LINE__, __func__, message.str()); } Bit_packer::unpack(vec.data(), (int)(vec.size() / n_frames), n_frames, msb_to_lsb, Nbps); } template <typename B> void Bit_packer ::unpack(B *vec, const int n_bits_per_frame, const int n_frames, const bool msb_to_lsb, const int Nbps) { if (Nbps > (int)CHAR_BIT || Nbps <= 0) { std::stringstream message; message << "'Nbps' must be between 1 and CHAR_BIT. ('Nbps' = " << Nbps << ")."; throw invalid_argument(__FILE__, __LINE__, __func__, message.str()); } const auto n_symbs_per_frame = static_cast<int>(std::ceil((float)n_bits_per_frame / Nbps)); unsigned char* bytes = (unsigned char*)vec; std::vector<unsigned char> bytes_cpy(n_symbs_per_frame); //TODO: find a way to avoid this allocation for (auto f = 0; f < n_frames; f++) { //TODO: find a way to avoid this copy std::copy(&bytes[f * n_symbs_per_frame], &bytes[(f +1) * n_symbs_per_frame], bytes_cpy.begin()); Bit_packer::_unpack(bytes_cpy.data() + f * n_symbs_per_frame, vec + f * n_bits_per_frame, n_bits_per_frame, msb_to_lsb, Nbps); } } template <typename B, typename S> void Bit_packer ::_pack(const B* vec_in, S* symbs_out, const int n_bits, const bool msb_to_lsb, const int Nbps) { const auto n_symbs = n_bits / Nbps; const auto rest = n_bits - n_symbs * Nbps; if (!msb_to_lsb) // lsb_to_msb { for (auto i = 0; i < n_symbs; i++, symbs_out++) { S symb = 0; for (auto j = 0; j < Nbps; j++, vec_in++) symb |= ((S)(*vec_in != 0)) << j; *symbs_out = symb; } if (rest != 0) { S symb = 0; for (auto j = 0; j < rest; j++, vec_in++) symb |= ((S)(*vec_in != 0)) << j; *symbs_out = symb; } } else // msb_to_lsb { for (auto i = 0; i < n_symbs; i++, symbs_out++) { S symb = 0; for (auto j = 0; j < Nbps; j++, vec_in++) symb = (symb << 1) | (*vec_in != 0); *symbs_out = symb << (sizeof(S) * CHAR_BIT - Nbps); } if (rest != 0) { S symb = 0; for (auto j = 0; j < rest; j++, vec_in++) symb = (symb << 1) | (*vec_in != 0); *symbs_out = symb << (sizeof(S) * CHAR_BIT - rest); } } } template <typename B, typename S> void Bit_packer ::_unpack(const S *symbs_in, B* vec_out, const int n_bits, const bool msb_to_lsb, const int Nbps) { const auto n_symbs = n_bits / Nbps; const auto rest = n_bits - n_symbs * Nbps; if (!msb_to_lsb) // lsb_to_msb { for (auto i = 0; i < n_symbs; i++, symbs_in++) for (auto j = 0; j < Nbps; j++, vec_out++) *vec_out = (*symbs_in >> j) & (S)1; for (auto j = 0; j < rest; j++, vec_out++) *vec_out = (*symbs_in >> j) & (S)1; } else // msb_to_lsb { for (auto i = 0; i < n_symbs; i++, symbs_in++) for (auto j = 0; j < Nbps; j++, vec_out++) *vec_out = (*symbs_in >> (sizeof(S) * CHAR_BIT -1 -j)) & (S)1; for (auto j = 0; j < rest; j++, vec_out++) *vec_out = (*symbs_in >> (sizeof(S) * CHAR_BIT -1 -j)) & (S)1; } } } } /* Test code : #include <random> #include <string> #include <vector> #include "Tools/Display/Frame_trace/Frame_trace.hpp" #include "Tools/Algo/Bit_packer.hpp" int main(int argc, char** argv) { using namespace aff3ct; using B = int; using S = short; std::random_device rd; size_t size_in = (argc >= 2) ? std::stoi(argv[1]) : 16; int Nbps = (argc >= 3) ? std::stoi(argv[2]) : CHAR_BIT; int n_frames = (argc >= 4) ? std::stoi(argv[3]) : 1; int msb_to_lsb = (argc >= 5) ? std::stoi(argv[4]) : 0; int pack_per_byte = (argc >= 6) ? std::stoi(argv[5]) : 1; int seed = (argc >= 7) ? std::stoi(argv[6]) : rd(); size_t size_out = std::ceil(1.f * size_in / Nbps); std::vector<B> vec_in (size_in * n_frames); std::vector<S> vec_packed (size_out * n_frames); std::vector<B> vec_unpacked(size_in * n_frames); std::mt19937 gen(seed); std::bernoulli_distribution d(0.5); for (auto& v : vec_in) v = d(gen); tools::Frame_trace<> ft; std::cout << "Vec in" << std::endl; ft.display_bit_vector(vec_in, Nbps); tools::Bit_packer::pack(vec_in, vec_packed, n_frames, msb_to_lsb, pack_per_byte, Nbps); std::cout << "Vec packed" << std::endl; if (pack_per_byte) { std::vector<char> vec_char(vec_packed.size() * sizeof(S)); std::copy_n((char*)vec_packed.data(), vec_char.size(), vec_char.data()); ft.display_hex_vector(vec_char, size_out * sizeof(S)); } else ft.display_hex_vector(vec_packed, size_out); tools::Bit_packer::unpack(vec_packed, vec_unpacked, n_frames, msb_to_lsb, pack_per_byte, Nbps); std::cout << "Vec unpacked" << std::endl; ft.display_bit_vector(vec_unpacked, Nbps); bool same = true; for (unsigned i = 0; i < vec_unpacked.size(); i++) same &= vec_unpacked[i] == vec_in[i]; std::cout << "Same in and unpacked = " << same << std::endl; } */
[ "adrien.cassagne@inria.fr" ]
adrien.cassagne@inria.fr
7d39d0114e09dd474329195d0cfc2e2d73adbbf2
648641c5e244b54071a1e90923b4e56eaa531239
/Recursion/Replace Pi with 3.1416 using recursion.cpp
a6b8c7cb955ba087c5c8dbf147b7775d9397dea9
[]
no_license
islamshaheb/Algorithm_Data_structure_and_OOP
29818d8bc797fcbec67b0d8b1760558fd3e86f8e
3b5c5bd0698f9d75ab49401213968524851099ce
refs/heads/master
2023-06-13T21:56:12.450330
2021-07-03T16:20:43
2021-07-03T16:20:43
378,949,609
0
0
null
null
null
null
UTF-8
C++
false
false
1,633
cpp
#include<bits/stdc++.h> using namespace std; #define frr(frm,fornn)for(int i=frm; i<=fornn; i++) #define rfrr(frm,fornn)for(int i=frm; i>=fornn; i--) #define fr(iii,frm,fornn)for(int iii=frm; iii<=fornn; iii++) #define rfr(iii,frm,fornn)for(int iii=frm; iii>=fornn; iii--) #define itfr(iii,frm)for(auto iii=frm.begin(); iii!=frm.end(); iii++) #define ll long long int #define lll unsigned long long int #define pb push_back #define seet(seta) memset(seta,-1,sizeof(seta)) #define clr(seta) memset(seta,0,sizeof(seta)) #define clr2(seta,xxxx,yyyy) memset(seta,0,sizeof(int)*xxxx*yyyy) #define seet2(seta,xxxx,yyyy) memset(seta,-1,sizeof(int)*xxxx*yyyy) #define E "\n" #define infi 10000000000000 #define F first #define S second #define pri1(qxt) cout<<qxt<<"\n"; #define pri2(qxt1,qxt2) cout<<qxt1<<" "<<qxt2<<"\n"; #define pri3(qxt1,qxt2,qxt3) cout<<qxt1<<" "<<qxt2<<" "<<qxt3<<"\n"; #define pri4(qxt1,qxt2,qxt3,qxt4) cout<<qxt1<<" "<<qxt2<<" "<<qxt3<<" "<<qxt4<<"\n"; typedef vector <int> ve; typedef vector <bool> vb; void priarr(int qxt[],int to) { for(int i=0;i<=to;i++)cout<<qxt[i]<<" "; pri1("\n"); } void rec(string s) { if(s.length() == 0)return; if(s[0] == 'p' and s[1]=='i') { cout<<3.14; rec(s.substr(2)); } else { cout<<s[0]; rec(s.substr(1)); } } void solve() { string s = "pidfspisfspipipieeef"; rec(s); cout<<E; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); //freopen("input.txt","r",stdin); //freopen("output.txt","w",stdout); int tc,cse=0; //cin>>tc; //while(tc--) solve(); }
[ "mujahidulislam9345@gmail.com" ]
mujahidulislam9345@gmail.com
96ca90e89f47c1671917823f799a25765b8deeb6
b9be2cf0fe9d11f779cbf8eacfc13fc5f1aa05bc
/C++ toolbox/laplacian.h
789a575c969c4cd765245c9ccf9774126d067d55
[]
no_license
ZainBashir/OpenCV-toolbox
f036fadefc17e3a02d21d3d93ab1dfcb25a84142
4745fd4e8bb140183515857ad3c8a7b838ccf081
refs/heads/master
2021-04-15T08:54:03.039761
2018-03-24T18:26:07
2018-03-24T18:26:07
126,625,604
1
0
null
null
null
null
UTF-8
C++
false
false
625
h
#ifndef LAPLACIAN_H #define LAPLACIAN_H #include <opencv2/core/core.hpp> #include <opencv2/highgui/highgui.hpp> #include <opencv2/imgproc/imgproc.hpp> class laplacian { private: private: // original image cv::Mat img; // 32-bit float image containing the Laplacian cv::Mat laplace; // Aperture size of the laplacian kernel int aperture; public: // laplacian(); laplacian() : aperture(3) {} // Set the aperture size of the kernel void setAperture(int a); cv::Mat computeLaplacian(const cv::Mat& image); cv::Mat getLaplacianImage(double scale=-1.0); }; #endif // LAPLACIAN_H
[ "zain_bashir999@hotmail.com" ]
zain_bashir999@hotmail.com
3cdc2fd082f8a7aaf50da0deef451f4959c8e7c6
39adfee7b03a59c40f0b2cca7a3b5d2381936207
/codeforces/488/D.cpp
f4e894cdb74b4b095f7d652c1760c7d702fbb58e
[]
no_license
ngthanhtrung23/CompetitiveProgramming
c4dee269c320c972482d5f56d3808a43356821ca
642346c18569df76024bfb0678142e513d48d514
refs/heads/master
2023-07-06T05:46:25.038205
2023-06-24T14:18:48
2023-06-24T14:18:48
179,512,787
78
22
null
null
null
null
UTF-8
C++
false
false
2,695
cpp
#include <set> #include <map> #include <list> #include <cmath> #include <queue> #include <stack> #include <cstdio> #include <string> #include <vector> #include <cstdlib> #include <cstring> #include <sstream> #include <iomanip> #include <complex> #include <iostream> #include <algorithm> #include <ctime> #include <deque> #include <bitset> #include <cctype> #include <utility> #include <cassert> using namespace std; #define FOR(i,a,b) for(int i=(a),_b=(b); i<=_b; i++) #define FORD(i,a,b) for(int i=(a),_b=(b); i>=_b; i--) #define REP(i,a) for(int i=0,_a=(a); i<_a; i++) #define EACH(it,a) for(__typeof(a.begin()) it = a.begin(); it != a.end(); ++it) #define SZ(S) ((int) ((S).size())) #define DEBUG(x) { cout << #x << " = " << x << endl; } #define PR(a,n) { cout << #a << " = "; FOR(_,1,n) cout << a[_] << ' '; cout << endl; } #define PR0(a,n) { cout << #a << " = "; REP(_,n) cout << a[_] << ' '; cout << endl; } const int MN = 100111; const int oo = 1000111000; int n, s, l, a[MN], f[MN], far[MN]; int it[MN * 8]; #define CT(X) ((X) << 1) #define CP(X) (CT(X) + 1) #define MID ((l + r) >> 1) void build(int i, int l, int r) { if (l == r) { it[i] = oo; return ; } build(CT(i), l, MID); build(CP(i), MID+1, r); it[i] = oo; } int get(int i, int l, int r, int u, int v) { if (v < l || r < u) return oo; if (u <= l && r <= v) return it[i]; return min(get(CT(i), l, MID, u, v), get(CP(i), MID+1, r, u, v)); } void update(int i, int l, int r, int u, int val) { if (u < l || r < u) return ; if (l == r) { it[i] = val; return ; } update(CT(i), l, MID, u, val); update(CP(i), MID+1, r, u, val); it[i] = min(it[CT(i)], it[CP(i)]); } int main() { ios :: sync_with_stdio(false); cin.tie(NULL); cout << (fixed) << setprecision(6); while (cin >> n >> s >> l) { FOR(i,1,n) cin >> a[i]; f[0] = 0; FOR(i,1,n) f[i] = oo; build(1, 1, n); int j = 1; multiset<int> cur; FOR(i,1,n) { cur.insert(a[i]); while (*cur.rbegin() - *cur.begin() > s) { cur.erase(cur.find(a[j])); ++j; } far[i] = j; } // PR(far, n); FOR(i,1,n) { int from = far[i], to = i - l + 1; if (from > to) continue; if (from == 1) f[i] = 1; else f[i] = get(1, 1, n, from-1, to-1) + 1; update(1, 1, n, i, f[i]); } if (f[n] >= oo) f[n] = -1; cout << f[n] << endl; } return 0; }
[ "ngthanhtrung23@gmail.com" ]
ngthanhtrung23@gmail.com
e94e84509d96903241e95593047cec4b5bb067fc
db20d5b6b448f54cdee5d258436455ed0803c209
/BobKinectWrapper/BobNuiSkeletonStream.cpp
e110e913fbbb7afbab151cf1d68043dad6aed0b2
[]
no_license
zhaxiu3/BobKinectWrapper
0ec935903406253791514660be87ab1aa755e11b
7f5bba616e4f936d0bf95a9aafcb06dde32d0ba9
refs/heads/master
2016-08-06T07:20:29.871096
2014-01-15T11:16:30
2014-01-15T11:16:30
null
0
0
null
null
null
null
UTF-8
C++
false
false
548
cpp
#include "BobNuiSkeletonStream.h" CBobNuiSkeletonStream::CBobNuiSkeletonStream(INuiSensor* psensor) :CBobNuiStream(psensor) { } CBobNuiSkeletonStream::~CBobNuiSkeletonStream(void) { } HRESULT CBobNuiSkeletonStream::OpenStream() { throw std::logic_error("The method or operation is not implemented."); } void CBobNuiSkeletonStream::PauseStream() { throw std::logic_error("The method or operation is not implemented."); } void CBobNuiSkeletonStream::CloseStream() { throw std::logic_error("The method or operation is not implemented."); }
[ "zhaxiu3@163.com" ]
zhaxiu3@163.com
0ee39b3079e9f3a8ea29214ddcca27e327b09263
31039552c3fe7099bbff01dd37bc7a29a7730986
/ico-terminal/GuiExchangePairList.h
c5451303f28464ec6b778ff0aa28456e42e26fa0
[]
no_license
goaquit/ico-terminal
6ea363406191a054b1d693abbc49f6d9461a54ae
4fb846fbee2847ac33045203f5ff316d623e9951
refs/heads/master
2020-04-02T14:04:35.798942
2018-10-24T13:51:59
2018-10-24T13:51:59
154,509,523
3
1
null
null
null
null
UTF-8
C++
false
false
891
h
#pragma once #include <QWidget> #include "ui_GuiExchangePairList.h" #include <vector> #include "DepthOrder.h" class ControllerOrderBook; using OrderBook = Entity::DepthOrder; class GuiExchangePairList : public QWidget { Q_OBJECT public: GuiExchangePairList(QWidget *parent = nullptr); void init(); void connectOrderBook(const ControllerOrderBook *controllerOrderBook); signals: void reuqestOrderBook(const QString &index); void newChart(uint exchange, uint pair); void newOrderBook(const QString &title, const QString &index); private: Ui::GuiExchangePairList ui; std::map<uint, std::vector<uint>> exchangePair; std::map<uint, QString> pairsList; void initConnect(); private slots: void onExchangeSelected(QListWidgetItem *item); void onOrderBookRecieved(const OrderBook &orderBook, const QString &index); void createChart(); void createOrderBook(); };
[ "goaquit@gmail.com" ]
goaquit@gmail.com
8de847eaeac57b8aea26d16efabbf85a50463e8b
87f983c7784bffce8938509c1ef26c6ba2bf7408
/tempconv.cpp
4f22032eb9d46c22c2c683185c25938988a189ef
[]
no_license
ZetaRift/conv-cpp
a1da898d85f26703da43000760db8c65a3b2a2a3
3d92c04930ed0596505b330bad6334f3fa96d467
refs/heads/master
2021-01-01T16:19:53.703573
2015-03-23T01:53:48
2015-03-23T01:53:48
23,058,737
0
0
null
null
null
null
UTF-8
C++
false
false
3,523
cpp
#include <FL/Fl.H> #include <FL/Fl_Window.H> #include <FL/Fl_Float_Input.H> #include <FL/Fl_Button.H> #include <FL/Fl_Choice.H> #include <FL/Fl_Output.H> #include <cstdlib> #include <iostream> #include <fstream> #include <cstring> #include <string> #include <csignal> #define HEADER "TEMPCONVFL" #define TEXT "Terminus" /* This requires the FLTK headers, along with these parameters for compiling: -s $(fltk-config --cxxflags --ldflags) */ Fl_Choice *convchoicein; Fl_Choice *convchoiceout; Fl_Window *window1; Fl_Window *window2; Fl_Choice *gchoice; Fl_Float_Input *inp1; Fl_Output *out1; Fl_Button *convbutton; Fl_Button *okbutton; using namespace std; void quit(Fl_Widget*, void*){ printf("Exited.\n"); exit(0); } void sigquit(int sig){ // Clean exit on catching a signal printf("\n"); printf("Caught signal %i\n", sig); printf("Exited.\n"); exit(0); } void tempconv(Fl_Widget*, void*){ char cstr[32]; float n; float res; int abz; n = atof(inp1->value()); if (n > 999999999) { out1->value("Overflow"); } else { if (convchoicein->value() == 0) { // 0 if (n < -273.15) { abz = 1; } else { abz = 0; if (convchoiceout->value() == 0) { // 0 0 res = n; } else if (convchoiceout->value() == 1) { // 0 1 res = n * 1.8 + 32; } else if (convchoiceout->value() == 2) { // 0 2 res = n + 273.15; } } } else if (convchoicein->value() == 1) { // 1 if (n < -459.67) { abz = 1; } else { abz = 0; if (convchoiceout->value() == 0) { // 1 0 res = (n - 32) * 5 / 9; } else if (convchoiceout->value() == 1) { // 1 1 res = n; } else if (convchoiceout->value() == 2) { // 1 2 res = (n - 32) * 5 / 9; res = res + 273.15; } } } else if (convchoicein->value() == 2) { if (n < 0) { abz = 1; } else { abz = 0; if (convchoiceout->value() == 0) { // 2 0 res = n - 273.15; } else if (convchoiceout->value() == 1) { // 2 1 res = n - 273.15; res = res * 1.8 + 32; } else if (convchoiceout->value() == 2) { // 2 2 res = n; } } } sprintf(cstr, "%.2f", res); // the '%.2f' limits the output floating point to two decimal places res = (n + 273.15) * 9 / 5; if (abz == 0) { out1->value(cstr); } else { out1->value("Below Absolute Zero"); } } } int main() { signal(SIGINT, sigquit); //Save when Ctrl-C is pressed signal(SIGTERM, sigquit); //Save when signal 15 happens window2 = new Fl_Window(310,190, "Temperature converter"); window2->callback(&quit); // Will save conf and exit when you close the window, removed the exit button. convchoicein = new Fl_Choice(80,30,200,20, "From"); // Conversion choices, the value of which choice is selected is an integer, for example: "C to F" is 0, "F to C" is 1, and so on.. convchoiceout = new Fl_Choice(80,60,200,20, "To"); Fl_Menu_Item opts[] = { {"Celsius"}, {"Fahrenheit"}, {"Kelvin"}, {0}}; convchoicein->menu(opts); convchoiceout->menu(opts); inp1 = new Fl_Float_Input(80,90,150,20, "Input"); inp1->callback(&tempconv); // Added callback for inp1, it will convert when you hit enter on the input field out1 = new Fl_Output(80,120,160,20, "Output"); convbutton = new Fl_Button(110,150,70,20, "Convert"); convbutton->type(FL_NORMAL_BUTTON); inp1->handle(1); out1->handle(1); out1->value("NaN"); convbutton->callback(&tempconv); window2->end(); window2->show(); Fl::run(); }
[ "avery.lamar@yahoo.com" ]
avery.lamar@yahoo.com
fe731b0f009ac08578bee23530f5c5bd8a44db1d
572871ee2bbcdf9c1a5f6999300307c57d2b31ae
/general/func/include/ScifiIncidentPosition02.h
29279a9e4b129687293787919c17d26691aad757
[]
no_license
hmenjo/RHICf-library
9bd3ed12726e989962e1b882e871a6ad59756ca5
c95cb94a2cc2fbe281b2d85bbf02296da2329eac
refs/heads/develop
2022-05-15T00:45:30.783099
2022-04-19T01:57:01
2022-04-19T01:57:01
203,476,841
0
0
null
2021-04-28T06:30:37
2019-08-21T00:45:21
Shell
UTF-8
C++
false
false
1,899
h
#ifndef __SCIFIINCIDENTPOSITION02_H__ #define __SCIFIINCIDENTPOSITION02_H__ //----------------------------------------------------------------- // ScifiIncidentPosition02 //----------------------------------------------------------------- #include <TObject.h> #include <TF1.h> #include <TGraphErrors.h> #include <TCanvas.h> #include "MyFunction.h" #include "A1Cal2.h" #include "ConScifiPosition.h" class ScifiIncidentPosition02{ public: double pos[2][4][2]; double qparam[2][4][2][6]; double pede[2][4][2]; ConScifiPosition* scifipos; TF1 *f[2][4][2]; //! TGraphErrors *ge[2][4][2]; //! public: ScifiIncidentPosition02(); ScifiIncidentPosition02(char *file); virtual ~ScifiIncidentPosition02(){;} int Initialize(); int Clear(); int ReadScifiPisition(char *file); int SetConScifiPosition(ConScifiPosition* c){scifipos = c; return 0;} int Calculate(A1Cal2* c2data,int it,int il,int ixy); int Calculate(A1Cal2* c2data,int it); double GetPos(int it=0,int il=0,int ixy=0){return pos[it][il][ixy];} double GetPosX(int it,int il=-1); double GetPosY(int it,int il=-1); double GetQParam(int it=0,int il=0,int ixy=0,int ip=0) {return qparam[it][il][ixy][ip];} void SetQParam(int it,int il,int ixy,int ip,double value); double GetBaseFluctuation(int it=-1,int il=-1,int ixy=-1); void SetBaseFluctuation(int it,int il,int ixy,double value); void SetBaseFluctuation(double value); TF1* GetFunction(int it,int il,int ixy){return f[it][il][ixy];} int SetGraph(A1Cal2* c2data,int it,int il,int ixy); int Draw(A1Cal2* c2data,int it,int il,int ixy); static const int SCIFIINCIDENTPOSITION02_OK = 0; static const int SCIFIINCIDENTPOSITION02_ERROR = -10; ClassDef(ScifiIncidentPosition02,1); // Hit position search of SciFi (ver. MENJO) }; #endif
[ "hiroaki.menjo@cern.ch" ]
hiroaki.menjo@cern.ch
af5e94238006b4451a9c1398b6d6030d6a3bbe5d
4c626c943b6af56524c6599b64451722ee2e9629
/aep_model/api/checkers/aep_model_ovl_checkers_factory.hpp
18e0bdc6e0a59cad2307f5f779d87c54d77a4aec
[]
no_license
kirillPshenychnyi/AEP
96cec51a4c579b2430b8c93cace5e25003c64219
07d9f3deb47514043a8a1cb0c5ff6091737c3d47
refs/heads/master
2018-08-31T16:59:08.415648
2018-06-10T22:21:04
2018-06-10T22:21:04
117,731,321
0
0
null
null
null
null
UTF-8
C++
false
false
1,238
hpp
#ifndef __AEP_MODEL_OVL_CHECKERS_FACTORY_HPP__ #define __AEP_MODEL_OVL_CHECKERS_FACTORY_HPP__ /***************************************************************************/ #include "aep_model\api\aep_model_fwd.hpp" /***************************************************************************/ namespace AepModel { /***************************************************************************/ struct OvlCheckersFactory : public boost::noncopyable { /***************************************************************************/ virtual ~OvlCheckersFactory() = default; virtual std::unique_ptr< OvlAlwaysCheckerBuilder > newOvlAlwaysChecker( std::string const & _instanceName , std::string const & _fileName , int _suspectLine ) const = 0; virtual std::unique_ptr< OvlOneHotCheckerBuilder > newOvlOneHotChecker( std::string const & _instanceName , std::string const & _fileName , int _suspectLine ) const = 0; /***************************************************************************/ }; /***************************************************************************/ } /***************************************************************************/ #endif // !__AEP_MODEL_OVL_CHECKERS_FACTORY_HPP__
[ "pshenychnyi96@gmail.com" ]
pshenychnyi96@gmail.com
45c15ac413217386a6eaaca3a7786e9e8c241607
050ebbbc7d5f89d340fd9f2aa534eac42d9babb7
/grupa1/mnaduk/cza.cpp
64ed66d085f2e6894b0df59df4f7793eb4779da9
[]
no_license
anagorko/zpk2015
83461a25831fa4358366ec15ab915a0d9b6acdf5
0553ec55d2617f7bea588d650b94828b5f434915
refs/heads/master
2020-04-05T23:47:55.299547
2016-09-14T11:01:46
2016-09-14T11:01:46
52,429,626
0
13
null
2016-03-22T09:35:25
2016-02-24T09:19:07
C++
UTF-8
C++
false
false
184
cpp
#include <iostream> using namespace std; int main() { int c, g, m, s; cin >> c; g=c/3600; m=(c-(g*3600))/60; s=c-(g*3600+m*60); cout << g << "g" << m << "m" << s << "s"; return 0; }
[ "maciej.naduk@gmail.com" ]
maciej.naduk@gmail.com
3d3a88af268a157e8be0a2ad7505dd1e64b20b42
48fd5f42986b2f14930c50f693010483ef51d271
/Stellaris_FreeRtos/src/Tcp.h
7cb2ae5641b64810cf40301ad21c158edff16a3b
[ "LicenseRef-scancode-warranty-disclaimer" ]
no_license
vortex314/projects
96298706698c145b1650638c377a63b87f1964d2
43ef8e091dba1bf4e71097469a1e63780fc0bafc
refs/heads/master
2016-09-05T12:31:08.220957
2015-08-23T17:30:24
2015-08-23T17:30:24
20,578,565
0
0
null
null
null
null
UTF-8
C++
false
false
1,484
h
/* * File: Tcp.h * Author: lieven * * Created on August 24, 2013, 9:39 PM */ #ifndef TCP_H #define TCP_H #include <stdint.h> #include "Erc.h" #include "Bytes.h" #include "CircBuf.h" #include "Timer.h" #include "Wiz5100.h" #include "pt.h" #include "Stream.h" #include "Event.h" class Tcp : public Stream { public: enum TcpEvents { CONNECTED = EVENT('t', 'C'), DISCONNECTED = EVENT('t', 'D'), RXD = EVENT('t', 'R'), TXD = EVENT('t', 'T'), CMD_SEND = EVENT('t', 'S') }; enum State { ST_CONNECTED = 1, ST_DISCONNECTED = 2, ST_CONNECTING }; Tcp(Wiz5100* wiz,uint32_t socket); ~Tcp(); int init(); void setDstIp(uint8_t* dstIp); void setDstPort(uint16_t port); Erc incSrcPort(); Erc connect(); void disconnect(); Erc write(Bytes* outMsg); int recvSize(uint16_t* size); int recv(Bytes& inMsg); Erc recvLoop(); Erc flush(); bool hasData(); uint8_t read(); char run(struct pt *pt); void poll(); void state(State state); bool isConnected(); bool isConnecting(); Erc event(Event* pEvent); private: Erc inConnected(Event& event); uint8_t _dstIp[4]; uint16_t _dstPort; uint16_t _srcPort; uint8_t _socket; State _state; Wiz5100* _wiz; CircBuf _rxd; CircBuf _txd; uint32_t _bytesTxd; uint32_t _bytesRxd; uint32_t _connects; uint32_t _disconnects; }; #endif /* TCP_H */
[ "lieven.merckx@gmail.com" ]
lieven.merckx@gmail.com