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(); }
107 vector_.reserve(
Size);
128 return vector_.rbegin();
139 assert(!
empty() &&
"Cannot call front() on empty SetVector!");
140 return vector_.front();
145 assert(!
empty() &&
"Cannot call back() on empty SetVector!");
146 return vector_.back();
151 assert(n < vector_.size() &&
"SetVector access out of range!");
158 if constexpr (canBeSmall())
161 vector_.push_back(
X);
162 if (vector_.size() >
N)
169 bool result = set_.insert(
X).second;
171 vector_.push_back(
X);
176 template<
typename It>
178 for (; Start !=
End; ++Start)
188 if constexpr (canBeSmall())
191 if (
I != vector_.end()) {
200 assert(
I != vector_.end() &&
"Corrupted SetVector instances!");
212 if constexpr (canBeSmall())
214 return vector_.erase(
I);
217 assert(set_.count(
V) &&
"Corrupted SetVector instances!");
219 return vector_.erase(
I);
235 template <
typename UnaryPredicate>
238 if constexpr (canBeSmall())
251 if (
I == vector_.end())
253 vector_.erase(
I, vector_.end());
258 [[nodiscard]]
bool contains(const_arg_type key)
const {
259 if constexpr (canBeSmall())
280 assert(!
empty() &&
"Cannot remove an element from an empty SetVector!");
292 return vector_ == that.vector_;
296 return vector_ != that.vector_;
306 for (
const auto &Elem : S)
318 for (
const auto &Elem : S)
324 vector_.swap(
RHS.vector_);
328 [[nodiscard]]
static constexpr bool canBeSmall() {
return N != 0; }
330 [[nodiscard]]
bool isSmall()
const {
return set_.empty(); }
333 if constexpr (canBeSmall())
334 for (
const auto &entry : vector_)
344template <
typename T,
unsigned N>
346 :
public SetVector<T, SmallVector<T, N>, DenseSet<T>, N> {
356template <
typename T,
typename V,
typename S,
unsigned N>
363template<
typename T,
unsigned N>
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
#define LLVM_ATTRIBUTE_WARN_UNUSED
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.
static bool contains(SmallPtrSetImpl< ConstantExpr * > &Cache, ConstantExpr *Expr, Constant *C)
This file defines the SmallVector class.
static const BasicSubtargetSubTypeKV * find(StringRef S, ArrayRef< BasicSubtargetSubTypeKV > A)
Find KV in array using binary search.
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
void reserve(size_type Size)
Reserve space in the SetVector if supported by the underlying containers.
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)
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.
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.
@ End
Run the machine verifier once, at the end of the pipeline.
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