20 #ifndef LLVM_ADT_SETVECTOR_H
21 #define LLVM_ADT_SETVECTOR_H
35 template <
typename T,
typename Vector = std::vector<T>,
36 typename Set = SmallSet<T, 16> >
45 typedef typename vector_type::const_iterator
iterator;
60 return vector_.empty();
65 return vector_.size();
70 return vector_.begin();
75 return vector_.begin();
90 assert(!
empty() &&
"Cannot call back() on empty SetVector!");
91 return vector_.back();
96 assert(n < vector_.size() &&
"SetVector access out of range!");
103 bool result = set_.insert(X);
105 vector_.push_back(X);
110 template<
typename It>
112 for (; Start != End; ++Start)
113 if (set_.insert(*Start))
114 vector_.push_back(*Start);
120 typename vector_type::iterator
I =
121 std::find(vector_.begin(), vector_.end(),
X);
122 assert(I != vector_.end() &&
"Corrupted SetVector instances!");
142 template <
typename UnaryPredicate>
144 typename vector_type::iterator
I
145 = std::remove_if(vector_.begin(), vector_.end(),
146 TestAndEraseFromSet<UnaryPredicate>(
P, set_));
147 if (I == vector_.end())
149 vector_.erase(I, vector_.end());
157 return set_.count(key);
168 assert(!
empty() &&
"Cannot remove an element from an empty SetVector!");
180 return vector_ == that.vector_;
184 return vector_ != that.vector_;
192 template <
typename UnaryPredicate>
193 class TestAndEraseFromSet {
198 typedef typename UnaryPredicate::argument_type argument_type;
200 TestAndEraseFromSet(UnaryPredicate
P,
set_type &set_) : P(P), set_(set_) {}
202 bool operator()(argument_type Arg) {
217 template <
typename T,
unsigned N>
223 template<
typename It>
const_iterator end() const
Get a const_iterator to the end of the SetVector.
#define LLVM_ATTRIBUTE_UNUSED_RESULT
SetVector()
Construct an empty SetVector.
vector_type::const_iterator const_iterator
iterator end()
Get an iterator to the end of the SetVector.
vector_type::size_type size_type
size_type size() const
Determine the number of elements in the SetVector.
const_iterator begin() const
Get a const_iterator to the beginning of the SetVector.
const_reference operator[](size_type n) const
Index into the SetVector.
void pop_back()
Remove the last element of the SetVector.
bool operator==(const SetVector &that) const
bool insert(const value_type &X)
Insert a new element into the SetVector.
iterator begin()
Get an iterator to the beginning of the SetVector.
bool empty() const
Determine if the SetVector is empty or not.
T LLVM_ATTRIBUTE_UNUSED_RESULT pop_back_val()
LLVM Basic Block Representation.
void insert(It Start, It End)
Insert a range of elements into the SetVector.
SetVector(It Start, It End)
Initialize a SetVector with a range of elements.
A SetVector that performs no allocations if smaller than a certain size.
bool operator!=(const SetVector &that) const
void clear()
Completely clear the SetVector.
size_type count(const key_type &key) const
Count the number of elements of a given key in the SetVector.
const T & back() const
Return the last element of the SetVector.
const T & const_reference
SmallSetVector(It Start, It End)
Initialize a SmallSetVector with a range of elements.
vector_type::const_iterator iterator
A vector that has set insertion semantics.
bool remove_if(UnaryPredicate P)
Remove items from the set vector based on a predicate function.
static RegisterPass< NVPTXAllocaHoisting > X("alloca-hoisting","Hoisting alloca instructions in non-entry ""blocks to the entry block")