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
5057e0463d0283f3d559b2b6b8e09188b9849234
87d8af054e17e0c346b6f59636402883fbf0158d
/Cpp/SDK/BP_eye_col_black_03_Desc_classes.h
c3c11385818a9d3a83a5dabc4e6008e856f3e0a5
[]
no_license
AthenaVision/SoT-SDK-2
53676d349bca171b5e48dc812fd7bb97b9a4f1d8
4a803206d707a081b86c89a4b866a1761119613d
refs/heads/main
2023-03-20T10:48:21.491008
2021-03-10T21:55:10
2021-03-10T21:55:10
null
0
0
null
null
null
null
UTF-8
C++
false
false
757
h
#pragma once // Name: sot, Version: 4.2 /*!!DEFINE!!*/ /*!!HELPER_DEF!!*/ /*!!HELPER_INC!!*/ #ifdef _MSC_VER #pragma pack(push, 0x01) #endif namespace CG { //--------------------------------------------------------------------------- // Classes //--------------------------------------------------------------------------- // BlueprintGeneratedClass BP_eye_col_black_03_Desc.BP_eye_col_black_03_Desc_C // 0x0000 (FullSize[0x00E0] - InheritedSize[0x00E0]) class UBP_eye_col_black_03_Desc_C : public UClothingDesc { public: static UClass* StaticClass() { static auto ptr = UObject::FindClass("BlueprintGeneratedClass BP_eye_col_black_03_Desc.BP_eye_col_black_03_Desc_C"); return ptr; } }; } #ifdef _MSC_VER #pragma pack(pop) #endif
[ "59620169+NtLoadDriverEx@users.noreply.github.com" ]
59620169+NtLoadDriverEx@users.noreply.github.com
481472ea21e507cbfba83e8488bb580ca84a04a7
c56bcde04453ba80f618042f4fd79e37e3880b57
/src/Config.cpp
60527ce55aa648aaca0bcbcde7996aa4eda0230d
[]
no_license
jack111331/Ray
aa71a346d558b36fe13257de00cbcf75865c4ec3
c174783f9c98ac420f934b042f918c6239281452
refs/heads/master
2023-06-21T00:20:04.207217
2021-07-08T09:04:49
2021-07-08T09:04:49
307,962,200
1
0
null
null
null
null
UTF-8
C++
false
false
1,402
cpp
// // Created by Edge on 2020/7/8. // #include <string> #include <fstream> #include <sstream> #include <Dielectric.h> #include <BVH.h> #include <Lambertian.h> #include <IllumModelFactory.h> #include "Config.h" #include "Sphere.h" #include "Triangle.h" #include "Light.h" #include "GeometryGroupObj.h" #include "AreaLight.h" #include <yaml-cpp/yaml.h> #include <PipelineFactory.h> using namespace std; Pipeline *Config::loadConfig(const string &configFilename) { YAML::Node configNode = YAML::LoadFile(configFilename); if(configNode.IsNull()) { return nullptr; } Pipeline *pipeline = nullptr; if(configNode["model"]) { auto modelNode = configNode["model"]; if(!modelNode["type"] || !modelNode["pipeline"]) { std::cerr << "No shading type or pipeline specified" << std::endl; exit(1); } pipeline = PipelineFactory::generatePipeline(modelNode["type"].as<std::string>(), modelNode["pipeline"].as<std::string>()); pipeline->readPipelineInfo(modelNode); } if(configNode["scene"]) { Scene *scene = new Scene(); scene->readSceneInfo(configNode["scene"]); pipeline->setupScene(scene); } if(configNode["viewer"]) { Camera *camera = new Camera(); camera->readCameraInfo(configNode["viewer"]); pipeline->setupCamera(camera); } return pipeline; }
[ "jack111331@gmail.com" ]
jack111331@gmail.com
2d034ce85c97d9905080647f437e8b1d306d4755
6e2e8592b602ac36de770ad101eed05405c982cc
/modules/common/proto/header.pb.cc
d0653b7f3a151e3cb1fb433be13a211d32f8a670
[]
no_license
sxhxliang/Apollo-Lite
6060dc361fd22b90fa2c986ee4dbbb6cf38d50ec
b59e1c6a9a88aa421e72fa709a80c10e868531f8
refs/heads/main
2023-04-09T19:04:15.275450
2021-04-17T18:25:22
2021-04-17T18:25:22
356,549,140
2
3
null
null
null
null
UTF-8
C++
false
true
33,545
cc
// Generated by the protocol buffer compiler. DO NOT EDIT! // source: modules/common/proto/header.proto #include "modules/common/proto/header.pb.h" #include <algorithm> #include <google/protobuf/stubs/common.h> #include <google/protobuf/io/coded_stream.h> #include <google/protobuf/extension_set.h> #include <google/protobuf/wire_format_lite.h> #include <google/protobuf/descriptor.h> #include <google/protobuf/generated_message_reflection.h> #include <google/protobuf/reflection_ops.h> #include <google/protobuf/wire_format.h> // @@protoc_insertion_point(includes) #include <google/protobuf/port_def.inc> extern PROTOBUF_INTERNAL_EXPORT_modules_2fcommon_2fproto_2ferror_5fcode_2eproto ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<0> scc_info_StatusPb_modules_2fcommon_2fproto_2ferror_5fcode_2eproto; namespace apollo { namespace common { class HeaderDefaultTypeInternal { public: ::PROTOBUF_NAMESPACE_ID::internal::ExplicitlyConstructed<Header> _instance; } _Header_default_instance_; } // namespace common } // namespace apollo static void InitDefaultsscc_info_Header_modules_2fcommon_2fproto_2fheader_2eproto() { GOOGLE_PROTOBUF_VERIFY_VERSION; { void* ptr = &::apollo::common::_Header_default_instance_; new (ptr) ::apollo::common::Header(); ::PROTOBUF_NAMESPACE_ID::internal::OnShutdownDestroyMessage(ptr); } ::apollo::common::Header::InitAsDefaultInstance(); } ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<1> scc_info_Header_modules_2fcommon_2fproto_2fheader_2eproto = {{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 1, InitDefaultsscc_info_Header_modules_2fcommon_2fproto_2fheader_2eproto}, { &scc_info_StatusPb_modules_2fcommon_2fproto_2ferror_5fcode_2eproto.base,}}; static ::PROTOBUF_NAMESPACE_ID::Metadata file_level_metadata_modules_2fcommon_2fproto_2fheader_2eproto[1]; static constexpr ::PROTOBUF_NAMESPACE_ID::EnumDescriptor const** file_level_enum_descriptors_modules_2fcommon_2fproto_2fheader_2eproto = nullptr; static constexpr ::PROTOBUF_NAMESPACE_ID::ServiceDescriptor const** file_level_service_descriptors_modules_2fcommon_2fproto_2fheader_2eproto = nullptr; const ::PROTOBUF_NAMESPACE_ID::uint32 TableStruct_modules_2fcommon_2fproto_2fheader_2eproto::offsets[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = { PROTOBUF_FIELD_OFFSET(::apollo::common::Header, _has_bits_), PROTOBUF_FIELD_OFFSET(::apollo::common::Header, _internal_metadata_), ~0u, // no _extensions_ ~0u, // no _oneof_case_ ~0u, // no _weak_field_map_ PROTOBUF_FIELD_OFFSET(::apollo::common::Header, timestamp_sec_), PROTOBUF_FIELD_OFFSET(::apollo::common::Header, module_name_), PROTOBUF_FIELD_OFFSET(::apollo::common::Header, sequence_num_), PROTOBUF_FIELD_OFFSET(::apollo::common::Header, lidar_timestamp_), PROTOBUF_FIELD_OFFSET(::apollo::common::Header, camera_timestamp_), PROTOBUF_FIELD_OFFSET(::apollo::common::Header, radar_timestamp_), PROTOBUF_FIELD_OFFSET(::apollo::common::Header, version_), PROTOBUF_FIELD_OFFSET(::apollo::common::Header, status_), PROTOBUF_FIELD_OFFSET(::apollo::common::Header, frame_id_), 3, 0, 7, 4, 5, 6, 8, 2, 1, }; static const ::PROTOBUF_NAMESPACE_ID::internal::MigrationSchema schemas[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = { { 0, 14, sizeof(::apollo::common::Header)}, }; static ::PROTOBUF_NAMESPACE_ID::Message const * const file_default_instances[] = { reinterpret_cast<const ::PROTOBUF_NAMESPACE_ID::Message*>(&::apollo::common::_Header_default_instance_), }; const char descriptor_table_protodef_modules_2fcommon_2fproto_2fheader_2eproto[] = "\n!modules/common/proto/header.proto\022\rapo" "llo.common\032%modules/common/proto/error_c" "ode.proto\"\345\001\n\006Header\022\025\n\rtimestamp_sec\030\001 " "\001(\001\022\023\n\013module_name\030\002 \001(\t\022\024\n\014sequence_num" "\030\003 \001(\r\022\027\n\017lidar_timestamp\030\004 \001(\004\022\030\n\020camer" "a_timestamp\030\005 \001(\004\022\027\n\017radar_timestamp\030\006 \001" "(\004\022\022\n\007version\030\007 \001(\r:\0011\022\'\n\006status\030\010 \001(\0132\027" ".apollo.common.StatusPb\022\020\n\010frame_id\030\t \001(" "\t" ; static const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable*const descriptor_table_modules_2fcommon_2fproto_2fheader_2eproto_deps[1] = { &::descriptor_table_modules_2fcommon_2fproto_2ferror_5fcode_2eproto, }; static ::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase*const descriptor_table_modules_2fcommon_2fproto_2fheader_2eproto_sccs[1] = { &scc_info_Header_modules_2fcommon_2fproto_2fheader_2eproto.base, }; static ::PROTOBUF_NAMESPACE_ID::internal::once_flag descriptor_table_modules_2fcommon_2fproto_2fheader_2eproto_once; static bool descriptor_table_modules_2fcommon_2fproto_2fheader_2eproto_initialized = false; const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable descriptor_table_modules_2fcommon_2fproto_2fheader_2eproto = { &descriptor_table_modules_2fcommon_2fproto_2fheader_2eproto_initialized, descriptor_table_protodef_modules_2fcommon_2fproto_2fheader_2eproto, "modules/common/proto/header.proto", 321, &descriptor_table_modules_2fcommon_2fproto_2fheader_2eproto_once, descriptor_table_modules_2fcommon_2fproto_2fheader_2eproto_sccs, descriptor_table_modules_2fcommon_2fproto_2fheader_2eproto_deps, 1, 1, schemas, file_default_instances, TableStruct_modules_2fcommon_2fproto_2fheader_2eproto::offsets, file_level_metadata_modules_2fcommon_2fproto_2fheader_2eproto, 1, file_level_enum_descriptors_modules_2fcommon_2fproto_2fheader_2eproto, file_level_service_descriptors_modules_2fcommon_2fproto_2fheader_2eproto, }; // Force running AddDescriptors() at dynamic initialization time. static bool dynamic_init_dummy_modules_2fcommon_2fproto_2fheader_2eproto = ( ::PROTOBUF_NAMESPACE_ID::internal::AddDescriptors(&descriptor_table_modules_2fcommon_2fproto_2fheader_2eproto), true); namespace apollo { namespace common { // =================================================================== void Header::InitAsDefaultInstance() { ::apollo::common::_Header_default_instance_._instance.get_mutable()->status_ = const_cast< ::apollo::common::StatusPb*>( ::apollo::common::StatusPb::internal_default_instance()); } class Header::HasBitSetters { public: using HasBits = decltype(std::declval<Header>()._has_bits_); static void set_has_timestamp_sec(HasBits* has_bits) { (*has_bits)[0] |= 8u; } static void set_has_module_name(HasBits* has_bits) { (*has_bits)[0] |= 1u; } static void set_has_sequence_num(HasBits* has_bits) { (*has_bits)[0] |= 128u; } static void set_has_lidar_timestamp(HasBits* has_bits) { (*has_bits)[0] |= 16u; } static void set_has_camera_timestamp(HasBits* has_bits) { (*has_bits)[0] |= 32u; } static void set_has_radar_timestamp(HasBits* has_bits) { (*has_bits)[0] |= 64u; } static void set_has_version(HasBits* has_bits) { (*has_bits)[0] |= 256u; } static const ::apollo::common::StatusPb& status(const Header* msg); static void set_has_status(HasBits* has_bits) { (*has_bits)[0] |= 4u; } static void set_has_frame_id(HasBits* has_bits) { (*has_bits)[0] |= 2u; } }; const ::apollo::common::StatusPb& Header::HasBitSetters::status(const Header* msg) { return *msg->status_; } void Header::clear_status() { if (status_ != nullptr) status_->Clear(); _has_bits_[0] &= ~0x00000004u; } #if !defined(_MSC_VER) || _MSC_VER >= 1900 const int Header::kTimestampSecFieldNumber; const int Header::kModuleNameFieldNumber; const int Header::kSequenceNumFieldNumber; const int Header::kLidarTimestampFieldNumber; const int Header::kCameraTimestampFieldNumber; const int Header::kRadarTimestampFieldNumber; const int Header::kVersionFieldNumber; const int Header::kStatusFieldNumber; const int Header::kFrameIdFieldNumber; #endif // !defined(_MSC_VER) || _MSC_VER >= 1900 Header::Header() : ::PROTOBUF_NAMESPACE_ID::Message(), _internal_metadata_(nullptr) { SharedCtor(); // @@protoc_insertion_point(constructor:apollo.common.Header) } Header::Header(const Header& from) : ::PROTOBUF_NAMESPACE_ID::Message(), _internal_metadata_(nullptr), _has_bits_(from._has_bits_) { _internal_metadata_.MergeFrom(from._internal_metadata_); module_name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); if (from.has_module_name()) { module_name_.AssignWithDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from.module_name_); } frame_id_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); if (from.has_frame_id()) { frame_id_.AssignWithDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from.frame_id_); } if (from.has_status()) { status_ = new ::apollo::common::StatusPb(*from.status_); } else { status_ = nullptr; } ::memcpy(&timestamp_sec_, &from.timestamp_sec_, static_cast<size_t>(reinterpret_cast<char*>(&version_) - reinterpret_cast<char*>(&timestamp_sec_)) + sizeof(version_)); // @@protoc_insertion_point(copy_constructor:apollo.common.Header) } void Header::SharedCtor() { ::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&scc_info_Header_modules_2fcommon_2fproto_2fheader_2eproto.base); module_name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); frame_id_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); ::memset(&status_, 0, static_cast<size_t>( reinterpret_cast<char*>(&sequence_num_) - reinterpret_cast<char*>(&status_)) + sizeof(sequence_num_)); version_ = 1u; } Header::~Header() { // @@protoc_insertion_point(destructor:apollo.common.Header) SharedDtor(); } void Header::SharedDtor() { module_name_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); frame_id_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); if (this != internal_default_instance()) delete status_; } void Header::SetCachedSize(int size) const { _cached_size_.Set(size); } const Header& Header::default_instance() { ::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&::scc_info_Header_modules_2fcommon_2fproto_2fheader_2eproto.base); return *internal_default_instance(); } void Header::Clear() { // @@protoc_insertion_point(message_clear_start:apollo.common.Header) ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; // Prevent compiler warnings about cached_has_bits being unused (void) cached_has_bits; cached_has_bits = _has_bits_[0]; if (cached_has_bits & 0x00000007u) { if (cached_has_bits & 0x00000001u) { module_name_.ClearNonDefaultToEmptyNoArena(); } if (cached_has_bits & 0x00000002u) { frame_id_.ClearNonDefaultToEmptyNoArena(); } if (cached_has_bits & 0x00000004u) { GOOGLE_DCHECK(status_ != nullptr); status_->Clear(); } } if (cached_has_bits & 0x000000f8u) { ::memset(&timestamp_sec_, 0, static_cast<size_t>( reinterpret_cast<char*>(&sequence_num_) - reinterpret_cast<char*>(&timestamp_sec_)) + sizeof(sequence_num_)); } version_ = 1u; _has_bits_.Clear(); _internal_metadata_.Clear(); } #if GOOGLE_PROTOBUF_ENABLE_EXPERIMENTAL_PARSER const char* Header::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) { #define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure HasBitSetters::HasBits has_bits{}; while (!ctx->Done(&ptr)) { ::PROTOBUF_NAMESPACE_ID::uint32 tag; ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag); CHK_(ptr); switch (tag >> 3) { // optional double timestamp_sec = 1; case 1: if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 9)) { HasBitSetters::set_has_timestamp_sec(&has_bits); timestamp_sec_ = ::PROTOBUF_NAMESPACE_ID::internal::UnalignedLoad<double>(ptr); ptr += sizeof(double); } else goto handle_unusual; continue; // optional string module_name = 2; case 2: if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 18)) { ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParserUTF8Verify(mutable_module_name(), ptr, ctx, "apollo.common.Header.module_name"); CHK_(ptr); } else goto handle_unusual; continue; // optional uint32 sequence_num = 3; case 3: if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 24)) { HasBitSetters::set_has_sequence_num(&has_bits); sequence_num_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint(&ptr); CHK_(ptr); } else goto handle_unusual; continue; // optional uint64 lidar_timestamp = 4; case 4: if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 32)) { HasBitSetters::set_has_lidar_timestamp(&has_bits); lidar_timestamp_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint(&ptr); CHK_(ptr); } else goto handle_unusual; continue; // optional uint64 camera_timestamp = 5; case 5: if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 40)) { HasBitSetters::set_has_camera_timestamp(&has_bits); camera_timestamp_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint(&ptr); CHK_(ptr); } else goto handle_unusual; continue; // optional uint64 radar_timestamp = 6; case 6: if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 48)) { HasBitSetters::set_has_radar_timestamp(&has_bits); radar_timestamp_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint(&ptr); CHK_(ptr); } else goto handle_unusual; continue; // optional uint32 version = 7 [default = 1]; case 7: if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 56)) { HasBitSetters::set_has_version(&has_bits); version_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint(&ptr); CHK_(ptr); } else goto handle_unusual; continue; // optional .apollo.common.StatusPb status = 8; case 8: if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 66)) { ptr = ctx->ParseMessage(mutable_status(), ptr); CHK_(ptr); } else goto handle_unusual; continue; // optional string frame_id = 9; case 9: if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 74)) { ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParserUTF8Verify(mutable_frame_id(), ptr, ctx, "apollo.common.Header.frame_id"); CHK_(ptr); } else goto handle_unusual; continue; default: { handle_unusual: if ((tag & 7) == 4 || tag == 0) { ctx->SetLastTag(tag); goto success; } ptr = UnknownFieldParse(tag, &_internal_metadata_, ptr, ctx); CHK_(ptr != nullptr); continue; } } // switch } // while success: _has_bits_.Or(has_bits); return ptr; failure: ptr = nullptr; goto success; #undef CHK_ } #else // GOOGLE_PROTOBUF_ENABLE_EXPERIMENTAL_PARSER bool Header::MergePartialFromCodedStream( ::PROTOBUF_NAMESPACE_ID::io::CodedInputStream* input) { #define DO_(EXPRESSION) if (!PROTOBUF_PREDICT_TRUE(EXPRESSION)) goto failure ::PROTOBUF_NAMESPACE_ID::uint32 tag; // @@protoc_insertion_point(parse_start:apollo.common.Header) for (;;) { ::std::pair<::PROTOBUF_NAMESPACE_ID::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(127u); tag = p.first; if (!p.second) goto handle_unusual; switch (::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::GetTagFieldNumber(tag)) { // optional double timestamp_sec = 1; case 1: { if (static_cast< ::PROTOBUF_NAMESPACE_ID::uint8>(tag) == (9 & 0xFF)) { HasBitSetters::set_has_timestamp_sec(&_has_bits_); DO_((::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::ReadPrimitive< double, ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::TYPE_DOUBLE>( input, &timestamp_sec_))); } else { goto handle_unusual; } break; } // optional string module_name = 2; case 2: { if (static_cast< ::PROTOBUF_NAMESPACE_ID::uint8>(tag) == (18 & 0xFF)) { DO_(::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::ReadString( input, this->mutable_module_name())); ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField( this->module_name().data(), static_cast<int>(this->module_name().length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::PARSE, "apollo.common.Header.module_name"); } else { goto handle_unusual; } break; } // optional uint32 sequence_num = 3; case 3: { if (static_cast< ::PROTOBUF_NAMESPACE_ID::uint8>(tag) == (24 & 0xFF)) { HasBitSetters::set_has_sequence_num(&_has_bits_); DO_((::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::ReadPrimitive< ::PROTOBUF_NAMESPACE_ID::uint32, ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::TYPE_UINT32>( input, &sequence_num_))); } else { goto handle_unusual; } break; } // optional uint64 lidar_timestamp = 4; case 4: { if (static_cast< ::PROTOBUF_NAMESPACE_ID::uint8>(tag) == (32 & 0xFF)) { HasBitSetters::set_has_lidar_timestamp(&_has_bits_); DO_((::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::ReadPrimitive< ::PROTOBUF_NAMESPACE_ID::uint64, ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::TYPE_UINT64>( input, &lidar_timestamp_))); } else { goto handle_unusual; } break; } // optional uint64 camera_timestamp = 5; case 5: { if (static_cast< ::PROTOBUF_NAMESPACE_ID::uint8>(tag) == (40 & 0xFF)) { HasBitSetters::set_has_camera_timestamp(&_has_bits_); DO_((::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::ReadPrimitive< ::PROTOBUF_NAMESPACE_ID::uint64, ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::TYPE_UINT64>( input, &camera_timestamp_))); } else { goto handle_unusual; } break; } // optional uint64 radar_timestamp = 6; case 6: { if (static_cast< ::PROTOBUF_NAMESPACE_ID::uint8>(tag) == (48 & 0xFF)) { HasBitSetters::set_has_radar_timestamp(&_has_bits_); DO_((::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::ReadPrimitive< ::PROTOBUF_NAMESPACE_ID::uint64, ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::TYPE_UINT64>( input, &radar_timestamp_))); } else { goto handle_unusual; } break; } // optional uint32 version = 7 [default = 1]; case 7: { if (static_cast< ::PROTOBUF_NAMESPACE_ID::uint8>(tag) == (56 & 0xFF)) { HasBitSetters::set_has_version(&_has_bits_); DO_((::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::ReadPrimitive< ::PROTOBUF_NAMESPACE_ID::uint32, ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::TYPE_UINT32>( input, &version_))); } else { goto handle_unusual; } break; } // optional .apollo.common.StatusPb status = 8; case 8: { if (static_cast< ::PROTOBUF_NAMESPACE_ID::uint8>(tag) == (66 & 0xFF)) { DO_(::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::ReadMessage( input, mutable_status())); } else { goto handle_unusual; } break; } // optional string frame_id = 9; case 9: { if (static_cast< ::PROTOBUF_NAMESPACE_ID::uint8>(tag) == (74 & 0xFF)) { DO_(::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::ReadString( input, this->mutable_frame_id())); ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField( this->frame_id().data(), static_cast<int>(this->frame_id().length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::PARSE, "apollo.common.Header.frame_id"); } else { goto handle_unusual; } break; } default: { handle_unusual: if (tag == 0) { goto success; } DO_(::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SkipField( input, tag, _internal_metadata_.mutable_unknown_fields())); break; } } } success: // @@protoc_insertion_point(parse_success:apollo.common.Header) return true; failure: // @@protoc_insertion_point(parse_failure:apollo.common.Header) return false; #undef DO_ } #endif // GOOGLE_PROTOBUF_ENABLE_EXPERIMENTAL_PARSER void Header::SerializeWithCachedSizes( ::PROTOBUF_NAMESPACE_ID::io::CodedOutputStream* output) const { // @@protoc_insertion_point(serialize_start:apollo.common.Header) ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; (void) cached_has_bits; cached_has_bits = _has_bits_[0]; // optional double timestamp_sec = 1; if (cached_has_bits & 0x00000008u) { ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteDouble(1, this->timestamp_sec(), output); } // optional string module_name = 2; if (cached_has_bits & 0x00000001u) { ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField( this->module_name().data(), static_cast<int>(this->module_name().length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE, "apollo.common.Header.module_name"); ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteStringMaybeAliased( 2, this->module_name(), output); } // optional uint32 sequence_num = 3; if (cached_has_bits & 0x00000080u) { ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteUInt32(3, this->sequence_num(), output); } // optional uint64 lidar_timestamp = 4; if (cached_has_bits & 0x00000010u) { ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteUInt64(4, this->lidar_timestamp(), output); } // optional uint64 camera_timestamp = 5; if (cached_has_bits & 0x00000020u) { ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteUInt64(5, this->camera_timestamp(), output); } // optional uint64 radar_timestamp = 6; if (cached_has_bits & 0x00000040u) { ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteUInt64(6, this->radar_timestamp(), output); } // optional uint32 version = 7 [default = 1]; if (cached_has_bits & 0x00000100u) { ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteUInt32(7, this->version(), output); } // optional .apollo.common.StatusPb status = 8; if (cached_has_bits & 0x00000004u) { ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteMessageMaybeToArray( 8, HasBitSetters::status(this), output); } // optional string frame_id = 9; if (cached_has_bits & 0x00000002u) { ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField( this->frame_id().data(), static_cast<int>(this->frame_id().length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE, "apollo.common.Header.frame_id"); ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteStringMaybeAliased( 9, this->frame_id(), output); } if (_internal_metadata_.have_unknown_fields()) { ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SerializeUnknownFields( _internal_metadata_.unknown_fields(), output); } // @@protoc_insertion_point(serialize_end:apollo.common.Header) } ::PROTOBUF_NAMESPACE_ID::uint8* Header::InternalSerializeWithCachedSizesToArray( ::PROTOBUF_NAMESPACE_ID::uint8* target) const { // @@protoc_insertion_point(serialize_to_array_start:apollo.common.Header) ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; (void) cached_has_bits; cached_has_bits = _has_bits_[0]; // optional double timestamp_sec = 1; if (cached_has_bits & 0x00000008u) { target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteDoubleToArray(1, this->timestamp_sec(), target); } // optional string module_name = 2; if (cached_has_bits & 0x00000001u) { ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField( this->module_name().data(), static_cast<int>(this->module_name().length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE, "apollo.common.Header.module_name"); target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteStringToArray( 2, this->module_name(), target); } // optional uint32 sequence_num = 3; if (cached_has_bits & 0x00000080u) { target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteUInt32ToArray(3, this->sequence_num(), target); } // optional uint64 lidar_timestamp = 4; if (cached_has_bits & 0x00000010u) { target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteUInt64ToArray(4, this->lidar_timestamp(), target); } // optional uint64 camera_timestamp = 5; if (cached_has_bits & 0x00000020u) { target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteUInt64ToArray(5, this->camera_timestamp(), target); } // optional uint64 radar_timestamp = 6; if (cached_has_bits & 0x00000040u) { target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteUInt64ToArray(6, this->radar_timestamp(), target); } // optional uint32 version = 7 [default = 1]; if (cached_has_bits & 0x00000100u) { target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteUInt32ToArray(7, this->version(), target); } // optional .apollo.common.StatusPb status = 8; if (cached_has_bits & 0x00000004u) { target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: InternalWriteMessageToArray( 8, HasBitSetters::status(this), target); } // optional string frame_id = 9; if (cached_has_bits & 0x00000002u) { ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField( this->frame_id().data(), static_cast<int>(this->frame_id().length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE, "apollo.common.Header.frame_id"); target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteStringToArray( 9, this->frame_id(), target); } if (_internal_metadata_.have_unknown_fields()) { target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SerializeUnknownFieldsToArray( _internal_metadata_.unknown_fields(), target); } // @@protoc_insertion_point(serialize_to_array_end:apollo.common.Header) return target; } size_t Header::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:apollo.common.Header) size_t total_size = 0; if (_internal_metadata_.have_unknown_fields()) { total_size += ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::ComputeUnknownFieldsSize( _internal_metadata_.unknown_fields()); } ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; // Prevent compiler warnings about cached_has_bits being unused (void) cached_has_bits; cached_has_bits = _has_bits_[0]; if (cached_has_bits & 0x000000ffu) { // optional string module_name = 2; if (cached_has_bits & 0x00000001u) { total_size += 1 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( this->module_name()); } // optional string frame_id = 9; if (cached_has_bits & 0x00000002u) { total_size += 1 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( this->frame_id()); } // optional .apollo.common.StatusPb status = 8; if (cached_has_bits & 0x00000004u) { total_size += 1 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( *status_); } // optional double timestamp_sec = 1; if (cached_has_bits & 0x00000008u) { total_size += 1 + 8; } // optional uint64 lidar_timestamp = 4; if (cached_has_bits & 0x00000010u) { total_size += 1 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::UInt64Size( this->lidar_timestamp()); } // optional uint64 camera_timestamp = 5; if (cached_has_bits & 0x00000020u) { total_size += 1 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::UInt64Size( this->camera_timestamp()); } // optional uint64 radar_timestamp = 6; if (cached_has_bits & 0x00000040u) { total_size += 1 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::UInt64Size( this->radar_timestamp()); } // optional uint32 sequence_num = 3; if (cached_has_bits & 0x00000080u) { total_size += 1 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::UInt32Size( this->sequence_num()); } } // optional uint32 version = 7 [default = 1]; if (cached_has_bits & 0x00000100u) { total_size += 1 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::UInt32Size( this->version()); } int cached_size = ::PROTOBUF_NAMESPACE_ID::internal::ToCachedSize(total_size); SetCachedSize(cached_size); return total_size; } void Header::MergeFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) { // @@protoc_insertion_point(generalized_merge_from_start:apollo.common.Header) GOOGLE_DCHECK_NE(&from, this); const Header* source = ::PROTOBUF_NAMESPACE_ID::DynamicCastToGenerated<Header>( &from); if (source == nullptr) { // @@protoc_insertion_point(generalized_merge_from_cast_fail:apollo.common.Header) ::PROTOBUF_NAMESPACE_ID::internal::ReflectionOps::Merge(from, this); } else { // @@protoc_insertion_point(generalized_merge_from_cast_success:apollo.common.Header) MergeFrom(*source); } } void Header::MergeFrom(const Header& from) { // @@protoc_insertion_point(class_specific_merge_from_start:apollo.common.Header) GOOGLE_DCHECK_NE(&from, this); _internal_metadata_.MergeFrom(from._internal_metadata_); ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; (void) cached_has_bits; cached_has_bits = from._has_bits_[0]; if (cached_has_bits & 0x000000ffu) { if (cached_has_bits & 0x00000001u) { _has_bits_[0] |= 0x00000001u; module_name_.AssignWithDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from.module_name_); } if (cached_has_bits & 0x00000002u) { _has_bits_[0] |= 0x00000002u; frame_id_.AssignWithDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from.frame_id_); } if (cached_has_bits & 0x00000004u) { mutable_status()->::apollo::common::StatusPb::MergeFrom(from.status()); } if (cached_has_bits & 0x00000008u) { timestamp_sec_ = from.timestamp_sec_; } if (cached_has_bits & 0x00000010u) { lidar_timestamp_ = from.lidar_timestamp_; } if (cached_has_bits & 0x00000020u) { camera_timestamp_ = from.camera_timestamp_; } if (cached_has_bits & 0x00000040u) { radar_timestamp_ = from.radar_timestamp_; } if (cached_has_bits & 0x00000080u) { sequence_num_ = from.sequence_num_; } _has_bits_[0] |= cached_has_bits; } if (cached_has_bits & 0x00000100u) { set_version(from.version()); } } void Header::CopyFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) { // @@protoc_insertion_point(generalized_copy_from_start:apollo.common.Header) if (&from == this) return; Clear(); MergeFrom(from); } void Header::CopyFrom(const Header& from) { // @@protoc_insertion_point(class_specific_copy_from_start:apollo.common.Header) if (&from == this) return; Clear(); MergeFrom(from); } bool Header::IsInitialized() const { return true; } void Header::Swap(Header* other) { if (other == this) return; InternalSwap(other); } void Header::InternalSwap(Header* other) { using std::swap; _internal_metadata_.Swap(&other->_internal_metadata_); swap(_has_bits_[0], other->_has_bits_[0]); module_name_.Swap(&other->module_name_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); frame_id_.Swap(&other->frame_id_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual()); swap(status_, other->status_); swap(timestamp_sec_, other->timestamp_sec_); swap(lidar_timestamp_, other->lidar_timestamp_); swap(camera_timestamp_, other->camera_timestamp_); swap(radar_timestamp_, other->radar_timestamp_); swap(sequence_num_, other->sequence_num_); swap(version_, other->version_); } ::PROTOBUF_NAMESPACE_ID::Metadata Header::GetMetadata() const { return GetMetadataStatic(); } // @@protoc_insertion_point(namespace_scope) } // namespace common } // namespace apollo PROTOBUF_NAMESPACE_OPEN template<> PROTOBUF_NOINLINE ::apollo::common::Header* Arena::CreateMaybeMessage< ::apollo::common::Header >(Arena* arena) { return Arena::CreateInternal< ::apollo::common::Header >(arena); } PROTOBUF_NAMESPACE_CLOSE // @@protoc_insertion_point(global_scope) #include <google/protobuf/port_undef.inc>
[ "626786864@qq.com" ]
626786864@qq.com
91af281783c266d8ccb3bdbad9861b91dc0b97f1
59179e4f655a40b421fa9aeda9c90736b8c11b1b
/compiler/.history/lab1/lexical_20210415000532.cpp
b38da7643d895bb2dd7861667fe6c3a3e71bd5be
[]
no_license
wjw136/course_designing_project
ccd39da420f0de22b39fa2fea032054f4cbe8bfd
2614928bd779bc0d996857b123e2862836d81333
refs/heads/master
2023-06-04T12:52:40.501335
2021-06-17T13:19:23
2021-06-17T13:19:23
374,384,252
0
0
null
null
null
null
GB18030
C++
false
false
9,217
cpp
#include <iostream> #include <windows.h> #include <string.h> #include <queue> #include <math.h> #include "stdio.h" #include <fstream> #include <map> #define ll long long #define inf 100000 #define clr1(a) memset(a, -1, sizeof(a)) #define clr(a) memset(a, 0, sizeof(a)) using namespace std; //reserved word static char reserveword[35][20] = { "and", "array", "begin", "bool", "call", "case", "char", "constant", "dim", "do", "else", "end", "false", "for", "if", "input", "integer", "not", "of", "or", "output", "procedure", "program", "read", "real", "repeat", "set", "stop", "then", "to", "true", "until", "var", "while", "write"}; //operator static char myoperator[22][10] = { "(", ")", "*", "*/", "+", ",", "-", "..", "/", "/*", ":", ":=", ";", "<", "<=", "<>", "=", ">", ">=", "[", "]"}; bool isDigit(char ch) { if (ch >= '0' && ch <= '9') return true; else { return false; } } bool isLetter(char ch) { if ((ch >= 'a' && ch <= 'z') || (ch <= 'Z' && ch >= 'A') || ch == '_') return true; else { return false; } } int isReserve(char *s) { for (int i = 0; i < 35; ++i) { if (strcmp(reserveword[i], s) == 0) { return i + 1; } } return -1; } //filter int row = 1; void filter(char *s, int len) { row = 1; char tmp[10000]; int p = 0; for (int i = 0; i < len; ++i) { //注释 if (s[i] == '/' && s[i + 1] == '*') { i += 2; while (s[i] != '*' || s[i + 1] != '/') { if (s[i] == '\0' || s[i] == '\n') { cout << "Annotation error!" << endl; exit(0); } i++; } i += 2; } //检查字符串 if (s[i] == '\'') { tmp[p++] = s[i++]; while (s[i] != '\'') { if (s[i] == '\n' || s[i] == '\0') { printf("字符串(单引号) error!, row: %d\n", row); exit(0); } tmp[p++] = s[i++]; } } //检查括号 if (s[i] == '(') { tmp[p++] = s[i++]; while (s[i] != ')') { if (s[i] == '\0') { printf("括号 error!, row: %d\n", row); exit(0); } tmp[p++] = s[i++]; } } //检查[] if (s[i] == '[') { tmp[p++] = s[i++]; while (s[i] != ']') { if (s[i] == '\0') { printf("[] error!, row: %d\n", row); exit(0); } tmp[p++] = s[i++]; } } //去除换行等 if (s[i] != '\n' && s[i] != '\t' && s[i] != '\v' && s[i] != '\r') { tmp[p] = s[i]; p++; //i++; } else { if (s[i] == '\n') row++; tmp[p++] = ' '; } } tmp[p] = '\0'; strcpy(s, tmp); } //scanner void scanner(int &syn, char *project, char *token, int &p) { int count = 0; char ch; ch = project[p]; while (ch == ' ') { //white space ++p; ch = project[p]; } for (int i = 0; i < 20; i++) { token[i] = '\0'; } if (isLetter(project[p])) { token[count++] = project[p++]; //cout<<isLetter(project[p])<<endl; while (isLetter(project[p]) || isDigit(project[p])) { //cout<<project[p]<<endl; token[count++] = project[p++]; } token[count] = '\0'; syn = isReserve(token); if (syn == -1) { syn = 36; } return; } else if (isDigit(project[p])) { token[count++] = project[p++]; while (isDigit(project[p])) { token[count++] = project[p++]; } if (isLetter(project[p])) { cout << "symbol begin with digit wrong!" << endl; exit(0); } token[count] = '\0'; syn = 37; return; } else if (ch == '<') { //可能是< <= << token[count++] = project[p]; ++p; if (project[p] == '=') //<= { token[count++] = project[p]; syn = 54; } else if (project[p] == '>') //<< { token[count++] = project[p]; syn = 55; } else //< { --p; syn = 53; } ++p; return; } else if (ch == '>') { //可能是> >= >> token[count++] = project[p]; ++p; if (project[p] == '=') //>= { token[count++] = project[p]; syn = 58; } else //> { --p; syn = 57; } ++p; return; } else if (ch == ':') { //可能是: := token[count++] = project[p]; ++p; if (project[p] == '=') //>= { token[count++] = project[p]; syn = 51; } else //> { --p; syn = 50; } ++p; return; } else if (ch == '.') { //可能是. .. token[count++] = project[p]; ++p; if (project[p] == '.') //>= { syn = 47; token[count++] = project[p]; } else //> { --p; syn = 46; } ++p; return; } else if (ch == '\0') //文件结束 { syn = 0; } else if (ch == '\'') { token[count++] = project[p++]; //cout<<project[p]; while (project[p] != '\'') { token[count++] = project[p++]; // } token[count++] = project[p++]; syn = 38; } else { switch (project[p]) { case '(': syn = 39; break; case ')': syn = 40; break; case '*': syn = 41; break; case '+': syn = 43; break; case ',': syn = 44; break; case '-': syn = 45; break; case '/': syn = 48; break; case ';': syn = 52; break; case '=': syn = 56; break; case '[': syn = 59; break; case ']': syn = 60; break; //无法匹配 default: //非法字符,提示并自动跳过 syn = -2; } token[count++] = project[p++]; } } map<string, int> mp; int main() { mp.clear(); //cout << "我i"; cout<<"王建伟 19计联 201930420160"<<endl; cout << "键入程序名: "; string s; //cin>>s; while (cin >> s) { ifstream fin(s + ".txt"); if (!fin) { cout << "The program not exists!" << endl; } else { char project[10000]; int p = 0; //fin.get(project[p++]); while (fin.peek() != EOF) { fin.get(project[p++]); //cout<<project[p-1]<<endl; } //cout << project << endl; project[p++] = '\0'; fin.close(); //cout << project << endl; filter(project, p - 1); //cout << project << endl; p = 0; int syn = -1; char token[20] = {}; //cout<<project<<endl; int cnt = 0; int cnt1 = 0; while (true) { scanner(syn, project, token, p); //cout<<syn<<endl; if (syn == 0) break; else if (syn == -2) { printf("(非法字符, %s)\t\n", token); cnt1++; } else if (syn == 36 || syn == 37) { //cout<<mp.count("37")<<endl; int tmp = cnt; if (mp.count(token)) { tmp = mp[token]; } else { cnt++; tmp = cnt; mp[token] = cnt; } printf("(%d, %d)\t\n", syn, tmp); cnt1++; } else { //cout<<setw(10) printf("(%d, ~)\t\n", syn); cnt1++; } if (cnt1 % 5 == 0) { cout << endl; } } } cout << "键入程序名: "; } return 0; }
[ "2831419633@qq.com" ]
2831419633@qq.com
1a7b9d6dc1138debf7bc72ae010037d6c396c77a
01a42b69633daf62a2eb3bb70c5b1b6e2639aa5f
/SCUM_Dog_Rose_functions.cpp
86653003c0333374c3fd9c9cd67f071ed9df084b
[]
no_license
Kehczar/scum_sdk
45db80e46dac736cc7370912ed671fa77fcb95cf
8d1770b44321a9d0b277e4029551f39b11f15111
refs/heads/master
2022-07-25T10:06:20.892750
2020-05-21T11:45:36
2020-05-21T11:45:36
265,826,541
1
0
null
null
null
null
UTF-8
C++
false
false
4,739
cpp
// Scum 3.79.22573 (UE 4.24) #ifdef _MSC_VER #pragma pack(push, 0x8) #endif #include "../SDK.hpp" namespace Classes { //--------------------------------------------------------------------------- //Functions //--------------------------------------------------------------------------- // Function ConZ.FoodItem.OnRep_Temperature // () void ADog_Rose_C::OnRep_Temperature() { static auto fn = UObject::FindObject<UFunction>("Function ConZ.FoodItem.OnRep_Temperature"); ADog_Rose_C_OnRep_Temperature_Params params; auto flags = fn->FunctionFlags; UObject::ProcessEvent(fn, &params); fn->FunctionFlags = flags; } // Function ConZ.FoodItem.OnRep_ItemOpened // () void ADog_Rose_C::OnRep_ItemOpened() { static auto fn = UObject::FindObject<UFunction>("Function ConZ.FoodItem.OnRep_ItemOpened"); ADog_Rose_C_OnRep_ItemOpened_Params params; auto flags = fn->FunctionFlags; UObject::ProcessEvent(fn, &params); fn->FunctionFlags = flags; } // Function ConZ.FoodItem.OnRep_IsCooking // () void ADog_Rose_C::OnRep_IsCooking() { static auto fn = UObject::FindObject<UFunction>("Function ConZ.FoodItem.OnRep_IsCooking"); ADog_Rose_C_OnRep_IsCooking_Params params; auto flags = fn->FunctionFlags; UObject::ProcessEvent(fn, &params); fn->FunctionFlags = flags; } // Function ConZ.FoodItem.OnAudioComponentExpired // () void ADog_Rose_C::OnAudioComponentExpired() { static auto fn = UObject::FindObject<UFunction>("Function ConZ.FoodItem.OnAudioComponentExpired"); ADog_Rose_C_OnAudioComponentExpired_Params params; auto flags = fn->FunctionFlags; UObject::ProcessEvent(fn, &params); fn->FunctionFlags = flags; } // Function ConZ.FoodItem.IsCooking // () // Parameters: // bool ReturnValue (Parm, OutParm, ZeroConstructor, ReturnParm, IsPlainOldData) bool ADog_Rose_C::IsCooking() { static auto fn = UObject::FindObject<UFunction>("Function ConZ.FoodItem.IsCooking"); ADog_Rose_C_IsCooking_Params params; auto flags = fn->FunctionFlags; UObject::ProcessEvent(fn, &params); fn->FunctionFlags = flags; return params.ReturnValue; } // Function ConZ.FoodItem.GetVolume // () // Parameters: // float ReturnValue (Parm, OutParm, ZeroConstructor, ReturnParm, IsPlainOldData) float ADog_Rose_C::GetVolume() { static auto fn = UObject::FindObject<UFunction>("Function ConZ.FoodItem.GetVolume"); ADog_Rose_C_GetVolume_Params params; auto flags = fn->FunctionFlags; UObject::ProcessEvent(fn, &params); fn->FunctionFlags = flags; return params.ReturnValue; } // Function ConZ.FoodItem.GetThermalConductivityFactor // () // Parameters: // float ReturnValue (Parm, OutParm, ZeroConstructor, ReturnParm, IsPlainOldData) float ADog_Rose_C::GetThermalConductivityFactor() { static auto fn = UObject::FindObject<UFunction>("Function ConZ.FoodItem.GetThermalConductivityFactor"); ADog_Rose_C_GetThermalConductivityFactor_Params params; auto flags = fn->FunctionFlags; UObject::ProcessEvent(fn, &params); fn->FunctionFlags = flags; return params.ReturnValue; } // Function ConZ.FoodItem.GetTemperature // () // Parameters: // float ReturnValue (Parm, OutParm, ZeroConstructor, ReturnParm, IsPlainOldData) float ADog_Rose_C::GetTemperature() { static auto fn = UObject::FindObject<UFunction>("Function ConZ.FoodItem.GetTemperature"); ADog_Rose_C_GetTemperature_Params params; auto flags = fn->FunctionFlags; UObject::ProcessEvent(fn, &params); fn->FunctionFlags = flags; return params.ReturnValue; } // Function ConZ.FoodItem.GetEnvironmentTemperature // () // Parameters: // float ReturnValue (Parm, OutParm, ZeroConstructor, ReturnParm, IsPlainOldData) float ADog_Rose_C::GetEnvironmentTemperature() { static auto fn = UObject::FindObject<UFunction>("Function ConZ.FoodItem.GetEnvironmentTemperature"); ADog_Rose_C_GetEnvironmentTemperature_Params params; auto flags = fn->FunctionFlags; UObject::ProcessEvent(fn, &params); fn->FunctionFlags = flags; return params.ReturnValue; } // Function ConZ.FoodItem.GetCookingAmount // () // Parameters: // float ReturnValue (Parm, OutParm, ZeroConstructor, ReturnParm, IsPlainOldData) float ADog_Rose_C::GetCookingAmount() { static auto fn = UObject::FindObject<UFunction>("Function ConZ.FoodItem.GetCookingAmount"); ADog_Rose_C_GetCookingAmount_Params params; auto flags = fn->FunctionFlags; UObject::ProcessEvent(fn, &params); fn->FunctionFlags = flags; return params.ReturnValue; } } #ifdef _MSC_VER #pragma pack(pop) #endif
[ "65712402+Kehczar@users.noreply.github.com" ]
65712402+Kehczar@users.noreply.github.com
a3b4d55117dd60a26d1174e513fec99e84c08868
54d7ffe58f84ecd76aae4e51dff7dd2802e0a5dc
/src/old_classes/SF_WjetsREWGT.cxx
66f493f104e02b509e8890bbfb83a3d352062fa8
[]
no_license
denschwarz/MTopJet-1
d9f29e64b2e4f1daaf474c8941c96d7843838e48
961171ecf55cc362989e56922753c0cbab178010
refs/heads/master
2021-01-11T01:33:10.488612
2016-10-11T12:20:59
2016-10-11T12:20:59
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,294
cxx
#include <UHH2/MTopJet/include/SF_WjetsREWGT.h> weightcalc_WjetsREWGT::weightcalc_WjetsREWGT() {} float weightcalc_WjetsREWGT::weight(const uhh2::Event& evt_) const { if(evt_.isRealData) return 1.; float wgt(1.); assert(evt_.genparticles); const GenParticle* genW_ptr = genW(*evt_.genparticles); if(genW_ptr){ const auto& gen_W = *genW_ptr; wgt = weightcalc_WjetsREWGT::kfactor_QCD(gen_W); wgt *= weightcalc_WjetsREWGT::kfactor_EWK(gen_W); } else wgt = 1.; return wgt; } float weightcalc_WjetsREWGT::kfactor_QCD(const GenParticle& genw) const { float K(1.); const float wpt = genw.pt(); if (wpt < 150.) K = 1.89123;// 1.685005; else if(wpt < 200.) K = 1.70414;// 1.552560; else if(wpt < 250.) K = 1.60726;// 1.522595; else if(wpt < 300.) K = 1.57206;// 1.520624; else if(wpt < 350.) K = 1.51689;// 1.432282; else if(wpt < 400.) K = 1.41090;// 1.457417; else if(wpt < 500.) K = 1.30758;// 1.368499; else if(wpt < 600.) K = 1.32046;// 1.358024; else K = 1.26853;// 1.164847; return K; } float weightcalc_WjetsREWGT::kfactor_EWK(const GenParticle& genw) const { float K(1.); const float wpt = genw.pt(); if (wpt < 150.) K = 0.980859;// 0.984525; else if(wpt < 200.) K = 0.962119;// 0.969079; else if(wpt < 250.) K = 0.944429;// 0.954627; else if(wpt < 300.) K = 0.927686;// 0.941059; else if(wpt < 350.) K = 0.911802;// 0.928284; else if(wpt < 400.) K = 0.896700;// 0.916220; else if(wpt < 500.) K = 0.875368;// 0.899312; else if(wpt < 600.) K = 0.849097;// 0.878693; else K = 0.792159;// 0.834718; return K; } const GenParticle* weightcalc_WjetsREWGT::genW(const std::vector<GenParticle>& genps) const { const GenParticle* p(0); unsigned int W_N(0); for(const auto& genp : genps){ const bool is_me = (20 <= genp.status() && genp.status() <= 30); if(!is_me) continue; const bool has_mo1 = (genp.mother1() != (unsigned short)(-1)); if(!has_mo1) continue; const bool has_mo2 = (genp.mother2() != (unsigned short)(-1)); if(!has_mo2) continue; const bool is_W = (std::abs(genp.pdgId()) == 24); if(!is_W) continue; if(is_W){ if(W_N > 0){ p = 0; break; } p = &genp; ++W_N; } } return p; }
[ "dennnis.schwarz@desy.de" ]
dennnis.schwarz@desy.de
3d09332c72d9db0577f8bb7c397a604f5d273e1e
c24b5c1f14828769703dac4be36866944454a209
/cpp/osoba/osoba.cpp
a147f4fa5da758269cdf1f1191f37ef04ea6d235
[]
no_license
Matix426/gitrepo
941792a56b6575bc9018d24a35c824630e112e4c
31430958ad47551ce1713d5f8263e865ba14a49b
refs/heads/master
2021-07-10T00:02:45.406676
2019-03-22T12:30:47
2019-03-22T12:30:47
103,923,089
0
0
null
null
null
null
UTF-8
C++
false
false
67,650
cpp
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <link rel="dns-prefetch" href="https://github.githubassets.com"> <link rel="dns-prefetch" href="https://avatars0.githubusercontent.com"> <link rel="dns-prefetch" href="https://avatars1.githubusercontent.com"> <link rel="dns-prefetch" href="https://avatars2.githubusercontent.com"> <link rel="dns-prefetch" href="https://avatars3.githubusercontent.com"> <link rel="dns-prefetch" href="https://github-cloud.s3.amazonaws.com"> <link rel="dns-prefetch" href="https://user-images.githubusercontent.com/"> <link crossorigin="anonymous" media="all" integrity="sha512-7uoDIEGQ8zTwUS9KjTP+/2I13FQPHvJ9EKoeUThfin5R1+27bcUC08VQzUo4CIjCdhvJM4zxuI+3HcSycAUTCg==" rel="stylesheet" href="https://github.githubassets.com/assets/frameworks-abba74d6e28a6842788159fec056bf26.css" /> <link crossorigin="anonymous" media="all" integrity="sha512-5LDBQ/DhsFq/ry7aepdbc1FV0mW/0lPqH6GlYFfzzd5wo8MBz9Rb67LigKe0uKM8kK5QrA/QsJCpsE1+hOLF6w==" rel="stylesheet" href="https://github.githubassets.com/assets/site-0e25450ff46c1fbf61d504f9ffc4d784.css" /> <link crossorigin="anonymous" media="all" integrity="sha512-jiYfuCC6laAkC/UmxmKA8LyJf0P7Tnr/Spj2/FaAntS9JxlHc5qy/spf/hZy1IiTPbsL2fQ7HGm54wsTQqD1sg==" rel="stylesheet" href="https://github.githubassets.com/assets/github-c21717b983d9e056fa427742984a76c0.css" /> <meta name="viewport" content="width=device-width"> <title>gitrepo/osoba.cpp at master · gabusiaaa2310/gitrepo · GitHub</title> <meta name="description" content="Repozytorium z kodami na informatykę. Contribute to gabusiaaa2310/gitrepo development by creating an account on GitHub."> <link rel="search" type="application/opensearchdescription+xml" href="/opensearch.xml" title="GitHub"> <link rel="fluid-icon" href="https://github.com/fluidicon.png" title="GitHub"> <meta property="fb:app_id" content="1401488693436528"> <meta property="og:image" content="https://avatars0.githubusercontent.com/u/32060924?s=400&amp;v=4" /><meta property="og:site_name" content="GitHub" /><meta property="og:type" content="object" /><meta property="og:title" content="gabusiaaa2310/gitrepo" /><meta property="og:url" content="https://github.com/gabusiaaa2310/gitrepo" /><meta property="og:description" content="Repozytorium z kodami na informatykę. Contribute to gabusiaaa2310/gitrepo development by creating an account on GitHub." /> <link rel="assets" href="https://github.githubassets.com/"> <meta name="pjax-timeout" content="1000"> <meta name="request-id" content="EB5A:158F2:1A2BD46:26C242F:5C94C0DE" data-pjax-transient> <meta name="selected-link" value="repo_source" data-pjax-transient> <meta name="google-site-verification" content="KT5gs8h0wvaagLKAVWq8bbeNwnZZK1r1XQysX3xurLU"> <meta name="google-site-verification" content="ZzhVyEFwb7w3e0-uOTltm8Jsck2F5StVihD0exw2fsA"> <meta name="google-site-verification" content="GXs5KoUUkNCoaAZn7wPN-t01Pywp9M3sEjnt_3_ZWPc"> <meta name="octolytics-host" content="collector.githubapp.com" /><meta name="octolytics-app-id" content="github" /><meta name="octolytics-event-url" content="https://collector.githubapp.com/github-external/browser_event" /><meta name="octolytics-dimension-request_id" content="EB5A:158F2:1A2BD46:26C242F:5C94C0DE" /><meta name="octolytics-dimension-region_edge" content="ams" /><meta name="octolytics-dimension-region_render" content="iad" /> <meta name="analytics-location" content="/&lt;user-name&gt;/&lt;repo-name&gt;/blob/show" data-pjax-transient="true" /> <meta name="google-analytics" content="UA-3769691-2"> <meta class="js-ga-set" name="dimension1" content="Logged Out"> <meta name="hostname" content="github.com"> <meta name="user-login" content=""> <meta name="expected-hostname" content="github.com"> <meta name="js-proxy-site-detection-payload" content="OTFjMDI1OTQ1NTNkZjE0MjZjZWUwZjc0NTgyYWFkMTA2YWViZDg2OTQwZDlkYjYyNTVlMTY5YjVkYzExZGU3Mnx7InJlbW90ZV9hZGRyZXNzIjoiNzkuMTg1LjkxLjMyIiwicmVxdWVzdF9pZCI6IkVCNUE6MTU4RjI6MUEyQkQ0NjoyNkMyNDJGOjVDOTRDMERFIiwidGltZXN0YW1wIjoxNTUzMjUyNTc4LCJob3N0IjoiZ2l0aHViLmNvbSJ9"> <meta name="enabled-features" content="UNIVERSE_BANNER,MARKETPLACE_SOCIAL_PROOF,MARKETPLACE_SOCIAL_PROOF_CUSTOMERS,MARKETPLACE_TRENDING_SOCIAL_PROOF,MARKETPLACE_PLAN_RESTRICTION_EDITOR"> <meta name="html-safe-nonce" content="bb20b12a09b0612957d355814b8cab59c5283b16"> <meta http-equiv="x-pjax-version" content="4c8b486b1a16d92c57dc17fb514ee52a"> <link href="https://github.com/gabusiaaa2310/gitrepo/commits/master.atom" rel="alternate" title="Recent Commits to gitrepo:master" type="application/atom+xml"> <meta name="go-import" content="github.com/gabusiaaa2310/gitrepo git https://github.com/gabusiaaa2310/gitrepo.git"> <meta name="octolytics-dimension-user_id" content="32060924" /><meta name="octolytics-dimension-user_login" content="gabusiaaa2310" /><meta name="octolytics-dimension-repository_id" content="103923132" /><meta name="octolytics-dimension-repository_nwo" content="gabusiaaa2310/gitrepo" /><meta name="octolytics-dimension-repository_public" content="true" /><meta name="octolytics-dimension-repository_is_fork" content="false" /><meta name="octolytics-dimension-repository_network_root_id" content="103923132" /><meta name="octolytics-dimension-repository_network_root_nwo" content="gabusiaaa2310/gitrepo" /><meta name="octolytics-dimension-repository_explore_github_marketplace_ci_cta_shown" content="false" /> <link rel="canonical" href="https://github.com/gabusiaaa2310/gitrepo/blob/master/cpp/osoba/osoba.cpp" data-pjax-transient> <meta name="browser-stats-url" content="https://api.github.com/_private/browser/stats"> <meta name="browser-errors-url" content="https://api.github.com/_private/browser/errors"> <link rel="mask-icon" href="https://github.githubassets.com/pinned-octocat.svg" color="#000000"> <link rel="icon" type="image/x-icon" class="js-site-favicon" href="https://github.githubassets.com/favicon.ico"> <meta name="theme-color" content="#1e2327"> <link rel="manifest" href="/manifest.json" crossOrigin="use-credentials"> </head> <body class="logged-out env-production page-blob"> <div class="position-relative js-header-wrapper "> <a href="#start-of-content" tabindex="1" class="px-2 py-4 bg-blue text-white show-on-focus js-skip-to-content">Skip to content</a> <div id="js-pjax-loader-bar" class="pjax-loader-bar"><div class="progress"></div></div> <header class="Header-old header-logged-out position-relative f4 py-3" role="banner"> <div class="container-lg d-flex px-3"> <div class="d-flex flex-justify-between flex-items-center"> <a class="mr-4" href="https://github.com/" aria-label="Homepage" data-ga-click="(Logged out) Header, go to homepage, icon:logo-wordmark"> <svg height="32" class="octicon octicon-mark-github text-white" viewBox="0 0 16 16" version="1.1" width="32" aria-hidden="true"><path fill-rule="evenodd" d="M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.013 8.013 0 0 0 16 8c0-4.42-3.58-8-8-8z"/></svg> </a> </div> <div class="HeaderMenu HeaderMenu--logged-out d-flex flex-justify-between flex-items-center flex-auto"> <div class="d-none"> <button class="btn-link js-details-target" type="button" aria-label="Toggle navigation" aria-expanded="false"> <svg height="24" class="octicon octicon-x text-gray" viewBox="0 0 12 16" version="1.1" width="18" aria-hidden="true"><path fill-rule="evenodd" d="M7.48 8l3.75 3.75-1.48 1.48L6 9.48l-3.75 3.75-1.48-1.48L4.52 8 .77 4.25l1.48-1.48L6 6.52l3.75-3.75 1.48 1.48L7.48 8z"/></svg> </button> </div> <nav class="mt-0" aria-label="Global"> <ul class="d-flex list-style-none"> <li class=" mr-3 mr-lg-3 edge-item-fix position-relative flex-wrap flex-justify-between d-flex flex-items-center "> <details class="HeaderMenu-details details-overlay details-reset width-full"> <summary class="HeaderMenu-summary HeaderMenu-link px-0 py-3 border-0 no-wrap d-inline-block"> Why GitHub? <svg x="0px" y="0px" viewBox="0 0 14 8" xml:space="preserve" fill="none" class="icon-chevon-down-mktg position-relative"> <path d="M1,1l6.2,6L13,1"></path> </svg> </summary> <div class="dropdown-menu flex-auto rounded-1 bg-white px-0 mt-0 p-4 left-n4 position-absolute"> <a href="/features" class="py-2 lh-condensed-ultra d-block link-gray-dark no-underline h5 Bump-link--hover" data-ga-click="(Logged out) Header, go to Features">Features <span class="Bump-link-symbol float-right text-normal text-gray-light">&rarr;</span></a> <ul class="list-style-none f5 pb-3"> <li class="edge-item-fix"><a href="/features/code-review/" class="py-2 lh-condensed-ultra d-block link-gray no-underline f5" data-ga-click="(Logged out) Header, go to Code review">Code review</a></li> <li class="edge-item-fix"><a href="/features/project-management/" class="py-2 lh-condensed-ultra d-block link-gray no-underline f5" data-ga-click="(Logged out) Header, go to Project management">Project management</a></li> <li class="edge-item-fix"><a href="/features/integrations" class="py-2 lh-condensed-ultra d-block link-gray no-underline f5" data-ga-click="(Logged out) Header, go to Integrations">Integrations</a></li> <li class="edge-item-fix"><a href="/features/actions" class="py-2 lh-condensed-ultra d-block link-gray no-underline f5" data-ga-click="(Logged out) Header, go to Actions">Actions</a> <li class="edge-item-fix"><a href="/features#team-management" class="py-2 lh-condensed-ultra d-block link-gray no-underline f5" data-ga-click="(Logged out) Header, go to Team management">Team management</a></li> <li class="edge-item-fix"><a href="/features#social-coding" class="py-2 lh-condensed-ultra d-block link-gray no-underline f5" data-ga-click="(Logged out) Header, go to Social coding">Social coding</a></li> <li class="edge-item-fix"><a href="/features#documentation" class="py-2 lh-condensed-ultra d-block link-gray no-underline f5" data-ga-click="(Logged out) Header, go to Documentation">Documentation</a></li> <li class="edge-item-fix"><a href="/features#code-hosting" class="py-2 lh-condensed-ultra d-block link-gray no-underline f5" data-ga-click="(Logged out) Header, go to Code hosting">Code hosting</a></li> </ul> <ul class="list-style-none mb-0 border-lg-top pt-lg-3"> <li class="edge-item-fix"><a href="/customer-stories" class="py-2 lh-condensed-ultra d-block no-underline link-gray-dark no-underline h5 Bump-link--hover" data-ga-click="(Logged out) Header, go to Customer stories">Customer stories <span class="Bump-link-symbol float-right text-normal text-gray-light">&rarr;</span></a></li> <li class="edge-item-fix"><a href="/security" class="py-2 lh-condensed-ultra d-block no-underline link-gray-dark no-underline h5 Bump-link--hover" data-ga-click="(Logged out) Header, go to Security">Security <span class="Bump-link-symbol float-right text-normal text-gray-light">&rarr;</span></a></li> </ul> </div> </details> </li> <li class=" mr-3 mr-lg-3"> <a href="/enterprise" class="HeaderMenu-link no-underline py-3 d-block d-lg-inline-block" data-ga-click="(Logged out) Header, go to Enterprise">Enterprise</a> </li> <li class=" mr-3 mr-lg-3 edge-item-fix position-relative flex-wrap flex-justify-between d-flex flex-items-center "> <details class="HeaderMenu-details details-overlay details-reset width-full"> <summary class="HeaderMenu-summary HeaderMenu-link px-0 py-3 border-0 no-wrap d-inline-block"> Explore <svg x="0px" y="0px" viewBox="0 0 14 8" xml:space="preserve" fill="none" class="icon-chevon-down-mktg position-relative"> <path d="M1,1l6.2,6L13,1"></path> </svg> </summary> <div class="dropdown-menu flex-auto rounded-1 bg-white px-0 pt-2 pb-0 mt-0 p-4 left-n4 position-absolute"> <ul class="list-style-none mb-3"> <li class="edge-item-fix"><a href="/explore" class="py-2 lh-condensed-ultra d-block link-gray-dark no-underline h5 Bump-link--hover" data-ga-click="(Logged out) Header, go to Explore">Explore GitHub <span class="Bump-link-symbol float-right text-normal text-gray-light">&rarr;</span></a></li> </ul> <h4 class="text-gray-light text-normal text-mono f5 mb-2 border-top pt-3">Learn &amp; contribute</h4> <ul class="list-style-none mb-3"> <li class="edge-item-fix"><a href="/topics" class="py-2 lh-condensed-ultra d-block link-gray no-underline f5" data-ga-click="(Logged out) Header, go to Topics">Topics</a></li> <li class="edge-item-fix"><a href="/collections" class="py-2 lh-condensed-ultra d-block link-gray no-underline f5" data-ga-click="(Logged out) Header, go to Collections">Collections</a></li> <li class="edge-item-fix"><a href="/trending" class="py-2 lh-condensed-ultra d-block link-gray no-underline f5" data-ga-click="(Logged out) Header, go to Trending">Trending</a></li> <li class="edge-item-fix"><a href="https://lab.github.com/" class="py-2 lh-condensed-ultra d-block link-gray no-underline f5" data-ga-click="(Logged out) Header, go to Learning lab">Learning Lab</a></li> <li class="edge-item-fix"><a href="https://opensource.guide" class="py-2 lh-condensed-ultra d-block link-gray no-underline f5" data-ga-click="(Logged out) Header, go to Open source guides">Open source guides</a></li> </ul> <h4 class="text-gray-light text-normal text-mono f5 mb-2 border-top pt-3">Connect with others</h4> <ul class="list-style-none mb-0"> <li class="edge-item-fix"><a href="https://github.com/events" class="py-2 lh-condensed-ultra d-block link-gray no-underline f5" data-ga-click="(Logged out) Header, go to Events">Events</a></li> <li class="edge-item-fix"><a href="https://github.community" class="py-2 lh-condensed-ultra d-block link-gray no-underline f5" data-ga-click="(Logged out) Header, go to Community forum">Community forum</a></li> <li class="edge-item-fix"><a href="https://education.github.com" class="py-2 pb-0 lh-condensed-ultra d-block link-gray no-underline f5" data-ga-click="(Logged out) Header, go to GitHub Education">GitHub Education</a></li> </ul> </div> </details> </li> <li class=" mr-3 mr-lg-3"> <a href="/marketplace" class="HeaderMenu-link no-underline py-3 d-block d-lg-inline-block" data-ga-click="(Logged out) Header, go to Marketplace">Marketplace</a> </li> <li class=" mr-3 mr-lg-3 edge-item-fix position-relative flex-wrap flex-justify-between d-flex flex-items-center "> <details class="HeaderMenu-details details-overlay details-reset width-full"> <summary class="HeaderMenu-summary HeaderMenu-link px-0 py-3 border-0 no-wrap d-inline-block"> Pricing <svg x="0px" y="0px" viewBox="0 0 14 8" xml:space="preserve" fill="none" class="icon-chevon-down-mktg position-relative"> <path d="M1,1l6.2,6L13,1"></path> </svg> </summary> <div class="dropdown-menu flex-auto rounded-1 bg-white px-0 pt-2 pb-4 mt-0 p-4 left-n4 position-absolute"> <a href="/pricing" class="pb-2 lh-condensed-ultra d-block link-gray-dark no-underline h5 Bump-link--hover" data-ga-click="(Logged out) Header, go to Pricing">Plans <span class="Bump-link-symbol float-right text-normal text-gray-light">&rarr;</span></a> <ul class="list-style-none mb-3"> <li class="edge-item-fix"><a href="/pricing#feature-comparison" class="py-2 lh-condensed-ultra d-block link-gray no-underline f5" data-ga-click="(Logged out) Header, go to Compare plans">Compare plans</a></li> <li class="edge-item-fix"><a href="https://enterprise.github.com/contact" class="py-2 lh-condensed-ultra d-block link-gray no-underline f5" data-ga-click="(Logged out) Header, go to Contact Sales">Contact Sales</a></li> </ul> <ul class="list-style-none mb-0 border-top pt-3"> <li class="edge-item-fix"><a href="/nonprofit" class="py-2 lh-condensed-ultra d-block no-underline link-gray-dark no-underline h5 Bump-link--hover" data-ga-click="(Logged out) Header, go to Nonprofits">Nonprofit <span class="Bump-link-symbol float-right text-normal text-gray-light">&rarr;</span></a></li> <li class="edge-item-fix"><a href="https://education.github.com" class="py-2 pb-0 lh-condensed-ultra d-block no-underline link-gray-dark no-underline h5 Bump-link--hover" data-ga-click="(Logged out) Header, go to Education">Education <span class="Bump-link-symbol float-right text-normal text-gray-light">&rarr;</span></a></li> </ul> </div> </details> </li> </ul> </nav> <div class="d-flex flex-items-center px-0 text-center text-left"> <div class="d-lg-flex "> <div class="header-search mr-3 scoped-search site-scoped-search js-site-search position-relative js-jump-to" role="combobox" aria-owns="jump-to-results" aria-label="Search or jump to" aria-haspopup="listbox" aria-expanded="false" > <div class="position-relative"> <!-- '"` --><!-- </textarea></xmp> --></option></form><form class="js-site-search-form" role="search" aria-label="Site" data-scope-type="Repository" data-scope-id="103923132" data-scoped-search-url="/gabusiaaa2310/gitrepo/search" data-unscoped-search-url="/search" action="/gabusiaaa2310/gitrepo/search" accept-charset="UTF-8" method="get"><input name="utf8" type="hidden" value="&#x2713;" /> <label class="form-control input-sm header-search-wrapper p-0 header-search-wrapper-jump-to position-relative d-flex flex-justify-between flex-items-center js-chromeless-input-container"> <input type="text" class="form-control input-sm header-search-input jump-to-field js-jump-to-field js-site-search-focus js-site-search-field is-clearable" data-hotkey="s,/" name="q" value="" placeholder="Search" data-unscoped-placeholder="Search GitHub" data-scoped-placeholder="Search" autocapitalize="off" aria-autocomplete="list" aria-controls="jump-to-results" aria-label="Search" data-jump-to-suggestions-path="/_graphql/GetSuggestedNavigationDestinations#csrf-token=2iWp+opje+Hcbfj9IHA1FpLvZgAFYkcfhpdWZVU0hc82WYfD/KeACFanAWgZj7Z11uFGlEuX15XtdVGX3p8XsA==" spellcheck="false" autocomplete="off" > <input type="hidden" class="js-site-search-type-field" name="type" > <img src="https://github.githubassets.com/images/search-key-slash.svg" alt="" class="mr-2 header-search-key-slash"> <div class="Box position-absolute overflow-hidden d-none jump-to-suggestions js-jump-to-suggestions-container"> <ul class="d-none js-jump-to-suggestions-template-container"> <li class="d-flex flex-justify-start flex-items-center p-0 f5 navigation-item js-navigation-item js-jump-to-suggestion" role="option"> <a tabindex="-1" class="no-underline d-flex flex-auto flex-items-center jump-to-suggestions-path js-jump-to-suggestion-path js-navigation-open p-2" href=""> <div class="jump-to-octicon js-jump-to-octicon flex-shrink-0 mr-2 text-center d-none"> <svg height="16" width="16" class="octicon octicon-repo flex-shrink-0 js-jump-to-octicon-repo d-none" title="Repository" aria-label="Repository" viewBox="0 0 12 16" version="1.1" role="img"><path fill-rule="evenodd" d="M4 9H3V8h1v1zm0-3H3v1h1V6zm0-2H3v1h1V4zm0-2H3v1h1V2zm8-1v12c0 .55-.45 1-1 1H6v2l-1.5-1.5L3 16v-2H1c-.55 0-1-.45-1-1V1c0-.55.45-1 1-1h10c.55 0 1 .45 1 1zm-1 10H1v2h2v-1h3v1h5v-2zm0-10H2v9h9V1z"/></svg> <svg height="16" width="16" class="octicon octicon-project flex-shrink-0 js-jump-to-octicon-project d-none" title="Project" aria-label="Project" viewBox="0 0 15 16" version="1.1" role="img"><path fill-rule="evenodd" d="M10 12h3V2h-3v10zm-4-2h3V2H6v8zm-4 4h3V2H2v12zm-1 1h13V1H1v14zM14 0H1a1 1 0 0 0-1 1v14a1 1 0 0 0 1 1h13a1 1 0 0 0 1-1V1a1 1 0 0 0-1-1z"/></svg> <svg height="16" width="16" class="octicon octicon-search flex-shrink-0 js-jump-to-octicon-search d-none" title="Search" aria-label="Search" viewBox="0 0 16 16" version="1.1" role="img"><path fill-rule="evenodd" d="M15.7 13.3l-3.81-3.83A5.93 5.93 0 0 0 13 6c0-3.31-2.69-6-6-6S1 2.69 1 6s2.69 6 6 6c1.3 0 2.48-.41 3.47-1.11l3.83 3.81c.19.2.45.3.7.3.25 0 .52-.09.7-.3a.996.996 0 0 0 0-1.41v.01zM7 10.7c-2.59 0-4.7-2.11-4.7-4.7 0-2.59 2.11-4.7 4.7-4.7 2.59 0 4.7 2.11 4.7 4.7 0 2.59-2.11 4.7-4.7 4.7z"/></svg> </div> <img class="avatar mr-2 flex-shrink-0 js-jump-to-suggestion-avatar d-none" alt="" aria-label="Team" src="" width="28" height="28"> <div class="jump-to-suggestion-name js-jump-to-suggestion-name flex-auto overflow-hidden text-left no-wrap css-truncate css-truncate-target"> </div> <div class="border rounded-1 flex-shrink-0 bg-gray px-1 text-gray-light ml-1 f6 d-none js-jump-to-badge-search"> <span class="js-jump-to-badge-search-text-default d-none" aria-label="in this repository"> In this repository </span> <span class="js-jump-to-badge-search-text-global d-none" aria-label="in all of GitHub"> All GitHub </span> <span aria-hidden="true" class="d-inline-block ml-1 v-align-middle">↵</span> </div> <div aria-hidden="true" class="border rounded-1 flex-shrink-0 bg-gray px-1 text-gray-light ml-1 f6 d-none d-on-nav-focus js-jump-to-badge-jump"> Jump to <span class="d-inline-block ml-1 v-align-middle">↵</span> </div> </a> </li> </ul> <ul class="d-none js-jump-to-no-results-template-container"> <li class="d-flex flex-justify-center flex-items-center f5 d-none js-jump-to-suggestion p-2"> <span class="text-gray">No suggested jump to results</span> </li> </ul> <ul id="jump-to-results" role="listbox" class="p-0 m-0 js-navigation-container jump-to-suggestions-results-container js-jump-to-suggestions-results-container"> <li class="d-flex flex-justify-start flex-items-center p-0 f5 navigation-item js-navigation-item js-jump-to-scoped-search d-none" role="option"> <a tabindex="-1" class="no-underline d-flex flex-auto flex-items-center jump-to-suggestions-path js-jump-to-suggestion-path js-navigation-open p-2" href=""> <div class="jump-to-octicon js-jump-to-octicon flex-shrink-0 mr-2 text-center d-none"> <svg height="16" width="16" class="octicon octicon-repo flex-shrink-0 js-jump-to-octicon-repo d-none" title="Repository" aria-label="Repository" viewBox="0 0 12 16" version="1.1" role="img"><path fill-rule="evenodd" d="M4 9H3V8h1v1zm0-3H3v1h1V6zm0-2H3v1h1V4zm0-2H3v1h1V2zm8-1v12c0 .55-.45 1-1 1H6v2l-1.5-1.5L3 16v-2H1c-.55 0-1-.45-1-1V1c0-.55.45-1 1-1h10c.55 0 1 .45 1 1zm-1 10H1v2h2v-1h3v1h5v-2zm0-10H2v9h9V1z"/></svg> <svg height="16" width="16" class="octicon octicon-project flex-shrink-0 js-jump-to-octicon-project d-none" title="Project" aria-label="Project" viewBox="0 0 15 16" version="1.1" role="img"><path fill-rule="evenodd" d="M10 12h3V2h-3v10zm-4-2h3V2H6v8zm-4 4h3V2H2v12zm-1 1h13V1H1v14zM14 0H1a1 1 0 0 0-1 1v14a1 1 0 0 0 1 1h13a1 1 0 0 0 1-1V1a1 1 0 0 0-1-1z"/></svg> <svg height="16" width="16" class="octicon octicon-search flex-shrink-0 js-jump-to-octicon-search d-none" title="Search" aria-label="Search" viewBox="0 0 16 16" version="1.1" role="img"><path fill-rule="evenodd" d="M15.7 13.3l-3.81-3.83A5.93 5.93 0 0 0 13 6c0-3.31-2.69-6-6-6S1 2.69 1 6s2.69 6 6 6c1.3 0 2.48-.41 3.47-1.11l3.83 3.81c.19.2.45.3.7.3.25 0 .52-.09.7-.3a.996.996 0 0 0 0-1.41v.01zM7 10.7c-2.59 0-4.7-2.11-4.7-4.7 0-2.59 2.11-4.7 4.7-4.7 2.59 0 4.7 2.11 4.7 4.7 0 2.59-2.11 4.7-4.7 4.7z"/></svg> </div> <img class="avatar mr-2 flex-shrink-0 js-jump-to-suggestion-avatar d-none" alt="" aria-label="Team" src="" width="28" height="28"> <div class="jump-to-suggestion-name js-jump-to-suggestion-name flex-auto overflow-hidden text-left no-wrap css-truncate css-truncate-target"> </div> <div class="border rounded-1 flex-shrink-0 bg-gray px-1 text-gray-light ml-1 f6 d-none js-jump-to-badge-search"> <span class="js-jump-to-badge-search-text-default d-none" aria-label="in this repository"> In this repository </span> <span class="js-jump-to-badge-search-text-global d-none" aria-label="in all of GitHub"> All GitHub </span> <span aria-hidden="true" class="d-inline-block ml-1 v-align-middle">↵</span> </div> <div aria-hidden="true" class="border rounded-1 flex-shrink-0 bg-gray px-1 text-gray-light ml-1 f6 d-none d-on-nav-focus js-jump-to-badge-jump"> Jump to <span class="d-inline-block ml-1 v-align-middle">↵</span> </div> </a> </li> <li class="d-flex flex-justify-start flex-items-center p-0 f5 navigation-item js-navigation-item js-jump-to-global-search d-none" role="option"> <a tabindex="-1" class="no-underline d-flex flex-auto flex-items-center jump-to-suggestions-path js-jump-to-suggestion-path js-navigation-open p-2" href=""> <div class="jump-to-octicon js-jump-to-octicon flex-shrink-0 mr-2 text-center d-none"> <svg height="16" width="16" class="octicon octicon-repo flex-shrink-0 js-jump-to-octicon-repo d-none" title="Repository" aria-label="Repository" viewBox="0 0 12 16" version="1.1" role="img"><path fill-rule="evenodd" d="M4 9H3V8h1v1zm0-3H3v1h1V6zm0-2H3v1h1V4zm0-2H3v1h1V2zm8-1v12c0 .55-.45 1-1 1H6v2l-1.5-1.5L3 16v-2H1c-.55 0-1-.45-1-1V1c0-.55.45-1 1-1h10c.55 0 1 .45 1 1zm-1 10H1v2h2v-1h3v1h5v-2zm0-10H2v9h9V1z"/></svg> <svg height="16" width="16" class="octicon octicon-project flex-shrink-0 js-jump-to-octicon-project d-none" title="Project" aria-label="Project" viewBox="0 0 15 16" version="1.1" role="img"><path fill-rule="evenodd" d="M10 12h3V2h-3v10zm-4-2h3V2H6v8zm-4 4h3V2H2v12zm-1 1h13V1H1v14zM14 0H1a1 1 0 0 0-1 1v14a1 1 0 0 0 1 1h13a1 1 0 0 0 1-1V1a1 1 0 0 0-1-1z"/></svg> <svg height="16" width="16" class="octicon octicon-search flex-shrink-0 js-jump-to-octicon-search d-none" title="Search" aria-label="Search" viewBox="0 0 16 16" version="1.1" role="img"><path fill-rule="evenodd" d="M15.7 13.3l-3.81-3.83A5.93 5.93 0 0 0 13 6c0-3.31-2.69-6-6-6S1 2.69 1 6s2.69 6 6 6c1.3 0 2.48-.41 3.47-1.11l3.83 3.81c.19.2.45.3.7.3.25 0 .52-.09.7-.3a.996.996 0 0 0 0-1.41v.01zM7 10.7c-2.59 0-4.7-2.11-4.7-4.7 0-2.59 2.11-4.7 4.7-4.7 2.59 0 4.7 2.11 4.7 4.7 0 2.59-2.11 4.7-4.7 4.7z"/></svg> </div> <img class="avatar mr-2 flex-shrink-0 js-jump-to-suggestion-avatar d-none" alt="" aria-label="Team" src="" width="28" height="28"> <div class="jump-to-suggestion-name js-jump-to-suggestion-name flex-auto overflow-hidden text-left no-wrap css-truncate css-truncate-target"> </div> <div class="border rounded-1 flex-shrink-0 bg-gray px-1 text-gray-light ml-1 f6 d-none js-jump-to-badge-search"> <span class="js-jump-to-badge-search-text-default d-none" aria-label="in this repository"> In this repository </span> <span class="js-jump-to-badge-search-text-global d-none" aria-label="in all of GitHub"> All GitHub </span> <span aria-hidden="true" class="d-inline-block ml-1 v-align-middle">↵</span> </div> <div aria-hidden="true" class="border rounded-1 flex-shrink-0 bg-gray px-1 text-gray-light ml-1 f6 d-none d-on-nav-focus js-jump-to-badge-jump"> Jump to <span class="d-inline-block ml-1 v-align-middle">↵</span> </div> </a> </li> </ul> </div> </label> </form> </div> </div> </div> <a class="HeaderMenu-link no-underline mr-3" data-hydro-click="{&quot;event_type&quot;:&quot;authentication.click&quot;,&quot;payload&quot;:{&quot;location_in_page&quot;:&quot;site header menu&quot;,&quot;repository_id&quot;:null,&quot;auth_type&quot;:&quot;LOG_IN&quot;,&quot;client_id&quot;:&quot;1828424712.1553252391&quot;,&quot;originating_request_id&quot;:&quot;EB5A:158F2:1A2BD46:26C242F:5C94C0DE&quot;,&quot;originating_url&quot;:&quot;https://github.com/gabusiaaa2310/gitrepo/blob/master/cpp/osoba/osoba.cpp&quot;,&quot;user_id&quot;:null}}" data-hydro-click-hmac="b4bc87768b5d30ec6121e1df241a9e182bc983882fbb7792c093616f17a83112" data-ga-click="(Logged out) Header, clicked Sign in, text:sign-in" href="/login?return_to=%2Fgabusiaaa2310%2Fgitrepo%2Fblob%2Fmaster%2Fcpp%2Fosoba%2Fosoba.cpp"> Sign&nbsp;in </a> <a class="HeaderMenu-link d-inline-block no-underline border border-gray-dark rounded-1 px-2 py-1" data-hydro-click="{&quot;event_type&quot;:&quot;authentication.click&quot;,&quot;payload&quot;:{&quot;location_in_page&quot;:&quot;site header menu&quot;,&quot;repository_id&quot;:null,&quot;auth_type&quot;:&quot;SIGN_UP&quot;,&quot;client_id&quot;:&quot;1828424712.1553252391&quot;,&quot;originating_request_id&quot;:&quot;EB5A:158F2:1A2BD46:26C242F:5C94C0DE&quot;,&quot;originating_url&quot;:&quot;https://github.com/gabusiaaa2310/gitrepo/blob/master/cpp/osoba/osoba.cpp&quot;,&quot;user_id&quot;:null}}" data-hydro-click-hmac="901fad2739c3317a354fae6633ce7cbfa0ab237a1dafa98f9072136c00611aec" data-ga-click="(Logged out) Header, clicked Sign up, text:sign-up" href="/join"> Sign&nbsp;up </a> </div> </div> </div> </header> </div> <div id="start-of-content" class="show-on-focus"></div> <div id="js-flash-container"> </div> <div class="application-main " data-commit-hovercards-enabled> <div itemscope itemtype="http://schema.org/SoftwareSourceCode" class=""> <main id="js-repo-pjax-container" data-pjax-container > <div class="pagehead repohead instapaper_ignore readability-menu experiment-repo-nav "> <div class="repohead-details-container clearfix container"> <ul class="pagehead-actions"> <li> <a class="btn btn-sm btn-with-count tooltipped tooltipped-s" aria-label="You must be signed in to watch a repository" rel="nofollow" data-hydro-click="{&quot;event_type&quot;:&quot;authentication.click&quot;,&quot;payload&quot;:{&quot;location_in_page&quot;:&quot;notification subscription menu watch&quot;,&quot;repository_id&quot;:null,&quot;auth_type&quot;:&quot;LOG_IN&quot;,&quot;client_id&quot;:&quot;1828424712.1553252391&quot;,&quot;originating_request_id&quot;:&quot;EB5A:158F2:1A2BD46:26C242F:5C94C0DE&quot;,&quot;originating_url&quot;:&quot;https://github.com/gabusiaaa2310/gitrepo/blob/master/cpp/osoba/osoba.cpp&quot;,&quot;user_id&quot;:null}}" data-hydro-click-hmac="ec3cd0fc106d557541761063951bd2de7c6aeb2606b4d22d16e4b4f3f1a2211d" href="/login?return_to=%2Fgabusiaaa2310%2Fgitrepo"> <svg class="octicon octicon-eye v-align-text-bottom" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path fill-rule="evenodd" d="M8.06 2C3 2 0 8 0 8s3 6 8.06 6C13 14 16 8 16 8s-3-6-7.94-6zM8 12c-2.2 0-4-1.78-4-4 0-2.2 1.8-4 4-4 2.22 0 4 1.8 4 4 0 2.22-1.78 4-4 4zm2-4c0 1.11-.89 2-2 2-1.11 0-2-.89-2-2 0-1.11.89-2 2-2 1.11 0 2 .89 2 2z"/></svg> Watch </a> <a class="social-count" href="/gabusiaaa2310/gitrepo/watchers" aria-label="0 users are watching this repository"> 0 </a> </li> <li> <a class="btn btn-sm btn-with-count tooltipped tooltipped-s" aria-label="You must be signed in to star a repository" rel="nofollow" data-hydro-click="{&quot;event_type&quot;:&quot;authentication.click&quot;,&quot;payload&quot;:{&quot;location_in_page&quot;:&quot;star button&quot;,&quot;repository_id&quot;:103923132,&quot;auth_type&quot;:&quot;LOG_IN&quot;,&quot;client_id&quot;:&quot;1828424712.1553252391&quot;,&quot;originating_request_id&quot;:&quot;EB5A:158F2:1A2BD46:26C242F:5C94C0DE&quot;,&quot;originating_url&quot;:&quot;https://github.com/gabusiaaa2310/gitrepo/blob/master/cpp/osoba/osoba.cpp&quot;,&quot;user_id&quot;:null}}" data-hydro-click-hmac="886db8436801c35080965ae78459e078433ca560c9da7863bfbbd435f25b8158" href="/login?return_to=%2Fgabusiaaa2310%2Fgitrepo"> <svg class="octicon octicon-star v-align-text-bottom" viewBox="0 0 14 16" version="1.1" width="14" height="16" aria-hidden="true"><path fill-rule="evenodd" d="M14 6l-4.9-.64L7 1 4.9 5.36 0 6l3.6 3.26L2.67 14 7 11.67 11.33 14l-.93-4.74L14 6z"/></svg> Star </a> <a class="social-count js-social-count" href="/gabusiaaa2310/gitrepo/stargazers" aria-label="0 users starred this repository"> 0 </a> </li> <li> <a class="btn btn-sm btn-with-count tooltipped tooltipped-s" aria-label="You must be signed in to fork a repository" rel="nofollow" data-hydro-click="{&quot;event_type&quot;:&quot;authentication.click&quot;,&quot;payload&quot;:{&quot;location_in_page&quot;:&quot;repo details fork button&quot;,&quot;repository_id&quot;:103923132,&quot;auth_type&quot;:&quot;LOG_IN&quot;,&quot;client_id&quot;:&quot;1828424712.1553252391&quot;,&quot;originating_request_id&quot;:&quot;EB5A:158F2:1A2BD46:26C242F:5C94C0DE&quot;,&quot;originating_url&quot;:&quot;https://github.com/gabusiaaa2310/gitrepo/blob/master/cpp/osoba/osoba.cpp&quot;,&quot;user_id&quot;:null}}" data-hydro-click-hmac="804ab1f115727dd89c1d0223623b44a2cc2ac6b7778d2a0749c9cca9d6c76f30" href="/login?return_to=%2Fgabusiaaa2310%2Fgitrepo"> <svg class="octicon octicon-repo-forked v-align-text-bottom" viewBox="0 0 10 16" version="1.1" width="10" height="16" aria-hidden="true"><path fill-rule="evenodd" d="M8 1a1.993 1.993 0 0 0-1 3.72V6L5 8 3 6V4.72A1.993 1.993 0 0 0 2 1a1.993 1.993 0 0 0-1 3.72V6.5l3 3v1.78A1.993 1.993 0 0 0 5 15a1.993 1.993 0 0 0 1-3.72V9.5l3-3V4.72A1.993 1.993 0 0 0 8 1zM2 4.2C1.34 4.2.8 3.65.8 3c0-.65.55-1.2 1.2-1.2.65 0 1.2.55 1.2 1.2 0 .65-.55 1.2-1.2 1.2zm3 10c-.66 0-1.2-.55-1.2-1.2 0-.65.55-1.2 1.2-1.2.65 0 1.2.55 1.2 1.2 0 .65-.55 1.2-1.2 1.2zm3-10c-.66 0-1.2-.55-1.2-1.2 0-.65.55-1.2 1.2-1.2.65 0 1.2.55 1.2 1.2 0 .65-.55 1.2-1.2 1.2z"/></svg> Fork </a> <a href="/gabusiaaa2310/gitrepo/network/members" class="social-count" aria-label="0 users forked this repository"> 0 </a> </li> </ul> <h1 class="public "> <svg class="octicon octicon-repo" viewBox="0 0 12 16" version="1.1" width="12" height="16" aria-hidden="true"><path fill-rule="evenodd" d="M4 9H3V8h1v1zm0-3H3v1h1V6zm0-2H3v1h1V4zm0-2H3v1h1V2zm8-1v12c0 .55-.45 1-1 1H6v2l-1.5-1.5L3 16v-2H1c-.55 0-1-.45-1-1V1c0-.55.45-1 1-1h10c.55 0 1 .45 1 1zm-1 10H1v2h2v-1h3v1h5v-2zm0-10H2v9h9V1z"/></svg> <span class="author" itemprop="author"><a class="url fn" rel="author" data-hovercard-type="user" data-hovercard-url="/hovercards?user_id=32060924" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="/gabusiaaa2310">gabusiaaa2310</a></span><!-- --><span class="path-divider">/</span><!-- --><strong itemprop="name"><a data-pjax="#js-repo-pjax-container" href="/gabusiaaa2310/gitrepo">gitrepo</a></strong> </h1> </div> <nav class="reponav js-repo-nav js-sidenav-container-pjax container" itemscope itemtype="http://schema.org/BreadcrumbList" aria-label="Repository" data-pjax="#js-repo-pjax-container"> <span itemscope itemtype="http://schema.org/ListItem" itemprop="itemListElement"> <a class="js-selected-navigation-item selected reponav-item" itemprop="url" data-hotkey="g c" aria-current="page" data-selected-links="repo_source repo_downloads repo_commits repo_releases repo_tags repo_branches repo_packages /gabusiaaa2310/gitrepo" href="/gabusiaaa2310/gitrepo"> <svg class="octicon octicon-code" viewBox="0 0 14 16" version="1.1" width="14" height="16" aria-hidden="true"><path fill-rule="evenodd" d="M9.5 3L8 4.5 11.5 8 8 11.5 9.5 13 14 8 9.5 3zm-5 0L0 8l4.5 5L6 11.5 2.5 8 6 4.5 4.5 3z"/></svg> <span itemprop="name">Code</span> <meta itemprop="position" content="1"> </a> </span> <span itemscope itemtype="http://schema.org/ListItem" itemprop="itemListElement"> <a itemprop="url" data-hotkey="g i" class="js-selected-navigation-item reponav-item" data-selected-links="repo_issues repo_labels repo_milestones /gabusiaaa2310/gitrepo/issues" href="/gabusiaaa2310/gitrepo/issues"> <svg class="octicon octicon-issue-opened" viewBox="0 0 14 16" version="1.1" width="14" height="16" aria-hidden="true"><path fill-rule="evenodd" d="M7 2.3c3.14 0 5.7 2.56 5.7 5.7s-2.56 5.7-5.7 5.7A5.71 5.71 0 0 1 1.3 8c0-3.14 2.56-5.7 5.7-5.7zM7 1C3.14 1 0 4.14 0 8s3.14 7 7 7 7-3.14 7-7-3.14-7-7-7zm1 3H6v5h2V4zm0 6H6v2h2v-2z"/></svg> <span itemprop="name">Issues</span> <span class="Counter">0</span> <meta itemprop="position" content="2"> </a> </span> <span itemscope itemtype="http://schema.org/ListItem" itemprop="itemListElement"> <a data-hotkey="g p" itemprop="url" class="js-selected-navigation-item reponav-item" data-selected-links="repo_pulls checks /gabusiaaa2310/gitrepo/pulls" href="/gabusiaaa2310/gitrepo/pulls"> <svg class="octicon octicon-git-pull-request" viewBox="0 0 12 16" version="1.1" width="12" height="16" aria-hidden="true"><path fill-rule="evenodd" d="M11 11.28V5c-.03-.78-.34-1.47-.94-2.06C9.46 2.35 8.78 2.03 8 2H7V0L4 3l3 3V4h1c.27.02.48.11.69.31.21.2.3.42.31.69v6.28A1.993 1.993 0 0 0 10 15a1.993 1.993 0 0 0 1-3.72zm-1 2.92c-.66 0-1.2-.55-1.2-1.2 0-.65.55-1.2 1.2-1.2.65 0 1.2.55 1.2 1.2 0 .65-.55 1.2-1.2 1.2zM4 3c0-1.11-.89-2-2-2a1.993 1.993 0 0 0-1 3.72v6.56A1.993 1.993 0 0 0 2 15a1.993 1.993 0 0 0 1-3.72V4.72c.59-.34 1-.98 1-1.72zm-.8 10c0 .66-.55 1.2-1.2 1.2-.65 0-1.2-.55-1.2-1.2 0-.65.55-1.2 1.2-1.2.65 0 1.2.55 1.2 1.2zM2 4.2C1.34 4.2.8 3.65.8 3c0-.65.55-1.2 1.2-1.2.65 0 1.2.55 1.2 1.2 0 .65-.55 1.2-1.2 1.2z"/></svg> <span itemprop="name">Pull requests</span> <span class="Counter">0</span> <meta itemprop="position" content="3"> </a> </span> <a data-hotkey="g b" class="js-selected-navigation-item reponav-item" data-selected-links="repo_projects new_repo_project repo_project /gabusiaaa2310/gitrepo/projects" href="/gabusiaaa2310/gitrepo/projects"> <svg class="octicon octicon-project" viewBox="0 0 15 16" version="1.1" width="15" height="16" aria-hidden="true"><path fill-rule="evenodd" d="M10 12h3V2h-3v10zm-4-2h3V2H6v8zm-4 4h3V2H2v12zm-1 1h13V1H1v14zM14 0H1a1 1 0 0 0-1 1v14a1 1 0 0 0 1 1h13a1 1 0 0 0 1-1V1a1 1 0 0 0-1-1z"/></svg> Projects <span class="Counter" >0</span> </a> <a class="js-selected-navigation-item reponav-item" data-selected-links="repo_graphs repo_contributors dependency_graph pulse alerts security people /gabusiaaa2310/gitrepo/pulse" href="/gabusiaaa2310/gitrepo/pulse"> <svg class="octicon octicon-graph" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path fill-rule="evenodd" d="M16 14v1H0V0h1v14h15zM5 13H3V8h2v5zm4 0H7V3h2v10zm4 0h-2V6h2v7z"/></svg> Insights </a> </nav> </div> <div class="container new-discussion-timeline experiment-repo-nav "> <div class="repository-content "> <a class="d-none js-permalink-shortcut" data-hotkey="y" href="/gabusiaaa2310/gitrepo/blob/e461f53d44e335dc0bb4cbf1266e1a9490783e64/cpp/osoba/osoba.cpp">Permalink</a> <!-- blob contrib key: blob_contributors:v21:7f4a30bd1e7910537343619579226f5f --> <div class="signup-prompt-bg rounded-1"> <div class="signup-prompt p-4 text-center mb-4 rounded-1"> <div class="position-relative"> <!-- '"` --><!-- </textarea></xmp> --></option></form><form action="/site/dismiss_signup_prompt" accept-charset="UTF-8" method="post"><input name="utf8" type="hidden" value="&#x2713;" /><input type="hidden" name="authenticity_token" value="NHXdTOakpyFNdEO3U/PpKFr9E7lVQfAX07gzzunx8yhRCr91T02AQRAkKXB5GinOnxr9kla7HTBZ6S/Ei6zl9w==" /> <button type="submit" class="position-absolute top-0 right-0 btn-link link-gray" data-ga-click="(Logged out) Sign up prompt, clicked Dismiss, text:dismiss"> Dismiss </button> </form> <h3 class="pt-2">Join GitHub today</h3> <p class="col-6 mx-auto">GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.</p> <a class="btn btn-primary" data-hydro-click="{&quot;event_type&quot;:&quot;authentication.click&quot;,&quot;payload&quot;:{&quot;location_in_page&quot;:&quot;files signup prompt&quot;,&quot;repository_id&quot;:null,&quot;auth_type&quot;:&quot;SIGN_UP&quot;,&quot;client_id&quot;:&quot;1828424712.1553252391&quot;,&quot;originating_request_id&quot;:&quot;EB5A:158F2:1A2BD46:26C242F:5C94C0DE&quot;,&quot;originating_url&quot;:&quot;https://github.com/gabusiaaa2310/gitrepo/blob/master/cpp/osoba/osoba.cpp&quot;,&quot;user_id&quot;:null}}" data-hydro-click-hmac="027e27d29f268200b958ec4c8e8c055451e078f9ef2315a3fd5af2680c8e9dba" data-ga-click="(Logged out) Sign up prompt, clicked Sign up, text:sign-up" href="/join?source=prompt-blob-show">Sign up</a> </div> </div> </div> <div class="d-flex flex-shrink-0 flex-items-center mb-3"> <details class="details-reset details-overlay select-menu branch-select-menu"> <summary class="btn btn-sm select-menu-button css-truncate" data-hotkey="w" title="Switch branches or tags"> <i>Branch:</i> <span class="css-truncate-target">master</span> </summary> <details-menu class="select-menu-modal position-absolute" style="z-index: 99;" src="/gabusiaaa2310/gitrepo/ref-list/master/cpp/osoba/osoba.cpp?source_action=show&amp;source_controller=blob" preload> <include-fragment class="select-menu-loading-overlay anim-pulse"> <svg height="32" class="octicon octicon-octoface" viewBox="0 0 16 16" version="1.1" width="32" aria-hidden="true"><path fill-rule="evenodd" d="M14.7 5.34c.13-.32.55-1.59-.13-3.31 0 0-1.05-.33-3.44 1.3-1-.28-2.07-.32-3.13-.32s-2.13.04-3.13.32c-2.39-1.64-3.44-1.3-3.44-1.3-.68 1.72-.26 2.99-.13 3.31C.49 6.21 0 7.33 0 8.69 0 13.84 3.33 15 7.98 15S16 13.84 16 8.69c0-1.36-.49-2.48-1.3-3.35zM8 14.02c-3.3 0-5.98-.15-5.98-3.35 0-.76.38-1.48 1.02-2.07 1.07-.98 2.9-.46 4.96-.46 2.07 0 3.88-.52 4.96.46.65.59 1.02 1.3 1.02 2.07 0 3.19-2.68 3.35-5.98 3.35zM5.49 9.01c-.66 0-1.2.8-1.2 1.78s.54 1.79 1.2 1.79c.66 0 1.2-.8 1.2-1.79s-.54-1.78-1.2-1.78zm5.02 0c-.66 0-1.2.79-1.2 1.78s.54 1.79 1.2 1.79c.66 0 1.2-.8 1.2-1.79s-.53-1.78-1.2-1.78z"/></svg> </include-fragment> </details-menu> </details> <div id="blob-path" class="breadcrumb flex-auto ml-2"> <span class="js-repo-root text-bold"><span class="js-path-segment"><a data-pjax="true" href="/gabusiaaa2310/gitrepo"><span>gitrepo</span></a></span></span><span class="separator">/</span><span class="js-path-segment"><a data-pjax="true" href="/gabusiaaa2310/gitrepo/tree/master/cpp"><span>cpp</span></a></span><span class="separator">/</span><span class="js-path-segment"><a data-pjax="true" href="/gabusiaaa2310/gitrepo/tree/master/cpp/osoba"><span>osoba</span></a></span><span class="separator">/</span><strong class="final-path">osoba.cpp</strong> </div> <div class="BtnGroup"> <a href="/gabusiaaa2310/gitrepo/find/master" class="js-pjax-capture-input btn btn-sm BtnGroup-item" data-pjax data-hotkey="t"> Find file </a> <clipboard-copy for="blob-path" class="btn btn-sm BtnGroup-item"> Copy path </clipboard-copy> </div> </div> <div class="Box Box--condensed d-flex flex-column flex-shrink-0"> <div class="Box-body d-flex flex-justify-between bg-blue-light flex-items-center"> <span class="pr-md-4 f6"> <a rel="author" data-skip-pjax="true" data-hovercard-type="user" data-hovercard-url="/hovercards?user_id=32060924" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="/gabusiaaa2310"><img class="avatar" src="https://avatars2.githubusercontent.com/u/32060924?s=40&amp;v=4" width="20" height="20" alt="@gabusiaaa2310" /></a> <a class="text-bold link-gray-dark lh-default v-align-middle" rel="author" data-hovercard-type="user" data-hovercard-url="/hovercards?user_id=32060924" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="/gabusiaaa2310">gabusiaaa2310</a> <span class="lh-default v-align-middle"> <a data-pjax="true" title="osoba, car" class="link-gray" href="/gabusiaaa2310/gitrepo/commit/e461f53d44e335dc0bb4cbf1266e1a9490783e64">osoba, car</a> </span> </span> <span class="d-inline-block flex-shrink-0 v-align-bottom f6"> <a class="pr-2 text-mono link-gray" href="/gabusiaaa2310/gitrepo/commit/e461f53d44e335dc0bb4cbf1266e1a9490783e64" data-pjax> e461f53 </a> <relative-time datetime="2019-03-18T08:39:57Z">Mar 18, 2019</relative-time> </span> </div> <div class="Box-body d-flex flex-items-center flex-auto f6 border-bottom-0" > <details class="details-reset details-overlay details-overlay-dark lh-default text-gray-dark float-left mr-2" id="blob_contributors_box"> <summary class="btn-link" aria-haspopup="dialog" > <span><strong>1</strong> contributor</span> </summary> <details-dialog class="Box Box--overlay d-flex flex-column anim-fade-in fast " aria-label="Users who have contributed to this file"> <div class="Box-header"> <button class="Box-btn-octicon btn-octicon float-right" type="button" aria-label="Close dialog" data-close-dialog> <svg class="octicon octicon-x" viewBox="0 0 12 16" version="1.1" width="12" height="16" aria-hidden="true"><path fill-rule="evenodd" d="M7.48 8l3.75 3.75-1.48 1.48L6 9.48l-3.75 3.75-1.48-1.48L4.52 8 .77 4.25l1.48-1.48L6 6.52l3.75-3.75 1.48 1.48L7.48 8z"/></svg> </button> <h3 class="Box-title">Users who have contributed to this file</h3> </div> <ul class="list-style-none overflow-auto"> <li class="Box-row"> <a class="link-gray-dark no-underline" href="/gabusiaaa2310"> <img class="avatar mr-1" alt="" src="https://avatars2.githubusercontent.com/u/32060924?s=40&amp;v=4" width="20" height="20" /> gabusiaaa2310 </a> </li> </ul> </details-dialog> </details> </div> </div> <div class="Box mt-3 position-relative"> <div class="Box-header py-2 d-flex flex-justify-between flex-items-center"> <div class="text-mono f6"> 38 lines (31 sloc) <span class="file-info-divider"></span> 690 Bytes </div> <div class="d-flex"> <div class="BtnGroup"> <a id="raw-url" class="btn btn-sm BtnGroup-item" href="/gabusiaaa2310/gitrepo/raw/master/cpp/osoba/osoba.cpp">Raw</a> <a class="btn btn-sm js-update-url-with-hash BtnGroup-item" data-hotkey="b" href="/gabusiaaa2310/gitrepo/blame/master/cpp/osoba/osoba.cpp">Blame</a> <a rel="nofollow" class="btn btn-sm BtnGroup-item" href="/gabusiaaa2310/gitrepo/commits/master/cpp/osoba/osoba.cpp">History</a> </div> <div> <button type="button" class="btn-octicon disabled tooltipped tooltipped-nw" aria-label="You must be signed in to make or propose changes"> <svg class="octicon octicon-pencil" viewBox="0 0 14 16" version="1.1" width="14" height="16" aria-hidden="true"><path fill-rule="evenodd" d="M0 12v3h3l8-8-3-3-8 8zm3 2H1v-2h1v1h1v1zm10.3-9.3L12 6 9 3l1.3-1.3a.996.996 0 0 1 1.41 0l1.59 1.59c.39.39.39 1.02 0 1.41z"/></svg> </button> <button type="button" class="btn-octicon btn-octicon-danger disabled tooltipped tooltipped-nw" aria-label="You must be signed in to make or propose changes"> <svg class="octicon octicon-trashcan" viewBox="0 0 12 16" version="1.1" width="12" height="16" aria-hidden="true"><path fill-rule="evenodd" d="M11 2H9c0-.55-.45-1-1-1H5c-.55 0-1 .45-1 1H2c-.55 0-1 .45-1 1v1c0 .55.45 1 1 1v9c0 .55.45 1 1 1h7c.55 0 1-.45 1-1V5c.55 0 1-.45 1-1V3c0-.55-.45-1-1-1zm-1 12H3V5h1v8h1V5h1v8h1V5h1v8h1V5h1v9zm1-10H2V3h9v1z"/></svg> </button> </div> </div> </div> <div itemprop="text" class="Box-body px-0 blob-wrapper data type-c "> <table class="highlight tab-size js-file-line-container" data-tab-size="8"> <tr> <td id="L1" class="blob-num js-line-number" data-line-number="1"></td> <td id="LC1" class="blob-code blob-code-inner js-file-line"><span class="pl-c"><span class="pl-c">/*</span></span></td> </tr> <tr> <td id="L2" class="blob-num js-line-number" data-line-number="2"></td> <td id="LC2" class="blob-code blob-code-inner js-file-line"><span class="pl-c"> * person.cpp</span></td> </tr> <tr> <td id="L3" class="blob-num js-line-number" data-line-number="3"></td> <td id="LC3" class="blob-code blob-code-inner js-file-line"><span class="pl-c"> <span class="pl-c">*/</span></span></td> </tr> <tr> <td id="L4" class="blob-num js-line-number" data-line-number="4"></td> <td id="LC4" class="blob-code blob-code-inner js-file-line">#<span class="pl-k">include</span> <span class="pl-s"><span class="pl-pds">&lt;</span>iostream<span class="pl-pds">&gt;</span></span></td> </tr> <tr> <td id="L5" class="blob-num js-line-number" data-line-number="5"></td> <td id="LC5" class="blob-code blob-code-inner js-file-line">#<span class="pl-k">include</span> <span class="pl-s"><span class="pl-pds">&lt;</span>cstdlib<span class="pl-pds">&gt;</span></span></td> </tr> <tr> <td id="L6" class="blob-num js-line-number" data-line-number="6"></td> <td id="LC6" class="blob-code blob-code-inner js-file-line">#<span class="pl-k">include</span> <span class="pl-s"><span class="pl-pds">&quot;</span>person.h<span class="pl-pds">&quot;</span></span></td> </tr> <tr> <td id="L7" class="blob-num js-line-number" data-line-number="7"></td> <td id="LC7" class="blob-code blob-code-inner js-file-line"> </td> </tr> <tr> <td id="L8" class="blob-num js-line-number" data-line-number="8"></td> <td id="LC8" class="blob-code blob-code-inner js-file-line"><span class="pl-en">Car::Car</span>() {</td> </tr> <tr> <td id="L9" class="blob-num js-line-number" data-line-number="9"></td> <td id="LC9" class="blob-code blob-code-inner js-file-line"> wiek=<span class="pl-c1">0</span>;</td> </tr> <tr> <td id="L10" class="blob-num js-line-number" data-line-number="10"></td> <td id="LC10" class="blob-code blob-code-inner js-file-line">}</td> </tr> <tr> <td id="L11" class="blob-num js-line-number" data-line-number="11"></td> <td id="LC11" class="blob-code blob-code-inner js-file-line"> </td> </tr> <tr> <td id="L12" class="blob-num js-line-number" data-line-number="12"></td> <td id="LC12" class="blob-code blob-code-inner js-file-line"><span class="pl-en">Car::Car</span>(string im, string na, <span class="pl-k">int</span> w, string pl ) {</td> </tr> <tr> <td id="L13" class="blob-num js-line-number" data-line-number="13"></td> <td id="LC13" class="blob-code blob-code-inner js-file-line"> <span class="pl-k">if</span> (w =&lt; <span class="pl-c1">1</span>) w = <span class="pl-c1">19</span>;</td> </tr> <tr> <td id="L14" class="blob-num js-line-number" data-line-number="14"></td> <td id="LC14" class="blob-code blob-code-inner js-file-line"> imie = im;</td> </tr> <tr> <td id="L15" class="blob-num js-line-number" data-line-number="15"></td> <td id="LC15" class="blob-code blob-code-inner js-file-line"> nazwisko = na;</td> </tr> <tr> <td id="L16" class="blob-num js-line-number" data-line-number="16"></td> <td id="LC16" class="blob-code blob-code-inner js-file-line"> wiek = w;</td> </tr> <tr> <td id="L17" class="blob-num js-line-number" data-line-number="17"></td> <td id="LC17" class="blob-code blob-code-inner js-file-line"> plec = pl;</td> </tr> <tr> <td id="L18" class="blob-num js-line-number" data-line-number="18"></td> <td id="LC18" class="blob-code blob-code-inner js-file-line">}</td> </tr> <tr> <td id="L19" class="blob-num js-line-number" data-line-number="19"></td> <td id="LC19" class="blob-code blob-code-inner js-file-line"> </td> </tr> <tr> <td id="L20" class="blob-num js-line-number" data-line-number="20"></td> <td id="LC20" class="blob-code blob-code-inner js-file-line"><span class="pl-k">void</span> <span class="pl-en">Car::dodaj</span>() {</td> </tr> <tr> <td id="L21" class="blob-num js-line-number" data-line-number="21"></td> <td id="LC21" class="blob-code blob-code-inner js-file-line"> cout &lt;&lt; <span class="pl-s"><span class="pl-pds">&quot;</span>Osoba:<span class="pl-pds">&quot;</span></span> &lt;&lt; endl;</td> </tr> <tr> <td id="L22" class="blob-num js-line-number" data-line-number="22"></td> <td id="LC22" class="blob-code blob-code-inner js-file-line"> cout &lt;&lt; <span class="pl-s"><span class="pl-pds">&quot;</span>Imię: <span class="pl-pds">&quot;</span></span>; cin &gt;&gt; imie;</td> </tr> <tr> <td id="L23" class="blob-num js-line-number" data-line-number="23"></td> <td id="LC23" class="blob-code blob-code-inner js-file-line"> cout &lt;&lt; <span class="pl-s"><span class="pl-pds">&quot;</span>Nazwisko: <span class="pl-pds">&quot;</span></span>; cin &gt;&gt; nazwisko;</td> </tr> <tr> <td id="L24" class="blob-num js-line-number" data-line-number="24"></td> <td id="LC24" class="blob-code blob-code-inner js-file-line"> cout &lt;&lt; <span class="pl-s"><span class="pl-pds">&quot;</span>Wiek: <span class="pl-pds">&quot;</span></span>; cin &gt;&gt; wiek;</td> </tr> <tr> <td id="L25" class="blob-num js-line-number" data-line-number="25"></td> <td id="LC25" class="blob-code blob-code-inner js-file-line"> cout &lt;&lt; <span class="pl-s"><span class="pl-pds">&quot;</span>Płeć: <span class="pl-pds">&quot;</span></span>; cin &gt;&gt; plec;</td> </tr> <tr> <td id="L26" class="blob-num js-line-number" data-line-number="26"></td> <td id="LC26" class="blob-code blob-code-inner js-file-line">}</td> </tr> <tr> <td id="L27" class="blob-num js-line-number" data-line-number="27"></td> <td id="LC27" class="blob-code blob-code-inner js-file-line"> </td> </tr> <tr> <td id="L28" class="blob-num js-line-number" data-line-number="28"></td> <td id="LC28" class="blob-code blob-code-inner js-file-line"><span class="pl-k">void</span> <span class="pl-en">Car::dane</span>() {</td> </tr> <tr> <td id="L29" class="blob-num js-line-number" data-line-number="29"></td> <td id="LC29" class="blob-code blob-code-inner js-file-line"> cout &lt;&lt; endl;</td> </tr> <tr> <td id="L30" class="blob-num js-line-number" data-line-number="30"></td> <td id="LC30" class="blob-code blob-code-inner js-file-line"> cout &lt;&lt; <span class="pl-s"><span class="pl-pds">&quot;</span>Osoba: <span class="pl-pds">&quot;</span></span> &lt;&lt; endl;</td> </tr> <tr> <td id="L31" class="blob-num js-line-number" data-line-number="31"></td> <td id="LC31" class="blob-code blob-code-inner js-file-line"> cout &lt;&lt; <span class="pl-s"><span class="pl-pds">&quot;</span>Imię: <span class="pl-pds">&quot;</span></span> &lt;&lt; imie &lt;&lt; endl;</td> </tr> <tr> <td id="L32" class="blob-num js-line-number" data-line-number="32"></td> <td id="LC32" class="blob-code blob-code-inner js-file-line"> cout &lt;&lt; <span class="pl-s"><span class="pl-pds">&quot;</span>Nazwisko: <span class="pl-pds">&quot;</span></span> &lt;&lt; nazwisko &lt;&lt; endl;</td> </tr> <tr> <td id="L33" class="blob-num js-line-number" data-line-number="33"></td> <td id="LC33" class="blob-code blob-code-inner js-file-line"> cout &lt;&lt; <span class="pl-s"><span class="pl-pds">&quot;</span>Wiek: <span class="pl-pds">&quot;</span></span> &lt;&lt; wiek &lt;&lt; endl;</td> </tr> <tr> <td id="L34" class="blob-num js-line-number" data-line-number="34"></td> <td id="LC34" class="blob-code blob-code-inner js-file-line"> cout &lt;&lt; <span class="pl-s"><span class="pl-pds">&quot;</span>Płeć: <span class="pl-pds">&quot;</span></span> &lt;&lt; plec &lt;&lt; endl;</td> </tr> <tr> <td id="L35" class="blob-num js-line-number" data-line-number="35"></td> <td id="LC35" class="blob-code blob-code-inner js-file-line"> </td> </tr> <tr> <td id="L36" class="blob-num js-line-number" data-line-number="36"></td> <td id="LC36" class="blob-code blob-code-inner js-file-line">}</td> </tr> <tr> <td id="L37" class="blob-num js-line-number" data-line-number="37"></td> <td id="LC37" class="blob-code blob-code-inner js-file-line"> </td> </tr> </table> <details class="details-reset details-overlay BlobToolbar position-absolute js-file-line-actions dropdown d-none" aria-hidden="true"> <summary class="btn-octicon ml-0 px-2 p-0 bg-white border border-gray-dark rounded-1" aria-label="Inline file action toolbar"> <svg class="octicon octicon-kebab-horizontal" viewBox="0 0 13 16" version="1.1" width="13" height="16" aria-hidden="true"><path fill-rule="evenodd" d="M1.5 9a1.5 1.5 0 1 0 0-3 1.5 1.5 0 0 0 0 3zm5 0a1.5 1.5 0 1 0 0-3 1.5 1.5 0 0 0 0 3zM13 7.5a1.5 1.5 0 1 1-3 0 1.5 1.5 0 0 1 3 0z"/></svg> </summary> <details-menu> <ul class="BlobToolbar-dropdown dropdown-menu dropdown-menu-se mt-2" style="width:185px"> <li><clipboard-copy role="menuitem" class="dropdown-item" id="js-copy-lines" style="cursor:pointer;" data-original-text="Copy lines">Copy lines</clipboard-copy></li> <li><clipboard-copy role="menuitem" class="dropdown-item" id="js-copy-permalink" style="cursor:pointer;" data-original-text="Copy permalink">Copy permalink</clipboard-copy></li> <li><a class="dropdown-item js-update-url-with-hash" id="js-view-git-blame" role="menuitem" href="/gabusiaaa2310/gitrepo/blame/e461f53d44e335dc0bb4cbf1266e1a9490783e64/cpp/osoba/osoba.cpp">View git blame</a></li> <li><a class="dropdown-item" id="js-new-issue" role="menuitem" href="/gabusiaaa2310/gitrepo/issues/new">Reference in new issue</a></li> </ul> </details-menu> </details> </div> </div> <details class="details-reset details-overlay details-overlay-dark"> <summary data-hotkey="l" aria-label="Jump to line"></summary> <details-dialog class="Box Box--overlay d-flex flex-column anim-fade-in fast linejump" aria-label="Jump to line"> <!-- '"` --><!-- </textarea></xmp> --></option></form><form class="js-jump-to-line-form Box-body d-flex" action="" accept-charset="UTF-8" method="get"><input name="utf8" type="hidden" value="&#x2713;" /> <input class="form-control flex-auto mr-3 linejump-input js-jump-to-line-field" type="text" placeholder="Jump to line&hellip;" aria-label="Jump to line" autofocus> <button type="submit" class="btn" data-close-dialog>Go</button> </form> </details-dialog> </details> </div> <div class="modal-backdrop js-touch-events"></div> </div> </main> </div> </div> <div class="footer container-lg width-full px-3" role="contentinfo"> <div class="position-relative d-flex flex-justify-between pt-6 pb-2 mt-6 f6 text-gray border-top border-gray-light "> <ul class="list-style-none d-flex flex-wrap "> <li class="mr-3">&copy; 2019 <span title="0.14313s from unicorn-6cf4c87cf9-ln6jf">GitHub</span>, Inc.</li> <li class="mr-3"><a data-ga-click="Footer, go to terms, text:terms" href="https://github.com/site/terms">Terms</a></li> <li class="mr-3"><a data-ga-click="Footer, go to privacy, text:privacy" href="https://github.com/site/privacy">Privacy</a></li> <li class="mr-3"><a data-ga-click="Footer, go to security, text:security" href="https://github.com/security">Security</a></li> <li class="mr-3"><a href="https://githubstatus.com/" data-ga-click="Footer, go to status, text:status">Status</a></li> <li><a data-ga-click="Footer, go to help, text:help" href="https://help.github.com">Help</a></li> </ul> <a aria-label="Homepage" title="GitHub" class="footer-octicon mx-lg-4" href="https://github.com"> <svg height="24" class="octicon octicon-mark-github" viewBox="0 0 16 16" version="1.1" width="24" aria-hidden="true"><path fill-rule="evenodd" d="M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.013 8.013 0 0 0 16 8c0-4.42-3.58-8-8-8z"/></svg> </a> <ul class="list-style-none d-flex flex-wrap "> <li class="mr-3"><a data-ga-click="Footer, go to contact, text:contact" href="https://github.com/contact">Contact GitHub</a></li> <li class="mr-3"><a href="https://github.com/pricing" data-ga-click="Footer, go to Pricing, text:Pricing">Pricing</a></li> <li class="mr-3"><a href="https://developer.github.com" data-ga-click="Footer, go to api, text:api">API</a></li> <li class="mr-3"><a href="https://training.github.com" data-ga-click="Footer, go to training, text:training">Training</a></li> <li class="mr-3"><a href="https://github.blog" data-ga-click="Footer, go to blog, text:blog">Blog</a></li> <li><a data-ga-click="Footer, go to about, text:about" href="https://github.com/about">About</a></li> </ul> </div> <div class="d-flex flex-justify-center pb-6"> <span class="f6 text-gray-light"></span> </div> </div> <div id="ajax-error-message" class="ajax-error-message flash flash-error"> <svg class="octicon octicon-alert" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path fill-rule="evenodd" d="M8.893 1.5c-.183-.31-.52-.5-.887-.5s-.703.19-.886.5L.138 13.499a.98.98 0 0 0 0 1.001c.193.31.53.501.886.501h13.964c.367 0 .704-.19.877-.5a1.03 1.03 0 0 0 .01-1.002L8.893 1.5zm.133 11.497H6.987v-2.003h2.039v2.003zm0-3.004H6.987V5.987h2.039v4.006z"/></svg> <button type="button" class="flash-close js-ajax-error-dismiss" aria-label="Dismiss error"> <svg class="octicon octicon-x" viewBox="0 0 12 16" version="1.1" width="12" height="16" aria-hidden="true"><path fill-rule="evenodd" d="M7.48 8l3.75 3.75-1.48 1.48L6 9.48l-3.75 3.75-1.48-1.48L4.52 8 .77 4.25l1.48-1.48L6 6.52l3.75-3.75 1.48 1.48L7.48 8z"/></svg> </button> You can’t perform that action at this time. </div> <script crossorigin="anonymous" integrity="sha512-CJIaJ6wsoizWLxKGlyK2fmWFnKx9bHeSEO4FRL1XOT9z63SEa/VwxmlB363W/28GzYp/Q74luN8xFbdv0KCIKg==" type="application/javascript" src="https://github.githubassets.com/assets/frameworks-53e066c5.js"></script> <script crossorigin="anonymous" async="async" integrity="sha512-qas9w2MTKacv62/PZyKYU5iZMoSveHzx0M1P/BdlsJKJivVcHufTANoget2NAjA+0VFnSnVrKPO7paJFWUid3w==" type="application/javascript" src="https://github.githubassets.com/assets/github-bootstrap-ff56b0b0.js"></script> <div class="js-stale-session-flash stale-session-flash flash flash-warn flash-banner" hidden > <svg class="octicon octicon-alert" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path fill-rule="evenodd" d="M8.893 1.5c-.183-.31-.52-.5-.887-.5s-.703.19-.886.5L.138 13.499a.98.98 0 0 0 0 1.001c.193.31.53.501.886.501h13.964c.367 0 .704-.19.877-.5a1.03 1.03 0 0 0 .01-1.002L8.893 1.5zm.133 11.497H6.987v-2.003h2.039v2.003zm0-3.004H6.987V5.987h2.039v4.006z"/></svg> <span class="signed-in-tab-flash">You signed in with another tab or window. <a href="">Reload</a> to refresh your session.</span> <span class="signed-out-tab-flash">You signed out in another tab or window. <a href="">Reload</a> to refresh your session.</span> </div> <template id="site-details-dialog"> <details class="details-reset details-overlay details-overlay-dark lh-default text-gray-dark" open> <summary aria-haspopup="dialog" aria-label="Close dialog"></summary> <details-dialog class="Box Box--overlay d-flex flex-column anim-fade-in fast"> <button class="Box-btn-octicon m-0 btn-octicon position-absolute right-0 top-0" type="button" aria-label="Close dialog" data-close-dialog> <svg class="octicon octicon-x" viewBox="0 0 12 16" version="1.1" width="12" height="16" aria-hidden="true"><path fill-rule="evenodd" d="M7.48 8l3.75 3.75-1.48 1.48L6 9.48l-3.75 3.75-1.48-1.48L4.52 8 .77 4.25l1.48-1.48L6 6.52l3.75-3.75 1.48 1.48L7.48 8z"/></svg> </button> <div class="octocat-spinner my-6 js-details-dialog-spinner"></div> </details-dialog> </details> </template> <div class="Popover js-hovercard-content position-absolute" style="display: none; outline: none;" tabindex="0"> <div class="Popover-message Popover-message--bottom-left Popover-message--large Box box-shadow-large" style="width:360px;"> </div> </div> <div aria-live="polite" class="js-global-screen-reader-notice sr-only"></div> </body> </html>
[ "kinder0011@wp.pl" ]
kinder0011@wp.pl
2ee49ba25e8770d385cfcd646318f57e0ede74a6
fa56a46c7518a16b49838f8ca0160f4833d43992
/timer.h
c3ee0794a9a98b388d011e15d5d408a84c40fa39
[]
no_license
alibenD/interview_d
3592a87ba4e9189bd7fc06cedc683a96c62c6c14
989e8a1b1cf9f53f16efffd15ced3d3d9092b91e
refs/heads/master
2022-12-20T08:53:29.967127
2017-07-31T02:07:07
2017-07-31T02:07:07
298,805,988
0
0
null
null
null
null
UTF-8
C++
false
false
1,115
h
/********************************************************************************* *Copyright(C), Aliben *FileName: timer.h *Author: Aliben *Version: 0.0.1 *Date: 2017.7.30 *Description: Declaration of timer, head file of timer.cpp *Others: *Function List: 1.void start() 2.void stop() 3.clock_t getInterval() *History: 1.Date: 2017.7.30 Author: Aliben Modification: Create a timer class **********************************************************************************/ #ifndef __TIMER_H_ #define __TIMER_H_ #include<time.h> class timerMs; class timerUs; class timerMs{ public: void start(); void stop(); clock_t getInterval(); double transInterval2ms(); private: clock_t clockBegin, clockEnd, timeInterval; }; // Nano second timer exists some trouble //class timerNs{ // public: // void start(); // void stop(); // unsigned long long getInterval(); // unsigned long long transInterval2ms(); // private: // timespec timeBegin, timeEnd; // unsigned long long timeInterval; //}; #endif // __TIMER_H_
[ "aliben.develop@gmail.com" ]
aliben.develop@gmail.com
2f3f9b0e4519f6b997e4e2a33429da8fa4298ace
f56a64aa8d76185783002b55f2ff5db1a22cb3a4
/src/netbase.h
2bee22e15060e2fd45a19dd37ba5dbdbad24287b
[ "MIT" ]
permissive
ViogCommunity/VIOG
4032e92ae8dbd3d4e2b0c48073a69544b84474ce
498375e9f29e06101377550cf1e08bf2ef66f4f3
refs/heads/master
2020-03-14T17:59:33.470755
2018-06-03T18:39:00
2018-06-03T18:39:00
131,732,660
3
4
MIT
2018-06-03T14:28:34
2018-05-01T15:56:21
C++
UTF-8
C++
false
false
8,794
h
// Copyright (c) 2009-2015 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. #ifndef BITCOIN_NETBASE_H #define BITCOIN_NETBASE_H #if defined(HAVE_CONFIG_H) #include "config/viog-config.h" #endif #include "compat.h" #include "serialize.h" #include <stdint.h> #include <string> #include <vector> extern int nConnectTimeout; extern bool fNameLookup; //! -timeout default static const int DEFAULT_CONNECT_TIMEOUT = 5000; //! -dns default static const int DEFAULT_NAME_LOOKUP = true; #ifdef WIN32 // In MSVC, this is defined as a macro, undefine it to prevent a compile and link error #undef SetPort #endif enum Network { NET_UNROUTABLE = 0, NET_IPV4, NET_IPV6, NET_TOR, NET_MAX, }; /** IP address (IPv6, or IPv4 using mapped IPv6 range (::FFFF:0:0/96)) */ class CNetAddr { protected: unsigned char ip[16]; // in network byte order public: CNetAddr(); CNetAddr(const struct in_addr& ipv4Addr); explicit CNetAddr(const char *pszIp, bool fAllowLookup = false); explicit CNetAddr(const std::string &strIp, bool fAllowLookup = false); void Init(); void SetIP(const CNetAddr& ip); /** * Set raw IPv4 or IPv6 address (in network byte order) * @note Only NET_IPV4 and NET_IPV6 are allowed for network. */ void SetRaw(Network network, const uint8_t *data); bool SetSpecial(const std::string &strName); // for Tor addresses bool IsIPv4() const; // IPv4 mapped address (::FFFF:0:0/96, 0.0.0.0/0) bool IsIPv6() const; // IPv6 address (not mapped IPv4, not Tor) bool IsRFC1918() const; // IPv4 private networks (10.0.0.0/8, 192.168.0.0/16, 172.16.0.0/12) bool IsRFC2544() const; // IPv4 inter-network communcations (192.18.0.0/15) bool IsRFC6598() const; // IPv4 ISP-level NAT (100.64.0.0/10) bool IsRFC5737() const; // IPv4 documentation addresses (192.0.2.0/24, 198.51.100.0/24, 203.0.113.0/24) bool IsRFC3849() const; // IPv6 documentation address (2001:0DB8::/32) bool IsRFC3927() const; // IPv4 autoconfig (169.254.0.0/16) bool IsRFC3964() const; // IPv6 6to4 tunnelling (2002::/16) bool IsRFC4193() const; // IPv6 unique local (FC00::/7) bool IsRFC4380() const; // IPv6 Teredo tunnelling (2001::/32) bool IsRFC4843() const; // IPv6 ORCHID (2001:10::/28) bool IsRFC4862() const; // IPv6 autoconfig (FE80::/64) bool IsRFC6052() const; // IPv6 well-known prefix (64:FF9B::/96) bool IsRFC6145() const; // IPv6 IPv4-translated address (::FFFF:0:0:0/96) bool IsTor() const; bool IsLocal() const; bool IsRoutable() const; bool IsValid() const; bool IsMulticast() const; enum Network GetNetwork() const; std::string ToString() const; std::string ToStringIP(bool fUseGetnameinfo = true) const; unsigned int GetByte(int n) const; uint64_t GetHash() const; bool GetInAddr(struct in_addr* pipv4Addr) const; std::vector<unsigned char> GetGroup() const; int GetReachabilityFrom(const CNetAddr *paddrPartner = NULL) const; CNetAddr(const struct in6_addr& pipv6Addr); bool GetIn6Addr(struct in6_addr* pipv6Addr) const; friend bool operator==(const CNetAddr& a, const CNetAddr& b); friend bool operator!=(const CNetAddr& a, const CNetAddr& b); friend bool operator<(const CNetAddr& a, const CNetAddr& b); ADD_SERIALIZE_METHODS; template <typename Stream, typename Operation> inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) { READWRITE(FLATDATA(ip)); } friend class CSubNet; }; class CSubNet { protected: /// Network (base) address CNetAddr network; /// Netmask, in network byte order uint8_t netmask[16]; /// Is this value valid? (only used to signal parse errors) bool valid; public: CSubNet(); explicit CSubNet(const std::string &strSubnet, bool fAllowLookup = false); //constructor for single ip subnet (<ipv4>/32 or <ipv6>/128) explicit CSubNet(const CNetAddr &addr); bool Match(const CNetAddr &addr) const; std::string ToString() const; bool IsValid() const; friend bool operator==(const CSubNet& a, const CSubNet& b); friend bool operator!=(const CSubNet& a, const CSubNet& b); friend bool operator<(const CSubNet& a, const CSubNet& b); ADD_SERIALIZE_METHODS; template <typename Stream, typename Operation> inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) { READWRITE(network); READWRITE(FLATDATA(netmask)); READWRITE(FLATDATA(valid)); } }; /** A combination of a network address (CNetAddr) and a (TCP) port */ class CService : public CNetAddr { protected: unsigned short port; // host order public: CService(); CService(const CNetAddr& ip, unsigned short port); CService(const struct in_addr& ipv4Addr, unsigned short port); CService(const struct sockaddr_in& addr); explicit CService(const char *pszIpPort, int portDefault, bool fAllowLookup = false); explicit CService(const char *pszIpPort, bool fAllowLookup = false); explicit CService(const std::string& strIpPort, int portDefault, bool fAllowLookup = false); explicit CService(const std::string& strIpPort, bool fAllowLookup = false); void Init(); void SetPort(unsigned short portIn); unsigned short GetPort() const; bool GetSockAddr(struct sockaddr* paddr, socklen_t *addrlen) const; bool SetSockAddr(const struct sockaddr* paddr); friend bool operator==(const CService& a, const CService& b); friend bool operator!=(const CService& a, const CService& b); friend bool operator<(const CService& a, const CService& b); std::vector<unsigned char> GetKey() const; std::string ToString(bool fUseGetnameinfo = true) const; std::string ToStringPort() const; std::string ToStringIPPort(bool fUseGetnameinfo = true) const; CService(const struct in6_addr& ipv6Addr, unsigned short port); CService(const struct sockaddr_in6& addr); ADD_SERIALIZE_METHODS; template <typename Stream, typename Operation> inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) { READWRITE(FLATDATA(ip)); unsigned short portN = htons(port); READWRITE(FLATDATA(portN)); if (ser_action.ForRead()) port = ntohs(portN); } }; class proxyType { public: proxyType(): randomize_credentials(false) {} proxyType(const CService &proxy, bool randomize_credentials=false): proxy(proxy), randomize_credentials(randomize_credentials) {} bool IsValid() const { return proxy.IsValid(); } CService proxy; bool randomize_credentials; }; enum Network ParseNetwork(std::string net); std::string GetNetworkName(enum Network net); void SplitHostPort(std::string in, int &portOut, std::string &hostOut); bool SetProxy(enum Network net, const proxyType &addrProxy); bool GetProxy(enum Network net, proxyType &proxyInfoOut); bool IsProxy(const CNetAddr &addr); bool SetNameProxy(const proxyType &addrProxy); bool HaveNameProxy(); bool LookupHost(const char *pszName, std::vector<CNetAddr>& vIP, unsigned int nMaxSolutions = 0, bool fAllowLookup = true); bool Lookup(const char *pszName, CService& addr, int portDefault = 0, bool fAllowLookup = true); bool Lookup(const char *pszName, std::vector<CService>& vAddr, int portDefault = 0, bool fAllowLookup = true, unsigned int nMaxSolutions = 0); bool LookupNumeric(const char *pszName, CService& addr, int portDefault = 0); bool ConnectSocket(const CService &addr, SOCKET& hSocketRet, int nTimeout, bool *outProxyConnectionFailed = 0); bool ConnectSocketByName(CService &addr, SOCKET& hSocketRet, const char *pszDest, int portDefault, int nTimeout, bool *outProxyConnectionFailed = 0); /** Return readable error string for a network error code */ std::string NetworkErrorString(int err); /** Close socket and set hSocket to INVALID_SOCKET */ bool CloseSocket(SOCKET& hSocket); /** Disable or enable blocking-mode for a socket */ bool SetSocketNonBlocking(SOCKET& hSocket, bool fNonBlocking); /** * Convert milliseconds to a struct timeval for e.g. select. */ struct timeval MillisToTimeval(int64_t nTimeout); #endif // BITCOIN_NETBASE_H
[ "37681164+Iwwerall@users.noreply.github.com" ]
37681164+Iwwerall@users.noreply.github.com
3d19163fca35284c9082db07ba52d43391729af3
c794cd15cd922bf11b1b3b2dbc9c9cda79b0164a
/UnnamedEngine/Sources/Engine/Graphics/VulkanDriver/VulkanPipelineManager.cpp
cb059f1a23edcd617ed0b5c75895332df1e7d33e
[ "MIT" ]
permissive
kevinchen2015/UnnamedEngine
906312f504f36e0a92284c6e0ca07eb81c6c9e25
ce906886c381291ce6bac259d929a627ce8cad01
refs/heads/master
2021-05-05T15:52:17.722074
2018-01-10T14:58:02
2018-01-10T14:58:02
null
0
0
null
null
null
null
UTF-8
C++
false
false
36
cpp
#include "VulkanPipelineManager.h"
[ "tinnymint@gmail.com" ]
tinnymint@gmail.com
6db17743c68fda1f225bccbcc542c081922c8916
57610d90506f9b93d2097067bbe7658e7460c2e6
/yoketoru-unity/Temp/StagingArea/Data/il2cppOutput/t2712570874.h
deadab890dc9610f9b8eeb4690f2759ed3e0624b
[]
no_license
GEhikachu/GEhikachu.github.io
4c10b77020b9face4d27a50e1a9f4a1434f390c1
b9d6627a3d1145325f2a7b9cf02712fe17c8f334
refs/heads/master
2020-07-01T08:16:40.998434
2016-12-09T01:22:35
2016-12-09T01:22:35
74,089,233
0
0
null
null
null
null
UTF-8
C++
false
false
1,144
h
#pragma once #include "il2cpp-config.h" #ifndef _MSC_VER # include <alloca.h> #else # include <malloc.h> #endif #include <stdint.h> struct t4106212282; struct t411320003; #include "Il2CppObject.h" #ifdef __clang__ #pragma clang diagnostic push #pragma clang diagnostic ignored "-Winvalid-offsetof" #pragma clang diagnostic ignored "-Wunused-variable" #endif struct t2712570874 : public Il2CppObject { public: public: }; struct t2712570874_SFs { public: t4106212282 * f0; t411320003 * f1; public: inline static int32_t fog0() { return static_cast<int32_t>(offsetof(t2712570874_SFs, f0)); } inline t4106212282 * fg0() const { return f0; } inline t4106212282 ** fag0() { return &f0; } inline void fs0(t4106212282 * value) { f0 = value; Il2CppCodeGenWriteBarrier(&f0, value); } inline static int32_t fog1() { return static_cast<int32_t>(offsetof(t2712570874_SFs, f1)); } inline t411320003 * fg1() const { return f1; } inline t411320003 ** fag1() { return &f1; } inline void fs1(t411320003 * value) { f1 = value; Il2CppCodeGenWriteBarrier(&f1, value); } }; #ifdef __clang__ #pragma clang diagnostic pop #endif
[ "hikapika911@gmail.com" ]
hikapika911@gmail.com
aab175bc80ee983697dc77bd8ac918218c4beeed
4c0f6ffc627e2d2ab48d428a4be20f1cde0f02d0
/G.B.SHOOTER.X/Classes/TitleScene.h
eac9fd36bdf1d3bd92034da1f88f5f5bbfbd4fdd
[ "MIT" ]
permissive
kama2vern/G.B.SHOOTER.X
e73a66b7bc23bf3f02bfcdc59ebd0766ffc31a0a
1d7aba80278cd4830f9acac4f6adeb41c0a3e05f
refs/heads/master
2021-05-27T10:52:37.584899
2013-03-14T13:26:18
2013-03-14T13:26:18
null
0
0
null
null
null
null
UTF-8
C++
false
false
397
h
// // TitleScene.h // G.B.SHOOTER.X // // Created by M.Komiya on 2013/01/22. // // #ifndef MyProject_TitleScene_h #define MyProject_TitleScene_h #include "cocos2d.h" class TitleScene : public cocos2d::CCLayer { public: virtual bool init(); static cocos2d::CCScene* scene(); CREATE_FUNC(TitleScene); void goNextScene(); void goNextEndlessModeScene(); }; #endif
[ "s.wyvern.acespring@gmail.com" ]
s.wyvern.acespring@gmail.com
78ee6cca8b8c7b2dea0728a86fe6c3a7e42991fa
2e1e118a2325cdbc12fa842d792df3f729f4728a
/알고리즘 문제 풀이/BOJ/단계별 기초 연습/큐, 덱/11866_요세푸스 문제 0/11866.cc
7a074f2afe40abaa4ddcbb193f808586d27d8b36
[]
no_license
wonny-Jo/algorithm
adf4c3f66c9f4dcde80f8e04c75b6d79d68f8ab3
8b0c2a13ec38948ffe82234b29f90d42ddd905c2
refs/heads/master
2021-07-14T22:18:55.785514
2021-04-29T06:33:11
2021-04-29T06:33:11
245,082,007
1
0
null
null
null
null
UTF-8
C++
false
false
1,645
cc
#include<iostream> using namespace std; #include<queue> #include<string.h> //class Queue //{ //private: // int* data; // int data_max_size; // int data_count; // int start_position; // //public: // Queue():data_max_size(10),data_count(0), start_position(0) // { // data = new int[data_max_size]; // } // ~Queue(){} // // void push(int x) // { // if (data_count >= data_max_size) // { // data_max_size *=2; // int* temp = new int[data_max_size]; // memcpy(temp, data, sizeof(int) * data_count); // delete data; // data = temp; // } // data[data_count] = x; // ++data_count; // } // // int pop() // { // if (empty()) // { // return -1; // } // ++start_position; // return data[start_position-1]; // } // // int size() // { // return data_count-start_position; // } // // int empty() // { // if (data_count<start_position) // { // return -1; // } // else if (data_count==start_position) // { // return 1; // } // else // { // return 0; // } // } // // int front() // { // if (empty()) // { // return -1; // } // return data[start_position]; // } // int back() // { // if (empty()) // { // return -1; // } // return data[data_count-1]; // // } //}; int main() { queue<int> Que; queue<int> Que_result; int N, K; cin >> N >> K; for (int i = 1; i <= N; ++i) Que.push(i); while (!Que.empty()) { for (int i = 1; i < K; ++i) { Que.push(Que.front()); Que.pop(); } Que_result.push(Que.front()); Que.pop(); } cout << '<'<<Que_result.front(); Que_result.pop(); while (!Que_result.empty()) { cout<<", " << Que_result.front(); Que_result.pop(); } cout << '>'; return 0; }
[ "jwh6896@gmail.com" ]
jwh6896@gmail.com
e336cb558c45bf41ec8eff149858bc9443f61111
e3de99eb6bcd95f6b7e4f7557befc3d91e5415bf
/rsa.cpp
46d54428cc50b28b413a207f4e486a83b3c10753
[]
no_license
suchetha27/net
a4fe4fcfdc2524f712043b6bcaaa3fa680c02277
8dfb207d8b3c4a41c55180dc98b368a1ff2101c6
refs/heads/main
2023-02-23T02:30:42.023779
2021-01-26T15:44:04
2021-01-26T15:44:04
333,125,455
0
0
null
null
null
null
UTF-8
C++
false
false
2,092
cpp
#include <iostream> #include <stdlib.h> #include <math.h> #include <string.h> using namespace std; long int gcd(long int a, long int b) { if(a == 0) return b; if(b == 0) return a; return gcd(b, a%b); } long int isprime(long int a) { int i; for(i = 2; i < a; i++){ if((a % i) == 0) return 0; } return 1; } long int encrypt(char ch, long int n, long int e) { int i; long int temp = ch; for(i = 1; i < e; i++) temp = (temp * ch) % n; return temp; } char decrypt(long int ch, long int n, long int d) { int i; long int temp = ch; for(i = 1; i < d; i++) ch =(temp * ch) % n; return ch; } int main() { long int i, len; long int p, q, n, phi, e, d, cipher[50]; char text[50]; cout << "Enter the text to be encrypted: "; cin.getline(text, sizeof(text)); len = strlen(text); do { cout<<"Enter value of p: "<<"\n";//p = rand() % 30; cin>>p; } while (!isprime(p)); do { cout<<"Enter value of q: "<<"\n";//p = rand() % 30; cin>>q; //q = rand() % 30; } while (!isprime(q)); n = p * q; phi = (p - 1) * (q - 1); do { cout<<"Enter value of e: "<<"\n";//p = rand() % 30; cin>>e; //e = rand() % phi; } while (gcd(phi, e) != 1); do { d = rand() % phi; } while (((d * e) % phi) != 1); cout << "Two prime numbers (p and q) are: " << p << " and " << q << endl; cout << "n(p * q) = " << p << " * " << q << " = " << p*q << endl; cout << "(p - 1) * (q - 1) = "<< phi << endl; cout << "Public key (n, e): (" << n << ", " << e << ")\n"; cout << "Private key (n, d): (" << n << ", " << d << ")\n"; for (i = 0; i < len; i++) cipher[i] = encrypt(text[i], n, e); cout << "Encrypted message: "; for (i = 0; i < len; i++) cout << cipher[i]; for (i = 0; i < len; i++) text[i] = decrypt(cipher[i], n, d); cout << endl; cout << "Decrypted message: "; for (i = 0; i < len; i++) cout << text[i]; cout << endl; return 0; }
[ "noreply@github.com" ]
noreply@github.com
e8a56429a014765cc55f853ab92393e396f1b497
6f5ab6c58e3b31dbaf3ef15d14dcac4a69d8013f
/codeforces/contest/1213/main.cpp
7bdd474c9e30ecc239c241c24827372eb68532de
[]
no_license
sambey04/c_code
f1cb9d96ee5f78b7219ac2656ad1424201364bb0
080fb9720f70e44c37e9fa845549bb1951dc6a79
refs/heads/master
2020-05-31T22:41:12.513839
2020-03-06T04:23:51
2020-03-06T04:23:51
190,525,768
1
0
null
null
null
null
UTF-8
C++
false
false
317
cpp
//https://codeforces.com/contest/1213 // // #include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int x,n,test=0; cin >> n ; for(int i=0;i<n;i++) { cin >> x; if(x%2==0) test++; } if(test>n-test) cout << n-test; else cout << test; return 0; }
[ "ram@localhost.localdomain" ]
ram@localhost.localdomain
5398ac8fff17b5f59897104ae5f154d038c8d8f0
083ad051981273866006eb777311ba486a06e214
/testsrc/libjamsat/unit/utils/BinaryHeapTests.cpp
6cbf4305ed1f4c80da3f8b6cc30c3e6ed6f9ce70
[ "MIT", "X11" ]
permissive
fkutzner/JamSAT
31d0932f1f0acf7fa63bc86cad83e5fe031fc03b
226a8b3ba79a5450e96bd4b98015e1f6a187d290
refs/heads/master
2021-05-23T05:48:20.160881
2020-08-23T11:30:57
2020-08-23T11:30:57
94,918,870
7
1
null
2018-05-20T19:30:33
2017-06-20T17:43:04
C++
UTF-8
C++
false
false
5,496
cpp
/* Copyright (c) 2018 Felix Kutzner (github.com/fkutzner) 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. Except as contained in this notice, the name(s) of the above copyright holders shall not be used in advertising or otherwise to promote the sale, use or other dealings in this Software without prior written authorization. */ #include <gtest/gtest.h> #include <libjamsat/utils/BinaryHeap.h> #include <algorithm> #include <cstdint> namespace jamsat { class IntIndex { public: using Type = int; static constexpr auto getIndex(int i) -> std::size_t { int z = 2 * i; if (i < 0) { return static_cast<std::size_t>(-z); } return static_cast<std::size_t>(z + 1); } }; class TestIntComparator { public: TestIntComparator(int max) { (void)max; } auto operator()(int lhs, int rhs) const noexcept -> bool { return lhs < rhs; } void increaseMaxSizeTo(int newMaxElement) noexcept { (void)newMaxElement; } }; TEST(UnitUtils, EmptyBinaryMaxHeapIsMarkedAsEmpty) { BinaryMaxHeap<int, TestIntComparator, IntIndex> underTest{10}; EXPECT_TRUE(underTest.empty()); EXPECT_EQ(underTest.size(), 0ULL); } TEST(UnitUtils, EmptyBinaryMaxHeapContainsNoElements) { BinaryMaxHeap<int, TestIntComparator, IntIndex> underTest{10}; for (int i = -10; i <= 10; ++i) { EXPECT_FALSE(underTest.contains(i)) << "Heap unexpectedly contains element " << i; } } TEST(UnitUtils, SingleElementMaxHeapContainsExactlyOneElement) { BinaryMaxHeap<int, TestIntComparator, IntIndex> underTest{10}; underTest.insert(5); EXPECT_FALSE(underTest.empty()); EXPECT_EQ(underTest.size(), 1ULL); EXPECT_TRUE(underTest.contains(5)); for (int i = -10; i <= 10; ++i) { if (i != 5) { EXPECT_FALSE(underTest.contains(i)) << "Heap unexpectedly contains element " << i; } } } TEST(UnitUtils, MaxHeapDoubleInsertionsDoNotDuplicateElements) { BinaryMaxHeap<int, TestIntComparator, IntIndex> underTest{10}; underTest.insert(5); underTest.insert(5); EXPECT_EQ(underTest.size(), 1ULL); EXPECT_EQ(underTest.removeMax(), 5); EXPECT_TRUE(underTest.empty()); } TEST(UnitUtils, SingleElementMaxHeapIsEmptyAfterRemoval) { BinaryMaxHeap<int, TestIntComparator, IntIndex> underTest{10}; underTest.insert(5); auto removed = underTest.removeMax(); EXPECT_EQ(removed, 5); EXPECT_TRUE(underTest.empty()); } TEST(UnitUtils, BinaryMaxHeapHasHeapPropertyAfterInsertion) { BinaryMaxHeap<int, TestIntComparator, IntIndex> underTest{10}; std::vector<int> testSeq = std::vector<int>{3, 9, 1, -5, -10, -9, 10, 0, -1, 7}; for (auto i : testSeq) { underTest.insert(i); } EXPECT_TRUE(underTest.test_satisfiesHeapProperty()); EXPECT_EQ(underTest.size(), testSeq.size()); } TEST(UnitUtils, BinaryMaxHeapCanBeFilledToMax) { BinaryMaxHeap<int, TestIntComparator, IntIndex> underTest{10}; for (int i = -10; i <= 10; ++i) { underTest.insert(i); } EXPECT_EQ(underTest.size(), 21ULL); } TEST(UnitUtils, BinaryMaxHeapHasDescendingRemovalSequence) { BinaryMaxHeap<int, TestIntComparator, IntIndex> underTest{10}; std::vector<int> testSeq = std::vector<int>{3, 9, 1, -5, -10, -9, 10, 0, -1, 7}; for (auto i : testSeq) { underTest.insert(i); } std::sort(testSeq.rbegin(), testSeq.rend()); for (size_t i = 0; i < testSeq.size(); ++i) { auto removed = underTest.removeMax(); EXPECT_EQ(testSeq[i], removed) << "Differing elements at removal step " << i; EXPECT_TRUE(underTest.test_satisfiesHeapProperty()) << "Heap property violated at removal step " << i; } EXPECT_TRUE(underTest.empty()); } TEST(UnitUtils, BinaryMaxHeapElementInsertedAfterRemoveCanBeRetrieved) { BinaryMaxHeap<int, TestIntComparator, IntIndex> underTest{10}; std::vector<int> testSeq = std::vector<int>{3, 9, 1, -5}; for (auto i : testSeq) { underTest.insert(i); } EXPECT_EQ(underTest.removeMax(), 9); EXPECT_EQ(underTest.removeMax(), 3); underTest.insert(2); EXPECT_EQ(underTest.removeMax(), 2); underTest.insert(-3); EXPECT_EQ(underTest.removeMax(), 1); EXPECT_EQ(underTest.removeMax(), -3); EXPECT_EQ(underTest.removeMax(), -5); } TEST(UnitUtils, BinaryMaxHeapCanBeResized) { BinaryMaxHeap<int, TestIntComparator, IntIndex> underTest{5}; std::vector<int> testSeq = std::vector<int>{3, 2, 1, -5}; for (auto i : testSeq) { underTest.insert(i); } underTest.increaseMaxSizeTo(8); underTest.insert(8); EXPECT_EQ(underTest.size(), testSeq.size() + 1); EXPECT_EQ(underTest.removeMax(), 8); } }
[ "felixkutzner@gmail.com" ]
felixkutzner@gmail.com
f80bb6bbba8561a02521f90a222b0d780226af91
fd753470a1b0fe901080cdd2ebc7e181134be6f3
/0840. Magic Squares In Grid.cpp
bc47c0a9fe47c949a90419182d5d2a0947b02ea1
[]
no_license
virsing/Leetcode
5e420459ca6be13ec7070eef154d24ad66ca7c3e
ef94bc7a6cce289d597ac41bc4a1f07f6e85dc33
refs/heads/master
2021-06-28T19:11:25.497561
2019-02-13T09:54:35
2019-02-13T09:54:35
134,942,950
0
0
null
null
null
null
UTF-8
C++
false
false
2,163
cpp
A 3 x 3 magic square is a 3 x 3 grid filled with distinct numbers from 1 to 9 such that each row, column, and both diagonals all have the same sum. Given an grid of integers, how many 3 x 3 "magic square" subgrids are there? (Each subgrid is contiguous). Example 1: Input: [[4,3,8,4], [9,5,1,9], [2,7,6,2]] Output: 1 Explanation: The following subgrid is a 3 x 3 magic square: 438 951 276 while this one is not: 384 519 762 In total, there is only one magic square inside the given grid. Note: 1 <= grid.length <= 10 1 <= grid[0].length <= 10 0 <= grid[i][j] <= 15 题意:给定一个二维矩阵,问你一共有几个3*3魔法矩阵.(3*3魔法矩阵定义为:矩阵内每个元素数字范围在1--9之间,并且每行每列以及两条对角线之和均相等) 思路: 1.逐个矩阵判断即可。 参考代码: class Solution { public: int numMagicSquaresInside(vector<vector<int>>& grid) { int row=grid.size(),col=grid[0].size(),cnt=0; for(int i=0;i<row-2;++i){ for(int j=0;j<col-2;++j){ if(islegal(i,j,grid)){ cnt++; } } } return cnt; } bool islegal(int i,int j,vector<vector<int>>& grid){ for(int r=i;r<i+3;++r){ for(int c=j;c<j+3;++c){ if(!(grid[r][c]>=1&&grid[r][c]<=9)) { return false; } } } vector<int> v(8); v[0]=grid[i][j]+grid[i][j+1]+grid[i][j+2]; v[1]=grid[i+1][j]+grid[i+1][j+1]+grid[i+1][j+2]; v[2]=grid[i+2][j]+grid[i+2][j+1]+grid[i+2][j+2]; v[3]=grid[i][j]+grid[i+1][j]+grid[i+2][j]; v[4]=grid[i][j+1]+grid[i+1][j+1]+grid[i+2][j+1]; v[5]=grid[i][j+2]+grid[i+1][j+2]+grid[i+2][j+2]; v[6]=grid[i][j]+grid[i+1][j+1]+grid[i+2][j+2]; v[7]=grid[i+2][j]+grid[i+1][j+1]+grid[i][j+2]; for(int k=0;k<7;++k){ if(v[k]!=v[k+1]) return false; } return true; } };
[ "noreply@github.com" ]
noreply@github.com
0a4b2af8df47140ac675f81c78b33b3c3a40babc
a8a29667e73d3659622d57ea948fbebc85a9ef0b
/LeetCode/1269-wayNumStaySamePlaceAfterSteps.h
255de738a2463c37505d87ade9ebbfde4de1f847
[]
no_license
cosensible/LeetCode
c352acea6caf5c4737f8e1e96d3bedb2885c96e2
1bdf2d09ee4bd286e8f1304020928bdd1467e2b5
refs/heads/master
2021-09-09T03:11:41.257058
2021-09-06T03:40:48
2021-09-06T03:40:48
217,175,623
3
0
null
null
null
null
GB18030
C++
false
false
1,379
h
#include <vector> #include <algorithm> #include <iostream> using namespace std; class Solution_1269 { const int MOD = 1e9 + 7; public: int numWays(int steps, int arrLen) { int idxNum = min(arrLen, steps + 1); // // 最远能走到 arrLen-1 或 steps vector<vector<int>> dp(steps + 1, vector<int>(idxNum)); // dp[i][j]: 走 i 步到 j 的方案数 dp[0][0] = 1; // 初始位置为 0, 不需要走就能到 for (int i = 1; i <= steps; ++i) { for (int j = 0; j < idxNum; ++j) { dp[i][j] = dp[i - 1][j]; if (j > 0) dp[i][j] = (dp[i][j] + dp[i - 1][j - 1]) % MOD; if (j < idxNum - 1) dp[i][j] = (dp[i][j] + dp[i - 1][j + 1]) % MOD; } } return dp[steps][0]; } }; class Solution_1269_Better { const int MOD = 1e9 + 7; public: int numWays(int steps, int arrLen) { int idxNum = min(arrLen, steps / 2 + 1); // 最远能走到 arrLen-1 或 steps/2, 因为走太远了回不到初始位置 vector<int> dp(idxNum); // dp 的每一行只和上一行有关 dp[0] = 1; for (int i = 1; i <= steps; ++i) { vector<int> dpNext(idxNum); for (int j = 0; j < idxNum; ++j) { dpNext[j] = dp[j]; if (j > 0) dpNext[j] = (dpNext[j] + dp[j - 1]) % MOD; if (j < idxNum - 1) dpNext[j] = (dpNext[j] + dp[j + 1]) % MOD; } swap(dp, dpNext); } return dp[0]; } }; void test_1269() { cout << (Solution_1269().numWays(4, 2) == 8) << endl; }
[ "cosensible@gmail.com" ]
cosensible@gmail.com
27982d4d16681b0ecdabb2fb4da5b58f62cda3e6
3aff7156207d7207ae84ff3870487509fa4a7ff5
/sdasdasdasd 2 2/Classes/Native/mscorlib_System_Security_Cryptography_Rfc2898Deriv1773348698.h
0ab90e8a135eb2dd5758b1e1324e2d5da121ed8b
[]
no_license
huangliliu0917/iOS_wsl_mallbuy_for_vr
080ea5512fff6ff4665efab1216d8544d621404e
6f141c8cf255e655db38e1f98dda75a978dfe985
refs/heads/master
2020-04-07T10:07:55.773244
2017-08-08T12:23:42
2017-08-08T12:23:42
null
0
0
null
null
null
null
UTF-8
C++
false
false
3,616
h
#pragma once #include "il2cpp-config.h" #ifndef _MSC_VER # include <alloca.h> #else # include <malloc.h> #endif #include <stdint.h> #include "mscorlib_System_Security_Cryptography_DeriveBytes1087525826.h" // System.Byte[] struct ByteU5BU5D_t3397334013; // System.Security.Cryptography.HMACSHA1 struct HMACSHA1_t1958407246; #ifdef __clang__ #pragma clang diagnostic push #pragma clang diagnostic ignored "-Winvalid-offsetof" #pragma clang diagnostic ignored "-Wunused-variable" #endif // System.Security.Cryptography.Rfc2898DeriveBytes struct Rfc2898DeriveBytes_t1773348698 : public DeriveBytes_t1087525826 { public: // System.Int32 System.Security.Cryptography.Rfc2898DeriveBytes::_iteration int32_t ____iteration_0; // System.Byte[] System.Security.Cryptography.Rfc2898DeriveBytes::_salt ByteU5BU5D_t3397334013* ____salt_1; // System.Security.Cryptography.HMACSHA1 System.Security.Cryptography.Rfc2898DeriveBytes::_hmac HMACSHA1_t1958407246 * ____hmac_2; // System.Byte[] System.Security.Cryptography.Rfc2898DeriveBytes::_buffer ByteU5BU5D_t3397334013* ____buffer_3; // System.Int32 System.Security.Cryptography.Rfc2898DeriveBytes::_pos int32_t ____pos_4; // System.Int32 System.Security.Cryptography.Rfc2898DeriveBytes::_f int32_t ____f_5; public: inline static int32_t get_offset_of__iteration_0() { return static_cast<int32_t>(offsetof(Rfc2898DeriveBytes_t1773348698, ____iteration_0)); } inline int32_t get__iteration_0() const { return ____iteration_0; } inline int32_t* get_address_of__iteration_0() { return &____iteration_0; } inline void set__iteration_0(int32_t value) { ____iteration_0 = value; } inline static int32_t get_offset_of__salt_1() { return static_cast<int32_t>(offsetof(Rfc2898DeriveBytes_t1773348698, ____salt_1)); } inline ByteU5BU5D_t3397334013* get__salt_1() const { return ____salt_1; } inline ByteU5BU5D_t3397334013** get_address_of__salt_1() { return &____salt_1; } inline void set__salt_1(ByteU5BU5D_t3397334013* value) { ____salt_1 = value; Il2CppCodeGenWriteBarrier(&____salt_1, value); } inline static int32_t get_offset_of__hmac_2() { return static_cast<int32_t>(offsetof(Rfc2898DeriveBytes_t1773348698, ____hmac_2)); } inline HMACSHA1_t1958407246 * get__hmac_2() const { return ____hmac_2; } inline HMACSHA1_t1958407246 ** get_address_of__hmac_2() { return &____hmac_2; } inline void set__hmac_2(HMACSHA1_t1958407246 * value) { ____hmac_2 = value; Il2CppCodeGenWriteBarrier(&____hmac_2, value); } inline static int32_t get_offset_of__buffer_3() { return static_cast<int32_t>(offsetof(Rfc2898DeriveBytes_t1773348698, ____buffer_3)); } inline ByteU5BU5D_t3397334013* get__buffer_3() const { return ____buffer_3; } inline ByteU5BU5D_t3397334013** get_address_of__buffer_3() { return &____buffer_3; } inline void set__buffer_3(ByteU5BU5D_t3397334013* value) { ____buffer_3 = value; Il2CppCodeGenWriteBarrier(&____buffer_3, value); } inline static int32_t get_offset_of__pos_4() { return static_cast<int32_t>(offsetof(Rfc2898DeriveBytes_t1773348698, ____pos_4)); } inline int32_t get__pos_4() const { return ____pos_4; } inline int32_t* get_address_of__pos_4() { return &____pos_4; } inline void set__pos_4(int32_t value) { ____pos_4 = value; } inline static int32_t get_offset_of__f_5() { return static_cast<int32_t>(offsetof(Rfc2898DeriveBytes_t1773348698, ____f_5)); } inline int32_t get__f_5() const { return ____f_5; } inline int32_t* get_address_of__f_5() { return &____f_5; } inline void set__f_5(int32_t value) { ____f_5 = value; } }; #ifdef __clang__ #pragma clang diagnostic pop #endif
[ "284353855@qq.com" ]
284353855@qq.com
5be279e888413f813f4db1592245664cfc7c0030
71ffdff29137de6bda23f02c9e22a45fe94e7910
/KillaCoptuz3000/src/Menu/CMenuItem.h
b4658890d1d48ed8f451b438264663eb8af81a0b
[]
no_license
anhoppe/killakoptuz3000
f2b6ecca308c1d6ebee9f43a1632a2051f321272
fbf2e77d16c11abdadf45a88e1c747fa86517c59
refs/heads/master
2021-01-02T22:19:10.695739
2009-03-15T21:22:31
2009-03-15T21:22:31
35,839,301
0
0
null
null
null
null
WINDOWS-1252
C++
false
false
1,797
h
// *************************************************************** // CMenuItem version: 1.0 · date: 06/17/2007 // ------------------------------------------------------------- // // ------------------------------------------------------------- // Copyright (C) 2007 - All Rights Reserved // *************************************************************** // // *************************************************************** #ifndef CMENU_ITEM_H #define CMENU_ITEM_H #include "tinyxml/tinyxml.h" #include "glut/glut.h" #include <string> class CMenu; enum EMenuAction { e_startGame = 0, e_quitGame = 1, e_succeedingMenu = 2 }; class CMenuItem { ////////////////////////////////////////////////////////////////////////// // Methods ////////////////////////////////////////////////////////////////////////// public: CMenuItem(CMenu* t_parentPtr); ~CMenuItem(); bool load(TiXmlNode* t_nodePtr); void draw(float t_position, float t_depth); void update(); ////////////////////////////////////////////////////////////////////////// // Variables ////////////////////////////////////////////////////////////////////////// public: /** This text is displayed for the menu */ ////////////////////////////////////////////////////////////////////////// std::string m_textureKey; /** This is the succeeding menu when this is selected. Only set if menu action is 'menu' */ std::string m_succeedingMenu; /** Type of action (start game / end program / menu) */ EMenuAction m_action; /** size of the menu item */ float m_width; float m_height; private: CMenu* m_parentPtr; GLuint m_textureIndex; }; #endif
[ "anhoppe@9386d06f-8230-0410-af72-8d16ca8b68df" ]
anhoppe@9386d06f-8230-0410-af72-8d16ca8b68df
9c08e226829489324a7fec0a8eb1226cc5287770
c7b5bd813aa8504b8b534c0ce6e0a416eb0e1fbd
/Ceng 242/PE5/path_tracker.cpp
239eb1a6f1051b7b41e26261356f3b114263d3db
[]
no_license
aalparslan/Homeworks
faf011d880523b18877734d8c0fada950b2363b7
c6df1704886af9a394d69f4d3cb4c4aa9bf7f201
refs/heads/master
2023-06-25T06:16:37.688253
2021-07-26T16:46:14
2021-07-26T16:46:14
345,940,749
0
0
null
null
null
null
UTF-8
C++
false
false
3,601
cpp
#include <iostream> #include <math.h> #include "path_tracker.h" /* DO NOT EDIT HEADER FILE*/ /** * Empty constructor * * Initialize all attributes as 0 */ PathTracker::PathTracker() { } /** * Constructor * * Given existing_path array contains x,y couples representing vectors * to add end-to-end. * [1, 2, 3, 4, 5, 6] -> 3 vectors: [1, 2], [3, 4], [5, 6] * Add them end-to end: [1, 2] + [3, 4] + [5, 6] -> [9, 12] * Note: Update displacement and distance at each addition. * * @param existing_path List of vectors to add end-to-end * @param number_of_vectors The number of vectors (not the size of the array) */ PathTracker::PathTracker(int *existing_path, int number_of_vectors) { } /** * sum and equal operator * Adds new vector to the end of the path. * * Note: All properties of the object will be updated. * final_x and final_y coordinates, displacement and distance * values will be updated. * * @param rhs Integer array with length of 2, containing x, y components of the vector to be added. * @return this PathTracker after adding new vector to the end. */ PathTracker &PathTracker::operator+=(const int *new_vector) { } /** * Equality comparison overload * * This operator checks only displacements. * * @param rhs The PathTracker to compare * @return returns true if both displacements are same false otherwise */ bool PathTracker::operator==(const PathTracker &rhs) const { return true; } /** * Comparison overload * * This operator checks only displacements. * * @param rhs The PathTracker to compare * @return returns true if the displacement of original PathTracker is longer, false otherwise */ bool PathTracker::operator>(const PathTracker &rhs) const { return true; } /** * Comparison overload * * This operator checks only displacements. * * @param rhs The PathTracker to compare * @return returns true if the displacement of original PathTracker is shorter, false otherwise */ bool PathTracker::operator<(const PathTracker &rhs) const { return true; } /** * Equality comparison overload * * This operator checks only distance of the PathTracker * * @param distance floating-point to compare * @return returns true if the distance value of PathTracker is bigger than comp value, false otherwise */ bool PathTracker::operator==(const float comp) const { return true; } /** * Calculates and returns the displacement value of the path. * Displacement: Distance between final position and the first position (origin) * * @return value of the displacement */ float PathTracker::calculate_displacement() { return 0; } /** * Calculates and sets the distance value of the path. * Distance: Total length of the path. * * @param x x-component of the newly added vector * @param y y-component of the newly added vector */ void PathTracker::calculate_distance(int x, int y) { } /** * It is a helper function which calculates Euclidean distance between two * points on the vector space. * * @param x1 x-component of the first point * @param y1 y-component of the first point * @param x2 x-component of the second point * @param y2 y-component of the second point * @return Euclidean distance value */ float PathTracker::calculate_l2(int x1, int y1, int x2, int y2) { return 0; } /** * Prints the summary of the PathTracker as: * Final position: [x,y] Displacement: #disp# Distance: #dist# * Do not forget the newline char at the end. */ void PathTracker::summary() { /* do NOT remove this line */ std::cout.precision(5); /* WRITE YOUR CODE HERE */ }
[ "ahmetalpaslan58@hotmail.com" ]
ahmetalpaslan58@hotmail.com
4cfae420244af08a96c6598c5a3a47b3e6084123
487fd495fec491acb04453255c870808d037f889
/src/qt/openuridialog.h
0db980ab119096032cae7f04e401618549fb1249
[ "MIT" ]
permissive
TechDude2u/GSAcoin
58b94eba767f6e17c8a88bcf0ee3b4cea719657a
c0a64da39501a52f25e709368a869d743f77221d
refs/heads/main
2023-08-08T04:03:42.198250
2021-09-21T16:27:42
2021-09-21T16:27:42
null
0
0
null
null
null
null
UTF-8
C++
false
false
858
h
// Copyright (c) 2019 The PIVX developers // Copyright (c) 2021 The GLOBALSMARTASSET Core Developers // Distributed under the MIT/X11 software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. #ifndef BITCOIN_QT_OPENURIDIALOG_H #define BITCOIN_QT_OPENURIDIALOG_H #include <QDialog> #include "qt/gsa/snackbar.h" namespace Ui { class OpenURIDialog; } class OpenURIDialog : public QDialog { Q_OBJECT public: explicit OpenURIDialog(QWidget* parent); ~OpenURIDialog(); QString getURI(); void showEvent(QShowEvent *event) override; protected Q_SLOTS: void accept() override; private Q_SLOTS: void on_selectFileButton_clicked(); private: Ui::OpenURIDialog* ui; SnackBar *snackBar = nullptr; void inform(const QString& str); }; #endif // BITCOIN_QT_OPENURIDIALOG_H
[ "gsasset24@gmail.com" ]
gsasset24@gmail.com
a00e8d565e34b7dfcac6789e75d6bba580fc8d4d
54f352a242a8ad6ff5516703e91da61e08d9a9e6
/Source Codes/AtCoder/arc077/B/1393983.cpp
224c484735e3abc62fae5d681c8276f12325952a
[]
no_license
Kawser-nerd/CLCDSA
5cbd8a4c3f65173e4e8e0d7ed845574c4770c3eb
aee32551795763b54acb26856ab239370cac4e75
refs/heads/master
2022-02-09T11:08:56.588303
2022-01-26T18:53:40
2022-01-26T18:53:40
211,783,197
23
9
null
null
null
null
UTF-8
C++
false
false
1,473
cpp
#include <iostream> #include <vector> int main() { const unsigned long long mod = 1000000007; unsigned n; std::cin >> n; std::vector<unsigned long long> inv(n + 2); inv[1] = 1; for (unsigned i = 2; i < n + 2; ++i) { inv[i] = mod - (mod / i) * inv[mod % i] % mod; } std::vector<unsigned long long> fact(n + 2); fact[0] = 1; for (unsigned i = 1; i < n + 2; ++i) { fact[i] = fact[i - 1] * i % mod; } std::vector<unsigned long long> inv_fact(n + 2); inv_fact[0] = 1; for (unsigned i = 1; i < n + 2; ++i) { inv_fact[i] = inv_fact[i - 1] * inv[i] % mod; } std::vector<unsigned long long> a(n + 1); for (unsigned i = 0; i < n + 1; ++i) { std::cin >> a[i]; } std::vector<unsigned> place(n + 1, 0); unsigned s = 0, t = 0; for (unsigned i = 0; i < n + 1; ++i) { if (place[a[i]] == 0) { place[a[i]] = i + 1; } else { s = place[a[i]]; t = i + 1; break; } } unsigned x = n + 1 - (t - s); for (unsigned k = 1; k <= n + 1; ++k) { unsigned long long hoge = fact[n + 1] * inv_fact[k] % mod; hoge *= inv_fact[n + 1 - k]; hoge %= mod; if (x >= k) { unsigned long long fuga = fact[x - 1] * inv_fact[x - k] % mod; fuga *= inv_fact[k - 1]; fuga %= mod; std::cout << (hoge > fuga ? hoge - fuga : hoge + mod - fuga) << std::endl; } else { std::cout << hoge << std::endl; } } return 0; }
[ "kwnafi@yahoo.com" ]
kwnafi@yahoo.com
ab5803a815a5b00763bf3bacb69ed7b536450b09
474cdcd87879efc091a06aaee264a889b81b3343
/MCG_GFX_Framework/Sphere.cpp
d5966687e830c9dd37ff94c91aff6026d80f4336
[]
no_license
LiruJ/RayCasting
0f302743d5128cc3d3943b6f97995c7aab117990
68a2ade61fb7b7996419eab0a8d9324af89a14ff
refs/heads/master
2023-01-18T23:20:12.798936
2020-11-24T15:43:51
2020-11-24T15:43:51
183,261,455
0
0
null
null
null
null
UTF-8
C++
false
false
3,645
cpp
#include "Sphere.h" // Framework includes. #include <gtx/norm.hpp> /// <summary> Calculates the colour of a certain point on the sphere. </summary> /// <param name="_intersection"> The point on the sphere for which to calculate the colour. </param> /// <param name="_normal"> The pre-calculated normal from the centre of the sphere to the intersection point. </param> /// <param name="_lightSource"> The light source to check against. </param> /// <returns> The calculated colour on the given intersection point on this sphere. </returns> Colour Shapes::Sphere::Shade(const glm::vec3 _intersection, const glm::vec3 _normal, const PointLight _lightSource) const { // Calulate the direction from the intersection point to the light source. glm::vec3 directionToLight = glm::normalize(_lightSource.m_position - _intersection); // Calculate the scalar for the light intensity based off the dot product of the normal and the direction towards the light. float_t facingAmount = glm::dot(_normal, directionToLight); // If the facing is 0 or lower, just return black. if (facingAmount <= 0.0f) { return Colour::Black(); } // Calculate and return the final colour. return m_properties.m_colour * _lightSource.m_colour * facingAmount * _lightSource.m_intensity; } /// <summary> Finds if the given ray intersects with this sphere. </summary> /// <param name="_ray"> The ray to check against. </param> /// <returns> The result of the check. </returns> SphereIntersection Shapes::Sphere::RayIntersects(const Ray _ray) const { // Create an empty intersection object to hold the result. SphereIntersection result = SphereIntersection::Empty(); // If the ray starts within this sphere, return the empty result. if (glm::length2(m_centre - _ray.m_origin) < glm::pow(m_radius, 2)) { return result; } // Otherwise, calculate the intersection as normal. else { // Calculate the dot product between the ray's direction and the direction towards the centre of the sphere from the ray's origin. float_t sphereRayDot = glm::dot(m_centre - _ray.m_origin, _ray.m_direction); // If the dot product is less than or equal to 0, the sphere is beyond the ray intersecting it, so return the empty result. if (sphereRayDot <= 0) { return result; } // Otherwise, calculate the intersection. else { // Calculates the closest point of the ray to this sphere. glm::vec3 closestPoint = _ray.ClosestPoint(m_centre); // Calculate the squared distance between the closest point and the centre of this sphere. float_t squaredDistance = glm::length2(m_centre - closestPoint); // If the distance is exactly the radius, there was one intersection. if (squaredDistance == glm::pow(m_radius, 2)) { result.m_didHit = true; result.m_firstIntersection = closestPoint; result.m_secondIntersection = closestPoint; result.m_distance = glm::length(closestPoint - _ray.m_origin); return result; } // If the distance is shorter than the radius, there were two intersections. else if (squaredDistance < glm::pow(m_radius, 2)) { // Calculate the length between the closest point and circle radius. float_t closestRadiusLength = glm::sqrt(glm::pow(m_radius, 2) - squaredDistance); result.m_didHit = true; result.m_firstIntersection = _ray.m_origin + (sphereRayDot - closestRadiusLength) * _ray.m_direction; result.m_secondIntersection = _ray.m_origin + (sphereRayDot + closestRadiusLength) * _ray.m_direction; result.m_distance = glm::length(result.m_firstIntersection - _ray.m_origin); return result; } // Otherwise, there were none. else { return result; } } } }
[ "liruotaku@gmail.com" ]
liruotaku@gmail.com
164d9614923449654cac54ccc7950494a3ddaa91
9a130efcd9061e526d4a11f06036319fad179afa
/uva/929.cpp
81d1a1711a4bb6001c68089a5fc41c9f2f0bcd9a
[]
no_license
divyah12/uva
1c5ba3047b0fee781aaf7b95cc71f6df80282e18
c055651e68f696f2a8828601984d9f45e5388759
refs/heads/master
2021-01-13T16:44:57.735646
2017-04-26T01:04:19
2017-04-26T01:04:19
77,159,925
0
0
null
null
null
null
UTF-8
C++
false
false
1,285
cpp
#include <iostream> #include<vector> #include<set> #define INT_MAX 2147483647 #define endl '\n' using namespace std; void dijkstra(vector<vector<int>> graph, int start,int first_val,int n,int m) { //defining infinity as largest int //each vertices distance is set to infinity vector<int> dist(n*m,INT_MAX); vector<bool> visited(n*m, false); dist[start] = 0;//distance of src(start) set to 0 for (int i = 0; i <n*m; i++) { //find u int min = INT_MAX,u; for (int k = 0; k < n*m; k++) { if (visited[k] == false && dist[k] <= min) { min = dist[k]; u = k; } } visited[u]=true; for (int j = 0; j <n*m; j++) { if(!visited[j] && ) } } //for (int i = 0; i <dist.size(); i++) //printing the result of src to dest(last node)alnog with src distance int result = first_val + dist.back(); cout <<result << endl; } int main() { int casenum; cin >> casenum;//number of case while (casenum--) { int n, m; cin >> n;//row cin >> m;//colum vector<vector<int>> maze(n, vector<int>(m));//matrix for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) {//write val directly to matrix cin >> maze[i][j]; } } cout << dijkstra(maze,0,maze[0][0],n,m) << endl; }//while-end return 0; }//main-end
[ "divya.h.shree12@gmail.com" ]
divya.h.shree12@gmail.com
dc57607efb6d76e26a475bb5646443d4220c12f6
9bcff70ac1d9cdd149ef76583375ad5349d8ffb8
/Lab 20/balanced_tree.cpp
f80275ce354385f3a21c5ee18d3c6b91602ffeb6
[]
no_license
Reap3r/Labs
d972676e94779e315b294fe4abac43a4e3f58356
597684cff82ed1eee941683f782837c6465e9593
refs/heads/main
2023-05-08T10:23:44.494410
2021-06-04T13:50:44
2021-06-04T13:50:44
312,559,487
0
1
null
null
null
null
UTF-8
C++
false
false
1,122
cpp
#include "balanced_tree.h" #include <algorithm> balanced_tree::balanced_tree(double i) { left = nullptr; right = nullptr; item = i; num_of_children = 0; } void balanced_tree::add_leaf(double l) { if (left == nullptr) { balanced_tree* leaf = new balanced_tree(l); left = leaf; } else if (right == nullptr) { balanced_tree* leaf = new balanced_tree(l); right = leaf; } else if (left->num_of_children > right->num_of_children) { right->add_leaf(l); } else { left->add_leaf(l); } ++num_of_children; } double balanced_tree::get_item() { return item; } double balanced_tree::find_max() { if (right == nullptr && left == nullptr) { return item; } else if (right == nullptr) { return std::max(item, left->find_max()); } else { return std::max({item, left->find_max(), right->find_max()}); } } int balanced_tree::get_n_of_children() { return num_of_children; } balanced_tree* balanced_tree::get_left() { return left; } balanced_tree* balanced_tree::get_right() { return right; }
[ "noreply@github.com" ]
noreply@github.com
24bc123cf40998fb1a2c0afd71f4a77bdb626e10
02a19fd0b3059025f91ba592e1928ce2a4d93929
/src/bit-io.cpp
89ea7b48207a5facaf8aaf541b2a476f6e90cd36
[ "MIT" ]
permissive
operutka/alzw
618c6c7dcdde6e785adb9ad7bcedf2214440c11e
117fa7ae065ace7c5d35d90a0e9b3d2c8ed61a24
refs/heads/master
2021-01-01T05:34:54.068902
2015-04-27T11:22:33
2015-04-27T11:22:33
34,070,076
0
0
null
null
null
null
UTF-8
C++
false
false
5,732
cpp
/* Copyright (c) 2015 Perutka, Ondrej Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #include "bit-io.hpp" #include "utils.hpp" #include "exception.hpp" #include <cstring> using namespace alzw; void bwriter::write_str(const char* str) { write_buf((const uint8_t*)str, (strlen(str) + 1) << 3); } void bwriter::write_buf(const uint8_t* buffer, size_t bits) { size_t offset = 0; while (bits >= 8) { write(buffer[offset++], 8); bits -= 8; } if (bits > 0) write(buffer[offset], bits); } int bwriter::write_gamma(uint64_t n) { int bits = utils::number_width(n); int width = (bits << 1) - 1; n = (1 << (bits - 1)) | n; write(n, width); return width; } int bwriter::write_delta(uint64_t n) { int bits = utils::number_width(n); int gwidth = write_gamma(bits); int bwidth = bits - 1; write(n, bwidth); return gwidth + bwidth; } int breader::read_int() { uint64_t val = 0; read(val, sizeof(int) << 3); return (int)val; } uint64_t breader::read_gamma() { uint64_t bits = 0; uint64_t val = 0; int len = read(val, 1); while (len && val == 0) { len = read(val, 1); bits++; } if (bits == 0) return 1; else if (bits > 63) throw runtime_exception("gamma code overflow"); read(val, bits); return (1 << bits) | val; } uint64_t breader::read_delta() { uint64_t bits = read_gamma() - 1; uint64_t val = 0; if (bits == 0) return 1; else if (bits > 63) throw runtime_exception("delta code overflow"); read(val, bits); return (1 << bits) | val; } ssize_t breader::read_str(char* buffer, size_t size) { size_t offset = 0; uint64_t val = 0; int res = read(val, 8); while (res > 0 && val != 0 && (offset + 1) < size) { buffer[offset++] = (char)val; res = read(val, 8); } buffer[offset] = 0; if (val != 0) return -1; return offset; } stream_bwriter::stream_bwriter(FILE* stream) { this->stream = stream; this->bit_offset = 0; } stream_bwriter::~stream_bwriter() { flush(); } void stream_bwriter::write(uint64_t bits, int width) { if ((bit_offset + width) > (sizeof(buffer) << 3)) { fwrite(buffer, sizeof(uint8_t), bit_offset >> 3, stream); if (ferror(stream)) throw io_exception("error while writing into a file"); buffer[0] = buffer[bit_offset >> 3]; bit_offset &= 0x7; } while (width > 0) { int wa = 8 - (bit_offset & 0x7); int wr = wa > width ? width : wa; uint8_t m = (1 << wr) - 1; uint8_t b = (bits >> (width - wr)) & m; buffer[bit_offset >> 3] &= ~m << (wa - wr); buffer[bit_offset >> 3] |= b << (wa - wr); width -= wr; bit_offset += wr; } } void stream_bwriter::flush() { fwrite(buffer, sizeof(uint8_t), (bit_offset + 7) >> 3, stream); fflush(stream); bit_offset = 0; } file_bwriter::file_bwriter(const char* file) : stream_bwriter(fopen(file, "wb")) { if (!stream) throw io_exception("unable to open output file: %s", file); } file_bwriter::~file_bwriter() { fclose(stream); } stream_breader::stream_breader(FILE* stream) { this->stream = stream; this->bit_offset = 0; this->available = 0; } stream_breader::~stream_breader() { } int stream_breader::read(uint64_t& bits, int width) { if ((bit_offset + width) > available) { size_t a = (available >> 3) - (bit_offset >> 3); memcpy(buffer, buffer + (bit_offset >> 3), a); available = a << 3; bit_offset &= 0x7; a = fread(buffer + a, sizeof(uint8_t), sizeof(buffer) - a, stream); if (ferror(stream)) throw io_exception("error while reading from a file"); available += a << 3; } if (bit_offset >= available) return 0; if ((bit_offset + width) > available) width = available - bit_offset; int rest = width; bits = 0; while (rest > 0) { int wa = 8 - (bit_offset & 0x7); int wr = wa > rest ? rest : wa; uint8_t m = (1 << wa) - 1; uint8_t b = buffer[bit_offset >> 3] & m; bits <<= wr; bits |= b >> (wa - wr); rest -= wr; bit_offset += wr; } return width; } file_breader::file_breader(const char* file) : stream_breader(fopen(file, "rb")) { if (!stream) throw io_exception("unable to open input file: %s", file); } file_breader::~file_breader() { fclose(stream); }
[ "perutka.ondrej@gmail.com" ]
perutka.ondrej@gmail.com
2f9f94b0585758fbdc816d3243d6e71df1de7a3c
f82b315643718a69aebde709cd93e66612269bd3
/src/misc/Queue.h
a433e8ddb5294bb6e2d46c7e373068acfb5ddc43
[]
no_license
jakewhitton/radiance-pixelpusher
64c6264b86b9de888ed0c6ea12abd7270ff62279
aded36dbe5e108e77cc1a9b365c5bf5d429d73bc
refs/heads/master
2020-04-27T19:55:08.004332
2019-08-29T00:50:04
2019-08-29T00:50:04
174,639,135
1
0
null
null
null
null
UTF-8
C++
false
false
1,377
h
#ifndef QUEUE_H #define QUEUE_H #include "BlockingCollection.h" #include "OperationInterruptedException.h" #include "misc/Log.h" template <typename Element> class Queue { using milliseconds = std::chrono::milliseconds; using Status = code_machina::BlockingCollectionStatus; code_machina::BlockingQueue<Element> _queue; static constexpr milliseconds defaultTimeout = milliseconds(10); public: Queue(const int queueSize = 10) : _queue(queueSize) { } bool empty() { return _queue.empty(); } void add(Element e, const bool & condition, const bool trigger) { Status status; do { if (condition == trigger) { throw OperationInterruptedException(); } status = _queue.try_add_timed(std::move(e), defaultTimeout); } while (status != Status::Ok); } bool add(Element e, unsigned timeoutMs) { Status status = _queue.try_add_timed(std::move(e), milliseconds(timeoutMs)); return status == Status::Ok; } void take(Element & e, const bool & condition, const bool trigger) { Status status; do { if (condition == trigger) { throw OperationInterruptedException(); } status = _queue.try_take(e, defaultTimeout); } while (status != Status::Ok); } bool take(Element & e, unsigned timeoutMs) { Status status = _queue.try_take(e, milliseconds(timeoutMs)); return status == Status::Ok; } }; #endif
[ "jwhitton@mit.edu" ]
jwhitton@mit.edu
69dfa52934af5dc26b4cdb9657e8fb7336614cd0
4957edc2fb4c9bc564a0a25883071a523fdf6980
/include/Utils/RandomBoolStream.h
b871abaf46ae7f20e5b038846bacf78f1c1f5eab
[]
no_license
michitux/extmem-lfr
0be8a58d3a6897923e9671648984eef075ba8552
a6d6e43b0fb262480443ec02bd11e0ca5a0a56bc
refs/heads/master
2020-03-16T16:23:38.710235
2018-05-07T09:05:28
2018-05-07T09:05:28
132,785,379
0
1
null
2018-10-18T12:12:46
2018-05-09T16:36:40
C++
UTF-8
C++
false
false
946
h
#pragma once #include <defs.h> #include <stxxl/random> #include <memory> class RandomBoolStream { private: unsigned int _flag_bits_remaining = 0; uint64_t _flag_bits; std::unique_ptr<stxxl::random_number64> _random_integer_value_ptr; stxxl::random_number64& _random_integer; public: RandomBoolStream() : _random_integer_value_ptr(new stxxl::random_number64), _random_integer(*_random_integer_value_ptr) { operator++(); } RandomBoolStream(stxxl::random_number64& generator) : _random_integer(generator) { operator++(); } bool empty() const { return false; } bool operator *() const { return _flag_bits & 1; } RandomBoolStream& operator++() { if (!_flag_bits_remaining) { _flag_bits_remaining = 8 * sizeof(_flag_bits); _flag_bits = _random_integer(); } else { _flag_bits >>= 1; --_flag_bits_remaining; } return *this; } };
[ "michael.hamann@kit.edu" ]
michael.hamann@kit.edu
bb8a6b9a9c69e8e0d1f6210c2634b58e7f32cde6
0c71ffb070edbffdf807316d416c77830bd07835
/RDCServer/RDCConfiguration.cpp
cc2700ca409acad9b881ac2e78482f7f7e67147c
[]
no_license
WangLuofan/RDCSource
2d8dfa2bfb4f4b3000c697381b870d8f47d105b0
ffde6f67aaa634bcef011e25e7a3e77c74c673d3
refs/heads/master
2021-04-06T00:47:13.823018
2018-03-31T08:51:09
2018-03-31T08:51:09
124,505,805
1
0
null
null
null
null
UTF-8
C++
false
false
1,254
cpp
#include "RDCConfiguration.h" #include <QCoreApplication> #include <QSettings> #include <QString> #include <QFile> RDCConfiguration* RDCConfiguration::config = nullptr; RDCConfiguration::RDCConfiguration() : m_pSettings(new QSettings(QSettings::NativeFormat, QSettings::UserScope, QCoreApplication::organizationName(), QCoreApplication::applicationName())) { this->initDefaultValues(); } RDCConfiguration* RDCConfiguration::standardConfiguration(void) { if(RDCConfiguration::config == nullptr) RDCConfiguration::config = new RDCConfiguration(); return RDCConfiguration::config; } void RDCConfiguration::initDefaultValues(void) { QFile file(this->m_pSettings->fileName()); if(!file.exists()) { //初始化配置 this->m_pSettings->setValue(QString("ListenPort"), QString("9999")); } return ; } const QVariant RDCConfiguration::valueForKey(const char* key) const { return this->m_pSettings->value(QString(key)); } void RDCConfiguration::setValueForKey(const QVariant& value, const char* key) { return this->m_pSettings->setValue(QString(key), value); }
[ "wangluofan@gmail.com" ]
wangluofan@gmail.com
57ea40e539ddacf25a7c994e1153525cdf6522c2
bcf4b953bb92d462b8db140adc6da7e03a7592d6
/NewYearChaos.cpp
d5d0d35cdf10b5e393ddc55f8bbf37dbe645f228
[]
no_license
brucekevinadams/CPP-Programs
0a9d4a073d2483bd80d471616002723d8c9aae96
cc6e5b4c36f1fada28e23084e2c69e46d61b852f
refs/heads/master
2018-12-23T02:16:38.018708
2018-10-18T13:18:34
2018-10-18T13:18:34
117,719,141
0
0
null
null
null
null
UTF-8
C++
false
false
2,008
cpp
/* * Author: Bruce Adams * email: ezaroth@gmail.com * website: austingamestudios.com * * C++ program from a Hackerrank problem. */ #include <bits/stdc++.h> using namespace std; vector<string> split_string(string); // Complete the minimumBribes function below. void minimumBribes(vector<int> q) { int ans = 0; for (int i = q.size() - 1; i >= 0; i--) { if (q[i] - (i + 1) > 2) { cout << "Too chaotic" << endl; return; } for (int j = max(0, q[i] - 2); j < i; j++) if (q[j] > q[i]) ans++; } cout << ans << endl; } int main() { int t; cin >> t; cin.ignore(numeric_limits<streamsize>::max(), '\n'); for (int t_itr = 0; t_itr < t; t_itr++) { int n; cin >> n; cin.ignore(numeric_limits<streamsize>::max(), '\n'); string q_temp_temp; getline(cin, q_temp_temp); vector<string> q_temp = split_string(q_temp_temp); vector<int> q(n); for (int i = 0; i < n; i++) { int q_item = stoi(q_temp[i]); q[i] = q_item; } minimumBribes(q); } return 0; } vector<string> split_string(string input_string) { string::iterator new_end = unique(input_string.begin(), input_string.end(), [] (const char &x, const char &y) { return x == y and x == ' '; }); input_string.erase(new_end, input_string.end()); while (input_string[input_string.length() - 1] == ' ') { input_string.pop_back(); } vector<string> splits; char delimiter = ' '; size_t i = 0; size_t pos = input_string.find(delimiter); while (pos != string::npos) { splits.push_back(input_string.substr(i, pos - i)); i = pos + 1; pos = input_string.find(delimiter, i); } splits.push_back(input_string.substr(i, min(pos, input_string.length()) - i + 1)); return splits; }
[ "noreply@github.com" ]
noreply@github.com
ec855f3b97989dce2187c59e75c787a277851c1d
f55a5a7152e14e217b30807325dc9223b82e2286
/ParticleSkinner/marchingTet.H
8b02cac83b3605a62ee0b9db5713455ebdfec643
[ "MIT" ]
permissive
elrnv/sph-cpp
152bbe8f8648e73b261ecabd90b63eebfa8d2d77
ba63d9b6d44710c0f1c34f05047c815ee1997651
refs/heads/master
2020-05-31T08:29:11.399103
2020-01-29T08:59:14
2020-01-29T08:59:14
30,516,081
12
2
null
null
null
null
UTF-8
C++
false
false
2,473
h
// Copyright (c) 2011, Regents of the University of Utah // 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 <organization> 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 <COPYRIGHT HOLDER> 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. #ifndef marchingTet_H #define marchingTet_H #include "slUtil.H" #include "slArray.H" class MarchingTet { public: MarchingTet(int nx, int ny, int nz, double h, const SlVector3 &lc); void buildTriangleMesh(const SlArray3D<double> &phi, std::vector<SlTri> &triangles, std::vector<SlVector3> &meshPts); protected: int nx_, ny_, nz_; double h_; SlVector3 lc_, uc_; SlArray3D<int> xFace, yFace, zFace, xEdge, yEdge, zEdge; SlVector3 createVertex(SlVector3 &a, SlVector3 &b, double aPhi, double bPhi); SlVector3 createVertexCR(const SlArray3D<double> &phi, SlVector3 &a, SlVector3 &b, double aPhi, double bPhi); double catmullrom(const SlArray3D<double> &phi, SlVector3 &x); bool doTet(int e1, int e2, int e3, int e4, int e5, int e6, double val0, double val1, double val2, double val3, std::vector<SlTri> &triangles, std::vector<SlVector3> &meshPts) ; }; #endif
[ "egor.larionov@gmail.com" ]
egor.larionov@gmail.com
456dc434b6297f46726e845ad0e72280a72b9a1f
f8ad76fc99f56c3d415fd588d7a4e52841f023bd
/Assignments/Assignment_1/Savitch_Ch1_Prob6_Free Fall/main.cpp
b8f923fa367ae63f4abb78adb11523a97883a34c
[]
no_license
jg1287010/Kovacs_Jamie_CIS5_40106
1335610d7af984b05ac46fb8b68d752d9f751adc
5db11812fa99a00482bb14aab9d6fd7dc4bc2e4d
refs/heads/master
2020-04-14T18:02:00.996381
2019-01-06T04:23:49
2019-01-06T04:23:49
164,003,687
0
0
null
null
null
null
UTF-8
C++
false
false
644
cpp
/* * File: main.cpp * Author: Jamie Kovacs * Created on January 5, 2019 * Purpose: * */ //System Libraries #include <iostream> //Input/Output Library using namespace std; //User Libraries //Global Constants, no Global Variables are allowed //Math/Physics/Conversions/Higher Dimensions - i.e. PI, e, etc... //Function Prototypes //Execution Begins Here! int main(int argc, char** argv) { //Set the random number seed //Declare Variables //Initialize or input i.e. set variable values //Map inputs -> outputs //Display the outputs //Exit stage right or left! return 0; }
[ "jgould3@student.rccd.edu" ]
jgould3@student.rccd.edu
c3165123db187b9ab43a5f98d2e1d02cd17f1ae1
8faa7462f32ec045f448af376855d2138d33cca3
/Plugins/RenderDocPlugin/Source/RenderDocPlugin/Private/RenderDocPluginAboutWindow.cpp
eac1a419eb7c109df4123754f6344082dcda7365
[]
no_license
nipananodesu/SGame
fac446c8c92961b7673c35006774786b483676c4
29d712a631a4896d1d900981da052c40f1b97fb4
refs/heads/master
2021-01-18T05:28:51.414223
2017-01-15T14:51:01
2017-01-15T14:51:01
null
0
0
null
null
null
null
UTF-8
C++
false
false
3,694
cpp
/****************************************************************************** * The MIT License (MIT) * * Copyright (c) 2014 Fredrik Lindh * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. ******************************************************************************/ #include "RenderDocPluginPrivatePCH.h" #include "Editor.h" #include "RenderDocPluginStyle.h" #include "RenderDocPluginAboutWindow.h" #define LOCTEXT_NAMESPACE "RenderDocPluginAboutWindow" void SRenderDocPluginAboutWindow::Construct(const FArguments& InArgs) { FString Message = FString("Hello and thank you for trying out this plugin!\n\n" \ "To capture a frame, press the green capture button on the top\n" \ "right of any viewport. If you cannot see the button, you might\n" \ "have to adjust your viewport width until all buttons fit the screen.\n" \ "You can also use the assigned hotkey (default is Alt+F12).\n\n" \ "For best performance I recommend using the experimental\n" \ "AutoCompileShaders branch in the repository and downloading\n" \ "my fork of the engine so you are able to include shader meta\n" \ "data in your compiled shaders.This will make it easier to step\n" \ "through your shader code in the UI as you will be able to see \n" \ "your variable names etc.\n\n" \ "If you have any questions or suggestions I'll try to answer them \n" \ "as best I can at:\ntemaran(at) gmail(dot) com.\n\n" \ "You can find my fork and updates to the plugins at these github repos:\n" \ "https://github.com/Temaran/UE4RenderDocPlugin\n" \ "https://github.com/Temaran/UnrealEngine (RenderDocPluginChanges)"); SWindow::Construct(SWindow::FArguments() .SupportsMaximize(false) .SupportsMinimize(false) .IsPopupWindow(false) .CreateTitleBar(false) .SizingRule(ESizingRule::FixedSize) .SupportsTransparency(EWindowTransparency::None) .InitialOpacity(1.0f) .FocusWhenFirstShown(true) .bDragAnywhere(false) .ActivateWhenFirstShown(true) .ClientSize(FVector2D(400, 400)) .ScreenPosition(FVector2D((float)(GEditor->GetActiveViewport()->GetSizeXY().X) / 2.0, (float)(GEditor->GetActiveViewport()->GetSizeXY().Y) / 2.0)) [ SNew(SVerticalBox) + SVerticalBox::Slot() .FillHeight(0.9f) .Padding(5) [ SNew(STextBlock) .Text(FText::FromString(Message)) ] + SVerticalBox::Slot() .FillHeight(0.1f) [ SNew(SButton) .VAlign(VAlign_Center) .OnClicked(this, &SRenderDocPluginAboutWindow::Close) .Text(LOCTEXT("OkButton", "Ok")) ] ]); bIsTopmostWindow = true; FlashWindow(); } FReply SRenderDocPluginAboutWindow::Close() { RequestDestroyWindow(); return FReply::Handled(); } #undef LOCTEXT_NAMESPACE
[ "wangli.rei@gamil.com" ]
wangli.rei@gamil.com
a1f1ca5ad935961a372b6ebc6fc387faa512a52f
191126328427ffb1d2cebcc5d3ccb670a7f4f8be
/sortdist.cpp
d66b32121a9e7b553fcaea9b52549f83706aac11
[]
no_license
drviruses/CP
090ca7db998f7f113d85ab96a91a73fd9d5892ac
69294c62218fda3453daf4b69251ab98bb24cccb
refs/heads/master
2023-03-14T06:09:15.174975
2021-03-01T05:04:26
2021-03-01T05:04:26
305,608,273
1
0
null
null
null
null
UTF-8
C++
false
false
2,206
cpp
/* @uthor: Amit Kumar user -->GitHub: drviruses ; CodeChef: dr_virus_ ; Codeforces,AtCoder,Hackerearth,Hakerrank: dr_virus; */ #include <bits/stdc++.h> #include <chrono> using namespace std; using namespace std::chrono; //#include <boost/multiprecision/cpp_int.hpp> //namespace mp = boost::multiprecision; //#define ln mp::cpp_int; #define ll long long #define ld long double #define ull unsigned long long #define all(vec) vec.begin(),vec.end() #define endl "\n" ll google_itr = 1; #define google(x) cout<<"Case #"<<x<<":" #define pi 3.14159265358979323846264338327950L const ll mod = 1e9+7; const ll inf = 1e18; vector<vector<ll>> adj; vector<bool> visited; vector<ll> par,dist; void mybfs(ll scr){ queue<ll> q; q.push(scr); par[scr] = -1; while(!q.empty()){ ll rec = q.front(); q.pop(); for(auto i:adj[rec]){ if(!visited[i]){ visited[i] = true; q.push(i); par[i] = rec; dist[i] = dist[rec] + 1; } } } } void virus(){ ll nodes, ini; cin>>nodes>>ini; ini--; adj.resize(nodes); visited.resize(nodes,false); par.resize(nodes); dist.resize(nodes); for(auto i=0; i<nodes; i++){ for(auto j=0; j<nodes; j++){ ll t; cin>>t; if(t) adj[i].push_back(j); } } mybfs(ini); for(auto i=0; i<nodes; i++){ if(i == ini) cout<<"0 "; else if(dist[i] == 0) cout<<"-1 "; else cout<<dist[i]<<" "; } } int32_t main(){ ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); /*#ifndef ONLINE_JUDGE freopen("input.txt","r",stdin); freopen("output.txt","w",stdout); #endif*/ ll t = 1; //cin>>t; while(t--){ auto start = high_resolution_clock::now(); virus(); auto stop = high_resolution_clock::now(); auto duration = duration_cast<seconds>(stop - start); cerr << "\n Time: "<<duration.count()<<endl; //your code goes here } return 0; }
[ "amitkumarhero28@gmail.com" ]
amitkumarhero28@gmail.com
23faf542df5a69291de89515171de1f44ed697c0
777a75e6ed0934c193aece9de4421f8d8db01aac
/src/Providers/UNIXProviders/AuthorizedSubject/UNIX_AuthorizedSubject.cpp
6b13bcab80de5df0c7c45e7630ba2c8257596350
[ "MIT" ]
permissive
brunolauze/openpegasus-providers-old
20fc13958016e35dc4d87f93d1999db0eae9010a
b00f1aad575bae144b8538bf57ba5fd5582a4ec7
refs/heads/master
2021-01-01T20:05:44.559362
2014-04-30T17:50:06
2014-04-30T17:50:06
19,132,738
1
0
null
null
null
null
UTF-8
C++
false
false
3,272
cpp
//%LICENSE//////////////////////////////////////////////////////////////// // // Licensed to The Open Group (TOG) under one or more contributor license // agreements. Refer to the OpenPegasusNOTICE.txt file distributed with // this work for additional information regarding copyright ownership. // Each contributor licenses this file to you under the OpenPegasus Open // Source License; you may not use this file except in compliance with the // License. // // Permission is hereby granted, free of charge, to any person obtaining a // copy of this software and associated documentation files (the "Software"), // to deal in the Software without restriction, including without limitation // the rights to use, copy, modify, merge, publish, distribute, sublicense, // and/or sell copies of the Software, and to permit persons to whom the // Software is furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included // in all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. // IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY // CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, // TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE // SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // ////////////////////////////////////////////////////////////////////////// // //%///////////////////////////////////////////////////////////////////////// #include "UNIX_AuthorizedSubject.h" #if defined(PEGASUS_OS_HPUX) # include "UNIX_AuthorizedSubject_HPUX.hxx" # include "UNIX_AuthorizedSubject_HPUX.hpp" #elif defined(PEGASUS_OS_LINUX) # include "UNIX_AuthorizedSubject_LINUX.hxx" # include "UNIX_AuthorizedSubject_LINUX.hpp" #elif defined(PEGASUS_OS_DARWIN) # include "UNIX_AuthorizedSubject_DARWIN.hxx" # include "UNIX_AuthorizedSubject_DARWIN.hpp" #elif defined(PEGASUS_OS_AIX) # include "UNIX_AuthorizedSubject_AIX.hxx" # include "UNIX_AuthorizedSubject_AIX.hpp" #elif defined(PEGASUS_OS_FREEBSD) # include "UNIX_AuthorizedSubject_FREEBSD.hxx" # include "UNIX_AuthorizedSubject_FREEBSD.hpp" #elif defined(PEGASUS_OS_SOLARIS) # include "UNIX_AuthorizedSubject_SOLARIS.hxx" # include "UNIX_AuthorizedSubject_SOLARIS.hpp" #elif defined(PEGASUS_OS_ZOS) # include "UNIX_AuthorizedSubject_ZOS.hxx" # include "UNIX_AuthorizedSubject_ZOS.hpp" #elif defined(PEGASUS_OS_VMS) # include "UNIX_AuthorizedSubject_VMS.hxx" # include "UNIX_AuthorizedSubject_VMS.hpp" #elif defined(PEGASUS_OS_TRU64) # include "UNIX_AuthorizedSubject_TRU64.hxx" # include "UNIX_AuthorizedSubject_TRU64.hpp" #else # include "UNIX_AuthorizedSubject_STUB.hxx" # include "UNIX_AuthorizedSubject_STUB.hpp" #endif Boolean UNIX_AuthorizedSubject::validateKey(CIMKeyBinding &kb) const { /* Keys */ //Privilege //PrivilegedElement CIMName name = kb.getName(); if (name.equal(PROPERTY_PRIVILEGE) || name.equal(PROPERTY_PRIVILEGED_ELEMENT) ) return true; return false; } void UNIX_AuthorizedSubject::setScope(CIMName scope) { currentScope = scope; }
[ "brunolauze@msn.com" ]
brunolauze@msn.com
769b50ed07cae113d922647545905d8afa53bfab
c5271b18225b183c54526f13ab968b942c5d1c49
/tmp.cpp
6d62fd432dd5f82b044961f1b4e1ea7413867218
[]
no_license
coderpen-me/competitive_programming
afbc41e0eed12741ba4dcc2650a02e667506739c
3d8d00b9099871c1b044e1ac3f25cc1eb17dba64
refs/heads/master
2021-06-28T09:48:01.156675
2021-03-09T19:01:09
2021-03-09T19:01:09
220,846,911
2
2
null
null
null
null
UTF-8
C++
false
false
2,005
cpp
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define vi vector<int> #define vs vector<string> #define vvi vector<vector<int>> #define LP(i, n) for (ll i = 0; i < n; i++) #define LP1(i, n) for (ll i = 1; i <= n; i++) #define BLP1(i, n) for (ll i = n; i > 0; i--) #define BLP(i, n) for (ll i = n; i >= 0; i--) #define el '\n' #define IOS() \ ios_base::sync_with_stdio(0); \ cin.tie(0); #define tc() testcases() #define pvi(A) printvectorint(A) #define pvs(A) printvectorstring(A) #define pvvi(A) printvectorvectorint(A) #define a1(a) cout << a << " "; #define a2(a, b) cout << a << " " << b << " "; #define a3(a, b, c) cout << a << " " << b << " " << c << " "; #define a4(a, b, c, d) cout << a << " " << b << " " << c << " " << d << " "; #define a5(a, b, c, d, e) cout << a << " " << b << " " << c << " " << d << " " << e << " "; #define b1(a) cout << a << "\n"; #define b2(a, b) cout << a << " " << b << "\n"; #define b3(a, b, c) cout << a << " " << b << " " << c << "\n"; #define b4(a, b, c, d) cout << a << " " << b << " " << c << " " << d << "\n"; #define b5(a, b, c, d, e) cout << a << " " << b << " " << c << " " << d << " " << e << "\n"; #define nl cout << "\n" const ll MAXn = 1e5 + 5, MAXlg = __lg(MAXn) + 2; const ll MOD = 1000000007; const ll INF = ll(1e15); void printvectorint(vector<int> A) { nl; for (auto x : A) { a1(x); } nl; } void printvectorstring(vector<string> A) { nl; for (auto x : A) { cout << (x); } nl; } void printvectorvectorint(vector<vector<int>> A) { nl; for (auto x : A) { for (auto y : x) { a1(y); } nl; } nl; } ll t = 0, u = 0, v = 0, w = 0, x = 0, y = 0, z = 0; ll sum = 0, sum1 = 0, mul = 0, subs = 0, test = 0, num = 0, num1 = 0; string in; int testcases() { cin >> test; return test; } int main() { ll t; cin >> t; while (t--) { } return 0; }
[ "coderpen@gmail.com" ]
coderpen@gmail.com
65619ba86e0038f96e053ca88731222d143a9291
04f379ce942b1b8878467c3f511f2974bdfbc69b
/src/qt/transactionfilterproxy.cpp
3482821010666afd42077bdc319f3a4a3216a65b
[ "MIT" ]
permissive
musdcoin1/musdcoin
0ee082256bb7987eea5a58b66a9b43336d3c6718
a310dc41074e55e6504e4839f2c55ecf76c7a34d
refs/heads/master
2021-05-05T22:22:08.398938
2018-01-03T14:25:07
2018-01-03T14:25:07
116,145,629
1
0
null
null
null
null
UTF-8
C++
false
false
2,671
cpp
// Copyright (c) 2011-2013 The Bitcoin developers // Copyright (c) 2014-2017 Thinkwide Technology developers // Distributed under the MIT/X11 software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. #include "transactionfilterproxy.h" #include "transactiontablemodel.h" #include <QDateTime> #include <cstdlib> // Earliest date that can be represented (far in the past) const QDateTime TransactionFilterProxy::MIN_DATE = QDateTime::fromTime_t(0); // Last date that can be represented (far in the future) const QDateTime TransactionFilterProxy::MAX_DATE = QDateTime::fromTime_t(0xFFFFFFFF); TransactionFilterProxy::TransactionFilterProxy(QObject *parent) : QSortFilterProxyModel(parent), dateFrom(MIN_DATE), dateTo(MAX_DATE), addrPrefix(), typeFilter(ALL_TYPES), minAmount(0), limitRows(-1) { } bool TransactionFilterProxy::filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const { QModelIndex index = sourceModel()->index(sourceRow, 0, sourceParent); int type = index.data(TransactionTableModel::TypeRole).toInt(); QDateTime datetime = index.data(TransactionTableModel::DateRole).toDateTime(); QString address = index.data(TransactionTableModel::AddressRole).toString(); QString label = index.data(TransactionTableModel::LabelRole).toString(); qint64 amount = llabs(index.data(TransactionTableModel::AmountRole).toLongLong()); if(!(TYPE(type) & typeFilter)) return false; if(datetime < dateFrom || datetime > dateTo) return false; if (!address.contains(addrPrefix, Qt::CaseInsensitive) && !label.contains(addrPrefix, Qt::CaseInsensitive)) return false; if(amount < minAmount) return false; return true; } void TransactionFilterProxy::setDateRange(const QDateTime &from, const QDateTime &to) { this->dateFrom = from; this->dateTo = to; invalidateFilter(); } void TransactionFilterProxy::setAddressPrefix(const QString &addrPrefix) { this->addrPrefix = addrPrefix; invalidateFilter(); } void TransactionFilterProxy::setTypeFilter(quint32 modes) { this->typeFilter = modes; invalidateFilter(); } void TransactionFilterProxy::setMinAmount(qint64 minimum) { this->minAmount = minimum; invalidateFilter(); } void TransactionFilterProxy::setLimit(int limit) { this->limitRows = limit; } int TransactionFilterProxy::rowCount(const QModelIndex &parent) const { if(limitRows != -1) { return std::min(QSortFilterProxyModel::rowCount(parent), limitRows); } else { return QSortFilterProxyModel::rowCount(parent); } }
[ "thinkwide.sa1@gmail.com" ]
thinkwide.sa1@gmail.com
caa451c492c831dd64ef445e9e2e9ee4b7924805
8178161f4eabf12eae1b0e099eac9e8bc4df1bbe
/simulation client/SimulationLoop/UDP_sender.h
21a972e4199a58fe998aab248c2589b57271759e
[]
no_license
AlexKLM/Physics-sim-and-concurrency
367f1820e6d0049f07f9b733d72685fea9d77256
16218695242a879f8d064e77d2a35184298464e1
refs/heads/master
2020-05-17T17:32:11.166574
2013-07-24T10:33:48
2013-07-24T10:33:48
null
0
0
null
null
null
null
UTF-8
C++
false
false
735
h
#pragma once #include <iostream> #include <winsock2.h> #include <process.h> #include<Windows.h> #include <string> #include <vector> #include <sstream> #include "shared_memory.h" #include "shared_struct.h" class UDP_sender { private: HANDLE thread; SOCKET send_socket; sockaddr_in server_addr; bool ready; int run(); public: bool isready();//ready to send; void setready(bool input); void start(); bool send(string msg); bool setup(sockaddr_in address); void close(); void set_address(sockaddr_in address); UDP_sender(sockaddr_in address); UDP_sender(void); ~UDP_sender(void); static unsigned __stdcall threadFunc(void *param) { if (param) return ((UDP_sender*)param)->run(); return 1; // Return error } };
[ "alex900622@gmail.com" ]
alex900622@gmail.com
95c1d2b105cfa6c764c4c441a14729beefaae19f
980d09072b5ec9d0b456156b04ec8ad5b7f96c2b
/gcd.cpp
95f6a62e371a9370bcbe9c3c2dced011d7f6e8b3
[]
no_license
kant-shashi/cpp-code
69c7242ce4b932efa1011b5044dd3a9d5bc2ca63
f289a7429dd26c1d0e24ccb2672bf4bec1e4686b
refs/heads/master
2018-12-31T18:07:43.300725
2013-06-23T12:04:29
2013-06-23T12:04:29
null
0
0
null
null
null
null
UTF-8
C++
false
false
597
cpp
/** * Author: Shashi Kant (blog.tenhash.com) * code to find the gcd of two integers. use 'echo $?' to find the returned value of last program executed. */ #include<iostream> using namespace std; int main() { unsigned long long a,b,x,y,temp; cin>>a>>b; a>=b?(y=a,x=b):(y=b,x=a); if (!(y%x)) { /*cout<<x<<endl<<y<<endl; cout<<"first"<<endl;*/ return x; } else { while (y%x) { temp = y%x; y = x; x = temp; } /*cout<<x<<endl; cout<<"second"<<endl;*/ return x; } }
[ "supershashikant@gmail.com" ]
supershashikant@gmail.com
a3a439302a66ee04756665deb9fd639cab4ee2cf
3b0c159d34aec31dd5a8a7998ff3ed3c97ebeeb5
/Polygon.cpp
99d563174e5f54f56cc04ff7a160cb484bbdb7e8
[]
no_license
Tsunaou/GraphicsYoung
af619de800d5d028769b555af46b221712617979
caf2fc191d1673dd3e6a153b5377d9e8ae22fc1f
refs/heads/master
2020-04-03T02:42:21.497385
2018-12-31T03:43:08
2018-12-31T03:43:08
154,964,206
13
3
null
null
null
null
UTF-8
C++
false
false
3,356
cpp
#include "Polygon.h" Polygon::Polygon() { this->start = NULL; this->end = NULL; this->type = POLYGON; this->colseFlag = false; //For test xCenter = 0; yCenter = 0; } Polygon::Polygon(QPoint *start, QPoint *end, FIGURE_TYPE type) { this->start = start; this->end = end; this->type = POLYGON; this->vertex.push_back(Point(start->x(),start->y())); //起始点进去 this->colseFlag = false; //对于起始点的处理 this->startPoint = Point(*start); } void Polygon::setNextPoint(Point p) { vertex.push_back(p); } void Polygon::changeNextPoint(Point p) { vertex[vertex.size()-1] = p; } void Polygon::changePoint(int index, Point p) { if(index<0 || index >= vertex.size()){ qDebug()<<"Change Points in polygon error"<<endl; }else{ if(index == 0){ this->vertex[0] = p; this->vertex[this->vertex.size()-1] = p; }else{ this->vertex[index] = p; } } } void Polygon::getRectangle() { int maxX = vertex.first().getX(); int minX = vertex.first().getX(); int maxY = vertex.first().getY(); int minY = vertex.first().getY(); for(Point v: vertex){ int vx = v.getX(); int vy = v.getY(); if(vx>maxX){ maxX = vx; } if(vx<minX){ minX = vx; } if(vy>maxY){ maxY = vy; } if(vy<minY){ minY = vy; } } LeftUp.setPoint(minX,minY); //左上角(minX,minY) LeftDown.setPoint(minX,maxY); //左下角(minX,maxY) RightUp.setPoint(maxX,minY); //右上角(maxX,minY) RightDown.setPoint(maxX,maxY);//右下角(maxX,maxY) double cX = (minX+maxX)/2; double cY = (minY+maxY)/2; this->xCenter = cX; this->yCenter = cY; double offSetX = cX + ROTATE_RIDUS*qSin(rotateAngle); double offSetY = cY - ROTATE_RIDUS*qCos(rotateAngle); centerPoint.setPoint(cX,cY); //中点 rotatePoint.setPoint(offSetX,offSetY); //旋转点 } void Polygon::getRectangleRotating() { if(xCenter == 0){ xCenter = this->centerPoint.getX(); yCenter = this->centerPoint.getY(); } qDebug()<<"稳定!getRectangleRotating"<<endl; int maxX = vertex.first().getX(); int minX = vertex.first().getX(); int maxY = vertex.first().getY(); int minY = vertex.first().getY(); for(Point v: vertex){ int vx = v.getX(); int vy = v.getY(); if(vx>maxX){ maxX = vx; } if(vx<minX){ minX = vx; } if(vy>maxY){ maxY = vy; } if(vy<minY){ minY = vy; } } LeftUp.setPoint(minX,minY); //左上角(minX,minY) LeftDown.setPoint(minX,maxY); //左下角(minX,maxY) RightUp.setPoint(maxX,minY); //右上角(maxX,minY) RightDown.setPoint(maxX,maxY);//右下角(maxX,maxY) // double cX = this->centerPoint.getX(); // double cY = this->centerPoint.getY(); double cX = xCenter; double cY = yCenter; qDebug()<<"中点坐标为: "<<"("<<(int)cX<<","<<(int)cY<<")"<<endl; double offSetX = cX + ROTATE_RIDUS*qSin(rotateAngle); double offSetY = cY - ROTATE_RIDUS*qCos(rotateAngle); rotatePoint.setPoint(offSetX,offSetY); //旋转点 }
[ "895254752@qq.com" ]
895254752@qq.com
769d083a6473be549f2cdd5afb7c3e232de8eda6
f9e2767948b357fcc1107d8e3da7e1f119ed50a2
/libc/bionic/grp_pwd_file.cpp
37493a7a711933d7927ddadca5dfea9072736288
[ "SMLNJ", "BSD-3-Clause", "BSD-4-Clause-UC", "ISC", "LicenseRef-scancode-warranty-disclaimer", "Apache-2.0", "HPND", "LicenseRef-scancode-ibm-dhcp", "BSD-2-Clause", "Martin-Birgmeier", "BSD-4-Clause", "MIT", "LicenseRef-scancode-bsd-unmodified", "SunPro", "LicenseRef-scancode-red-hat-attr...
permissive
MIPS/bionic
76d1f4d8f7deb1a09b18440a31e325811c94796d
a39b60940b1a9a494f5cf37ab35f63068bd7e76c
refs/heads/master
2020-05-21T23:47:35.721017
2018-05-08T14:00:22
2018-05-08T14:00:22
1,400,491
0
2
null
null
null
null
UTF-8
C++
false
false
8,980
cpp
/* * Copyright (C) 2018 The Android Open Source Project * 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. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #include "grp_pwd_file.h" #include <fcntl.h> #include <stdlib.h> #include <sys/mman.h> #include <sys/stat.h> #include "private/ErrnoRestorer.h" // This file mmap's /*/etc/passwd and /*/etc/group in order to return their contents without any // allocations. Note that these files and the strings contained within them are explicitly not // null-terminated. ':'s are used to deliminate fields and '\n's are used to deliminate lines. // There is a check that the file ends with '\n', such that terminating loops at '\n' ensures that // memory will be not ready before the mmap region. namespace { void CopyFieldToString(char* dest, const char* source, size_t max) { while (*source != ':' && *source != '\n' && max > 1) { *dest++ = *source++; --max; } *dest = '\0'; } bool FieldToUid(const char* field, uid_t* uid) { if (field == nullptr) { return false; } char* end = nullptr; errno = 0; uid_t result = strtoul(field, &end, 0); if (errno != 0 || field == end || *end != ':') { return false; } *uid = result; return true; } // Returns a pointer to one past the end of line. const char* ParseLine(const char* begin, const char* end, const char** fields, size_t num_fields) { size_t fields_written = 0; const char* position = begin; fields[fields_written++] = position; while (position < end && fields_written < num_fields) { if (*position == '\n') { return position + 1; } if (*position == ':') { fields[fields_written++] = position + 1; } position++; } while (position < end && *position != '\n') { position++; } return position + 1; } struct PasswdLine { const char* name() const { return fields[0]; } // Password is not supported. const char* uid() const { return fields[2]; } const char* gid() const { return fields[3]; } // User Info is not supported const char* dir() const { return fields[5]; } const char* shell() const { return fields[6]; } bool ToPasswdState(passwd_state_t* passwd_state) { if (name() == nullptr || dir() == nullptr || shell() == nullptr) { return false; } uid_t uid; if (!FieldToUid(this->uid(), &uid)) { return false; } gid_t gid; if (!FieldToUid(this->gid(), &gid)) { return false; } passwd_state->passwd_.pw_uid = uid; passwd_state->passwd_.pw_gid = gid; CopyFieldToString(passwd_state->name_buffer_, name(), sizeof(passwd_state->name_buffer_)); passwd_state->passwd_.pw_name = passwd_state->name_buffer_; passwd_state->passwd_.pw_passwd = nullptr; #ifdef __LP64__ passwd_state->passwd_.pw_gecos = nullptr; #endif CopyFieldToString(passwd_state->dir_buffer_, dir(), sizeof(passwd_state->dir_buffer_)); passwd_state->passwd_.pw_dir = passwd_state->dir_buffer_; CopyFieldToString(passwd_state->sh_buffer_, shell(), sizeof(passwd_state->sh_buffer_)); passwd_state->passwd_.pw_shell = passwd_state->sh_buffer_; return true; } static constexpr size_t kNumFields = 7; const char* fields[kNumFields] = {}; }; struct GroupLine { const char* name() const { return fields[0]; } // Password is not supported. const char* gid() const { return fields[2]; } // User list is not supported (returns simply name) bool ToGroupState(group_state_t* group_state) { if (name() == nullptr || gid() == nullptr) { return false; } gid_t gid; if (!FieldToUid(this->gid(), &gid)) { return false; } group_state->group_.gr_gid = gid; CopyFieldToString(group_state->group_name_buffer_, name(), sizeof(group_state->group_name_buffer_)); group_state->group_.gr_name = group_state->group_name_buffer_; group_state->group_.gr_passwd = nullptr; group_state->group_.gr_mem = group_state->group_members_; group_state->group_.gr_mem[0] = group_state->group_.gr_name; group_state->group_.gr_mem[1] = nullptr; return true; } static constexpr size_t kNumFields = 4; const char* fields[kNumFields] = {}; }; } // namespace MmapFile::MmapFile(const char* filename) : filename_(filename) { lock_.init(false); } void MmapFile::Unmap() { if (status_ == FileStatus::Initialized) { size_t size = end_ - start_ + 1; munmap(const_cast<char*>(start_), size); status_ = FileStatus::Uninitialized; start_ = nullptr; end_ = nullptr; } } bool MmapFile::GetFile(const char** start, const char** end) { LockGuard guard(lock_); if (status_ == FileStatus::Initialized) { *start = start_; *end = end_; return true; } if (status_ == FileStatus::Error) { return false; } if (!DoMmap()) { status_ = FileStatus::Error; return false; } status_ = FileStatus::Initialized; *start = start_; *end = end_; return true; } bool MmapFile::DoMmap() { int fd = open(filename_, O_CLOEXEC | O_NOFOLLOW | O_RDONLY); struct stat fd_stat; if (fstat(fd, &fd_stat) == -1) { close(fd); return false; } auto mmap_size = fd_stat.st_size; void* map_result = mmap(nullptr, mmap_size, PROT_READ, MAP_SHARED, fd, 0); close(fd); if (map_result == MAP_FAILED) { return false; } start_ = static_cast<const char*>(map_result); end_ = start_ + mmap_size - 1; if (*end_ != '\n') { munmap(map_result, mmap_size); return false; } return true; } template <typename Line, typename Predicate> bool MmapFile::Find(Line* line, Predicate predicate) { const char* start; const char* end; if (!GetFile(&start, &end)) { return false; } const char* line_beginning = start; while (line_beginning < end) { line_beginning = ParseLine(line_beginning, end, line->fields, line->kNumFields); if (predicate(line)) return true; } return false; } template <typename Line> bool MmapFile::FindById(uid_t uid, Line* line) { return Find(line, [uid](const auto& line) { uid_t line_id; if (!FieldToUid(line->fields[2], &line_id)) { return false; } return line_id == uid; }); } template <typename Line> bool MmapFile::FindByName(const char* name, Line* line) { return Find(line, [name](const auto& line) { const char* line_name = line->fields[0]; if (line_name == nullptr) { return false; } const char* match_name = name; while (*line_name != '\n' && *line_name != ':' && *match_name != '\0') { if (*line_name++ != *match_name++) { return false; } } return *line_name == ':' && *match_name == '\0'; }); } PasswdFile::PasswdFile(const char* filename) : mmap_file_(filename) { } bool PasswdFile::FindById(uid_t id, passwd_state_t* passwd_state) { ErrnoRestorer errno_restorer; PasswdLine passwd_line; return mmap_file_.FindById(id, &passwd_line) && passwd_line.ToPasswdState(passwd_state); } bool PasswdFile::FindByName(const char* name, passwd_state_t* passwd_state) { ErrnoRestorer errno_restorer; PasswdLine passwd_line; return mmap_file_.FindByName(name, &passwd_line) && passwd_line.ToPasswdState(passwd_state); } GroupFile::GroupFile(const char* filename) : mmap_file_(filename) { } bool GroupFile::FindById(gid_t id, group_state_t* group_state) { ErrnoRestorer errno_restorer; GroupLine group_line; return mmap_file_.FindById(id, &group_line) && group_line.ToGroupState(group_state); } bool GroupFile::FindByName(const char* name, group_state_t* group_state) { ErrnoRestorer errno_restorer; GroupLine group_line; return mmap_file_.FindByName(name, &group_line) && group_line.ToGroupState(group_state); }
[ "tomcherry@google.com" ]
tomcherry@google.com
2dee2511503811e0918b5e1ba6f80423cb99f6af
ef6203ced36a85d733f71bcedb2c97c49497a0c3
/src/utils/DebugUtil.cpp
b4d7c6b458f119d6e1aa3b802a18483bd23a1a3d
[]
no_license
crob/LabRetriever
87ee9c558272cd2b5732dc9ca6937cbd8d8742f9
479cec0175ed468132fd2e34a2dc50afc43215df
refs/heads/master
2021-01-24T03:43:44.280323
2013-09-06T20:57:54
2013-09-06T20:57:54
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,872
cpp
//================================================================================================== // Name : DebugUtil.cpp // Author : Ken Cheng // Copyright : 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 see <http://www.gnu.org/licenses/>. // Description : //================================================================================================== #include "DebugUtil.h" #include <iostream> using namespace std; namespace LabRetriever { template <class A> void debug(const A& a) { debugToken(a); cout << endl; } template <class A, class B> void debugToken(const map<A, B>& m) { typedef typename map<A, B>::const_iterator Iterator; cout << "{" << endl; for (Iterator iter = m.begin(); iter != m.end(); iter++) { debugToken(iter->first); cout << "\t:\t"; debugToken(iter->second); cout << endl; } cout << "}"; } template <class A> void debugToken(const vector<A>& v) { cout << "[ "; for (unsigned int i = 0; i < v.size(); i++) { debugToken(v[i]); cout << " "; } cout << "]"; } template <class A> void debugToken(const set<A>& s) { cout << "{ "; if (s.size() != 0) { typedef typename set<A>::const_iterator Iterator; for (Iterator iter = s.begin(); iter != s.end(); iter++) { debugToken(*iter); cout << " "; } } cout << "}"; } void debugToken(const AlleleProfile& a) { cout << "Allele Profile: "; debugToken(a.getAlleleCounts()); } void debugToken(const ReplicateData& r) { cout << "Assumed Alleles: "; debugToken(r.maskedAlleles); cout << endl << "Unattributed Alleles: "; debugToken(r.unattributedAlleles); } void debugToken(const Configuration& c) { cout << "Configuration: " << endl; debug(c.suspectProfile); debug(c.data); cout << "Allele Proportions: "; debug(c.alleleProportions); cout << "Alpha: "; debug(c.alpha); cout << "Drop-in rate: "; debug(c.dropinRate); cout << "Drop-out rate: "; debugToken(c.dropoutRate); } template <class A> void debugToken(const A& a) { cout << a; } }
[ "luke.semerau@gmail.com" ]
luke.semerau@gmail.com
d0d2eea2ed7188b140e9df6f827e6f2e0eb0c8ab
9b4a35626ee8011b125ba887ea8f2421486f0870
/MFCStudy/MFCStudy/MFCStudyView.h
98377fecc679ba9475f37d744cae5572e6de3eed
[]
no_license
93minki/MFC-Calculator
c2389a16e59447cddc38b76e25f7e985452dc08b
af09c295dadee41385a4f58a2ff521d985eff884
refs/heads/master
2020-12-06T15:49:08.931124
2020-01-12T23:05:53
2020-01-12T23:05:53
232,499,953
0
0
null
null
null
null
UHC
C++
false
false
1,640
h
// MFCStudyView.h : CMFCStudyView 클래스의 인터페이스 // #pragma once #include "atltypes.h" class CMFCStudyView : public CView { protected: // serialization에서만 만들어집니다. CMFCStudyView(); DECLARE_DYNCREATE(CMFCStudyView) // 특성입니다. public: CMFCStudyDoc* GetDocument() const; // 작업입니다. public: // 재정의입니다. public: virtual void OnDraw(CDC* pDC); // 이 뷰를 그리기 위해 재정의되었습니다. virtual BOOL PreCreateWindow(CREATESTRUCT& cs); protected: virtual BOOL OnPreparePrinting(CPrintInfo* pInfo); virtual void OnBeginPrinting(CDC* pDC, CPrintInfo* pInfo); virtual void OnEndPrinting(CDC* pDC, CPrintInfo* pInfo); // 구현입니다. public: virtual ~CMFCStudyView(); #ifdef _DEBUG virtual void AssertValid() const; virtual void Dump(CDumpContext& dc) const; #endif protected: // 생성된 메시지 맵 함수 protected: DECLARE_MESSAGE_MAP() public: bool m_bTimerRun; afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); CString m_strTimer; afx_msg void OnTimer(UINT_PTR nIDEvent); afx_msg void OnLButtonDown(UINT nFlags, CPoint point); afx_msg void OnRButtonDown(UINT nFlags, CPoint point); afx_msg void OnDestroy(); CString m_strOutText; CPoint m_ptNow; afx_msg void OnChar(UINT nChar, UINT nRepCnt, UINT nFlags); afx_msg void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags); CPoint m_ptClientSize; afx_msg void OnSize(UINT nType, int cx, int cy); }; #ifndef _DEBUG // MFCStudyView.cpp의 디버그 버전 inline CMFCStudyDoc* CMFCStudyView::GetDocument() const { return reinterpret_cast<CMFCStudyDoc*>(m_pDocument); } #endif
[ "93minki@taeha.co.kr" ]
93minki@taeha.co.kr
a5899f0b2f36b60e327dc4be0f608e6a44602c09
de42db6b7ca9da722804b9a754158d477a4550d6
/src/filterFuncs.cxx
633e9b5b4fd8d8a53b012da4280c1ba6a1c87cea
[]
no_license
hershen/commonRootFunctions
247a95e74d9491e23d56b28adc67c29443bbfb33
28d3b74e02b4d526ecfbe728a80aa86968613c3e
refs/heads/master
2022-03-09T07:46:47.403425
2019-11-26T18:33:27
2019-11-26T18:33:27
104,494,016
0
0
null
null
null
null
UTF-8
C++
false
false
12,455
cxx
#include "filterFuncs.h" // STL #include <cmath> // Mine #include "fftFuncs.h" #include "mathFuncs.h" namespace myFuncs { namespace DSP { // Implementations taken from "Recursive algorithms for real time digital CR-(RC)^n pulse shaping", M. Nakhostin, IEEE // transactions on nuclear science, Vol 58, no 5, october 2011 //---------------------------------------------------------- // filterCR_RC //---------------------------------------------------------- template <typename Type> std::vector<double> filterCR_RC(const std::vector<Type>& xs, const double tau, const double T) { //--------------------------- // xs.size() == 0 //--------------------------- if (xs.size() == 0) { return std::vector<double>(); } //--------------------------- // xs.size() >= 1 //--------------------------- const double normFactor = T / tau; // Peak amplitude = tau / T. // return vector std::vector<double> ys; ys.reserve(xs.size()); ys.push_back(xs[0]); // ys[0] if (xs.size() == 1) { return myFuncs::scaleVector(ys, normFactor); } //--------------------------- // xs.size() >= 2 //--------------------------- // Define constants const double a = 1. / tau; const double alpha = std::exp(-T * a); const double xPreviousMultiplier = -alpha * (1.0 + a * T); const double yPreviousMultiplier = 2 * alpha; ys.push_back(yPreviousMultiplier * ys[0] + xs[1] + xPreviousMultiplier * xs[0]); // ys[1] if (xs.size() == 2) { return myFuncs::scaleVector(ys, normFactor); } //--------------------------- // xs.size() >= 3 //--------------------------- const double yPrevious2Multiplier = -alpha * alpha; for (unsigned int idx = 2; idx < xs.size(); ++idx) { ys.push_back(yPreviousMultiplier * ys[idx - 1] + yPrevious2Multiplier * ys[idx - 2] + xs[idx] + xPreviousMultiplier * xs[idx - 1]); // ys[>=2] } return myFuncs::scaleVector(ys, normFactor); } // Declare all usefule implementations in order to avoid linker problems! template std::vector<double> filterCR_RC<double>(const std::vector<double>& xs, const double tau, const double T); template std::vector<double> filterCR_RC<unsigned int>(const std::vector<unsigned int>& xs, const double tau, const double T); template std::vector<double> filterCR_RC<int>(const std::vector<int>& xs, const double tau, const double T); //---------------------------------------------------------- // filterCR_RC2 //---------------------------------------------------------- template <typename Type> std::vector<double> filterCR_RC2(const std::vector<Type>& xs, const double tau, const double T) { //--------------------------- // xs.size() == 0 //--------------------------- if (xs.size() == 0) { return std::vector<double>(); } //--------------------------- // xs.size() >= 1 //--------------------------- // return vector std::vector<double> ys; ys.reserve(xs.size()); ys.push_back(0.0); // y[0] if (xs.size() == 1) { return ys; } //--------------------------- // xs.size() >= 2 //--------------------------- // Define constants const double normFactor = T / tau / tau; // Peak amplitude = tau^2 / T. const double a = 1. / tau; const double alpha = std::exp(-T * a); const double xPreviousMultiplier = T * alpha * (1.0 - 0.5 * a * T); ys.push_back(xPreviousMultiplier * xs[0]); // y[1] if (xs.size() == 2) { return myFuncs::scaleVector(ys, normFactor); } //--------------------------- // xs.size() >= 3 //--------------------------- const double xPrevious2Multiplier = -T * alpha * alpha * (1.0 + 0.5 * a * T); const double yPreviousMultiplier = 3 * alpha; ys.push_back(yPreviousMultiplier * ys[1] + xPreviousMultiplier * xs[1] + xPrevious2Multiplier * xs[0]); // y[2] if (xs.size() == 3) { return myFuncs::scaleVector(ys, normFactor); } //--------------------------- // xs.size() >= 4 //--------------------------- const double yPrevious2Multiplier = -3 * alpha * alpha; ys.push_back(yPreviousMultiplier * ys[2] + yPrevious2Multiplier * ys[1] + xPreviousMultiplier * xs[2] + xPrevious2Multiplier * xs[1]); // y[3] if (xs.size() == 4) { return myFuncs::scaleVector(ys, normFactor); } //--------------------------- // xs.size() > 4 //--------------------------- const double yPrevious3Multiplier = alpha * alpha * alpha; for (unsigned int idx = 4; idx < xs.size(); ++idx) ys.push_back(yPreviousMultiplier * ys[idx - 1] + yPrevious2Multiplier * ys[idx - 2] + yPrevious3Multiplier * ys[idx - 3] + xPreviousMultiplier * xs[idx - 1] + xPrevious2Multiplier * xs[idx - 2]); return myFuncs::scaleVector(ys, normFactor); } // namespace DSP // Declare all usefule implementations in order to avoid linker problems! template std::vector<double> filterCR_RC2<double>(const std::vector<double>& xs, const double tau, const double T); template std::vector<double> filterCR_RC2<unsigned int>(const std::vector<unsigned int>& xs, const double tau, const double T); template std::vector<double> filterCR_RC2<int>(const std::vector<int>& xs, const double tau, const double T); //---------------------------------------------------------- // filterCR_RC4 //---------------------------------------------------------- template <typename Type> std::vector<double> filterCR_RC4(const std::vector<Type>& xs, const double tau, const double T) { //--------------------------- // xs.size() == 0 //--------------------------- if (xs.size() == 0) { return std::vector<double>(); } //--------------------------- // xs.size() >= 1 //--------------------------- // return vector std::vector<double> ys; ys.reserve(xs.size()); ys.push_back(0.0); // y[0] if (xs.size() == 1) { return ys; } //--------------------------- // xs.size() >= 2 //--------------------------- // Define constants const double normFactor = T / tau / tau / tau / tau; // Peak amplitude = tau^4 / T. const double a = 1. / tau; const double alpha = std::exp(-T * a); constexpr double oneO24 = 1.0 / 24.0; const double T3 = T * T * T; const double T4 = T3 * T; const double xPreviousMultiplier = oneO24 * alpha * (-a * T4 + 4.0 * T3); ys.push_back(xPreviousMultiplier * xs[0]); // y[1] if (xs.size() == 2) { return myFuncs::scaleVector(ys, normFactor); } //--------------------------- // xs.size() >= 3 //--------------------------- const double xPrevious2Multiplier = oneO24 * alpha * alpha * (-11.0 * a * T4 + 12.0 * T3); const double yPreviousMultiplier = 5.0 * alpha; ys.push_back(yPreviousMultiplier * ys[1] + xPreviousMultiplier * xs[1] + xPrevious2Multiplier * xs[0]); // y[2] if (xs.size() == 3) { return myFuncs::scaleVector(ys, normFactor); } //--------------------------- // xs.size() >= 4 //--------------------------- const double xPrevious3Multiplier = oneO24 * alpha * alpha * alpha * (-11.0 * a * T4 - 12.0 * T3); const double yPrevious2Multiplier = -10.0 * alpha * alpha; ys.push_back(yPreviousMultiplier * ys[2] + yPrevious2Multiplier * ys[1] + xPreviousMultiplier * xs[2] + xPrevious2Multiplier * xs[1] + xPrevious3Multiplier * xs[0]); // y[3] if (xs.size() == 4) { return myFuncs::scaleVector(ys, normFactor); } //--------------------------- // xs.size() >= 5 //--------------------------- const double xPrevious4Multiplier = oneO24 * alpha * alpha * alpha * alpha * (-a * T4 - 4.0 * T3); const double yPrevious3Multiplier = 10.0 * alpha * alpha * alpha; ys.push_back(yPreviousMultiplier * ys[3] + yPrevious2Multiplier * ys[2] + yPrevious3Multiplier * ys[1] + xPreviousMultiplier * xs[3] + xPrevious2Multiplier * xs[2] + xPrevious3Multiplier * xs[1] + xPrevious4Multiplier * xs[0]); // y[4] if (xs.size() == 5) { return myFuncs::scaleVector(ys, normFactor); } //--------------------------- // xs.size() >= 6 //--------------------------- const double yPrevious4Multiplier = -5.0 * alpha * alpha * alpha * alpha; ys.push_back(yPreviousMultiplier * ys[4] + yPrevious2Multiplier * ys[3] + yPrevious3Multiplier * ys[2] + yPrevious4Multiplier * ys[1] + xPreviousMultiplier * xs[4] + xPrevious2Multiplier * xs[3] + xPrevious3Multiplier * xs[2] + xPrevious4Multiplier * xs[1]); // y[5] if (xs.size() == 6) { return myFuncs::scaleVector(ys, normFactor); } //--------------------------- // xs.size() > 6 //--------------------------- const double yPrevious5Multiplier = alpha * alpha * alpha * alpha * alpha; for (unsigned int idx = 6; idx < xs.size(); ++idx) ys.push_back(yPreviousMultiplier * ys[idx - 1] + yPrevious2Multiplier * ys[idx - 2] + yPrevious3Multiplier * ys[idx - 3] + yPrevious4Multiplier * ys[idx - 4] + yPrevious5Multiplier * ys[idx - 5] + xPreviousMultiplier * xs[idx - 1] + xPrevious2Multiplier * xs[idx - 2] + xPrevious3Multiplier * xs[idx - 3] + xPrevious4Multiplier * xs[idx - 4]); return myFuncs::scaleVector(ys, normFactor); } // namespace myFuncs // Declare all usefule implementations in order to avoid linker problems! template std::vector<double> filterCR_RC4<double>(const std::vector<double>& xs, const double tau, const double T); template std::vector<double> filterCR_RC4<unsigned int>(const std::vector<unsigned int>& xs, const double tau, const double T); template std::vector<double> filterCR_RC4<int>(const std::vector<int>& xs, const double tau, const double T); template <typename Type> std::vector<double> filterBrickwall(const std::vector<Type>& xs, const std::size_t numToBrick, const Type valueToBrick) { auto fft = myFuncs::fftR2C(xs); for (size_t i = 0; i < numToBrick; ++i) { fft.first[i] = valueToBrick; fft.second[i] = valueToBrick; } return myFuncs::fftC2R(xs.size(), fft.first, fft.second); } template std::vector<double> filterBrickwall<double>(const std::vector<double>& xs, const std::size_t numToBrick, const double valueToBrick); // template std::vector<double> filterBrickwall<unsigned int>(const std::vector<unsigned int> &xs, const std::size_t numToBrick, // const unsigned int valueToBrick); template std::vector<double> filterBrickwall<int>(const std::vector<int> &xs, const // std::size_t numToBrick, const int valueToBrick); std::pair<std::vector<double>, std::vector<double>> getCR_RCnCoefficients(const int n, const double tau, const double samplingFrequency) { const double a = 1.0 / tau; const double T = 1.0 / samplingFrequency; const double alpha = std::exp(-T / tau); const double norm = T; // I don't know why this is needed. It doesn't come out of the z transform of the time response std::vector<double> nominators; std::vector<double> denominators; if (n == 1) { nominators = {a * norm, -a * alpha * (1 + a * T) * norm}; denominators = {1.0, -2 * alpha, alpha * alpha}; } else if (n == 2) { nominators = {0, a * a * T * alpha * (2 - a * T) * norm, -a * a * T * alpha * alpha * (2 + a * T) * norm}; denominators = {2, -6 * alpha, 6 * alpha * alpha, -2 * alpha * alpha * alpha}; } else if (n == 3) { nominators = {0, a * a * a * T * T * alpha * (3 - a * T) * norm, a * a * a * T * T * alpha * alpha * (-4 * a * T) * norm, -a * a * a * T * T * alpha * alpha * alpha * (3 + a * T) * norm}; denominators = {6, -24 * alpha, 36 * alpha * alpha, -24 * alpha * alpha * alpha, 6 * alpha * alpha * alpha * alpha}; } else if (n == 4) { nominators = {0, a * a * a * a * alpha * T * T * T * (4 - a * T) * norm, a * a * a * a * alpha * alpha * T * T * T * (12 - 11 * a * T) * norm, a * a * a * a * alpha * alpha * alpha * T * T * T * (-12 - 11 * a * T) * norm, a * a * a * a * alpha * alpha * alpha * alpha * T * T * T * (-4 - a * T) * norm}; denominators = {24, -120 * alpha, 240 * alpha * alpha, -240 * alpha * alpha * alpha, 120 * alpha * alpha * alpha * alpha, -24 * alpha * alpha * alpha * alpha * alpha}; } else { std::cout << "filterFuncs::getCR_RCnCoefficients: n = " << n << " not supported. \n"; } return std::make_pair(nominators, denominators); } } // namespace DSP } // namespace myFuncs
[ "hershen@phas.ubc.ca" ]
hershen@phas.ubc.ca
aab769ade53a536d8b3142333dc67318e23d418e
184180d341d2928ab7c5a626d94f2a9863726c65
/issuestests/mixR/inst/testfiles/g_weib/g_weib_DeepState_TestHarness.cpp
c1e7120c10e427c2fc1253d11e74b5d36027f396
[]
no_license
akhikolla/RcppDeepStateTest
f102ddf03a22b0fc05e02239d53405c8977cbc2b
97e73fe4f8cb0f8e5415f52a2474c8bc322bbbe5
refs/heads/master
2023-03-03T12:19:31.725234
2021-02-12T21:50:12
2021-02-12T21:50:12
254,214,504
2
1
null
null
null
null
UTF-8
C++
false
false
1,567
cpp
#include <fstream> #include <RInside.h> #include <iostream> #include <RcppDeepState.h> #include <qs.h> #include <DeepState.hpp> double g_weib(double r, NumericVector n, NumericVector ex, NumericVector tx); TEST(mixR_deepstate_test,g_weib_test){ RInside R; std::cout << "input starts" << std::endl; NumericVector r(1); r[0] = RcppDeepState_double(); qs::c_qsave(r,"/home/akhila/R/x86_64-pc-linux-gnu-library/3.6/RcppDeepState/extdata/issuestests/mixR/inst/testfiles/g_weib/inputs/r.qs", "high", "zstd", 1, 15, true, 1); std::cout << "r values: "<< r << std::endl; NumericVector n = RcppDeepState_NumericVector(); qs::c_qsave(n,"/home/akhila/R/x86_64-pc-linux-gnu-library/3.6/RcppDeepState/extdata/issuestests/mixR/inst/testfiles/g_weib/inputs/n.qs", "high", "zstd", 1, 15, true, 1); std::cout << "n values: "<< n << std::endl; NumericVector ex = RcppDeepState_NumericVector(); qs::c_qsave(ex,"/home/akhila/R/x86_64-pc-linux-gnu-library/3.6/RcppDeepState/extdata/issuestests/mixR/inst/testfiles/g_weib/inputs/ex.qs", "high", "zstd", 1, 15, true, 1); std::cout << "ex values: "<< ex << std::endl; NumericVector tx = RcppDeepState_NumericVector(); qs::c_qsave(tx,"/home/akhila/R/x86_64-pc-linux-gnu-library/3.6/RcppDeepState/extdata/issuestests/mixR/inst/testfiles/g_weib/inputs/tx.qs", "high", "zstd", 1, 15, true, 1); std::cout << "tx values: "<< tx << std::endl; std::cout << "input ends" << std::endl; try{ g_weib(r[0],n,ex,tx); } catch(Rcpp::exception& e){ std::cout<<"Exception Handled"<<std::endl; } }
[ "akhilakollasrinu424jf@gmail.com" ]
akhilakollasrinu424jf@gmail.com
7f846daf6f8f4e278f18ee0f92b79568364048af
24dc5985f1b120e4865324322822393606e1dd91
/Program Tugas Prak2 B1 (Array&Strukture).cpp
868103492022629daed77da434c46227d92e767e
[]
no_license
MOHSARIFULHUDA20051397049/TUGAS-SEMESTER-2
0601ca849daadd0980b9ee8f543994a0b61f6316
480d3adbb0c4ec2abfc232b1ad7b602553cf3859
refs/heads/main
2023-05-30T00:18:07.597870
2021-06-08T01:18:54
2021-06-08T01:18:54
339,266,769
0
0
null
null
null
null
UTF-8
C++
false
false
543
cpp
//m. sariful huda 20051397049 2020A MI// //Program membalik huruf 'P', 'E', 'N', 'S', 'I', 'T'// #include <iostream> using namespace std; int main(){ cout << "PROGRAM ARRAY MEMBALIK HURUF" << endl; cout << "============================\n" << endl; char a[6] = {'p', 'e', 'n', 's', 'i', 't'}; int i, j; cout << "--Kata sebelum dibalik : --"<< endl; for (i=0; i<6; i++){ cout << a [i]; } cout << "\n\n"; cout << "--kata setelah dibalik : --"<< endl; for (j=6; j>=0; j--){ cout << a [j]; } return 0; }
[ "noreply@github.com" ]
noreply@github.com
db47ff07043a673cf1cde0eb41cde5f29cc02a7b
90ed8c2f83b8db17f539428541b6a2d49a9ab999
/PROGRAM PRACTISE/strlen.cpp
3db46cf7eca09877c0e5473b931260cd49400d44
[]
no_license
Piaash/UVA-Solution-Collection
49a319330f85f2cb4e4e0f3d4c92238f08e51391
8eab98fd75e3d4298f047c16a5d3d7d1552ca815
refs/heads/master
2021-01-01T15:48:46.733192
2017-07-19T11:29:04
2017-07-19T11:29:04
97,708,135
0
0
null
null
null
null
UTF-8
C++
false
false
158
cpp
#include<stdio.h> #include<conio.h> #include<string.h> main() { char str[100]; scanf("%s",&str); printf("%d",strlen(str)); getch(); }
[ "piaash11cse@gmail.com" ]
piaash11cse@gmail.com
53045943363e98baa6fed170c8dc0d8eeac0e7ef
e2ea0a550e8d35eae7da7d1591210a893004e34a
/Minemonics/src/model/universe/evolution/population/creature/genome/controller/ControllerGene.hpp
a71bf93c4279bacfd6f5b0eb172ac5d8c50728ed
[]
no_license
netzz/minemonics
cbc98cc2a33b64f3c0f5acb89328b74e22124a9f
b628eadc8f341012cd0433cb20b9c02ca1edf40b
refs/heads/master
2021-01-16T20:51:28.387476
2015-08-07T14:53:34
2015-08-07T14:53:34
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,649
hpp
#ifndef MODEL_UNIVERSE_EVOLUTION_POPULATION_CREATURE_GENOME_CONTROLLER_CONTROLLERGENE_HPP_ #define MODEL_UNIVERSE_EVOLUTION_POPULATION_CREATURE_GENOME_CONTROLLER_CONTROLLERGENE_HPP_ //# forward declarations //# system headers //## controller headers //## model headers // include headers that implement a archive in xml format #include <boost/archive/tmpdir.hpp> #include <boost/archive/xml_iarchive.hpp> #include <boost/archive/xml_oarchive.hpp> #include <boost/serialization/version.hpp> //## view headers //# custom headers //## base headers //## configuration headers //## controller headers //## model headers //## view headers //## utils headers /** * @brief The controller gene is the base class for all genes encoding different controllers. * @details Details * @date 2015-03-09 * @author Benjamin Ellenberger */ class ControllerGene { public: ControllerGene(); virtual ~ControllerGene(); /** * Initialize the controller gene. */ virtual void initialize() = 0; /** * Clone the controller gene. * @return The clone of the controller gene. */ virtual ControllerGene* clone() = 0; /** * Compare the controller gene to another controller gene. * @param controllerGene Another controller gene. * @return If equal. */ bool equals(const ControllerGene& controllerGene) const; enum ControllerGeneType { SineControllerGene, GenericControllerGene }; //Accessor methods ControllerGeneType getControllerGeneType() const { return mControllerGeneType; } void setControllerGeneType(const ControllerGeneType controllerGeneType) { mControllerGeneType = controllerGeneType; } //Serialization /** * Give access to boost serialization */ friend class boost::serialization::access; /** * Serializes the controller gene to a string. * @param os The ostream. * @param controllerGene The controller gene we want to serialize. * @return A string containing all information about the controller gene. */ friend std::ostream & operator<<(std::ostream &os, const ControllerGene &controllerGene) { return os << "ControllerGene:" << controllerGene.mControllerGeneType; } /** * Serializes the controller gene to an xml file. * @param ar The archive. * @param The file version. */ template<class Archive> void serialize(Archive & ar, const unsigned int /* file_version */) { ar & BOOST_SERIALIZATION_NVP(mControllerGeneType); } protected: ControllerGeneType mControllerGeneType; }; BOOST_CLASS_VERSION(ControllerGene, 1) BOOST_SERIALIZATION_ASSUME_ABSTRACT(ControllerGene) #endif /* MODEL_UNIVERSE_EVOLUTION_POPULATION_CREATURE_GENOME_CONTROLLER_CONTROLLERGENE_HPP_ */
[ "be.ellenberger@gmail.com" ]
be.ellenberger@gmail.com
298465b148f260cf990ea4359dc0d2a71c196dda
a734001826e353631d9e510639bbcc8e7ac89728
/geometry/ClosestPair.cpp
03b1abbad7496fadb4bd6da20cf8807d1f6f42a3
[]
no_license
manish05/acm-algo
1f3ab3303b458d783c89efbb1ada92a9b0e2bfda
ec00d95cb816a8a968604d2314027973909df5f2
refs/heads/master
2020-12-28T23:24:09.246740
2014-08-31T16:33:40
2014-08-31T16:33:40
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,134
cpp
// Closest Pair - Divide and Conquer // Complexity is O(N*logN) struct Point { double x; double y; explicit Point(double x, double y): x(x), y(y) { } bool operator<(const struct Point rhs) const { return x < rhs.x; } }; inline double dis(struct Point lhs, struct Point rhs) { return (lhs.x - rhs.x) * (lhs.x - rhs.x) + (lhs.y - rhs.y) * (lhs.y - rhs.y); } struct ClosestPair { int n; vector<Point> p; static const int BOUND = 8; void init(int n) { this-> n = n; p.clear(); } void add_point(double x, double y) { p.push_back(Point(x, y)); } double _find_pair(int left, int right) { if (right - left < BOUND) { double td = 1E20; for (int i = left; i < right; ++i) { for (int j = i + 1; j <= right; ++j) { td = min(td, dis(p[i], p[j])); } } return td; } int mid = (left + right) >> 1; double ldis = _find_pair(left, mid); double rdis = _find_pair(mid, right); double bst = min(ldis, rdis); vector<pair<double, double> > lp, rp; int lc = mid - 1, rc = mid + 1; while (lc >= left && p[mid].x - p[lc].x < bst) { lp.push_back(make_pair(p[lc].y, p[lc].x)); --lc; } while (rc <= right && p[rc].x - p[mid].x < bst) { rp.push_back(make_pair(p[rc].y, p[rc].x)); ++rc; } sort(lp.begin(), lp.end()); sort(rp.begin(), rp.end()); int k = 0; for (size_t i = 0; i < lp.size(); ++i) { for (size_t j = k; j < rp.size(); ++j) { if (fabs(rp[j].second - lp[i].second) >= bst) { continue; } if (rp[j].first - lp[i].first >= bst) { // * break; } if (lp[i].first - rp[j].first >= bst) { // * k = j; continue; } bst = min(bst, dis(Point(lp[i].second, lp[i].first), Point(rp[j].second, rp[j].first))); } } return bst; } double closest_dis() { sort(p.begin(), p.end()); double dis = _find_pair(0, n - 1); return sqrt(dis) / 2; } };
[ "lcntn3@gmail.com" ]
lcntn3@gmail.com
6f12d53e7efe9c51743c40b9205bc00f35cfc8d3
91b948758d0111e9f6d01df2a79b475caf796479
/figure_rules.cpp
969a9284f587f6234ca5a7940cff39c4ba691f54
[]
no_license
AginSquash/ChessCPP
2c2179c078416aa05e8c777252494ab01f96a173
9c3b41c51296f9058bbd001b54beaeba77b495fe
refs/heads/master
2020-07-30T23:18:35.315890
2020-01-26T17:52:36
2020-01-26T17:52:36
210,394,309
1
0
null
2019-12-02T18:25:30
2019-09-23T15:49:11
C++
UTF-8
C++
false
false
408
cpp
// // figure_rules.cpp // ChessCPP // // Created by Vlad Vrublevsky on 25.10.2019. // #include "figure_rules.hpp" #include "SFML/System/Vector2.hpp" void Qween(sf::Vector2f pos) { } bool getRules(figure_type type, sf::Vector2f delta_pos) { switch (type) { case (b_Qween || w_Qween): //Проверка поля return true; break; default: break; } }
[ "agins.main@gmail.com" ]
agins.main@gmail.com
d7f218ebd2db0cb4e04b6f51d449321e14ae145c
d1f14a2827fc202f929f47de1f0e54d9dec21aef
/alloc.cpp
e215693f1272cba1d5e47bd34dd61611806d12ff
[ "MIT" ]
permissive
grachev/greencpp
3ee8ea8273af0f9ff3b096995356e97b0d400f95
4d034e204b7bdb0de66fa5d5802e448a1ee47222
refs/heads/master
2021-01-19T16:26:43.563116
2012-04-25T16:30:13
2012-04-25T16:30:13
4,138,416
0
1
null
null
null
null
UTF-8
C++
false
false
243
cpp
#include "alloc.h" #include "singleton.h" template <> struct TSingletonTraits<TDefaultAllocator> { static const size_t Priority = 256; }; IAllocator* TDefaultAllocator::Instance() throw () { return Singleton<TDefaultAllocator>(); }
[ "grachev@MacBook-Air-Roman-Grachev.local" ]
grachev@MacBook-Air-Roman-Grachev.local
d47f3c7025d9b3834394fa4bc1146df558067516
9f81d77e028503dcbb6d7d4c0c302391b8fdd50c
/google/cloud/bigquery/storage/v1/internal/bigquery_read_stub.h
48a2a1171be010167a9943f16d140eadc7d3631e
[ "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
googleapis/google-cloud-cpp
b96a6ee50c972371daa8b8067ddd803de95f54ba
178d6581b499242c52f9150817d91e6c95b773a5
refs/heads/main
2023-08-31T09:30:11.624568
2023-08-31T03:29:11
2023-08-31T03:29:11
111,860,063
450
351
Apache-2.0
2023-09-14T21:52:02
2017-11-24T00:19:31
C++
UTF-8
C++
false
false
3,512
h
// Copyright 2021 Google LLC // // 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 // // https://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. // Generated by the Codegen C++ plugin. // If you make any local changes, they will be lost. // source: google/cloud/bigquery/storage/v1/storage.proto #ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_BIGQUERY_STORAGE_V1_INTERNAL_BIGQUERY_READ_STUB_H #define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_BIGQUERY_STORAGE_V1_INTERNAL_BIGQUERY_READ_STUB_H #include "google/cloud/internal/streaming_read_rpc.h" #include "google/cloud/status_or.h" #include "google/cloud/version.h" #include <google/cloud/bigquery/storage/v1/storage.grpc.pb.h> #include <memory> namespace google { namespace cloud { namespace bigquery_storage_v1_internal { GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN class BigQueryReadStub { public: virtual ~BigQueryReadStub() = 0; virtual StatusOr<google::cloud::bigquery::storage::v1::ReadSession> CreateReadSession( grpc::ClientContext& context, google::cloud::bigquery::storage::v1::CreateReadSessionRequest const& request) = 0; virtual std::unique_ptr<google::cloud::internal::StreamingReadRpc< google::cloud::bigquery::storage::v1::ReadRowsResponse>> ReadRows( std::shared_ptr<grpc::ClientContext> context, google::cloud::bigquery::storage::v1::ReadRowsRequest const& request) = 0; virtual StatusOr< google::cloud::bigquery::storage::v1::SplitReadStreamResponse> SplitReadStream( grpc::ClientContext& context, google::cloud::bigquery::storage::v1::SplitReadStreamRequest const& request) = 0; }; class DefaultBigQueryReadStub : public BigQueryReadStub { public: explicit DefaultBigQueryReadStub( std::unique_ptr< google::cloud::bigquery::storage::v1::BigQueryRead::StubInterface> grpc_stub) : grpc_stub_(std::move(grpc_stub)) {} StatusOr<google::cloud::bigquery::storage::v1::ReadSession> CreateReadSession( grpc::ClientContext& client_context, google::cloud::bigquery::storage::v1::CreateReadSessionRequest const& request) override; std::unique_ptr<google::cloud::internal::StreamingReadRpc< google::cloud::bigquery::storage::v1::ReadRowsResponse>> ReadRows(std::shared_ptr<grpc::ClientContext> client_context, google::cloud::bigquery::storage::v1::ReadRowsRequest const& request) override; StatusOr<google::cloud::bigquery::storage::v1::SplitReadStreamResponse> SplitReadStream( grpc::ClientContext& client_context, google::cloud::bigquery::storage::v1::SplitReadStreamRequest const& request) override; private: std::unique_ptr< google::cloud::bigquery::storage::v1::BigQueryRead::StubInterface> grpc_stub_; }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END namespace gcpcxxV1 = GOOGLE_CLOUD_CPP_NS; // NOLINT(misc-unused-alias-decls) } // namespace bigquery_storage_v1_internal } // namespace cloud } // namespace google #endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_BIGQUERY_STORAGE_V1_INTERNAL_BIGQUERY_READ_STUB_H
[ "noreply@github.com" ]
noreply@github.com
a71fb7fc816dab048ecf6fefda053d5ad98a8afd
1189787cc120ae59a0a599d7ac1b88881735537a
/shand/old/shared_array.hpp
5888f241adb16e9725394ffe10866fb4351d1b71
[]
no_license
kariya-mitsuru/Shand
519c11556ead241ca1d33e12595bd3a9d557ea69
e4e4d79ef108bca9512adbde82c59a42f19b650d
refs/heads/master
2021-01-18T01:25:12.779022
2012-11-14T05:30:41
2012-11-14T05:30:41
null
0
0
null
null
null
null
SHIFT_JIS
C++
false
false
2,415
hpp
#ifndef SHAND_SHARED_ARRAY_INCLUDE #define SHAND_SHARED_ARRAY_INCLUDE //----------------------------------------------------------// // // // クラス名 : shared_array<Type> // // 用 途 : 参照カウント付きスマートポインタの配列版 // // // // Version : 1.00 2007/06/22 作成 // // // // Programmed By Akira.T // // Copyright(C) 2007 Akira.T All rights reserved // //----------------------------------------------------------// #include <functional> // less namespace shand { template <class Type> class shared_array { Type* object_; // 生のポインタ int* counter_; // 参照カウンタ public: typedef Type element_type; typedef Type value_type; typedef Type* pointer; shared_array() : object_(0), counter_(0) {} shared_array(const shared_array& src) : object_(0), counter_(0) { set(src); } explicit shared_array(Type* object) : object_(object), counter_(new int(1)) {} ~shared_array() { release(); } // ポインタ取得 Type* get() const { return object_; } // 参照カウント取得 long use_count() const { if (!counter_) return 0; return *counter_; } // 参照先が1つか判断 bool unique() const { return use_count() == 1; } shared_array& operator=(const shared_array& rhs) { set(rhs); return *this; } Type& operator[](int index) const { return object_[index]; } bool operator!() const { return object_ == 0; } operator bool() const { return object_ != 0; } private: void set(const shared_array& src) { if (this != &src) { release(); object_ = src.object_; counter_ = src.counter_; if (counter_ != 0) ++*counter_; } } void release() { // 参照カウンタを減らす if (counter_ != 0 && --*counter_ == 0) { delete[] object_; delete counter_; } object_ = 0; counter_ = 0; } }; template<class Type> inline bool operator==(shared_array<Type> const & lhs, shared_array<Type> const & rhs) { return lhs.get() == rhs.get(); } template<class Type> inline bool operator!=(shared_array<Type> const & lhs, shared_array<Type> const & rhs) { return lhs.get() != rhs.get(); } template<class Type> inline bool operator<(shared_array<Type> const & lhs, shared_array<Type> const & rhs) { return std::less<Type*>()(lhs.get(), rhs.get()); } } // namespace shand #endif // SHAND_SHARED_ARRAY_INCLUDE
[ "Akira.T@.(none)" ]
Akira.T@.(none)
ef311e493b667547ed1b69904c8e4a2ce6489a7a
14dc72fd771b1b935757983e77a7929fd4ba9aa2
/Network/Proto/local.pb.h
51d4ef6fa19bca42cd12ff9998cb5cada88c4001
[ "MIT" ]
permissive
xeyos/RM-Kaepora
1599d9b3049d1b074335caa3ff00885effde2754
46a955b974d0ca972bfbee05c048f254d9c167f7
refs/heads/master
2016-09-06T01:45:14.147032
2015-02-06T16:58:46
2015-02-06T16:58:46
19,490,586
0
0
null
null
null
null
UTF-8
C++
false
true
42,096
h
// Generated by the protocol buffer compiler. DO NOT EDIT! // source: local.proto #ifndef PROTOBUF_local_2eproto__INCLUDED #define PROTOBUF_local_2eproto__INCLUDED #include <string> #include <google/protobuf/stubs/common.h> #if GOOGLE_PROTOBUF_VERSION < 2005000 #error This file was generated by a newer version of protoc which is #error incompatible with your Protocol Buffer headers. Please update #error your headers. #endif #if 2005000 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION #error This file was generated by an older version of protoc which is #error incompatible with your Protocol Buffer headers. Please #error regenerate this file with a newer version of protoc. #endif #include <google/protobuf/generated_message_util.h> #include <google/protobuf/message.h> #include <google/protobuf/repeated_field.h> #include <google/protobuf/extension_set.h> #include <google/protobuf/unknown_field_set.h> // @@protoc_insertion_point(includes) namespace navi { // Internal implementation detail -- do not call these. void protobuf_AddDesc_local_2eproto(); void protobuf_AssignDesc_local_2eproto(); void protobuf_ShutdownFile_local_2eproto(); class OptionsSave; class FriendData; class Friend; class FriendList; // =================================================================== class OptionsSave : public ::google::protobuf::Message { public: OptionsSave(); virtual ~OptionsSave(); OptionsSave(const OptionsSave& from); inline OptionsSave& operator=(const OptionsSave& from) { CopyFrom(from); return *this; } inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const { return _unknown_fields_; } inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() { return &_unknown_fields_; } static const ::google::protobuf::Descriptor* descriptor(); static const OptionsSave& default_instance(); void Swap(OptionsSave* other); // implements Message ---------------------------------------------- OptionsSave* New() const; void CopyFrom(const ::google::protobuf::Message& from); void MergeFrom(const ::google::protobuf::Message& from); void CopyFrom(const OptionsSave& from); void MergeFrom(const OptionsSave& from); void Clear(); bool IsInitialized() const; int ByteSize() const; bool MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input); void SerializeWithCachedSizes( ::google::protobuf::io::CodedOutputStream* output) const; ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const; int GetCachedSize() const { return _cached_size_; } private: void SharedCtor(); void SharedDtor(); void SetCachedSize(int size) const; public: ::google::protobuf::Metadata GetMetadata() const; // nested types ---------------------------------------------------- // accessors ------------------------------------------------------- // required int32 port = 1; inline bool has_port() const; inline void clear_port(); static const int kPortFieldNumber = 1; inline ::google::protobuf::int32 port() const; inline void set_port(::google::protobuf::int32 value); // optional string languaje = 2; inline bool has_languaje() const; inline void clear_languaje(); static const int kLanguajeFieldNumber = 2; inline const ::std::string& languaje() const; inline void set_languaje(const ::std::string& value); inline void set_languaje(const char* value); inline void set_languaje(const char* value, size_t size); inline ::std::string* mutable_languaje(); inline ::std::string* release_languaje(); inline void set_allocated_languaje(::std::string* languaje); // @@protoc_insertion_point(class_scope:navi.OptionsSave) private: inline void set_has_port(); inline void clear_has_port(); inline void set_has_languaje(); inline void clear_has_languaje(); ::google::protobuf::UnknownFieldSet _unknown_fields_; ::std::string* languaje_; ::google::protobuf::int32 port_; mutable int _cached_size_; ::google::protobuf::uint32 _has_bits_[(2 + 31) / 32]; friend void protobuf_AddDesc_local_2eproto(); friend void protobuf_AssignDesc_local_2eproto(); friend void protobuf_ShutdownFile_local_2eproto(); void InitAsDefaultInstance(); static OptionsSave* default_instance_; }; // ------------------------------------------------------------------- class FriendData : public ::google::protobuf::Message { public: FriendData(); virtual ~FriendData(); FriendData(const FriendData& from); inline FriendData& operator=(const FriendData& from) { CopyFrom(from); return *this; } inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const { return _unknown_fields_; } inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() { return &_unknown_fields_; } static const ::google::protobuf::Descriptor* descriptor(); static const FriendData& default_instance(); void Swap(FriendData* other); // implements Message ---------------------------------------------- FriendData* New() const; void CopyFrom(const ::google::protobuf::Message& from); void MergeFrom(const ::google::protobuf::Message& from); void CopyFrom(const FriendData& from); void MergeFrom(const FriendData& from); void Clear(); bool IsInitialized() const; int ByteSize() const; bool MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input); void SerializeWithCachedSizes( ::google::protobuf::io::CodedOutputStream* output) const; ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const; int GetCachedSize() const { return _cached_size_; } private: void SharedCtor(); void SharedDtor(); void SetCachedSize(int size) const; public: ::google::protobuf::Metadata GetMetadata() const; // nested types ---------------------------------------------------- // accessors ------------------------------------------------------- // optional bytes port = 1 [default = "NONE"]; inline bool has_port() const; inline void clear_port(); static const int kPortFieldNumber = 1; inline const ::std::string& port() const; inline void set_port(const ::std::string& value); inline void set_port(const char* value); inline void set_port(const void* value, size_t size); inline ::std::string* mutable_port(); inline ::std::string* release_port(); inline void set_allocated_port(::std::string* port); // optional bytes ip = 2 [default = "NONE"]; inline bool has_ip() const; inline void clear_ip(); static const int kIpFieldNumber = 2; inline const ::std::string& ip() const; inline void set_ip(const ::std::string& value); inline void set_ip(const char* value); inline void set_ip(const void* value, size_t size); inline ::std::string* mutable_ip(); inline ::std::string* release_ip(); inline void set_allocated_ip(::std::string* ip); // optional bytes date = 3 [default = "NONE"]; inline bool has_date() const; inline void clear_date(); static const int kDateFieldNumber = 3; inline const ::std::string& date() const; inline void set_date(const ::std::string& value); inline void set_date(const char* value); inline void set_date(const void* value, size_t size); inline ::std::string* mutable_date(); inline ::std::string* release_date(); inline void set_allocated_date(::std::string* date); // required bytes key = 4; inline bool has_key() const; inline void clear_key(); static const int kKeyFieldNumber = 4; inline const ::std::string& key() const; inline void set_key(const ::std::string& value); inline void set_key(const char* value); inline void set_key(const void* value, size_t size); inline ::std::string* mutable_key(); inline ::std::string* release_key(); inline void set_allocated_key(::std::string* key); // repeated .navi.FriendList commonFriends = 5; inline int commonfriends_size() const; inline void clear_commonfriends(); static const int kCommonFriendsFieldNumber = 5; inline const ::navi::FriendList& commonfriends(int index) const; inline ::navi::FriendList* mutable_commonfriends(int index); inline ::navi::FriendList* add_commonfriends(); inline const ::google::protobuf::RepeatedPtrField< ::navi::FriendList >& commonfriends() const; inline ::google::protobuf::RepeatedPtrField< ::navi::FriendList >* mutable_commonfriends(); // @@protoc_insertion_point(class_scope:navi.FriendData) private: inline void set_has_port(); inline void clear_has_port(); inline void set_has_ip(); inline void clear_has_ip(); inline void set_has_date(); inline void clear_has_date(); inline void set_has_key(); inline void clear_has_key(); ::google::protobuf::UnknownFieldSet _unknown_fields_; ::std::string* port_; static ::std::string* _default_port_; ::std::string* ip_; static ::std::string* _default_ip_; ::std::string* date_; static ::std::string* _default_date_; ::std::string* key_; ::google::protobuf::RepeatedPtrField< ::navi::FriendList > commonfriends_; mutable int _cached_size_; ::google::protobuf::uint32 _has_bits_[(5 + 31) / 32]; friend void protobuf_AddDesc_local_2eproto(); friend void protobuf_AssignDesc_local_2eproto(); friend void protobuf_ShutdownFile_local_2eproto(); void InitAsDefaultInstance(); static FriendData* default_instance_; }; // ------------------------------------------------------------------- class Friend : public ::google::protobuf::Message { public: Friend(); virtual ~Friend(); Friend(const Friend& from); inline Friend& operator=(const Friend& from) { CopyFrom(from); return *this; } inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const { return _unknown_fields_; } inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() { return &_unknown_fields_; } static const ::google::protobuf::Descriptor* descriptor(); static const Friend& default_instance(); void Swap(Friend* other); // implements Message ---------------------------------------------- Friend* New() const; void CopyFrom(const ::google::protobuf::Message& from); void MergeFrom(const ::google::protobuf::Message& from); void CopyFrom(const Friend& from); void MergeFrom(const Friend& from); void Clear(); bool IsInitialized() const; int ByteSize() const; bool MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input); void SerializeWithCachedSizes( ::google::protobuf::io::CodedOutputStream* output) const; ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const; int GetCachedSize() const { return _cached_size_; } private: void SharedCtor(); void SharedDtor(); void SetCachedSize(int size) const; public: ::google::protobuf::Metadata GetMetadata() const; // nested types ---------------------------------------------------- // accessors ------------------------------------------------------- // required string uname = 5; inline bool has_uname() const; inline void clear_uname(); static const int kUnameFieldNumber = 5; inline const ::std::string& uname() const; inline void set_uname(const ::std::string& value); inline void set_uname(const char* value); inline void set_uname(const char* value, size_t size); inline ::std::string* mutable_uname(); inline ::std::string* release_uname(); inline void set_allocated_uname(::std::string* uname); // required string server = 8; inline bool has_server() const; inline void clear_server(); static const int kServerFieldNumber = 8; inline const ::std::string& server() const; inline void set_server(const ::std::string& value); inline void set_server(const char* value); inline void set_server(const char* value, size_t size); inline ::std::string* mutable_server(); inline ::std::string* release_server(); inline void set_allocated_server(::std::string* server); // optional string identifier = 6 [default = ""]; inline bool has_identifier() const; inline void clear_identifier(); static const int kIdentifierFieldNumber = 6; inline const ::std::string& identifier() const; inline void set_identifier(const ::std::string& value); inline void set_identifier(const char* value); inline void set_identifier(const char* value, size_t size); inline ::std::string* mutable_identifier(); inline ::std::string* release_identifier(); inline void set_allocated_identifier(::std::string* identifier); // optional string avatar = 7 [default = ""]; inline bool has_avatar() const; inline void clear_avatar(); static const int kAvatarFieldNumber = 7; inline const ::std::string& avatar() const; inline void set_avatar(const ::std::string& value); inline void set_avatar(const char* value); inline void set_avatar(const char* value, size_t size); inline ::std::string* mutable_avatar(); inline ::std::string* release_avatar(); inline void set_allocated_avatar(::std::string* avatar); // optional int32 port = 1 [default = 0]; inline bool has_port() const; inline void clear_port(); static const int kPortFieldNumber = 1; inline ::google::protobuf::int32 port() const; inline void set_port(::google::protobuf::int32 value); // optional string ip = 2 [default = "NONE"]; inline bool has_ip() const; inline void clear_ip(); static const int kIpFieldNumber = 2; inline const ::std::string& ip() const; inline void set_ip(const ::std::string& value); inline void set_ip(const char* value); inline void set_ip(const char* value, size_t size); inline ::std::string* mutable_ip(); inline ::std::string* release_ip(); inline void set_allocated_ip(::std::string* ip); // required string key = 4; inline bool has_key() const; inline void clear_key(); static const int kKeyFieldNumber = 4; inline const ::std::string& key() const; inline void set_key(const ::std::string& value); inline void set_key(const char* value); inline void set_key(const char* value, size_t size); inline ::std::string* mutable_key(); inline ::std::string* release_key(); inline void set_allocated_key(::std::string* key); // @@protoc_insertion_point(class_scope:navi.Friend) private: inline void set_has_uname(); inline void clear_has_uname(); inline void set_has_server(); inline void clear_has_server(); inline void set_has_identifier(); inline void clear_has_identifier(); inline void set_has_avatar(); inline void clear_has_avatar(); inline void set_has_port(); inline void clear_has_port(); inline void set_has_ip(); inline void clear_has_ip(); inline void set_has_key(); inline void clear_has_key(); ::google::protobuf::UnknownFieldSet _unknown_fields_; ::std::string* uname_; ::std::string* server_; ::std::string* identifier_; ::std::string* avatar_; ::std::string* ip_; static ::std::string* _default_ip_; ::std::string* key_; ::google::protobuf::int32 port_; mutable int _cached_size_; ::google::protobuf::uint32 _has_bits_[(7 + 31) / 32]; friend void protobuf_AddDesc_local_2eproto(); friend void protobuf_AssignDesc_local_2eproto(); friend void protobuf_ShutdownFile_local_2eproto(); void InitAsDefaultInstance(); static Friend* default_instance_; }; // ------------------------------------------------------------------- class FriendList : public ::google::protobuf::Message { public: FriendList(); virtual ~FriendList(); FriendList(const FriendList& from); inline FriendList& operator=(const FriendList& from) { CopyFrom(from); return *this; } inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const { return _unknown_fields_; } inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() { return &_unknown_fields_; } static const ::google::protobuf::Descriptor* descriptor(); static const FriendList& default_instance(); void Swap(FriendList* other); // implements Message ---------------------------------------------- FriendList* New() const; void CopyFrom(const ::google::protobuf::Message& from); void MergeFrom(const ::google::protobuf::Message& from); void CopyFrom(const FriendList& from); void MergeFrom(const FriendList& from); void Clear(); bool IsInitialized() const; int ByteSize() const; bool MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input); void SerializeWithCachedSizes( ::google::protobuf::io::CodedOutputStream* output) const; ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const; int GetCachedSize() const { return _cached_size_; } private: void SharedCtor(); void SharedDtor(); void SetCachedSize(int size) const; public: ::google::protobuf::Metadata GetMetadata() const; // nested types ---------------------------------------------------- // accessors ------------------------------------------------------- // repeated .navi.FriendData friend = 1; inline int friend__size() const; inline void clear_friend_(); static const int kFriendFieldNumber = 1; inline const ::navi::FriendData& friend_(int index) const; inline ::navi::FriendData* mutable_friend_(int index); inline ::navi::FriendData* add_friend_(); inline const ::google::protobuf::RepeatedPtrField< ::navi::FriendData >& friend_() const; inline ::google::protobuf::RepeatedPtrField< ::navi::FriendData >* mutable_friend_(); // @@protoc_insertion_point(class_scope:navi.FriendList) private: ::google::protobuf::UnknownFieldSet _unknown_fields_; ::google::protobuf::RepeatedPtrField< ::navi::FriendData > friend__; mutable int _cached_size_; ::google::protobuf::uint32 _has_bits_[(1 + 31) / 32]; friend void protobuf_AddDesc_local_2eproto(); friend void protobuf_AssignDesc_local_2eproto(); friend void protobuf_ShutdownFile_local_2eproto(); void InitAsDefaultInstance(); static FriendList* default_instance_; }; // =================================================================== // =================================================================== // OptionsSave // required int32 port = 1; inline bool OptionsSave::has_port() const { return (_has_bits_[0] & 0x00000001u) != 0; } inline void OptionsSave::set_has_port() { _has_bits_[0] |= 0x00000001u; } inline void OptionsSave::clear_has_port() { _has_bits_[0] &= ~0x00000001u; } inline void OptionsSave::clear_port() { port_ = 0; clear_has_port(); } inline ::google::protobuf::int32 OptionsSave::port() const { return port_; } inline void OptionsSave::set_port(::google::protobuf::int32 value) { set_has_port(); port_ = value; } // optional string languaje = 2; inline bool OptionsSave::has_languaje() const { return (_has_bits_[0] & 0x00000002u) != 0; } inline void OptionsSave::set_has_languaje() { _has_bits_[0] |= 0x00000002u; } inline void OptionsSave::clear_has_languaje() { _has_bits_[0] &= ~0x00000002u; } inline void OptionsSave::clear_languaje() { if (languaje_ != &::google::protobuf::internal::kEmptyString) { languaje_->clear(); } clear_has_languaje(); } inline const ::std::string& OptionsSave::languaje() const { return *languaje_; } inline void OptionsSave::set_languaje(const ::std::string& value) { set_has_languaje(); if (languaje_ == &::google::protobuf::internal::kEmptyString) { languaje_ = new ::std::string; } languaje_->assign(value); } inline void OptionsSave::set_languaje(const char* value) { set_has_languaje(); if (languaje_ == &::google::protobuf::internal::kEmptyString) { languaje_ = new ::std::string; } languaje_->assign(value); } inline void OptionsSave::set_languaje(const char* value, size_t size) { set_has_languaje(); if (languaje_ == &::google::protobuf::internal::kEmptyString) { languaje_ = new ::std::string; } languaje_->assign(reinterpret_cast<const char*>(value), size); } inline ::std::string* OptionsSave::mutable_languaje() { set_has_languaje(); if (languaje_ == &::google::protobuf::internal::kEmptyString) { languaje_ = new ::std::string; } return languaje_; } inline ::std::string* OptionsSave::release_languaje() { clear_has_languaje(); if (languaje_ == &::google::protobuf::internal::kEmptyString) { return NULL; } else { ::std::string* temp = languaje_; languaje_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); return temp; } } inline void OptionsSave::set_allocated_languaje(::std::string* languaje) { if (languaje_ != &::google::protobuf::internal::kEmptyString) { delete languaje_; } if (languaje) { set_has_languaje(); languaje_ = languaje; } else { clear_has_languaje(); languaje_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); } } // ------------------------------------------------------------------- // FriendData // optional bytes port = 1 [default = "NONE"]; inline bool FriendData::has_port() const { return (_has_bits_[0] & 0x00000001u) != 0; } inline void FriendData::set_has_port() { _has_bits_[0] |= 0x00000001u; } inline void FriendData::clear_has_port() { _has_bits_[0] &= ~0x00000001u; } inline void FriendData::clear_port() { if (port_ != _default_port_) { port_->assign(*_default_port_); } clear_has_port(); } inline const ::std::string& FriendData::port() const { return *port_; } inline void FriendData::set_port(const ::std::string& value) { set_has_port(); if (port_ == _default_port_) { port_ = new ::std::string; } port_->assign(value); } inline void FriendData::set_port(const char* value) { set_has_port(); if (port_ == _default_port_) { port_ = new ::std::string; } port_->assign(value); } inline void FriendData::set_port(const void* value, size_t size) { set_has_port(); if (port_ == _default_port_) { port_ = new ::std::string; } port_->assign(reinterpret_cast<const char*>(value), size); } inline ::std::string* FriendData::mutable_port() { set_has_port(); if (port_ == _default_port_) { port_ = new ::std::string(*_default_port_); } return port_; } inline ::std::string* FriendData::release_port() { clear_has_port(); if (port_ == _default_port_) { return NULL; } else { ::std::string* temp = port_; port_ = const_cast< ::std::string*>(_default_port_); return temp; } } inline void FriendData::set_allocated_port(::std::string* port) { if (port_ != _default_port_) { delete port_; } if (port) { set_has_port(); port_ = port; } else { clear_has_port(); port_ = const_cast< ::std::string*>(_default_port_); } } // optional bytes ip = 2 [default = "NONE"]; inline bool FriendData::has_ip() const { return (_has_bits_[0] & 0x00000002u) != 0; } inline void FriendData::set_has_ip() { _has_bits_[0] |= 0x00000002u; } inline void FriendData::clear_has_ip() { _has_bits_[0] &= ~0x00000002u; } inline void FriendData::clear_ip() { if (ip_ != _default_ip_) { ip_->assign(*_default_ip_); } clear_has_ip(); } inline const ::std::string& FriendData::ip() const { return *ip_; } inline void FriendData::set_ip(const ::std::string& value) { set_has_ip(); if (ip_ == _default_ip_) { ip_ = new ::std::string; } ip_->assign(value); } inline void FriendData::set_ip(const char* value) { set_has_ip(); if (ip_ == _default_ip_) { ip_ = new ::std::string; } ip_->assign(value); } inline void FriendData::set_ip(const void* value, size_t size) { set_has_ip(); if (ip_ == _default_ip_) { ip_ = new ::std::string; } ip_->assign(reinterpret_cast<const char*>(value), size); } inline ::std::string* FriendData::mutable_ip() { set_has_ip(); if (ip_ == _default_ip_) { ip_ = new ::std::string(*_default_ip_); } return ip_; } inline ::std::string* FriendData::release_ip() { clear_has_ip(); if (ip_ == _default_ip_) { return NULL; } else { ::std::string* temp = ip_; ip_ = const_cast< ::std::string*>(_default_ip_); return temp; } } inline void FriendData::set_allocated_ip(::std::string* ip) { if (ip_ != _default_ip_) { delete ip_; } if (ip) { set_has_ip(); ip_ = ip; } else { clear_has_ip(); ip_ = const_cast< ::std::string*>(_default_ip_); } } // optional bytes date = 3 [default = "NONE"]; inline bool FriendData::has_date() const { return (_has_bits_[0] & 0x00000004u) != 0; } inline void FriendData::set_has_date() { _has_bits_[0] |= 0x00000004u; } inline void FriendData::clear_has_date() { _has_bits_[0] &= ~0x00000004u; } inline void FriendData::clear_date() { if (date_ != _default_date_) { date_->assign(*_default_date_); } clear_has_date(); } inline const ::std::string& FriendData::date() const { return *date_; } inline void FriendData::set_date(const ::std::string& value) { set_has_date(); if (date_ == _default_date_) { date_ = new ::std::string; } date_->assign(value); } inline void FriendData::set_date(const char* value) { set_has_date(); if (date_ == _default_date_) { date_ = new ::std::string; } date_->assign(value); } inline void FriendData::set_date(const void* value, size_t size) { set_has_date(); if (date_ == _default_date_) { date_ = new ::std::string; } date_->assign(reinterpret_cast<const char*>(value), size); } inline ::std::string* FriendData::mutable_date() { set_has_date(); if (date_ == _default_date_) { date_ = new ::std::string(*_default_date_); } return date_; } inline ::std::string* FriendData::release_date() { clear_has_date(); if (date_ == _default_date_) { return NULL; } else { ::std::string* temp = date_; date_ = const_cast< ::std::string*>(_default_date_); return temp; } } inline void FriendData::set_allocated_date(::std::string* date) { if (date_ != _default_date_) { delete date_; } if (date) { set_has_date(); date_ = date; } else { clear_has_date(); date_ = const_cast< ::std::string*>(_default_date_); } } // required bytes key = 4; inline bool FriendData::has_key() const { return (_has_bits_[0] & 0x00000008u) != 0; } inline void FriendData::set_has_key() { _has_bits_[0] |= 0x00000008u; } inline void FriendData::clear_has_key() { _has_bits_[0] &= ~0x00000008u; } inline void FriendData::clear_key() { if (key_ != &::google::protobuf::internal::kEmptyString) { key_->clear(); } clear_has_key(); } inline const ::std::string& FriendData::key() const { return *key_; } inline void FriendData::set_key(const ::std::string& value) { set_has_key(); if (key_ == &::google::protobuf::internal::kEmptyString) { key_ = new ::std::string; } key_->assign(value); } inline void FriendData::set_key(const char* value) { set_has_key(); if (key_ == &::google::protobuf::internal::kEmptyString) { key_ = new ::std::string; } key_->assign(value); } inline void FriendData::set_key(const void* value, size_t size) { set_has_key(); if (key_ == &::google::protobuf::internal::kEmptyString) { key_ = new ::std::string; } key_->assign(reinterpret_cast<const char*>(value), size); } inline ::std::string* FriendData::mutable_key() { set_has_key(); if (key_ == &::google::protobuf::internal::kEmptyString) { key_ = new ::std::string; } return key_; } inline ::std::string* FriendData::release_key() { clear_has_key(); if (key_ == &::google::protobuf::internal::kEmptyString) { return NULL; } else { ::std::string* temp = key_; key_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); return temp; } } inline void FriendData::set_allocated_key(::std::string* key) { if (key_ != &::google::protobuf::internal::kEmptyString) { delete key_; } if (key) { set_has_key(); key_ = key; } else { clear_has_key(); key_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); } } // repeated .navi.FriendList commonFriends = 5; inline int FriendData::commonfriends_size() const { return commonfriends_.size(); } inline void FriendData::clear_commonfriends() { commonfriends_.Clear(); } inline const ::navi::FriendList& FriendData::commonfriends(int index) const { return commonfriends_.Get(index); } inline ::navi::FriendList* FriendData::mutable_commonfriends(int index) { return commonfriends_.Mutable(index); } inline ::navi::FriendList* FriendData::add_commonfriends() { return commonfriends_.Add(); } inline const ::google::protobuf::RepeatedPtrField< ::navi::FriendList >& FriendData::commonfriends() const { return commonfriends_; } inline ::google::protobuf::RepeatedPtrField< ::navi::FriendList >* FriendData::mutable_commonfriends() { return &commonfriends_; } // ------------------------------------------------------------------- // Friend // required string uname = 5; inline bool Friend::has_uname() const { return (_has_bits_[0] & 0x00000001u) != 0; } inline void Friend::set_has_uname() { _has_bits_[0] |= 0x00000001u; } inline void Friend::clear_has_uname() { _has_bits_[0] &= ~0x00000001u; } inline void Friend::clear_uname() { if (uname_ != &::google::protobuf::internal::kEmptyString) { uname_->clear(); } clear_has_uname(); } inline const ::std::string& Friend::uname() const { return *uname_; } inline void Friend::set_uname(const ::std::string& value) { set_has_uname(); if (uname_ == &::google::protobuf::internal::kEmptyString) { uname_ = new ::std::string; } uname_->assign(value); } inline void Friend::set_uname(const char* value) { set_has_uname(); if (uname_ == &::google::protobuf::internal::kEmptyString) { uname_ = new ::std::string; } uname_->assign(value); } inline void Friend::set_uname(const char* value, size_t size) { set_has_uname(); if (uname_ == &::google::protobuf::internal::kEmptyString) { uname_ = new ::std::string; } uname_->assign(reinterpret_cast<const char*>(value), size); } inline ::std::string* Friend::mutable_uname() { set_has_uname(); if (uname_ == &::google::protobuf::internal::kEmptyString) { uname_ = new ::std::string; } return uname_; } inline ::std::string* Friend::release_uname() { clear_has_uname(); if (uname_ == &::google::protobuf::internal::kEmptyString) { return NULL; } else { ::std::string* temp = uname_; uname_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); return temp; } } inline void Friend::set_allocated_uname(::std::string* uname) { if (uname_ != &::google::protobuf::internal::kEmptyString) { delete uname_; } if (uname) { set_has_uname(); uname_ = uname; } else { clear_has_uname(); uname_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); } } // required string server = 8; inline bool Friend::has_server() const { return (_has_bits_[0] & 0x00000002u) != 0; } inline void Friend::set_has_server() { _has_bits_[0] |= 0x00000002u; } inline void Friend::clear_has_server() { _has_bits_[0] &= ~0x00000002u; } inline void Friend::clear_server() { if (server_ != &::google::protobuf::internal::kEmptyString) { server_->clear(); } clear_has_server(); } inline const ::std::string& Friend::server() const { return *server_; } inline void Friend::set_server(const ::std::string& value) { set_has_server(); if (server_ == &::google::protobuf::internal::kEmptyString) { server_ = new ::std::string; } server_->assign(value); } inline void Friend::set_server(const char* value) { set_has_server(); if (server_ == &::google::protobuf::internal::kEmptyString) { server_ = new ::std::string; } server_->assign(value); } inline void Friend::set_server(const char* value, size_t size) { set_has_server(); if (server_ == &::google::protobuf::internal::kEmptyString) { server_ = new ::std::string; } server_->assign(reinterpret_cast<const char*>(value), size); } inline ::std::string* Friend::mutable_server() { set_has_server(); if (server_ == &::google::protobuf::internal::kEmptyString) { server_ = new ::std::string; } return server_; } inline ::std::string* Friend::release_server() { clear_has_server(); if (server_ == &::google::protobuf::internal::kEmptyString) { return NULL; } else { ::std::string* temp = server_; server_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); return temp; } } inline void Friend::set_allocated_server(::std::string* server) { if (server_ != &::google::protobuf::internal::kEmptyString) { delete server_; } if (server) { set_has_server(); server_ = server; } else { clear_has_server(); server_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); } } // optional string identifier = 6 [default = ""]; inline bool Friend::has_identifier() const { return (_has_bits_[0] & 0x00000004u) != 0; } inline void Friend::set_has_identifier() { _has_bits_[0] |= 0x00000004u; } inline void Friend::clear_has_identifier() { _has_bits_[0] &= ~0x00000004u; } inline void Friend::clear_identifier() { if (identifier_ != &::google::protobuf::internal::kEmptyString) { identifier_->clear(); } clear_has_identifier(); } inline const ::std::string& Friend::identifier() const { return *identifier_; } inline void Friend::set_identifier(const ::std::string& value) { set_has_identifier(); if (identifier_ == &::google::protobuf::internal::kEmptyString) { identifier_ = new ::std::string; } identifier_->assign(value); } inline void Friend::set_identifier(const char* value) { set_has_identifier(); if (identifier_ == &::google::protobuf::internal::kEmptyString) { identifier_ = new ::std::string; } identifier_->assign(value); } inline void Friend::set_identifier(const char* value, size_t size) { set_has_identifier(); if (identifier_ == &::google::protobuf::internal::kEmptyString) { identifier_ = new ::std::string; } identifier_->assign(reinterpret_cast<const char*>(value), size); } inline ::std::string* Friend::mutable_identifier() { set_has_identifier(); if (identifier_ == &::google::protobuf::internal::kEmptyString) { identifier_ = new ::std::string; } return identifier_; } inline ::std::string* Friend::release_identifier() { clear_has_identifier(); if (identifier_ == &::google::protobuf::internal::kEmptyString) { return NULL; } else { ::std::string* temp = identifier_; identifier_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); return temp; } } inline void Friend::set_allocated_identifier(::std::string* identifier) { if (identifier_ != &::google::protobuf::internal::kEmptyString) { delete identifier_; } if (identifier) { set_has_identifier(); identifier_ = identifier; } else { clear_has_identifier(); identifier_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); } } // optional string avatar = 7 [default = ""]; inline bool Friend::has_avatar() const { return (_has_bits_[0] & 0x00000008u) != 0; } inline void Friend::set_has_avatar() { _has_bits_[0] |= 0x00000008u; } inline void Friend::clear_has_avatar() { _has_bits_[0] &= ~0x00000008u; } inline void Friend::clear_avatar() { if (avatar_ != &::google::protobuf::internal::kEmptyString) { avatar_->clear(); } clear_has_avatar(); } inline const ::std::string& Friend::avatar() const { return *avatar_; } inline void Friend::set_avatar(const ::std::string& value) { set_has_avatar(); if (avatar_ == &::google::protobuf::internal::kEmptyString) { avatar_ = new ::std::string; } avatar_->assign(value); } inline void Friend::set_avatar(const char* value) { set_has_avatar(); if (avatar_ == &::google::protobuf::internal::kEmptyString) { avatar_ = new ::std::string; } avatar_->assign(value); } inline void Friend::set_avatar(const char* value, size_t size) { set_has_avatar(); if (avatar_ == &::google::protobuf::internal::kEmptyString) { avatar_ = new ::std::string; } avatar_->assign(reinterpret_cast<const char*>(value), size); } inline ::std::string* Friend::mutable_avatar() { set_has_avatar(); if (avatar_ == &::google::protobuf::internal::kEmptyString) { avatar_ = new ::std::string; } return avatar_; } inline ::std::string* Friend::release_avatar() { clear_has_avatar(); if (avatar_ == &::google::protobuf::internal::kEmptyString) { return NULL; } else { ::std::string* temp = avatar_; avatar_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); return temp; } } inline void Friend::set_allocated_avatar(::std::string* avatar) { if (avatar_ != &::google::protobuf::internal::kEmptyString) { delete avatar_; } if (avatar) { set_has_avatar(); avatar_ = avatar; } else { clear_has_avatar(); avatar_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); } } // optional int32 port = 1 [default = 0]; inline bool Friend::has_port() const { return (_has_bits_[0] & 0x00000010u) != 0; } inline void Friend::set_has_port() { _has_bits_[0] |= 0x00000010u; } inline void Friend::clear_has_port() { _has_bits_[0] &= ~0x00000010u; } inline void Friend::clear_port() { port_ = 0; clear_has_port(); } inline ::google::protobuf::int32 Friend::port() const { return port_; } inline void Friend::set_port(::google::protobuf::int32 value) { set_has_port(); port_ = value; } // optional string ip = 2 [default = "NONE"]; inline bool Friend::has_ip() const { return (_has_bits_[0] & 0x00000020u) != 0; } inline void Friend::set_has_ip() { _has_bits_[0] |= 0x00000020u; } inline void Friend::clear_has_ip() { _has_bits_[0] &= ~0x00000020u; } inline void Friend::clear_ip() { if (ip_ != _default_ip_) { ip_->assign(*_default_ip_); } clear_has_ip(); } inline const ::std::string& Friend::ip() const { return *ip_; } inline void Friend::set_ip(const ::std::string& value) { set_has_ip(); if (ip_ == _default_ip_) { ip_ = new ::std::string; } ip_->assign(value); } inline void Friend::set_ip(const char* value) { set_has_ip(); if (ip_ == _default_ip_) { ip_ = new ::std::string; } ip_->assign(value); } inline void Friend::set_ip(const char* value, size_t size) { set_has_ip(); if (ip_ == _default_ip_) { ip_ = new ::std::string; } ip_->assign(reinterpret_cast<const char*>(value), size); } inline ::std::string* Friend::mutable_ip() { set_has_ip(); if (ip_ == _default_ip_) { ip_ = new ::std::string(*_default_ip_); } return ip_; } inline ::std::string* Friend::release_ip() { clear_has_ip(); if (ip_ == _default_ip_) { return NULL; } else { ::std::string* temp = ip_; ip_ = const_cast< ::std::string*>(_default_ip_); return temp; } } inline void Friend::set_allocated_ip(::std::string* ip) { if (ip_ != _default_ip_) { delete ip_; } if (ip) { set_has_ip(); ip_ = ip; } else { clear_has_ip(); ip_ = const_cast< ::std::string*>(_default_ip_); } } // required string key = 4; inline bool Friend::has_key() const { return (_has_bits_[0] & 0x00000040u) != 0; } inline void Friend::set_has_key() { _has_bits_[0] |= 0x00000040u; } inline void Friend::clear_has_key() { _has_bits_[0] &= ~0x00000040u; } inline void Friend::clear_key() { if (key_ != &::google::protobuf::internal::kEmptyString) { key_->clear(); } clear_has_key(); } inline const ::std::string& Friend::key() const { return *key_; } inline void Friend::set_key(const ::std::string& value) { set_has_key(); if (key_ == &::google::protobuf::internal::kEmptyString) { key_ = new ::std::string; } key_->assign(value); } inline void Friend::set_key(const char* value) { set_has_key(); if (key_ == &::google::protobuf::internal::kEmptyString) { key_ = new ::std::string; } key_->assign(value); } inline void Friend::set_key(const char* value, size_t size) { set_has_key(); if (key_ == &::google::protobuf::internal::kEmptyString) { key_ = new ::std::string; } key_->assign(reinterpret_cast<const char*>(value), size); } inline ::std::string* Friend::mutable_key() { set_has_key(); if (key_ == &::google::protobuf::internal::kEmptyString) { key_ = new ::std::string; } return key_; } inline ::std::string* Friend::release_key() { clear_has_key(); if (key_ == &::google::protobuf::internal::kEmptyString) { return NULL; } else { ::std::string* temp = key_; key_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); return temp; } } inline void Friend::set_allocated_key(::std::string* key) { if (key_ != &::google::protobuf::internal::kEmptyString) { delete key_; } if (key) { set_has_key(); key_ = key; } else { clear_has_key(); key_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); } } // ------------------------------------------------------------------- // FriendList // repeated .navi.FriendData friend = 1; inline int FriendList::friend__size() const { return friend__.size(); } inline void FriendList::clear_friend_() { friend__.Clear(); } inline const ::navi::FriendData& FriendList::friend_(int index) const { return friend__.Get(index); } inline ::navi::FriendData* FriendList::mutable_friend_(int index) { return friend__.Mutable(index); } inline ::navi::FriendData* FriendList::add_friend_() { return friend__.Add(); } inline const ::google::protobuf::RepeatedPtrField< ::navi::FriendData >& FriendList::friend_() const { return friend__; } inline ::google::protobuf::RepeatedPtrField< ::navi::FriendData >* FriendList::mutable_friend_() { return &friend__; } // @@protoc_insertion_point(namespace_scope) } // namespace navi #ifndef SWIG namespace google { namespace protobuf { } // namespace google } // namespace protobuf #endif // SWIG // @@protoc_insertion_point(global_scope) #endif // PROTOBUF_local_2eproto__INCLUDED
[ "orb@InfinityJustice.(none)" ]
orb@InfinityJustice.(none)
d962785aeb928b63e69f56d4d4a7fd01c7620709
3b870b15415b4f18c06f08c01dc7a68b7461c769
/include/fraction.h
29b7d4fd650e16e4315dfca1456564f91769cfc8
[]
no_license
bryce-johnston/fractions
b6223968abb1a31dca161de35c61e378ea8ec6b1
4c7f1fbcff4226802b92a4b0669e6b4fe1656478
refs/heads/master
2020-04-02T18:36:38.108786
2018-10-25T16:53:45
2018-10-25T16:53:45
154,706,565
1
0
null
null
null
null
UTF-8
C++
false
false
557
h
#ifndef FRACTION_FRACTION_H #define FRACTION_FRACTION_H #include <cstdint> class Fraction { public: Fraction(int32_t numerator, int32_t denominator){ this->numerator = numerator; this->denominator = denominator; } public: int32_t getNumerator() const; int32_t getDenominator() const; double getRealValue() const; void setNumerator( int32_t numerator ); void setDenominator ( int32_t denominator ); void output(); private: int32_t numerator; int32_t denominator; }; #endif //FRACTION_FRACTION_H
[ "bryce.t.johnston@gmail.com" ]
bryce.t.johnston@gmail.com
959bdd48f2014eaf4c7a5b39055275020bd9dcdf
4960d4f64928a065748fd072fc6d246e23775bbd
/hdu1878之欧拉回路.cpp
23ac3fa8dd8daefd6ab029ca65bc7f7c020b8361
[]
no_license
Stephen1993/ACM-code
b46d75e4367387e7ca4bec6442a7b29b73594f8d
fd6c2fbad8b0dd1d5f3c90df733c8bc09070ae2a
refs/heads/master
2020-07-28T19:44:03.076259
2019-11-15T15:08:12
2019-11-15T15:08:12
73,697,351
0
1
null
null
null
null
UTF-8
C++
false
false
1,087
cpp
#include<iostream> #include<cstdio> #include<cstdlib> #include<cstring> #include<string> #include<queue> #include<algorithm> #include<map> #include<iomanip> #include<vector> #define INF 99999999 using namespace std; const int MAX=1001; int n,m,father[MAX],rank[MAX]; int degree[MAX],sum; void makeset(int num){ for(int i=1;i<=num;++i){ father[i]=i; rank[i]=1; } } int findset(int v){ if(v != father[v])father[v]=findset(father[v]); return father[v]; } void Union(int a,int b){ int x=findset(a); int y=findset(b); if(x == y)return; if(rank[x]<rank[y]){ father[x]=y; rank[y]+=rank[x]; } else{ father[y]=x; rank[x]+=rank[y]; } --sum; } int main(){ int a,b; while(cin>>n,n){ cin>>m; memset(degree,0,sizeof degree); makeset(n); sum=n; for(int i=0;i<m;++i){ scanf("%d%d",&a,&b); ++degree[a]; ++degree[b]; Union(a,b); } if(sum == 1){ while(n){ if(degree[n]&1){cout<<"0"<<endl;break;} --n; } if(!n)cout<<"1"<<endl; }else cout<<"0"<<endl; } return 0; }
[ "chenyang.zhang@outlook.com" ]
chenyang.zhang@outlook.com
0b25a1b40195c8bc061314864d291a2f98f98265
4fa1e0711c3023a94035b58f6a66c9acd4a7f424
/Microsoft/SAMPLES/Ole2View/IViewers/idataobj.cpp
f8f0617d3f8b4ea344add1c52ef4f66eba922f17
[ "MIT" ]
permissive
tig/Tigger
4d1f5a2088468c75a7c21b103705445a93ec571c
8e06d117a5b520c5fc9e37a710bf17aa51a9958c
refs/heads/master
2023-06-09T01:59:43.167371
2020-08-19T15:21:53
2020-08-19T15:21:53
3,426,737
1
2
null
2023-05-31T18:56:36
2012-02-13T03:05:18
C
UTF-8
C++
false
false
40,465
cpp
// idataobj.cpp // // Implementation file for the IDataObject interface viewer. // // This is a part of the Microsoft Foundation Classes C++ library. // Copyright (C) 1992-1993 Microsoft Corporation // All rights reserved. // // This source code is only intended as a supplement to the // Microsoft Foundation Classes Reference and Microsoft // QuickHelp and/or WinHelp documentation provided with the library. // See these sources for detailed information regarding the // Microsoft Foundation Classes product. // // Revisions: // August 7, 1993 cek First implementation. // February 19, 1994 cek Removed XRT stuff. Fixed minor bugs. // April 9, 1994 cek Pulled from XRTView and genericized again. // #include "stdafx.h" #include <windowsx.h> #include "iviewers.h" #include "util.h" #include "idataobj.h" #include "iadvsink.h" #define new DEBUG_NEW static HFONT g_hFont ; static HFONT g_hFontBold ; static UINT g_cyFont ; static WNDPROC g_pfnEdit = NULL ; #define I_NORMAL 0x0000 #define I_LABEL 0x0001 #define I_COLUMNHEAD 0x0002 #define I_COLUMNENTRY 0x0003 typedef struct FAR tagITEMDATA { UINT nLevel ; UINT uiType ; int cColumns ; LPCOLUMNSTRUCT rgCol ; LPVOID lpData ; } ITEMDATA, *PITEMDATA, FAR*LPITEMDATA ; extern "C" LRESULT EXPORT CALLBACK fnEditSubclass( HWND hwnd, UINT uiMsg, WPARAM wP, LPARAM lP ) ; LPCTSTR MyGetClipboardFormatName( UINT cf ) ; ///////////////////////////////////////////////////////////////////////////// // CIDataObjectDlg dialog // CIDataObjectDlg::CIDataObjectDlg( HWND hwnd, LPDATAOBJECT lpDO, REFIID /*riid*/, LPTSTR lpszName ) { m_lbFmtEtc = NULL ; m_edtAdvise = NULL ; m_MetaFile.hMF = NULL ; m_hWndParent = hwnd ; m_lpDO = lpDO ; m_lpszName = lpszName ; m_pSink = NULL ; m_dwConn = 0 ; m_advf = ADVF_PRIMEFIRST ; m_fetc.cfFormat = CF_TEXT ; m_fetc.dwAspect = DVASPECT_CONTENT ; m_fetc.ptd = NULL ; m_fetc.tymed = TYMED_HGLOBAL ; m_fetc.lindex = - 1 ; m_fDoOnGetDataPosted = FALSE ; m_cchOutput = 0 ; m_cLinesOutput = 0 ; } CIDataObjectDlg::~CIDataObjectDlg() { if (m_MetaFile.hMF != NULL) DeleteMetaFile( m_MetaFile.hMF ) ; } int CIDataObjectDlg::DoModal( void ) { if (-1 == DialogBoxParam( GetModuleHandle(_T("IVIEWERS.DLL")), MAKEINTRESOURCE( IDD_IDATAOBJDLG ), m_hWndParent, (DLGPROC)fnIDataObjectDlg, (LONG)this )) { DWORD dw = GetLastError() ; ErrorMessage( "Could not open dialog box", dw ) ; return -1 ; } else return 0 ; } extern "C" BOOL EXPORT CALLBACK fnIDataObjectDlg( HWND hDlg, UINT uiMsg, WPARAM wParam, LPARAM lParam ) { CIDataObjectDlg * pIDOD =(CIDataObjectDlg *)GetWindowLong( hDlg, DWL_USER ) ; switch (uiMsg) { case WM_INITDIALOG: pIDOD=(CIDataObjectDlg *)lParam ; if (pIDOD==NULL) { EndDialog( hDlg, 0 ) ; return TRUE ; } SetWindowLong( hDlg, DWL_USER, (LONG)pIDOD ) ; pIDOD->m_hDlg = hDlg ; return pIDOD->OnInitDialog() ; break ; case WM_DESTROY: if (pIDOD) pIDOD->OnDestroy() ; break ; case WM_SIZE: if (pIDOD) pIDOD->OnSize( (UINT)wParam, LOWORD( lParam ), HIWORD( lParam ) ) ; break ; case WM_COMMAND: { WORD wNotifyCode = HIWORD(wParam); WORD wID = LOWORD(wParam); HWND hwndCtl = (HWND) lParam; switch (wID) { case IDCANCEL: EndDialog( hDlg, IDCANCEL ) ; break ; case IDC_DOGETDATA: pIDOD->OnDoGetData() ; break ; case IDC_SETUPADVISE: if (pIDOD->m_dwConn != 0) pIDOD->OnKillAdvise() ; else pIDOD->OnSetupAdvise() ; break ; case IDC_CLEAROUTPUT: if (pIDOD) { pIDOD->m_cchOutput = 0 ; pIDOD->m_cLinesOutput = 0 ; if (pIDOD->m_MetaFile.hMF != NULL) { DeleteMetaFile( pIDOD->m_MetaFile.hMF ) ; pIDOD->m_MetaFile.hMF = NULL ; } SetWindowText( pIDOD->m_edtAdvise, _T("") ) ; InvalidateRect( pIDOD->m_edtAdvise, NULL, TRUE ) ; UpdateWindow( pIDOD->m_edtAdvise ) ; } break ; case IDC_FORMATETC: if (wNotifyCode == LBN_SELCHANGE) pIDOD->OnSelChangeFormatEtc() ; break ; case IDC_UPDATEDISPLAY: pIDOD->m_fUpdateDisplay = Button_GetCheck( pIDOD->m_chkUpdateDisplay ) ; break ; case IDC_PRIMEFIRST: if (Button_GetCheck( pIDOD->m_chkPrimeFirst )) pIDOD->m_advf = ADVF_PRIMEFIRST ; else pIDOD->m_advf = ADVF_NODATA ; break ; case IDC_ADVISEDATA: if (wNotifyCode == EN_ERRSPACE) { #ifdef _DEBUG OutputDebugString(_T("Output Edit Control reports EN_ERRSPACE\r\n")) ; #endif } break ; } } break ; case WM_DRAWITEM: if (pIDOD) pIDOD->OnDrawItem( wParam, (LPDRAWITEMSTRUCT)lParam ) ; break ; case WM_MEASUREITEM: if (pIDOD) pIDOD->OnMeasureItem( wParam, (LPMEASUREITEMSTRUCT)lParam ) ; break ; case WM_OUTPUTBUFFERHASDATA: if (pIDOD) pIDOD->OnOutputBufferHasData() ; break ; default: return FALSE ; } return TRUE ; } ///////////////////////////////////////////////////////////////////////////// // CIDataObjectDlg message handlers BOOL CIDataObjectDlg::OnInitDialog() { m_btnDoGetData = GetDlgItem( m_hDlg, IDC_DOGETDATA ) ; m_btnSetupAdvise = GetDlgItem( m_hDlg, IDC_SETUPADVISE ) ; m_lbGetData = GetDlgItem( m_hDlg, IDC_GETDATA ) ; m_lbFmtEtc = GetDlgItem( m_hDlg, IDC_FORMATETC ) ; m_edtAdvise = GetDlgItem( m_hDlg, IDC_ADVISEDATA ) ; // Sublcass the edit so we can override it's WM_PAINT and // draw a metafile if we want to... if (g_pfnEdit == NULL) g_pfnEdit = SubclassWindow( m_edtAdvise, fnEditSubclass) ; m_chkUpdateDisplay = GetDlgItem( m_hDlg, IDC_UPDATEDISPLAY ); m_fUpdateDisplay = TRUE ; Button_SetCheck( m_chkUpdateDisplay, m_fUpdateDisplay ) ; m_chkPrimeFirst = GetDlgItem( m_hDlg, IDC_PRIMEFIRST ); Button_SetCheck( m_chkPrimeFirst, m_advf == ADVF_PRIMEFIRST ) ; //m_chkDump = GetDlgItem( m_hDlg, IDC_DUMPTOFILE ) ; //EnableWindow( m_chkDump, FALSE ) ; TEXTMETRIC tm ; HDC hdc = GetDC(NULL); g_hFont = CreateFont( -8, 0, 0, 0, 0, 0, 0, 0, ANSI_CHARSET, 0, 0, 0, FF_SWISS, _T("MS Sans Serif") ) ; g_hFontBold = CreateFont( -8, 0, 0, 0, 0, FW_BOLD, 0, 0, ANSI_CHARSET, 0, 0, 0, FF_SWISS, _T("MS Sans Serif") ) ; HFONT hFont = (HFONT)SelectObject( hdc, g_hFont ) ; GetTextMetrics( hdc, &tm ) ; SelectObject( hdc, hFont ) ; ReleaseDC( NULL, hdc ) ; g_cyFont = tm.tmHeight + tm.tmExternalLeading ; SetWindowFont( m_lbFmtEtc, g_hFont, TRUE ) ; SetWindowFont( m_lbGetData, g_hFont, TRUE ) ; SetWindowFont( m_edtAdvise, g_hFont, TRUE ) ; DoIDataObject( 0, (LPDATAOBJECT)m_lpDO ) ; DlgCenter( m_hDlg, m_hWndParent, FALSE ) ; RECT rc ; GetWindowRect( m_hDlg, &rc ) ; SetWindowPos( m_hDlg, NULL, rc.left, rc.top, rc.right - rc.left + 1, rc.bottom - rc.top +1, SWP_NOMOVE|SWP_NOZORDER | SWP_NOACTIVATE ) ; //SetWindowText( m_hDlg, m_lpszName ) ; return TRUE; // return TRUE unless you set the focus to a control } void CIDataObjectDlg::OnDestroy() { OnKillAdvise() ; if (g_pfnEdit != NULL && m_edtAdvise && IsWindow(m_edtAdvise)) { SubclassWindow(m_edtAdvise, g_pfnEdit) ; g_pfnEdit = NULL ; } int c = ListBox_GetCount( m_lbFmtEtc ) ; for (int i = 0 ; i < c ; i++) { LPITEMDATA lpID = (LPITEMDATA)ListBox_GetItemData( m_lbFmtEtc, i ) ; if (lpID) { if (lpID->uiType == I_COLUMNHEAD) delete lpID->rgCol ; if (lpID->lpData != NULL) delete (LPFORMATETC)lpID->lpData ; delete lpID ; } } if (g_hFont) DeleteObject( g_hFont ); if (g_hFontBold) DeleteObject (g_hFontBold) ; } void CIDataObjectDlg::OnSize(UINT, int cx, int cy) { if (m_edtAdvise && !IsWindow( m_edtAdvise ) ) return ; RECT rc ; RECT rcWnd ; GetClientRect( m_hDlg, &rcWnd ) ; GetWindowRect( m_edtAdvise, &rc ) ; MapWindowPoints( NULL, m_hDlg, (POINT *)&rc, 2 ) ; SetWindowPos( m_edtAdvise, NULL, -1, rc.top, cx+2, cy - rc.top + 1, SWP_NOZORDER | SWP_NOACTIVATE ) ; } void CIDataObjectDlg::OnDrawItem(int, LPDRAWITEMSTRUCT lpDIS ) { if (lpDIS->itemID == LB_ERR) return ; LPITEMDATA lpID ; COLORREF rgbBack ; RECT rcFocus ; BOOL fSelected ; int x, y, cy ; TCHAR szItem[128] ; HFONT hFont ; lpID = (LPITEMDATA)lpDIS->itemData ; rcFocus = lpDIS->rcItem ; ListBox_GetText( m_lbFmtEtc, lpDIS->itemID, szItem ) ; fSelected = (lpDIS->itemState & ODS_SELECTED) ? TRUE : FALSE; if (fSelected) { SetTextColor( lpDIS->hDC, GetSysColor( COLOR_HIGHLIGHTTEXT ) ) ; SetBkColor( lpDIS->hDC, rgbBack = GetSysColor( COLOR_HIGHLIGHT ) ) ; } else { SetTextColor( lpDIS->hDC, GetSysColor( COLOR_WINDOWTEXT ) ) ; SetBkColor( lpDIS->hDC, rgbBack = GetSysColor( COLOR_WINDOW ) ) ; } // if we are loosing focus, remove the focus rect before // drawing. // if ((lpDIS->itemAction) & (ODA_FOCUS)) if (!((lpDIS->itemState) & (ODS_FOCUS))) DrawFocusRect( lpDIS->hDC, &rcFocus ) ; y = lpDIS->rcItem.top ; x = lpDIS->rcItem.left ; int cxChar = GetTextMetricsCorrectly( lpDIS->hDC, NULL ) ; if (lpID && (lpID->uiType == I_COLUMNHEAD || lpID->uiType == I_LABEL)) hFont = (HFONT)SelectObject( lpDIS->hDC, g_hFontBold ) ; cy = (rcFocus.bottom - rcFocus.top - g_cyFont) / 2 ; ExtTextOut( lpDIS->hDC, x+2, y + cy, ETO_OPAQUE, &lpDIS->rcItem, NULL, 0, NULL ) ; if (lpID) ColumnTextOut( lpDIS->hDC, x + 2 + ((cxChar*3) * lpID->nLevel), y + cy, szItem, lpID->cColumns, lpID->rgCol ) ; if (lpID && lpID->uiType == I_COLUMNHEAD ) { COLORREF rgb ; RECT rc = rcFocus ; rgb = SetBkColor( lpDIS->hDC, GetTextColor( lpDIS->hDC ) ) ; rc.top = rc.bottom - 1 ; rc.left = x + 2 + ((cxChar*3) * lpID->nLevel) ; ExtTextOut( lpDIS->hDC, 0, 0, ETO_OPAQUE, &rc, NULL, 0, NULL ) ; SetBkColor( lpDIS->hDC, rgb ) ; } if (lpID && (lpID->uiType == I_COLUMNHEAD || lpID->uiType == I_LABEL)) (HFONT)SelectObject( lpDIS->hDC, hFont ) ; // if we are gaining focus draw the focus rect after drawing // the text. if ((lpDIS->itemAction) & (ODA_FOCUS)) if ((lpDIS->itemState) & (ODS_FOCUS)) DrawFocusRect( lpDIS->hDC, &rcFocus ) ; if (fSelected) { SetTextColor( lpDIS->hDC, GetSysColor( COLOR_WINDOWTEXT ) ) ; SetBkColor( lpDIS->hDC, GetSysColor( COLOR_WINDOW ) ) ; } } void CIDataObjectDlg::OnMeasureItem(int, LPMEASUREITEMSTRUCT lpMeasureItemStruct) { lpMeasureItemStruct->itemHeight = g_cyFont ; } void CIDataObjectDlg::OnDblClkFormatEtc() { } void CIDataObjectDlg::OnSelChangeFormatEtc() { if (m_MetaFile.hMF != NULL) { DeleteMetaFile( m_MetaFile.hMF ) ; m_MetaFile.hMF = NULL ; } InvalidateRect( m_edtAdvise, NULL, TRUE ) ; SetWindowText( m_edtAdvise, _T("") ) ; int i = ListBox_GetCurSel( m_lbFmtEtc ) ; if (i != LB_ERR) { LPITEMDATA lpid = (LPITEMDATA)ListBox_GetItemData( m_lbFmtEtc, i ) ; if (lpid && lpid->lpData) { m_fetc = *(LPFORMATETC)lpid->lpData ; return ; } } m_fetc.cfFormat = CF_TEXT ; m_fetc.dwAspect = DVASPECT_CONTENT ; m_fetc.ptd = NULL ; m_fetc.tymed = TYMED_HGLOBAL ; m_fetc.lindex = - 1 ; } void CIDataObjectDlg::OnDoGetData() { HRESULT hr ; STGMEDIUM stm ; TCHAR szBuf[256] ; if (m_lpDO == NULL) { ListBox_AddString( m_lbGetData, _T( "IDataObject viewer internal error: m_lpDO == NULL" ) ) ; return ; } wsprintf( szBuf, _T( "Calling GetData for %s" ), (LPCTSTR)MyGetClipboardFormatName( m_fetc.cfFormat ) ) ; ListBox_AddString( m_lbGetData, szBuf ) ; hr = m_lpDO->QueryGetData( &m_fetc ) ; if (FAILED( hr )) { wsprintf( szBuf, _T( "QueryGetData() failed: %s" ), (LPTSTR)HRtoString( hr ) ) ; ListBox_AddString( m_lbGetData, szBuf ) ; return ; } stm.tymed = m_fetc.tymed ; hr = m_lpDO->GetData( &m_fetc, &stm ) ; if (FAILED( hr )) { wsprintf( szBuf, _T( "GetData() failed: %s" ), (LPTSTR)HRtoString( hr ) ) ; ListBox_AddString( m_lbGetData, szBuf ) ; return ; } if (FAILED( hr = GotData( &m_fetc, &stm ) )) { wsprintf( szBuf, _T( "IDataDlg::GotData() failed: %s" ), (LPTSTR)HRtoString( hr ) ) ; ListBox_AddString( m_lbGetData, szBuf ) ; return ; } // If we're warm linked, then don't let the queue overfill. Allow only one // message at a time. This is similar to the way Excel handles it's DDE Links. // m_fDoOnGetDataPosted = FALSE ; } HRESULT CIDataObjectDlg::GotData( LPFORMATETC lpfetc, LPSTGMEDIUM lpstm ) { HRESULT hr = NOERROR ; BOOL fHandled = FALSE ; if ((lpfetc->cfFormat == CF_TEXT || lpfetc->cfFormat == CF_UNICODETEXT) && lpstm->tymed & TYMED_HGLOBAL) { LPTSTR lpsz = (LPTSTR)GlobalLock( lpstm->hGlobal ) ; if (lpsz == NULL) { ListBox_AddString( m_lbGetData, _T( "hGlobal returned by GetData is NULL!" ) ) ; ReleaseStgMedium( lpstm ); return ResultFromScode( E_FAIL ) ; } if (m_fUpdateDisplay == TRUE) { #ifndef _UNICODE if (lpfetc->cfFormat == CF_UNICODETEXT) { UINT n = wcslen( (LPWSTR)lpsz ) ; TCHAR* sztemp = new TCHAR[n+1] ; wcstombs( sztemp, (LPWSTR)lpsz, n ) ; WriteToOutput( sztemp ) ; delete [] sztemp ; } else WriteToOutput( lpsz ) ; #else if (lpfetc->cfFormat == CF_TEXT) { UINT n = _mbstrlen( (LPCSTR)lpsz ) ; TCHAR* sztemp = new TCHAR[n+1] ; mbstowcs( sztemp, (LPSTR)lpsz, n ) ; WriteToOutput( sztemp ) ; delete [] sztemp ; } else WriteToOutput( lpsz ) ; #endif } GlobalUnlock( lpstm->hGlobal ) ; fHandled = TRUE ; } if (lpfetc->cfFormat == CF_METAFILEPICT && lpstm->tymed & TYMED_MFPICT) { LPMETAFILEPICT pMF = (LPMETAFILEPICT)GlobalLock(lpstm->hGlobal) ; if (pMF) { if (m_MetaFile.hMF) { DeleteMetaFile( m_MetaFile.hMF ) ; m_MetaFile.hMF = NULL ; } if (m_fUpdateDisplay) { m_MetaFile = *pMF ; m_MetaFile.hMF = CopyMetaFile( pMF->hMF, NULL ) ; InvalidateRect( m_edtAdvise, NULL, FALSE ) ; } } fHandled = TRUE ; } m_cOnDataChanges++ ; ReleaseStgMedium( lpstm ); if (fHandled == FALSE) { ListBox_AddString( m_lbGetData, _T( "The IDataObject viewer does not know how to decode this FORMATETC" ) ) ; } return hr; } void CIDataObjectDlg::OnSetupAdvise() { TCHAR szBuf[128] ; OnKillAdvise() ; m_pSink = new CImpIAdviseSink( this ) ; if (m_pSink == NULL) { ListBox_AddString( m_lbGetData, _T( "CImpIAdviseSink constructor failed" ) ) ; return ; } SetWindowText( m_btnSetupAdvise, _T( "&Kill Advise" ) ) ; wsprintf( szBuf, _T( "Advise started with a cfFormat of %s" ), (LPCTSTR)MyGetClipboardFormatName( m_fetc.cfFormat ) ) ; ListBox_AddString( m_lbGetData, szBuf ) ; m_dwTime = GetTickCount() ; m_cOnDataChanges = 0 ; HRESULT hr = m_lpDO->DAdvise( &m_fetc, m_advf, m_pSink, &m_dwConn ) ; if (FAILED( hr )) { wsprintf( szBuf, _T( "DAdvise() failed: %s" ), (LPTSTR)HRtoString( hr ) ) ; ListBox_AddString( m_lbGetData, szBuf ) ; SetWindowText( m_btnSetupAdvise, _T( "&DAdvise" ) ) ; return ; } } void CIDataObjectDlg::OnKillAdvise() { if (m_dwConn != 0) { TCHAR szBuf[128] ; DWORD dwTime = max( 1000, GetTickCount() - m_dwTime ) ; // avoid div by zero m_lpDO->DUnadvise( m_dwConn ) ; m_dwConn = 0 ; wsprintf( szBuf, _T( " Advise Killed after %lu milliseconds, and %lu OnDataChanges;" ), dwTime, m_cOnDataChanges ) ; ListBox_AddString( m_lbGetData, szBuf ) ; wsprintf( szBuf, _T( " That's %lu.%lu OnDataChange calls per second." ), m_cOnDataChanges / (dwTime / 1000L), m_cOnDataChanges % (dwTime / 1000L) ) ; ListBox_AddString( m_lbGetData, szBuf ) ; } if (m_pSink != NULL) { m_pSink->Release() ; m_pSink = NULL ; } SetWindowText( m_btnSetupAdvise, _T( "&DAdvise" ) ) ; } // DoIDataObject // // This is where we start doing IDataObject dirty work. // This function calls pIDataObject->EnumFormatEtc twice, once // each for DATADIR_GET and DATADIR_SET, to get a pIEnumFORMATETC. // // We then call DoIEnumFormatEtc() with this pointer to actually // perform the enumaration. // BOOL CIDataObjectDlg::DoIDataObject( UINT nLevel, LPDATAOBJECT pIDataObject ) { LPENUMFORMATETC pEFE = NULL ; HRESULT hr1 ; hr1 = pIDataObject->EnumFormatEtc( DATADIR_GET, &pEFE ) ; if (SUCCEEDED( hr1 )) { if (pEFE == NULL) { AfxMessageBox(_T("IDataObject::EnumFormatEtc returned success, but returned IEnumFORMATETC pointer is NULL.")) ; AddItem( nLevel, _T( "<<DATA_DIRGET failed>>" ), NULL, I_LABEL ) ; return FALSE ; } DoIEnumFormatEtc( nLevel, pEFE ) ; pEFE->Release() ; } else AddItem( nLevel, _T( "<<DATA_DIRGET failed>>" ), NULL, I_LABEL ) ; if (SUCCEEDED(hr1)) { ListBox_SetCurSel( m_lbFmtEtc, 0 ) ; OnSelChangeFormatEtc() ; } return TRUE ; } // This member takes a pointer to an IEnumFORMATETC and enumerates // the FORMATETC structures avaialbe, inserting them into our // listbox. // BOOL CIDataObjectDlg::DoIEnumFormatEtc( UINT nLevel, LPENUMFORMATETC pIFormatEtc ) { LPCOLUMNSTRUCT rgCol = new COLUMNSTRUCT[5] ; UINT cxChar ; HDC hdc = GetDC( NULL) ; // We use the "ColumnTextOut" code in util.c to create nice // columns in our list box. // HFONT hFont = (HFONT)SelectObject( hdc, g_hFontBold ) ; cxChar = GetTextMetricsCorrectly( hdc, NULL ) ; rgCol[0].nLeft = 0 ; rgCol[0].nRight = cxChar * lstrlen( _T( "CF_METAFILEPICT_" ) ) ; rgCol[0].uiFlags = DT_LEFT ; rgCol[1].nLeft = rgCol[0].nRight + cxChar ; rgCol[1].nRight = rgCol[1].nLeft + cxChar * lstrlen( _T( "0000:0000_" ) ) ; rgCol[1].uiFlags = DT_LEFT ; rgCol[2].nLeft = rgCol[1].nRight + cxChar ; rgCol[2].nRight = rgCol[2].nLeft + cxChar * lstrlen( _T( "THUMBNAIL_" ) ) ; rgCol[2].uiFlags = DT_LEFT ; rgCol[3].nLeft = rgCol[2].nRight + cxChar ; rgCol[3].nRight = rgCol[3].nLeft + cxChar * lstrlen( _T( "0000:0000_" ) ) ; rgCol[3].uiFlags = DT_LEFT ; rgCol[4].nLeft = rgCol[3].nRight + cxChar ; rgCol[4].nRight = rgCol[4].nLeft + cxChar * lstrlen( _T( "_HGLOBAL_" ) ) ; rgCol[4].uiFlags = DT_LEFT ; (HFONT)SelectObject( hdc, hFont ) ; ReleaseDC( NULL, hdc ) ; AddItem( nLevel, _T( "cfFormat\tptd\tdwAspect\tlindex\ttymed" ), NULL, I_COLUMNHEAD, 5, rgCol ) ; LPFORMATETC pfetc ; FORMATETC fetc ; TCHAR sz[512] ; ULONG ulFE ; // number returned while (pIFormatEtc->Next( 1, &fetc, &ulFE ) == S_OK) { // now insert into list pfetc = new FORMATETC ; *pfetc = fetc ; lstrcpy( sz, MyGetClipboardFormatName( (UINT)fetc.cfFormat ) ) ; lstrcat( sz, _T("\t") ) ; TCHAR szTemp[32] ; wsprintf( szTemp, _T( "%04lX:%04lX\t" ), (DWORD)HIWORD( (DWORD)fetc.ptd ), (DWORD)LOWORD( (DWORD)fetc.ptd ) ) ; lstrcat( sz, szTemp ) ; switch( fetc.dwAspect ) { case DVASPECT_CONTENT: lstrcat( sz, _T( "CONTENT\t" ) ) ; break ; case DVASPECT_THUMBNAIL: lstrcat( sz, _T( "THUMBNAIL\t" ) ) ; break ; case DVASPECT_ICON: lstrcat( sz, _T( "ICON\t" ) ) ; break ; case DVASPECT_DOCPRINT: lstrcat( sz, _T( "DOCPRINT\t" ) ) ; break ; default: wsprintf( szTemp, _T( "%08lX\t" ), (DWORD)fetc.dwAspect ) ; lstrcat( sz, szTemp ) ; break ; } wsprintf( szTemp, _T( "%04lX:%04lX\t" ), (DWORD)HIWORD( fetc.lindex ), (DWORD)LOWORD( fetc.lindex ) ) ; lstrcat( sz, szTemp ) ; switch( fetc.tymed ) { case TYMED_HGLOBAL: lstrcat( sz, _T( "HGLOBAL\t" ) ) ; break ; case TYMED_FILE: lstrcat( sz, _T( "FILE\t" ) ) ; break ; case TYMED_ISTREAM: lstrcat( sz, _T( "ISTREAM\t" ) ) ; break ; case TYMED_ISTORAGE: lstrcat( sz, _T( "ISTORAGE\t" ) ) ; break ; case TYMED_GDI: lstrcat( sz, _T( "GDI\t" ) ) ; break ; case TYMED_MFPICT: lstrcat( sz, _T( "MFPICT\t" ) ) ; break ; case TYMED_NULL: lstrcat( sz, _T( "NULL\t" ) ) ; break ; default: wsprintf( szTemp, _T( "%08lX\t" ), (DWORD)fetc.tymed ) ; lstrcat( sz, szTemp ) ; break ; } AddItem( nLevel, sz, pfetc, I_COLUMNENTRY, 5, rgCol ) ; } return TRUE ; } LPCTSTR MyGetClipboardFormatName( UINT cf ) { static TCHAR sz[256] ; switch( cf ) { case CF_UNICODETEXT: lstrcpy( sz, _T( "CF_UNICODETEXT" ) ) ; break ; case CF_ENHMETAFILE: lstrcpy( sz, _T( "CF_ENHMETAFILE" ) ) ; break ; case CF_TEXT: lstrcpy( sz, _T( "CF_TEXT" ) ) ; break ; case CF_BITMAP: lstrcpy( sz, _T( "CF_BITMAP" ) ) ; break ; case CF_METAFILEPICT: lstrcpy( sz, _T( "CF_METAFILEPICT" ) ) ; break ; case CF_SYLK: lstrcpy( sz, _T( "CF_SYLK" ) ) ; break ; case CF_DIF: lstrcpy( sz, _T( "CF_DIF" ) ) ; break ; case CF_TIFF: lstrcpy( sz, _T( "CF_TIFF" ) ) ; break ; case CF_OEMTEXT: lstrcpy( sz, _T( "CF_OEMTEXT" ) ) ; break ; case CF_DIB: lstrcpy( sz, _T( "CF_DIB" ) ) ; break ; case CF_PALETTE: lstrcpy( sz, _T( "CF_PALETTE" ) ) ; break ; case CF_PENDATA: lstrcpy( sz, _T( "CF_PENDATA" ) ) ; break ; case CF_RIFF: lstrcpy( sz, _T( "CF_RIFF" ) ) ; break ; case CF_WAVE: lstrcpy( sz, _T( "CF_WAVE" ) ) ; break ; case 0: lstrcpy( sz, _T( "\"Wildcard Advise\"" ) ) ; break ; default: if (!GetClipboardFormatName( (UINT)cf, sz, 254 )) wsprintf( sz, _T( "%#08lX" ), (DWORD)cf ) ; break ; } return sz ; } UINT DBStrCpy(LPTSTR pszDst, LPCTSTR pszSrc, int far* pcLines) ; BOOL CIDataObjectDlg::WriteToOutput( LPTSTR lpsz ) { UINT cch; int cLines; cch = DBStrCpy(NULL, lpsz, &cLines); if (cch > (CCHOUTPUTMAX - m_cchOutput)) { MessageBeep(0); return FALSE; } DBStrCpy(&m_szOutput[m_cchOutput], lpsz, NULL); m_cchOutput += cch; m_cLinesOutput += cLines; // If buffer was originally empty, wake up the main loop. // if (m_cchOutput == cch) PostMessage( m_hDlg, WM_OUTPUTBUFFERHASDATA, 0, 0L); return TRUE; } // This function performs a string copy (or string length if pszDst is NULL) // It also ensures the destination string is properly formatted for the // edit controls: line terminators must be CR followed by LF, in that orderc. // If pcLines != NULL, returns number of lines in the string in *pcLines // // (pulled from the dbwin sample) // UINT DBStrCpy(LPTSTR pszDst, LPCTSTR pszSrc, int far* pcLines) { TCHAR ch; UINT cch = 0; int cLines = 0; while ('\0' != (ch = *pszSrc++)) { // If we find a CR or LF, then store a CR/LF in // the output string. // if (ch == 0x0d || ch == 0x0a) { cch += 2; cLines++; if (pszDst) { *pszDst++ = 0x0d; *pszDst++ = 0x0a; } // Skip any other CRs or LFs we find. // while (('\0' != (ch = *pszSrc)) && (ch == 0x0d || ch == 0x0a)) ++pszSrc; } else { cch++; if (pszDst) *pszDst++ = ch; } } if (pszDst) *pszDst = 0; if (pcLines) *pcLines = cLines; return cch; } // Whenever something happens that causes output, it calls the WriteToOutput function // which puts the data into a buffer (m_szOutput) and posts a message. This is // the message handler. // void CIDataObjectDlg::OnOutputBufferHasData() { if (m_szOutput != NULL && m_cchOutput != 0) { int cLines = Edit_GetLineCount(m_edtAdvise) + m_cLinesOutput ; if (cLines > CLINESMAX) { SetWindowRedraw( m_edtAdvise, FALSE ) ; // If the total # of lines is greater than our arbitrary max lines // remove some from the top. // Edit_SetSel( m_edtAdvise, 0, Edit_LineIndex( m_edtAdvise, cLines - CLINESMAX)); Edit_ReplaceSel( m_edtAdvise, _T("")); } // Put current output buffer at the end of the edit control // Edit_SetSel( m_edtAdvise, (UINT)-1, (UINT)-1 ) ; // select the end Edit_ReplaceSel( m_edtAdvise, m_szOutput ) ; Edit_SetSel( m_edtAdvise, (UINT)-1, (UINT)-1 ) ; // select the end if (cLines > CLINESMAX) SetWindowRedraw( m_edtAdvise, TRUE ) ; // Reset the output buffer m_cLinesOutput = 0 ; m_cchOutput = 0 ; } } // AddItem does a ListBox_AddString() plus a ListBox_SetItemData(). The // item data that is set tells our owner-draw code what 'level' this // item is at (indentation) and whether it is a label (bold), column // head (column info is stored), or column entry (no column info is // stored, but previous column head is used in WM_DRAWITEM). // int CIDataObjectDlg::AddItem( UINT nLevel, LPTSTR sz, LPVOID lpData, UINT uiType, int cColumns, LPCOLUMNSTRUCT rgCol ) { int i ; LPITEMDATA lpID ; i = ListBox_AddString( m_lbFmtEtc, sz ) ; lpID = new ITEMDATA ; lpID->uiType = uiType ; lpID->cColumns = cColumns ; lpID->rgCol = rgCol ; lpID->nLevel = nLevel ; lpID->lpData = lpData ; ListBox_SetItemData( m_lbFmtEtc, i, (DWORD)lpID ) ; return i ; } int CIDataObjectDlg::AddItem( UINT nLevel, LPTSTR sz, LPVOID lpData, UINT uiType ) { return AddItem( nLevel, sz, lpData, uiType, 0, NULL ) ; } int CIDataObjectDlg::AddItem( UINT nLevel, LPTSTR sz, LPVOID lpData ) { return AddItem( nLevel, sz, lpData, I_NORMAL, 0, NULL ) ; } extern "C" LRESULT EXPORT CALLBACK fnEditSubclass( HWND hwnd, UINT uiMsg, WPARAM wP, LPARAM lP ) { if (uiMsg == WM_PAINT) { HWND hwndParent = GetParent(hwnd) ; CIDataObjectDlg * pIDOD =(CIDataObjectDlg *)GetWindowLong( hwndParent, DWL_USER ) ; if (pIDOD && pIDOD->m_MetaFile.hMF != NULL) { PAINTSTRUCT ps ; BeginPaint( hwnd, &ps ) ; /* if (pIDOD->m_MetaFile.mm == MM_ISOTROPIC || pIDOD->m_MetaFile.mm == MM_ANISOTROPIC) { if (pIDOD->m_MetaFile.xExt != 0 && pIDOD->m_MetaFile.yExt != 0) { } } else { SetMapMode( ps.hdc, MM_ANISOTROPIC ) ; SetWindowOrg( ps.hdc, 0, 0 ) ; SetWindowExt( ps.hdc, pIDOD->m_MetaFile.xExt, pIDOD->m_MetaFile.yExt ) ; SetViewportExt( ps.hdc, pIDOD->m_MetaFile.xExt, pIDOD->m_MetaFile.yExt ) ; } */ PlayMetaFile( ps.hdc, pIDOD->m_MetaFile.hMF ) ; EndPaint( hwnd, &ps ) ; return 0L ; } } return CallWindowProc( g_pfnEdit, hwnd, uiMsg, wP, lP ) ; } /**************************************************************** * * Description: * * The ColumntTextOut function writes a character string at * the specified location, using tabs to identify column breaks. Each * column is aligned according to the array of COLUMNSTRUCTs. * * A COLUMNSTRUCT looks like this: * * { * int nLeft ; // starting x position of the column * int nRight ; // ending x position of the column * UINT uiFlags ; // format flags * } * * If a column has another column to the left of it, it's nLeft member * is ignored. * * uiFlags can be any of the following: * * #define DT_LEFT 0x0000 * #define DT_CENTER 0x0001 * #define DT_RIGHT 0x0002 * * Comments: * ****************************************************************/ void WINAPI ColumnTextOut( HDC hdc, int nX, int nY, LPTSTR lpszIN, int cColumns, LPCOLUMNSTRUCT rgColumns ) { #define ETOFLAGS ETO_CLIPPED COLUMNSTRUCT CS ; // local copy for speed RECT rc ; // current cell rect int cIteration = 0 ; // what column LPTSTR lpNext ; // next string (current is lpsz) int cch ; // count of chars in current string SIZE size ; // extent of current string int dx ; // column width rc.left = nX ; rc.top = nY ; rc.right = 0 ; if (rgColumns == NULL || cColumns <= 1) { int Tab = 15 ; TabbedTextOut( hdc, nX, nY, lpszIN, lstrlen(lpszIN), 1, &Tab, nX ) ; return ; } // For each sub string (bracketed by a tab) // LPTSTR lpsz = lpszIN ; while (*lpsz) { if (cIteration >= cColumns) return ; for (cch = 0, lpNext = lpsz ; *lpNext != _T('\t') && *lpNext ; lpNext++, cch++) ; CS = rgColumns[cIteration] ; // If it's the leftmost column use // if (cIteration == 0) { rc.left = nX + CS.nLeft ; rc.right = nX + CS.nRight ; } else rc.right = nX + CS.nRight ; GetTextExtentPoint( hdc, lpsz, cch, &size ) ; rc.bottom = rc.top + size.cy ; // If the width of the column is 0 do nothing // if ((dx = (rc.right - rc.left)) > 0) { switch(CS.uiFlags) { case DT_CENTER: ExtTextOut( hdc, rc.left + ((dx - size.cx) / (int)2), rc.top, ETOFLAGS, &rc, lpsz, cch, NULL ) ; break ; case DT_RIGHT: // If it's right justified then make the left border 0 // //rc.left = nX + rgColumns[0].nLeft ; ExtTextOut( hdc, rc.left + (dx - size.cx), rc.top, ETOFLAGS, &rc, lpsz, cch, NULL ) ; break ; case DT_LEFT: default: ExtTextOut( hdc, rc.left, rc.top, ETOFLAGS, &rc, lpsz, cch, NULL ) ; break ; } } rc.left = rc.right ; cIteration++ ; lpsz = lpNext + 1 ; } } // ColumnTextOut() /************************************************************************* * void WINAPI * DlgCenter( HWND hwndCenter, HWND hwndWithin, BOOL fClient ) * * Description: * * Centers a window within another window. * * Type/Parameter * Description * * HWND hwndCenter * Window to center. This does not have to be a child of * hwndWithin. * * HWND hwndWithin * Window to center the above window within. Can be NULL. * * BOOL fClient * If TRUE the window is centered within the available client * area. Otherwise it's centered within the entire window area. * * Comments: * *************************************************************************/ void WINAPI DlgCenter( HWND hwndCenter, HWND hwndWithin, BOOL fClient ) { RECT rcWithin ; RECT rcCenter ; int x, y ; int dxCenter, dyCenter ; int dxScreen, dyScreen ; dxScreen = GetSystemMetrics( SM_CXSCREEN ) ; dyScreen = GetSystemMetrics( SM_CYSCREEN ) ; if (!IsWindow(hwndCenter)) return ; if (hwndWithin && !IsWindow(hwndWithin)) return ; if (hwndWithin == NULL) { rcWithin.left = rcWithin.top = 0 ; rcWithin.right = dxScreen ; rcWithin.bottom = dyScreen ; } else { if (fClient) { /* * First get screen coords of rectangle we're going to be * centered within. */ GetClientRect( hwndWithin, (LPRECT)&rcWithin ) ; ClientToScreen( hwndWithin, (LPPOINT)&rcWithin.left ) ; ClientToScreen( hwndWithin, (LPPOINT)&rcWithin.right ) ; } else GetWindowRect( hwndWithin, (LPRECT)&rcWithin ) ; } GetWindowRect( hwndCenter, (LPRECT)&rcCenter ) ; dxCenter = rcCenter.right - rcCenter.left ; dyCenter = rcCenter.bottom - rcCenter.top ; /* * Now we have both the within and center rects in screen coords. * * SetWindowPos behaves differently for Non child windows * than for child windows. For popups it's coordinates * are relative to the upper left corner of the screen. For * children it's coords are relative to the upper left corner * of the client area of the parent. */ x = ((rcWithin.right - rcWithin.left) - dxCenter) / 2 ; y = ((rcWithin.bottom - rcWithin.top) - dyCenter) / 2 ; if (hwndWithin == GetParent( hwndCenter ) && !(GetWindowLong( hwndCenter, GWL_STYLE ) & WS_CHILD )) { x += rcWithin.left ; y += rcWithin.top ; if (x + dxCenter > dxScreen ) x = dxScreen - dxCenter ; if (y + dyCenter > dyScreen ) y = dyScreen - dyCenter ; SetWindowPos( hwndCenter, NULL, max(x,0), max(y,0), 0, 0, SWP_NOACTIVATE | SWP_NOSIZE | SWP_NOZORDER ) ; return ; } SetWindowPos( hwndCenter, NULL, max(x,0), max(y,0), 0, 0, SWP_NOACTIVATE | SWP_NOSIZE | SWP_NOZORDER ) ; return ; }/* DlgCenter() */ /**************************************************************** * int WINAPI * GetTextMetricsCorrectly( HDC hDC, LPTEXTMETRIC lpTextMetrics ) * * Description: * * This function gets the textmetrics of the font currently * selected into the hDC. It returns the average char width as * the return value. * * This function computes the average character width correctly * by using GetTextExtent() on the string "abc...xzyABC...XYZ" * which works out much better for proportional fonts. * * Note that this function returns the same TEXTMETRIC * values that GetTextMetrics() does, it simply has a different * return value. * * Comments: * ****************************************************************/ int WINAPI GetTextMetricsCorrectly( HDC hDC, LPTEXTMETRIC lpTM ) { int nAveWidth ; TCHAR rgchAlphabet[52] ; int i ; SIZE size ; // Get the TM of the current font. Note that GetTextMetrics // gets the incorrect AveCharWidth value for proportional fonts. // This is the whole poshort in this exercise. // if (lpTM) GetTextMetrics(hDC, lpTM); // If it's not a variable pitch font GetTextMetrics was correct // so just return. // if (lpTM && !(lpTM->tmPitchAndFamily & FIXED_PITCH)) return lpTM->tmAveCharWidth ; else { for ( i = 0 ; i <= 25 ; i++) rgchAlphabet[i] = (TCHAR)(i+(int)'a') ; for ( i = 0 ; i<=25 ; i++) rgchAlphabet[i+25] = (TCHAR)(i+(int)'A') ; GetTextExtentPoint( hDC, (LPTSTR)rgchAlphabet, 52, &size ) ; nAveWidth = size.cx / 26 ; nAveWidth = (nAveWidth + 1) / 2 ; } // Return the calculated average char width // return nAveWidth ; } /* GetTextMetricsCorrectly() */
[ "charlie@kindel.com" ]
charlie@kindel.com
84c56675f7e2412779404f36057941a61a07ab25
75e2a23cd558d485958aeae24c812141c0346642
/include/Canvas.h
05f73755d19dbea8ebcd230f686d9cc51bb116b0
[]
no_license
SoraUmika/SDL_OPENGL
132a19ec9e7656866ca4e8e2a7862bec77478498
9b8207cde53fc4fef2ec26636d81598b557558ec
refs/heads/master
2020-07-01T23:34:53.288634
2019-08-26T18:21:36
2019-08-26T18:21:36
201,344,060
1
0
null
null
null
null
UTF-8
C++
false
false
387
h
#ifndef CANVAS_H_INCLUDED #define CANVAS_H_INCLUDED #include <iostream> #include <SDL.h> #include <Root.h> #include <Utility.h> class Canvas: public Root{ public: void drawGrid(int gridSize, enumColors color=BLACK); void drawRect(SDL_Rect *rect, enumColors Color=GREEN); void drawRectOutline(SDL_Rect *rect, enumColors Color=YELLOW); private: }; #endif
[ "dazzlejohn1212@gmail.com" ]
dazzlejohn1212@gmail.com
de81e58b8c24d8c21df376b4fa033fc6b1df7345
dba3f1868db2cf65a8fbe8f81ec26d35d0745525
/src/include/platform/Platform.hpp
b54ccc7d7ab2d51a080843516769e0cac8b0d023
[]
no_license
e-shrubsall/MScFinalProject
c71ffe382f7d5334ca528341e56ad4cb19c34f51
59dbb1228878e238e959120c1066fd354d9cda24
refs/heads/master
2020-08-02T11:49:00.618536
2019-12-04T12:27:13
2019-12-04T12:27:13
211,340,842
0
0
null
null
null
null
UTF-8
C++
false
false
346
hpp
#ifndef MSCFINALPROJECT_PLATFORM_PLATFORM_HPP #define MSCFINALPROJECT_PLATFORM_PLATFORM_HPP #include <string> namespace Platform { namespace Files { extern const char FILE_SEPARATOR; std::string getResourceFolder(); void createFolder(const std::string& folder); } } #endif//MSCFINALPROJECT_PLATFORM_PLATFORM_HPP
[ "eshrubsall@gmail.com" ]
eshrubsall@gmail.com
4dc0bf35219d6b4eab6e20ea1a8248ccc4a509ea
9d925fdf418d12a07e80ecb670d1a1641e273b1b
/include/stats/seed_values.hpp
77f695dadfe3cfed959dcbd5a9f5480af4332213
[ "Apache-2.0", "GPL-1.0-or-later" ]
permissive
skn123/optim
ee53676a5d969ad8d05afe62343f15075304be13
248a927d6edee185f5fb6931e30051f9f1d2cf9e
refs/heads/master
2023-07-20T19:01:55.074457
2023-07-13T21:29:46
2023-07-13T21:29:46
234,919,688
0
0
Apache-2.0
2023-07-14T06:30:59
2020-01-19T15:15:24
C++
UTF-8
C++
false
false
1,237
hpp
/*################################################################################ ## ## Copyright (C) 2016-2023 Keith O'Hara ## ## This file is part of the OptimLib C++ library. ## ## 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 OPTIMLIB_STATS_SEED_VALUES #define OPTIMLIB_STATS_SEED_VALUES inline size_t generate_seed_value(const int ind_inp, const int n_threads, rand_engine_t& rand_engine) { return static_cast<size_t>( (bmo::stats::runif<fp_t>(rand_engine) + ind_inp + n_threads) * 1000 ); // return static_cast<size_t>( (ind_inp + n_threads) * 1000 ); } #endif
[ "kth.ohr@gmail.com" ]
kth.ohr@gmail.com
9ccb952758b4b6971f0a8e30cb85fe922b0bb39e
2f55116f7ae8d1bd5671380e1395f0f51369127e
/challenge11/reduce.cpp
046dafdd153ed425ecb0e7da2e19c2cbe15a9a64
[]
no_license
ddurks/DataStructures
d5a0310ea79367b342be699c90107ff06ffafd33
823a1f8eeccdb7be2f9f1e3cff13a25d2f507197
refs/heads/master
2020-07-16T09:22:31.920365
2017-10-10T12:55:13
2017-10-10T12:55:13
73,949,303
0
0
null
null
null
null
UTF-8
C++
false
false
753
cpp
// reduce.cpp: inverted index #include <iostream> #include <cstdlib> #include <map> #include <set> using namespace std; int main(int argc, char *argv[]) { map<string, set<int>> words; string word; int lineNum; while(cin >> word){ cin >> lineNum; words[word].insert(lineNum); } for(auto it = words.cbegin(); it != words.cend(); ++it) { cout << it->first << "\t"; int first = true; for(auto it2 = it->second.cbegin(); it2 != it->second.cend(); ++it2){ if(!first){ cout << " "; } cout << *it2; first = false; } cout << endl; } return EXIT_SUCCESS; } // vim: set sts=4 sw=4 ts=8 expandtab ft=cpp:
[ "noreply@github.com" ]
noreply@github.com
035d64ccf73628194f2c4d104ec1dea77f39af86
6869d13095c3d165aec00b1021175b252a28557a
/CLI/linearSubdivision/lib/vtkLinearSubdivisionFilter2.h
b3b161388a15b4ae97174d99efa95d3568cec97a
[]
no_license
juanprietob/ShapeDistanceAnalyzer
9943f14b0c8a30c4ba8a11edfb11ee3ba0553959
7efb397ac0c6c5503284a4ce3e63b7b781e4f720
refs/heads/master
2021-04-18T16:44:55.371604
2018-12-06T15:04:59
2018-12-06T15:04:59
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,939
h
/*========================================================================= Program: Visualization Toolkit Module: vtkLinearSubdivisionFilter2.h Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen All rights reserved. See Copyright.txt or http://www.kitware.com/Copyright.htm for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notice for more information. =========================================================================*/ /** * @class vtkLinearSubdivisionFilter2 * @brief generate a subdivision surface using the Linear Scheme * * vtkLinearSubdivisionFilter2 is a filter that generates output by * subdividing its input polydata. Each subdivision iteration create 4 * new triangles for each triangle in the polydata. * * @par Thanks: * This work was supported by PHS Research Grant No. 1 P41 RR13218-01 * from the National Center for Research Resources. * * @sa * vtkInterpolatingSubdivisionFilter vtkButterflySubdivisionFilter */ #ifndef vtkLinearSubdivisionFilter2_h #define vtkLinearSubdivisionFilter2_h #include "vtkFiltersModelingModule.h" // For export macro #include "vtkInterpolatingSubdivisionFilter.h" #include "vtkInformation.h" #include "vtkInformationVector.h" #include <map> class vtkIntArray; class vtkPointData; class vtkPoints; class vtkPolyData; class vtkCellArray; class vtkCellData; class vtkIdList; class VTKFILTERSMODELING_EXPORT vtkLinearSubdivisionFilter2 : public vtkInterpolatingSubdivisionFilter { public: //@{ /** * Construct object with NumberOfSubdivisions set to 1. */ static vtkLinearSubdivisionFilter2 *New(); vtkTypeMacro(vtkLinearSubdivisionFilter2,vtkInterpolatingSubdivisionFilter); //@} protected: vtkLinearSubdivisionFilter2 () {} ~vtkLinearSubdivisionFilter2 () override {} int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *) override; void GenerateSubdivisionCells (vtkPolyData *inputDS, vtkIntArray *edgeData, vtkCellArray *outputPolys, vtkCellData *outputCD) ; int GenerateSubdivisionPoints (vtkPolyData *inputDS, vtkIntArray *edgeData, vtkPoints *outputPts, vtkPointData *outputPD) override; int vtkSubdivisionFilterRequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *); private: vtkLinearSubdivisionFilter2(const vtkLinearSubdivisionFilter2&) = delete; void operator=(const vtkLinearSubdivisionFilter2&) = delete; }; #endif // VTK-HeaderTest-Exclude: vtkLinearSubdivisionFilter2.h
[ "lpzmateo@gmail.com" ]
lpzmateo@gmail.com
cad35a243445f8e02c565f56ed27fa3b96981532
9644f19ffdac3a5d0eec4c8f802a9ab998719f82
/Online Judges/POJ/1811.cpp
43013cf12e8c0f6593457e7fda47f3ec463723c3
[]
no_license
ypizarroza1990/ACM
ca472a3773be0c925cc312960aa82046fc4057fa
3a5a81a66540bcdae9960b497d9cf8ef4c8a50f0
refs/heads/master
2021-01-18T19:14:19.920891
2020-02-18T19:18:10
2020-02-18T19:18:10
56,805,153
0
0
null
null
null
null
UTF-8
C++
false
false
1,687
cpp
#include <iostream> #include <vector> #include <algorithm> using namespace std; #define i64 long long i64 n; vector<i64> ans; inline i64 mod_mul(i64 x,i64 y,i64 n){ if(!x) return 0; return (((x&1)*y)%n+(mod_mul(x>>1,y,n)<<1)%n)%n; } inline int rand32(){ return (rand()|rand()<<16)&0x7fffffff; } inline i64 myrand(){ return ((i64)rand32()|(i64)rand32()<<32)&0x7fffffffffffffffLL; } i64 mod_exp(i64 a,i64 x,i64 n){ i64 ret=1; while(x){ if(x&1) ret=mod_mul(ret,a,n); a=mod_mul(a,a,n); x>>=1; } return ret; } i64 gcd(i64 x,i64 y){ i64 q; while(1){ if(!y) return abs(x); q=x,x=y,y=q%y; } } bool Rabin_Miller(i64 n){ i64 k=0,i,j,m,a; if(n<2) return 0; if(n==2) return 1; if(!(n&1)) return 0; m=n-1; while(!(m&1)) m>>=1,k++; for(i=0;i<20;i++){ a=myrand()%(n-2)+2; a=mod_exp(a,m,n); if(a==1) continue; for(j=0;j<k;j++){ if(a==n-1) break; a=mod_mul(a,a,n); } if(j<k) continue; return false; } return true; } i64 func(i64 x,i64 n){ return (mod_mul(x,x,n)+1)%n; } i64 Pollard(i64 n){ i64 i,x,y,p; if(Rabin_Miller(n)) return n; if(!(n&1)) return 2; for(i=1;i<20;i++){ x=i; y=func(x,n); p=gcd(y-x,n); while(p==1){ x=func(x,n); y=func(func(y,n),n); p=gcd((y-x+n)%n,n)%n; } if(p==0||p==n) continue; return p; } } void factor(i64 n){ i64 x; x=Pollard(n); if(x==n){ ans.push_back(x); return; } factor(x); factor(n/x); } int cas; i64 N; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cin>>cas; while(cas--){ cin>>N; if(Rabin_Miller(N)) cout<<"Prime\n"; else{ factor(N); sort(ans.begin(),ans.end()); cout<<ans[0]<<"\n"; } ans.clear(); } return 0; }
[ "root@pizarrozaPC" ]
root@pizarrozaPC
f4bae6a3220a26cb7397b69fe7e2c0079a86eef8
aef85409e201affa30ea137729ef39b73e4d2f33
/OpenBracket_Command.cpp
984b60dadad99cecd5dde8dfdcc19ece3bed6c5e
[]
no_license
patrickbags/MaximizePerformanceMathEvaluator
f07b7f5e5b0efe85881400859d26b40c9f384609
9006f2f161b074a7054debfabd24ed8c06b4c817
refs/heads/master
2020-04-05T05:03:20.374476
2014-05-15T21:02:39
2014-05-15T21:02:39
null
0
0
null
null
null
null
UTF-8
C++
false
false
465
cpp
#include "OpenBracket_Command.h" //CONSTRUCTOR OpenBracket_Command::OpenBracket_Command() { } //DESTRUCTOR OpenBracket_Command::~OpenBracket_Command() { } //EXECUTE FUNCTION - SIMPLY RETURNS TRUE FOR OPENING PARENTHESIS COMMAND bool OpenBracket_Command::execute(Stack<int> &s) { return true; } /* * PRECEDENCE FUNCTION * * returns the precedence of the command */ int OpenBracket_Command::precedence() { //Precedence of Subtract command return 0; }
[ "shwetaskatdare@gmail.com" ]
shwetaskatdare@gmail.com
3bd8405da7f28062a0794119b0611719f03cfd75
45c1404043ea0910831f8bc2fe85c247b8c1b2de
/src/game/ai.cpp
a82610ffc268787b7dca51ff04de767d5d96f733
[]
no_license
ronanp/base
767765d85c588edf600f99656df7ab4b6af636e6
9ac1ea25fe920a75ca9bc3079bd61bfb72591425
refs/heads/master
2021-01-18T16:34:41.858354
2015-03-16T12:13:58
2015-03-16T12:13:58
null
0
0
null
null
null
null
UTF-8
C++
false
false
79,277
cpp
#include "game.h" namespace ai { avoidset obstacles, wpavoid; int updatemillis = 0, iteration = 0, itermillis = 0; vec aitarget(0, 0, 0); VAR(0, aidebug, 0, 0, 7); VAR(0, aidebugfocus, 0, 1, 2); VAR(0, aipassive, 0, 0, 2); // 0 = off, 1 = passive to humans, 2 = completely passive VARF(0, showwaypoints, 0, 0, 1, if(showwaypoints) getwaypoints()); VAR(IDF_PERSIST, showwaypointsdrop, 0, 1, 1); VAR(IDF_PERSIST, showwaypointsradius, 0, 256, VAR_MAX); VAR(IDF_PERSIST|IDF_HEX, showwaypointscolour, 0, 0xFF00FF, 0xFFFFFF); VAR(IDF_PERSIST, aideadfade, 0, 10000, VAR_MAX); VAR(IDF_PERSIST, showaiinfo, 0, 0, 2); // 0/1 = shows/hides bot join/parts, 2 = show more verbose info bool passive(gameent *d = NULL) { if(m_edit(game::gamemode)) return true; switch(aipassive) { case 2: return true; case 1: if(d && d->actortype == A_PLAYER) return true; case 0: default: break; } return false; } bool dbgfocus(gameent *d) { return d->ai && (!aidebugfocus || d == game::focus || (aidebugfocus != 2 && !game::focus->ai)); } void startmap(const char *name, const char *reqname, bool empty) // called just after a map load { savewaypoints(); clearwaypoints(true); showwaypoints = dropwaypoints = 0; } float viewdist(int x) { return x <= 100 ? clamp((SIGHTMIN+(SIGHTMAX-SIGHTMIN))/100.f*float(x), float(SIGHTMIN), max(float(fog), SIGHTMIN)) : max(float(fog), SIGHTMIN); } float viewfieldx(int x) { return x <= 100 ? clamp((VIEWMIN+(VIEWMAX-VIEWMIN))/100.f*float(x), float(VIEWMIN), float(VIEWMAX)) : float(VIEWMAX); } float viewfieldy(int x) { return viewfieldx(x)*3.f/4.f; } float weapmindist(int weap, bool alt) { if(weaptype[weap].melee) return 0.f; if(WX(false, weap, explode, alt, game::gamemode, game::mutators, 1.f) > 0) return WX(false, weap, explode, alt, game::gamemode, game::mutators, 1.f); return CLOSEDIST; } float weapmaxdist(int weap, bool alt) { if(weaptype[weap].melee) return CLOSEDIST; if(W2(weap, aidist, alt) > 0) return W2(weap, aidist, alt); return getworldsize(); } bool weaprange(gameent *d, int weap, bool alt, float dist) { if(!isweap(weap) || (W2(weap, extinguish, alt) && d->inliquid)) return false; float mindist = weapmindist(weap, alt), maxdist = weapmaxdist(weap, alt); return dist >= mindist*mindist && dist <= maxdist*maxdist; } bool targetable(gameent *d, gameent *e, bool solid) { if(d && e && d != e && !passive(e) && e->state == CS_ALIVE && (!solid || physics::issolid(e, d))) { if(d->team == T_ENEMY && e->team == T_ENEMY) return false; if(!m_team(game::gamemode, game::mutators) || d->team != e->team) return true; } return false; } bool cansee(gameent *d, vec &x, vec &y, bool force, vec &targ) { if(force) return raycubelos(x, y, targ); return getsight(x, d->yaw, d->pitch, y, targ, d->ai->views[2], d->ai->views[0], d->ai->views[1]); } bool badhealth(gameent *d) { if(d->skill <= 100) return d->health <= (111-d->skill)/4; return false; } bool canshoot(gameent *d, gameent *e, bool alt = true) { if(isweap(d->weapselect) && weaprange(d, d->weapselect, alt, e->o.squaredist(d->o))) { int prot = m_protect(game::gamemode, game::mutators); if((d->actortype >= A_ENEMY || !d->protect(lastmillis, prot)) && targetable(d, e, true)) return d->canshoot(d->weapselect, alt ? HIT_ALT : 0, m_weapon(game::gamemode, game::mutators), lastmillis, (1<<W_S_RELOAD)); } return false; } bool altfire(gameent *d, gameent *e) { if(e && !(W2(d->weapselect, cooked, true)&W_C_ZOOM) && canshoot(d, e, true)) { if(d->weapstate[d->weapselect] == W_S_POWER || d->weapstate[d->weapselect] == W_S_ZOOM) { if(d->action[AC_SECONDARY] && (!d->action[AC_PRIMARY] || d->actiontime[AC_SECONDARY] > d->actiontime[AC_PRIMARY])) return true; } switch(d->weapselect) { case W_PISTOL: return true; break; case W_MELEE: case W_ROCKET: default: return false; break; case W_SWORD: case W_SHOTGUN: case W_SMG: case W_FLAMER: case W_PLASMA: case W_ZAPPER: case W_GRENADE: case W_MINE: if(rnd(d->skill*3) <= d->skill) return false; break; case W_RIFLE: if(weaprange(d, d->weapselect, false, e->o.squaredist(d->o))) return false; break; } return true; } return false; } bool hastarget(gameent *d, aistate &b, gameent *e, bool alt, bool insight, float yaw, float pitch) { // add margins of error if((insight && weaprange(d, d->weapselect, alt, e->o.squaredist(d->o))) || (d->skill <= 100 && !rnd(d->skill))) { if(weaptype[d->weapselect].melee) return true; float skew = clamp(float(lastmillis-d->ai->enemymillis)/float((d->skill*W(d->weapselect, delayreload)/5000.f)+(d->skill*W2(d->weapselect, delayattack, alt)/500.f)), 0.f, weaptype[d->weapselect].thrown ? 0.25f : 1e16f), offy = yaw-d->yaw, offp = pitch-d->pitch; if(offy > 180) offy -= 360; else if(offy < -180) offy += 360; if(fabs(offy) <= d->ai->views[0]*skew && fabs(offp) <= d->ai->views[1]*skew) return true; } return false; } vec getaimpos(gameent *d, gameent *e, bool alt) { vec o = e->o; if(d->skill <= 100) { if(lastmillis >= d->ai->lastaimrnd) { int radius = ceilf(e->radius*W2(d->weapselect, aiskew, alt)); float speed = clamp(e->vel.magnitude()/movespeed, 0.f, 1.f), scale = speed+((1-speed)*((101-d->skill)/100.f)); loopk(3) d->ai->aimrnd[k] = (rnd((radius*2)+1)-radius)*scale; int dur = (d->skill+10)*10; d->ai->lastaimrnd = lastmillis+dur+rnd(dur); } o.add(d->ai->aimrnd); } return o; } int weappref(gameent *d) { if(d->loadweap.length()) return d->loadweap[0]; return m_weapon(game::gamemode, game::mutators); } bool hasweap(gameent *d, int weap) { if(!isweap(weap)) return false; if(w_carry(weap, m_weapon(game::gamemode, game::mutators))) return d->hasweap(weap, m_weapon(game::gamemode, game::mutators)); return d->ammo[weap] >= W(weap, ammomax); } bool wantsweap(gameent *d, int weap) { if(!isweap(weap) || hasweap(d, weap)) return false; if(d->carry(m_weapon(game::gamemode, game::mutators)) >= maxcarry && (hasweap(d, weappref(d)) || weap != weappref(d))) return false; return true; } void create(gameent *d) { if(!d->ai && !(d->ai = new aiinfo())) { fatal("could not create ai"); return; } d->respawned = -1; } void destroy(gameent *d) { if(d->ai) DELETEP(d->ai); } void checkinfo(gameent *d) { gameent *o = game::getclient(d->ownernum); if(o) { copystring(d->hostname, o->hostname); copystring(d->hostip, o->hostip); d->version.grab(o->version); } } void init(gameent *d, int at, int et, int on, int sk, int bn, char *name, int tm, int cl, int md, const char *vn, vector<int> &lweaps) { getwaypoints(); gameent *o = game::newclient(on); if(!o) return; bool resetthisguy = false; string m; copystring(m, game::colourname(o)); if(!d->name[0]) { if(at == A_BOT && showaiinfo && client::showpresence >= (client::waiting(false) ? 2 : 1)) { if(showaiinfo > 1) conoutft(CON_EVENT, "\fg%s assigned to %s at skill %d", game::colourname(d, name), m, sk); else conoutft(CON_EVENT, "\fg%s was added to the game", game::colourname(d, name));//, m, sk); } game::specreset(d); resetthisguy = true; } else { if(d->ownernum != on) { if(at == A_BOT && showaiinfo && client::showpresence >= (client::waiting(false) ? 2 : 1)) conoutft(CON_EVENT, "\fg%s reassigned to %s", game::colourname(d, name), m); resetthisguy = true; } if(at == A_BOT && d->skill != sk && showaiinfo > 1 && client::showpresence >= (client::waiting(false) ? 2 : 1)) conoutft(CON_EVENT, "\fg%s changed skill to %d", game::colourname(d, name), sk); } if((d->actortype = at) >= A_ENEMY) d->type = ENT_AI; else { d->loadweap.shrink(0); loopv(lweaps) d->loadweap.add(lweaps[i]); } d->setname(name); d->spawnpoint = et; d->ownernum = on; d->skill = sk; d->team = tm; d->colour = cl; d->model = md; d->setvanity(vn); if(resetthisguy) projs::remove(d); if(d->ownernum >= 0 && game::player1->clientnum == d->ownernum) { create(d); if(d->ai) { d->ai->views[0] = viewfieldx(d->skill); d->ai->views[1] = viewfieldy(d->skill); d->ai->views[2] = viewdist(d->skill); } } else if(d->ai) destroy(d); checkinfo(d); } void update() { if(!gs_playing(game::gamestate)) { loopv(game::players) if(game::players[i] && game::players[i]->ai) game::players[i]->stopmoving(true); } else // fixed rate logic done out-of-sequence at 1 frame per second for each ai { if(totalmillis-updatemillis > 100) avoid(); if(!iteration && totalmillis-itermillis > 1000) { iteration = 1; itermillis = totalmillis; if(multiplayer(false)) aipassive = 0; updatemillis = totalmillis; } int c = 0; loopv(game::players) if(game::players[i] && game::players[i]->ai) { checkinfo(game::players[i]); think(game::players[i], ++c == iteration ? true : false); } if(c && ++iteration > c) iteration = 0; } } int checkothers(vector<int> &targets, gameent *d, int state, int targtype, int target, bool teams, int *members) { // checks the states of other ai for a match targets.setsize(0); gameent *e = NULL; int numdyns = game::numdynents(); loopi(numdyns) if((e = (gameent *)game::iterdynents(i))) { if(targets.find(e->clientnum) >= 0) continue; if(teams && (d->team != T_ENEMY || e->team != T_ENEMY) && m_team(game::gamemode, game::mutators) && d->team != e->team) continue; if(members) (*members)++; if(e == d || !e->ai || e->state != CS_ALIVE || e->actortype != d->actortype) continue; aistate &b = e->ai->getstate(); if(state >= 0 && b.type != state) continue; if(target >= 0 && b.target != target) continue; if(targtype >=0 && b.targtype != targtype) continue; targets.add(e->clientnum); } return targets.length(); } bool makeroute(gameent *d, aistate &b, int node, bool changed, int retries) { if(changed && !d->ai->route.empty() && d->ai->route[0] == node) return true; if(route(d, d->lastnode, node, d->ai->route, obstacles, retries)) { b.override = false; return true; } // retry fails: 0 = first attempt, 1 = try ignoring obstacles, 2 = try ignoring prevnodes too if(retries <= 1) return makeroute(d, b, node, false, retries+1); return false; } bool makeroute(gameent *d, aistate &b, const vec &pos, bool changed, int retries) { int node = closestwaypoint(pos, CLOSEDIST, true); return makeroute(d, b, node, changed, retries); } bool randomnode(gameent *d, aistate &b, const vec &pos, float guard, float wander) { static vector<int> candidates; candidates.setsize(0); findwaypointswithin(pos, guard, wander, candidates); while(!candidates.empty()) { int w = rnd(candidates.length()), n = candidates.removeunordered(w); if(n != d->lastnode && !d->ai->hasprevnode(n) && !obstacles.find(n, d) && makeroute(d, b, n)) return true; } return false; } bool randomnode(gameent *d, aistate &b, float guard, float wander) { return randomnode(d, b, d->feetpos(), guard, wander); } bool enemy(gameent *d, aistate &b, const vec &pos, float guard, int pursue, bool force, bool retry = false) { if(passive() || (d->ai->enemy >= 0 && lastmillis-d->ai->enemymillis >= (111-d->skill)*50)) return false; gameent *t = NULL, *e = NULL; float mindist = guard*guard, bestdist = 1e16f; int numdyns = game::numdynents(); loopi(numdyns) if((e = (gameent *)game::iterdynents(i)) && targetable(d, e)) { float dist = d->o.squaredist(e->o); if(dist < bestdist && (force || dist <= mindist || cansee(d, d->o, e->o, d->actortype >= A_ENEMY))) { t = e; bestdist = dist; } } if(t && violence(d, b, t, pursue)) return true; if(retry && !force) return enemy(d, b, pos, guard, pursue, true, false); return false; } bool patrol(gameent *d, aistate &b, const vec &pos, float guard, float wander, int walk, bool retry) { if(actor[d->actortype].canmove) { vec feet = d->feetpos(); float dist = feet.squaredist(pos); if(walk == 2 || b.override || (walk && dist <= guard*guard) || !makeroute(d, b, pos)) { // run away and back to keep ourselves busy if(!b.override && wander > 0 && randomnode(d, b, pos, guard, wander)) { b.override = true; return true; } if(d->ai->route.empty()) { b.override = false; if(!retry) return patrol(d, b, pos, guard, wander, walk, true); if(wander > 0) return false; } if(wander <= 0) { b.acttype = AI_A_IDLE; return true; } } if(!b.override && dist > guard*guard) b.acttype = AI_A_HASTE; } b.override = false; return true; } bool defense(gameent *d, aistate &b, const vec &pos, float guard, float wander, int walk) { if(!actor[d->actortype].canmove) { b.acttype = enemy(d, b, pos, wander, weaptype[d->weapselect].melee ? 1 : 0, false, true) ? AI_A_PROTECT : AI_A_IDLE; return true; } if(!walk) { if(d->feetpos().squaredist(pos) <= guard*guard) { b.acttype = enemy(d, b, pos, d->ai->views[2], weaptype[d->weapselect].melee ? 1 : 0, false, true) ? AI_A_PROTECT : AI_A_IDLE; return true; } walk++; } return patrol(d, b, pos, guard, wander, walk); } bool violence(gameent *d, aistate &b, gameent *e, int pursue) { if(passive() || !targetable(d, e)) return false; if(d->ai->enemy != e->clientnum) { gameent *f = game::getclient(d->ai->enemy); if(f && (d->o.squaredist(e->o) < d->o.squaredist(f->o) || (d->ai->enemyseen && lastmillis-d->ai->enemyseen <= (d->skill*10)+1000))) return false; } if(pursue) { if((b.targtype != AI_T_AFFINITY || !(pursue%2)) && makeroute(d, b, e->lastnode)) d->ai->switchstate(b, AI_S_PURSUE, AI_T_ACTOR, e->clientnum, b.targtype != AI_T_AFFINITY ? AI_A_NORMAL : AI_A_HASTE); else if(pursue >= 3) return false; // can't pursue } if(d->ai->enemy != e->clientnum) { d->ai->enemyseen = d->ai->enemymillis = lastmillis; d->ai->enemy = e->clientnum; } return true; } struct targcache { gameent *d; bool dominated, visible; float dist; targcache() : d(NULL), dominated(false), visible(false), dist(0) {} ~targcache() {} static bool tcsort(targcache &a, targcache &b) { if(a.dominated && !b.dominated) return true; if(!a.dominated && b.dominated) return false; if(a.visible && !b.visible) return true; if(!a.visible && b.visible) return false; if(a.dist < b.dist) return true; if(a.dist > b.dist) return false; return true; } }; bool target(gameent *d, aistate &b, int pursue = 0, bool force = false) { if(passive()) return false; static vector<targcache> targets; targets.setsize(0); gameent *e = NULL; int numdyns = game::numdynents(); loopi(numdyns) if((e = (gameent *)game::iterdynents(i)) && targetable(d, e)) { targcache &c = targets.add(); c.d = e; c.dist = d->o.squaredist(e->o); if(d->dominating.find(c.d) >= 0) c.dominated = true; c.visible = force || cansee(d, d->o, e->o, d->actortype >= A_ENEMY); } if(targets.empty()) return false; targets.sort(targcache::tcsort); d->ai->enemy = -1; d->ai->enemymillis = d->ai->enemyseen = 0; loopv(targets) if(violence(d, b, targets[i].d, pursue || targets[i].dominated ? 1 : 0)) return true; return false; } void assist(gameent *d, aistate &b, vector<interest> &interests, bool all = false, bool force = false) { gameent *e = NULL; int numdyns = game::numdynents(); loopi(numdyns) if((e = (gameent *)game::iterdynents(i)) && e != d && (all || e->actortype == A_PLAYER) && d->team == e->team) { interest &n = interests.add(); n.state = AI_S_DEFEND; n.node = e->lastnode; n.target = e->clientnum; n.targtype = AI_T_ACTOR; n.score = e->o.squaredist(d->o)/(force ? 1e8f : (hasweap(d, weappref(d)) ? 1.f : 0.5f)); n.tolerance = 0.25f; n.team = true; n.acttype = AI_A_PROTECT; } } void items(gameent *d, aistate &b, vector<interest> &interests, bool force = false) { vec pos = d->feetpos(); int sweap = m_weapon(game::gamemode, game::mutators); loopj(entities::lastuse(EU_ITEM)) { gameentity &e = *(gameentity *)entities::ents[j]; if(enttype[e.type].usetype != EU_ITEM || e.type != WEAPON) continue; int attr = w_attr(game::gamemode, game::mutators, e.type, e.attrs[0], sweap); if(e.spawned() && isweap(attr) && wantsweap(d, attr)) { // go get a weapon upgrade interest &n = interests.add(); n.state = AI_S_INTEREST; n.node = closestwaypoint(e.o, CLOSEDIST, true); n.target = j; n.targtype = AI_T_ENTITY; n.score = pos.squaredist(e.o)/(attr == weappref(d) ? 1e8f : (force ? 1e4f : 1.f)); n.tolerance = 0; } } loopvj(projs::projs) if(projs::projs[j]->projtype == PRJ_ENT && projs::projs[j]->ready()) { projent &proj = *projs::projs[j]; if(!entities::ents.inrange(proj.id)) continue; gameentity &e = *(gameentity *)entities::ents[proj.id]; if(enttype[e.type].usetype != EU_ITEM || e.type != WEAPON) continue; int attr = w_attr(game::gamemode, game::mutators, e.type, e.attrs[0], sweap); if(isweap(attr) && wantsweap(d, attr) && proj.owner != d) { // go get a weapon upgrade interest &n = interests.add(); n.state = AI_S_INTEREST; n.node = closestwaypoint(proj.o, CLOSEDIST, true); n.target = proj.id; n.targtype = AI_T_DROP; n.score = pos.squaredist(proj.o)/(attr == weappref(d) ? 1e8f : (force ? 1e4f : 1.f)); n.tolerance = 0; } } } bool find(gameent *d, aistate &b) { static vector<interest> interests; interests.setsize(0); if(d->actortype == A_BOT) { if(!passive()) { int sweap = m_weapon(game::gamemode, game::mutators); if(!hasweap(d, weappref(d)) || d->carry(sweap) == 0) items(d, b, interests, d->carry(sweap) == 0); if(m_team(game::gamemode, game::mutators) && !m_duke(game::gamemode, game::mutators)) assist(d, b, interests, false, false); } if(m_fight(game::gamemode)) { if(m_capture(game::gamemode)) capture::aifind(d, b, interests); else if(m_defend(game::gamemode)) defend::aifind(d, b, interests); else if(m_bomber(game::gamemode)) bomber::aifind(d, b, interests); } } else if(entities::ents.inrange(d->spawnpoint)) loopv(entities::ents[d->spawnpoint]->links) { int t = entities::ents[d->spawnpoint]->links[i]; if(!entities::ents.inrange(t)) continue; interest &n = interests.add(); n.state = AI_S_DEFEND; n.target = t; n.node = closestwaypoint(entities::ents[t]->o, CLOSEDIST, true); n.targtype = AI_T_ENTITY; n.score = -1; n.tolerance = 1; } while(!interests.empty()) { int q = interests.length()-1; loopi(interests.length()-1) if(interests[i].score < interests[q].score) q = i; interest n = interests.removeunordered(q); if(d->actortype == A_BOT && m_fight(game::gamemode) && m_team(game::gamemode, game::mutators)) { int members = 0; static vector<int> targets; targets.setsize(0); int others = checkothers(targets, d, n.state, n.targtype, n.target, n.team, &members); if(d->actortype == A_BOT && n.state == AI_S_DEFEND && members == 1) continue; if(others >= int(ceilf(members*n.tolerance))) continue; } if(!actor[d->actortype].canmove || makeroute(d, b, n.node)) { d->ai->switchstate(b, n.state, n.targtype, n.target, n.acttype); return true; } } return false; } void damaged(gameent *d, gameent *e, int weap, int flags, int damage) { if(d != e) { if(d->ai && (d->actortype >= A_ENEMY || (hithurts(flags) && damage > 0) || d->ai->enemy < 0 || d->dominating.find(e))) // see if this ai is interested in a grudge { aistate &b = d->ai->getstate(); violence(d, b, e, d->actortype != A_BOT || weaptype[d->weapselect].melee ? 1 : 0); } static vector<int> targets; // check if one of our ai is defending them targets.setsize(0); if(checkothers(targets, d, AI_S_DEFEND, AI_T_ACTOR, d->clientnum, true)) { gameent *t; loopv(targets) if((t = game::getclient(targets[i])) && t->ai && t->actortype == A_BOT && ((hithurts(flags) && damage > 0) || t->ai->enemy < 0 || t->dominating.find(e))) { aistate &c = t->ai->getstate(); violence(t, c, e, weaptype[d->weapselect].melee ? 1 : 0); } } } } void setup(gameent *d, int ent = -1) { d->spawnpoint = ent; if(d->ai) { d->ai->clean(); d->ai->reset(true); d->ai->lastrun = lastmillis; findorientation(d->o, d->yaw, d->pitch, d->ai->target); } } void respawned(gameent *d, bool local, int ent) { if(d->ai) setup(d, ent); } void killed(gameent *d, gameent *e) { if(d->ai) d->ai->reset(true); } void itemspawned(int ent, int spawned) { if(!passive() && m_fight(game::gamemode) && entities::ents.inrange(ent) && entities::ents[ent]->type == WEAPON && spawned > 0) { int sweap = m_weapon(game::gamemode, game::mutators), attr = w_attr(game::gamemode, game::mutators, entities::ents[ent]->type, entities::ents[ent]->attrs[0], sweap); loopv(game::players) if(game::players[i] && game::players[i]->ai && game::players[i]->actortype == A_BOT && game::players[i]->state == CS_ALIVE && iswaypoint(game::players[i]->lastnode)) { gameent *d = game::players[i]; aistate &b = d->ai->getstate(); if(b.targtype == AI_T_AFFINITY) continue; // don't override any affinity states if(!hasweap(d, attr) && (!hasweap(d, weappref(d)) || d->carry(sweap) == 0) && wantsweap(d, attr)) { if(b.type == AI_S_INTEREST && (b.targtype == AI_T_ENTITY || b.targtype == AI_T_DROP)) { if(entities::ents.inrange(b.target)) { int weap = w_attr(game::gamemode, game::mutators, entities::ents[ent]->type, entities::ents[b.target]->attrs[0], sweap); if((attr == weappref(d) && weap != weappref(d)) || d->o.squaredist(entities::ents[ent]->o) < d->o.squaredist(entities::ents[b.target]->o)) d->ai->switchstate(b, AI_S_INTEREST, AI_T_ENTITY, ent); } continue; } d->ai->switchstate(b, AI_S_INTEREST, AI_T_ENTITY, ent); } } } } bool check(gameent *d, aistate &b) { if(d->actortype == A_BOT) { if(m_capture(game::gamemode) && capture::aicheck(d, b)) return true; else if(m_defend(game::gamemode) && defend::aicheck(d, b)) return true; else if(m_bomber(game::gamemode) && bomber::aicheck(d, b)) return true; } return false; } bool dowait(gameent *d, aistate &b) { //d->ai->clear(true); // ensure they're clean if(check(d, b) || find(d, b)) return true; if(!passive()) { if(target(d, b, 4, false)) return true; if(target(d, b, 4, true)) return true; } if(actor[d->actortype].canmove && randomnode(d, b, CLOSEDIST, 1e16f)) { d->ai->switchstate(b, AI_S_INTEREST, AI_T_NODE, d->ai->route[0]); return true; } return false; // but don't pop the state } bool dodefense(gameent *d, aistate &b) { if(d->state != CS_ALIVE) return false; switch(b.targtype) { case AI_T_ENTITY: { if(check(d, b)) return true; if(entities::ents.inrange(b.target)) return defense(d, b, entities::ents[b.target]->o); break; } case AI_T_AFFINITY: { if(m_capture(game::gamemode)) return capture::aidefense(d, b); else if(m_defend(game::gamemode)) return defend::aidefense(d, b); else if(m_bomber(game::gamemode)) return bomber::aidefense(d, b); break; } case AI_T_ACTOR: { if(check(d, b)) return true; gameent *e = game::getclient(b.target); if(e && d->team == e->team) { if(e->state == CS_ALIVE) return defense(d, b, e->feetpos()); if(b.owner >= 0) return patrol(d, b, d->feetpos()); } break; } default: { if(check(d, b)) return true; if(iswaypoint(b.target)) return defense(d, b, waypoints[b.target].o, CLOSEDIST, 0, 0); break; } } return false; } bool dointerest(gameent *d, aistate &b) { if(d->state != CS_ALIVE || !actor[d->actortype].canmove) return false; switch(b.targtype) { case AI_T_ENTITY: { if(entities::ents.inrange(b.target)) { gameentity &e = *(gameentity *)entities::ents[b.target]; if(enttype[e.type].usetype != EU_ITEM || e.type != WEAPON) return false; int sweap = m_weapon(game::gamemode, game::mutators), attr = w_attr(game::gamemode, game::mutators, e.type, e.attrs[0], sweap); if(!isweap(attr) || !e.spawned() || !wantsweap(d, attr)) return false; //float guard = enttype[e.type].radius; //if(d->feetpos().squaredist(e.o) <= guard*guard) // b.acttype = enemy(d, b, e.o, guard*4, weaptype[d->weapselect].melee ? 1 : 0, false) ? AI_A_PROTECT : AI_A_IDLE; return makeroute(d, b, e.o); } break; } case AI_T_DROP: { loopvj(projs::projs) if(projs::projs[j]->projtype == PRJ_ENT && projs::projs[j]->ready() && projs::projs[j]->id == b.target) { projent &proj = *projs::projs[j]; if(!entities::ents.inrange(proj.id) || proj.owner == d) return false; gameentity &e = *(gameentity *)entities::ents[proj.id]; if(enttype[entities::ents[proj.id]->type].usetype != EU_ITEM || e.type != WEAPON) return false; int sweap = m_weapon(game::gamemode, game::mutators), attr = w_attr(game::gamemode, game::mutators, e.type, e.attrs[0], sweap); if(!isweap(attr) || !wantsweap(d, attr)) return false; //float guard = enttype[e.type].radius; //if(d->feetpos().squaredist(e.o) <= guard*guard) // b.acttype = enemy(d, b, e.o, guard*4, weaptype[d->weapselect].melee ? 1 : 0, false) ? AI_A_PROTECT : AI_A_IDLE; return makeroute(d, b, proj.o); } break; } default: // this is like a wait state without sitting still.. { if(check(d, b) || (b.owner < 0 && find(d, b))) return true; if(target(d, b, b.owner < 0 ? 0 : 4, true)) return true; if(iswaypoint(b.target) && (b.owner >= 0 || d->lastnode != b.target)) return defense(d, b, waypoints[b.target].o, CLOSEDIST, b.owner >= 0 ? 0.f : FARDIST, b.owner >= 0 ? 0 : 2); break; } } return false; } bool dopursue(gameent *d, aistate &b) { if(d->state != CS_ALIVE) return false; switch(b.targtype) { case AI_T_AFFINITY: { if(m_capture(game::gamemode)) return capture::aipursue(d, b); else if(m_defend(game::gamemode)) return defend::aipursue(d, b); else if(m_bomber(game::gamemode)) return bomber::aipursue(d, b); break; } case AI_T_ACTOR: { //if(check(d, b)) return true; gameent *e = game::getclient(b.target); if(e && targetable(d, e)) { if(e->state == CS_ALIVE) { bool alt = altfire(d, e); if(!actor[d->actortype].canmove) { if(cansee(d, d->o, e->o, d->actortype >= A_ENEMY) || (e->clientnum == d->ai->enemy && d->ai->enemyseen && lastmillis-d->ai->enemyseen <= (d->skill*30)+1000)) return true; return false; } return patrol(d, b, e->feetpos(), weapmindist(d->weapselect, alt), weapmaxdist(d->weapselect, alt)); } if(b.owner >= 0) return patrol(d, b, d->feetpos()); } break; } default: { if(check(d, b)) return true; if(iswaypoint(b.target)) return defense(d, b, waypoints[b.target].o); break; } } return false; } int closenode(gameent *d) { vec pos = d->feetpos(); int node1 = -1, node2 = -1, node3 = -1; float mindist1 = CLOSEDIST*CLOSEDIST, mindist2 = RETRYDIST*RETRYDIST, mindist3 = mindist2; loopv(d->ai->route) if(iswaypoint(d->ai->route[i])) { vec epos = waypoints[d->ai->route[i]].o; float dist = epos.squaredist(pos); if(dist > mindist3) continue; if(dist < mindist1) { node1 = i; mindist1 = dist; } else { int entid = obstacles.remap(d, d->ai->route[i], epos); if(entid >= 0) { if(entid != i) dist = epos.squaredist(pos); if(dist < mindist2) { node2 = i; mindist2 = dist; } } else if(dist < mindist3) { node3 = i; mindist3 = dist; } } } return node1 >= 0 ? node1 : (node2 >= 0 ? node2 : node3); } int wpspot(gameent *d, int n, bool check = false) { if(iswaypoint(n)) loopk(2) { vec epos = waypoints[n].o; int entid = obstacles.remap(d, n, epos, k!=0); if(iswaypoint(entid)) { vec feet = d->feetpos(); float zoff = epos.z-d->feetpos().z; if(!actor[d->actortype].canjump && zoff >= JUMPMIN) epos.z = feet.z; else if(actor[d->actortype].canjump && d->airtime(lastmillis) >= 25 && zoff <= -JUMPMIN) epos.z = feet.z; d->ai->spot = epos; d->ai->targnode = entid; return !check || feet.squaredist(epos) > MINWPDIST*MINWPDIST ? 1 : 2; } } return 0; } int randomlink(gameent *d, int n) { if(iswaypoint(n) && waypoints[n].haslinks()) { waypoint &w = waypoints[n]; static vector<int> linkmap; linkmap.setsize(0); loopi(MAXWAYPOINTLINKS) { if(!w.links[i]) break; if(iswaypoint(w.links[i]) && !d->ai->hasprevnode(w.links[i]) && d->ai->route.find(w.links[i]) < 0) linkmap.add(w.links[i]); } if(!linkmap.empty()) return linkmap[rnd(linkmap.length())]; } return -1; } bool anynode(gameent *d, aistate &b, int len = NUMPREVNODES) { if(iswaypoint(d->lastnode)) loopk(2) { //d->ai->clear(k ? true : false); int n = randomlink(d, d->lastnode); if(wpspot(d, n)) { d->ai->route.add(n); d->ai->route.add(d->lastnode); loopi(len) { n = randomlink(d, n); if(iswaypoint(n)) d->ai->route.insert(0, n); else break; } return true; } } return false; } bool checkroute(gameent *d, int n) { if(d->ai->route.empty() || !d->ai->route.inrange(n)) return false; int len = d->ai->route.length(); if(len <= 2 || (d->ai->lastcheck && lastmillis-d->ai->lastcheck <= 100)) return false; int w = iswaypoint(d->lastnode) ? d->lastnode : d->ai->route[n], c = min(len, NUMPREVNODES); if(c >= 3) loopj(c) // check ahead to see if we need to go around something { int m = len-j-1; if(m <= 1) return false; // route length is too short from this point int v = d->ai->route[j]; if(d->ai->hasprevnode(v) || obstacles.find(v, d)) // something is in the way, try to remap around it { d->ai->lastcheck = lastmillis; loopi(m) { int q = j+i+1, t = d->ai->route[q]; if(!d->ai->hasprevnode(t) && !obstacles.find(t, d)) { static vector<int> remap; remap.setsize(0); if(route(d, w, t, remap, obstacles)) { // kill what we don't want and put the remap in while(d->ai->route.length() > i) d->ai->route.pop(); loopvk(remap) d->ai->route.add(remap[k]); return true; } return false; // we failed } } return false; } } return false; } bool hunt(gameent *d, aistate &b) { if(!d->ai->route.empty()) { int n = closenode(d); if(d->ai->route.inrange(n) && checkroute(d, n)) n = closenode(d); if(d->ai->route.inrange(n)) { if(!n) { switch(wpspot(d, d->ai->route[n], true)) { case 2: d->ai->clear(false); case 1: return true; // not close enough to pop it yet case 0: default: break; } } else { while(d->ai->route.length() > n+1) d->ai->route.pop(); // waka-waka-waka-waka int m = n-1; // next, please! if(d->ai->route.inrange(m) && wpspot(d, d->ai->route[m])) return true; } } } b.override = false; return anynode(d, b); } void jumpto(gameent *d, aistate &b, const vec &pos) { vec off = vec(pos).sub(d->feetpos()); int airtime = d->airtime(lastmillis); bool sequenced = d->ai->blockseq || d->ai->targseq, offground = airtime && !physics::liquidcheck(d) && !d->onladder, impulse = airtime > (b.acttype >= AI_A_LOCKON ? 100 : 250) && !d->turnside && (b.acttype >= AI_A_LOCKON || off.z >= JUMPMIN) && physics::canimpulse(d, IM_A_BOOST, false) && (m_freestyle(game::gamemode, game::mutators) || impulsemeter-d->impulse[IM_METER] >= impulsecost), jumper = !offground && (b.acttype == AI_A_LOCKON || sequenced || off.z >= JUMPMIN || (d->actortype == A_BOT && lastmillis >= d->ai->jumprand)), jump = (impulse || jumper) && lastmillis >= d->ai->jumpseed; if(jump) { vec old = d->o; d->o = vec(pos).add(vec(0, 0, d->height)); if(collide(d, vec(0, 0, 1))) jump = false; d->o = old; if(jump) { loopi(entities::lastent(PUSHER)) if(entities::ents[i]->type == PUSHER) { gameentity &e = *(gameentity *)entities::ents[i]; float radius = (e.attrs[3] ? e.attrs[3] : enttype[e.type].radius)*1.5f; radius *= radius; if(e.o.squaredist(pos) <= radius) { jump = false; break; } } } } if(d->action[AC_JUMP] != jump) { d->action[AC_JUMP] = jump; d->actiontime[AC_JUMP] = lastmillis; } if(jumper && d->action[AC_JUMP]) { int seed = (111-d->skill)*(b.acttype == AI_A_LOCKON || b.acttype == AI_A_HASTE ? 2 : (d->onladder || d->inliquid || b.acttype == AI_A_PROTECT ? 4 : 8)); d->ai->jumpseed = lastmillis+seed+rnd(seed); seed *= b.acttype == AI_A_IDLE ? 500 : 100; d->ai->jumprand = lastmillis+seed+rnd(seed); } if(!sequenced && !d->onladder && airtime) { if(airtime > (b.acttype >= AI_A_LOCKON ? 250 : 500) && !d->turnside && (d->skill >= 100 || !rnd(101-d->skill)) && physics::canimpulse(d, IM_A_PARKOUR, true)) d->action[AC_SPECIAL] = true; else if(!passive() && lastmillis-d->ai->lastmelee >= (201-d->skill)*5 && d->canmelee(m_weapon(game::gamemode, game::mutators), lastmillis)) { d->action[AC_SPECIAL] = true; d->ai->lastmelee = lastmillis; } } } bool lockon(gameent *d, gameent *e, float maxdist, bool check) { if(!passive() && check && !d->blocked && (d->inmaterial&MATF_CLIP) != MAT_AICLIP) { vec dir = vec(e->o).sub(d->o); float xydist = dir.x*dir.x+dir.y*dir.y, zdist = dir.z*dir.z, mdist = maxdist*maxdist, ddist = d->radius*d->radius+e->radius*e->radius; if(zdist <= ddist && xydist >= ddist+4 && xydist <= mdist+ddist) return true; } return false; } void process(gameent *d, aistate &b, bool &occupied, bool &firing, bool &enemyok) { int skmod = max(101-d->skill, 1); float frame = d->skill <= 100 ? ((lastmillis-d->ai->lastrun)*(100.f/gamespeed))/float(skmod*10) : 1; if(!actor[d->actortype].canstrafe && d->skill <= 100) frame *= 2; if(d->dominating.length()) frame *= 1+d->dominating.length(); d->action[AC_SPECIAL] = d->ai->dontmove = false; if(b.acttype == AI_A_IDLE || !actor[d->actortype].canmove) { frame *= 10; d->ai->dontmove = true; d->ai->spot = d->feetpos(); } else if(hunt(d, b)) { vec fp = d->feetpos(); game::getyawpitch(fp, d->ai->spot, d->ai->targyaw, d->ai->targpitch); if(d->ai->route.length() <= 1 && d->ai->spot.squaredist(fp) <= MINWPDIST*MINWPDIST) d->ai->dontmove = true; } else { if((d->blocked || (d->inmaterial&MATF_CLIP) == MAT_AICLIP) && (!d->ai->lastturn || lastmillis-d->ai->lastturn >= 1000)) { d->ai->targyaw += 90+rnd(180); d->ai->lastturn = lastmillis; } d->ai->targpitch = 0; vec dir(d->ai->targyaw, d->ai->targpitch); d->ai->spot = vec(d->feetpos()).add(dir.mul(CLOSEDIST)); d->ai->targnode = -1; } gameent *e = game::getclient(d->ai->enemy); if(passive()) enemyok = false; else if(!(enemyok = (e && targetable(d, e, true))) || d->skill >= 50 || d->ai->dontmove) { gameent *f = game::intersectclosest(d->o, d->ai->target, d); if(f) { if(targetable(d, f, true)) { if(!enemyok) violence(d, b, f, weaptype[d->weapselect].melee ? 1 : 0); enemyok = true; e = f; } else enemyok = false; // would hit non-targetable person } else if((!enemyok || d->ai->dontmove) && target(d, b, weaptype[d->weapselect].melee ? 1 : 0, d->ai->dontmove)) enemyok = (e = game::getclient(d->ai->enemy)) != NULL; } if(enemyok) { bool alt = altfire(d, e); vec ep = getaimpos(d, e, alt); float yaw, pitch; game::getyawpitch(d->o, ep, yaw, pitch); game::fixrange(yaw, pitch); bool insight = cansee(d, d->o, e->o), hasseen = d->ai->enemyseen && lastmillis-d->ai->enemyseen <= (d->skill*10)+1000, quick = d->ai->enemyseen && lastmillis-d->ai->enemyseen <= (W2(d->weapselect, fullauto, alt) ? W2(d->weapselect, delayattack, alt)*3 : skmod*3)+skmod*3; if(insight) d->ai->enemyseen = lastmillis; if(d->ai->dontmove || insight || hasseen || quick) { frame *= insight || d->skill > 100 ? 1.5f : (hasseen || quick ? 1.25f : 1.f); if(lockon(d, e, actor[d->actortype].canstrafe ? 32 : 16, weaptype[d->weapselect].melee)) { frame *= 2.f; b.acttype = AI_A_LOCKON; d->ai->dontmove = false; d->ai->targyaw = yaw; d->ai->targpitch = pitch; d->ai->spot = e->feetpos(); } game::scaleyawpitch(d->yaw, d->pitch, yaw, pitch, frame, frame*0.75f); bool shoot = canshoot(d, e, alt); if(d->action[alt ? AC_SECONDARY : AC_PRIMARY] && W2(d->weapselect, cooktime, alt) && W2(d->weapselect, cooked, alt)) { // TODO: make AI more aware of what they're shooting int cooked = W2(d->weapselect, cooked, alt); if(cooked&8) shoot = false; // inverted life } if(shoot && hastarget(d, b, e, alt, insight || (!d->ai->dontmove && quick), yaw, pitch)) { d->action[alt ? AC_SECONDARY : AC_PRIMARY] = true; d->actiontime[alt ? AC_SECONDARY : AC_PRIMARY] = lastmillis; firing = true; } occupied = true; } else enemyok = false; } if(!enemyok) { d->ai->enemy = -1; d->ai->enemyseen = d->ai->enemymillis = 0; } if(!firing) d->action[AC_PRIMARY] = d->action[AC_SECONDARY] = false; game::fixrange(d->ai->targyaw, d->ai->targpitch); if(!occupied) { if(!m_insta(game::gamemode, game::mutators)) { if(b.acttype == AI_A_NORMAL && (d->health <= m_health(game::gamemode, game::mutators, d->model)/3 || (iswaypoint(d->ai->targnode) && obstacles.find(d->ai->targnode, d)))) b.acttype = AI_A_HASTE; if(b.acttype == AI_A_HASTE) frame *= 1+(max(m_health(game::gamemode, game::mutators, d->model)/3, 1)/float(max(d->health, 1))); } else frame *= 2; game::scaleyawpitch(d->yaw, d->pitch, d->ai->targyaw, d->ai->targpitch, frame, frame*0.5f); } if(actor[d->actortype].canjump) jumpto(d, b, d->ai->spot); if((d->actortype == A_BOT || d->actortype == A_GRUNT) && d->action[AC_CROUCH] != d->ai->dontmove) if((d->action[AC_CROUCH] = !d->action[AC_CROUCH]) == true) d->actiontime[AC_CROUCH] = lastmillis; if(d->ai->dontmove || (d->actortype >= A_ENEMY && lastmillis-d->lastpain <= PHYSMILLIS/3)) d->move = d->strafe = 0; else if(!actor[d->actortype].canmove || !actor[d->actortype].canstrafe) { d->move = actor[d->actortype].canmove ? 1 : 0; d->strafe = 0; } else { // our guys move one way.. but turn another?! :) const struct aimdir { int move, strafe, offset; } aimdirs[8] = { { 1, 0, 0 }, { 1, -1, 45 }, { 0, -1, 90 }, { -1, -1, 135 }, { -1, 0, 180 }, { -1, 1, 225 }, { 0, 1, 270 }, { 1, 1, 315 } }; float yaw = d->ai->targyaw-d->yaw; while(yaw < 0.0f) yaw += 360.0f; while(yaw >= 360.0f) yaw -= 360.0f; const aimdir &ad = aimdirs[clamp(((int)floor((yaw+22.5f)/45.0f))&7, 0, 7)]; d->move = ad.move; d->strafe = ad.strafe; } if(!actor[d->actortype].canstrafe && d->move && enemyok && lockon(d, e, 8, weaptype[d->weapselect].melee)) d->move = 0; findorientation(d->o, d->yaw, d->pitch, d->ai->target); } bool hasrange(gameent *d, gameent *e, int weap) { if(!targetable(d, e)) return false; loopk(2) { float dist = e->o.squaredist(d->o); if(weaprange(d, weap, k!=0, dist)) return true; } return false; } bool request(gameent *d, aistate &b) { int sweap = m_weapon(game::gamemode, game::mutators); bool occupied = false, firing = false, enemyok = false, haswaited = d->weapwaited(d->weapselect, lastmillis, (1<<W_S_RELOAD)); process(d, b, occupied, firing, enemyok); if(d->actortype == A_BOT) { if(d->ai->dontmove && haswaited && !firing && d->carry(sweap, 1) > 1) { loopirev(W_ITEM) if(i != weappref(d) && d->candrop(i, sweap, lastmillis, m_loadout(game::gamemode, game::mutators), (1<<W_S_SWITCH)|(1<<W_S_RELOAD))) { client::addmsg(N_DROP, "ri3", d->clientnum, lastmillis-game::maptime, i); d->setweapstate(d->weapselect, W_S_WAIT, weaponswitchdelay, lastmillis); d->ai->lastaction = lastmillis; return true; } } if(haswaited && !firing && !d->action[AC_USE]) { static vector<actitem> actitems; actitems.setsize(0); vec pos = d->center(); float radius = max(d->height*0.5f, max(d->xradius, d->yradius)); if(entities::collateitems(d, pos, radius, actitems)) { while(!actitems.empty()) { actitem &t = actitems.last(); int ent = -1; switch(t.type) { case actitem::ENT: { if(!entities::ents.inrange(t.target)) break; extentity &e = *entities::ents[t.target]; if(enttype[e.type].usetype != EU_ITEM || e.type != WEAPON) break; ent = t.target; break; } case actitem::PROJ: { if(!projs::projs.inrange(t.target)) break; projent &proj = *projs::projs[t.target]; if(!entities::ents.inrange(proj.id)) break; extentity &e = *entities::ents[proj.id]; if(enttype[e.type].usetype != EU_ITEM || e.type != WEAPON || proj.owner == d) break; ent = proj.id; break; } default: break; } if(entities::ents.inrange(ent)) { extentity &e = *entities::ents[ent]; int attr = w_attr(game::gamemode, game::mutators, e.type, e.attrs[0], sweap); if(d->canuse(e.type, attr, e.attrs, sweap, lastmillis, (1<<W_S_SWITCH)|(1<<W_S_RELOAD))) { if(!wantsweap(d, attr)) break; d->action[AC_USE] = true; d->ai->lastaction = d->actiontime[AC_USE] = lastmillis; return true; } } actitems.pop(); } } } } bool timepassed = d->weapstate[d->weapselect] == W_S_IDLE && (d->ammo[d->weapselect] <= 0 || lastmillis-d->weaplast[d->weapselect] >= max(6000-(d->skill*50), weaponswitchdelay)); if(!firing && (!occupied || d->ammo[d->weapselect] <= 0) && timepassed && d->hasweap(d->weapselect, sweap) && weapons::weapreload(d, d->weapselect)) { d->ai->lastaction = lastmillis; return true; } if(!firing && timepassed) { int weap = weappref(d); gameent *e = game::getclient(d->ai->enemy); if(!isweap(weap) || !d->hasweap(weap, sweap) || (e && !hasrange(d, e, weap))) { loopirev(W_MAX) if(i >= W_MELEE && d->hasweap(i, sweap) && (!e || hasrange(d, e, i))) { weap = i; break; } } if(isweap(weap) && weap != d->weapselect && weapons::weapselect(d, weap, (1<<W_S_SWITCH)|(1<<W_S_RELOAD))) { d->ai->lastaction = lastmillis; return true; } } return occupied; } bool transport(gameent *d, int find = 0) { vec pos = d->feetpos(); static vector<int> candidates; candidates.setsize(0); if(find) findwaypointswithin(pos, WAYPOINTRADIUS, RETRYDIST*find, candidates); if(find ? !candidates.empty() : !d->ai->route.empty()) loopk(2) { int best = -1; float dist = 1e16f; loopv(find ? candidates : d->ai->route) { int n = find ? candidates[i] : d->ai->route[i]; if((k || (!d->ai->hasprevnode(n) && n != d->lastnode)) && !obstacles.find(n, d)) { float v = waypoints[n].o.squaredist(pos); if(!iswaypoint(best) || v < dist) { best = n; dist = v; } } } if(iswaypoint(best)) { d->o = waypoints[best].o; d->o.z += d->height; d->resetinterp(); return true; } } if(find <= 1) return transport(d, find+1); return false; } void timeouts(gameent *d, aistate &b) { if(d->blocked || (d->inmaterial&MATF_CLIP) == MAT_AICLIP) { d->ai->blocktime += lastmillis-d->ai->lastrun; if(d->ai->blocktime > (d->ai->blockseq+1)*500) { d->ai->blockseq++; switch(d->ai->blockseq) { case 1: break; case 2: d->ai->clear(d->ai->blockseq != 1); if(d->ai->blockseq != 1 && iswaypoint(d->ai->targnode)) { if(!d->ai->hasprevnode(d->ai->targnode)) d->ai->addprevnode(d->ai->targnode); waypoints[d->ai->targnode].weight = -1; wpavoid.avoidnear(NULL, waypoints[d->ai->targnode].o.z + WAYPOINTRADIUS, waypoints[d->ai->targnode].o, WAYPOINTRADIUS); } break; case 3: if(!transport(d)) d->ai->reset(false); break; case 4: default: if(b.type != AI_S_WAIT) { game::suicide(d, HIT_LOST); return; } // this is our last resort.. else d->ai->blockseq = 0; // waiting, so just try again.. break; } if(aidebug >= 7 && dbgfocus(d)) conoutf("%s blocked %dms sequence %d", game::colourname(d), d->ai->blocktime, d->ai->blockseq); } } else d->ai->blocktime = d->ai->blockseq = 0; if(iswaypoint(d->ai->targnode) && (d->ai->targnode == d->ai->targlast || d->ai->hasprevnode(d->ai->targnode))) { d->ai->targtime += lastmillis-d->ai->lastrun; if(d->ai->targtime > (d->ai->targseq+1)*500) { d->ai->targseq++; switch(d->ai->targseq) { case 1: break; case 2: d->ai->clear(d->ai->targseq != 1); if(iswaypoint(d->ai->targnode) && !d->ai->hasprevnode(d->ai->targnode)) d->ai->addprevnode(d->ai->targnode); break; case 3: if(!transport(d)) d->ai->reset(false); break; case 4: default: if(b.type != AI_S_WAIT) { game::suicide(d, HIT_LOST); return; } // this is our last resort.. else d->ai->blockseq = 0; // waiting, so just try again.. break; } if(aidebug >= 7 && dbgfocus(d)) conoutf("%s targeted %d too long %dms sequence %d", game::colourname(d), d->ai->targnode, d->ai->targtime, d->ai->targseq); } } else { d->ai->targtime = d->ai->targseq = 0; d->ai->targlast = d->ai->targnode; } } void logic(gameent *d, aistate &b) { if(d->speedscale != 0) { if(d->state != CS_ALIVE || !game::allowmove(d)) d->stopmoving(true); else { if(!request(d, b)) target(d, b, weaptype[d->weapselect].melee ? 1 : 0); weapons::shoot(d, d->ai->target); } } if(d->state == CS_DEAD || d->state == CS_WAITING) { if(d->ragdoll) moveragdoll(d, true); else if(lastmillis-d->lastpain < 5000) physics::move(d, 1, false); } else { if(d->ragdoll) cleanragdoll(d); if(d->state == CS_ALIVE && gs_playing(game::gamestate)) { if(d->speedscale != 0) { physics::move(d, 1, true); if(actor[d->actortype].canmove && !d->ai->dontmove) timeouts(d, b); } else { d->move = d->strafe = 0; physics::move(d, 1, true); } } } if(gs_playing(game::gamestate) && (d->state == CS_ALIVE || d->state == CS_DEAD || d->state == CS_WAITING)) entities::checkitems(d); } void avoid() { float guessradius = max(actor[A_PLAYER].xradius, actor[A_PLAYER].yradius); obstacles.clear(); int numdyns = game::numdynents(); loopi(numdyns) { gameent *d = (gameent *)game::iterdynents(i); if(!d) continue; // || d->actortype >= A_ENEMY) continue; if(d->state != CS_ALIVE || !physics::issolid(d)) continue; obstacles.avoidnear(d, d->o.z + d->aboveeye + 1, d->feetpos(), guessradius + d->radius + 1); } obstacles.add(wpavoid); loopv(projs::projs) { projent *p = projs::projs[i]; if(p && p->state == CS_ALIVE && p->projtype == PRJ_SHOT) { float expl = WX(WK(p->flags), p->weap, explode, WS(p->flags), game::gamemode, game::mutators, p->curscale); if(expl > 0) obstacles.avoidnear(p, p->o.z + expl, p->o, guessradius + expl + 1); } } loopi(entities::lastent(MAPMODEL)) if(entities::ents[i]->type == MAPMODEL && !entities::ents[i]->spawned()) { gameentity &e = *(gameentity *)entities::ents[i]; bool skip = false; loopvk(e.links) if(entities::ents.inrange(e.links[k])) { gameentity &f = *(gameentity *)entities::ents[e.links[k]]; if(f.type != TRIGGER || !m_check(f.attrs[5], f.attrs[6], game::gamemode, game::mutators)) continue; if(f.attrs[2] != TA_AUTO || (f.attrs[1] != TR_TOGGLE && f.attrs[1] != TR_LINK)) continue; skip = true; break; } if(skip) continue; mapmodelinfo *mmi = getmminfo(e.attrs[0]); if(!mmi || !mmi->m) continue; vec center, radius; mmi->m->collisionbox(center, radius); if(e.attrs[5]) { center.mul(e.attrs[5]/100.f); radius.mul(e.attrs[5]/100.f); } if(!mmi->m->ellipsecollide) rotatebb(center, radius, int(e.attrs[1]), int(e.attrs[2])); obstacles.avoidnear(NULL, e.o.z + radius.z, e.o, max(radius.x, max(radius.y, radius.z)) + WAYPOINTRADIUS); } } void think(gameent *d, bool run) { // the state stack works like a chain of commands, certain commands simply replace each other // others spawn new commands to the stack the ai reads the top command from the stack and executes // it or pops the stack and goes back along the history until it finds a suitable command to execute bool cleannext = false; if(d->ai->state.empty()) d->ai->addstate(AI_S_WAIT); loopvrev(d->ai->state) { aistate &c = d->ai->state[i]; if(c.owner >= 0) { gameent *e = game::getclient(c.owner); if(!e || e->team != d->team) c.owner = -1; } if(cleannext) { c.millis = lastmillis; c.override = false; cleannext = false; } if(d->state == CS_DEAD) { if(d->respawned < 0 && (!d->lastdeath || lastmillis-d->lastdeath > (d->actortype == A_BOT ? 500 : enemyspawntime))) { client::addmsg(N_TRYSPAWN, "ri", d->clientnum); d->respawned = lastmillis; } } else if(d->state == CS_ALIVE && run) { bool result = false; c.acttype = m_insta(game::gamemode, game::mutators) ? AI_A_HASTE : AI_A_NORMAL; switch(c.type) { case AI_S_WAIT: result = dowait(d, c); break; case AI_S_DEFEND: result = dodefense(d, c); break; case AI_S_PURSUE: result = dopursue(d, c); break; case AI_S_INTEREST: result = dointerest(d, c); break; default: result = 0; break; } if(!result && c.type != AI_S_WAIT) { d->ai->removestate(i); cleannext = true; continue; // logic is run on working states } } logic(d, c); break; } if(d->ai->tryreset) d->ai->reset(); d->ai->lastrun = lastmillis; } void drawroute(gameent *d, float amt) { int colour = game::getcolour(d, game::playerdisplaytone), last = -1; loopvrev(d->ai->route) { if(d->ai->route.inrange(last)) { int index = d->ai->route[i], prev = d->ai->route[last]; if(iswaypoint(index) && iswaypoint(prev)) { waypoint &w = waypoints[index], &v = waypoints[prev]; vec fr = v.o, dr = w.o; fr.z += amt; dr.z += amt; part_trace(fr, dr, 1, 1, 1, colour); } } last = i; } if(aidebug >= 5) { vec pos = d->feetpos(); if(!d->ai->spot.iszero()) part_trace(pos, d->ai->spot, 1, 1, 1, 0x00FFFF); if(iswaypoint(d->ai->targnode)) part_trace(pos, waypoints[d->ai->targnode].o, 1, 1, 1, 0xFF00FF); if(iswaypoint(d->lastnode)) part_trace(pos, waypoints[d->lastnode].o, 1, 1, 1, 0xFFFF00); loopi(NUMPREVNODES) if(iswaypoint(d->ai->prevnodes[i])) { part_trace(pos, waypoints[d->ai->prevnodes[i]].o, 1, 1, 1, 0x884400); pos = waypoints[d->ai->prevnodes[i]].o; } } } const char *stnames[AI_S_MAX] = { "wait", "defend", "pursue", "interest" }, *sttypes[AI_T_MAX+1] = { "none", "node", "actor", "affinity", "entity", "drop" }, *attypes[AI_A_MAX] = { "normal", "idle", "lockon", "protect", "haste" }; void render() { if(aidebug >= 2) { int total = 0, alive = 0; loopv(game::players) if(game::players[i] && dbgfocus(game::players[i])) total++; loopv(game::players) if(game::players[i] && game::players[i]->state == CS_ALIVE && dbgfocus(game::players[i])) { gameent *d = game::players[i]; vec pos = d->abovehead(); pos.z += 3; alive++; if(aidebug >= 4 && actor[d->actortype].canmove) drawroute(d, 4.f*(float(alive)/float(total))); if(aidebug >= 3) { defformatstring(q)("node: %d route: %d (%d)", d->lastnode, !d->ai->route.empty() ? d->ai->route[0] : -1, d->ai->route.length() ); part_textcopy(pos, q); pos.z += 2; } bool top = true; loopvrev(d->ai->state) { aistate &b = d->ai->state[i]; gameent *e = b.owner >= 0 ? game::getclient(b.owner) : NULL; defformatstring(s)("%s%s (%s) %s:%d (\fs%s%s\fS%s%s%s)", top ? "<default>\fg" : "<sub>\fa", stnames[b.type], timestr(lastmillis-b.millis), sttypes[b.targtype+1], b.target, top ? "\fc" : "\fw", attypes[b.acttype], e ? " [" : "", e ? game::colourname(e) : "", e ? "]" : "" ); part_textcopy(pos, s); pos.z += 2; if(top) { if(aidebug >= 3) top = false; else break; } } if(aidebug >= 3) { if(isweap(weappref(d))) { part_textcopy(pos, W(weappref(d), name)); pos.z += 2; } gameent *e = game::getclient(d->ai->enemy); if(e) { part_textcopy(pos, game::colourname(e)); pos.z += 2; } } } if(aidebug >= 4) { int cur = 0; loopv(obstacles.obstacles) { const avoidset::obstacle &ob = obstacles.obstacles[i]; int next = cur + ob.numwaypoints; for(; cur < next; cur++) { int ent = obstacles.waypoints[cur]; if(iswaypoint(ent)) part_create(PART_EDIT, 1, waypoints[ent].o, 0xFF6600, 2); } cur = next; } } } if(showwaypoints || (dropwaypoints && showwaypointsdrop) || aidebug >= 7) { vector<int> close; int len = waypoints.length(), col = vec::hexcolor(showwaypointscolour).mul(0.5f).tohexcolor(); if(showwaypointsradius) { findwaypointswithin(camera1->o, 0, showwaypointsradius, close); len = close.length(); } loopi(len) { int idx = showwaypointsradius ? close[i] : i; waypoint &w = waypoints[idx]; if(!w.haslinks()) part_create(PART_EDIT, 1, w.o, showwaypointscolour, 1.f); else loopj(MAXWAYPOINTLINKS) { int link = w.links[j]; if(!link) break; waypoint &v = waypoints[link]; bool both = false; loopk(MAXWAYPOINTLINKS) if(v.links[k] == idx) { both = true; break; } part_trace(w.o, v.o, 1, 1, 1, both ? showwaypointscolour : col); } } if(game::player1->state == CS_ALIVE && iswaypoint(game::player1->lastnode)) part_trace(game::player1->feetpos(), waypoints[game::player1->lastnode].o, 1, 1, 1, 0xFFFF00); } } void preload() { loopi(A_TOTAL) loopk(3) preloadmodel(actor[i+A_ENEMY].playermodel[1]); } void botsay(gameent *d, int flags, const char *fmt, ...) { defvformatbigstring(msg, fmt, fmt); client::addmsg(N_TEXT, "ri2s", d->clientnum, flags, msg); } void scanchat(gameent *d, int flags, const char *text) { if((!m_edit(game::gamemode) && !m_team(game::gamemode, game::mutators)) || flags&SAY_ACTION || d->actortype != A_PLAYER) return; bigstring msg; filterbigstring(msg, text, true, true, true, true); const int MAXWORDS = 8; int numargs = MAXWORDS, reply = flags&SAY_TEAM ? SAY_TEAM : SAY_NONE; char *w[MAXWORDS]; const char *p = (const char *)msg; loopi(MAXWORDS) { w[i] = (char *)""; if(i > numargs) continue; char *s = parsetext(p); if(s) w[i] = s; else numargs = i; } if(*w[0]) loopvj(game::players) if(game::players[j] && game::players[j]->actortype == A_BOT && game::players[j]->ai) { gameent *e = game::players[j]; if(!m_edit(game::gamemode) && d->team != e->team) continue; if(strncmp(w[0], "bots", 4)) { size_t len = strlen(e->name); if(!len || strncasecmp(w[0], e->name, len)) continue; switch(w[0][len]) { case 0: break; case ':': case ',': case ';': len++; break; default: continue; } if(w[0][len] != 0) continue; } int pos = 1; const char *affirm[4] = { "roger", "okay", "will do", "i'm on it" }; if(!strcasecmp(w[pos], "defend")) { pos++; if(!strcasecmp(w[pos], "me")) { e->ai->clear(); e->ai->addstate(AI_S_DEFEND, AI_T_ACTOR, d->clientnum, AI_A_PROTECT, d->clientnum); botsay(e, reply, "%s: %s, defending you", d->name, affirm[rnd(4)]); } else if(!strcasecmp(w[pos], "here")) { e->ai->clear(); e->ai->addstate(AI_S_DEFEND, AI_T_NODE, e->lastnode, AI_A_PROTECT, d->clientnum); botsay(e, reply, "%s: %s, defending your position", d->name, affirm[rnd(4)]); } else { bool defend = false; gameent *f = NULL; int numdyns = game::numdynents(); loopi(numdyns) if((f = (gameent *)game::iterdynents(i)) && f != e && f->team == e->team && !strcmp(w[pos], f->name)) { e->ai->clear(); e->ai->addstate(AI_S_DEFEND, AI_T_ACTOR, f->clientnum, AI_A_PROTECT, d->clientnum); botsay(e, reply, "%s: %s, defending %s", d->name, affirm[rnd(4)], f->name); defend = true; break; } if(!defend) { if(!strcasecmp(w[pos], "the")) pos++; switch(game::gamemode) { case G_CAPTURE: { if(!strcasecmp(w[pos], "flag")) { loopv(capture::st.flags) if(capture::st.flags[i].team == e->team) { e->ai->clear(); e->ai->addstate(AI_S_DEFEND, AI_T_AFFINITY, i, AI_A_PROTECT, d->clientnum); botsay(e, reply, "%s: %s, defending the flag", d->name, affirm[rnd(4)]); break; } } #if 0 else if(!strcasecmp(w[pos], "base")) { loopv(capture::st.flags) if(capture::st.flags[i].team == e->team) { e->ai->clear(); e->ai->addstate(AI_S_DEFEND, AI_T_ENTITY, capture::st.flags[i].ent, AI_A_PROTECT, d->clientnum); botsay(e, reply, "%s: %s, defending base for the flag", d->name, affirm[rnd(4)]); break; } } #endif else botsay(e, reply, "%s: 'me', 'here', or 'flag'", d->name); break; } case G_BOMBER: { if(!strcasecmp(w[pos], "goal") || !strcasecmp(w[pos], "base")) { loopv(bomber::st.flags) if(!isbomberaffinity(bomber::st.flags[i]) && bomber::st.flags[i].team == e->team) { e->ai->clear(); e->ai->addstate(AI_S_DEFEND, AI_T_AFFINITY, i, AI_A_PROTECT, d->clientnum); botsay(e, reply, "%s: %s, defending the goal", d->name, affirm[rnd(4)]); break; } } else botsay(e, reply, "%s: 'me', 'here', or 'goal'", d->name); break; } default: botsay(e, reply, "%s: 'me', or 'here'", d->name); break; } } } } else if(!strcasecmp(w[pos], "attack")) { pos++; if(!strcasecmp(w[pos], "the")) pos++; switch(game::gamemode) { case G_CAPTURE: { if(!strcasecmp(w[pos], "flag")) { loopv(capture::st.flags) if(capture::st.flags[i].team != e->team) { e->ai->clear(); e->ai->addstate(AI_S_PURSUE, AI_T_AFFINITY, i, AI_A_HASTE, d->clientnum); botsay(e, reply, "%s: %s, attacking the flag", d->name, affirm[rnd(4)]); break; } } #if 0 else if(!strcasecmp(w[pos], "base")) { loopv(capture::st.flags) if(capture::st.flags[i].team != e->team) { e->ai->clear(); e->ai->addstate(AI_S_DEFEND, AI_T_ENTITY, capture::st.flags[i].ent, AI_A_HASTE, d->clientnum); botsay(e, reply, "%s: %s, attacking the flag", d->name, affirm[rnd(4)]); break; } } #endif else botsay(e, reply, "%s: 'flag' is the only option", d->name); break; } case G_BOMBER: { if(!strcasecmp(w[pos], "goal") || !strcasecmp(w[pos], "base")) { loopv(bomber::st.flags) if(!isbomberaffinity(bomber::st.flags[i]) && bomber::st.flags[i].team != e->team) { e->ai->clear(); e->ai->addstate(AI_S_PURSUE, AI_T_AFFINITY, i, AI_A_HASTE, d->clientnum); botsay(e, reply, "%s: %s, attacking the goal", d->name, affirm[rnd(4)]); break; } } else if(!strcasecmp(w[pos], "ball")) { loopv(bomber::st.flags) if(isbomberaffinity(bomber::st.flags[i])) { e->ai->clear(); e->ai->addstate(AI_S_PURSUE, AI_T_AFFINITY, i, AI_A_HASTE, d->clientnum); botsay(e, reply, "%s: %s, attacking the ball", d->name, affirm[rnd(4)]); break; } } else botsay(e, reply, "%s: 'goal', or 'ball'", d->name); break; } default: botsay(e, reply, "%s: sorry, no attack directions in this game", d->name); break; } } else if(!strcasecmp(w[pos], "forget")) { loopvrev(e->ai->state) if(e->ai->state[i].owner == d->clientnum) e->ai->state.remove(i); const char *quip[4] = { "back to what i was doing then", "resuming previous operations", "i am no longer your slave", "jolly good show then" }; botsay(e, reply, "%s: %s, %s", d->name, affirm[rnd(4)], quip[rnd(4)]); } else if(!strcasecmp(w[pos], "reset")) { e->ai->reset(true, false); const char *quip[4] = { "what was i doing again?", "duh... off i go..", "who were you again?", "ummmm... wtf do i do now?" }; botsay(e, reply, "%s: %s, %s", d->name, affirm[rnd(4)], quip[rnd(4)]); } else botsay(e, reply, "%s: 'defend', 'attack', 'forget', or 'reset'", d->name); } loopi(numargs) DELETEA(w[i]); } }
[ "qreeves@gmail.com" ]
qreeves@gmail.com
0debc6fe4db172429d86f74492fd90eeb60e372b
24eab1d005ee7fa30b9d1ac3a20560375cd35e3e
/dictionarySimple.hxx
d0ff91613fb7f11ca4b3dbe3cdba0a226481a74b
[]
no_license
KatarzynaMialkowska/Dictionary_and_Set
efd2adc2e8b4286def06c947eea35c1f1d93dcd9
927ec9cf891df2359becf98111a65c7fed5a929d
refs/heads/master
2023-08-21T08:56:04.012377
2021-09-30T14:26:51
2021-09-30T14:26:51
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,763
hxx
#pragma once #include <iostream> #include <vector> #include <iterator> #include <algorithm> #include <ctime> #include <random> #include <iomanip> #include <string> constexpr int N = 100; class DictonarySimple { std::string set[N]{""}; int size = 0; public: DictonarySimple() = default; DictonarySimple(const DictonarySimple& obj): set(obj.set), size(obj.size) { for(int i = 0; i<N; i++){ set[i] = obj.set[i]; } } DictonarySimple operator+(const DictonarySimple &obj) { DictonarySimple result(*this); for(int i = 0; i<N; i++) { if(obj.set[i] != set[i]) { result.set[result.size] = obj.set[i]; result.size++; } } return result; } DictonarySimple operator&&(DictonarySimple &obj) { DictonarySimple result; for(int i = 0; i<N; i++) { if(obj.set[i]==set[i]) result.set[i] == obj.set[i]; } return result; } DictonarySimple operator-(DictonarySimple &obj) { DictonarySimple result(*this); for(int i = 0; i<N; i++) { if(obj.set[i]==set[i]) result.set[i]==""; } return result; } bool operator==(const DictonarySimple &obj) { for(int i = 0; i<N; i++) { if(obj.set[i]!=set[i]) return false; } return true; } bool operator!=(const DictonarySimple &obj) { return !(*this==obj); } void insert(std::string x) { if(size>=0 && size<N) { if(!find(x)) set[size] = x; size++; }else std::cout<<"size error\n"; } bool find(std::string x) { for(int i = 0; i < size; i++) if(set[i] == x) return true; return false; } void del(std::string x) { for(int i = 0; i < size; i++) if(set[i] == x) set[i] = ""; if(size>0) size--; } void view() { for(int i = 0; i < size; i++) { std::cout<<set[i]<<" "; } std::cout<<'\n'; } int Size() { return size; } std::string getElement(int id) { if(id>=0 && id<N) return set[id]; else "not exist\n"; } }; void generator(DictonarySimple& obj, const int& n) { static std::uniform_int_distribution<int> dist1 ( 97, 122 ); static std::mt19937 gen ( time ( NULL ) ); std::string word; for( int i = 0; i < n; i++ ) { word+=(char)dist1(gen); word+=(char)dist1(gen); obj.insert(word); word = ""; } }
[ "catherinemialkowska@gmail.com" ]
catherinemialkowska@gmail.com
0050c9732ffe547f2a0c055e1021b83059533074
9065bdf8946e476270f5f86c29fa154f8fdbc85d
/vpr/src/power/power_sizing.cpp
883c168b8d853f83d69aaea9e53490542becf61d
[ "MIT", "MIT-Modern-Variant", "LicenseRef-scancode-unknown-license-reference" ]
permissive
helloworld1983/vtr-verilog-to-routing-1
d6bf4f333eac89d9cf57101948bc3d03341d539f
edcaa9d4a6ce2a8a3e52b3ce4afd60bb37e966f8
refs/heads/master
2022-12-23T20:59:38.357108
2018-07-27T13:40:37
2018-07-27T13:40:37
174,370,682
0
1
NOASSERTION
2022-12-18T12:48:42
2019-03-07T15:27:38
C
UTF-8
C++
false
false
26,429
cpp
/********************************************************************* * The following code is part of the power modelling feature of VTR. * * For support: * http://code.google.com/p/vtr-verilog-to-routing/wiki/Power * * or email: * vtr.power.estimation@gmail.com * * If you are using power estimation for your researach please cite: * * Jeffrey Goeders and Steven Wilton. VersaPower: Power Estimation * for Diverse FPGA Architectures. In International Conference on * Field Programmable Technology, 2012. * ********************************************************************/ /** * The functions in this file are used to count the transistors in the * FPGA, for physical size estimations */ /************************* INCLUDES *********************************/ #include <cstring> #include <cmath> using namespace std; #include "vtr_util.h" #include "vtr_assert.h" #include "vtr_memory.h" #include "power_sizing.h" #include "power.h" #include "globals.h" #include "power_util.h" #include "vpr_utils.h" /************************ FILE SCOPE *********************************/ static double f_MTA_area; /************************* FUNCTION DECLARATIONS ********************/ static double power_count_transistors_connectionbox(); static double power_count_transistors_mux(t_mux_arch * mux_arch); static double power_count_transistors_mux_node(t_mux_node * mux_node, float transistor_size); static void power_mux_node_max_inputs(t_mux_node * mux_node, float * max_inputs); static double power_count_transistors_interc(t_interconnect * interc); static double power_count_transistors_pb_node(t_pb_graph_node * pb_node); static double power_count_transistors_switchbox(const t_arch * arch); static double power_count_transistors_primitive(t_pb_type * pb_type); static double power_count_transistors_LUT(int LUT_inputs, float transistor_size); static double power_count_transistors_FF(float size); static double power_count_transistor_SRAM_bit(); static double power_count_transistors_inv(float size); static double power_count_transistors_trans_gate(float size); static double power_count_transistors_levr(); static void power_size_pin_buffers_and_wires(t_pb_graph_pin * pin, bool pin_is_an_input); static double power_transistors_for_pb_node(t_pb_graph_node * pb_node); static double power_transistors_per_tile(const t_arch * arch); static void power_size_pb(); static void power_size_pb_rec(t_pb_graph_node * pb_node); static void power_size_pin_to_interconnect(t_interconnect * interc, int * fanout, float * wirelength); static double power_MTAs(float W_size); static double power_MTAs_L(float L_size); /************************* FUNCTION DEFINITIONS *********************/ /** * Counts the number of transistors in the largest connection box */ static double power_count_transistors_connectionbox() { double transistor_cnt = 0.; int inputs; float buffer_size; auto& device_ctx = g_vpr_ctx.device(); auto& power_ctx = g_vpr_ctx.power(); auto type = find_most_common_block_type(device_ctx.grid); VTR_ASSERT(type->pb_graph_head->num_input_ports == 1); inputs = type->pb_graph_head->num_input_pins[0]; /* Buffers from Tracks */ buffer_size = power_ctx.commonly_used->max_seg_to_IPIN_fanout * (power_ctx.commonly_used->NMOS_1X_C_d / power_ctx.commonly_used->INV_1X_C_in) / power_ctx.arch->logical_effort_factor; buffer_size = max(1.0F, buffer_size); transistor_cnt += power_ctx.solution_inf.channel_width * power_count_transistors_buffer(buffer_size); /* Muxes to IPINs */ transistor_cnt += inputs * power_count_transistors_mux( power_get_mux_arch(power_ctx.commonly_used->max_IPIN_fanin, power_ctx.arch->mux_transistor_size)); return transistor_cnt; } /** * Counts the number of transistors in a buffer. * - buffer_size: The final stage size of the buffer, relative to a minimum sized inverter */ double power_count_transistors_buffer(float buffer_size) { int stages; float effort; float stage_size; int stage_idx; double transistor_cnt = 0.; auto& power_ctx = g_vpr_ctx.power(); stages = power_calc_buffer_num_stages(buffer_size, power_ctx.arch->logical_effort_factor); effort = calc_buffer_stage_effort(stages, buffer_size); stage_size = 1; for (stage_idx = 0; stage_idx < stages; stage_idx++) { transistor_cnt += power_count_transistors_inv(stage_size); stage_size *= effort; } return transistor_cnt; } /** * Counts the number of transistors in a multiplexer * - mux_arch: The architecture of the multiplexer */ static double power_count_transistors_mux(t_mux_arch * mux_arch) { double transistor_cnt = 0.; int lvl_idx; float * max_inputs; /* SRAM bits */ max_inputs = (float*) vtr::calloc(mux_arch->levels, sizeof(float)); for (lvl_idx = 0; lvl_idx < mux_arch->levels; lvl_idx++) { max_inputs[lvl_idx] = 0.; } power_mux_node_max_inputs(mux_arch->mux_graph_head, max_inputs); for (lvl_idx = 0; lvl_idx < mux_arch->levels; lvl_idx++) { /* Assume there is decoder logic */ transistor_cnt += ceil(log(max_inputs[lvl_idx]) / log((double) 2.0)) * power_count_transistor_SRAM_bit(); /* if (mux_arch->encoding_types[lvl_idx] == ENCODING_DECODER) { transistor_cnt += ceil(log2((float)max_inputs[lvl_idx])) * power_cnt_transistor_SRAM_bit(); // TODO - Size of decoder } else if (mux_arch->encoding_types[lvl_idx] == ENCODING_ONE_HOT) { transistor_cnt += max_inputs[lvl_idx] * power_cnt_transistor_SRAM_bit(); } else { VTR_ASSERT(0); } */ } transistor_cnt += power_count_transistors_mux_node(mux_arch->mux_graph_head, mux_arch->transistor_size); free(max_inputs); return transistor_cnt; } /** * This function is used recursively to determine the largest single-level * multiplexer at each level of a multi-level multiplexer */ static void power_mux_node_max_inputs(t_mux_node * mux_node, float * max_inputs) { max_inputs[mux_node->level] = max(max_inputs[mux_node->level], static_cast<float>(mux_node->num_inputs)); if (mux_node->level != 0) { int child_idx; for (child_idx = 0; child_idx < mux_node->num_inputs; child_idx++) { power_mux_node_max_inputs(&mux_node->children[child_idx], max_inputs); } } } /** * This function is used recursively to count the number of transistors in a multiplexer */ static double power_count_transistors_mux_node(t_mux_node * mux_node, float transistor_size) { int input_idx; double transistor_cnt = 0.; if (mux_node->num_inputs != 1) { for (input_idx = 0; input_idx < mux_node->num_inputs; input_idx++) { /* Single Pass transistor */ transistor_cnt += power_MTAs(transistor_size); /* Child MUX */ if (mux_node->level != 0) { transistor_cnt += power_count_transistors_mux_node( &mux_node->children[input_idx], transistor_size); } } } return transistor_cnt; } /** * This function returns the number of transistors in an interconnect structure */ static double power_count_transistors_interc(t_interconnect * interc) { double transistor_cnt = 0.; switch (interc->type) { case DIRECT_INTERC: /* No transistors */ break; case MUX_INTERC: case COMPLETE_INTERC: { /* Bus based interconnect: * - Each output port requires a (num_input_ports:1) bus-based multiplexor. * - The number of muxes required for bus based multiplexors is equivalent to * the width of the bus (num_pins_per_port). */ auto& power_ctx = g_vpr_ctx.power(); transistor_cnt += interc->interconnect_power->num_output_ports * interc->interconnect_power->num_pins_per_port * power_count_transistors_mux( power_get_mux_arch( interc->interconnect_power->num_input_ports, power_ctx.arch->mux_transistor_size)); break; } default: VTR_ASSERT(0); } interc->interconnect_power->transistor_cnt = transistor_cnt; return transistor_cnt; } void power_sizing_init(const t_arch * arch) { float transistors_per_tile; auto& power_ctx = g_vpr_ctx.power(); // tech size = 2 lambda, so lambda^2/4.0 = tech^2 f_MTA_area = ((POWER_MTA_L * POWER_MTA_W)/ 4.0)*pow(power_ctx.tech->tech_size, (float) 2.0); // Determines physical size of different PBs power_size_pb(); /* Find # of transistors in each tile type */ transistors_per_tile = power_transistors_per_tile(arch); /* Calculate CLB tile size * - Assume a square tile * - Assume min transistor size is Wx6L * - Assume an overhead to space transistors */ power_ctx.commonly_used->tile_length = sqrt( power_transistor_area(transistors_per_tile)); } /** * This functions counts the number of transistors in all structures in the FPGA. * It returns the number of transistors in a grid of the FPGA (logic block, * switch box, 2 connection boxes) */ static double power_transistors_per_tile(const t_arch * arch) { auto& device_ctx = g_vpr_ctx.device(); double transistor_cnt = 0.; auto type = find_most_common_block_type(device_ctx.grid); transistor_cnt += power_transistors_for_pb_node(type->pb_graph_head); transistor_cnt += 2 * power_count_transistors_switchbox(arch); transistor_cnt += 2 * power_count_transistors_connectionbox(); return transistor_cnt; } static double power_transistors_for_pb_node(t_pb_graph_node * pb_node) { return pb_node->pb_node_power->transistor_cnt_interc + pb_node->pb_node_power->transistor_cnt_pb_children + pb_node->pb_node_power->transistor_cnt_buffers; } /** * This function counts the number of transistors for a given physical block type */ static double power_count_transistors_pb_node(t_pb_graph_node * pb_node) { int mode_idx; int interc; int child; int pb_idx; double tc_children_max = 0; double tc_interc_max = 0; bool ignore_interc = false; t_pb_type * pb_type = pb_node->pb_type; /* Check if this is a leaf node, or whether it has children */ if (pb_type->num_modes == 0) { /* Leaf node */ tc_interc_max = 0; tc_children_max = power_count_transistors_primitive(pb_type); } else { /* Find max transistor count between all modes */ for (mode_idx = 0; mode_idx < pb_type->num_modes; mode_idx++) { double tc_children = 0; double tc_interc = 0; t_mode * mode = &pb_type->modes[mode_idx]; if (pb_type->class_type == LUT_CLASS) { /* LUTs will have a child node that is used for routing purposes * For the routing algorithms it is completely connected; however, * this interconnect does not exist in FPGA hardware and should * be ignored for power calculations. */ ignore_interc = true; } /* Count Interconnect Transistors */ if (!ignore_interc) { for (interc = 0; interc < mode->num_interconnect; interc++) { tc_interc += power_count_transistors_interc( &mode->interconnect[interc]); } } tc_interc_max = max(tc_interc_max, tc_interc); /* Count Child PB Types */ for (child = 0; child < mode->num_pb_type_children; child++) { t_pb_type * child_type = &mode->pb_type_children[child]; for (pb_idx = 0; pb_idx < child_type->num_pb; pb_idx++) { tc_children += power_transistors_for_pb_node( &pb_node->child_pb_graph_nodes[mode_idx][child][pb_idx]); } } tc_children_max = max(tc_children_max, tc_children); } } pb_node->pb_node_power->transistor_cnt_interc = tc_interc_max; pb_node->pb_node_power->transistor_cnt_pb_children = tc_children_max; return (tc_interc_max + tc_children_max); } /** * This function counts the maximum number of transistors in a switch box */ static double power_count_transistors_switchbox(const t_arch * arch) { double transistor_cnt = 0.; double transistors_per_buf_mux = 0.; int seg_idx; auto& power_ctx = g_vpr_ctx.power(); /* Buffer */ transistors_per_buf_mux += power_count_transistors_buffer( (float) power_ctx.commonly_used->max_seg_fanout / power_ctx.arch->logical_effort_factor); /* Multiplexor */ transistors_per_buf_mux += power_count_transistors_mux( power_get_mux_arch(power_ctx.commonly_used->max_routing_mux_size, power_ctx.arch->mux_transistor_size)); for (seg_idx = 0; seg_idx < arch->num_segments; seg_idx++) { /* In each switchbox, the different types of segments occur with relative freqencies. * Thus the total number of wires of each segment type is (#tracks * freq * 2). * The (x2) factor accounts for vertical and horizontal tracks. * Of the wires of each segment type only (1/seglength) will have a mux&buffer. */ float freq_frac = (float) arch->Segments[seg_idx].frequency / (float) MAX_CHANNEL_WIDTH; transistor_cnt += transistors_per_buf_mux * 2 * freq_frac * power_ctx.solution_inf.channel_width * (1 / (float) arch->Segments[seg_idx].length); } return transistor_cnt; } /** * This function calculates the number of transistors for a primitive physical block */ static double power_count_transistors_primitive(t_pb_type * pb_type) { double transistor_cnt; auto& power_ctx = g_vpr_ctx.power(); if (strcmp(pb_type->blif_model, MODEL_NAMES) == 0) { /* LUT */ transistor_cnt = power_count_transistors_LUT(pb_type->num_input_pins, power_ctx.arch->LUT_transistor_size); } else if (strcmp(pb_type->blif_model, MODEL_LATCH) == 0) { /* Latch */ transistor_cnt = power_count_transistors_FF(power_ctx.arch->FF_size); } else { /* Other */ char msg[vtr::bufsize]; sprintf(msg, "No transistor counter function for BLIF model: %s", pb_type->blif_model); power_log_msg(POWER_LOG_WARNING, msg); transistor_cnt = 0; } return transistor_cnt; } /** * Returns the transistor count of an SRAM cell */ static double power_count_transistor_SRAM_bit() { auto& power_ctx = g_vpr_ctx.power(); return power_ctx.arch->transistors_per_SRAM_bit; } static double power_count_transistors_levr() { double transistor_cnt = 0.; /* Each level restorer has a P/N=1/2 inverter and a W/L=1/2 PMOS */ /* Inverter */ transistor_cnt += power_MTAs(2); // NMOS transistor_cnt += 1.0; // PMOS /* Pull-up */ transistor_cnt += power_MTAs_L(2.0); // Double length return transistor_cnt; } /** * Returns the transistor count for a LUT */ static double power_count_transistors_LUT(int LUT_inputs, float transistor_size) { double transistor_cnt = 0.; int level_idx; /* Each input driver has 1-1X and 2-2X inverters */ transistor_cnt += (double) LUT_inputs * (power_count_transistors_inv(1.0) + 2 * power_count_transistors_inv(2.0)); /* SRAM bits */ transistor_cnt += power_count_transistor_SRAM_bit() * (1 << LUT_inputs); for (level_idx = 0; level_idx < LUT_inputs; level_idx++) { /* Pass transistors */ transistor_cnt += (1 << (LUT_inputs - level_idx)) * power_MTAs(transistor_size); /* Add level restorer after every 2 stages (level_idx %2 == 1) * But if there is an odd # of stages, just put one at the last * stage (level_idx == LUT_size - 1) and not at the stage just before * the last stage (level_idx != LUT_size - 2) */ if (((level_idx % 2 == 1) && (level_idx != LUT_inputs - 2)) || (level_idx == LUT_inputs - 1)) { transistor_cnt += power_count_transistors_levr(); } } return transistor_cnt; } static double power_count_transistors_trans_gate(float size) { double transistor_cnt = 0.; auto& power_ctx = g_vpr_ctx.power(); transistor_cnt += power_MTAs(size); transistor_cnt += power_MTAs(size * power_ctx.tech->PN_ratio); return transistor_cnt; } static double power_count_transistors_inv(float size) { double transistor_cnt = 0.; auto& power_ctx = g_vpr_ctx.power(); /* NMOS */ transistor_cnt += power_MTAs(size); /* PMOS */ transistor_cnt += power_MTAs(power_ctx.tech->PN_ratio * size); return transistor_cnt; } /** * Returns the transistor count for a flip-flop */ static double power_count_transistors_FF(float size) { double transistor_cnt = 0.; /* 4 1X Inverters */ transistor_cnt += 4 * power_count_transistors_inv(size); /* 2 Muxes = 4 transmission gates */ transistor_cnt += 4 * power_count_transistors_trans_gate(size); return transistor_cnt; } double power_transistor_area(double num_MTAs) { return num_MTAs * f_MTA_area; } static double power_MTAs(float W_size) { return 1 + (W_size - 1) * (POWER_DRC_MIN_W / POWER_MTA_W); } static double power_MTAs_L(float L_size) { return 1 + (L_size - 1) * (POWER_DRC_MIN_L / POWER_MTA_L); } static void power_size_pb() { int type_idx; auto& device_ctx = g_vpr_ctx.device(); for (type_idx = 0; type_idx < device_ctx.num_block_types; type_idx++) { if (device_ctx.block_types[type_idx].pb_graph_head) { power_size_pb_rec(device_ctx.block_types[type_idx].pb_graph_head); } } } static void power_size_pb_rec(t_pb_graph_node * pb_node) { int port_idx, pin_idx; int mode_idx, type_idx, pb_idx; bool size_buffers_and_wires = true; auto& device_ctx = g_vpr_ctx.device(); auto type = find_most_common_block_type(device_ctx.grid); if (!power_method_is_transistor_level( pb_node->pb_type->pb_type_power->estimation_method) && pb_node != type->pb_graph_head) { /* Area information is only needed for: * 1. Transistor-level estimation methods * 2. the most common block type for tile size calculations */ return; } /* Recursive call for all child pb nodes */ for (mode_idx = 0; mode_idx < pb_node->pb_type->num_modes; mode_idx++) { t_mode * mode = &pb_node->pb_type->modes[mode_idx]; for (type_idx = 0; type_idx < mode->num_pb_type_children; type_idx++) { int num_pb = mode->pb_type_children[type_idx].num_pb; for (pb_idx = 0; pb_idx < num_pb; pb_idx++) { power_size_pb_rec( &pb_node->child_pb_graph_nodes[mode_idx][type_idx][pb_idx]); } } } /* Determine # of transistors for this node */ power_count_transistors_pb_node(pb_node); if (pb_node->pb_type->class_type == LUT_CLASS) { /* LUTs will have a child node that is used for routing purposes * For the routing algorithms it is completely connected; however, * this interconnect does not exist in FPGA hardware and should * be ignored for power calculations. */ size_buffers_and_wires = false; } if (!power_method_is_transistor_level( pb_node->pb_type->pb_type_power->estimation_method)) { size_buffers_and_wires = false; } /* Size all local buffers and wires */ if (size_buffers_and_wires) { for (port_idx = 0; port_idx < pb_node->num_input_ports; port_idx++) { for (pin_idx = 0; pin_idx < pb_node->num_input_pins[port_idx]; pin_idx++) { power_size_pin_buffers_and_wires( &pb_node->input_pins[port_idx][pin_idx], true); } } for (port_idx = 0; port_idx < pb_node->num_output_ports; port_idx++) { for (pin_idx = 0; pin_idx < pb_node->num_output_pins[port_idx]; pin_idx++) { power_size_pin_buffers_and_wires( &pb_node->output_pins[port_idx][pin_idx], false); } } for (port_idx = 0; port_idx < pb_node->num_clock_ports; port_idx++) { for (pin_idx = 0; pin_idx < pb_node->num_clock_pins[port_idx]; pin_idx++) { power_size_pin_buffers_and_wires( &pb_node->clock_pins[port_idx][pin_idx], true); } } } } /* Provides statistics about the connection between the pin and interconnect */ static void power_size_pin_to_interconnect(t_interconnect * interc, int * fanout, float * wirelength) { float this_interc_sidelength; /* Pin to interconnect wirelength */ switch (interc->type) { case DIRECT_INTERC: *wirelength = 0; *fanout = 1; break; case MUX_INTERC: case COMPLETE_INTERC: /* The sidelength of this crossbar */ this_interc_sidelength = sqrt( power_transistor_area( interc->interconnect_power->transistor_cnt)); /* Assume that inputs to the crossbar have a structure like this: * * A B|----- * -----|---C- * |----- * * A - wire from pin to point of fanout (grows pb interconnect area) * B - fanout wire (sidelength of this crossbar) * C - fanouts to crossbar muxes (grows with pb interconnect area) */ *fanout = interc->interconnect_power->num_output_ports; *wirelength = this_interc_sidelength; //*wirelength = ((1 + *fanout) / 2.0) * power_ctx.arch->local_interc_factor // * pb_interc_sidelength + this_interc_sidelength; break; default: VTR_ASSERT(0); break; } } static void power_size_pin_buffers_and_wires(t_pb_graph_pin * pin, bool pin_is_an_input) { int edge_idx; int list_cnt; t_interconnect ** list; bool found; int i; float C_load; float this_pb_length; int fanout; float wirelength_out = 0; float wirelength_in = 0; int fanout_tmp = 0; float wirelength_tmp = 0; float this_pb_interc_sidelength = 0; float parent_pb_interc_sidelength = 0; bool top_level_pb; t_pb_type * this_pb_type = pin->parent_node->pb_type; auto& power_ctx = g_vpr_ctx.power(); /* if (strcmp(pin->parent_node->pb_type->name, "clb") == 0) { //vtr::printf_info("here\n"); }*/ this_pb_interc_sidelength = sqrt( power_transistor_area( pin->parent_node->pb_node_power->transistor_cnt_interc)); if (pin->parent_node->parent_pb_graph_node == nullptr) { top_level_pb = true; parent_pb_interc_sidelength = 0.; } else { top_level_pb = false; parent_pb_interc_sidelength = sqrt( power_transistor_area( pin->parent_node->parent_pb_graph_node->pb_node_power->transistor_cnt_interc)); } /* Pins are connected to a wire that is connected to: * 1. Interconnect structures belonging its pb_node, and/or * - The pb_node may have one or more modes, each with a set of * interconnect. The capacitance is the worst-case capacitance * between the different modes. * * 2. Interconnect structures belonging to its parent pb_node */ /* We want to estimate the physical pin fan-out, unfortunately it is not defined in the architecture file. * Instead, we know the modes of operation, and the fanout may differ depending on the mode. We assume * that the physical fanout is the max of the connections to the various modes (although in reality it could * be higher)*/ /* Loop through all edges, building a list of interconnect that this pin drives */ list = nullptr; list_cnt = 0; for (edge_idx = 0; edge_idx < pin->num_output_edges; edge_idx++) { /* Check if its already in the list */ found = false; for (i = 0; i < list_cnt; i++) { if (list[i] == pin->output_edges[edge_idx]->interconnect) { found = true; break; } } if (!found) { list_cnt++; list = (t_interconnect**) vtr::realloc(list, list_cnt * sizeof(t_interconnect*)); list[list_cnt - 1] = pin->output_edges[edge_idx]->interconnect; } } /* Determine the: * 1. Wirelength connected to the pin * 2. Fanout of the pin */ if (pin_is_an_input) { /* Pin is an input to the PB. * Thus, all interconnect it drives belong to the modes of the PB. */ int * fanout_per_mode; float * wirelength_out_per_mode; fanout_per_mode = (int*) vtr::calloc(this_pb_type->num_modes, sizeof(int)); wirelength_out_per_mode = (float *) vtr::calloc(this_pb_type->num_modes, sizeof(float)); for (i = 0; i < list_cnt; i++) { int mode_idx = list[i]->parent_mode_index; power_size_pin_to_interconnect(list[i], &fanout_tmp, &wirelength_tmp); fanout_per_mode[mode_idx] += fanout_tmp; wirelength_out_per_mode[mode_idx] += wirelength_tmp; } fanout = 0; wirelength_out = 0.; /* Find worst-case between modes*/ for (i = 0; i < this_pb_type->num_modes; i++) { fanout = max(fanout, fanout_per_mode[i]); wirelength_out = max(wirelength_out, wirelength_out_per_mode[i]); } if (wirelength_out != 0) { wirelength_out += power_ctx.arch->local_interc_factor * this_pb_interc_sidelength; } free(fanout_per_mode); free(wirelength_out_per_mode); /* Input wirelength - from parent PB */ if (!top_level_pb) { wirelength_in = power_ctx.arch->local_interc_factor * parent_pb_interc_sidelength; } } else { /* Pin is an output of the PB. * Thus, all interconnect it drives belong to the parent PB. */ fanout = 0; wirelength_out = 0.; if (top_level_pb) { /* Outputs of top-level pb should not drive interconnect */ VTR_ASSERT(list_cnt == 0); } /* Loop through all interconnect that this pin drives */ for (i = 0; i < list_cnt; i++) { power_size_pin_to_interconnect(list[i], &fanout_tmp, &wirelength_tmp); fanout += fanout_tmp; wirelength_out += wirelength_tmp; } if (wirelength_out != 0) { wirelength_out += power_ctx.arch->local_interc_factor * parent_pb_interc_sidelength; } /* Input wirelength - from this PB */ wirelength_in = power_ctx.arch->local_interc_factor * this_pb_interc_sidelength; } free(list); /* Wirelength */ switch (pin->port->port_power->wire_type) { case POWER_WIRE_TYPE_IGNORED: /* User is ignoring this wirelength */ pin->pin_power->C_wire = 0.; break; case POWER_WIRE_TYPE_C: pin->pin_power->C_wire = pin->port->port_power->wire.C; break; case POWER_WIRE_TYPE_ABSOLUTE_LENGTH: pin->pin_power->C_wire = pin->port->port_power->wire.absolute_length * power_ctx.arch->C_wire_local; break; case POWER_WIRE_TYPE_RELATIVE_LENGTH: this_pb_length = sqrt( power_transistor_area( power_transistors_for_pb_node(pin->parent_node))); pin->pin_power->C_wire = pin->port->port_power->wire.relative_length * this_pb_length * power_ctx.arch->C_wire_local; break; case POWER_WIRE_TYPE_AUTO: pin->pin_power->C_wire += power_ctx.arch->C_wire_local * (wirelength_in + wirelength_out); break; case POWER_WIRE_TYPE_UNDEFINED: default: VTR_ASSERT(0); break; } /* Buffer */ switch (pin->port->port_power->buffer_type) { case POWER_BUFFER_TYPE_NONE: /* User assumes no buffer */ pin->pin_power->buffer_size = 0.; break; case POWER_BUFFER_TYPE_ABSOLUTE_SIZE: pin->pin_power->buffer_size = pin->port->port_power->buffer_size; break; case POWER_BUFFER_TYPE_AUTO: /* Asume the buffer drives the wire & fanout muxes */ C_load = pin->pin_power->C_wire + (fanout) * power_ctx.commonly_used->INV_1X_C_in; //power_ctx.commonly_used->NMOS_1X_C_d; if (C_load > power_ctx.commonly_used->INV_1X_C_in) { pin->pin_power->buffer_size = power_buffer_size_from_logical_effort( C_load); } else { pin->pin_power->buffer_size = 0.; } break; case POWER_BUFFER_TYPE_UNDEFINED: default: VTR_ASSERT(0); } pin->parent_node->pb_node_power->transistor_cnt_buffers += power_count_transistors_buffer(pin->pin_power->buffer_size); }
[ "kmurray@users.noreply.github.com" ]
kmurray@users.noreply.github.com
13ce73653465e2036db52342b3885781e1885d56
9b80574d56cc577dd5eea2412ed6682e0f4b52a3
/SquiLu/sqstdlib/sqstdmath.cpp
b83392fedaf140975b1b5b39c3c5515d77521b86
[ "MIT" ]
permissive
renshijun/squilu
f055ecc615b332de74e0fa2112b491dfbe6f0810
2647a62551d72acef8e72711cb6608ebc32cf25e
refs/heads/master
2020-04-22T08:31:34.774939
2019-01-25T11:28:18
2019-01-25T11:28:18
170,245,028
0
1
null
2019-02-12T03:27:26
2019-02-12T03:27:25
null
UTF-8
C++
false
false
13,693
cpp
/* see copyright notice in squirrel.h */ #include <squirrel.h> #include <math.h> //#include <float.h> #include <limits.h> #include <stdlib.h> #include <sqstdmath.h> /* Some useful constants. */ #ifndef M_E # define M_E 2.7182818284590452354 /* e */ #endif #ifndef M_LOG2E # define M_LOG2E 1.4426950408889634074 /* log_2 e */ #endif #ifndef M_LOG10E # define M_LOG10E 0.43429448190325182765 /* log_10 e */ #endif #ifndef M_LN2 # define M_LN2 0.69314718055994530942 /* log_e 2 */ #endif #ifndef M_LN10 # define M_LN10 (2.30258509299404568402) /* log_e 10 */ #endif #ifndef M_PI # define M_PI (3.14159265358979323846) /* pi */ #endif #ifndef M_PI_2 # define M_PI_2 (1.57079632679489661923) /* pi/2 */ #endif #ifndef M_PI_4 # define M_PI_4 (0.78539816339744830962) /* pi/4 */ #endif #ifndef M_1_PI # define M_1_PI (0.31830988618379067154) /* 1/pi */ #endif #ifndef M_2_PI # define M_2_PI (0.63661977236758134308) /* 2/pi */ #endif #ifndef M_2_SQRTPI # define M_2_SQRTPI (1.12837916709551257390) /* 2/sqrt(pi) */ #endif #ifndef M_SQRT2 # define M_SQRT2 (1.41421356237309504880) /* sqrt(2) */ #endif #ifndef M_SQRT1_2 # define M_SQRT1_2 (0.70710678118654752440) /* 1/sqrt(2) */ #endif #define SINGLE_ARG_FUNC(_funcname) static SQRESULT math_##_funcname(HSQUIRRELVM v){ \ SQFloat f; \ sq_getfloat(v,2,&f); \ sq_pushfloat(v,(SQFloat)_funcname(f)); \ return 1; \ } #define TWO_ARGS_FUNC(_funcname) static SQRESULT math_##_funcname(HSQUIRRELVM v){ \ SQFloat p1,p2; \ sq_getfloat(v,2,&p1); \ sq_getfloat(v,3,&p2); \ sq_pushfloat(v,(SQFloat)_funcname(p1,p2)); \ return 1; \ } #define BOOL_SINGLE_ARG_FUNC(_funcname) static SQRESULT math_##_funcname(HSQUIRRELVM v){ \ SQFloat f; \ sq_getfloat(v,2,&f); \ sq_pushbool(v,(SQBool)_funcname(f)); \ return 1; \ } static SQRESULT math_srand(HSQUIRRELVM v) { SQInteger i; if(SQ_FAILED(sq_getinteger(v,2,&i))) return sq_throwerror(v,_SC("invalid param")); srand((unsigned int)i); return 0; } static SQRESULT math_rand(HSQUIRRELVM v) { sq_pushinteger(v,rand()); return 1; } static SQRESULT math_random(HSQUIRRELVM v) { SQ_FUNC_VARS(v); SQInteger low, up; SQFloat r = (SQFloat)rand() * (1.0 / ((SQFloat)RAND_MAX + 1.0)); switch (_top_) { /* check number of arguments */ case 1: { /* no arguments */ sq_pushfloat(v, r); /* Number between 0 and 1 */ return 1; } case 2: { /* only upper limit */ low = 1; SQ_GET_INTEGER_NVD(v, 2, up); break; } case 3: { /* lower and upper limits */ SQ_GET_INTEGER_NVD(v, 2, low); SQ_GET_INTEGER_NVD(v, 3, up); break; } default: return sq_throwerror(v, _SC("wrong number of arguments")); } /* random integer in the interval [low, up] */ if(low >= up) return sq_throwerror(v, _SC("interval is empty")); if(low <= 0 && up >= SQ_INT_MAX + low) return sq_throwerror(v, _SC("interval too large")); r *= (SQFloat)(up - low) + 1.0; sq_pushinteger(v, (SQInteger)r + low); return 1; } static SQRESULT math_abs(HSQUIRRELVM v) { SQInteger n; sq_getinteger(v,2,&n); sq_pushinteger(v,(SQInteger)::abs(n)); return 1; } static SQRESULT math_log(HSQUIRRELVM v) { SQ_FUNC_VARS(v); SQ_GET_FLOAT(v, 2, num); switch (_top_) { /* check number of arguments */ case 2: { /* only num */ sq_pushfloat(v,log(num)); break; } case 3: { /* num and base */ SQ_GET_FLOAT(v, 3, base); sq_pushfloat(v,log(num)/log(base)); break; } } return 1; } SINGLE_ARG_FUNC(sqrt) SINGLE_ARG_FUNC(fabs) SINGLE_ARG_FUNC(sin) SINGLE_ARG_FUNC(asin) SINGLE_ARG_FUNC(cos) SINGLE_ARG_FUNC(acos) //SINGLE_ARG_FUNC(log) SINGLE_ARG_FUNC(log10) SINGLE_ARG_FUNC(tan) SINGLE_ARG_FUNC(atan) TWO_ARGS_FUNC(atan2) TWO_ARGS_FUNC(pow) SINGLE_ARG_FUNC(floor) SINGLE_ARG_FUNC(ceil) SINGLE_ARG_FUNC(exp) SINGLE_ARG_FUNC(acosh) SINGLE_ARG_FUNC(asinh) SINGLE_ARG_FUNC(tanh) SINGLE_ARG_FUNC(atanh) BOOL_SINGLE_ARG_FUNC(isnan) BOOL_SINGLE_ARG_FUNC(isfinite) //DAD start #include <string.h> #include <stdio.h> #include <ctype.h> SQ_OPT_STRING_STRLEN() /* mathB_roundf: rounds real value x to the d-th digit; patched Dec 22, 2007 for negative values */ static SQRESULT math_roundf (HSQUIRRELVM v) { SQ_FUNC_VARS(v); SQ_GET_FLOAT(v, 2, x); SQ_OPT_INTEGER(v, 3, dec_places, 0); SQFloat dec_factor; if( dec_places>15 || dec_places<0 ) return sq_throwerror(v, _SC("decimal places out of range 0-15")); switch(dec_places){ case 0: dec_factor = 1.0; break; case 1: dec_factor = 10.0; break; case 2: dec_factor = 100.0; break; case 3: dec_factor = 1000.0; break; case 4: dec_factor = 10000.0; break; case 5: dec_factor = 100000.0; break; case 6: dec_factor = 1000000.0; break; default: dec_factor = pow((double)10.0, dec_places); } if (x < 0) sq_pushfloat(v, ceil(dec_factor*x-0.5) / dec_factor); else sq_pushfloat(v, floor(dec_factor*x+0.5) / dec_factor); return 1; } static SQRESULT math_broundf (HSQUIRRELVM v) { SQ_FUNC_VARS(v); SQ_GET_FLOAT(v, 2, num); SQ_OPT_INTEGER(v, 3, dec_places, 0); SQFloat dec_factor, tmp, itmp; int neg; if( dec_places>15 || dec_places<0 ) return sq_throwerror(v, _SC("decimal places out of range 0-15")); neg = num < 0; switch(dec_places){ case 0: dec_factor = 1.0; break; case 1: dec_factor = 10.0; break; case 2: dec_factor = 100.0; break; case 3: dec_factor = 1000.0; break; case 4: dec_factor = 10000.0; break; case 5: dec_factor = 100000.0; break; case 6: dec_factor = 1000000.0; break; default: dec_factor = pow((double)10.0, dec_places); } tmp = num * dec_factor; itmp = floor(tmp + (neg ? -0.5 : 0.5)); // Handle rounding of .5 in a special manner if(tmp - floor(tmp) == 0.5){ tmp = itmp / 2; if(tmp != floor(tmp) ) { // Is itmp odd // Reduce Magnitude by 1 to make even if(neg) itmp++; else itmp--; } } sq_pushfloat(v, itmp / dec_factor); return 1; } static SQChar math_number_format_dec_point[2] = _SC("."); static SQChar math_number_format_thousand_sep[2] = _SC(","); static SQRESULT math_number_format_get_dec_point(HSQUIRRELVM v) { sq_pushstring(v, math_number_format_dec_point, -1); return 1; } static SQRESULT math_number_format_set_dec_point(HSQUIRRELVM v) { SQ_FUNC_VARS_NO_TOP(v); SQ_GET_STRING(v, 2, dec_point); math_number_format_dec_point[0] = *dec_point; math_number_format_dec_point[1] = _SC('\0'); return 0; } static SQRESULT math_number_format_get_thousand_sep(HSQUIRRELVM v) { sq_pushstring(v, math_number_format_thousand_sep, -1); return 1; } static SQRESULT math_number_format_set_thousand_sep(HSQUIRRELVM v) { SQ_FUNC_VARS_NO_TOP(v); SQ_GET_STRING(v, 2, thousand_sep); math_number_format_thousand_sep[0] = *thousand_sep; math_number_format_thousand_sep[1] = '\0'; return 0; } static SQRESULT math_number_format(HSQUIRRELVM v) { SQ_FUNC_VARS(v); SQ_GET_FLOAT(v, 2, d); SQ_OPT_INTEGER(v, 3, dec, 2); SQ_OPT_STRING(v, 4, dec_point, math_number_format_dec_point); SQ_OPT_STRING(v, 5, thousand_sep, math_number_format_thousand_sep); SQChar tmpbuf[64], resbuf[64]; SQChar *s, *t; /* source, target */ SQChar *dp; int integral; size_t tmplen, reslen=0; int count=0; int is_negative=0; int trim_right_zeros=0; if (d < 0) { is_negative = 1; d = -d; } if (dec < 0) { trim_right_zeros = 1; dec = -dec; } tmplen = scsprintf(tmpbuf, sizeof(tmpbuf), _SC("%.*f"), (int)dec, d); resbuf[0] = _SC('\0'); if (isdigit((int)tmpbuf[0])) { /* find decimal point, if expected */ if (dec) { dp = scstrpbrk(tmpbuf, _SC(".,")); } else { dp = NULL; } /* calculate the length of the return buffer */ if (dp) { integral = dp - tmpbuf; } else { /* no decimal point was found */ integral = tmplen; } /* allow for thousand separators */ if (*thousand_sep) { integral += (integral-1) / 3; } reslen = integral; if (dec) { reslen += dec; if (*dec_point) { reslen++; } } /* add a byte for minus sign */ if (is_negative) { reslen++; } if(sizeof(resbuf) >= reslen+1) { s = tmpbuf+tmplen-1; t = resbuf+reslen; *t-- = '\0'; /* copy the decimal places. * Take care, as the sprintf implementation may return less places than * we requested due to internal buffer limitations */ if (dec) { int declen = dp ? s - dp : 0; int topad = dec > declen ? dec - declen : 0; /* pad with '0's */ while (topad--) { *t-- = '0'; } if (dp) { s -= declen + 1; /* +1 to skip the point */ t -= declen; /* now copy the chars after the point */ memcpy(t + 1, dp + 1, declen); } /* add decimal point */ if (*dec_point) { *t-- = *dec_point; } } /* copy the numbers before the decimal point, adding thousand * separator every three digits */ while(s >= tmpbuf) { *t-- = *s--; if (*thousand_sep && (++count%3)==0 && s>=tmpbuf) { *t-- = *thousand_sep; } } /* and a minus sign, if needed */ if (is_negative) { *t-- = '-'; } /* trim right zeros */ if (*dec_point && trim_right_zeros) { for(t=resbuf+reslen-1; *t != *dec_point; t--){ if (*t == '0') *t = '\0'; else break; } if (*t == *dec_point) *t = '\0'; } } } sq_pushstring(v, resbuf, -1); return 1; } static SQRESULT math_ult(HSQUIRRELVM v) { SQ_FUNC_VARS_NO_TOP(v); SQ_GET_INTEGER(v, 2, n1); SQ_GET_INTEGER(v, 3, n2); sq_pushbool(v,((SQUnsignedInteger)n1) < ((SQUnsignedInteger)n2)); return 1; } static SQRESULT math_min (HSQUIRRELVM v) { SQInteger n = sq_gettop(v); /* number of arguments */ SQInteger imin = 2; /* index of current minimum value */ for (SQInteger i = 3; i <= n; i++) { if (sq_compare(v, i, imin) < 0) imin = i; } sq_push(v, imin); return 1; } static SQRESULT math_max (HSQUIRRELVM v) { SQInteger n = sq_gettop(v); /* number of arguments */ SQInteger imax = 2; /* index of current minimum value */ for (SQInteger i = 3; i <= n; i++) { if (sq_compare(v, i, imax) > 0) imax = i; } sq_push(v, imax); return 1; } static SQRESULT math_deg (HSQUIRRELVM v) { SQ_FUNC_VARS_NO_TOP(v); SQ_GET_FLOAT(v, 2, n); sq_pushfloat(v, n * (180.0 / M_PI)); return 1; } static SQRESULT math_rad (HSQUIRRELVM v) { SQ_FUNC_VARS_NO_TOP(v); SQ_GET_FLOAT(v, 2, n); sq_pushfloat(v, n * (M_PI / 180.0)); return 1; } //DAD end #define _DECL_FUNC(name,nparams,tycheck) {_SC(#name),math_##name,nparams,tycheck,false} static const SQRegFunction mathlib_funcs[] = { _DECL_FUNC(sqrt,2,_SC(".n")), _DECL_FUNC(sin,2,_SC(".n")), _DECL_FUNC(cos,2,_SC(".n")), _DECL_FUNC(asin,2,_SC(".n")), _DECL_FUNC(acos,2,_SC(".n")), _DECL_FUNC(log,-2,_SC(".nn")), _DECL_FUNC(log10,2,_SC(".n")), _DECL_FUNC(tan,2,_SC(".n")), _DECL_FUNC(atan,2,_SC(".n")), _DECL_FUNC(atan2,3,_SC(".nn")), _DECL_FUNC(pow,3,_SC(".nn")), _DECL_FUNC(floor,2,_SC(".n")), _DECL_FUNC(ceil,2,_SC(".n")), _DECL_FUNC(exp,2,_SC(".n")), _DECL_FUNC(srand,2,_SC(".n")), _DECL_FUNC(rand,1,NULL), _DECL_FUNC(random,-1,_SC(".ii")), _DECL_FUNC(fabs,2,_SC(".n")), _DECL_FUNC(abs,2,_SC(".n")), _DECL_FUNC(isnan,2,_SC(".n")), _DECL_FUNC(isfinite,2,_SC(".n")), _DECL_FUNC(roundf,-2,_SC(".ni")), _DECL_FUNC(broundf,-2,_SC(".ni")), _DECL_FUNC(number_format,-2,_SC(".niss")), _DECL_FUNC(number_format_get_dec_point,1,_SC(".")), _DECL_FUNC(number_format_set_dec_point,2,_SC(".s")), _DECL_FUNC(number_format_get_thousand_sep,1,_SC(".")), _DECL_FUNC(number_format_set_thousand_sep,2,_SC(".s")), _DECL_FUNC(ult,3,_SC(".nn")), _DECL_FUNC(min,-3,_SC(".nn")), _DECL_FUNC(max,-3,_SC(".nn")), _DECL_FUNC(rad,2,_SC(".n")), _DECL_FUNC(deg,2,_SC(".n")), _DECL_FUNC(asinh,2,_SC(".n")), _DECL_FUNC(acosh,2,_SC(".n")), _DECL_FUNC(tanh,2,_SC(".n")), _DECL_FUNC(atanh,2,_SC(".n")), {NULL,(SQFUNCTION)0,0,NULL,false} }; #undef _DECL_FUNC static void installFloatConst(HSQUIRRELVM v, const SQChar *skey, SQFloat fv) { sq_pushstring(v,skey,-1); sq_pushfloat(v,fv); sq_newslot(v,-3,SQFalse); } SQRESULT sqstd_register_mathlib(HSQUIRRELVM v) { sq_pushstring(v,_SC("math"),-1); sq_newtable(v); SQInteger i=0; while(mathlib_funcs[i].name!=0) { sq_pushstring(v,mathlib_funcs[i].name,-1); sq_newclosure(v,mathlib_funcs[i].f,0); sq_setparamscheck(v,mathlib_funcs[i].nparamscheck,mathlib_funcs[i].typemask); sq_setnativeclosurename(v,-1,mathlib_funcs[i].name); sq_newslot(v,-3,SQFalse); i++; } sq_pushstring(v,_SC("RAND_MAX"),-1); sq_pushinteger(v,RAND_MAX); sq_newslot(v,-3,SQFalse); installFloatConst(v, _SC("E"), (SQFloat)M_E); installFloatConst(v, _SC("LOG2E"), (SQFloat)M_LOG2E); installFloatConst(v, _SC("LOG10E"), (SQFloat)M_LOG10E); installFloatConst(v, _SC("LN2"), (SQFloat)M_LN2); installFloatConst(v, _SC("LN10"), (SQFloat)M_LN10); installFloatConst(v, _SC("PI"), (SQFloat)M_PI); installFloatConst(v, _SC("PI_2"), (SQFloat)M_PI_2); installFloatConst(v, _SC("PI_4"), (SQFloat)M_PI_4); installFloatConst(v, _SC("1_PI"), (SQFloat)M_1_PI); installFloatConst(v, _SC("2_PI"), (SQFloat)M_2_PI); installFloatConst(v, _SC("2_SQRTPI"), (SQFloat)M_2_SQRTPI); installFloatConst(v, _SC("SQRT2"), (SQFloat)M_SQRT2); installFloatConst(v, _SC("SQRT1_2"), (SQFloat)M_SQRT1_2); installFloatConst(v, _SC("HUGE"), (SQFloat)HUGE_VAL); /* installFloatConst(v, SC("DBL_MAX"), (SQFloat)DBL_MAX); installFloatConst(v, SC("DBL_MIN"), (SQFloat)DBL_MIN); */ sq_pushstring(v,_SC("INT_MAX"),-1); sq_pushinteger(v,SQ_INT_MAX); sq_newslot(v,-3,SQFalse); sq_pushstring(v,_SC("INT_MIN"),-1); sq_pushinteger(v,SQ_INT_MIN); sq_newslot(v,-3,SQFalse); sq_newslot(v,-3,SQTrue); //insert math return SQ_OK; }
[ "mingodad@gmail.com" ]
mingodad@gmail.com
9b1ed848e61a4926300523e442a8b2dd2b60544c
877fff5bb313ccd23d1d01bf23b1e1f2b13bb85a
/app/src/main/cpp/dir7941/dir29315/dir34411/file34491.cpp
91f8fe9a855981581ecd9badc1c5d221d2af0c47
[]
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 file34491 #error "macro file34491 must be defined" #endif static const char* file34491String = "file34491";
[ "tgeng@google.com" ]
tgeng@google.com
1ed6294155655db417d585a0995b5fa5083ea845
85ba69964514e625291ddacba45e66468978b9d2
/src/Misc.cpp
883f7237d0e58f7bf23b2d8ff5915769efc14576
[ "Apache-2.0", "LicenseRef-scancode-warranty-disclaimer" ]
permissive
Razdeep/Competitive-Programming-Starters-Kit
ad4730e2ed0a4c1f93dc8c029e59376cafcb70bc
9a6e012a51dd86ecbf3a2dde378d21321946fc7b
refs/heads/master
2023-03-10T20:21:52.196225
2023-03-01T04:39:42
2023-03-01T04:39:42
165,358,531
5
2
Apache-2.0
2023-03-01T04:39:43
2019-01-12T07:10:57
C++
UTF-8
C++
false
false
1,901
cpp
/** * Copyright 2019 Rajdeep Roy Chowdhury <rrajdeeproychowdhury@gmail.com> * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include "Misc.h" void cpsk::Misc::delay() { for (int i = 0; i < 100000; i++) { for (int j = 0; j < 1000; j++) { } } } void cpsk::Misc::delay(const long int ms) { // @TODO for (int i = 0; i < 10000; i++) { for (int j = 0; j < 1000; j++) { } } } void cpsk::Misc::drawLine(int n = 50) { for (int i = 0; i < n; i++) { std::cout << "-"; } std::cout << std::endl; } void cpsk::Misc::drawLine(const char ch, int n = 50) { for (int i = 0; i < n; i++) { std::cout << ch; } std::cout << std::endl; } void cpsk::Misc::drawLineTransition(unsigned int length, unsigned int delayms) { for (uint8_t i = 0; i < length; i++) { std::cout << "-"; std::cout.flush(); delay(100); } std::cout << std::endl; } void cpsk::Misc::drawLineTransition(const char ch, int n = 50, int ms = 50) { for (int i = 0; i < n; i++) { std::cout << ch; delay(100); } std::cout << std::endl; } void cpsk::Misc::transitionText(const std::string &str, int ms) { for (uint8_t i = 0; i < str.size(); i++) { std::cout << str[i]; std::cout.flush(); delay(ms); } std::cout << std::endl; }
[ "rrajdeeproychowdhury@gmail.com" ]
rrajdeeproychowdhury@gmail.com
5f670d589ac906d99a9ab22fade00fa5a43cb927
e2c0f5e5b311c3d511073db932d599ce12cc0f81
/DynRPG/include/DynRPG/Animation/AnimationFrame.hpp
0b6b85861c9d28ba01c494743aac118788221fe4
[]
no_license
ManDeJan/Cronus-Project
fc5f5112085bcee53ca6aac07b384b7b6d66c8b3
4f77584bc24591b5bc95ec282e57c56a7232718e
refs/heads/master
2023-05-10T06:57:00.319221
2021-05-25T14:58:08
2021-05-25T14:58:08
364,986,230
1
0
null
null
null
null
UTF-8
C++
false
false
569
hpp
#ifndef RPG_ANIMATION_FRAME_HPP #define RPG_ANIMATION_FRAME_HPP #include <DynRPG/Animation/AnimationFrameCel.hpp> #include <DynRPG/Catalog/CatalogPtr.hpp> namespace RPG { /*! \brief Used to define an animation's frame and its cels. \sa RPG::AnimationFrameCel \sa RPG::Animation \sa RPG::battleAnimations */ struct AnimationFrame { // clang-format off void** vTable; int id; //!< ID of the frame int _unknown_08; CatalogPtr<AnimationFrameCel*> cels; //!< Pointer to the RPG::AnimationFrameCel array // clang-format on }; } #endif // RPG_ANIMATION_FRAME_HPP
[ "janhlsm@gmail.com" ]
janhlsm@gmail.com
ebcf9297a0e57b2da0e5ba837b3a7a855aa0e6e6
76e81676497c28e02efaf9b40dff204fa8550731
/Project_3/Earth_Sun_system/UnitTesting.hpp
6afb9f5c6f2c4cf13efb5563d5cfcfc8156cdabd
[]
no_license
EirikBratli/FYS4150-3150
762631bed80ce0a4412ed996b6c92b94a0022d27
2467d8d3125a281c0423eadf1d30d081f5f2eeaf
refs/heads/master
2020-03-30T10:25:41.817368
2018-12-14T13:51:21
2018-12-14T13:51:21
151,119,381
0
1
null
null
null
null
UTF-8
C++
false
false
2,177
hpp
#include <iostream> #include <armadillo> #include <cmath> #include <fstream> #include <iomanip> using namespace arma; void EnergyTest (double v20, double v2N, double r0, double rN, double eps){ cout << "Testing energy conservation after one year" << endl; double pi = acos(-1); double GMsun = 4*pi*pi; double mass = 6e24/1.99e30; double K_init = 0.5 *mass*v20; double U_init = -GMsun*mass/r0; double K_final = 0.5 *mass*v2N; double U_final = -GMsun*mass/rN; double relerrorKin = fabs((K_init - K_final)); double relerrorPot = fabs((U_init - U_final)); if (relerrorKin < eps) { cout << " PASSED: Kinetic Energy is conserved, abs(K0-Kfinal) = "<< relerrorKin << endl; } else{ cout << " NOT PASSED: Kinetic Energy is not conserved, abs(K0-Kfinal) = " << relerrorKin << endl; } if (relerrorPot < eps) { cout << " PASSED: Potetial Energy is conserved, abs(U0-Ufinal) = "<< relerrorPot << endl; } else{ cout << " NOT PASSED: Potential Energy is not conserved, abs(U0-Ufinal) = " << relerrorPot << endl; } } void PositionTest(double r1, double r2, double eps){ cout << "Test for same x position after 1 year" << endl; if (fabs(r1 - r2) > eps){ cout << " NOT PASSED: To big difference in radius after a year " << fabs(r1 - r2)<< endl; } else{ cout << " PASSED: Circular orbit " << fabs(r1 - r2)<< endl; } } void AngularMomentumTest(mat pos, mat vel, double eps, int N){ cout << "Test for conservation of angualar momentum, r x p after one year" << endl; vec p0 = zeros(3); vec p1 = zeros(3); double diff=0; p0[0] = pos(1,0)*vel(2,0)-pos(2,0)*vel(1,0); p0[1] = pos(0,0)*vel(2,0)-pos(2,0)*vel(0,0); p0[2] = pos(0,0)*vel(1,0)-pos(1,0)*vel(0,0); p1[0] = pos(1,N-1)*vel(2,N-1)-pos(2,N-1)*vel(1,N-1); p1[1] = pos(0,N-1)*vel(2,N-1)-pos(2,N-1)*vel(0,N-1); p1[2] = pos(0,N-1)*vel(1,N-1)-pos(1,N-1)*vel(0,N-1); for (int i=0; i<3; i++){ diff = p1(i)-p0(i); } if (fabs(diff) < eps){ cout << " PASSED: Angular momentum is conserved" << endl; } else{ cout << " NOT PASSED: Angular momentum is not conserved. |p1-p0| = "<< fabs(diff) << " > eps" << endl; } }
[ "noreply@github.com" ]
noreply@github.com
edec4d1b919f08a4e715d91e47a9de139a152817
60a15a584b00895e47628c5a485bd1f14cfeebbe
/comps/misc/TestUI/InputPath.cpp
3755124d529feba7a1354accee72f05b82f4c147
[]
no_license
fcccode/vt5
ce4c1d8fe819715f2580586c8113cfedf2ab44ac
c88049949ebb999304f0fc7648f3d03f6501c65b
refs/heads/master
2020-09-27T22:56:55.348501
2019-06-17T20:39:46
2019-06-17T20:39:46
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,998
cpp
// InputPath.cpp : implementation file // #include "stdafx.h" #include "TestUI.h" #include "InputPath.h" #include "\vt5\comps\general\data\misc_types.h" // CInputPath dialog IMPLEMENT_DYNAMIC(CInputPathDlg, CDialog) CInputPathDlg::CInputPathDlg(CWnd* pParent /*=NULL*/) : CDialog(CInputPathDlg::IDD, pParent) { m_str_object_name.Empty(); m_str_type.Empty(); m_str_path.Empty(); } CInputPathDlg::~CInputPathDlg() { } void CInputPathDlg::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); DDX_Control(pDX, IDC_EDIT_PATH, m_ctrl_edit_path); DDX_Control(pDX, IDC_COMBO_TYPES, m_ctrl_combo_types); } BEGIN_MESSAGE_MAP(CInputPathDlg, CDialog) ON_CBN_SELCHANGE(IDC_COMBO_TYPES, OnCbnSelchangeComboTypes) ON_EN_CHANGE(IDC_EDIT_PATH, OnEnChangeEditPath) END_MESSAGE_MAP() // CInputPath message handlers BOOL CInputPathDlg::OnInitDialog() { AFX_MANAGE_STATE(AfxGetStaticModuleState()); CDialog::OnInitDialog(); // set object's name SetDlgItemText( IDC_EDIT_OBJ_NAME, m_str_object_name ); // init types m_ctrl_combo_types.ResetContent(); for( int i = 0; i < sizeof(g_VarCodes)/sizeof(g_VarCodes[0]); i++ ) { if( g_VarCodes[i].vt != VT_NULL && g_VarCodes[i].vt != VT_UNKNOWN && g_VarCodes[i].vt != VT_DISPATCH && g_VarCodes[i].vt != VT_BITS ) m_ctrl_combo_types.AddString( g_VarCodes[i].szUserName ); } // init path m_ctrl_edit_path.Clear(); // disable ok button update_ok(); return TRUE; } void CInputPathDlg::OnOK() { GetDlgItemText( IDC_EDIT_PATH, m_str_path ); GetDlgItemText( IDC_COMBO_TYPES, m_str_type ); __super::OnOK(); } void CInputPathDlg::OnCbnSelchangeComboTypes() { update_ok(); } void CInputPathDlg::OnEnChangeEditPath() { update_ok(); } void CInputPathDlg::update_ok() { CWnd *pWnd = 0; pWnd = GetDlgItem(IDOK); CString str_path( _T("") ); m_ctrl_edit_path.GetWindowText( str_path ); str_path.TrimLeft(); if( pWnd ) pWnd->EnableWindow( CB_ERR != m_ctrl_combo_types.GetCurSel() && !str_path.IsEmpty() ); }
[ "videotestc@gmail.com" ]
videotestc@gmail.com
dd13cef177924884d05157a6ab41ad5b08cb3c69
62e5263bc24bace515dd33e9d10465cdd393e19c
/client/client.hpp
d6c4015d838d1c283453e91288d8d64bcef529f0
[]
no_license
VladFear/Chat
72e24e20bf132958ad2b19b3ae35538773f3a15a
4219c251e13c62eec3537f16d610f1dea026453b
refs/heads/master
2020-09-04T16:07:32.805662
2019-11-13T19:31:32
2019-11-13T19:31:32
219,795,102
0
0
null
null
null
null
UTF-8
C++
false
false
359
hpp
#include <iostream> #include <unistd.h> #include <string.h> #include <arpa/inet.h> #include <sys/socket.h> class TcpClient { private: struct sockaddr_in serv_addr; int _socket; const short BUFFER_SIZE = 1024; public: TcpClient(); void create_socket(const int server_port); void connect_server() const; int send_data(std::string s) const; };
[ "onlylastfear1@gmail.com" ]
onlylastfear1@gmail.com
7c223368c82f2be4da5a84c7ad2bafd3bb7b047e
d984d3fb44a95082f3c15906e28ffefaf5de9a4e
/Source/TankVehicle/Private/TankVehicle.cpp
0fce642aee663dffc203763aaf5213961dbf031e
[]
no_license
alerdenisov/UE4_PhysXVehicleSnippets
1154d229300f720f46f3aa19c049eaaeeca2856a
a11734ab0d2145e8d4c58c8c84c2a710a4c5a08f
refs/heads/master
2021-07-10T21:48:22.695335
2017-10-09T07:07:02
2017-10-09T07:07:02
106,248,159
0
0
null
null
null
null
UTF-8
C++
false
false
670
cpp
// Copyright 1998-2017 Epic Games, Inc. All Rights Reserved. #include "TankVehicle.h" #define LOCTEXT_NAMESPACE "FTankVehicleModule" void FTankVehicleModule::StartupModule() { // This code will execute after your module is loaded into memory; the exact timing is specified in the .uplugin file per-module UE_LOG(LogTemp, Warning, TEXT("Tank Vehicle Plugin loaded")) } void FTankVehicleModule::ShutdownModule() { // This function may be called during shutdown to clean up your module. For modules that support dynamic reloading, // we call this function before unloading the module. } #undef LOCTEXT_NAMESPACE IMPLEMENT_MODULE(FTankVehicleModule, TankVehicle)
[ "aler.zampillo@gmail.com" ]
aler.zampillo@gmail.com
36f0477446bc29ed6b22ceac3a28f1aae975e94f
b9fa55c93ed47f8952eae8ced915e53ffcc6b75b
/graph/cycle_undirected.cpp
2c6567f876c4ab6c9088bde68f535a3f099269c6
[]
no_license
Prakash-sa/Competitive-Programming
954fba64afcc44ed9abe3446084f4da598afc1c9
9de709347bd6cc5cbd2763ed806b02bd46ccf992
refs/heads/master
2023-07-06T18:24:44.888790
2023-06-25T21:20:33
2023-06-25T21:20:33
204,765,539
2
2
null
2022-10-31T00:46:44
2019-08-27T18:29:38
C++
UTF-8
C++
false
false
578
cpp
//detect cycle in undirected graph bool dfs1(vector<int>adj[],int parent,vector<int>&vis,int x){ vis[x]=1; for(auto it:adj[x]){ if(!vis[it]){ if(dfs1(adj,x,vis,it)){ return true; } } else if(parent!=it)return true; } return false; } bool isCycle(int V, vector<int> adj[]) { vector<int>vis(V,0); for(int i=0;i<V;i++)vis[i]=0; for(int i=0;i<V;i++){ if(!vis[i]&&dfs1(adj,-1,vis,i))return true; } return false; }
[ "sainiprakash525@gmail.com" ]
sainiprakash525@gmail.com
958f844a55fbf58ed7fbca994f947496462688d8
846a7668ac964632bdb6db639ab381be11c13b77
/android/prebuilts/ndk/r13/sources/cxx-stl/llvm-libc++/test/support/nasty_containers.hpp
b9ef5a6a72764f60ed9fd97d9a3501128d4d28d2
[ "NCSA", "MIT", "LicenseRef-scancode-bsd-unchanged", "Martin-Birgmeier", "LicenseRef-scancode-bsd-unmodified", "LicenseRef-scancode-ibm-dhcp", "ISC", "Apache-2.0", "HPND", "BSD-4-Clause", "BSD-4-Clause-UC", "SMLNJ", "BSD-3-Clause", "LicenseRef-scancode-warranty-disclaimer", "BSD-2-Clause"...
permissive
BPI-SINOVOIP/BPI-A64-Android8
f2900965e96fd6f2a28ced68af668a858b15ebe1
744c72c133b9bf5d2e9efe0ab33e01e6e51d5743
refs/heads/master
2023-05-21T08:02:23.364495
2020-07-15T11:27:51
2020-07-15T11:27:51
143,945,191
2
0
null
null
null
null
UTF-8
C++
false
false
13,738
hpp
//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// #ifndef NASTY_CONTAINERS_H #define NASTY_CONTAINERS_H #include <cassert> #include <vector> #include <list> template <class T> class nasty_vector { public: typedef typename std::vector<T> nested_container; typedef typename nested_container::value_type value_type; typedef typename nested_container::reference reference; typedef typename nested_container::const_reference const_reference; typedef typename nested_container::iterator iterator; typedef typename nested_container::const_iterator const_iterator; typedef typename nested_container::size_type size_type; typedef typename nested_container::difference_type difference_type; typedef typename nested_container::pointer pointer; typedef typename nested_container::const_pointer const_pointer; typedef typename nested_container::reverse_iterator reverse_iterator; typedef typename nested_container::const_reverse_iterator const_reverse_iterator; nasty_vector() : v_() {} explicit nasty_vector(size_type n) : v_(n) {} nasty_vector(size_type n, const value_type& value) : v_(n, value) {} template <class InputIterator> nasty_vector(InputIterator first, InputIterator last) : v_(first, last) {} #ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS nasty_vector(std::initializer_list<value_type> il) : v_(il) {} #endif ~nasty_vector() {} template <class InputIterator> void assign(InputIterator first, InputIterator last) { v_.assign(first, last); } void assign(size_type n, const value_type& u) { v_.assign(n, u); } #ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS void assign(std::initializer_list<value_type> il) { v_.assign(il); } #endif iterator begin() _NOEXCEPT { return v_.begin(); } const_iterator begin() const _NOEXCEPT { return v_.begin(); } iterator end() _NOEXCEPT { return v_.end(); } const_iterator end() const _NOEXCEPT { return v_.end(); } reverse_iterator rbegin() _NOEXCEPT { return v_.rbegin(); } const_reverse_iterator rbegin() const _NOEXCEPT { return v_.rbegin(); } reverse_iterator rend() _NOEXCEPT { return v_.rend(); } const_reverse_iterator rend() const _NOEXCEPT { return v_.rend(); } const_iterator cbegin() const _NOEXCEPT { return v_.cbegin(); } const_iterator cend() const _NOEXCEPT { return v_.cend(); } const_reverse_iterator crbegin() const _NOEXCEPT { return v_.crbegin(); } const_reverse_iterator crend() const _NOEXCEPT { return v_.crend(); } size_type size() const _NOEXCEPT { return v_.size(); } size_type max_size() const _NOEXCEPT { return v_.max_size(); } size_type capacity() const _NOEXCEPT { return v_.capacity(); } bool empty() const _NOEXCEPT { return v_.empty(); } void reserve(size_type n) { v_.reserve(n); }; void shrink_to_fit() _NOEXCEPT { v_.shrink_to_fit(); } reference operator[](size_type n) { return v_[n]; } const_reference operator[](size_type n) const { return v_[n]; } reference at(size_type n) { return v_.at(n); } const_reference at(size_type n) const { return v_.at(n); } reference front() { return v_.front(); } const_reference front() const { return v_.front(); } reference back() { return v_.back(); } const_reference back() const { return v_.back(); } value_type* data() _NOEXCEPT { return v_.data(); } const value_type* data() const _NOEXCEPT { return v_.data(); } void push_back(const value_type& x) { v_.push_back(x); } #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES void push_back(value_type&& x) { v_.push_back(std::forward<value_type&&>(x)); } #ifndef _LIBCPP_HAS_NO_VARIADICS template <class... Args> void emplace_back(Args&&... args) { v_.emplace_back(std::forward<Args>(args)...); } #endif #endif void pop_back() { v_.pop_back(); } #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES #ifndef _LIBCPP_HAS_NO_VARIADICS template <class... Args> iterator emplace(const_iterator pos, Args&&... args) { return v_.emplace(pos, std::forward<Args>(args)...); } #endif #endif iterator insert(const_iterator pos, const value_type& x) { return v_.insert(pos, x); } #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES iterator insert(const_iterator pos, value_type&& x) { return v_.insert(pos, std::forward<value_type>(x)); } #endif iterator insert(const_iterator pos, size_type n, const value_type& x) { return v_.insert(pos, n, x); } template <class InputIterator> iterator insert(const_iterator pos, InputIterator first, InputIterator last) { return v_.insert(pos, first, last); } #ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS iterator insert(const_iterator pos, std::initializer_list<value_type> il) { return v_.insert(pos, il); } #endif iterator erase(const_iterator pos) { return v_.erase(pos); } iterator erase(const_iterator first, const_iterator last) { return v_.erase(first, last); } void clear() _NOEXCEPT { v_.clear(); } void resize(size_type sz) { v_.resize(sz); } void resize(size_type sz, const value_type& c) { v_.resize(sz, c); } void swap(nasty_vector &nv) _NOEXCEPT_(std::__is_nothrow_swappable<nested_container>::value) { v_.swap(nv.v_); } nasty_vector *operator &() { assert(false); return nullptr; } // nasty const nasty_vector *operator &() const { assert(false); return nullptr; } // nasty nested_container v_; }; template <class T> bool operator==(const nasty_vector<T>& x, const nasty_vector<T>& y) { return x.v_ == y.v_; } template <class T> class nasty_list { public: typedef typename std::list<T> nested_container; typedef typename nested_container::value_type value_type; typedef typename nested_container::reference reference; typedef typename nested_container::const_reference const_reference; typedef typename nested_container::iterator iterator; typedef typename nested_container::const_iterator const_iterator; typedef typename nested_container::size_type size_type; typedef typename nested_container::difference_type difference_type; typedef typename nested_container::pointer pointer; typedef typename nested_container::const_pointer const_pointer; typedef typename nested_container::reverse_iterator reverse_iterator; typedef typename nested_container::const_reverse_iterator const_reverse_iterator; nasty_list() : l_() {} explicit nasty_list(size_type n) : l_(n) {} nasty_list(size_type n, const value_type& value) : l_(n,value) {} template <class Iter> nasty_list(Iter first, Iter last) : l_(first, last) {} #ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS nasty_list(std::initializer_list<value_type> il) : l_(il) {} #endif ~nasty_list() {} #ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS nasty_list& operator=(std::initializer_list<value_type> il) { l_ = il; return *this; } #endif template <class Iter> void assign(Iter first, Iter last) { l_.assign(first, last); } void assign(size_type n, const value_type& t) { l_.assign(n, t); } #ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS void assign(std::initializer_list<value_type> il) { l_.assign(il); } #endif iterator begin() _NOEXCEPT { return l_.begin(); } const_iterator begin() const _NOEXCEPT { return l_.begin(); } iterator end() _NOEXCEPT { return l_.end(); } const_iterator end() const _NOEXCEPT { return l_.end(); } reverse_iterator rbegin() _NOEXCEPT { return l_.rbegin(); } const_reverse_iterator rbegin() const _NOEXCEPT { return l_.rbegin(); } reverse_iterator rend() _NOEXCEPT { return l_.rend(); } const_reverse_iterator rend() const _NOEXCEPT { return l_.rend(); } const_iterator cbegin() const _NOEXCEPT { return l_.cbegin(); } const_iterator cend() const _NOEXCEPT { return l_.cend(); } const_reverse_iterator crbegin() const _NOEXCEPT { return l_.crbegin(); } const_reverse_iterator crend() const _NOEXCEPT { return l_.crend(); } reference front() { return l_.front(); } const_reference front() const { return l_.front(); } reference back() { return l_.back(); } const_reference back() const { return l_.back(); } size_type size() const _NOEXCEPT { return l_.size(); } size_type max_size() const _NOEXCEPT { return l_.max_size(); } bool empty() const _NOEXCEPT { return l_.empty(); } void push_front(const value_type& x) { l_.push_front(x); } void push_back(const value_type& x) { l_.push_back(x); } #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES void push_back(value_type&& x) { l_.push_back(std::forward<value_type&&>(x)); } void push_front(value_type&& x) { l_.push_back(std::forward<value_type&&>(x)); } #ifndef _LIBCPP_HAS_NO_VARIADICS template <class... Args> void emplace_back(Args&&... args) { l_.emplace_back(std::forward<Args>(args)...); } template <class... Args> void emplace_front(Args&&... args) { l_.emplace_front(std::forward<Args>(args)...); } #endif #endif void pop_front() { l_.pop_front(); } void pop_back() { l_.pop_back(); } #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES #ifndef _LIBCPP_HAS_NO_VARIADICS template <class... Args> iterator emplace(const_iterator pos, Args&&... args) { return l_.emplace(pos, std::forward<Args>(args)...); } #endif #endif iterator insert(const_iterator pos, const value_type& x) { return l_.insert(pos, x); } #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES iterator insert(const_iterator pos, value_type&& x) { return l_.insert(pos, std::forward<value_type>(x)); } #endif iterator insert(const_iterator pos, size_type n, const value_type& x) { return l_.insert(pos, n, x); } template <class InputIterator> iterator insert(const_iterator pos, InputIterator first, InputIterator last) { return l_.insert(pos, first, last); } #ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS iterator insert(const_iterator pos, std::initializer_list<value_type> il) { return l_.insert(pos, il); } #endif iterator erase(const_iterator pos) { return l_.erase(pos); } iterator erase(const_iterator pos, const_iterator last) { return l_.erase(pos, last); } void resize(size_type sz) { l_.resize(); } void resize(size_type sz, const value_type& c) { l_.resize(c); } void swap(nasty_list &nl) _NOEXCEPT_(std::__is_nothrow_swappable<nested_container>::value) { l_.swap(nl.l_); } void clear() _NOEXCEPT { l_.clear(); } // void splice(const_iterator position, list& x); // void splice(const_iterator position, list&& x); // void splice(const_iterator position, list& x, const_iterator i); // void splice(const_iterator position, list&& x, const_iterator i); // void splice(const_iterator position, list& x, const_iterator first, // const_iterator last); // void splice(const_iterator position, list&& x, const_iterator first, // const_iterator last); // // void remove(const value_type& value); // template <class Pred> void remove_if(Pred pred); // void unique(); // template <class BinaryPredicate> // void unique(BinaryPredicate binary_pred); // void merge(list& x); // void merge(list&& x); // template <class Compare> // void merge(list& x, Compare comp); // template <class Compare> // void merge(list&& x, Compare comp); // void sort(); // template <class Compare> // void sort(Compare comp); // void reverse() noexcept; nasty_list *operator &() { assert(false); return nullptr; } // nasty const nasty_list *operator &() const { assert(false); return nullptr; } // nasty nested_container l_; }; template <class T> bool operator==(const nasty_list<T>& x, const nasty_list<T>& y) { return x.l_ == y.l_; } // Not really a mutex, but can play one in tests class nasty_mutex { public: nasty_mutex() _NOEXCEPT {} ~nasty_mutex() {} nasty_mutex *operator& () { assert(false); return nullptr; } template <typename T> void operator, (const T &) { assert(false); } private: nasty_mutex(const nasty_mutex&) { assert(false); } nasty_mutex& operator=(const nasty_mutex&) { assert(false); return *this; } public: void lock() {} bool try_lock() _NOEXCEPT { return true; } void unlock() _NOEXCEPT {} // Shared ownership void lock_shared() {} bool try_lock_shared() { return true; } void unlock_shared() {} }; #endif
[ "mingxin.android@gmail.com" ]
mingxin.android@gmail.com
c9f094e3543dc58d3c8a3f6dedc4946763089c8e
383b176f168c763f20e9b50c09b9ce3c1a538c8d
/1.cpp
9f53d24007775dffb6693d977758b14eb9139792
[]
no_license
mosthandsomeman/LeetCode
dab7e25037736cd993f657179f8ccbbf55940586
99f2b6dc1fed2829298996a432773bb28a42615e
refs/heads/master
2023-01-21T02:11:50.872572
2020-11-30T13:35:32
2020-11-30T13:35:32
280,103,486
0
0
null
null
null
null
UTF-8
C++
false
false
379
cpp
#include<vector> using namespace std; class Solution { public: vector<int> twoSum(vector<int>& nums, int target) { vector<int> res; for (int i = 0; i < nums.size(); ++i) { for (int j = 0; j < nums.size(); ++j) { if (j == i) break; if (nums[i] + nums[j] == target) { res.push_back(i); res.push_back(j); return res; } } } return res; } };
[ "22060313@zju.edu.cn" ]
22060313@zju.edu.cn
2a8e28cb5ae26a1faac53d7fa97d833015658af7
f266d531ac0ad2f641a48feb0a0e258899feae04
/RasterGraphic Assignment/Image.cpp
35d120addfb0a34602ebfb61a295277cfad45bd8
[]
no_license
DobieDevelopments/CST8219-CPP-Programming
7458f2ed33793a5d657018478a046974d55c9a3e
0d32c534d9f38e30a74d952f6a17f578ecc2e1a4
refs/heads/master
2020-04-16T12:13:03.637320
2019-01-14T00:21:48
2019-01-14T00:21:48
165,569,294
0
0
null
null
null
null
UTF-8
C++
false
false
3,569
cpp
/******* File Header ****************************************************************************************************************** * Filename : Image.cpp * Version : 1.0 * Purpose : To handle methods for modifying our linked list, * : (insert, delete from head, print/iterate through list. **************************************************************************************************************************************/ #include <iostream> using namespace std; #include "Image.h" /******* Function Header ************************************************************************************************************** * Function name : Image() //Default Constructor * Purpose : To initialize our Image class object * Function In parameters : int - x coordinate of the image * | int - y coordinate of the image * | int - how long to display the image * | char* - the image filename * Function Out parameters : Image - the instance of this class object * Version : 1.0 * Author : John Dobie **************************************************************************************************************************************/ Image::Image(int x, int y, int duration, char * name) { this->pixel_x = x; this->pixel_y = y; this->duration = duration; this->name = new char[strlen(name) * sizeof(char) + 1]; strcpy_s(this->name, strlen(name) * sizeof(char) + 1, name); } /******* Function Header ************************************************************************************************************** * Function name : Image() //Copy Constructor * Purpose : To initialize our image class object using the details of another passed in * Function In parameters : const Image& - the image to copy from * Function Out parameters : Image - the instance of this class object * Version : 1.0 * Author : John Dobie **************************************************************************************************************************************/ Image::Image(const Image & I) { this->pixel_x = I.pixel_x; this->pixel_y = I.pixel_y; this->duration = I.duration; this->name = new char[strlen(I.name) * sizeof(char) + 1]; strcpy_s(this->name, strlen(I.name) * sizeof(char) + 1, I.name); } /******* Function Header ************************************************************************************************************** * Function name : operator<<() * Purpose : An overload of the << operator * | To handle output functinality of Image class objects through the output stream * Function In parameters : ostream& - the output stream * | Image& - the image to output * Function Out parameters : ostream& - a reference to the ostream * Version : 1.0 * Author : John Dobie **************************************************************************************************************************************/ ostream & operator<<(ostream & os, Image & image) { os << "Image name = " << image.name << "; pixel_x = " << image.pixel_x << "; pixel_y = " << image.pixel_y << "; duration = " << image.duration << endl << "\tCounting the seconds for this Image: "; for (int i = 0; i < image.duration; ++i) { if (i != (image.duration - 1)) os << (i + 1) << ", "; else os << (i + 1) << "."; } return os; }
[ "noreply@github.com" ]
noreply@github.com
d62efbcaae6d41c48c759fc53459f8c9e5123777
61b399b3a51ad40d5c31c29517c128a802d5236c
/transfer/CodecDebugerTransfer.cpp
3a64c76f01d1120dce22b388c6b545496eb14f77
[]
no_license
cmguo/just-just-mux
d4671db9eb7f6d82bb1533fbd25d91d6c958ad91
53f6533c3b9b128fd1daabd842a9334a553ac742
refs/heads/master
2022-11-25T04:04:35.474777
2016-09-08T06:39:54
2016-09-08T06:39:54
280,884,540
0
0
null
null
null
null
UTF-8
C++
false
false
2,546
cpp
// CodecDebugerTransfer.cpp #include "just/mux/Common.h" #include "just/mux/transfer/CodecDebugerTransfer.h" namespace just { namespace mux { CodecDebugerTransfer::CodecDebugerTransfer( boost::uint32_t codec) : num_(0) { boost::system::error_code ec; debuger_ = just::avcodec::DebugerFactory::create(codec, ec); if (debuger_ == NULL) debuger_ = new just::avcodec::Debuger; } CodecDebugerTransfer::~CodecDebugerTransfer() { delete debuger_; } void CodecDebugerTransfer::transfer( StreamInfo & info) { std::cout << "track: " << info.index << "\t type: " << just::avbase::FourCC::to_string(info.type) << "\t sub_type: " << just::avbase::FourCC::to_string(info.sub_type) << "\t format_data: " << info.format_data.size() << " bytes" << std::endl; if (info.type == StreamType::VIDE) { std::cout << " width: " << info.video_format.width << " height: " << info.video_format.height << " frame_rate: " << info.video_format.frame_rate_num << "/" << info.video_format.frame_rate_den << std::endl; } else { std::cout << " channel_count: " << info.audio_format.channel_count << " sample_size: " << info.audio_format.sample_size << " sample_rate: " << info.audio_format.sample_rate << " block_align: " << info.audio_format.block_align << " sample_per_frame: " << info.audio_format.sample_per_frame << std::endl; } boost::system::error_code ec; if (debuger_) debuger_->reset(info, ec); num_ = 0; } void CodecDebugerTransfer::transfer( Sample & sample) { std::cout << "track: " << sample.itrack << " # " << num_++ << "\t time: " << sample.time << "\t size: " << sample.size << "\t dts: " << sample.dts << "\t cts: " << sample.dts + sample.cts_delta << std::endl; boost::system::error_code ec; if (debuger_) debuger_->debug(sample, ec); } } // namespace mux } // namespace just
[ "isxxguo@pptv.com" ]
isxxguo@pptv.com
b86d7c766e6aae8f0d36941bbd4f90f454799c9e
3b822b73a63ae0b4caabc34c8c817ddff418de12
/Algorithm/binary__Searchhhhhhhh.cpp
8f618438ebb224df1b465332dfd419f7d406d7d2
[]
no_license
okpiyush/LearningCPP
7db314a2b68db345bb60cbfd0498b58bcf81717f
ce40b820144470bd36691d03bc1b4c4eeab70b87
refs/heads/master
2023-07-15T16:51:04.801472
2021-08-31T10:06:21
2021-08-31T10:06:21
null
0
0
null
null
null
null
UTF-8
C++
false
false
602
cpp
#include <iostream> using namespace std; int main(){ int n=20; int arr[n]={226, 446, 604, 2605, 3172, 5000, 5177, 5964, 6279, 7632, 7981, 8071, 8163, 8177, 8624, 9092, 9813, 9873, 9978, 9997}; int start,end; start=0; end=20; int mid,s; cout<<"What do you want to search in the array ?"; cin>>s; while(true){ mid =(start+end)/2; if(s>arr[mid]){ start=mid; continue; }else if(s<arr[mid]){ end=mid; continue; }else{ cout<<mid; break; } } return 0; }
[ "piyushkumar2738@gmail.com" ]
piyushkumar2738@gmail.com
1b63024bc6bc9b88087629b68d8f3195af166909
2fa5c8d10d597fe1d590542596994fdbd016fddc
/dataset/simulation_experiment/Type1/4/Base0.cpp
d460540c56031a2474b626a04cb812740c945a9e
[]
no_license
guoliang72/colllectivePR
715ea332a147e115ac30326a013e19d80f4638a1
f9223e1d1aaa34ac377e75994c02c69033cd0d7f
refs/heads/master
2020-04-24T06:55:28.611842
2019-02-22T11:31:27
2019-02-22T11:31:27
171,782,140
0
0
null
null
null
null
UTF-8
C++
false
false
387
cpp
#include <stdio.h> int main(){ int i; int n; float a; double sum; sum=5; scanf("%d",&n); for(i=0;i<n;i=i+1){ scanf("%lf",&a); if(a<100){ a=0; }else if(a>=100 && a<200){ a=0.1*a; }else if(a>=200 && a<500){ a=0.3*a; }else if(a>=500){ a=0.1*a; } sum=sum+a; } printf("%.2lf\n",sum); return 0; }
[ "guoliang72@qq.com" ]
guoliang72@qq.com
ffcafc87c05e196a8447112d28ccc9145231e9e6
fff50c3ca25dc6d1c8e53a09ba98df1ddfa74741
/just_pir/myPhant.cpp
9cbb6801ed1aeaac3d9348f4798fb3bbb1b263c5
[]
no_license
ManitoSecurity/WiFi_and_BT
d4d16e4ea15479639f149c3fcde60bb38b98469d
d22df8d3bfd20fa9594281d6628d1bc97f9a80da
refs/heads/master
2016-09-02T03:22:57.618373
2015-04-28T06:28:42
2015-04-28T06:28:42
30,949,607
0
0
null
null
null
null
UTF-8
C++
false
false
2,950
cpp
/** * myPhant.h * * Author: Brian Gravelle * Based on Phant.h by Todd Treece <todd@sparkfun.com> * */ //#include "Arduino.h" //#include <SPI.h> #include <SFE_CC3000.h> #include <SFE_CC3000_Client.h> #include "myPhant.h" Phant::Phant(char* host, char* publicKey, char* privateKey, SFE_CC3000 &cc3000) { _host = host; _pub = publicKey; _prv = privateKey; _params[0] = '\0'; _param_length = 0; _client = SFE_CC3000_Client(cc3000); } bool Phant::connect() { return _client.connect(_host, 80); } bool Phant::isConnected() { return _client.connected(); } bool Phant::close() { return _client.close(); } char* Phant::add(char* param, int length) { int j = 0; //while(field[j] != '\0') { while(j < 17) { _params[j] = param[j]; j++; } _params[j] = '\0'; return _params; } char* Phant::add(char* field, char* data) { _params = "&alert=T&armed=F"; _param_length = 15; return "Hi there"; /* int j = 0; _params[_param_length] = '&'; _param_length++; while(field[j] != '\0') { _params[_param_length] = field[j]; j++; _param_length++; } _params[_param_length] = '='; _param_length++; j = 0; while(data[j] != '\0') { _params[_param_length] = data[j]; j++; _param_length++; } _params[_param_length] = '\0'; _param_length++; return "hi"; */ } char* Phant::queryString() { return _params; } /* char* Phant::url() { String result = "http://" + _host + "/input/" + _pub + ".txt"; result += "?private_key=" + _prv + _params; _params = ""; return "this doesn't do anytihng yet"; } */ void Phant::get() { _client.print("GET /output/"); _client.print(_pub); _client.println(".csv HTTP/1.1"); _client.print("Host: "); _client.println(_host); _client.println("Connection: close"); _client.print("\n"); } char Phant::recieve(){ if ( _client.available() ) return _client.read(); else return '\0'; } void Phant::post(char* params) { //skip first & //char* params = &_params[1]; _client.print("POST /input/"); _client.print(_pub); _client.println(".txt HTTP/1.1"); _client.print("Host: "); _client.println(_host); _client.print("Phant-Private-Key: "); _client.println(_prv); _client.println("Connection: close"); _client.println("Content-Type: application/x-www-form-urlencoded"); //_client.print("Content-Length: "); _client.print(_param_length); _client.print("Content-Length: 47"); _client.print("\n\n"); _client.print(params); _client.print("&phone=0008675309&away=F&sleep=F"); _client.print("\n"); _params[0] = '\0'; _param_length = 0; } void Phant::makeEmpty() { int _param_length; _client.print("DELETE /input/"); _client.print(_pub); _client.println(".txt HTTP/1.1"); _client.print("Host: "); _client.println(_host); _client.print("Phant-Private-Key: "); _client.println(_prv); _client.println("Connection: close"); _client.print("\n"); }
[ "cmbirmingham19@gmail.com" ]
cmbirmingham19@gmail.com
0edfd8ea8c9fa56186eef3417a7e9249e0e45515
ae219d28725c9dd58c200ae76ba3bf3f2a90d557
/BrowserLauncher/xulrunner-sdk/include/mozIStorageRow.h
3181f58ed6908fd199f9e7ec0f52bc6850eb4290
[]
no_license
pepekinha/src
de1f0c64cf1238e019f4daf7f87d95849304d88e
5223858f05f6791f1dec30df1dbb91ae3e4f5952
refs/heads/master
2021-01-22T01:05:54.659896
2014-04-06T01:43:37
2014-04-06T01:43:37
27,421,524
3
2
null
null
null
null
UTF-8
C++
false
false
3,939
h
/* * DO NOT EDIT. THIS FILE IS GENERATED FROM e:/builds/moz2_slave/release-mozilla-1.9.2-xulrunner_win32_build/build/storage/public/mozIStorageRow.idl */ #ifndef __gen_mozIStorageRow_h__ #define __gen_mozIStorageRow_h__ #ifndef __gen_mozIStorageValueArray_h__ #include "mozIStorageValueArray.h" #endif /* For IDL files that don't want to include root IDL files. */ #ifndef NS_NO_VTABLE #define NS_NO_VTABLE #endif class nsIVariant; /* forward declaration */ /* starting interface: mozIStorageRow */ #define MOZISTORAGEROW_IID_STR "62d1b6bd-cbfe-4f9b-aee1-0ead4af4e6dc" #define MOZISTORAGEROW_IID \ {0x62d1b6bd, 0xcbfe, 0x4f9b, \ { 0xae, 0xe1, 0x0e, 0xad, 0x4a, 0xf4, 0xe6, 0xdc }} class NS_NO_VTABLE NS_SCRIPTABLE mozIStorageRow : public mozIStorageValueArray { public: NS_DECLARE_STATIC_IID_ACCESSOR(MOZISTORAGEROW_IID) /** * Obtains the result of a given column specified by aIndex. * * @param aIndex * Zero-based index of the result to get from the tuple. * @returns the result of the specified column. */ /* nsIVariant getResultByIndex (in unsigned long aIndex); */ NS_SCRIPTABLE NS_IMETHOD GetResultByIndex(PRUint32 aIndex, nsIVariant **_retval NS_OUTPARAM) = 0; /** * Obtains the result of a given column specified by aIndex. * * @param aName * Name of the result to get from the tuple. * @returns the result of the specified column. */ /* nsIVariant getResultByName (in AUTF8String aName); */ NS_SCRIPTABLE NS_IMETHOD GetResultByName(const nsACString & aName, nsIVariant **_retval NS_OUTPARAM) = 0; }; NS_DEFINE_STATIC_IID_ACCESSOR(mozIStorageRow, MOZISTORAGEROW_IID) /* Use this macro when declaring classes that implement this interface. */ #define NS_DECL_MOZISTORAGEROW \ NS_SCRIPTABLE NS_IMETHOD GetResultByIndex(PRUint32 aIndex, nsIVariant **_retval NS_OUTPARAM); \ NS_SCRIPTABLE NS_IMETHOD GetResultByName(const nsACString & aName, nsIVariant **_retval NS_OUTPARAM); /* Use this macro to declare functions that forward the behavior of this interface to another object. */ #define NS_FORWARD_MOZISTORAGEROW(_to) \ NS_SCRIPTABLE NS_IMETHOD GetResultByIndex(PRUint32 aIndex, nsIVariant **_retval NS_OUTPARAM) { return _to GetResultByIndex(aIndex, _retval); } \ NS_SCRIPTABLE NS_IMETHOD GetResultByName(const nsACString & aName, nsIVariant **_retval NS_OUTPARAM) { return _to GetResultByName(aName, _retval); } /* Use this macro to declare functions that forward the behavior of this interface to another object in a safe way. */ #define NS_FORWARD_SAFE_MOZISTORAGEROW(_to) \ NS_SCRIPTABLE NS_IMETHOD GetResultByIndex(PRUint32 aIndex, nsIVariant **_retval NS_OUTPARAM) { return !_to ? NS_ERROR_NULL_POINTER : _to->GetResultByIndex(aIndex, _retval); } \ NS_SCRIPTABLE NS_IMETHOD GetResultByName(const nsACString & aName, nsIVariant **_retval NS_OUTPARAM) { return !_to ? NS_ERROR_NULL_POINTER : _to->GetResultByName(aName, _retval); } #if 0 /* Use the code below as a template for the implementation class for this interface. */ /* Header file */ class _MYCLASS_ : public mozIStorageRow { public: NS_DECL_ISUPPORTS NS_DECL_MOZISTORAGEROW _MYCLASS_(); private: ~_MYCLASS_(); protected: /* additional members */ }; /* Implementation file */ NS_IMPL_ISUPPORTS1(_MYCLASS_, mozIStorageRow) _MYCLASS_::_MYCLASS_() { /* member initializers and constructor code */ } _MYCLASS_::~_MYCLASS_() { /* destructor code */ } /* nsIVariant getResultByIndex (in unsigned long aIndex); */ NS_IMETHODIMP _MYCLASS_::GetResultByIndex(PRUint32 aIndex, nsIVariant **_retval NS_OUTPARAM) { return NS_ERROR_NOT_IMPLEMENTED; } /* nsIVariant getResultByName (in AUTF8String aName); */ NS_IMETHODIMP _MYCLASS_::GetResultByName(const nsACString & aName, nsIVariant **_retval NS_OUTPARAM) { return NS_ERROR_NOT_IMPLEMENTED; } /* End of implementation class template. */ #endif #endif /* __gen_mozIStorageRow_h__ */
[ "highnetlan@gmail.com" ]
highnetlan@gmail.com
66af45f48b23278bbeb6a8d309979ff38db891c0
0518e53526c214da6142d940c42a428ec7d58122
/CWE-399/source_files/112996/CWE761_Free_Pointer_Not_at_Start_of_Buffer__wchar_t_file_82a.cpp
e7204fb67c209c24a03a4663c7dd440fc3bbd61e
[ "Apache-2.0" ]
permissive
Adam-01/VulDeePecker
eb03cfa2b94d736b1cba17fb1cdcb36b01e18f5e
98610f3e116df97a1e819ffc81fbc7f6f138a8f2
refs/heads/master
2023-03-21T07:37:26.904949
2020-11-17T19:40:13
2020-11-17T19:40:13
null
0
0
null
null
null
null
UTF-8
C++
false
false
3,906
cpp
/* TEMPLATE GENERATED TESTCASE FILE Filename: CWE761_Free_Pointer_Not_at_Start_of_Buffer__wchar_t_file_82a.cpp Label Definition File: CWE761_Free_Pointer_Not_at_Start_of_Buffer.label.xml Template File: source-sinks-82a.tmpl.cpp */ /* * @description * CWE: 761 Free Pointer not at Start of Buffer * BadSource: file Read input from a file * Sinks: * GoodSink: free() memory correctly at the start of the buffer * BadSink : free() memory not at the start of the buffer * Flow Variant: 82 Data flow: data passed in a parameter to an virtual method called via a pointer * * */ #include "std_testcase.h" #include "CWE761_Free_Pointer_Not_at_Start_of_Buffer__wchar_t_file_82.h" #ifdef _WIN32 #define FILENAME "C:\\temp\\file.txt" #else #define FILENAME "/tmp/file.txt" #endif #define SEARCH_CHAR L'S' namespace CWE761_Free_Pointer_Not_at_Start_of_Buffer__wchar_t_file_82 { #ifndef OMITBAD void bad() { wchar_t * data; data = (wchar_t *)malloc(100*sizeof(wchar_t)); data[0] = L'\0'; { /* Read input from a file */ size_t dataLen = wcslen(data); FILE * pFile; /* if there is room in data, attempt to read the input from a file */ if (100-dataLen > 1) { pFile = fopen(FILENAME, "r"); if (pFile != NULL) { /* POTENTIAL FLAW: Read data from a file */ if (fgetws(data+dataLen, (int)(100-dataLen), pFile) == NULL) { printLine("fgetws() failed"); /* Restore NUL terminator if fgetws fails */ data[dataLen] = L'\0'; } fclose(pFile); } } } CWE761_Free_Pointer_Not_at_Start_of_Buffer__wchar_t_file_82_base* baseObject = new CWE761_Free_Pointer_Not_at_Start_of_Buffer__wchar_t_file_82_bad; baseObject->action(data); delete baseObject; } #endif /* OMITBAD */ #ifndef OMITGOOD /* goodB2G uses the BadSource with the GoodSink */ static void goodB2G() { wchar_t * data; data = (wchar_t *)malloc(100*sizeof(wchar_t)); data[0] = L'\0'; { /* Read input from a file */ size_t dataLen = wcslen(data); FILE * pFile; /* if there is room in data, attempt to read the input from a file */ if (100-dataLen > 1) { pFile = fopen(FILENAME, "r"); if (pFile != NULL) { /* POTENTIAL FLAW: Read data from a file */ if (fgetws(data+dataLen, (int)(100-dataLen), pFile) == NULL) { printLine("fgetws() failed"); /* Restore NUL terminator if fgetws fails */ data[dataLen] = L'\0'; } fclose(pFile); } } } CWE761_Free_Pointer_Not_at_Start_of_Buffer__wchar_t_file_82_base* baseObject = new CWE761_Free_Pointer_Not_at_Start_of_Buffer__wchar_t_file_82_goodB2G; baseObject->action(data); delete baseObject; } void good() { goodB2G(); } #endif /* OMITGOOD */ } /* close namespace */ /* Below is the main(). It is only used when building this testcase on its own for testing or for building a binary to use in testing binary analysis tools. It is not used when compiling all the testcases as one application, which is how source code analysis tools are tested. */ #ifdef INCLUDEMAIN using namespace CWE761_Free_Pointer_Not_at_Start_of_Buffer__wchar_t_file_82; /* so that we can use good and bad easily */ int main(int argc, char * argv[]) { /* seed randomness */ srand( (unsigned)time(NULL) ); #ifndef OMITGOOD printLine("Calling good()..."); good(); printLine("Finished good()"); #endif /* OMITGOOD */ #ifndef OMITBAD printLine("Calling bad()..."); bad(); printLine("Finished bad()"); #endif /* OMITBAD */ return 0; } #endif
[ "王苏菲" ]
王苏菲
a143f41672e18a8bf13355c359d55386bfab663c
5a6398e0b197dc76eb9d79e8c9a70940c826b00e
/src/include/izenelib/source/ir/index_manager/index/SkipListReader.cpp
dabec7dd896664057bdd472e84e829298b7bc11d
[ "Apache-2.0", "PostgreSQL" ]
permissive
RMoraffah/hippo-postgresql
38b07cd802e179c3fce00097f49c843b238c3e91
002702bab3a820bbc8cf99e6fcf3bb1eface96c1
refs/heads/master
2021-01-12T00:48:53.735686
2016-12-02T01:01:15
2016-12-02T01:13:51
null
0
0
null
null
null
null
UTF-8
C++
false
false
4,971
cpp
#include <ir/index_manager/index/SkipListReader.h> #include <ir/index_manager/utility/system.h> //#define SKIP_DEBUG NS_IZENELIB_IR_BEGIN namespace indexmanager{ SkipListReader::SkipListReader(IndexInput* pSkipInput, int skipInterval, int numSkipLevels) : loaded_(false) , defaultSkipInterval_(skipInterval) , numSkipLevels_(numSkipLevels) , numSkipped_(0) , totalSkipped_(0) , lastDoc_(0) , lastSkipInterval_(0) , lastChildPointer_(0) { init(); skipStream_[0] = pSkipInput->clone(); } SkipListReader::SkipListReader(VariantDataPool** pSkipLevels, int skipInterval, int numSkipLevels) : loaded_(false) , defaultSkipInterval_(skipInterval) , numSkipLevels_(numSkipLevels) , numSkipped_(0) , totalSkipped_(0) , lastDoc_(0) , lastSkipInterval_(0) , lastChildPointer_(0) { init(); for(int i = 0;i < numSkipLevels_;i++) skipStream_[i] = new VariantDataPoolInput(pSkipLevels[i]); } SkipListReader::~SkipListReader() { std::vector<IndexInput*>::iterator iter =skipStream_.begin(); for( ; iter != skipStream_.end(); ++iter) if(*iter) delete *iter; } docid_t SkipListReader::skipTo(docid_t target) { if (!loaded_) { loadSkipLevels(); loaded_ = true; } /// walk up the levels until highest level is found that has a skip for this target int level = 0; while (level < (numSkipLevels_-1) && target > skipDoc_[level + 1]) { level++; } while (level >= 0) { if (target > skipDoc_[level]) { #ifdef SKIP_DEBUG cout<<"in level "<<level<<":"; #endif if (!loadNextSkip(level)) continue; } else { /// no more skips on this level, go down one level if (level > 0 && lastChildPointer_ > skipStream_[level - 1]->getFilePointer()) { seekChild(level - 1); } level--; } } #ifdef SKIP_DEBUG cout<<"skipto result: doc "<<lastDoc_<<" totalskipped "<<totalSkipped_<<endl; #endif return lastDoc_; } bool SkipListReader::nextSkip(docid_t docID) { if (!loaded_) { loadSkipLevels(); loaded_ = true; } if(skipDoc_[0] == 0) { if(!loadNextSkip(0)) return false; } if(skipDoc_[0] <= docID) { loadNextSkip(0); return true; } return false; } void SkipListReader::seekChild(int level) { skipStream_[level]->seek(lastChildPointer_); skipDoc_[level] = lastDoc_; offsets_[level] = lastOffset_; pOffsets_[level] = lastPOffset_; numSkipped_[level] = totalSkipped_;//numSkipped_[level]; if (level > 0) { childPointer_[level] = skipStream_[level]->readVLong() + skipPointer_[level - 1]; } } bool SkipListReader::loadNextSkip(int level) { lastDoc_ = skipDoc_[level]; lastSkipInterval_ = skipInterval_[level]; lastChildPointer_ = childPointer_[level]; lastOffset_ = offsets_[level]; lastPOffset_ = pOffsets_[level]; totalSkipped_ = numSkipped_[level]; #ifdef SKIP_DEBUG cout<<"lastdoc "<<lastDoc_<<" totalskipped "<<totalSkipped_<<","; #endif if (skipStream_[level]->isEof()) { /// this skip list is exhausted skipDoc_[level] = BAD_DOCID; return false; } /// read next skip entry readSkipPoint(level, skipStream_[level]); return true; } void SkipListReader::readSkipPoint(int level,IndexInput* pLevelInput) { docid_t nDocDelta = pLevelInput->readVInt(); if( (nDocDelta & 1) == 1) skipInterval_[level] = pLevelInput->readVInt(); else skipInterval_[level] = getLevelSkipInterval(level); skipDoc_[level] += (nDocDelta >> 1);//pLevelInput->readVInt(); offsets_[level] += pLevelInput->readVLong(); pOffsets_[level] += pLevelInput->readVLong(); numSkipped_[level] += skipInterval_[level]; #ifdef SKIP_DEBUG cout<<"doc "<<skipDoc_[level]<<" numSkipped_[level] "<<numSkipped_[level]<<","; #endif if (level > 0) { /// read the child pointer if we are not on the leaf level childPointer_[level] = pLevelInput->readVLong() + skipPointer_[level- 1]; } } void SkipListReader::loadSkipLevels() { for (int i = numSkipLevels_-1; i >= 0; i--) { fileoffset_t length = skipStream_[0]->readVLong(); skipPointer_[i] = skipStream_[0]->getFilePointer(); if(i > 0) { skipStream_[i] = skipStream_[0]->clone(); } skipStream_[i]->setlength(skipStream_[0]->getFilePointer() + length); if(i > 0) { skipStream_[0]->seek(skipStream_[0]->getFilePointer() + length); } } } } NS_IZENELIB_IR_END
[ "jiayu198910@gmail.com" ]
jiayu198910@gmail.com
51ced789e7085c6a00837db3eb5319794acf983d
2f78e134c5b55c816fa8ee939f54bde4918696a5
/code/gui/tutorial.h
5975f0069d5fb717178a318f70c54a42f908df3c
[]
no_license
narayanr7/HeavenlySword
b53afa6a7a6c344e9a139279fbbd74bfbe70350c
a255b26020933e2336f024558fefcdddb48038b2
refs/heads/master
2022-08-23T01:32:46.029376
2020-05-26T04:45:56
2020-05-26T04:45:56
null
0
0
null
null
null
null
UTF-8
C++
false
false
8,985
h
#ifndef _TUTORIAL_H #define _TUTORIAL_H #include "game/attacks.h" #include "game/eventlog.h" #include "editable/enumlist.h" // For screen message #include "gui/guiunit.h" // Base class for all watch objects class CTutorialBaseWatch { public: //! Construction Destruction CTutorialBaseWatch( const CEntity* pobEnt, const CHashedString obMsg ); virtual ~CTutorialBaseWatch( void ); protected: const CHashedString m_obReplyMsg; const CEntity* m_pobReplyEnt; }; // Base class for all combat watch objects class CCombatTutorialBaseWatch : protected CTutorialBaseWatch { public: //! Construction Destruction CCombatTutorialBaseWatch( const CEntity* pobEnt, const CHashedString obMsg ); //virtual ~CCombatTutorialBaseWatch(); virtual bool Complete( CombatEventLog* pobCombatEventLog ); protected: }; // Simple strike - any hit made including those blocked class CTutorialSimpleStrikeWatch : protected CCombatTutorialBaseWatch { public: CTutorialSimpleStrikeWatch( const CEntity* pobEnt, const CHashedString obMsg, int iAttackClass, bool bSuccessful = true ); //virtual ~CTutorialSimpleStrikeWatch( void ); virtual bool Complete( CombatEventLog* pobCombatEventLog ); private: int m_iAttackClass; bool m_bSuccessful; }; // Combat event watch, ie KO, Kills and Grabs class CTutorialSimpleEventWatch : protected CCombatTutorialBaseWatch { public: CTutorialSimpleEventWatch( const CEntity* pobEnt, const CHashedString obMsg, int iEvent ); //virtual ~CTutorialSimpleEventWatch( void ); virtual bool Complete( CombatEventLog* pobCombatEventLog ); private: int m_iEvent; }; // Sucessful blocks ( deflections - i.e. blocking axeman is power stance) class CTutorialDeflectWatch : protected CCombatTutorialBaseWatch { public: CTutorialDeflectWatch( const CEntity* pobEnt, const CHashedString obMsg, int iStance ); //virtual ~CTutorialSimpleStrikeWatch( void ); virtual bool Complete( CombatEventLog* pobCombatEventLog ); private: int m_iStance; }; // Evade attacks class CTutorialEvadeAttackWatch : protected CCombatTutorialBaseWatch { public: CTutorialEvadeAttackWatch( const CEntity* pobEnt, const CHashedString obMsg/*, int iAttackClass*/, bool bSuccessful = true ); //virtual ~CTutorialSimpleStrikeWatch( void ); virtual bool Complete( CombatEventLog* pobCombatEventLog ); private: enum { EAW_EVADE, EAW_ATTACK, } m_eState; /*int m_iAttackClass;*/ bool m_bSuccessful; }; // Specific attack targets class CTutorialAttackTargetWatch : protected CCombatTutorialBaseWatch { public: CTutorialAttackTargetWatch( const CEntity* pobEnt, const CHashedString obMsg, int iAttackTarget, bool bSuccessful = true ); //virtual ~CTutorialAttackTargetWatch( void ); virtual bool Complete( CombatEventLog* pobCombatEventLog ); private: int m_iAttackTarget; bool m_bSuccessful; }; // Superstyle watch class CTutorialSuperstyleWatch : protected CCombatTutorialBaseWatch { public: CTutorialSuperstyleWatch( const CEntity* pobEnt, const CHashedString obMsg, int iLevel ); //virtual ~CTutorialSuperstyleWatch( void ); virtual bool Complete( CombatEventLog* pobCombatEventLog ); private: int m_iLevel; }; // Stance change watch class CTutorialStanceWatch : protected CCombatTutorialBaseWatch { public: CTutorialStanceWatch( const CEntity* pobEnt, const CHashedString obMsg, int iStance ); //virtual ~CTutorialStanceWatch( void ); virtual bool Complete( CombatEventLog* pobCombatEventLog ); private: int m_iStance; }; // Specific strike - a particular attack started class CTutorialSpecificStrikeWatch : protected CCombatTutorialBaseWatch { public: CTutorialSpecificStrikeWatch( const CEntity* pobEnt, const CHashedString obMsg, const CHashedString* pobSpecificStrike, bool bSuccessful = true ); //virtual ~CTutorialSpecificStrikeWatch( void ); virtual bool Complete( CombatEventLog* pobCombatEventLog ); private: CAttackData* m_pobSpecificStrike; bool m_bSuccessful; }; // Base class for all archer watch objects class CArcherTutorialBaseWatch : protected CTutorialBaseWatch { public: //! Construction Destruction CArcherTutorialBaseWatch( const CEntity* pobEnt, const CHashedString obMsg ); //virtual ~CArcherTutorialBaseWatch(); virtual bool Complete( ArcherEventLog* pobArcherEventLog ); protected: }; // Combat event watch, ie KO, Kills and Grabs class CArcherSimpleEventWatch : protected CArcherTutorialBaseWatch { public: CArcherSimpleEventWatch( const CEntity* pobEnt, const CHashedString obMsg, int iEvent ); //virtual ~CArcherSimpleEventWatch( void ); virtual bool Complete( ArcherEventLog* pobArcherEventLog ); private: int m_iEvent; }; // Base class for all entity watch objects class CEntityTutorialBaseWatch : protected CTutorialBaseWatch { public: //! Construction Destruction CEntityTutorialBaseWatch( const CEntity* pobEntity, const CEntity* pobReplyEnt, const CHashedString obMsg ); //virtual ~CEntityTutorialBaseWatch(); virtual bool Complete( ); protected: const CEntity* m_pobEntity; }; // Base class for all entity watch objects class CEntityAttackWindowWatch : protected CEntityTutorialBaseWatch { public: enum ATK_WINDOW { AW_INVUNERABLE, AW_STRIKE, AW_STRIKE2, AW_ATTACK_POP_OUT, AW_BLOCK_POP_OUT, AW_NO_LOCK, AW_MOVEMENT_POP_OUT, AW_UNINTERRUPTABLE, AW_NO_COLLIDE, AW_NEXTMOVE, AW_RANGE_INTERCEPT, AW_INTERCEPT, AW_EVADE_AND_GRAB_DENY, AW_VICTIM_RAGDOLLABLE }; enum ATK_WINDOW_STATE { AWS_INIT, AWS_IN, AWS_OUT }; //! Construction Destruction CEntityAttackWindowWatch( const CEntity* pobEntity, const CEntity* pobReplyEnt, const CHashedString obEnterMsg, const CHashedString obExitMsg, ATK_WINDOW eAtkWindow ); //virtual ~CEntityAttackWindowWatch(); virtual bool Complete( ); protected: ATK_WINDOW m_eAtkWindow; ATK_WINDOW_STATE m_eAtkWindowState; CHashedString m_obEnterMsg; }; class CTutorialManager : public Singleton<CTutorialManager> { public: //! Construction Destruction CTutorialManager( void ); ~CTutorialManager( void ); //! Go void Update( void ); void AddWatch( const CHashedString obEvent, const CEntity* pobReplyEnt, const CHashedString obMsg, void* pParam = 0, CEntity* pobWatchEnt = 0); void AddAttackWindowWatch( CEntity* pobWatchEnt, const CHashedString obWindow, const CEntity* pobReplyEnt, const CHashedString obEnterMsg, const CHashedString obExitMsg ); void ClearWatches( void ); bool AddScreenMessage(const char* pcTextID, const char* pcFont, float fDuration); void ScreenMessagePosition(float fX, float fY); void RemoveScreenMessage(void); typedef ntstd::List< CCombatTutorialBaseWatch* > CombatWatchList; typedef ntstd::List< CArcherTutorialBaseWatch* > ArcherWatchList; typedef ntstd::List< CEntityTutorialBaseWatch* > EntityWatchList; void AddTimeScalar ( float fTimeScalar, float fBlendTime ); void ClearTimeScalar ( float fBlendTime ); void TimeScalarCallback ( CEntity* pobReplyEnt, CHashedString obMsg ); // Struct to manage Combat logs/watches on many characters struct CombatTutorialContainer { private: CombatTutorialContainer::CombatTutorialContainer() : m_pobCombatEventLog ( 0 ) , m_pobEnt ( 0 ) { m_obCombatWatchList.clear(); }; public: CombatTutorialContainer::CombatTutorialContainer( CEntity* pobEnt ) { m_obCombatWatchList.clear(); m_pobCombatEventLog = NT_NEW CombatEventLog; if ( pobEnt && pobEnt->GetAttackComponent() ) { m_pobEnt = pobEnt; // Which events are we interested in? m_pobCombatEventLog->SetFlags( -1 ); m_pobEnt->GetAttackComponent()->RegisterCombatEventLog( m_pobCombatEventLog ); } }; CombatTutorialContainer::~CombatTutorialContainer( ) { if ( m_pobEnt ) { m_pobEnt->GetAttackComponent()->UnRegisterCombatEventLog( m_pobCombatEventLog ); m_pobEnt = 0; } for( CombatWatchList::iterator obIt = m_obCombatWatchList.begin(); obIt != m_obCombatWatchList.end(); ++obIt) { NT_DELETE ( (*obIt) ); } m_obCombatWatchList.clear(); if ( m_pobCombatEventLog ) { NT_DELETE (m_pobCombatEventLog); m_pobCombatEventLog = 0; } }; CombatWatchList m_obCombatWatchList; CombatEventLog* m_pobCombatEventLog; CEntity* m_pobEnt; }; protected: EntityWatchList m_obEntityWatchList; //CombatWatchList m_obCombatWatchList; ArcherWatchList m_obArcherWatchList; //CombatEventLog m_obCombatEventLog; ArcherEventLog m_obArcherEventLog; bool m_bRegistered; CPoint m_obTextPosition; CGuiUnit* m_pobScreenMsg; float m_fLastTimeScalar; float m_fAimTimeScalar; float m_fCurrTimeScalar; float m_fBlendTime; float m_fCurrBlendTime; ntstd::List< ntstd::pair < float, float > > m_aobTimeScalarQue; typedef ntstd::List< ntstd::pair < float, float > >::iterator TTSIt; CEntity* m_pobScalarCallbackEnt; CHashedString m_obScalarCallbackMsg; ntstd::Map< CEntity*, CombatTutorialContainer* > m_aobCombatTutorialList; typedef ntstd::Map< CEntity*, CombatTutorialContainer* >::iterator CTLIt; }; #endif // _TUTORIAL_H
[ "hopefullyidontgetbanned735@gmail.com" ]
hopefullyidontgetbanned735@gmail.com
e7fe54f671ac8cc7d4c4011ace2b8e5dcfbe0623
b7a5c0cf68124534bd3f482beca8a1a89f65e605
/etc/hhwin/StdAfx.cpp
ada605d1e1a29827552636a1a41869e47851594d
[]
no_license
willmomo/ry2kojima
032fe44a27c080c0d2731a827b1a328cc50c78dd
e65d4e278f7004e06744f22f6eff33529c1ec65b
refs/heads/master
2020-04-05T23:47:47.461217
2016-07-13T00:54:32
2016-07-13T00:54:32
63,201,963
1
0
null
null
null
null
SHIFT_JIS
C++
false
false
412
cpp
// stdafx.cpp : 標準インクルードファイルを含むソース ファイル // hhwin.pch 生成されるプリコンパイル済ヘッダー // stdafx.obj 生成されるプリコンパイル済タイプ情報 #include "stdafx.h" // TODO: STDAFX.H に含まれていて、このファイルに記述されていない // ヘッダーファイルを追加してください。
[ "ginna.strike@gmail.com" ]
ginna.strike@gmail.com
f02c1851f187417a09da9955fc4b2c6d4f0ca657
04b1803adb6653ecb7cb827c4f4aa616afacf629
/gpu/command_buffer/service/shared_context_state.cc
2010eb467073eb494b7a3aa2d60ca75f127b05aa
[ "BSD-3-Clause" ]
permissive
Samsung/Castanets
240d9338e097b75b3f669604315b06f7cf129d64
4896f732fc747dfdcfcbac3d442f2d2d42df264a
refs/heads/castanets_76_dev
2023-08-31T09:01:04.744346
2021-07-30T04:56:25
2021-08-11T05:45:21
125,484,161
58
49
BSD-3-Clause
2022-10-16T19:31:26
2018-03-16T08:07:37
null
UTF-8
C++
false
false
14,409
cc
// Copyright 2018 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "gpu/command_buffer/service/shared_context_state.h" #include "base/threading/thread_task_runner_handle.h" #include "base/trace_event/memory_dump_manager.h" #include "gpu/command_buffer/common/activity_flags.h" #include "gpu/command_buffer/service/context_state.h" #include "gpu/command_buffer/service/gl_context_virtual.h" #include "gpu/command_buffer/service/service_transfer_cache.h" #include "gpu/command_buffer/service/service_utils.h" #include "gpu/config/gpu_driver_bug_workarounds.h" #include "gpu/vulkan/buildflags.h" #include "ui/gl/gl_bindings.h" #include "ui/gl/gl_context.h" #include "ui/gl/gl_share_group.h" #include "ui/gl/gl_surface.h" #include "ui/gl/init/create_gr_gl_interface.h" #if BUILDFLAG(ENABLE_VULKAN) #include "components/viz/common/gpu/vulkan_context_provider.h" #endif #if defined(OS_MACOSX) #include "components/viz/common/gpu/metal_context_provider.h" #endif namespace { static constexpr size_t kInitialScratchDeserializationBufferSize = 1024; } namespace gpu { SharedContextState::SharedContextState( scoped_refptr<gl::GLShareGroup> share_group, scoped_refptr<gl::GLSurface> surface, scoped_refptr<gl::GLContext> context, bool use_virtualized_gl_contexts, base::OnceClosure context_lost_callback, viz::VulkanContextProvider* vulkan_context_provider, viz::MetalContextProvider* metal_context_provider) : use_virtualized_gl_contexts_(use_virtualized_gl_contexts), context_lost_callback_(std::move(context_lost_callback)), vk_context_provider_(vulkan_context_provider), metal_context_provider_(metal_context_provider), share_group_(std::move(share_group)), context_(context), real_context_(std::move(context)), surface_(std::move(surface)), weak_ptr_factory_(this) { if (GrContextIsVulkan()) { #if BUILDFLAG(ENABLE_VULKAN) gr_context_ = vk_context_provider_->GetGrContext(); #endif use_virtualized_gl_contexts_ = false; DCHECK(gr_context_); } if (GrContextIsMetal()) { #if defined(OS_MACOSX) gr_context_ = metal_context_provider_->GetGrContext(); #endif use_virtualized_gl_contexts_ = false; DCHECK(gr_context_); } if (base::ThreadTaskRunnerHandle::IsSet()) { base::trace_event::MemoryDumpManager::GetInstance()->RegisterDumpProvider( this, "SharedContextState", base::ThreadTaskRunnerHandle::Get()); } // Initialize the scratch buffer to some small initial size. scratch_deserialization_buffer_.resize( kInitialScratchDeserializationBufferSize); } SharedContextState::~SharedContextState() { // Delete the transfer cache first: that way, destruction callbacks for image // entries can use *|this| to make the context current and do GPU clean up. // The context should be current so that texture deletes that result from // destroying the cache happen in the right context (unless the context is // lost in which case we don't delete the textures). DCHECK(IsCurrent(nullptr) || context_lost_); transfer_cache_.reset(); // We should have the last ref on this GrContext to ensure we're not holding // onto any skia objects using this context. Note that some tests don't run // InitializeGrContext(), so |owned_gr_context_| is not expected to be // initialized. DCHECK(!owned_gr_context_ || owned_gr_context_->unique()); // Delete the GrContext. This will either do cleanup if the context is // current, or the GrContext was already abandoned if the GLContext was lost. owned_gr_context_.reset(); if (context_->IsCurrent(nullptr)) context_->ReleaseCurrent(nullptr); base::trace_event::MemoryDumpManager::GetInstance()->UnregisterDumpProvider( this); } void SharedContextState::InitializeGrContext( const GpuDriverBugWorkarounds& workarounds, GrContextOptions::PersistentCache* cache, GpuProcessActivityFlags* activity_flags, gl::ProgressReporter* progress_reporter) { progress_reporter_ = progress_reporter; #if defined(OS_MACOSX) if (metal_context_provider_) metal_context_provider_->SetProgressReporter(progress_reporter); #endif if (GrContextIsGL()) { DCHECK(context_->IsCurrent(nullptr)); sk_sp<GrGLInterface> interface(gl::init::CreateGrGLInterface( *context_->GetVersionInfo(), workarounds.use_es2_for_oopr, progress_reporter)); if (!interface) { LOG(ERROR) << "OOP raster support disabled: GrGLInterface creation " "failed."; return; } if (activity_flags && cache) { // |activity_flags| is safe to capture here since it must outlive the // this context state. interface->fFunctions.fProgramBinary = [activity_flags](GrGLuint program, GrGLenum binaryFormat, void* binary, GrGLsizei length) { GpuProcessActivityFlags::ScopedSetFlag scoped_set_flag( activity_flags, ActivityFlagsBase::FLAG_LOADING_PROGRAM_BINARY); glProgramBinary(program, binaryFormat, binary, length); }; } // If you make any changes to the GrContext::Options here that could // affect text rendering, make sure to match the capabilities initialized // in GetCapabilities and ensuring these are also used by the // PaintOpBufferSerializer. GrContextOptions options; options.fDriverBugWorkarounds = GrDriverBugWorkarounds(workarounds.ToIntSet()); options.fDisableCoverageCountingPaths = true; size_t max_resource_cache_bytes = 0u; raster::DetermineGrCacheLimitsFromAvailableMemory( &max_resource_cache_bytes, &glyph_cache_max_texture_bytes_); options.fGlyphCacheTextureMaximumBytes = glyph_cache_max_texture_bytes_; options.fPersistentCache = cache; options.fAvoidStencilBuffers = workarounds.avoid_stencil_buffers; options.fDisallowGLSLBinaryCaching = workarounds.disable_program_disk_cache; owned_gr_context_ = GrContext::MakeGL(std::move(interface), options); gr_context_ = owned_gr_context_.get(); if (!gr_context_) { LOG(ERROR) << "OOP raster support disabled: GrContext creation " "failed."; } else { constexpr int kMaxGaneshResourceCacheCount = 16384; gr_context_->setResourceCacheLimits(kMaxGaneshResourceCacheCount, max_resource_cache_bytes); } } transfer_cache_ = std::make_unique<ServiceTransferCache>(); } bool SharedContextState::InitializeGL( const GpuPreferences& gpu_preferences, scoped_refptr<gles2::FeatureInfo> feature_info) { // We still need initialize GL when Vulkan is used, because RasterDecoder // depends on GL. // TODO(penghuang): don't initialize GL when RasterDecoder can work without // GL. if (IsGLInitialized()) { DCHECK(feature_info == feature_info_); DCHECK(context_state_); return true; } DCHECK(context_->IsCurrent(nullptr)); bool use_passthrough_cmd_decoder = gpu_preferences.use_passthrough_cmd_decoder && gles2::PassthroughCommandDecoderSupported(); // Virtualized contexts don't work with passthrough command decoder. // See https://crbug.com/914976 DCHECK(!use_passthrough_cmd_decoder || !use_virtualized_gl_contexts_); feature_info_ = std::move(feature_info); feature_info_->Initialize(gpu::CONTEXT_TYPE_OPENGLES2, use_passthrough_cmd_decoder, gles2::DisallowedFeatures()); auto* api = gl::g_current_gl_context; const GLint kGLES2RequiredMinimumVertexAttribs = 8u; GLint max_vertex_attribs = 0; api->glGetIntegervFn(GL_MAX_VERTEX_ATTRIBS, &max_vertex_attribs); if (max_vertex_attribs < kGLES2RequiredMinimumVertexAttribs) { feature_info_ = nullptr; return false; } context_state_ = std::make_unique<gles2::ContextState>( feature_info_.get(), false /* track_texture_and_sampler_units */); context_state_->set_api(api); context_state_->InitGenericAttribs(max_vertex_attribs); // Set all the default state because some GL drivers get it wrong. // TODO(backer): Not all of this state needs to be initialized. Reduce the set // if perf becomes a problem. context_state_->InitCapabilities(nullptr); context_state_->InitState(nullptr); if (use_virtualized_gl_contexts_) { auto virtual_context = base::MakeRefCounted<GLContextVirtual>( share_group_.get(), real_context_.get(), weak_ptr_factory_.GetWeakPtr()); if (!virtual_context->Initialize(surface_.get(), gl::GLContextAttribs())) { feature_info_ = nullptr; context_state_ = nullptr; return false; } context_ = std::move(virtual_context); MakeCurrent(nullptr); } return true; } bool SharedContextState::MakeCurrent(gl::GLSurface* surface) { if (!GrContextIsGL()) return true; if (context_lost_) return false; if (!context_->MakeCurrent(surface ? surface : surface_.get())) { MarkContextLost(); return false; } return true; } void SharedContextState::MarkContextLost() { DCHECK(GrContextIsGL()); if (!context_lost_) { scoped_refptr<SharedContextState> prevent_last_ref_drop = this; context_lost_ = true; // context_state_ could be nullptr for some unittests. if (context_state_) context_state_->MarkContextLost(); if (gr_context_) gr_context_->abandonContext(); std::move(context_lost_callback_).Run(); for (auto& observer : context_lost_observers_) observer.OnContextLost(); } } bool SharedContextState::IsCurrent(gl::GLSurface* surface) { if (!GrContextIsGL()) return true; if (context_lost_) return false; return context_->IsCurrent(surface); } bool SharedContextState::OnMemoryDump( const base::trace_event::MemoryDumpArgs& args, base::trace_event::ProcessMemoryDump* pmd) { if (gr_context_) raster::DumpGrMemoryStatistics(gr_context_, pmd, base::nullopt); return true; } void SharedContextState::AddContextLostObserver(ContextLostObserver* obs) { context_lost_observers_.AddObserver(obs); } void SharedContextState::RemoveContextLostObserver(ContextLostObserver* obs) { context_lost_observers_.RemoveObserver(obs); } void SharedContextState::PurgeMemory( base::MemoryPressureListener::MemoryPressureLevel memory_pressure_level) { if (!gr_context_) { DCHECK(!transfer_cache_); return; } // Ensure the context is current before doing any GPU cleanup. MakeCurrent(nullptr); switch (memory_pressure_level) { case base::MemoryPressureListener::MEMORY_PRESSURE_LEVEL_NONE: // This function is only called with moderate or critical pressure. NOTREACHED(); return; case base::MemoryPressureListener::MEMORY_PRESSURE_LEVEL_MODERATE: // With moderate pressure, clear any unlocked resources. gr_context_->purgeUnlockedResources(true /* scratchResourcesOnly */); scratch_deserialization_buffer_.resize( kInitialScratchDeserializationBufferSize); scratch_deserialization_buffer_.shrink_to_fit(); break; case base::MemoryPressureListener::MEMORY_PRESSURE_LEVEL_CRITICAL: // With critical pressure, purge as much as possible. gr_context_->freeGpuResources(); scratch_deserialization_buffer_.resize(0u); scratch_deserialization_buffer_.shrink_to_fit(); break; } transfer_cache_->PurgeMemory(memory_pressure_level); } void SharedContextState::PessimisticallyResetGrContext() const { // Calling GrContext::resetContext() is very cheap, so we do it // pessimistically. We could dirty less state if skia state setting // performance becomes an issue. if (gr_context_ && GrContextIsGL()) gr_context_->resetContext(); } bool SharedContextState::initialized() const { return true; } const gles2::ContextState* SharedContextState::GetContextState() { if (need_context_state_reset_) { // Returning nullptr to force full state restoration by the caller. We do // this because GrContext changes to GL state are untracked in our // context_state_. return nullptr; } return context_state_.get(); } void SharedContextState::RestoreState(const gles2::ContextState* prev_state) { PessimisticallyResetGrContext(); context_state_->RestoreState(prev_state); need_context_state_reset_ = false; } void SharedContextState::RestoreGlobalState() const { PessimisticallyResetGrContext(); context_state_->RestoreGlobalState(nullptr); } void SharedContextState::ClearAllAttributes() const {} void SharedContextState::RestoreActiveTexture() const { PessimisticallyResetGrContext(); } void SharedContextState::RestoreAllTextureUnitAndSamplerBindings( const gles2::ContextState* prev_state) const { PessimisticallyResetGrContext(); } void SharedContextState::RestoreActiveTextureUnitBinding( unsigned int target) const { PessimisticallyResetGrContext(); } void SharedContextState::RestoreBufferBinding(unsigned int target) { PessimisticallyResetGrContext(); if (target == GL_PIXEL_PACK_BUFFER) { context_state_->UpdatePackParameters(); } else if (target == GL_PIXEL_UNPACK_BUFFER) { context_state_->UpdateUnpackParameters(); } context_state_->api()->glBindBufferFn(target, 0); } void SharedContextState::RestoreBufferBindings() const { PessimisticallyResetGrContext(); context_state_->RestoreBufferBindings(); } void SharedContextState::RestoreFramebufferBindings() const { PessimisticallyResetGrContext(); context_state_->fbo_binding_for_scissor_workaround_dirty = true; context_state_->stencil_state_changed_since_validation = true; } void SharedContextState::RestoreRenderbufferBindings() { PessimisticallyResetGrContext(); context_state_->RestoreRenderbufferBindings(); } void SharedContextState::RestoreProgramBindings() const { PessimisticallyResetGrContext(); context_state_->RestoreProgramSettings(nullptr, false); } void SharedContextState::RestoreTextureUnitBindings(unsigned unit) const { PessimisticallyResetGrContext(); } void SharedContextState::RestoreVertexAttribArray(unsigned index) { NOTIMPLEMENTED(); } void SharedContextState::RestoreAllExternalTextureBindingsIfNeeded() { PessimisticallyResetGrContext(); } QueryManager* SharedContextState::GetQueryManager() { return nullptr; } } // namespace gpu
[ "sunny.nam@samsung.com" ]
sunny.nam@samsung.com
5b81cea896e2a37adae55aa0d74b2b76116bbff3
71d9e6a2c3d35527a8ca62a12e0888755f6ebcfa
/playground/playground/smol/model_manager.h
9b5f54e336d8f4315ad3a34b8d83f33a0b27b039
[]
no_license
biomorphs/Playground
178acf661a4e99f6d76a03d15177233e69e2a17a
509264222d55500793f3bae200a123f8e443ceac
refs/heads/master
2021-06-29T01:05:07.336065
2021-01-03T03:44:26
2021-01-03T03:44:26
200,742,219
0
0
null
null
null
null
UTF-8
C++
false
false
1,757
h
#pragma once #include "model.h" #include "kernel/mutex.h" #include "../model_asset.h" #include "render/mesh_builder.h" #include <string> #include <vector> #include <memory> namespace SDE { class JobSystem; } namespace DebugGui { class DebugGuiSystem; } namespace smol { class TextureManager; struct ModelHandle { uint16_t m_index = -1; static ModelHandle Invalid() { return { (uint16_t)-1 }; }; }; class ModelManager { public: ModelManager(TextureManager* tm, SDE::JobSystem* js); ~ModelManager() = default; ModelManager(const ModelManager&) = delete; ModelManager(ModelManager&&) = delete; ModelHandle LoadModel(const char* path); Model* GetModel(const ModelHandle& h); void ProcessLoadedModels(); bool ShowGui(DebugGui::DebugGuiSystem& gui); void ReloadAll(); private: struct ModelDesc { std::unique_ptr<Model> m_model; std::string m_name; }; struct ModelLoadResult { std::unique_ptr<Assets::Model> m_model; std::unique_ptr<Model> m_renderModel; std::vector<std::unique_ptr<Render::MeshBuilder>> m_meshBuilders; ModelHandle m_destinationHandle; }; std::unique_ptr<Render::MeshBuilder> CreateBuilderForPart(const Assets::ModelMesh&); std::unique_ptr<Model> CreateModel(Assets::Model& model, const std::vector<std::unique_ptr<Render::MeshBuilder>>& meshBuilders); void FinaliseModel(Assets::Model& model, Model& renderModel, const std::vector<std::unique_ptr<Render::MeshBuilder>>& meshBuilders); std::vector<ModelDesc> m_models; Kernel::Mutex m_loadedModelsMutex; std::vector<ModelLoadResult> m_loadedModels; // models to process after successful load Kernel::AtomicInt32 m_inFlightModels = 0; TextureManager* m_textureManager; SDE::JobSystem* m_jobSystem; }; }
[ "matt.hoyle@gmail.com" ]
matt.hoyle@gmail.com
ea9cbb26e882c03061329662b2822ac0f49e0c89
a2eca70a9a7f2dbf586adb9251d8ddc3ed453497
/src/studio/synfigapp/actions/valuedescconnect.cpp
911de0506f3b3a1a636401c73372ed9192bc1b8e
[]
no_license
eshikafe/wxSynfig
03654379bfc6872cd82bfa2bbb928d4fd9f7a38f
35573f9c125dc645b1320172bce968a4512fa8f4
refs/heads/master
2021-06-15T02:30:59.511757
2019-11-20T07:26:19
2019-11-20T07:26:19
51,330,475
8
0
null
null
null
null
UTF-8
C++
false
false
7,218
cpp
/* === S Y N F I G ========================================================= */ /*! \file valuedescconnect.cpp ** \brief Template File ** ** $Id$ ** ** \legal ** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley ** Copyright (c) 2008 Chris Moore ** ** This package 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 package 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. ** \endlegal */ /* ========================================================================= */ /* === H E A D E R S ======================================================= */ #ifdef USING_PCH # include "pch.h" #else #ifdef HAVE_CONFIG_H # include <config.h> #endif #include "layerparamconnect.h" #include "waypointconnect.h" #include "valuenodelinkconnect.h" #include "valuenodereplace.h" #include "valuedescconnect.h" #include <synfigapp/canvasinterface.h> #include <synfigapp/general.h> #endif using namespace std; using namespace etl; using namespace synfig; using namespace synfigapp; using namespace Action; /* === M A C R O S ========================================================= */ ACTION_INIT_NO_GET_LOCAL_NAME(Action::ValueDescConnect); ACTION_SET_NAME(Action::ValueDescConnect,"ValueDescConnect"); ACTION_SET_LOCAL_NAME(Action::ValueDescConnect,N_("Connect")); ACTION_SET_TASK(Action::ValueDescConnect,"connect"); ACTION_SET_CATEGORY(Action::ValueDescConnect,Action::CATEGORY_VALUEDESC|Action::CATEGORY_VALUENODE); ACTION_SET_PRIORITY(Action::ValueDescConnect,0); ACTION_SET_VERSION(Action::ValueDescConnect,"0.0"); ACTION_SET_CVS_ID(Action::ValueDescConnect,"$Id$"); /* === G L O B A L S ======================================================= */ /* === P R O C E D U R E S ================================================= */ /* === M E T H O D S ======================================================= */ Action::ValueDescConnect::ValueDescConnect() { } synfig::String Action::ValueDescConnect::get_local_name()const { // TRANSLATORS: This is used in the 'history' dialog when a connection is made. return strprintf(_("Connect '%s' to '%s'"), value_desc.get_description(false).c_str(), value_node->get_id().c_str()); } Action::ParamVocab Action::ValueDescConnect::get_param_vocab() { ParamVocab ret(Action::CanvasSpecific::get_param_vocab()); ret.push_back(ParamDesc("dest",Param::TYPE_VALUEDESC) .set_local_name(_("Destination ValueDesc")) ); ret.push_back(ParamDesc("src",Param::TYPE_VALUENODE) .set_local_name(_("Source ValueNode")) .set_mutual_exclusion("src_name") ); ret.push_back(ParamDesc("src_name",Param::TYPE_STRING) .set_local_name(_("Source ValueNode Name")) .set_mutual_exclusion("src") .set_user_supplied() ); return ret; } bool Action::ValueDescConnect::is_candidate(const ParamList &x) { if(candidate_check(get_param_vocab(),x)) { ValueDesc value_desc(x.find("dest")->second.get_value_desc()); ValueNode::Handle value_node(x.find("src")->second.get_value_node()); //! forbid recursive linking (fix #48) if (value_desc.parent_is_value_node()) { ValueNode* vn = dynamic_cast<ValueNode*>(value_node.get()); if (vn && vn->is_descendant(value_desc.get_parent_value_node())) return false; } // don't show the option of connecting to an existing Index parameter of the Duplicate layer if(x.count("dest")) { if (value_desc.parent_is_layer() && value_desc.get_layer()->get_name() == "duplicate" && value_desc.get_param_name() == "index") return false; } if(x.count("src")) { if(value_desc.get_value_type()==value_node->get_type()) return true; } return true; } return false; } bool Action::ValueDescConnect::set_param(const synfig::String& name, const Action::Param &param) { if(name=="dest" && param.get_type()==Param::TYPE_VALUEDESC) { value_desc=param.get_value_desc(); return true; } if(name=="src" && param.get_type()==Param::TYPE_VALUENODE) { value_node=param.get_value_node(); return true; } if(!value_node_name.empty() && !value_node && name=="canvas" && param.get_type()==Param::TYPE_CANVAS) { value_node=param.get_canvas()->find_value_node(value_node_name, false); } if(name=="src_name" && param.get_type()==Param::TYPE_STRING) { value_node_name=param.get_string(); if(get_canvas()) { value_node=get_canvas()->find_value_node(value_node_name, false); if(!value_node) return false; } return true; } return Action::CanvasSpecific::set_param(name,param); } bool Action::ValueDescConnect::is_ready()const { if(!value_desc || !value_node) return false; return Action::CanvasSpecific::is_ready(); } void Action::ValueDescConnect::prepare() { clear(); if(value_desc.parent_is_canvas()) { ValueNode::Handle dest_value_node; dest_value_node=value_desc.get_value_node(); Action::Handle action(ValueNodeReplace::create()); action->set_param("canvas",get_canvas()); action->set_param("canvas_interface",get_canvas_interface()); action->set_param("src",value_node); action->set_param("dest",value_desc.get_value_node()); assert(action->is_ready()); if(!action->is_ready()) throw Error(Error::TYPE_NOTREADY); add_action_front(action); return; } else if(value_desc.parent_is_waypoint()) { Action::Handle action(WaypointConnect::create()); action->set_param("canvas",get_canvas()); action->set_param("canvas_interface",get_canvas_interface()); action->set_param("parent_value_node",value_desc.get_parent_value_node()); action->set_param("value_node", value_node); action->set_param("waypoint_time",value_desc.get_waypoint_time()); assert(action->is_ready()); if(!action->is_ready()) throw Error(Error::TYPE_NOTREADY); add_action_front(action); return; } if(value_desc.parent_is_linkable_value_node()) { Action::Handle action(ValueNodeLinkConnect::create()); action->set_param("canvas",get_canvas()); action->set_param("canvas_interface",get_canvas_interface()); action->set_param("parent_value_node",value_desc.get_parent_value_node()); action->set_param("value_node", value_node); action->set_param("index",value_desc.get_index()); assert(action->is_ready()); if(!action->is_ready()) throw Error(Error::TYPE_NOTREADY); add_action_front(action); return; } else if(value_desc.parent_is_layer()) { Action::Handle action(LayerParamConnect::create()); action->set_param("canvas",get_canvas()); action->set_param("canvas_interface",get_canvas_interface()); action->set_param("layer",value_desc.get_layer()); action->set_param("param",value_desc.get_param_name()); action->set_param("value_node",value_node); assert(action->is_ready()); if(!action->is_ready()) throw Error(Error::TYPE_NOTREADY); add_action_front(action); return; } throw Error(_("ValueDesc is not recognized or supported.")); }
[ "eshikafe@gmail.com" ]
eshikafe@gmail.com
d5545b514ebea958d6d7b229c217d4f2a1c3bd08
2d2c69acda9154755be0a22b9ec1b710789a5bf0
/LeetCode/leetcode-march-2021/week2/Coin Change.cpp
f08cc8fca0f4a0d76aa579beb5b3ae3f937bcedf
[]
no_license
Kalit31/cp-playground
2f74282a29222a308c022115e1a733ed2ed8dd6f
572b543403498ffa12e80236a245bd7fb71249dd
refs/heads/master
2023-06-26T21:50:26.676082
2021-07-31T08:45:15
2021-07-31T08:45:15
228,023,746
0
0
null
null
null
null
UTF-8
C++
false
false
627
cpp
#include <bits/stdc++.h> using namespace std; class Solution { public: int coinChange(vector<int> &coins, int amount) { int n = coins.size(); vector<int> ways(amount + 1, INT_MAX); ways[0] = 0; for (int i = 0; i <= amount; i++) { for (int j = 0; j < n; j++) { if (i - coins[j] >= 0) { if (ways[i - coins[j]] != INT_MAX) ways[i] = min(ways[i], 1 + ways[i - coins[j]]); } } } return ways[amount] == INT_MAX ? -1 : ways[amount]; } };
[ "inanikalit31@gmail.com" ]
inanikalit31@gmail.com
84a04dd4a4c0225b7474f119e5194b9f629fa019
7182b78c0ecf8b99d9e5db315b34b7c7577b779b
/old_complete/dynamol/trunk/Main_Build/dynamol/sdreader.h
abfafa95250d00251283360fd68231303a224981
[]
no_license
gnulnx/dynamol
cbc85abf3d23c9af508576731d06f8ba372449db
88a1000563f1d49793df8a404eff0fe8768b46b4
refs/heads/master
2016-09-06T11:20:54.279297
2015-04-09T14:02:42
2015-04-09T14:02:42
32,398,825
0
0
null
null
null
null
UTF-8
C++
false
false
2,551
h
/*************************************************************************** * Copyright (C) 2004 by Dynamol Inc. * emai: john.furr@dynamol.com ***************************************************************************/ #ifndef SDREADER_H #define SDREADER_H #include <map> #include <string> #include <vector> #include <qstring.h> using namespace std; /** @author jfurr This class provides functionality that enables you to read idividual records from an SD file based on either position or name. To that end it allows you to check for records of a certain name in the SD file. This will probably replace the molDB sd readers in the future */ class molecule; class sdReader{ public: sdReader(); ~sdReader(); /** \brief Returns the number records in the file * * Scans the sd file and stores the offset in the sdFileMap * typical usage: * <pre> * int numRecords = sdReader::scanSDFile(fileName); * for (int i=0; i< numRecords; i++) { * molecule * mol = sdReader::getMolNum(); * } * </pre> */ int scanSDFile(string fileName); /** \brief Return the molecule * * Return the molecule at position. This file is used in conjunction with * scanSDFile */ molecule *getMolPos(int pos); /** \brief Used to store recNum, offset maps * * This map is cleared and recreated every time scanSDFile is called */ map<int, long long int> posMap; private: /** \brief Used to store the location of records by name * * This map stores the offset location to each record by name */ multimap<QString, long long int> nameMap; /** \brief The currFileName * * This is the current fileName that sd records are read from */ string currFileName; /** \brief Return the molecule from the file * * This function reads the molecule at {offset} * from the file {fileName} and returns it; */ molecule *readSD(QString fileName, int offset); /** \brief Check to see if str is a Number (Float) * * This function is used to insure that the str is a number * It is called by readSD to make sure that the atomNum and bdNum * Make sense */ bool checkFloatNum(string &str); /** \brief Check to see if str is an Integer * * This function is used to insure that the str is a number * It is called by readSD to make sure that the atomNum and bdNum * Make sense */ bool checkIntNum(string &str); }; #endif
[ "jfurr@Johns-MacBook-Pro.local" ]
jfurr@Johns-MacBook-Pro.local
5ae8793f0173297d119334e1df3fbcf7d65bcd7d
d5b54169afcb81a5e7f11953915c7b0876f23052
/syntex-master/src/chainparamsbase.cpp
e99a1854b104a89f20c813a31b3b11f03fb0e2c7
[ "MIT" ]
permissive
syntexcoin/SynteX
f74751637f9ba0ab1537d3ca8dff126d411aa0eb
03c1cc14502077c48d6e89711bfc34dc7a1f54f9
refs/heads/master
2020-03-21T16:09:31.399397
2018-07-01T00:04:07
2018-07-01T00:04:07
138,754,006
0
0
null
null
null
null
UTF-8
C++
false
false
2,778
cpp
// Copyright (c) 2010 Satoshi Nakamoto // Copyright (c) 2009-2014 The Bitcoin developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. #include "chainparamsbase.h" #include "util.h" #include <assert.h> #include <boost/assign/list_of.hpp> using namespace boost::assign; /** * Main network */ class CBaseMainParams : public CBaseChainParams { public: CBaseMainParams() { networkID = CBaseChainParams::MAIN; nRPCPort = 9334; } }; static CBaseMainParams mainParams; /** * Testnet (v3) */ class CBaseTestNetParams : public CBaseMainParams { public: CBaseTestNetParams() { networkID = CBaseChainParams::TESTNET; nRPCPort = 19334; strDataDir = "testnet4"; } }; static CBaseTestNetParams testNetParams; /* * Regression test */ class CBaseRegTestParams : public CBaseTestNetParams { public: CBaseRegTestParams() { networkID = CBaseChainParams::REGTEST; strDataDir = "regtest"; } }; static CBaseRegTestParams regTestParams; /* * Unit test */ class CBaseUnitTestParams : public CBaseMainParams { public: CBaseUnitTestParams() { networkID = CBaseChainParams::UNITTEST; strDataDir = "unittest"; } }; static CBaseUnitTestParams unitTestParams; static CBaseChainParams* pCurrentBaseParams = 0; const CBaseChainParams& BaseParams() { assert(pCurrentBaseParams); return *pCurrentBaseParams; } void SelectBaseParams(CBaseChainParams::Network network) { switch (network) { case CBaseChainParams::MAIN: pCurrentBaseParams = &mainParams; break; case CBaseChainParams::TESTNET: pCurrentBaseParams = &testNetParams; break; case CBaseChainParams::REGTEST: pCurrentBaseParams = &regTestParams; break; case CBaseChainParams::UNITTEST: pCurrentBaseParams = &unitTestParams; break; default: assert(false && "Unimplemented network"); return; } } CBaseChainParams::Network NetworkIdFromCommandLine() { bool fRegTest = GetBoolArg("-regtest", false); bool fTestNet = GetBoolArg("-testnet", false); if (fTestNet && fRegTest) return CBaseChainParams::MAX_NETWORK_TYPES; if (fRegTest) return CBaseChainParams::REGTEST; if (fTestNet) return CBaseChainParams::TESTNET; return CBaseChainParams::MAIN; } bool SelectBaseParamsFromCommandLine() { CBaseChainParams::Network network = NetworkIdFromCommandLine(); if (network == CBaseChainParams::MAX_NETWORK_TYPES) return false; SelectBaseParams(network); return true; } bool AreBaseParamsConfigured() { return pCurrentBaseParams != NULL; }
[ "marcin@debian.DOM" ]
marcin@debian.DOM
2fcc0026f83f5bdb730066b42e561388a0e2c27d
ee4f338aebedc47b06bd08fd35eada5aa81c7a91
/SDK/BZ_UI_BoatMarker_classes.hpp
1f4e406b20b7ba1788da1640d0fde9bdb395bb83
[]
no_license
Hengle/BlazingSails_SDK
5cf1ff31e0ac314aa841d7b55d0409e3e659e488
8a70c90a01d65c6cbd25f3dfdd1a8262714d3a60
refs/heads/master
2023-03-17T11:11:09.896530
2020-01-28T19:46:17
2020-01-28T19:46:17
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,316
hpp
#pragma once // BlazingSails (Dumped by Hinnie) SDK #ifdef _MSC_VER #pragma pack(push, 0x8) #endif namespace SDK { //--------------------------------------------------------------------------- //Classes //--------------------------------------------------------------------------- // WidgetBlueprintGeneratedClass UI_BoatMarker.UI_BoatMarker_C // 0x0008 (0x0210 - 0x0208) class UUI_BoatMarker_C : public UUserWidget { public: class UImage* Image_90; // 0x0208(0x0008) (BlueprintVisible, ExportObject, ZeroConstructor, InstancedReference, IsPlainOldData, RepSkip, RepNotify, Interp, NonTransactional, EditorOnly, NoDestructor, AutoWeak, ContainsInstancedReference, AssetRegistrySearchable, SimpleDisplay, AdvancedDisplay, Protected, BlueprintCallable, BlueprintAuthorityOnly, TextExportTransient, NonPIEDuplicateTransient, ExposeOnSpawn, PersistentInstance, UObjectWrapper, HasGetValueTypeHash, NativeAccessSpecifierPublic, NativeAccessSpecifierProtected, NativeAccessSpecifierPrivate) static UClass* StaticClass() { static auto ptr = UObject::FindClass("WidgetBlueprintGeneratedClass UI_BoatMarker.UI_BoatMarker_C"); return ptr; } }; } #ifdef _MSC_VER #pragma pack(pop) #endif
[ "hsibma02@gmail.com" ]
hsibma02@gmail.com
ad6b066a14f7f7cfc01618e7b804447214bc5851
86535d64213d939a507cb45ea5627d89b910f6bb
/abel/container/internal/hashtable_debug.h
94a5f96b8b8b6ec92d30d008bd57767c2c7ccb26
[ "BSD-3-Clause" ]
permissive
Conun/abel
4afcd24d844e5380abde3cb8a8fbb88b2274bb4c
485ef38c917c0df3750242cc38966a2bcb163588
refs/heads/master
2020-12-29T13:51:26.721782
2020-02-07T07:35:04
2020-02-07T07:35:04
238,627,584
0
0
BSD-3-Clause
2020-02-06T07:02:49
2020-02-06T07:02:48
null
UTF-8
C++
false
false
3,494
h
// // This library provides APIs to debug the probing behavior of hash tables. // // In general, the probing behavior is a black box for users and only the // side effects can be measured in the form of performance differences. // These APIs give a glimpse on the actual behavior of the probing algorithms in // these hashtables given a specified hash function and a set of elements. // // The probe count distribution can be used to assess the quality of the hash // function for that particular hash table. Note that a hash function that // performs well in one hash table implementation does not necessarily performs // well in a different one. // // This library supports std::unordered_{set,map}, dense_hash_{set,map} and // abel::{flat,node,string}_hash_{set,map}. #ifndef ABEL_CONTAINER_INTERNAL_HASHTABLE_DEBUG_H_ #define ABEL_CONTAINER_INTERNAL_HASHTABLE_DEBUG_H_ #include <cstddef> #include <algorithm> #include <type_traits> #include <vector> #include <abel/container/internal/hashtable_debug_hooks.h> namespace abel { namespace container_internal { // Returns the number of probes required to lookup `key`. Returns 0 for a // search with no collisions. Higher values mean more hash collisions occurred; // however, the exact meaning of this number varies according to the container // type. template <typename C> size_t GetHashtableDebugNumProbes( const C& c, const typename C::key_type& key) { return abel::container_internal::hashtable_debug_internal:: HashtableDebugAccess<C>::GetNumProbes(c, key); } // Gets a histogram of the number of probes for each elements in the container. // The sum of all the values in the vector is equal to container.size(). template <typename C> std::vector<size_t> GetHashtableDebugNumProbesHistogram(const C& container) { std::vector<size_t> v; for (auto it = container.begin(); it != container.end(); ++it) { size_t num_probes = GetHashtableDebugNumProbes( container, abel::container_internal::hashtable_debug_internal::GetKey<C>(*it, 0)); v.resize((std::max)(v.size(), num_probes + 1)); v[num_probes]++; } return v; } struct HashtableDebugProbeSummary { size_t total_elements; size_t total_num_probes; double mean; }; // Gets a summary of the probe count distribution for the elements in the // container. template <typename C> HashtableDebugProbeSummary GetHashtableDebugProbeSummary(const C& container) { auto probes = GetHashtableDebugNumProbesHistogram(container); HashtableDebugProbeSummary summary = {}; for (size_t i = 0; i < probes.size(); ++i) { summary.total_elements += probes[i]; summary.total_num_probes += probes[i] * i; } summary.mean = 1.0 * summary.total_num_probes / summary.total_elements; return summary; } // Returns the number of bytes requested from the allocator by the container // and not freed. template <typename C> size_t AllocatedByteSize(const C& c) { return abel::container_internal::hashtable_debug_internal:: HashtableDebugAccess<C>::AllocatedByteSize(c); } // Returns a tight lower bound for AllocatedByteSize(c) where `c` is of type `C` // and `c.size()` is equal to `num_elements`. template <typename C> size_t LowerBoundAllocatedByteSize(size_t num_elements) { return abel::container_internal::hashtable_debug_internal:: HashtableDebugAccess<C>::LowerBoundAllocatedByteSize(num_elements); } } // namespace container_internal } // namespace abel #endif // ABEL_CONTAINER_INTERNAL_HASHTABLE_DEBUG_H_
[ "lijippy@163.com" ]
lijippy@163.com
c9c5fad65f6f986b6591ccabcccde6f03f7271fa
25c5fe54bad995965174408c15d886f0cb2ae508
/include/BankAccountExample.hpp
5b68f2868beb3de835ea2033b2ce918cf22681fc
[]
no_license
6842-Panther-Robotics/Warner.O.Workshop
db0198918f52321d319bdb531ac2b9895137893f
f0b4d2f347d58234d3bbe201f816a9e543bcf4c5
refs/heads/master
2021-06-13T21:30:48.691312
2020-04-09T19:06:21
2020-04-09T19:06:21
254,450,856
0
0
null
null
null
null
UTF-8
C++
false
false
202
hpp
class BankAccount { private: double balance; public: BankAccount (double amount); BankAccount (); void deposit(double amount); void withdraw(double amount); double getBalance(); };
[ "Owenjwarner@gmail.com" ]
Owenjwarner@gmail.com
7ffdc1a5e8e2f31b535cfe9c0319a64b61487b65
9eb10f8619ff31ee6f498b16af8d347a265ae3ce
/v8vm/vm_util.h
f5abff4e1b5fbe6093f036e0e755e3f25bd4befe
[ "NAIST-2003", "BSD-3-Clause", "Zlib", "ICU", "LicenseRef-scancode-unknown-license-reference", "MIT", "NTP", "LicenseRef-scancode-openssl", "Artistic-2.0", "ISC", "LicenseRef-scancode-public-domain", "BSD-2-Clause", "LicenseRef-scancode-unicode" ]
permissive
CFHH/node
2cd779035344cdb5bcfa9f2e7e7b4d58c18fed19
36d5deb3cd4d0104dd3e0f52532b6d614ab8a048
refs/heads/master
2020-03-22T09:25:14.266026
2019-07-09T06:32:06
2019-07-09T06:32:06
139,836,169
0
1
null
null
null
null
UTF-8
C++
false
false
3,583
h
#pragma once #include <stdlib.h> extern bool v8_initialized; #define DISALLOW_COPY_AND_ASSIGN(TypeName) \ void operator=(const TypeName&) = delete; \ void operator=(TypeName&&) = delete; \ TypeName(const TypeName&) = delete; \ TypeName(TypeName&&) = delete #define STRINGIFY(x) STRINGIFY_(x) #define STRINGIFY_(x) #x #ifdef __GNUC__ #define NO_RETURN __attribute__((noreturn)) #else #define NO_RETURN #endif NO_RETURN void Abort(); NO_RETURN void Assert(const char* const (*args)[4]); #ifdef _WIN32 #define ABORT_NO_BACKTRACE() _exit(134) #else #define ABORT_NO_BACKTRACE() abort() #endif #define ABORT() Abort() #ifdef __GNUC__ #define LIKELY(expr) __builtin_expect(!!(expr), 1) #define UNLIKELY(expr) __builtin_expect(!!(expr), 0) #define PRETTY_FUNCTION_NAME __PRETTY_FUNCTION__ #else #define LIKELY(expr) expr #define UNLIKELY(expr) expr #define PRETTY_FUNCTION_NAME "" #endif #define CHECK(expr) \ do { \ if (UNLIKELY(!(expr))) { \ static const char* const args[] = { __FILE__, STRINGIFY(__LINE__), \ #expr, PRETTY_FUNCTION_NAME }; \ Assert(&args); \ } \ } while (0) #define CHECK_EQ(a, b) CHECK((a) == (b)) #define CHECK_GE(a, b) CHECK((a) >= (b)) #define CHECK_GT(a, b) CHECK((a) > (b)) #define CHECK_LE(a, b) CHECK((a) <= (b)) #define CHECK_LT(a, b) CHECK((a) < (b)) #define CHECK_NE(a, b) CHECK((a) != (b)) #define CHECK_NULL(val) CHECK((val) == nullptr) #define CHECK_NOT_NULL(val) CHECK((val) != nullptr) #define CHECK_IMPLIES(a, b) CHECK(!(a) || (b)) template <typename T> inline T MultiplyWithOverflowCheck(T a, T b) { auto ret = a * b; if (a != 0) CHECK_EQ(b, ret / a); return ret; } void LowMemoryNotification(); template <typename T> T* UncheckedRealloc(T* pointer, size_t n) { size_t full_size = MultiplyWithOverflowCheck(sizeof(T), n); if (full_size == 0) { free(pointer); return nullptr; } void* allocated = realloc(pointer, full_size); if (UNLIKELY(allocated == nullptr)) { LowMemoryNotification(); allocated = realloc(pointer, full_size); } return static_cast<T*>(allocated); } template <typename T> inline T* UncheckedMalloc(size_t n) { if (n == 0) n = 1; return UncheckedRealloc<T>(nullptr, n); } template <typename T> inline T* UncheckedCalloc(size_t n) { if (n == 0) n = 1; MultiplyWithOverflowCheck(sizeof(T), n); return static_cast<T*>(calloc(n, sizeof(T))); } template <typename T> inline T* Realloc(T* pointer, size_t n) { T* ret = UncheckedRealloc(pointer, n); CHECK_IMPLIES(n > 0, ret != nullptr); return ret; } template <typename T> inline T* Malloc(size_t n) { T* ret = UncheckedMalloc<T>(n); CHECK_IMPLIES(n > 0, ret != nullptr); return ret; } template <typename T> inline T* Calloc(size_t n) { T* ret = UncheckedCalloc<T>(n); CHECK_IMPLIES(n > 0, ret != nullptr); return ret; } inline char* Malloc(size_t n) { return Malloc<char>(n); } inline char* Calloc(size_t n) { return Calloc<char>(n); } inline char* UncheckedMalloc(size_t n) { return UncheckedMalloc<char>(n); } inline char* UncheckedCalloc(size_t n) { return UncheckedCalloc<char>(n); }
[ "13436361@qq.com" ]
13436361@qq.com
07aa729a64a73441de1539e043802ac2af6732f1
2aa15f77370f199c965d54ab68c3056438e0d901
/ex3/src/ourGenerators/Generator.cpp
8e8729dc1b143b3a1aef54474ec3626179afd633
[]
no_license
artemmensk/ex-of-kk
771d6c636fdf48191dd729c6ca392b4122a9e6c0
5e10f5f04a96069880ad4fa003a991fd5d0b957d
refs/heads/master
2021-01-02T09:27:41.677818
2014-06-05T09:19:00
2014-06-05T09:19:00
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,705
cpp
#include "Generator.h" // ------------------------------------------------------------------------- const int Generator::DEFAULT_MIN_VALUE = 1; const int Generator::DEFAULT_VARIABLE_A = 16807; const int Generator::DEFAULT_VARIABLE_B = 21; const int Generator::DEFAULT_VARIABLE_C = 888; // ------------------------------------------------------------------------- int Generator::getSeed() { return seed; } // ------------------------------------------------------------------------- int Generator::getMinValue() { return minValue; } // ------------------------------------------------------------------------- int Generator::getMaxValue() { return maxValue; } // ------------------------------------------------------------------------- int Generator::getVariableA() { return variableA; } // ------------------------------------------------------------------------- int Generator::getVariableB() { return variableB; } // ------------------------------------------------------------------------- int Generator::getVariableC() { return variableC; } // ------------------------------------------------------------------------- void Generator::setSeed() { seed = time(NULL); } // ------------------------------------------------------------------------- void Generator::setRange() { minValue = DEFAULT_MIN_VALUE; maxValue = std::numeric_limits<int>::max(); } // ------------------------------------------------------------------------- void Generator::setVariables() { variableA = DEFAULT_VARIABLE_A; variableB = DEFAULT_VARIABLE_B; variableC = DEFAULT_VARIABLE_C; } // ------------------------------------------------------------------------- void Generator::setSeed(int _seed) { seed = _seed; } // ------------------------------------------------------------------------- void Generator::setRange(int _minValue, int _maxValue) { minValue = _minValue; maxValue = _maxValue; } // ------------------------------------------------------------------------- void Generator::setVariables(int _variableA, int _variableB, int _variableC) { variableA = _variableA; variableB = _variableB; variableC = _variableC; } // ------------------------------------------------------------------------- std::string& Generator::getGeneratorName() { return generatorName; } // ------------------------------------------------------------------------- void Generator::setGeneratorName(std::string _generatorName) { generatorName = _generatorName; } // ------------------------------------------------------------------------- void Generator::print(std::ostream& out){ out << getSeed() << " "; } // -------------------------------------------------------------------------
[ "artemmensk@gmail.com" ]
artemmensk@gmail.com