15 #ifndef LLVM_ADT_SMALLPTRSET_H
16 #define LLVM_ADT_SMALLPTRSET_H
19 #include "llvm/Support/DataTypes.h"
29 class SmallPtrSetIteratorImpl;
70 assert(SmallSize && (SmallSize & (SmallSize-1)) == 0 &&
71 "Initial size must be a power of two!");
85 return shrink_and_clear();
98 return reinterpret_cast<void*
>(-1);
104 std::pair<const void *const *, bool>
insert_imp(
const void *Ptr);
123 return *FindBucketFor(Ptr) == Ptr;
129 const void *
const *FindBucketFor(
const void *Ptr)
const;
130 void shrink_and_clear();
133 void Grow(
unsigned NewSize);
178 template<
typename PtrTy>
196 return PtrTraits::getFromVoidPointer(const_cast<void*>(*
Bucket));
217 template<
unsigned N,
bool isPowerTwo>
231 struct RoundUpToPowerOfTwo {
241 template <
typename PtrType>
264 std::pair<iterator, bool>
insert(PtrType Ptr) {
265 auto p =
insert_imp(PtrTraits::getAsVoidPointer(Ptr));
272 return erase_imp(PtrTraits::getAsVoidPointer(Ptr));
277 return count_imp(PtrTraits::getAsVoidPointer(Ptr)) ? 1 : 0;
280 template <
typename IterT>
298 template<
class PtrType,
unsigned SmallSize>
305 const void *SmallStorage[SmallSizePowTwo];
310 :
BaseT(SmallStorage, SmallSizePowTwo, std::move(that)) {}
312 template<
typename It>
327 this->
MoveFrom(SmallSizePowTwo, std::move(RHS));
341 template<
class T,
unsigned N>
static void * getTombstoneMarker()
SmallPtrSetImpl(const void **SmallStorage, unsigned SmallSize, SmallPtrSetImpl &&that)
bool count_imp(const void *Ptr) const
#define LLVM_ATTRIBUTE_UNUSED_RESULT
bool LLVM_ATTRIBUTE_UNUSED_RESULT empty() const
SmallPtrSet(const SmallPtrSet &that)
SmallPtrSetImpl(const void **SmallStorage, const SmallPtrSetImpl &that)
SmallPtrSetIterator< PtrType > const_iterator
std::ptrdiff_t difference_type
size_type count(PtrType Ptr) const
count - Return 1 if the specified pointer is in the set, 0 otherwise.
void MoveFrom(unsigned SmallSize, SmallPtrSetImplBase &&RHS)
PointerLikeTypeTraits - This is a traits object that is used to handle pointer types and things that ...
A templated base class for SmallPtrSet which provides the typesafe interface that is common across al...
SmallPtrSetIterator & operator++()
SmallPtrSetIteratorImpl - This is the common base class shared between all instances of SmallPtrSetIt...
void swap(SmallPtrSetImplBase &RHS)
swap - Swaps the elements of two sets.
SmallPtrSet(SmallPtrSet &&that)
unsigned CurArraySize
CurArraySize - The allocated size of CurArray, always a power of two.
SmallPtrSetIterator(const void *const *BP, const void *const *E)
const void ** CurArray
CurArray - This is the current set of buckets.
RoundUpToPowerOfTwo - This is a helper template that rounds N up to the next power of two (which mean...
bool operator!=(const SmallPtrSetIteratorImpl &RHS) const
SmallPtrSet< PtrType, SmallSize > & operator=(const SmallPtrSet< PtrType, SmallSize > &RHS)
static void * getEmptyMarker()
void AdvanceIfNotValid()
AdvanceIfNotValid - If the current bucket isn't valid, advance to a bucket that is.
void CopyFrom(const SmallPtrSetImplBase &RHS)
CopyFrom - implement operator= from a smallptrset that has the same pointer type, but may have a diff...
void insert(IterT I, IterT E)
SmallPtrSet< PtrType, SmallSize > & operator=(SmallPtrSet< PtrType, SmallSize > &&RHS)
const PtrTy operator*() const
SmallPtrSetIterator operator++(int)
std::pair< iterator, bool > insert(PtrType Ptr)
Inserts Ptr if and only if there is no element in the container equal to Ptr.
SmallPtrSetImpl(const void **SmallStorage, unsigned SmallSize)
const void *const * Bucket
bool operator==(const SmallPtrSetIteratorImpl &RHS) const
SmallPtrSetIterator - This implements a const_iterator for SmallPtrSet.
bool erase_imp(const void *Ptr)
erase_imp - If the set contains the specified pointer, remove it and return true, otherwise return fa...
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements...
bool erase(PtrType Ptr)
erase - If the set contains the specified pointer, remove it and return true, otherwise return false...
const void ** SmallArray
SmallArray - Points to a fixed size set of buckets, used in 'small mode'.
SmallPtrSetImplBase(const void **SmallStorage, unsigned SmallSize)
SmallPtrSetIterator< PtrType > iterator
SmallPtrSetImplBase(const void **SmallStorage, const SmallPtrSetImplBase &that)
void swap(llvm::BitVector &LHS, llvm::BitVector &RHS)
Implement std::swap in terms of BitVector swap.
RoundUpToPowerOfTwoH - If N is not a power of two, increase it.
SmallPtrSetImplBase - This is the common code shared among all the SmallPtrSet<>'s, which is almost everything.
std::pair< const void *const *, bool > insert_imp(const void *Ptr)
insert_imp - This returns true if the pointer was new to the set, false if it was already in the set...
SmallPtrSetIteratorImpl(const void *const *BP, const void *const *E)
void swap(SmallPtrSet< PtrType, SmallSize > &RHS)
swap - Swaps the elements of two sets.
std::forward_iterator_tag iterator_category