14 #ifndef LLVM_ADT_SMALLSET_H
15 #define LLVM_ADT_SMALLSET_H
35 template <
typename T,
unsigned N,
typename C = std::less<T>>
48 static_assert(
N <= 32,
"N should be small");
56 return Vector.empty() && Set.empty();
60 return isSmall() ? Vector.size() : Set.size();
67 return vfind(V) == Vector.end() ? 0 : 1;
80 std::pair<NoneType, bool>
insert(
const T &V) {
82 return std::make_pair(
None, Set.insert(V).second);
84 VIterator
I = vfind(V);
85 if (I != Vector.end())
86 return std::make_pair(
None,
false);
87 if (Vector.size() <
N) {
89 return std::make_pair(
None,
true);
93 while (!Vector.empty()) {
94 Set.insert(Vector.back());
98 return std::make_pair(
None,
true);
101 template <
typename IterT>
110 for (mutable_iterator
I = Vector.begin(),
E = Vector.end();
I !=
E; ++
I)
124 bool isSmall()
const {
return Set.empty(); }
126 VIterator vfind(
const T &V)
const {
127 for (VIterator
I = Vector.begin(),
E = Vector.end();
I !=
E; ++
I)
136 template <
typename Po
inteeType,
unsigned N>
141 #endif // LLVM_ADT_SMALLSET_H
LLVM_NODISCARD bool empty() const
void insert(IterT I, IterT E)
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...
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...
#define LLVM_NODISCARD
LLVM_NODISCARD - Warn if a type or return value is discarded.