Browse Source

Drop TEnumIndexedVector

babenko 1 year ago
parent
commit
bbacc05ccf

+ 0 - 61
library/cpp/yt/misc/enum-inl.h

@@ -302,67 +302,6 @@ T TEnumTraits<T, true>::FromString(TStringBuf literal)
 
 ////////////////////////////////////////////////////////////////////////////////
 
-template <class E, class T, E Min, E Max>
-constexpr TEnumIndexedVector<E, T, Min, Max>::TEnumIndexedVector()
-    : Items_{}
-{ }
-
-template <class E, class T, E Min, E Max>
-constexpr TEnumIndexedVector<E, T, Min, Max>::TEnumIndexedVector(std::initializer_list<T> elements)
-    : Items_{}
-{
-    Y_ASSERT(std::distance(elements.begin(), elements.end()) <= N);
-    size_t index = 0;
-    for (const auto& element : elements) {
-        Items_[index++] = element;
-    }
-}
-
-template <class E, class T, E Min, E Max>
-T& TEnumIndexedVector<E, T, Min, Max>::operator[] (E index)
-{
-    Y_ASSERT(index >= Min && index <= Max);
-    return Items_[ToUnderlying(index) - ToUnderlying(Min)];
-}
-
-template <class E, class T, E Min, E Max>
-const T& TEnumIndexedVector<E, T, Min, Max>::operator[] (E index) const
-{
-    return const_cast<TEnumIndexedVector&>(*this)[index];
-}
-
-template <class E, class T, E Min, E Max>
-T* TEnumIndexedVector<E, T, Min, Max>::begin()
-{
-    return Items_.data();
-}
-
-template <class E, class T, E Min, E Max>
-const T* TEnumIndexedVector<E, T, Min, Max>::begin() const
-{
-    return Items_.data();
-}
-
-template <class E, class T, E Min, E Max>
-T* TEnumIndexedVector<E, T, Min, Max>::end()
-{
-    return begin() + N;
-}
-
-template <class E, class T, E Min, E Max>
-const T* TEnumIndexedVector<E, T, Min, Max>::end() const
-{
-    return begin() + N;
-}
-
-template <class E, class T, E Min, E Max>
-bool TEnumIndexedVector<E, T, Min, Max>::IsDomainValue(E value)
-{
-    return value >= Min && value <= Max;
-}
-
-////////////////////////////////////////////////////////////////////////////////
-
 #define ENUM__BINARY_BITWISE_OPERATOR(T, assignOp, op) \
     [[maybe_unused]] inline constexpr T operator op (T lhs, T rhs) \
     { \

+ 0 - 46
library/cpp/yt/misc/enum.h

@@ -185,52 +185,6 @@ struct TEnumTraits<T, true>
 
 ////////////////////////////////////////////////////////////////////////////////
 
-// TODO(babenko): drop in favor of TEnumIndexedArray
-//! A statically sized vector with elements of type |T| indexed by
-//! the items of enumeration type |E|.
-/*!
- *  Items are value-initialized on construction.
- */
-template <
-    class E,
-    class T,
-    E Min = TEnumTraits<E>::GetMinValue(),
-    E Max = TEnumTraits<E>::GetMaxValue()
->
-class TEnumIndexedVector
-{
-public:
-    using TIndex = E;
-    using TValue = T;
-
-    constexpr TEnumIndexedVector();
-    constexpr TEnumIndexedVector(std::initializer_list<T> elements);
-
-    constexpr TEnumIndexedVector(const TEnumIndexedVector&) = default;
-    constexpr TEnumIndexedVector(TEnumIndexedVector&&) noexcept = default;
-
-    constexpr TEnumIndexedVector& operator=(const TEnumIndexedVector&) = default;
-    constexpr TEnumIndexedVector& operator=(TEnumIndexedVector&&) noexcept = default;
-
-    T& operator[] (E index);
-    const T& operator[] (E index) const;
-
-    // STL interop.
-    T* begin();
-    const T* begin() const;
-    T* end();
-    const T* end() const;
-
-    static bool IsDomainValue(E value);
-
-private:
-    using TUnderlying = std::underlying_type_t<E>;
-    static constexpr int N = static_cast<TUnderlying>(Max) - static_cast<TUnderlying>(Min) + 1;
-    std::array<T, N> Items_;
-};
-
-////////////////////////////////////////////////////////////////////////////////
-
 //! Returns |true| iff the enumeration value is not bitwise zero.
 template <typename E>
     requires TEnumTraits<E>::IsBitEnum

+ 0 - 21
library/cpp/yt/string/format-inl.h

@@ -415,27 +415,6 @@ struct TValueFormatter<TEnumIndexedArray<E, T>>
     }
 };
 
-// TEnumIndexedVector
-template <class E, class T>
-struct TValueFormatter<TEnumIndexedVector<E, T>>
-{
-    static void Do(TStringBuilderBase* builder, const TEnumIndexedVector<E, T>& collection, TStringBuf format)
-    {
-        builder->AppendChar('{');
-        bool firstItem = true;
-        for (const auto& index : TEnumTraits<E>::GetDomainValues()) {
-            if (!firstItem) {
-                builder->AppendString(DefaultJoinToStringDelimiter);
-            }
-            FormatValue(builder, index, format);
-            builder->AppendString(": ");
-            FormatValue(builder, collection[index], format);
-            firstItem = false;
-        }
-        builder->AppendChar('}');
-    }
-};
-
 // std::pair
 template <class T1, class T2>
 struct TValueFormatter<std::pair<T1, T2>>

+ 0 - 1
library/cpp/yt/string/unittests/enum_ut.cpp

@@ -14,7 +14,6 @@ namespace {
 DEFINE_ENUM(ESample, (One)(Two));
 static_assert(TFormatTraits<ESample>::HasCustomFormatValue);
 static_assert(TFormatTraits<TEnumIndexedArray<ESample, int>>::HasCustomFormatValue);
-static_assert(TFormatTraits<TEnumIndexedVector<ESample, int>>::HasCustomFormatValue);
 
 DEFINE_ENUM(EColor,
     (Red)