13 #ifndef LLVM_ADT_SMALLSET_H 14 #define LLVM_ADT_SMALLSET_H 25 #include <type_traits> 32 template <
typename T,
unsigned N,
typename C>
35 std::forward_iterator_tag, T> {
37 using SetIterTy =
typename std::set<T, C>::const_iterator;
88 isSmall = Other.isSmall;
102 isSmall =
Other.isSmall;
111 if (isSmall != RHS.isSmall)
133 template <
typename T,
unsigned N,
typename C = std::less<T>>
147 static_assert(
N <= 32,
"N should be small");
156 return Vector.
empty() && Set.empty();
160 return isSmall() ? Vector.
size() : Set.size();
167 return vfind(V) == Vector.
end() ? 0 : 1;
180 std::pair<NoneType, bool>
insert(
const T &V) {
182 return std::make_pair(
None, Set.insert(V).second);
184 VIterator
I = vfind(V);
185 if (I != Vector.
end())
186 return std::make_pair(
None,
false);
187 if (Vector.
size() <
N) {
189 return std::make_pair(
None,
true);
193 while (!Vector.
empty()) {
194 Set.insert(Vector.
back());
198 return std::make_pair(
None,
true);
201 template <
typename IterT>
210 for (mutable_iterator
I = Vector.
begin(),
E = Vector.
end();
I !=
E; ++
I)
225 return {Vector.
begin()};
226 return {Set.begin()};
231 return {Vector.
end()};
236 bool isSmall()
const {
return Set.empty(); }
238 VIterator vfind(
const T &V)
const {
239 for (VIterator
I = Vector.
begin(),
E = Vector.
end();
I !=
E; ++
I)
248 template <
typename Po
inteeType,
unsigned N>
259 template <
typename T,
unsigned LN,
unsigned RN,
typename C>
265 return all_of(LHS, [&RHS](
const T &
E) {
return RHS.
count(E); });
271 template <
typename T,
unsigned LN,
unsigned RN,
typename C>
273 return !(LHS == RHS);
278 #endif // LLVM_ADT_SMALLSET_H
typename SuperClass::const_iterator const_iterator
This class represents lattice values for constants.
bool operator!=(const SmallSetIterator< T, N, C > &RHS) const
SmallSetIterator & operator++()
void push_back(const T &Elt)
bool all_of(R &&range, UnaryPredicate P)
Provide wrappers to std::all_of which take ranges instead of having to pass begin/end explicitly...
block Block Frequency true
bool operator==(const SmallSetIterator &RHS) const
LLVM_NODISCARD bool empty() const
const_iterator begin() const
SmallSetIterator & operator=(const SmallSetIterator &Other)
SmallSetIterator(SmallSetIterator &&Other)
const_iterator end() const
CRTP base class which implements the entire standard iterator facade in terms of a minimal subset of ...
void insert(IterT I, IterT E)
SmallSetIterator(SetIterTy SetIter)
const T & operator*() const
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
SmallSet - This maintains a set of unique values, optimizing for the case when the set is small (less...
SmallSetIterator(VecIterTy VecIter)
std::pair< NoneType, bool > insert(const T &V)
insert - Insert an element into the set if it isn't already there.
SmallSetIterator(const SmallSetIterator &Other)
iterator erase(const_iterator CI)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
typename SuperClass::iterator iterator
SmallSetIterator - This class implements a const_iterator for SmallSet by delegating to the underlyin...
SmallSetIterator & operator=(SmallSetIterator &&Other)
LLVM_NODISCARD bool empty() const
#define LLVM_NODISCARD
LLVM_NODISCARD - Warn if a type or return value is discarded.
size_type count(const T &V) const
count - Return 1 if the element is in the set, 0 otherwise.