diff --git a/client/draft/ydb_dynamic_config.cpp b/client/draft/ydb_dynamic_config.cpp index e4cfceb0d07..e3b1553d0b2 100644 --- a/client/draft/ydb_dynamic_config.cpp +++ b/client/draft/ydb_dynamic_config.cpp @@ -122,7 +122,7 @@ class TDynamicConfigClient::TImpl : public TClientImplCommon(); auto extractor = [promise] (google::protobuf::Any* any, TPlainStatus status) mutable { - TMap labels; + std::map labels; if (Ydb::DynamicConfig::GetNodeLabelsResult result; any && any->UnpackTo(&result)) { for (auto& label : result.labels()) { labels[label.label()] = label.value(); @@ -153,7 +153,7 @@ class TDynamicConfigClient::TImpl : public TClientImplCommon volatileConfigs; + std::map volatileConfigs; if (Ydb::DynamicConfig::GetConfigResult result; any && any->UnpackTo(&result)) { clusterName = result.identity().cluster(); version = result.identity().version(); @@ -185,7 +185,7 @@ class TDynamicConfigClient::TImpl : public TClientImplCommon volatileConfigs; + std::map volatileConfigs; if (Ydb::DynamicConfig::GetMetadataResult result; any && any->UnpackTo(&result)) { metadata = result.metadata(); for (const auto& config : result.volatile_configs()) { @@ -208,7 +208,7 @@ class TDynamicConfigClient::TImpl : public TClientImplCommon& volatileConfigs, const TMap& labels, const TClusterConfigSettings& settings = {}) { + TAsyncResolveConfigResult ResolveConfig(const TString& config, const std::map& volatileConfigs, const std::map& labels, const TClusterConfigSettings& settings = {}) { auto request = MakeOperationRequest(settings); request.set_config(config); for (auto& [id, volatileConfig] : volatileConfigs) { @@ -245,7 +245,7 @@ class TDynamicConfigClient::TImpl : public TClientImplCommon& volatileConfigs, const TClusterConfigSettings& settings = {}) { + TAsyncResolveConfigResult ResolveConfig(const TString& config, const std::map& volatileConfigs, const TClusterConfigSettings& settings = {}) { auto request = MakeOperationRequest(settings); request.set_config(config); for (auto& [id, volatileConfig] : volatileConfigs) { @@ -277,7 +277,7 @@ class TDynamicConfigClient::TImpl : public TClientImplCommon& volatileConfigs, const TClusterConfigSettings& settings = {}) { + TAsyncVerboseResolveConfigResult VerboseResolveConfig(const TString& config, const std::map& volatileConfigs, const TClusterConfigSettings& settings = {}) { auto request = MakeOperationRequest(settings); request.set_config(config); for (auto& [id, volatileConfig] : volatileConfigs) { @@ -410,22 +410,22 @@ TAsyncGetNodeLabelsResult TDynamicConfigClient::GetNodeLabels(ui64 nodeId, const TAsyncResolveConfigResult TDynamicConfigClient::ResolveConfig( const TString& config, - const TMap& volatileConfigs, - const TMap& labels, + const std::map& volatileConfigs, + const std::map& labels, const TClusterConfigSettings& settings) { return Impl_->ResolveConfig(config, volatileConfigs, labels, settings); } TAsyncResolveConfigResult TDynamicConfigClient::ResolveConfig( const TString& config, - const TMap& volatileConfigs, + const std::map& volatileConfigs, const TClusterConfigSettings& settings) { return Impl_->ResolveConfig(config, volatileConfigs, settings); } TAsyncVerboseResolveConfigResult TDynamicConfigClient::VerboseResolveConfig( const TString& config, - const TMap& volatileConfigs, + const std::map& volatileConfigs, const TClusterConfigSettings& settings) { return Impl_->VerboseResolveConfig(config, volatileConfigs, settings); } diff --git a/client/draft/ydb_dynamic_config.h b/client/draft/ydb_dynamic_config.h index 25c9457b38c..a9d3b2edb8b 100644 --- a/client/draft/ydb_dynamic_config.h +++ b/client/draft/ydb_dynamic_config.h @@ -9,7 +9,6 @@ #include #include -#include #include #include @@ -22,7 +21,7 @@ struct TGetConfigResult : public TStatus { TString&& clusterName, ui64 version, TString&& config, - TMap&& volatileConfigs) + std::map&& volatileConfigs) : TStatus(std::move(status)) , ClusterName_(std::move(clusterName)) , Version_(version) @@ -42,7 +41,7 @@ struct TGetConfigResult : public TStatus { return Config_; } - const TMap& GetVolatileConfigs() const { + const std::map& GetVolatileConfigs() const { return VolatileConfigs_; } @@ -50,7 +49,7 @@ struct TGetConfigResult : public TStatus { TString ClusterName_; ui64 Version_; TString Config_; - TMap VolatileConfigs_; + std::map VolatileConfigs_; }; using TAsyncGetConfigResult = NThreading::TFuture; @@ -59,7 +58,7 @@ struct TGetMetadataResult : public TStatus { TGetMetadataResult( TStatus&& status, TString&& metadata, - TMap&& volatileConfigs) + std::map&& volatileConfigs) : TStatus(std::move(status)) , Metadata_(std::move(metadata)) , VolatileConfigs_(std::move(volatileConfigs)) @@ -69,13 +68,13 @@ struct TGetMetadataResult : public TStatus { return Metadata_; } - const TMap& GetVolatileConfigs() const { + const std::map& GetVolatileConfigs() const { return VolatileConfigs_; } private: TString Metadata_; - TMap VolatileConfigs_; + std::map VolatileConfigs_; }; using TAsyncGetMetadataResult = NThreading::TFuture; @@ -101,17 +100,17 @@ using TAsyncResolveConfigResult = NThreading::TFuture; struct TGetNodeLabelsResult : public TStatus { TGetNodeLabelsResult( TStatus&& status, - TMap&& labels) + std::map&& labels) : TStatus(std::move(status)) , Labels_(std::move(labels)) {} - const TMap& GetLabels() const { + const std::map& GetLabels() const { return Labels_; } private: - TMap Labels_; + std::map Labels_; }; using TAsyncGetNodeLabelsResult = NThreading::TFuture; @@ -140,7 +139,7 @@ struct TVerboseResolveConfigResult : public TStatus { } }; - using ConfigByLabelSet = TMap>, TString>; + using ConfigByLabelSet = std::map>, TString>; TVerboseResolveConfigResult( TStatus&& status, @@ -230,20 +229,20 @@ class TDynamicConfigClient { // Resolve arbitrary config for specific labels TAsyncResolveConfigResult ResolveConfig( const TString& config, - const TMap& volatileConfigs, - const TMap& labels, + const std::map& volatileConfigs, + const std::map& labels, const TClusterConfigSettings& settings = {}); // Resolve arbitrary config for all label combinations TAsyncResolveConfigResult ResolveConfig( const TString& config, - const TMap& volatileConfigs, + const std::map& volatileConfigs, const TClusterConfigSettings& settings = {}); // Resolve arbitrary config for all label combinations TAsyncVerboseResolveConfigResult VerboseResolveConfig( const TString& config, - const TMap& volatileConfigs, + const std::map& volatileConfigs, const TClusterConfigSettings& settings = {}); private: diff --git a/client/impl/ydb_endpoints/endpoints_ut.cpp b/client/impl/ydb_endpoints/endpoints_ut.cpp index 562df0059f5..3846493d35e 100644 --- a/client/impl/ydb_endpoints/endpoints_ut.cpp +++ b/client/impl/ydb_endpoints/endpoints_ut.cpp @@ -221,7 +221,7 @@ Y_UNIT_TEST_SUITE(EndpointElector) { UNIT_ASSERT_VALUES_EQUAL(obj4->ObjectCount(), 1); { - TMap sizes; + std::map sizes; size_t i = 0; elector.ForEachEndpoint([&sizes, &i](ui64 nodeId, const NYdb::IObjRegistryHandle& handle) { sizes[nodeId] = handle.Size(); @@ -236,7 +236,7 @@ Y_UNIT_TEST_SUITE(EndpointElector) { } { - TMap sizes; + std::map sizes; size_t i = 0; elector.ForEachEndpoint([&sizes, &i](ui64 nodeId, const NYdb::IObjRegistryHandle& handle) { sizes[nodeId] = handle.Size(); @@ -263,7 +263,7 @@ Y_UNIT_TEST_SUITE(EndpointElector) { UNIT_ASSERT_VALUES_EQUAL(obj4->HostRemoved(), false); { - TMap sizes; + std::map sizes; size_t i = 0; elector.ForEachEndpoint([&sizes, &i](ui64 nodeId, const NYdb::IObjRegistryHandle& handle) { sizes[nodeId] = handle.Size(); @@ -289,7 +289,7 @@ Y_UNIT_TEST_SUITE(EndpointElector) { UNIT_ASSERT_VALUES_EQUAL(obj5->HostRemoved(), true); { - TMap sizes; + std::map sizes; size_t i = 0; elector.ForEachEndpoint([&sizes, &i](ui64 nodeId, const NYdb::IObjRegistryHandle& handle) { sizes[nodeId] = handle.Size(); diff --git a/client/impl/ydb_internal/session_pool/session_pool.h b/client/impl/ydb_internal/session_pool/session_pool.h index 0451c94a9f5..bb1ac891b2f 100644 --- a/client/impl/ydb_internal/session_pool/session_pool.h +++ b/client/impl/ydb_internal/session_pool/session_pool.h @@ -3,7 +3,6 @@ #include #include -#include namespace NYdb { @@ -96,7 +95,7 @@ class TSessionPool { private: const ui32 MaxQueueSize_; const TDuration MaxWaitSessionTimeout_; - TMultiMap> Waiters_; + std::multimap> Waiters_; }; public: using TKeepAliveCmd = std::function; @@ -130,7 +129,7 @@ class TSessionPool { mutable std::mutex Mtx_; bool Closed_; - TMultiMap> Sessions_; + std::multimap> Sessions_; TWaitersQueue WaitersQueue_; i64 ActiveSessions_; diff --git a/client/ydb_params/impl.cpp b/client/ydb_params/impl.cpp index 9e8c5e1e7d7..77c0f5f84a3 100644 --- a/client/ydb_params/impl.cpp +++ b/client/ydb_params/impl.cpp @@ -3,8 +3,6 @@ #include #include -#include - namespace NYdb { @@ -16,8 +14,8 @@ bool TParams::TImpl::Empty() const { return ParamsMap_.empty(); } -TMap TParams::TImpl::GetValues() const { - TMap valuesMap; +std::map TParams::TImpl::GetValues() const { + std::map valuesMap; for (auto it = ParamsMap_.begin(); it != ParamsMap_.end(); ++it) { auto paramType = TType(it->second.type()); auto paramValue = TValue(paramType, it->second.value()); diff --git a/client/ydb_params/impl.h b/client/ydb_params/impl.h index 9e38d2463dd..ca01fd653bb 100644 --- a/client/ydb_params/impl.h +++ b/client/ydb_params/impl.h @@ -9,7 +9,7 @@ class TParams::TImpl { TImpl(::google::protobuf::Map&& paramsMap); bool Empty() const; - TMap GetValues() const; + std::map GetValues() const; TMaybe GetValue(const TString& name) const; ::google::protobuf::Map* GetProtoMapPtr(); const ::google::protobuf::Map& GetProtoMap() const; diff --git a/client/ydb_params/params.cpp b/client/ydb_params/params.cpp index d821d50895a..9c25651fd7c 100644 --- a/client/ydb_params/params.cpp +++ b/client/ydb_params/params.cpp @@ -5,7 +5,6 @@ #include -#include #include namespace NYdb { @@ -27,7 +26,7 @@ bool TParams::Empty() const { return Impl_->Empty(); } -TMap TParams::GetValues() const { +std::map TParams::GetValues() const { return Impl_->GetValues(); } @@ -49,7 +48,7 @@ class TParamsBuilder::TImpl { } } - TImpl(const TMap& typeInfo) + TImpl(const std::map& typeInfo) : HasTypeInfo_(true) { for (const auto& pair : typeInfo) { @@ -124,7 +123,7 @@ class TParamsBuilder::TImpl { private: bool HasTypeInfo_ = false; ::google::protobuf::Map ParamsMap_; - TMap ValueBuildersMap_; + std::map ValueBuildersMap_; }; //////////////////////////////////////////////////////////////////////////////// @@ -153,7 +152,7 @@ TParamsBuilder::~TParamsBuilder() = default; TParamsBuilder::TParamsBuilder() : Impl_(new TImpl()) {} -TParamsBuilder::TParamsBuilder(const TMap& typeInfo) +TParamsBuilder::TParamsBuilder(const std::map& typeInfo) : Impl_(new TImpl(typeInfo)) {} TParamsBuilder::TParamsBuilder(const ::google::protobuf::Map& typeInfo) diff --git a/client/ydb_params/params.h b/client/ydb_params/params.h index b922f06bcd1..fd1686a24be 100644 --- a/client/ydb_params/params.h +++ b/client/ydb_params/params.h @@ -44,7 +44,7 @@ class TParams { public: bool Empty() const; - TMap GetValues() const; + std::map GetValues() const; TMaybe GetValue(const TString& name) const; private: @@ -75,7 +75,7 @@ class TParamsBuilder : public TMoveOnly { public: TParamsBuilder(TParamsBuilder&&); TParamsBuilder(); - TParamsBuilder(const TMap& typeInfo); + TParamsBuilder(const std::map& typeInfo); ~TParamsBuilder(); diff --git a/client/ydb_params/params_ut.cpp b/client/ydb_params/params_ut.cpp index 04f5e12dfc0..690da06c08a 100644 --- a/client/ydb_params/params_ut.cpp +++ b/client/ydb_params/params_ut.cpp @@ -85,7 +85,7 @@ Y_UNIT_TEST_SUITE(ParamsBuilder) { .EndOptional() .Build(); - TMap paramsMap; + std::map paramsMap; paramsMap.emplace("$param1", param1Type); paramsMap.emplace("$param2", param2Type); @@ -129,7 +129,7 @@ Y_UNIT_TEST_SUITE(ParamsBuilder) { .EndOptional() .Build(); - TMap paramsMap; + std::map paramsMap; paramsMap.emplace("$param1", param1Type); paramsMap.emplace("$param2", param2Type); @@ -187,7 +187,7 @@ Y_UNIT_TEST_SUITE(ParamsBuilder) { .EndOptional() .Build(); - TMap paramsMap; + std::map paramsMap; paramsMap.emplace("$param1", param1Type); paramsMap.emplace("$param2", param2Type); @@ -217,7 +217,7 @@ Y_UNIT_TEST_SUITE(ParamsBuilder) { .EndOptional() .Build(); - TMap paramsMap; + std::map paramsMap; paramsMap.emplace("$param1", param1Type); paramsMap.emplace("$param2", param2Type); diff --git a/client/ydb_persqueue_core/impl/read_session.h b/client/ydb_persqueue_core/impl/read_session.h index c2b152881a6..e78a7e3d984 100644 --- a/client/ydb_persqueue_core/impl/read_session.h +++ b/client/ydb_persqueue_core/impl/read_session.h @@ -125,7 +125,7 @@ class TUserRetrievedEventsInfoAccumulator { size_t MessagesCount = 0; }; - TMap, TCounter> Counters; + std::map, TCounter> Counters; }; // Special class that stores actions to be done after lock will be released. diff --git a/client/ydb_persqueue_core/impl/read_session.ipp b/client/ydb_persqueue_core/impl/read_session.ipp index 46885d59426..b063325b21f 100644 --- a/client/ydb_persqueue_core/impl/read_session.ipp +++ b/client/ydb_persqueue_core/impl/read_session.ipp @@ -1123,7 +1123,7 @@ inline void TSingleClusterReadSessionImpl::OnReadDoneImpl( LOG_LAZY(Log, TLOG_DEBUG, GetLogPrefix() << "Committed response: " << msg); - TMap>> partitionStreams; + std::map>> partitionStreams; for (const Ydb::PersQueue::V1::CommitCookie& cookieProto : msg.cookies()) { typename TPartitionCookieMapping::TCookie::TPtr cookie = CookieMapping.RetrieveCommittedCookie(cookieProto); if (cookie) { diff --git a/client/ydb_result/result.cpp b/client/ydb_result/result.cpp index 75f2dc5aae9..d1e33df3533 100644 --- a/client/ydb_result/result.cpp +++ b/client/ydb_result/result.cpp @@ -132,7 +132,7 @@ class TResultSetParser::TImpl { } ssize_t ColumnIndex(const TString& columnName) { - auto idx = ColumnIndexMap.FindPtr(columnName); + auto idx = MapFindPtr(ColumnIndexMap, columnName); return idx ? static_cast(*idx) : -1; } @@ -145,7 +145,7 @@ class TResultSetParser::TImpl { } TValueParser& ColumnParser(const TString& columnName) { - auto idx = ColumnIndexMap.FindPtr(columnName); + auto idx = MapFindPtr(ColumnIndexMap, columnName); if (!idx) { FatalError(TStringBuilder() << "Unknown column: " << columnName); } @@ -169,7 +169,7 @@ class TResultSetParser::TImpl { } TValue GetValue(const TString& columnName) const { - auto idx = ColumnIndexMap.FindPtr(columnName); + auto idx = MapFindPtr(ColumnIndexMap, columnName); if (!idx) { FatalError(TStringBuilder() << "Unknown column: " << columnName); } @@ -184,8 +184,10 @@ class TResultSetParser::TImpl { private: TResultSet ResultSet_; - TMap ColumnIndexMap; + + std::map ColumnIndexMap; std::vector ColumnParsers; + size_t RowIndex_ = 0; }; diff --git a/client/ydb_topic/impl/topic.cpp b/client/ydb_topic/impl/topic.cpp index 5034ebb405d..66520e8a217 100644 --- a/client/ydb_topic/impl/topic.cpp +++ b/client/ydb_topic/impl/topic.cpp @@ -120,7 +120,7 @@ const std::vector& TConsumer::GetSupportedCodecs() const { return SupportedCodecs_; } -const TMap& TConsumer::GetAttributes() const { +const std::map& TConsumer::GetAttributes() const { return Attributes_; } @@ -172,7 +172,7 @@ EMeteringMode TTopicDescription::GetMeteringMode() const { return MeteringMode_; } -const TMap& TTopicDescription::GetAttributes() const { +const std::map& TTopicDescription::GetAttributes() const { return Attributes_; } diff --git a/client/ydb_topic/topic.h b/client/ydb_topic/topic.h index 0ae137374ad..f63c5502fea 100644 --- a/client/ydb_topic/topic.h +++ b/client/ydb_topic/topic.h @@ -58,13 +58,15 @@ class TConsumer { bool GetImportant() const; const TInstant& GetReadFrom() const; const std::vector& GetSupportedCodecs() const; - const TMap& GetAttributes() const; + const std::map& GetAttributes() const; + private: TString ConsumerName_; bool Important_; TInstant ReadFrom_; - TMap Attributes_; + std::map Attributes_; std::vector SupportedCodecs_; + }; @@ -214,7 +216,7 @@ class TTopicDescription { ui64 GetPartitionWriteBurstBytes() const; - const TMap& GetAttributes() const; + const std::map& GetAttributes() const; const std::vector& GetConsumers() const; @@ -236,8 +238,9 @@ class TTopicDescription { ui64 PartitionWriteSpeedBytesPerSecond_; ui64 PartitionWriteBurstBytes_; EMeteringMode MeteringMode_; - TMap Attributes_; + std::map Attributes_; std::vector Consumers_; + TTopicStats TopicStats_; TString Owner_; @@ -360,7 +363,7 @@ template struct TConsumerSettings { using TSelf = TConsumerSettings; - using TAttributes = TMap; + using TAttributes = std::map; TConsumerSettings(TSettings& parent): Parent_(parent) {} TConsumerSettings(TSettings& parent, const TString& name) : ConsumerName_(name), Parent_(parent) {} @@ -378,12 +381,12 @@ struct TConsumerSettings { return *this; } - TConsumerSettings& SetAttributes(TMap&& attributes) { + TConsumerSettings& SetAttributes(std::map&& attributes) { Attributes_ = std::move(attributes); return *this; } - TConsumerSettings& SetAttributes(const TMap& attributes) { + TConsumerSettings& SetAttributes(const std::map& attributes) { Attributes_ = attributes; return *this; } @@ -408,7 +411,7 @@ struct TConsumerSettings { struct TAlterConsumerSettings { using TSelf = TAlterConsumerSettings; - using TAlterAttributes = TMap; + using TAlterAttributes = std::map; TAlterConsumerSettings(TAlterTopicSettings& parent): Parent_(parent) {} TAlterConsumerSettings(TAlterTopicSettings& parent, const TString& name) : ConsumerName_(name), Parent_(parent) {} @@ -445,7 +448,7 @@ struct TAlterConsumerSettings { struct TCreateTopicSettings : public TOperationRequestSettings { using TSelf = TCreateTopicSettings; - using TAttributes = TMap; + using TAttributes = std::map; FLUENT_SETTING(TPartitioningSettings, PartitioningSettings); @@ -489,12 +492,12 @@ struct TCreateTopicSettings : public TOperationRequestSettings&& attributes) { + TCreateTopicSettings& SetAttributes(std::map&& attributes) { Attributes_ = std::move(attributes); return *this; } - TCreateTopicSettings& SetAttributes(const TMap& attributes) { + TCreateTopicSettings& SetAttributes(const std::map& attributes) { Attributes_ = attributes; return *this; } @@ -509,7 +512,7 @@ struct TCreateTopicSettings : public TOperationRequestSettings { using TSelf = TAlterTopicSettings; - using TAlterAttributes = TMap; + using TAlterAttributes = std::map; FLUENT_SETTING_OPTIONAL(TPartitioningSettings, AlterPartitioningSettings); diff --git a/client/ydb_value/value.cpp b/client/ydb_value/value.cpp index 8ab621d7b3f..2d92b0ce474 100644 --- a/client/ydb_value/value.cpp +++ b/client/ydb_value/value.cpp @@ -14,8 +14,8 @@ #include #include +#include #include -#include #include namespace NYdb { @@ -1955,7 +1955,7 @@ void TValueParser::CloseTagged() { class TValueBuilderImpl { using ETypeKind = TTypeParser::ETypeKind; - using TMembersMap = TMap; + using TMembersMap = std::map; struct TProtoPosition { Ydb::Value& Value; @@ -2308,7 +2308,7 @@ class TValueBuilderImpl { return; } - auto memberIndex = membersMap->FindPtr(memberName); + auto memberIndex = MapFindPtr(*membersMap, memberName); if (!memberIndex) { FatalError(TStringBuilder() << "Struct member not found: " << memberName); return; @@ -2702,7 +2702,7 @@ class TValueBuilderImpl { //TTypeBuilder TypeBuilder_; TTypeBuilder::TImpl TypeBuilder_; Ydb::Value ProtoValue_; - TMap StructsMap_; + std::map StructsMap_; TStackVec Path_; TStackVec StructsPath_; diff --git a/library/cpp/cgiparam/cgiparam.cpp b/library/cpp/cgiparam/cgiparam.cpp index ddc24c1f95b..b1e2f0843df 100644 --- a/library/cpp/cgiparam/cgiparam.cpp +++ b/library/cpp/cgiparam/cgiparam.cpp @@ -5,6 +5,8 @@ #include +#include + TCgiParameters::TCgiParameters(std::initializer_list> il) { for (const auto& item : il) { insert(item); @@ -18,7 +20,7 @@ const TString& TCgiParameters::Get(const TStringBuf name, size_t numOfValue) con } bool TCgiParameters::Erase(const TStringBuf name, size_t pos) { - const auto pair = equal_range(name); + const auto pair = equal_range(static_cast(name)); for (auto it = pair.first; it != pair.second; ++it, --pos) { if (0 == pos) { @@ -31,7 +33,7 @@ bool TCgiParameters::Erase(const TStringBuf name, size_t pos) { } bool TCgiParameters::Erase(const TStringBuf name, const TStringBuf val) { - const auto pair = equal_range(name); + const auto pair = equal_range(static_cast(name)); bool found = false; for (auto it = pair.first; it != pair.second;) { @@ -47,7 +49,7 @@ bool TCgiParameters::Erase(const TStringBuf name, const TStringBuf val) { } bool TCgiParameters::ErasePattern(const TStringBuf name, const TStringBuf pat) { - const auto pair = equal_range(name); + const auto pair = equal_range(static_cast(name)); bool found = false; for (auto it = pair.first; it != pair.second;) { @@ -66,7 +68,7 @@ bool TCgiParameters::ErasePattern(const TStringBuf name, const TStringBuf pat) { size_t TCgiParameters::EraseAll(const TStringBuf name) { size_t num = 0; - const auto pair = equal_range(name); + const auto pair = equal_range(static_cast(name)); for (auto it = pair.first; it != pair.second; erase(it++), ++num) ; @@ -75,7 +77,7 @@ size_t TCgiParameters::EraseAll(const TStringBuf name) { } void TCgiParameters::JoinUnescaped(const TStringBuf key, char sep, TStringBuf val) { - const auto pair = equal_range(key); + const auto pair = equal_range(static_cast(key)); auto it = pair.first; if (it == pair.second) { // not found @@ -222,7 +224,7 @@ TString TCgiParameters::QuotedPrint(const char* safe) const { } TCgiParameters::const_iterator TCgiParameters::Find(const TStringBuf name, size_t pos) const noexcept { - const auto pair = equal_range(name); + const auto pair = equal_range(static_cast(name)); for (auto it = pair.first; it != pair.second; ++it, --pos) { if (0 == pos) { @@ -234,7 +236,7 @@ TCgiParameters::const_iterator TCgiParameters::Find(const TStringBuf name, size_ } bool TCgiParameters::Has(const TStringBuf name, const TStringBuf value) const noexcept { - const auto pair = equal_range(name); + const auto pair = equal_range(static_cast(name)); for (auto it = pair.first; it != pair.second; ++it) { if (value == it->second) { @@ -266,7 +268,7 @@ TQuickCgiParam::TQuickCgiParam(const TStringBuf cgiParamStr) { } const TStringBuf& TQuickCgiParam::Get(const TStringBuf name, size_t pos) const noexcept { - const auto pair = equal_range(name); + const auto pair = equal_range(static_cast(name)); for (auto it = pair.first; it != pair.second; ++it, --pos) { if (0 == pos) { @@ -278,7 +280,7 @@ const TStringBuf& TQuickCgiParam::Get(const TStringBuf name, size_t pos) const n } bool TQuickCgiParam::Has(const TStringBuf name, const TStringBuf value) const noexcept { - const auto pair = equal_range(name); + const auto pair = equal_range(static_cast(name)); for (auto it = pair.first; it != pair.second; ++it) { if (value == it->second) { diff --git a/library/cpp/cgiparam/cgiparam.h b/library/cpp/cgiparam/cgiparam.h index cbb212f6f06..010cafc01b3 100644 --- a/library/cpp/cgiparam/cgiparam.h +++ b/library/cpp/cgiparam/cgiparam.h @@ -3,13 +3,13 @@ #include #include -#include #include #include +#include #include -class TCgiParameters: public TMultiMap { +class TCgiParameters: public std::multimap { public: TCgiParameters() = default; @@ -26,7 +26,7 @@ class TCgiParameters: public TMultiMap { size_t EraseAll(const TStringBuf name); size_t NumOfValues(const TStringBuf name) const noexcept { - return count(name); + return count(static_cast(name)); } TString operator()() const { @@ -57,7 +57,7 @@ class TCgiParameters: public TMultiMap { Y_PURE_FUNCTION auto Range(const TStringBuf name) const noexcept { - return IterateValues(MakeIteratorRange(equal_range(name))); + return IterateValues(MakeIteratorRange(equal_range(static_cast(name)))); } Y_PURE_FUNCTION @@ -68,7 +68,7 @@ class TCgiParameters: public TMultiMap { Y_PURE_FUNCTION bool Has(const TStringBuf name) const noexcept { - const auto pair = equal_range(name); + const auto pair = equal_range(static_cast(name)); return pair.first != pair.second; } /// Returns value by name @@ -139,7 +139,7 @@ class TCgiParameters: public TMultiMap { template void TCgiParameters::ReplaceUnescaped(const TStringBuf key, TIter valuesBegin, const TIter valuesEnd) { - const auto oldRange = equal_range(key); + const auto oldRange = equal_range(static_cast(key)); auto current = oldRange.first; // reuse as many existing nodes as possible (probably none) @@ -165,7 +165,7 @@ void TCgiParameters::ReplaceUnescaped(const TStringBuf key, TIter valuesBegin, c * - note that the result of Get() is invalidated when TQuickCgiParam object is destroyed. */ -class TQuickCgiParam: public TMultiMap { +class TQuickCgiParam: public std::multimap { public: TQuickCgiParam() = default; @@ -176,7 +176,7 @@ class TQuickCgiParam: public TMultiMap { Y_PURE_FUNCTION bool Has(const TStringBuf name) const noexcept { - const auto pair = equal_range(name); + const auto pair = equal_range(static_cast(name)); return pair.first != pair.second; } diff --git a/library/cpp/containers/disjoint_interval_tree/disjoint_interval_tree.h b/library/cpp/containers/disjoint_interval_tree/disjoint_interval_tree.h index 3f51c61277c..1b1a20de50d 100644 --- a/library/cpp/containers/disjoint_interval_tree/disjoint_interval_tree.h +++ b/library/cpp/containers/disjoint_interval_tree/disjoint_interval_tree.h @@ -1,16 +1,16 @@ #pragma once -#include #include #include +#include template class TDisjointIntervalTree { private: static_assert(std::is_integral::value, "expect std::is_integral::value"); - using TTree = TMap; // [key, value) + using TTree = std::map; // [key, value) using TIterator = typename TTree::iterator; using TConstIterator = typename TTree::const_iterator; using TReverseIterator = typename TTree::reverse_iterator; diff --git a/library/cpp/dbg_output/dumpers.h b/library/cpp/dbg_output/dumpers.h index 66d4e3a940a..7882328e2e5 100644 --- a/library/cpp/dbg_output/dumpers.h +++ b/library/cpp/dbg_output/dumpers.h @@ -6,6 +6,8 @@ #include #include +#include + //smart pointers template struct TDumper> { @@ -112,11 +114,11 @@ struct TDumper>: public TSeqDumper { //associatives template -struct TDumper>: public TAssocDumper { +struct TDumper>: public TAssocDumper { }; template -struct TDumper>: public TAssocDumper { +struct TDumper>: public TAssocDumper { }; template diff --git a/library/cpp/getopt/small/last_getopt_opts.cpp b/library/cpp/getopt/small/last_getopt_opts.cpp index f49ec9ca9f7..f89f9901e16 100644 --- a/library/cpp/getopt/small/last_getopt_opts.cpp +++ b/library/cpp/getopt/small/last_getopt_opts.cpp @@ -339,7 +339,9 @@ namespace NLastGetopt { ui32 numArgsToShow = Max(FreeArgsMin_, FreeArgsMax_ == UNLIMITED_ARGS ? numDescribedFlags : FreeArgsMax_); for (ui32 i = 0, nonOptionalFlagsPrinted = 0; i < numArgsToShow; ++i) { - bool isOptional = nonOptionalFlagsPrinted >= FreeArgsMin_ || FreeArgSpecs_.Value(i, TFreeArgSpec()).Optional_; + auto found = MapFindPtr(FreeArgSpecs_, i); + TFreeArgSpec value = found ? *found : TFreeArgSpec(); + bool isOptional = nonOptionalFlagsPrinted >= FreeArgsMin_ || value.Optional_; nonOptionalFlagsPrinted += !isOptional; diff --git a/library/cpp/getopt/small/last_getopt_opts.h b/library/cpp/getopt/small/last_getopt_opts.h index b32c48a3deb..e4128b85400 100644 --- a/library/cpp/getopt/small/last_getopt_opts.h +++ b/library/cpp/getopt/small/last_getopt_opts.h @@ -2,9 +2,9 @@ #include "last_getopt_opt.h" +#include #include -#include namespace NLastGetopt { enum EArgPermutation { @@ -60,7 +60,7 @@ namespace NLastGetopt { ui32 FreeArgsMin_; // minimal number of free args ui32 FreeArgsMax_; // maximal number of free args - TMap FreeArgSpecs_; // mapping [free arg position] -> [free arg specification] + std::map FreeArgSpecs_; // mapping [free arg position] -> [free arg specification] TFreeArgSpec TrailingArgSpec_; // spec for the trailing argument (when arguments are unlimited) TString DefaultFreeArgTitle_ = "ARG"; // title that's used for free args without a title @@ -486,7 +486,7 @@ namespace NLastGetopt { /** * Get mapping for free args */ - const TMap& GetFreeArgSpecs() const { + const std::map& GetFreeArgSpecs() const { return FreeArgSpecs_; } diff --git a/library/cpp/getopt/small/modchooser.cpp b/library/cpp/getopt/small/modchooser.cpp index 0d861c08b20..a8ea4a8e07a 100644 --- a/library/cpp/getopt/small/modchooser.cpp +++ b/library/cpp/getopt/small/modchooser.cpp @@ -97,7 +97,7 @@ void TModChooser::AddMode(const TString& mode, const TMainFunctionPtrV func, con } void TModChooser::AddMode(const TString& mode, TMainClass* func, const TString& description, bool hidden, bool noCompletion) { - if (Modes.FindPtr(mode)) { + if (MapFindPtr(Modes, mode)) { ythrow yexception() << "TMode '" << mode << "' already exists in TModChooser."; } @@ -118,7 +118,7 @@ void TModChooser::SetDefaultMode(const TString& mode) { } void TModChooser::AddAlias(const TString& alias, const TString& mode) { - if (!Modes.FindPtr(mode)) { + if (!MapFindPtr(Modes, mode)) { ythrow yexception() << "TMode '" << mode << "' not found in TModChooser."; } diff --git a/library/cpp/getopt/small/modchooser.h b/library/cpp/getopt/small/modchooser.h index a88f5b92efa..8da0c08403a 100644 --- a/library/cpp/getopt/small/modchooser.h +++ b/library/cpp/getopt/small/modchooser.h @@ -151,7 +151,7 @@ class TModChooser { std::vector> Wrappers; //! Modes - TMap Modes; + std::map Modes; TString DefaultMode; diff --git a/library/cpp/iterator/ut/mapped_ut.cpp b/library/cpp/iterator/ut/mapped_ut.cpp index 1e2c0b5eb45..7cb86787cd2 100644 --- a/library/cpp/iterator/ut/mapped_ut.cpp +++ b/library/cpp/iterator/ut/mapped_ut.cpp @@ -2,8 +2,6 @@ #include -#include - using namespace testing; @@ -29,12 +27,12 @@ TEST(TIterator, TMappedRangeTest) { //TODO: replace with dedicated IterateKeys / IterateValues methods TEST(TIterator, TMutableMappedRangeTest) { - TMap points = {{1, 2}, {3, 4}}; + std::map points = {{1, 2}, {3, 4}}; EXPECT_THAT( MakeMappedRange( points.begin(), points.end(), - [](TMap::value_type& kv) -> int& { return kv.second; } + [](std::map::value_type& kv) -> int& { return kv.second; } ), ElementsAre(2, 4) ); diff --git a/library/cpp/monlib/counters/counters.h b/library/cpp/monlib/counters/counters.h index 3529778d983..d14bca8af11 100644 --- a/library/cpp/monlib/counters/counters.h +++ b/library/cpp/monlib/counters/counters.h @@ -3,7 +3,8 @@ #include #include #include -#include + +#include #include #include @@ -16,6 +17,7 @@ #include #include +#include #include namespace NMonitoring { @@ -147,8 +149,9 @@ namespace NMonitoring { template > class TDeprecatedCounterGroups { public: - typedef TMap TGroups; + typedef std::map TGroups; typedef std::vector TGroupsNames; + typedef THolder TGroupsNamesPtr; private: diff --git a/library/cpp/monlib/dynamic_counters/counters.h b/library/cpp/monlib/dynamic_counters/counters.h index 338bf53fa3a..3b50854246d 100644 --- a/library/cpp/monlib/dynamic_counters/counters.h +++ b/library/cpp/monlib/dynamic_counters/counters.h @@ -7,11 +7,11 @@ #include #include -#include #include #include #include +#include #include namespace NMonitoring { @@ -224,7 +224,7 @@ namespace NMonitoring { } }; - using TCounters = TMap; + using TCounters = std::map; using TLabels = std::vector; /// XXX: hack for deferred removal of expired counters. Remove once Output* functions are not used for serialization diff --git a/library/cpp/object_factory/object_factory.h b/library/cpp/object_factory/object_factory.h index c2680b2301d..967ddded3a6 100644 --- a/library/cpp/object_factory/object_factory.h +++ b/library/cpp/object_factory/object_factory.h @@ -2,11 +2,12 @@ #include #include -#include #include #include #include +#include + namespace NObjectFactory { template class IFactoryObjectCreator { @@ -92,7 +93,7 @@ namespace NObjectFactory { private: typedef TSimpleSharedPtr> ICreatorPtr; - typedef TMap ICreators; + typedef std::map ICreators; ICreators Creators; TRWMutex CreatorsLock; }; diff --git a/library/cpp/testing/unittest/gtest.cpp b/library/cpp/testing/unittest/gtest.cpp index c2e38679506..00a8671f509 100644 --- a/library/cpp/testing/unittest/gtest.cpp +++ b/library/cpp/testing/unittest/gtest.cpp @@ -1,8 +1,6 @@ #include "gtest.h" #include "simple.h" -#include - #include using namespace NUnitTest; @@ -55,7 +53,7 @@ namespace { } IGTestFactory* NUnitTest::NPrivate::ByName(const char* name) { - static TMap> tests; + static std::map> tests; auto& ret = tests[name]; diff --git a/library/cpp/testing/unittest/junit.h b/library/cpp/testing/unittest/junit.h index 567558f08e1..8db01956c84 100644 --- a/library/cpp/testing/unittest/junit.h +++ b/library/cpp/testing/unittest/junit.h @@ -31,7 +31,7 @@ class TJUnitProcessor : public ITestSuiteProcessor { }; struct TTestSuite { - TMap Cases; + std::map Cases; size_t GetTestsCount() const { return Cases.size(); @@ -136,7 +136,7 @@ class TJUnitProcessor : public ITestSuiteProcessor { const EOutputFormat OutputFormat; TString ResultReportFileName; TMaybe TmpReportFile; - TMap Suites; + std::map Suites; THolder StdErrCapturer; THolder StdOutCapturer; TInstant StartCurrentTestTime; diff --git a/library/cpp/testing/unittest/registar.cpp b/library/cpp/testing/unittest/registar.cpp index 825f779a6c7..7b868b901f6 100644 --- a/library/cpp/testing/unittest/registar.cpp +++ b/library/cpp/testing/unittest/registar.cpp @@ -159,7 +159,7 @@ static TString MakeTestName(const NUnitTest::ITestSuiteProcessor::TTest& test) { return TStringBuilder() << test.unit->name << "::" << test.name; } -static size_t CountTests(const TMap& testErrors, bool succeeded) { +static size_t CountTests(const std::map& testErrors, bool succeeded) { size_t cnt = 0; for (const auto& t : testErrors) { if (succeeded && t.second == 0) { diff --git a/library/cpp/testing/unittest/registar.h b/library/cpp/testing/unittest/registar.h index 560c1c88a59..ffce89f9c81 100644 --- a/library/cpp/testing/unittest/registar.h +++ b/library/cpp/testing/unittest/registar.h @@ -5,7 +5,6 @@ #include #include #include -#include #include #include #include @@ -165,8 +164,8 @@ namespace NUnitTest { void AddTestFinish(const TTest& test); private: - TMap TestErrors_; - TMap CurTestErrors_; + std::map TestErrors_; + std::map CurTestErrors_; bool IsForked_ = false; bool ForkTests_ = false; }; diff --git a/library/cpp/uri/common.cpp b/library/cpp/uri/common.cpp index 7225e22dfd3..f233b54e269 100644 --- a/library/cpp/uri/common.cpp +++ b/library/cpp/uri/common.cpp @@ -1,8 +1,9 @@ #include "common.h" -#include #include +#include + namespace NUri { static_assert(TFeature::FeatureMAX <= sizeof(ui64) * 8, "expect TFeature::FeatureMAX <= sizeof(ui64) * 8"); @@ -26,7 +27,7 @@ namespace NUri { }; class TSchemeInfoMap { - typedef TMap TdMap; + typedef std::map TdMap; TdMap Map_; public: diff --git a/tools/archiver/main.cpp b/tools/archiver/main.cpp index 558f5b2d5c6..778b5f8d18a 100644 --- a/tools/archiver/main.cpp +++ b/tools/archiver/main.cpp @@ -241,14 +241,15 @@ namespace { void Finish() { Y_ENSURE(!InitialFillingDone); InitialFillingDone = true; - TMap> bySize; + std::map> bySize; for (const TString& fname: FileNames) { TFile file(fname, OpenExisting | RdOnly); bySize[file.GetLength()].push_back(fname); } for (const auto& bySizeElement: bySize) { if (bySizeElement.second.size() > 1) { - TMap, TMyFileComparator> byContents; + std::map, TMyFileComparator> byContents; + for (const TString& fname: bySizeElement.second) { byContents[fname].push_back(fname); } diff --git a/tools/enum_parser/enum_parser/main.cpp b/tools/enum_parser/enum_parser/main.cpp index 15ea1c1c33a..504c9bfe6fa 100644 --- a/tools/enum_parser/enum_parser/main.cpp +++ b/tools/enum_parser/enum_parser/main.cpp @@ -16,7 +16,6 @@ #include #include #include -#include #include #include @@ -224,7 +223,7 @@ void GenerateEnum( const TString nsNameBufsClass = nsName + "::TNameBufs"; - auto defineConstArray = [&out, payloadCache = TMap>, TString>()](const TStringBuf indent, const TStringBuf elementType, const TStringBuf name, const std::vector& items) mutable { + auto defineConstArray = [&out, payloadCache = std::map>, TString>()](const TStringBuf indent, const TStringBuf elementType, const TStringBuf name, const std::vector& items) mutable { if (items.empty()) { // ISO C++ forbids zero-size array out << indent << "static constexpr const TArrayRef " << name << ";\n"; } else { diff --git a/tools/enum_parser/enum_serialization_runtime/enum_runtime.cpp b/tools/enum_parser/enum_serialization_runtime/enum_runtime.cpp index 465f46b3e0b..a6ffc85b812 100644 --- a/tools/enum_parser/enum_serialization_runtime/enum_runtime.cpp +++ b/tools/enum_parser/enum_serialization_runtime/enum_runtime.cpp @@ -1,7 +1,6 @@ #include "enum_runtime.h" #include -#include #include #include @@ -172,8 +171,8 @@ namespace NEnumSerializationRuntime { const TArrayRef& valuesInitializer = enumInitData.ValuesInitializer; const TArrayRef& cppNamesInitializer = enumInitData.CppNamesInitializer; - TMap mapValueToName; - TMap mapNameToValue; + std::map mapValueToName; + std::map mapNameToValue; for (const TEnumStringPair& it : namesInitializer) { mapValueToName.emplace(it.Key, TString(it.Name)); } diff --git a/tools/enum_parser/enum_serialization_runtime/enum_runtime.h b/tools/enum_parser/enum_serialization_runtime/enum_runtime.h index b88e3cd1f63..1d996dfe821 100644 --- a/tools/enum_parser/enum_serialization_runtime/enum_runtime.h +++ b/tools/enum_parser/enum_serialization_runtime/enum_runtime.h @@ -61,7 +61,7 @@ namespace NEnumSerializationRuntime { return AllCppNames; } - const TMap& TypelessEnumNames() const noexcept { + const std::map& TypelessEnumNames() const noexcept { return Names; } @@ -70,8 +70,8 @@ namespace NEnumSerializationRuntime { } private: - TMap Names; - TMap Values; + std::map Names; + std::map Values; TString AllNames; std::vector AllCppNames; TString ClassName; diff --git a/util/digest/sequence_ut.cpp b/util/digest/sequence_ut.cpp index d2fe3b3f884..5ea57c69990 100644 --- a/util/digest/sequence_ut.cpp +++ b/util/digest/sequence_ut.cpp @@ -1,7 +1,6 @@ #include "sequence.h" #include -#include #include class TRangeHashTest: public TTestBase { @@ -33,7 +32,7 @@ class TRangeHashTest: public TTestBase { inline void TestMap() { const size_t canonicalHash = static_cast(ULL(4415387926488545605)); - TMap testMap{{"foo", 123}, {"bar", 456}}; + std::map testMap{{"foo", 123}, {"bar", 456}}; UNIT_ASSERT_EQUAL(canonicalHash, TRangeHash<>()(testMap)); } diff --git a/util/generic/algorithm_ut.cpp b/util/generic/algorithm_ut.cpp index b88195db7eb..1ecfa1b39c3 100644 --- a/util/generic/algorithm_ut.cpp +++ b/util/generic/algorithm_ut.cpp @@ -283,13 +283,13 @@ Y_UNIT_TEST_SUITE(TAlgorithm) { } Y_UNIT_TEST(EraseNodesIfTest) { - TMap map{{1, 1}, {2, 2}, {3, 5}}; - TMap expectedMap{{1, 1}}; + std::map map{{1, 1}, {2, 2}, {3, 5}}; + std::map expectedMap{{1, 1}}; EraseNodesIf(map, [](auto p) { return p.first >= 2; }); UNIT_ASSERT_EQUAL(map, expectedMap); - TMultiMap multiMap{{1, 1}, {1, 3}, {2, 2}, {3, 5}}; - TMultiMap expectedMultiMap{{1, 1}, {1, 3}}; + std::multimap multiMap{{1, 1}, {1, 3}, {2, 2}, {3, 5}}; + std::multimap expectedMultiMap{{1, 1}, {1, 3}}; EraseNodesIf(multiMap, [](auto p) { return p.first >= 2; }); UNIT_ASSERT_EQUAL(multiMap, expectedMultiMap); diff --git a/util/generic/fwd.h b/util/generic/fwd.h index 4d4e67fb0af..18f4e5b6572 100644 --- a/util/generic/fwd.h +++ b/util/generic/fwd.h @@ -79,12 +79,6 @@ class THashMultiSet; template > class TList; -template , class A = std::allocator> -class TMap; - -template , class A = std::allocator> -class TMultiMap; - template , class A = std::allocator> class TSet; diff --git a/util/generic/is_in_ut.cpp b/util/generic/is_in_ut.cpp index 7a6ff2c8020..ccfce0f7415 100644 --- a/util/generic/is_in_ut.cpp +++ b/util/generic/is_in_ut.cpp @@ -5,7 +5,6 @@ #include "hash_multi_map.h" #include "hash_set.h" #include "is_in.h" -#include "map.h" #include "set.h" #include "strbuf.h" #include "string.h" @@ -42,8 +41,6 @@ Y_UNIT_TEST_SUITE(TIsIn) { } Y_UNIT_TEST(IsInTest) { - TestIsInWithCont>(std::make_pair("found", "1")); - TestIsInWithCont>(std::make_pair("found", "1")); TestIsInWithCont>(std::make_pair("found", "1")); TestIsInWithCont>(std::make_pair("found", "1")); diff --git a/util/generic/map_ut.cpp b/util/generic/map_ut.cpp deleted file mode 100644 index 7182a6db306..00000000000 --- a/util/generic/map_ut.cpp +++ /dev/null @@ -1,496 +0,0 @@ -#include "map.h" - -#include -#include -#include - -Y_UNIT_TEST_SUITE(TYMapTest) { - template - void DoTestMap1(TMap, TAlloc>& m); - - template - void DoTestMMap1(TMultiMap, TAlloc>& mm); - - Y_UNIT_TEST(TestMap1) { - { - TMap> m; - DoTestMap1(m); - } - { - TMemoryPool p(100); - TMap, TPoolAllocator> m(&p); - DoTestMap1(m); - } - } - - Y_UNIT_TEST(TestMMap1) { - { - TMultiMap> mm; - DoTestMMap1(mm); - } - { - TMemoryPool p(100); - TMultiMap, TPoolAllocator> mm(&p); - DoTestMMap1(mm); - } - } - - template - void DoTestMap1(TMap, TAlloc>& m) { - using maptype = TMap, TAlloc>; - // Store mappings between roman numerals and decimals. - m['l'] = 50; - m['x'] = 20; // Deliberate mistake. - m['v'] = 5; - m['i'] = 1; - - UNIT_ASSERT(m['x'] == 20); - m['x'] = 10; // Correct mistake. - UNIT_ASSERT(m['x'] == 10); - UNIT_ASSERT(m['z'] == 0); - - UNIT_ASSERT(m.count('z') == 1); - - std::pair p = m.insert(std::pair('c', 100)); - - UNIT_ASSERT(p.second); - UNIT_ASSERT(p.first != m.end()); - UNIT_ASSERT((*p.first).first == 'c'); - UNIT_ASSERT((*p.first).second == 100); - - p = m.insert(std::pair('c', 100)); - - UNIT_ASSERT(!p.second); // already existing pair - UNIT_ASSERT(p.first != m.end()); - UNIT_ASSERT((*p.first).first == 'c'); - UNIT_ASSERT((*p.first).second == 100); - } - - template - void DoTestMMap1(TMultiMap, TAlloc>& m) { - using mmap = TMultiMap, TAlloc>; - - UNIT_ASSERT(m.count('X') == 0); - - m.insert(std::pair('X', 10)); // Standard way. - UNIT_ASSERT(m.count('X') == 1); - - m.insert(std::pair('X', 20)); // jbuck: standard way - UNIT_ASSERT(m.count('X') == 2); - - m.insert(std::pair('Y', 32)); // jbuck: standard way - typename mmap::iterator i = m.find('X'); // Find first match. - ++i; - UNIT_ASSERT((*i).first == 'X'); - UNIT_ASSERT((*i).second == 20); - ++i; - UNIT_ASSERT((*i).first == 'Y'); - UNIT_ASSERT((*i).second == 32); - ++i; - UNIT_ASSERT(i == m.end()); - - size_t count = m.erase('X'); - UNIT_ASSERT(count == 2); - } - - Y_UNIT_TEST(TestMMap2) { - using pair_type = std::pair; - - pair_type p1(3, 'c'); - pair_type p2(6, 'f'); - pair_type p3(1, 'a'); - pair_type p4(2, 'b'); - pair_type p5(3, 'x'); - pair_type p6(6, 'f'); - - using mmap = TMultiMap>; - - pair_type array[] = { - p1, - p2, - p3, - p4, - p5, - p6}; - - mmap m(array + 0, array + 6); - mmap::iterator i; - i = m.lower_bound(3); - UNIT_ASSERT((*i).first == 3); - UNIT_ASSERT((*i).second == 'c'); - - i = m.upper_bound(3); - UNIT_ASSERT((*i).first == 6); - UNIT_ASSERT((*i).second == 'f'); - } - - Y_UNIT_TEST(TestIterators) { - using int_map = TMap>; - int_map imap; - - { - int_map::iterator ite(imap.begin()); - int_map::const_iterator cite(imap.begin()); - - UNIT_ASSERT(ite == cite); - UNIT_ASSERT(!(ite != cite)); - UNIT_ASSERT(cite == ite); - UNIT_ASSERT(!(cite != ite)); - } - - using mmap = TMultiMap>; - using pair_type = mmap::value_type; - - pair_type p1(3, 'c'); - pair_type p2(6, 'f'); - pair_type p3(1, 'a'); - pair_type p4(2, 'b'); - pair_type p5(3, 'x'); - pair_type p6(6, 'f'); - - pair_type array[] = { - p1, - p2, - p3, - p4, - p5, - p6}; - - mmap m(array + 0, array + 6); - - { - mmap::iterator ite(m.begin()); - mmap::const_iterator cite(m.begin()); - //test compare between const_iterator and iterator - UNIT_ASSERT(ite == cite); - UNIT_ASSERT(!(ite != cite)); - UNIT_ASSERT(cite == ite); - UNIT_ASSERT(!(cite != ite)); - } - - mmap::reverse_iterator ri = m.rbegin(); - - UNIT_ASSERT(ri != m.rend()); - UNIT_ASSERT(ri == m.rbegin()); - UNIT_ASSERT((*ri).first == 6); - UNIT_ASSERT((*ri++).second == 'f'); - UNIT_ASSERT((*ri).first == 6); - UNIT_ASSERT((*ri).second == 'f'); - - mmap const& cm = m; - mmap::const_reverse_iterator rci = cm.rbegin(); - - UNIT_ASSERT(rci != cm.rend()); - UNIT_ASSERT((*rci).first == 6); - UNIT_ASSERT((*rci++).second == 'f'); - UNIT_ASSERT((*rci).first == 6); - UNIT_ASSERT((*rci).second == 'f'); - } - - Y_UNIT_TEST(TestEqualRange) { - using maptype = TMap>; - - { - maptype m; - m['x'] = 10; - - std::pair ret; - ret = m.equal_range('x'); - UNIT_ASSERT(ret.first != ret.second); - UNIT_ASSERT((*(ret.first)).first == 'x'); - UNIT_ASSERT((*(ret.first)).second == 10); - UNIT_ASSERT(++(ret.first) == ret.second); - } - - { - { - maptype m; - - maptype::iterator i = m.lower_bound('x'); - UNIT_ASSERT(i == m.end()); - - i = m.upper_bound('x'); - UNIT_ASSERT(i == m.end()); - - std::pair ret; - ret = m.equal_range('x'); - UNIT_ASSERT(ret.first == ret.second); - UNIT_ASSERT(ret.first == m.end()); - } - - { - const maptype m; - std::pair ret; - ret = m.equal_range('x'); - UNIT_ASSERT(ret.first == ret.second); - UNIT_ASSERT(ret.first == m.end()); - } - } - } - - struct TKey { - TKey() - : m_data(0) - { - } - - explicit TKey(int data) - : m_data(data) - { - } - - int m_data; - }; - - struct TKeyCmp { - bool operator()(TKey lhs, TKey rhs) const { - return lhs.m_data < rhs.m_data; - } - - bool operator()(TKey lhs, int rhs) const { - return lhs.m_data < rhs; - } - - bool operator()(int lhs, TKey rhs) const { - return lhs < rhs.m_data; - } - - using is_transparent = void; - }; - - struct TKeyCmpPtr { - bool operator()(TKey const volatile* lhs, TKey const volatile* rhs) const { - return (*lhs).m_data < (*rhs).m_data; - } - - bool operator()(TKey const volatile* lhs, int rhs) const { - return (*lhs).m_data < rhs; - } - - bool operator()(int lhs, TKey const volatile* rhs) const { - return lhs < (*rhs).m_data; - } - - using is_transparent = void; - }; - - Y_UNIT_TEST(TestTemplateMethods) { - { - using Container = TMap; - using value = Container::value_type; - - Container cont; - - cont.insert(value(TKey(1), 1)); - cont.insert(value(TKey(2), 2)); - cont.insert(value(TKey(3), 3)); - cont.insert(value(TKey(4), 4)); - - UNIT_ASSERT(cont.count(TKey(1)) == 1); - UNIT_ASSERT(cont.count(1) == 1); - UNIT_ASSERT(cont.count(5) == 0); - - UNIT_ASSERT(cont.find(2) != cont.end()); - UNIT_ASSERT(cont.lower_bound(2) != cont.end()); - UNIT_ASSERT(cont.upper_bound(2) != cont.end()); - UNIT_ASSERT(cont.equal_range(2) != std::make_pair(cont.begin(), cont.end())); - - Container const& ccont = cont; - - UNIT_ASSERT(ccont.find(2) != ccont.end()); - UNIT_ASSERT(ccont.lower_bound(2) != ccont.end()); - UNIT_ASSERT(ccont.upper_bound(2) != ccont.end()); - UNIT_ASSERT(ccont.equal_range(2) != std::make_pair(ccont.end(), ccont.end())); - } - - { - using Container = TMap; - using value = Container::value_type; - - Container cont; - - TKey key1(1), key2(2), key3(3), key4(4); - - cont.insert(value(&key1, 1)); - cont.insert(value(&key2, 2)); - cont.insert(value(&key3, 3)); - cont.insert(value(&key4, 4)); - - UNIT_ASSERT(cont.count(1) == 1); - UNIT_ASSERT(cont.count(5) == 0); - - UNIT_ASSERT(cont.find(2) != cont.end()); - UNIT_ASSERT(cont.lower_bound(2) != cont.end()); - UNIT_ASSERT(cont.upper_bound(2) != cont.end()); - UNIT_ASSERT(cont.equal_range(2) != std::make_pair(cont.begin(), cont.end())); - - Container const& ccont = cont; - - UNIT_ASSERT(ccont.find(2) != ccont.end()); - UNIT_ASSERT(ccont.lower_bound(2) != ccont.end()); - UNIT_ASSERT(ccont.upper_bound(2) != ccont.end()); - UNIT_ASSERT(ccont.equal_range(2) != std::make_pair(ccont.begin(), ccont.end())); - } - - { - using Container = TMultiMap; - using value = Container::value_type; - - Container cont; - - cont.insert(value(TKey(1), 1)); - cont.insert(value(TKey(2), 2)); - cont.insert(value(TKey(3), 3)); - cont.insert(value(TKey(4), 4)); - - UNIT_ASSERT(cont.count(TKey(1)) == 1); - UNIT_ASSERT(cont.count(1) == 1); - UNIT_ASSERT(cont.count(5) == 0); - - UNIT_ASSERT(cont.find(2) != cont.end()); - UNIT_ASSERT(cont.lower_bound(2) != cont.end()); - UNIT_ASSERT(cont.upper_bound(2) != cont.end()); - UNIT_ASSERT(cont.equal_range(2) != std::make_pair(cont.begin(), cont.end())); - - Container const& ccont = cont; - - UNIT_ASSERT(ccont.find(2) != ccont.end()); - UNIT_ASSERT(ccont.lower_bound(2) != ccont.end()); - UNIT_ASSERT(ccont.upper_bound(2) != ccont.end()); - UNIT_ASSERT(ccont.equal_range(2) != std::make_pair(ccont.end(), ccont.end())); - } - - { - using Container = TMultiMap; - using value = Container::value_type; - - Container cont; - - TKey key1(1), key2(2), key3(3), key4(4); - - cont.insert(value(&key1, 1)); - cont.insert(value(&key2, 2)); - cont.insert(value(&key3, 3)); - cont.insert(value(&key4, 4)); - - UNIT_ASSERT(cont.count(1) == 1); - UNIT_ASSERT(cont.count(5) == 0); - - UNIT_ASSERT(cont.find(2) != cont.end()); - UNIT_ASSERT(cont.lower_bound(2) != cont.end()); - UNIT_ASSERT(cont.upper_bound(2) != cont.end()); - UNIT_ASSERT(cont.equal_range(2) != std::make_pair(cont.begin(), cont.end())); - - Container const& ccont = cont; - - UNIT_ASSERT(ccont.find(2) != ccont.end()); - UNIT_ASSERT(ccont.lower_bound(2) != ccont.end()); - UNIT_ASSERT(ccont.upper_bound(2) != ccont.end()); - UNIT_ASSERT(ccont.equal_range(2) != std::make_pair(ccont.begin(), ccont.end())); - } - } - - template - static void EmptyAndInsertTest(typename T::value_type v) { - T c; - UNIT_ASSERT(!c); - c.insert(v); - UNIT_ASSERT(c); - } - - Y_UNIT_TEST(TestEmpty) { - EmptyAndInsertTest>>(std::pair('a', 1)); - EmptyAndInsertTest>>(std::pair('a', 1)); - } - - struct TParametrizedKeyCmp { - bool Inverse; - - TParametrizedKeyCmp(bool inverse = false) - : Inverse(inverse) - { - } - - bool operator()(TKey lhs, TKey rhs) const { - if (Inverse) { - return lhs.m_data > rhs.m_data; - } else { - return lhs.m_data < rhs.m_data; - } - } - }; - - Y_UNIT_TEST(TestMoveComparator) { - using Container = TMultiMap; - - TParametrizedKeyCmp direct(false); - TParametrizedKeyCmp inverse(true); - - { - Container c(direct); - c = Container(inverse); - - c.insert(std::make_pair(TKey(1), 101)); - c.insert(std::make_pair(TKey(2), 102)); - c.insert(std::make_pair(TKey(3), 103)); - - std::vector values; - for (auto& i : c) { - values.push_back(i.second); - } - - UNIT_ASSERT_VALUES_EQUAL(values.size(), 3); - UNIT_ASSERT_VALUES_EQUAL(values[0], 103); - UNIT_ASSERT_VALUES_EQUAL(values[1], 102); - UNIT_ASSERT_VALUES_EQUAL(values[2], 101); - } - } - - Y_UNIT_TEST(TestMapInitializerList) { - TMap m = { - {"one", 1}, - {"two", 2}, - {"three", 3}, - {"four", 4}, - }; - - UNIT_ASSERT_VALUES_EQUAL(m.size(), 4); - UNIT_ASSERT_VALUES_EQUAL(m["one"], 1); - UNIT_ASSERT_VALUES_EQUAL(m["two"], 2); - UNIT_ASSERT_VALUES_EQUAL(m["three"], 3); - UNIT_ASSERT_VALUES_EQUAL(m["four"], 4); - } - - Y_UNIT_TEST(TestMMapInitializerList) { - TMultiMap mm = { - {"one", 1}, - {"two", 2}, - {"two", -2}, - {"three", 3}, - }; - UNIT_ASSERT(mm.contains("two")); - TMultiMap expected; - expected.emplace("one", 1); - expected.emplace("two", 2); - expected.emplace("two", -2); - expected.emplace("three", 3); - UNIT_ASSERT_VALUES_EQUAL(mm, expected); - } - - Y_UNIT_TEST(TestMovePoolAlloc) { - using TMapInPool = TMap, TPoolAllocator>; - - TMemoryPool pool(1); - - TMapInPool m(&pool); - m.emplace(0, 1); - - UNIT_ASSERT(m.contains(0)); - UNIT_ASSERT_VALUES_EQUAL(1, m[0]); - - TMapInPool movedM = std::move(m); - - UNIT_ASSERT(movedM.contains(0)); - UNIT_ASSERT_VALUES_EQUAL(1, movedM[0]); - } -} diff --git a/util/generic/map_ut.pyx b/util/generic/map_ut.pyx deleted file mode 100644 index 19dc97b1347..00000000000 --- a/util/generic/map_ut.pyx +++ /dev/null @@ -1,84 +0,0 @@ -# cython: c_string_type=unicode, c_string_encoding=utf8 - -from util.generic.map cimport TMap -from util.generic.string cimport TString - -import pytest -import unittest - -from libcpp.pair cimport pair -from cython.operator cimport dereference as deref - - -def _check_convert(TMap[TString, int] x): - return x - - -class TestMap(unittest.TestCase): - - def test_constructors_and_assignments(self): - cdef TMap[TString, int] c1 - c1["one"] = 1 - c1["two"] = 2 - cdef TMap[TString, int] c2 = TMap[TString, int](c1) - self.assertEqual(2, c1.size()) - self.assertEqual(2, c2.size()) - self.assertEqual(1, c1.at("one")) - self.assertTrue(c1.contains("two")) - self.assertTrue(c2.contains("one")) - self.assertEqual(2, c2.at("two")) - c2["three"] = 3 - c1 = c2 - self.assertEqual(3, c1.size()) - self.assertEqual(3, c2.size()) - self.assertEqual(3, c1.at("three")) - - def test_equality_operator(self): - cdef TMap[TString, int] base - base["one"] = 1 - base["two"] = 2 - - cdef TMap[TString, int] c1 = TMap[TString, int](base) - self.assertTrue(c1==base) - - cdef TMap[TString, int] c2 - c2["one"] = 1 - c2["two"] = 2 - self.assertTrue(c2 == base) - - c2["three"] = 3 - self.assertTrue(c2 != base) - - cdef TMap[TString, int] c3 = TMap[TString, int](base) - c3["one"] = 0 - self.assertTrue(c3 != base) - - def test_insert_erase(self): - cdef TMap[TString, int] tmp - self.assertTrue(tmp.insert(pair[TString, int]("one", 0)).second) - self.assertFalse(tmp.insert(pair[TString, int]("one", 1)).second) - self.assertTrue(tmp.insert(pair[TString, int]("two", 2)).second) - cdef TString one = "one" - cdef TString two = "two" - self.assertEqual(tmp.erase(one), 1) - self.assertEqual(tmp.erase(two), 1) - self.assertEqual(tmp.size(), 0) - self.assertTrue(tmp.empty()) - - def test_iterators_and_find(self): - cdef TMap[TString, int] tmp - self.assertTrue(tmp.begin() == tmp.end()) - self.assertTrue(tmp.find("1") == tmp.end()) - tmp["1"] = 1 - self.assertTrue(tmp.begin() != tmp.end()) - cdef TMap[TString, int].iterator it = tmp.find("1") - self.assertTrue(it != tmp.end()) - self.assertEqual(deref(it).second, 1) - - def test_convert(self): - src = {'foo': 1, 'bar': 42} - self.assertEqual(_check_convert(src), src) - - bad_src = {'foo': 1, 'bar': 'baz'} - with self.assertRaises(TypeError): - _check_convert(bad_src) diff --git a/util/generic/serialized_enum.h b/util/generic/serialized_enum.h index a00902cca51..c032596d0c6 100644 --- a/util/generic/serialized_enum.h +++ b/util/generic/serialized_enum.h @@ -39,7 +39,7 @@ namespace NEnumSerializationRuntime { template > class TMappedArrayView; - template > + template > class TMappedDictView; } @@ -395,7 +395,7 @@ namespace NEnumSerializationRuntime { } // Allocate container and copy view's content into it - template