20 #ifndef LLVM_ADT_SETVECTOR_H
21 #define LLVM_ADT_SETVECTOR_H
39 template <
typename T,
typename Vector = std::vector<T>,
40 typename Set = DenseSet<T>>
69 return std::move(vector_);
74 return vector_.empty();
79 return vector_.size();
84 return vector_.begin();
89 return vector_.begin();
104 return vector_.rbegin();
109 return vector_.rbegin();
114 return vector_.rend();
119 return vector_.rend();
124 assert(!
empty() &&
"Cannot call back() on empty SetVector!");
125 return vector_.back();
130 assert(n < vector_.size() &&
"SetVector access out of range!");
137 bool result = set_.insert(X).second;
139 vector_.push_back(X);
144 template<
typename It>
146 for (; Start !=
End; ++Start)
147 if (set_.insert(*Start).second)
148 vector_.push_back(*Start);
155 assert(I != vector_.end() &&
"Corrupted SetVector instances!");
168 assert(set_.count(V) &&
"Corrupted SetVector instances!");
174 auto NI = vector_.begin();
177 return vector_.erase(NI);
193 template <
typename UnaryPredicate>
196 llvm::remove_if(vector_, TestAndEraseFromSet<UnaryPredicate>(P, set_));
197 if (I == vector_.end())
199 vector_.erase(I, vector_.end());
206 return set_.count(key);
217 assert(!
empty() &&
"Cannot remove an element from an empty SetVector!");
229 return vector_ == that.vector_;
233 return vector_ != that.vector_;
241 bool Changed =
false;
243 for (
typename STy::const_iterator
SI = S.begin(), SE = S.end();
SI != SE;
256 for (
typename STy::const_iterator
SI = S.begin(), SE = S.end();
SI != SE;
266 template <
typename UnaryPredicate>
267 class TestAndEraseFromSet {
272 TestAndEraseFromSet(UnaryPredicate
P,
set_type &set_)
273 : P(std::move(P)), set_(set_) {}
275 template <
typename ArgumentT>
276 bool operator()(
const ArgumentT &Arg) {
291 template <
typename T,
unsigned N>
293 :
public SetVector<T, SmallVector<T, N>, SmallDenseSet<T, N>> {
298 template<
typename It>
306 #endif // LLVM_ADT_SETVECTOR_H
const_iterator end() const
Get a const_iterator to the end of the SetVector.
LLVM_NODISCARD T pop_back_val()
auto remove_if(R &&Range, UnaryPredicate P) -> decltype(std::begin(Range))
Provide wrappers to std::remove_if which take ranges instead of having to pass begin/end explicitly...
const_reverse_iterator rbegin() const
Get a const_reverse_iterator to the end of the SetVector.
iterator erase(iterator I)
Erase a single element from the set vector.
vector_type::const_iterator const_iterator
iterator end()
Get an iterator to the end of the SetVector.
SetVector()=default
Construct an empty 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.
static void advance(T &it, size_t Val)
reverse_iterator rbegin()
Get an reverse_iterator to the end of 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.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
This is an important base class in LLVM.
bool set_union(const STy &S)
Compute This := This u S, return whether 'This' changed.
static GCMetadataPrinterRegistry::Add< ErlangGCPrinter > X("erlang","erlang-compatible garbage collector")
static const unsigned End
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.
Vector takeVector()
Clear the SetVector and return the underlying vector.
auto find(R &&Range, const T &Val) -> decltype(std::begin(Range))
Provide wrappers to std::find which take ranges instead of having to pass begin/end explicitly...
std::reverse_iterator< const_iterator > const_reverse_iterator
void set_subtract(const STy &S)
Compute This := This - B TODO: We should be able to use set_subtract from SetOperations.h, but SetVector interface is inconsistent with DenseSet.
const_reverse_iterator rend() const
Get a const_reverse_iterator to the beginning of the SetVector.
bool operator!=(const SetVector &that) const
void clear()
Completely clear the SetVector.
SuperClass::size_type size_type
size_type count(const key_type &key) const
Count the number of elements of a given key in the SetVector.
reverse_iterator rend()
Get a reverse_iterator to the beginning of the SetVector.
vector_type::const_reverse_iterator reverse_iterator
const T & back() const
Return the last element of the SetVector.
#define LLVM_NODISCARD
LLVM_NODISCARD - Warn if a type or return value is discarded.
vector_type::const_reverse_iterator const_reverse_iterator
const T & const_reference
ArrayRef< T > getArrayRef() const
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
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.