14 #ifndef LLVM_ADT_SMALLSET_H
15 #define LLVM_ADT_SMALLSET_H
31 template <
typename T,
unsigned N,
typename C = std::less<T> >
45 return Vector.empty() && Set.empty();
49 return isSmall() ? Vector.size() : Set.size();
56 return vfind(V) == Vector.end() ? 0 : 1;
69 std::pair<NoneType, bool>
insert(
const T &V) {
71 return std::make_pair(
None, Set.insert(V).second);
73 VIterator
I = vfind(V);
74 if (I != Vector.end())
75 return std::make_pair(
None,
false);
76 if (Vector.size() <
N) {
78 return std::make_pair(
None,
true);
82 while (!Vector.empty()) {
83 Set.insert(Vector.back());
87 return std::make_pair(
None,
true);
90 template <
typename IterT>
99 for (mutable_iterator
I = Vector.begin(), E = Vector.end();
I != E; ++
I)
112 bool isSmall()
const {
return Set.empty(); }
114 VIterator vfind(
const T &V)
const {
115 for (VIterator
I = Vector.begin(), E = Vector.end();
I != E; ++
I)
124 template <
typename Po
inteeType,
unsigned N>
#define LLVM_ATTRIBUTE_UNUSED_RESULT
bool LLVM_ATTRIBUTE_UNUSED_RESULT 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...