14#ifndef LLVM_ADT_SMALLSET_H
15#define LLVM_ADT_SMALLSET_H
24#include <initializer_list>
32template <
typename T,
unsigned N,
typename C>
35 std::forward_iterator_tag, T> {
37 using SetIterTy =
typename std::set<T, C>::const_iterator;
87 IsSmall =
Other.IsSmall;
101 IsSmall =
Other.IsSmall;
110 if (IsSmall !=
RHS.IsSmall)
132template <
typename T,
unsigned N,
typename C = std::less<T>>
143 static_assert(
N <= 32,
"N should be small");
155 template <
typename IterT>
SmallSet(IterT Begin, IterT End) {
159 template <
typename Range>
168 [[nodiscard]]
bool empty()
const {
return Vector.empty() && Set.empty(); }
171 return isSmall() ? Vector.size() : Set.size();
181 std::pair<const_iterator, bool>
insert(
const T &V) {
return insertImpl(V); }
183 std::pair<const_iterator, bool>
insert(
T &&V) {
184 return insertImpl(std::move(V));
187 template <
typename IterT>
201 if (
I != Vector.end()) {
215 return {Vector.begin()};
216 return {Set.begin()};
221 return {Vector.end()};
228 return vfind(V) != Vector.end();
229 return Set.find(V) != Set.end();
233 bool isSmall()
const {
return Set.empty(); }
235 template <
typename ArgType>
236 std::pair<const_iterator, bool> insertImpl(ArgType &&V) {
237 static_assert(std::is_convertible_v<ArgType, T>,
238 "ArgType must be convertible to T!");
240 auto [
I, Inserted] = Set.insert(std::forward<ArgType>(V));
245 if (
I != Vector.end())
247 if (Vector.size() <
N) {
248 Vector.push_back(std::forward<ArgType>(V));
252 Set.insert(std::make_move_iterator(Vector.begin()),
253 std::make_move_iterator(Vector.end()));
255 return {
const_iterator(Set.insert(std::forward<ArgType>(V)).first),
true};
261 for (
auto I = Vector.begin(),
E = Vector.end();
I !=
E; ++
I)
270template <
typename Po
inteeType,
unsigned N>
281template <
typename T,
unsigned LN,
unsigned RN,
typename C>
283 if (
LHS.size() !=
RHS.size())
293template <
typename T,
unsigned LN,
unsigned RN,
typename C>
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
ConstantRange Range(APInt(BitWidth, Low), APInt(BitWidth, High))
This file contains library features backported from future STL versions.
This file defines the SmallPtrSet class.
This file defines the SmallVector class.
SmallSetIterator - This class implements a const_iterator for SmallSet by delegating to the underlyin...
SmallSetIterator & operator=(SmallSetIterator &&Other)
SmallSetIterator & operator++()
bool operator==(const SmallSetIterator &RHS) const
SmallSetIterator(SetIterTy SetIter)
SmallSetIterator & operator=(const SmallSetIterator &Other)
SmallSetIterator(const SmallSetIterator &Other)
const T & operator*() const
SmallSetIterator(VecIterTy VecIter)
SmallSetIterator(SmallSetIterator &&Other)
SmallSet - This maintains a set of unique values, optimizing for the case when the set is small (less...
const_iterator begin() const
size_type count(const T &V) const
count - Return 1 if the element is in the set, 0 otherwise.
SmallSetIterator< T, N, C > const_iterator
void insert(IterT I, IterT E)
void insert_range(Range &&R)
std::pair< const_iterator, bool > insert(T &&V)
SmallSet(std::initializer_list< T > L)
SmallSet(llvm::from_range_t, Range &&R)
SmallSet & operator=(const SmallSet &)=default
SmallSet(SmallSet &&)=default
SmallSet(const SmallSet &)=default
const_iterator end() const
SmallSet(IterT Begin, IterT End)
bool contains(const T &V) const
Check if the SmallSet contains the given element.
SmallSet & operator=(SmallSet &&)=default
std::pair< const_iterator, bool > insert(const T &V)
insert - Insert an element into the set if it isn't already there.
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
CRTP base class which implements the entire standard iterator facade in terms of a minimal subset of ...
This is an optimization pass for GlobalISel generic memory operations.
bool all_of(R &&range, UnaryPredicate P)
Provide wrappers to std::all_of which take ranges instead of having to pass begin/end explicitly.
constexpr auto adl_begin(RangeT &&range) -> decltype(adl_detail::begin_impl(std::forward< RangeT >(range)))
Returns the begin iterator to range using std::begin and function found through Argument-Dependent Lo...
bool operator!=(uint64_t V1, const APInt &V2)
constexpr auto adl_end(RangeT &&range) -> decltype(adl_detail::end_impl(std::forward< RangeT >(range)))
Returns the end iterator to range using std::end and functions found through Argument-Dependent Looku...
bool operator==(const AddressRangeValuePair &LHS, const AddressRangeValuePair &RHS)