14 #ifndef LLVM_ADT_SMALLSET_H
15 #define LLVM_ADT_SMALLSET_H
35 template <
typename T,
unsigned N,
typename C = std::less<T>>
49 static_assert(
N <= 32,
"N should be small");
57 return Vector.empty() && Set.empty();
61 return isSmall() ? Vector.size() : Set.size();
68 return vfind(V) == Vector.end() ? 0 : 1;
81 std::pair<NoneType, bool>
insert(
const T &V) {
83 return std::make_pair(
None, Set.insert(V).second);
85 VIterator
I = vfind(V);
86 if (I != Vector.end())
87 return std::make_pair(
None,
false);
88 if (Vector.size() <
N) {
90 return std::make_pair(
None,
true);
94 while (!Vector.empty()) {
95 Set.insert(Vector.back());
99 return std::make_pair(
None,
true);
102 template <
typename IterT>
111 for (mutable_iterator
I = Vector.begin(),
E = Vector.end();
I !=
E; ++
I)
125 bool isSmall()
const {
return Set.empty(); }
127 VIterator vfind(
const T &V)
const {
128 for (VIterator
I = Vector.begin(),
E = Vector.end();
I !=
E; ++
I)
137 template <
typename Po
inteeType,
unsigned N>
142 #endif // LLVM_ADT_SMALLSET_H
typename SuperClass::const_iterator const_iterator
LLVM_NODISCARD bool empty() const
void insert(IterT I, IterT E)
SmallSet - This maintains a set of unique values, optimizing for the case when the set is small (less...
std::pair< NoneType, bool > insert(const T &V)
insert - Insert an element into the set if it isn't already there.
size_type count(const T &V) const
count - Return 1 if the element is in the set, 0 otherwise.
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
typename SuperClass::iterator iterator
#define LLVM_NODISCARD
LLVM_NODISCARD - Warn if a type or return value is discarded.