| 28 | // Used in the TSet to make iterator behave as const_iterator |
| 29 | template <class> class IteratorModifier = NPrivate::TTypeIdentity> |
| 30 | class TTable { |
| 31 | private: |
| 32 | static_assert(NConcepts::ContainerV<Container>); |
| 33 | static_assert(NConcepts::SizeFitterV<SizeFitter>); |
| 34 | |
| 35 | template <class C, class V> |
| 36 | class TIteratorImpl : public TIterator<C, V> { |
| 37 | private: |
| 38 | using TBase = TIterator<C, V>; |
| 39 | friend class TTable; |
| 40 | |
| 41 | using TBase::TBase; |
| 42 | |
| 43 | public: |
| 44 | TIteratorImpl() : TBase(nullptr, 0) {} |
| 45 | }; |
| 46 | |
| 47 | public: |
| 48 | using value_type = typename Container::value_type; |
| 49 | using size_type = typename Container::size_type; |
| 50 | using difference_type = typename Container::difference_type; |
| 51 | using hasher = Hash; |
| 52 | using key_equal = KeyEqual; |
| 53 | |
| 54 | using reference = value_type&; |
| 55 | using const_reference = const value_type&; |
| 56 | |
| 57 | using iterator = TIteratorImpl<typename IteratorModifier<Container>::type, |
| 58 | typename IteratorModifier<value_type>::type>; |
| 59 | using const_iterator = TIteratorImpl<const Container, const value_type>; |
| 60 | using allocator_type = typename Container::allocator_type; |
| 61 | using pointer = typename Container::pointer; |
| 62 | using const_pointer = typename Container::const_pointer; |
| 63 | |
| 64 | private: |
| 65 | TTable(Container buckets) |
| 66 | : Buckets_(std::move(buckets)) |
| 67 | { |
| 68 | SizeFitter_.Update(bucket_count()); |
| 69 | } |
| 70 | |
| 71 | static constexpr size_type INIT_SIZE = 8; |
| 72 | |
| 73 | public: |
| 74 | template <class... Rest> |
| 75 | TTable(size_type initSize, Rest&&... rest) |
| 76 | : Buckets_(initSize == 0 ? INIT_SIZE : SizeFitter_.EvalSize(initSize), |
| 77 | std::forward<Rest>(rest)...) |
| 78 | { |
| 79 | SizeFitter_.Update(bucket_count()); |
| 80 | } |
| 81 | |
| 82 | TTable(const TTable&) = default; |
| 83 | TTable(TTable&& rhs) |
| 84 | : SizeFitter_(std::move(rhs.SizeFitter_)) |
| 85 | , Buckets_(std::move(rhs.Buckets_)) |
| 86 | , Hasher_(std::move(rhs.Hasher_)) |
| 87 | , KeyEqual_(std::move(rhs.KeyEqual_)) |