14#ifndef LLVM_ADT_DENSESET_H
15#define LLVM_ADT_DENSESET_H
24#include <initializer_list>
55template <
typename ValueT,
typename MapTy,
typename ValueInfoT>
57 static_assert(
sizeof(
typename MapTy::value_type) ==
sizeof(
ValueT),
58 "DenseMap buckets unexpectedly large!");
69 explicit DenseSetImpl(
unsigned InitialReserve = 0) : TheMap(InitialReserve) {}
71 template <
typename InputIt>
79 insert(Elems.begin(), Elems.end());
82 template <
typename Range>
86 bool empty()
const {
return TheMap.empty(); }
98 void clear() { TheMap.clear(); }
105 template <
bool IsConst>
class DenseSetIterator {
109 std::conditional_t<IsConst,
typename MapTy::const_iterator,
110 typename MapTy::iterator>;
115 using difference_type =
typename MapIteratorT::difference_type;
116 using iterator_category = std::forward_iterator_tag;
117 using value_type =
ValueT;
119 std::conditional_t<IsConst, const value_type *, value_type *>;
121 std::conditional_t<IsConst, const value_type &, value_type &>;
123 DenseSetIterator() =
default;
124 DenseSetIterator(MapIteratorT
I) :
I(
I) {}
127 template <
bool C = IsConst,
typename = std::enable_if_t<C>>
128 DenseSetIterator(
const DenseSetIterator<false> &
Other) :
I(
Other.
I) {}
130 reference operator*()
const {
return I->getFirst(); }
131 pointer operator->()
const {
return &I->getFirst(); }
133 DenseSetIterator &operator++() {
137 DenseSetIterator operator++(
int) {
144 const DenseSetIterator &
RHS) {
147 friend bool operator!=(
const DenseSetIterator &
LHS,
148 const DenseSetIterator &
RHS) {
169 [[nodiscard]]
bool contains(const_arg_type_t<ValueT> V)
const {
170 return TheMap.contains(V);
175 return TheMap.count(V);
184 return iterator(TheMap.find_as(Val));
186 template <
class LookupKeyT>
195 return TheMap.try_emplace(V);
199 return TheMap.try_emplace(std::move(V));
204 template <
typename LookupKeyT>
206 const LookupKeyT &LookupKey) {
209 template <
typename LookupKeyT>
215 template <
typename InputIt>
void insert(InputIt
I, InputIt
E) {
231template <
typename ValueT,
typename MapTy,
typename ValueInfoT>
234 if (
LHS.size() !=
RHS.size())
247template <
typename ValueT,
typename MapTy,
typename ValueInfoT>
256template <
typename ValueT,
typename ValueInfoT = DenseMapInfo<ValueT>>
259 DenseMap<ValueT, detail::DenseSetEmpty, ValueInfoT,
260 detail::DenseSetPair<ValueT>>,
274template <
typename ValueT,
unsigned InlineBuckets = 4,
279 SmallDenseMap<ValueT, detail::DenseSetEmpty, InlineBuckets,
280 ValueInfoT, detail::DenseSetPair<ValueT>>,
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
This file defines DenseMapInfo traits for DenseMap.
This file defines the DenseMap class.
bool operator==(const MergedFunctionsInfo &LHS, const MergedFunctionsInfo &RHS)
ConstantRange Range(APInt(BitWidth, Low), APInt(BitWidth, High))
This file contains library features backported from future STL versions.
Implements a dense probed hash-table based set.
Implements a dense probed hash-table based set with some number of buckets stored inline.
Base class for DenseSet and DenseSmallSet.
const_iterator find(const_arg_type_t< ValueT > V) const
std::pair< iterator, bool > insert(ValueT &&V)
DenseSetImpl(llvm::from_range_t, Range &&R)
std::pair< iterator, bool > insert(const ValueT &V)
size_t getMemorySize() const
DenseSetIterator< false > iterator
const_iterator end() const
const_iterator begin() const
iterator find(const_arg_type_t< ValueT > V)
std::pair< iterator, bool > insert_as(const ValueT &V, const LookupKeyT &LookupKey)
Alternative version of insert that uses a different (and possibly less expensive) key type.
void reserve(size_t Size)
Grow the DenseSet so that it can contain at least NumEntries items before resizing again.
iterator find_as(const LookupKeyT &Val)
Alternative version of find() which allows a different, and possibly less expensive,...
void insert_range(Range &&R)
const_iterator find_as(const LookupKeyT &Val) const
std::pair< iterator, bool > insert_as(ValueT &&V, const LookupKeyT &LookupKey)
void insert(InputIt I, InputIt E)
void swap(DenseSetImpl &RHS)
DenseSetImpl(unsigned InitialReserve=0)
bool contains(const_arg_type_t< ValueT > V) const
Check if the set contains the given element.
DenseSetImpl(const InputIt &I, const InputIt &E)
void resize(size_t Size)
Grow the DenseSet so that it has at least Size buckets.
DenseSetIterator< true > const_iterator
bool erase(const ValueT &V)
DenseSetImpl(std::initializer_list< ValueT > Elems)
void erase(const_iterator CI)
size_type count(const_arg_type_t< ValueT > V) const
Return 1 if the specified key is in the set, 0 otherwise.
const DenseSetEmpty & getSecond() const
const KeyT & getFirst() const
DenseSetEmpty & getSecond()
These are wrappers over isa* function that allow them to be used in generic algorithms such as llvm:a...
bool operator!=(const DenseSetImpl< ValueT, MapTy, ValueInfoT > &LHS, const DenseSetImpl< ValueT, MapTy, ValueInfoT > &RHS)
Inequality comparison for DenseSet.
bool operator==(const DenseSetImpl< ValueT, MapTy, ValueInfoT > &LHS, const DenseSetImpl< ValueT, MapTy, ValueInfoT > &RHS)
Equality comparison for DenseSet.
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...
uint64_t PowerOf2Ceil(uint64_t A)
Returns the power of two which is greater than or equal to the given value.
Implement std::hash so that hash_code can be used in STL containers.
An information struct used to provide DenseMap with the various necessary components for a given valu...
std::conditional_t< std::is_pointer_v< T >, typename add_const_past_pointer< T >::type, const T & > type