14#ifndef LLVM_ADT_DENSESET_H
15#define LLVM_ADT_DENSESET_H
24#include <initializer_list>
55 static_assert(
sizeof(
typename MapTy::value_type) ==
sizeof(ValueT),
56 "DenseMap buckets unexpectedly large!");
67 explicit DenseSetImpl(
unsigned InitialReserve = 0) : TheMap(InitialReserve) {}
69 template <
typename InputIt>
77 insert(Elems.begin(), Elems.end());
80 template <
typename Range>
84 [[nodiscard]]
bool empty()
const {
return TheMap.empty(); }
86 [[nodiscard]]
size_t getMemorySize()
const {
return TheMap.getMemorySize(); }
96 void clear() { TheMap.clear(); }
98 bool erase(
const ValueT &
V) {
return TheMap.erase(
V); }
105 return TheMap.remove_if([&](
const typename MapTy::value_type &KV) {
106 return Pred(KV.getFirst());
113 template <
bool IsConst>
class DenseSetIterator {
117 std::conditional_t<IsConst,
typename MapTy::const_iterator,
118 typename MapTy::iterator>;
123 using difference_type =
typename MapIteratorT::difference_type;
124 using iterator_category = std::forward_iterator_tag;
127 std::conditional_t<IsConst, const value_type *, value_type *>;
129 std::conditional_t<IsConst, const value_type &, value_type &>;
131 DenseSetIterator() =
default;
132 DenseSetIterator(MapIteratorT
I) :
I(
I) {}
135 template <
bool C = IsConst,
typename = std::enable_if_t<C>>
136 DenseSetIterator(
const DenseSetIterator<false> &
Other) :
I(
Other.
I) {}
138 reference operator*()
const {
return I->getFirst(); }
139 pointer operator->()
const {
return &I->getFirst(); }
141 DenseSetIterator &operator++() {
145 DenseSetIterator operator++(
int) {
152 const DenseSetIterator &
RHS) {
155 friend bool operator!=(
const DenseSetIterator &
LHS,
156 const DenseSetIterator &
RHS) {
183 [[nodiscard]]
bool contains(const_arg_type_t<ValueT>
V)
const {
184 return TheMap.contains(
V);
189 return TheMap.count(
V);
197 template <
class LookupKeyT>
199 return iterator(TheMap.find_as(Val));
201 template <
class LookupKeyT>
210 std::pair<iterator, bool>
insert(
const ValueT &
V) {
211 return TheMap.try_emplace(
V);
214 std::pair<iterator, bool>
insert(ValueT &&
V) {
215 return TheMap.try_emplace(std::move(
V));
220 template <
typename LookupKeyT>
222 const LookupKeyT &LookupKey) {
225 template <
typename LookupKeyT>
226 std::pair<iterator, bool>
insert_as(ValueT &&
V,
const LookupKeyT &LookupKey) {
231 template <
typename InputIt>
void insert(InputIt
I, InputIt
E) {
247template <
typename ValueT,
typename MapTy>
250 if (
LHS.size() !=
RHS.size())
263template <
typename ValueT,
typename MapTy>
269template <
typename ValueT,
typename ValueInfoT>
273template <
typename ValueT,
unsigned InlineBuckets,
typename ValueInfoT>
281template <
typename ValueT,
typename ValueInfoT = DenseMapInfo<ValueT>>
292template <
typename ValueT,
unsigned InlineBuckets = 4,
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
#define LLVM_ATTRIBUTE_WARN_UNUSED
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.
std::pair< iterator, bool > insert(const ValueT &V)
bool contains(const_arg_type_t< ValueT > V) const
const_iterator begin() const
bool erase(const ValueT &V)
DenseSetImpl(llvm::from_range_t, Range &&R)
void insert_range(Range &&R)
size_t getMemorySize() const
void swap(DenseSetImpl &RHS)
DenseSetIterator< false > iterator
const_iterator find(const_arg_type_t< ValueT > V) const
std::pair< iterator, bool > insert_as(const ValueT &V, const LookupKeyT &LookupKey)
size_type count(const_arg_type_t< ValueT > V) const
const_iterator end() const
DenseSetImpl(unsigned InitialReserve=0)
void erase(const_iterator CI)
iterator find(const_arg_type_t< ValueT > V)
std::pair< iterator, bool > insert(ValueT &&V)
const_iterator find_as(const LookupKeyT &Val) const
DenseSetIterator< true > const_iterator
DenseSetImpl(const InputIt &I, const InputIt &E)
DenseSetImpl(std::initializer_list< ValueT > Elems)
bool remove_if(Predicate Pred)
std::pair< iterator, bool > insert_as(ValueT &&V, const LookupKeyT &LookupKey)
void reserve(size_t Size)
iterator find_as(const LookupKeyT &Val)
void insert(InputIt I, InputIt E)
const DenseSetEmpty & getSecond() const
const KeyT & getFirst() const
DenseSetEmpty & getSecond()
A self-contained host- and target-independent arbitrary-precision floating-point software implementat...
bool operator!=(const DenseSetImpl< ValueT, MapTy > &LHS, const DenseSetImpl< ValueT, MapTy > &RHS)
Inequality comparison for DenseSet.
DenseSetImpl< ValueT, SmallDenseMap< ValueT, DenseSetEmpty, InlineBuckets, ValueInfoT, DenseSetPair< ValueT > > > SmallDenseSet
bool operator==(const DenseSetImpl< ValueT, MapTy > &LHS, const DenseSetImpl< ValueT, MapTy > &RHS)
Equality comparison for DenseSet.
DenseSetImpl< ValueT, DenseMap< ValueT, DenseSetEmpty, ValueInfoT, DenseSetPair< ValueT > > > 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