20#ifndef LLVM_ADT_SETVECTOR_H
21#define LLVM_ADT_SETVECTOR_H
57template <
typename T,
typename Vector = SmallVector<T, 0>,
58 typename Set = DenseSet<T>,
unsigned N = 0>
62 static_assert(
N <= 32,
"Small size should be less than or equal to 32!");
86 template <
typename Range>
95 return std::move(vector_);
99 [[nodiscard]]
bool empty()
const {
return vector_.empty(); }
121 return vector_.rbegin();
132 assert(!
empty() &&
"Cannot call front() on empty SetVector!");
133 return vector_.front();
138 assert(!
empty() &&
"Cannot call back() on empty SetVector!");
139 return vector_.back();
144 assert(n < vector_.size() &&
"SetVector access out of range!");
151 if constexpr (canBeSmall())
154 vector_.push_back(
X);
155 if (vector_.size() >
N)
162 bool result = set_.insert(
X).second;
164 vector_.push_back(
X);
169 template<
typename It>
171 for (; Start != End; ++Start)
181 if constexpr (canBeSmall())
184 if (
I != vector_.end()) {
193 assert(
I != vector_.end() &&
"Corrupted SetVector instances!");
205 if constexpr (canBeSmall())
207 return vector_.erase(
I);
210 assert(set_.count(V) &&
"Corrupted SetVector instances!");
212 return vector_.erase(
I);
228 template <
typename UnaryPredicate>
231 if constexpr (canBeSmall())
244 if (
I == vector_.end())
246 vector_.erase(
I, vector_.end());
252 if constexpr (canBeSmall())
256 return set_.find(key) != set_.end();
273 assert(!
empty() &&
"Cannot remove an element from an empty SetVector!");
285 return vector_ == that.vector_;
289 return vector_ != that.vector_;
299 for (
const auto &Elem : S)
311 for (
const auto &Elem : S)
317 vector_.swap(
RHS.vector_);
321 [[nodiscard]]
static constexpr bool canBeSmall() {
return N != 0; }
323 [[nodiscard]]
bool isSmall()
const {
return set_.empty(); }
326 if constexpr (canBeSmall())
327 for (
const auto &entry : vector_)
337template <
typename T,
unsigned N>
348template <
typename T,
typename V,
typename S,
unsigned N>
355template<
typename T,
unsigned N>
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
This file defines the DenseSet and SmallDenseSet classes.
ConstantRange Range(APInt(BitWidth, Low), APInt(BitWidth, High))
This file contains library features backported from future STL versions.
This file defines the SmallVector class.
static TableGen::Emitter::OptClass< SkeletonEmitter > X("gen-skeleton-class", "Generate example skeleton class")
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Implements a dense probed hash-table based set.
A vector that has set insertion semantics.
const_reverse_iterator rend() const
Get a const_reverse_iterator to the beginning of the SetVector.
ArrayRef< value_type > getArrayRef() const
typename vector_type::const_reverse_iterator reverse_iterator
iterator erase(const_iterator I)
Erase a single element from the set vector.
bool remove(const value_type &X)
Remove an item from the set vector.
bool remove_if(UnaryPredicate P)
Remove items from the set vector based on a predicate function.
size_type size() const
Determine the number of elements in the SetVector.
const value_type & front() const
Return the first element of the SetVector.
bool operator==(const SetVector &that) const
typename vector_type::const_reverse_iterator const_reverse_iterator
SmallVector< EdgeType *, 0 > vector_type
const value_type & back() const
Return the last element of the SetVector.
void insert_range(Range &&R)
bool set_union(const STy &S)
Compute This := This u S, return whether 'This' changed.
typename SmallVector< EdgeType *, 0 >::value_type value_type
const_reverse_iterator rbegin() const
Get a const_reverse_iterator to the end of the SetVector.
Vector takeVector()
Clear the SetVector and return the underlying vector.
typename vector_type::const_iterator iterator
DenseSet< EdgeType * > set_type
iterator end()
Get an iterator to the end of the SetVector.
SetVector()=default
Construct an empty SetVector.
SetVector(llvm::from_range_t, Range &&R)
reverse_iterator rbegin()
Get an reverse_iterator to the end of the SetVector.
typename vector_type::const_iterator const_iterator
const_iterator end() const
Get a const_iterator to the end of the SetVector.
void clear()
Completely clear the SetVector.
bool operator!=(const SetVector &that) const
reverse_iterator rend()
Get a reverse_iterator to the beginning of the SetVector.
typename vector_type::size_type size_type
const_iterator begin() const
Get a const_iterator to the beginning of the SetVector.
size_type count(const key_type &key) const
Count the number of elements of a given key in the SetVector.
bool empty() const
Determine if the SetVector is empty or not.
void insert(It Start, It End)
Insert a range of elements into the SetVector.
const value_type & const_reference
iterator begin()
Get an iterator to the beginning of the SetVector.
SetVector(It Start, It End)
Initialize a SetVector with a range of elements.
void swap(SetVector< T, Vector, Set, N > &RHS)
typename DenseSet< EdgeType * >::key_type key_type
void set_subtract(const STy &S)
Compute This := This - B TODO: We should be able to use set_subtract from SetOperations....
bool insert(const value_type &X)
Insert a new element into the SetVector.
void pop_back()
Remove the last element of the SetVector.
value_type pop_back_val()
const_reference operator[](size_type n) const
Index into the SetVector.
bool contains(const key_type &key) const
Check if the SetVector contains the given key.
A SetVector that performs no allocations if smaller than a certain size.
std::reverse_iterator< const_iterator > const_reverse_iterator
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
This is an optimization pass for GlobalISel generic memory operations.
auto find(R &&Range, const T &Val)
Provide wrappers to std::find which take ranges instead of having to pass begin/end explicitly.
constexpr auto adl_begin(RangeT &&range) -> decltype(adl_detail::begin_impl(std::forward< RangeT >(range)))
Returns the begin iterator to range using std::begin and function found through Argument-Dependent Lo...
constexpr auto adl_end(RangeT &&range) -> decltype(adl_detail::end_impl(std::forward< RangeT >(range)))
Returns the end iterator to range using std::end and functions found through Argument-Dependent Looku...
auto remove_if(R &&Range, UnaryPredicate P)
Provide wrappers to std::remove_if which take ranges instead of having to pass begin/end explicitly.
bool is_contained(R &&Range, const E &Element)
Returns true if Element is found in Range.
Implement std::hash so that hash_code can be used in STL containers.
void swap(llvm::BitVector &LHS, llvm::BitVector &RHS)
Implement std::swap in terms of BitVector swap.