31#ifndef LLVM_ADT_SORTEDVECTORMAP_H
32#define LLVM_ADT_SORTEDVECTORMAP_H
45template <
typename KeyT,
typename ValueT,
unsigned N = 0,
46 typename KeyCompare = std::less<KeyT>>
64 template <
typename K1,
typename K2>
65 bool is_equal(
const K1 &
A,
const K2 &
B)
const {
66 return !Comp(
A,
B) && !Comp(
B,
A);
71 [
this](
const value_type &
E,
const K &KeyVal) {
72 return Comp(
E.first, KeyVal);
77 std::pair<const_iterator, bool> find_or_insert_location(
const K &
Key)
const {
78 if (!Vector.empty() && Comp(Vector.back().first,
Key))
79 return {Vector.end(),
false};
80 auto It = lower_bound(
Key);
81 bool Found = (It != Vector.end() && is_equal(
Key, It->first));
86 std::pair<iterator, bool> find_or_insert_location(
const K &
Key) {
87 auto [ConstIt, Found] = std::as_const(*this).find_or_insert_location(
Key);
88 return {Vector.begin() + (ConstIt - Vector.begin()), Found};
91 template <
typename KeyArgT,
typename... Ts>
92 std::pair<iterator, bool> try_emplace_impl(KeyArgT &&
Key, Ts &&...Args) {
93 auto [It, Found] = find_or_insert_location(
Key);
98 std::forward_as_tuple(std::forward<KeyArgT>(
Key)),
99 std::forward_as_tuple(std::forward<Ts>(Args)...)));
122 [[nodiscard]]
bool empty()
const {
return Vector.empty(); }
130 auto [It, Found] = find_or_insert_location(
Key);
131 return Found ? It : Vector.end();
135 auto [It, Found] = find_or_insert_location(
Key);
136 return Found ? It : Vector.end();
139 template <
typename... Ts>
141 return try_emplace_impl(
Key, std::forward<Ts>(Args)...);
144 template <
typename... Ts>
146 return try_emplace_impl(std::move(
Key), std::forward<Ts>(Args)...);
150 return try_emplace_impl(KV.first, KV.second);
154 return try_emplace_impl(std::move(KV.first), std::move(KV.second));
158 return try_emplace_impl(
Key).first->second;
162 return try_emplace_impl(std::move(
Key)).first->second;
169 return Vector ==
Other.Vector;
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
#define LLVM_NO_UNIQUE_ADDRESS
This file defines the SmallVector class.
typename SuperClass::const_iterator const_iterator
typename SuperClass::iterator iterator
typename SuperClass::size_type size_type
std::reverse_iterator< const_iterator > const_reverse_iterator
std::reverse_iterator< iterator > reverse_iterator
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
const_iterator find(const K &Key) const
reverse_iterator rbegin()
typename VectorType::iterator iterator
size_type capacity() const
void reserve(size_type Cap)
const_reverse_iterator crbegin() const
typename VectorType::const_iterator const_iterator
ValueT & operator[](const KeyT &Key)
std::pair< iterator, bool > try_emplace(KeyT &&Key, Ts &&...Args)
typename VectorType::const_reverse_iterator const_reverse_iterator
ValueT & operator[](KeyT &&Key)
const_reverse_iterator rend() const
std::pair< iterator, bool > try_emplace(const KeyT &Key, Ts &&...Args)
SortedVectorMap()=default
std::pair< KeyT, ValueT > value_type
const_iterator cend() const
const_reverse_iterator rbegin() const
const_iterator begin() const
const_iterator cbegin() const
iterator find(const K &Key)
SmallVector< value_type, N > VectorType
iterator erase(const_iterator Pos)
const_reverse_iterator crend() const
typename VectorType::size_type size_type
std::pair< iterator, bool > insert(const value_type &KV)
typename VectorType::reverse_iterator reverse_iterator
bool operator==(const SortedVectorMap &Other) const
std::pair< iterator, bool > insert(value_type &&KV)
iterator erase(iterator Pos)
const_iterator end() const
This is an optimization pass for GlobalISel generic memory operations.
LLVM_ATTRIBUTE_VISIBILITY_DEFAULT AnalysisKey InnerAnalysisManagerProxy< AnalysisManagerT, IRUnitT, ExtraArgTs... >::Key
auto lower_bound(R &&Range, T &&Value)
Provide wrappers to std::lower_bound which take ranges instead of having to pass begin/end explicitly...