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>>
62 template <
typename K1,
typename K2>
63 bool is_equal(
const K1 &
A,
const K2 &
B)
const {
64 return !Comp(
A,
B) && !Comp(
B,
A);
69 [
this](
const value_type &
E,
const K &KeyVal) {
70 return Comp(
E.first, KeyVal);
75 std::pair<const_iterator, bool> find_or_insert_location(
const K &
Key)
const {
76 if (!Vector.empty() && Comp(Vector.back().first,
Key))
77 return {Vector.end(),
false};
78 auto It = lower_bound(
Key);
79 bool Found = (It != Vector.end() && is_equal(
Key, It->first));
84 std::pair<iterator, bool> find_or_insert_location(
const K &
Key) {
85 auto [ConstIt, Found] = std::as_const(*this).find_or_insert_location(
Key);
86 return {Vector.begin() + (ConstIt - Vector.begin()), Found};
89 template <
typename KeyArgT,
typename... Ts>
90 std::pair<iterator, bool> try_emplace_impl(KeyArgT &&
Key, Ts &&...Args) {
91 auto [It, Found] = find_or_insert_location(
Key);
96 std::forward_as_tuple(std::forward<KeyArgT>(
Key)),
97 std::forward_as_tuple(std::forward<Ts>(Args)...)));
111 [[nodiscard]]
bool empty()
const {
return Vector.empty(); }
119 auto [It, Found] = find_or_insert_location(
Key);
120 return Found ? It : Vector.end();
124 auto [It, Found] = find_or_insert_location(
Key);
125 return Found ? It : Vector.end();
128 template <
typename... Ts>
130 return try_emplace_impl(
Key, std::forward<Ts>(Args)...);
133 template <
typename... Ts>
135 return try_emplace_impl(std::move(
Key), std::forward<Ts>(Args)...);
139 return try_emplace_impl(KV.first, KV.second);
143 return try_emplace_impl(std::move(KV.first), std::move(KV.second));
147 return try_emplace_impl(
Key).first->second;
151 return try_emplace_impl(std::move(
Key)).first->second;
158 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
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
typename VectorType::iterator iterator
size_type capacity() const
void reserve(size_type Cap)
typename VectorType::const_iterator const_iterator
ValueT & operator[](const KeyT &Key)
std::pair< iterator, bool > try_emplace(KeyT &&Key, Ts &&...Args)
ValueT & operator[](KeyT &&Key)
std::pair< iterator, bool > try_emplace(const KeyT &Key, Ts &&...Args)
SortedVectorMap()=default
std::pair< KeyT, ValueT > value_type
const_iterator begin() const
iterator find(const K &Key)
SmallVector< value_type, N > VectorType
iterator erase(const_iterator Pos)
typename VectorType::size_type size_type
std::pair< iterator, bool > insert(const value_type &KV)
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...