14 #ifndef LLVM_ADT_DENSESET_H
15 #define LLVM_ADT_DENSESET_H
18 #include <initializer_list>
46 template <
typename ValueT,
typename MapTy,
typename ValueInfoT>
48 static_assert(
sizeof(
typename MapTy::value_type) ==
sizeof(
ValueT),
49 "DenseMap buckets unexpectedly large!");
57 explicit DenseSetImpl(
unsigned InitialReserve = 0) : TheMap(InitialReserve) {}
61 insert(Elems.begin(), Elems.end());
64 bool empty()
const {
return TheMap.empty(); }
70 void resize(
size_t Size) { TheMap.resize(Size); }
74 void reserve(
size_t Size) { TheMap.reserve(Size); }
82 return TheMap.count(V);
86 return TheMap.erase(V);
94 typename MapTy::iterator I;
116 typename MapTy::const_iterator I;
148 return ConstIterator(TheMap.find(V));
156 template <
class LookupKeyT>
158 return Iterator(TheMap.find_as(Val));
160 template <
class LookupKeyT>
162 return ConstIterator(TheMap.find_as(Val));
165 void erase(Iterator
I) {
return TheMap.erase(I.I); }
166 void erase(ConstIterator CI) {
return TheMap.erase(CI.I); }
170 return TheMap.try_emplace(V, Empty);
175 return TheMap.try_emplace(std::move(V), Empty);
180 template <
typename LookupKeyT>
182 const LookupKeyT &LookupKey) {
185 template <
typename LookupKeyT>
191 template<
typename InputIt>
201 template <
typename ValueT,
typename ValueInfoT = DenseMapInfo<ValueT>>
203 ValueT, DenseMap<ValueT, detail::DenseSetEmpty, ValueInfoT,
204 detail::DenseSetPair<ValueT>>,
218 template <
typename ValueT,
unsigned InlineBuckets = 4,
222 ValueT, SmallDenseMap<ValueT, detail::DenseSetEmpty, InlineBuckets,
223 ValueInfoT, detail::DenseSetPair<ValueT>>,
size_t getMemorySize() const
const DenseSetEmpty & getSecond() const
iterator find(const ValueT &V)
Implements a dense probed hash-table based set.
ConstIterator & operator++()
const_iterator find_as(const LookupKeyT &Val) const
bool erase(const ValueT &V)
ConstIterator operator++(int)
std::pair< iterator, bool > insert_as(ValueT &&V, const LookupKeyT &LookupKey)
std::forward_iterator_tag iterator_category
ConstIterator const_iterator
DenseSetEmpty & getSecond()
MapTy::iterator::difference_type difference_type
Iterator(const typename MapTy::iterator &i)
bool operator==(const Iterator &X) const
static GCRegistry::Add< CoreCLRGC > E("coreclr","CoreCLR-compatible GC")
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...
const ValueT & operator*()
std::pair< iterator, bool > insert(const ValueT &V)
iterator find_as(const LookupKeyT &Val)
Alternative version of find() which allows a different, and possibly less expensive, key type.
static GCMetadataPrinterRegistry::Add< ErlangGCPrinter > X("erlang","erlang-compatible garbage collector")
std::pair< iterator, bool > insert(ValueT &&V)
void insert(InputIt I, InputIt E)
void swap(DenseSetImpl &RHS)
bool operator!=(const ConstIterator &X) const
std::forward_iterator_tag iterator_category
const_iterator end() const
MapTy::const_iterator::difference_type difference_type
DenseSetImpl(std::initializer_list< ValueT > Elems)
DenseSetImpl(unsigned InitialReserve=0)
const ValueT * operator->()
const_iterator find(const ValueT &V) const
const KeyT & getFirst() const
const_iterator begin() const
Implements a dense probed hash-table based set with some number of buckets stored inline...
void erase(ConstIterator CI)
void resize(size_t Size)
Grow the DenseSet so that it has at least Size buckets.
ConstIterator(const typename MapTy::const_iterator &i)
bool operator!=(const Iterator &X) const
size_type count(const ValueT &V) const
Return 1 if the specified key is in the set, 0 otherwise.
void reserve(size_t Size)
Grow the DenseSet so that it can contain at least NumEntries items before resizing again...
bool operator==(const ConstIterator &X) const
Base class for DenseSet and DenseSmallSet.