14 #ifndef LLVM_ADT_SMALLSET_H 15 #define LLVM_ADT_SMALLSET_H 26 #include <type_traits> 33 template <
typename T,
unsigned N,
typename C>
36 std::forward_iterator_tag, T> {
38 using SetIterTy =
typename std::set<T, C>::const_iterator;
89 isSmall = Other.isSmall;
103 isSmall =
Other.isSmall;
112 if (isSmall != RHS.isSmall)
134 template <
typename T,
unsigned N,
typename C = std::less<T>>
148 static_assert(
N <= 32,
"N should be small");
157 return Vector.
empty() && Set.empty();
161 return isSmall() ? Vector.
size() : Set.size();
168 return vfind(V) == Vector.
end() ? 0 : 1;
181 std::pair<NoneType, bool>
insert(
const T &V) {
183 return std::make_pair(
None, Set.insert(V).second);
185 VIterator
I = vfind(V);
186 if (I != Vector.
end())
187 return std::make_pair(
None,
false);
188 if (Vector.
size() <
N) {
190 return std::make_pair(
None,
true);
194 while (!Vector.
empty()) {
195 Set.insert(Vector.
back());
199 return std::make_pair(
None,
true);
202 template <
typename IterT>
211 for (mutable_iterator
I = Vector.
begin(),
E = Vector.
end();
I !=
E; ++
I)
226 return {Vector.
begin()};
227 return {Set.begin()};
232 return {Vector.
end()};
237 bool isSmall()
const {
return Set.empty(); }
239 VIterator vfind(
const T &V)
const {
240 for (VIterator
I = Vector.
begin(),
E = Vector.
end();
I !=
E; ++
I)
249 template <
typename Po
inteeType,
unsigned N>
254 #endif // LLVM_ADT_SMALLSET_H
typename SuperClass::const_iterator const_iterator
This class represents lattice values for constants.
SmallSetIterator & operator++()
void push_back(const T &Elt)
block Block Frequency true
bool operator==(const SmallSetIterator &RHS) const
#define LLVM_NODISCARD
LLVM_NODISCARD - Warn if a type or return value is discarded.
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")
LLVM_ATTRIBUTE_ALWAYS_INLINE iterator begin()
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_ATTRIBUTE_ALWAYS_INLINE iterator end()
LLVM_NODISCARD bool empty() const
size_type count(const T &V) const
count - Return 1 if the element is in the set, 0 otherwise.