20#ifndef LLVM_ADT_SETVECTOR_H
21#define LLVM_ADT_SETVECTOR_H
55template <
typename T,
typename Vector = SmallVector<T, 0>,
56 typename Set = DenseSet<T>,
unsigned N = 0>
60 static_assert(
N <= 32,
"Small size should be less than or equal to 32!");
62 using const_arg_type =
87 template <
typename Range>
96 return std::move(vector_);
100 [[nodiscard]]
bool empty()
const {
return vector_.empty(); }
122 return vector_.rbegin();
133 assert(!
empty() &&
"Cannot call front() on empty SetVector!");
134 return vector_.front();
139 assert(!
empty() &&
"Cannot call back() on empty SetVector!");
140 return vector_.back();
145 assert(n < vector_.size() &&
"SetVector access out of range!");
152 if constexpr (canBeSmall())
155 vector_.push_back(
X);
156 if (vector_.size() >
N)
163 bool result = set_.insert(
X).second;
165 vector_.push_back(
X);
170 template<
typename It>
172 for (; Start != End; ++Start)
182 if constexpr (canBeSmall())
185 if (
I != vector_.end()) {
194 assert(
I != vector_.end() &&
"Corrupted SetVector instances!");
206 if constexpr (canBeSmall())
208 return vector_.erase(
I);
211 assert(set_.count(V) &&
"Corrupted SetVector instances!");
213 return vector_.erase(
I);
229 template <
typename UnaryPredicate>
232 if constexpr (canBeSmall())
245 if (
I == vector_.end())
247 vector_.erase(
I, vector_.end());
252 [[nodiscard]]
bool contains(const_arg_type key)
const {
253 if constexpr (canBeSmall())
274 assert(!
empty() &&
"Cannot remove an element from an empty SetVector!");
286 return vector_ == that.vector_;
290 return vector_ != that.vector_;
300 for (
const auto &Elem : S)
312 for (
const auto &Elem : S)
318 vector_.swap(
RHS.vector_);
322 [[nodiscard]]
static constexpr bool canBeSmall() {
return N != 0; }
324 [[nodiscard]]
bool isSmall()
const {
return set_.empty(); }
327 if constexpr (canBeSmall())
328 for (
const auto &entry : vector_)
338template <
typename T,
unsigned N>
349template <
typename T,
typename V,
typename S,
unsigned N>
356template<
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.
size_type count(const_arg_type key) const
Count the number of elements of a given key in 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.
bool contains(const_arg_type key) const
Check if the SetVector contains the given key.
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.
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.
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.
std::conditional_t< std::is_pointer_v< T >, typename add_const_past_pointer< T >::type, const T & > type