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) {
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>
196 return TheMap.try_emplace(V, Empty);
201 return TheMap.try_emplace(std::move(V), Empty);
206 template <
typename LookupKeyT>
208 const LookupKeyT &LookupKey) {
211 template <
typename LookupKeyT>
217 template <
typename InputIt>
void insert(InputIt
I, InputIt
E) {
233template <
typename ValueT,
typename MapTy,
typename ValueInfoT>
236 if (
LHS.size() !=
RHS.size())
249template <
typename ValueT,
typename MapTy,
typename ValueInfoT>
258template <
typename ValueT,
typename ValueInfoT = DenseMapInfo<ValueT>>
261 DenseMap<ValueT, detail::DenseSetEmpty, ValueInfoT,
262 detail::DenseSetPair<ValueT>>,
276template <
typename ValueT,
unsigned InlineBuckets = 4,
281 SmallDenseMap<ValueT, detail::DenseSetEmpty, InlineBuckets,
282 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.
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()
bool operator!=(const DenseSetImpl< ValueT, MapTy, ValueInfoT > &LHS, const DenseSetImpl< ValueT, MapTy, ValueInfoT > &RHS)
Inequality 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...
bool operator!=(uint64_t V1, const APInt &V2)
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...
bool operator==(const AddressRangeValuePair &LHS, const AddressRangeValuePair &RHS)
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...