Iros
 
Loading...
Searching...
No Matches
tree_map.h
Go to the documentation of this file.
1#pragma once
2
11#include "di/function/compare.h"
12#include "di/platform/prelude.h"
15
16namespace di::container {
17namespace detail {
18 template<typename Comp, typename Key>
20 [[no_unique_address]] Comp comp {};
21
22 template<typename U, typename V1, typename V2>
24 constexpr auto operator()(Tuple<Key, V1> const& a, Tuple<U, V2> const& b) const {
26 }
27
28 template<typename U, typename V1, typename V2>
30 constexpr auto operator()(Tuple<U, V1> const& a, Tuple<Key, V2> const& b) const {
32 }
33
34 template<typename U, typename V1>
36 constexpr auto operator()(Tuple<Key, V1> const& a, U const& b) const {
37 return function::invoke(comp, util::get<0>(a), b);
38 }
39
40 template<typename U, typename V2>
42 constexpr auto operator()(U const& a, Tuple<Key, V2> const& b) const {
43 return function::invoke(comp, a, util::get<0>(b));
44 }
45
46 template<typename U>
48 constexpr auto operator()(Key const& a, U const& b) const {
49 return function::invoke(comp, a, b);
50 }
51
52 template<typename U>
54 constexpr auto operator()(U const& a, Key const& b) const {
55 return function::invoke(comp, a, b);
56 }
57
58 template<typename T, typename U>
60 constexpr auto operator()(T const& a, U const& b) const {
61 return function::invoke(comp, a, b);
62 }
63 };
64
65 template<typename Key, typename Value>
66 struct TreeMapTag : OwningRBTreeTag<TreeMapTag<Key, Value>, Tuple<Key, Value>> {};
67}
68
69template<typename Key, typename Value, concepts::StrictWeakOrder<Key> Comp = function::Compare,
70 concepts::Allocator Alloc = DefaultAllocator>
72 : public OwningRBTree<
73 Tuple<Key, Value>, detail::TreeMapCompAdapter<Comp, Key>, detail::TreeMapTag<Key, Value>, Alloc,
74 MapInterface<
75 TreeMap<Key, Value, Comp, Alloc>, Tuple<Key, Value>, Key, Value,
76 RBTreeIterator<Tuple<Key, Value>, detail::TreeMapTag<Key, Value>>,
77 container::ConstIteratorImpl<RBTreeIterator<Tuple<Key, Value>, detail::TreeMapTag<Key, Value>>>,
78 detail::RBTreeValidForLookup<Tuple<Key, Value>, detail::TreeMapCompAdapter<Comp, Key>>::template Type,
79 false>,
80 false> {
81private:
82 using Base = OwningRBTree<
89 false>,
90 false>;
91
92public:
93 TreeMap() = default;
94
95 TreeMap(Comp const& comparator) : Base(detail::TreeMapCompAdapter<Comp, Key> { comparator }) {}
96};
97
98template<concepts::InputContainer Con, concepts::TupleLike T = meta::ContainerValue<Con>>
99requires(meta::TupleSize<T> == 2)
102
103template<concepts::InputContainer Con, concepts::TupleLike T = meta::ContainerValue<Con>,
104 concepts::StrictWeakOrder<T> Comp>
105requires(meta::TupleSize<T> == 2)
108}
109
110namespace di {
112}
Definition const_iterator_impl.h:19
Definition map_interface.h:21
Definition owning_rb_tree.h:42
Definition rb_tree_iterator.h:10
Definition tree_map.h:80
TreeMap(Comp const &comparator)
Definition tree_map.h:95
Definition tuple_forward_declaration.h:5
Definition core.h:114
Definition relation.h:31
Definition sequence.h:13
Definition sequence.h:12
constexpr auto invoke
Definition invoke.h:100
constexpr auto TupleSize
Definition tuple_size.h:23
decltype(vocab::tuple_element(types::in_place_type< meta::RemoveReference< T > >, c_< index >))::Type TupleElement
Definition tuple_element.h:21
di::meta::Decay< decltype(T)> Tag
Definition tag_invoke.h:28
constexpr auto get(T &&value) -> decltype(auto)
Definition get.h:8
Definition zstring_parser.h:9
constexpr tag_invoke_detail::TagInvokeFn tag_invoke
Definition tag_invoke.h:22
Definition owning_rb_tree.h:28
Comp comp
Definition tree_map.h:20
Definition tree_map.h:66
Definition in_place_template.h:5