WPILibC++ 2023.4.3
wpi::SmallPtrSetImplBase Class Reference

SmallPtrSetImplBase - This is the common code shared among all the SmallPtrSet<>'s, which is almost everything. More...

#include </home/runner/work/allwpilib/allwpilib/wpiutil/src/main/native/thirdparty/llvm/include/wpi/SmallPtrSet.h>

Inheritance diagram for wpi::SmallPtrSetImplBase:
wpi::DebugEpochBase wpi::SmallPtrSetImpl< PointeeType * > wpi::SmallPtrSetImpl< PtrType > wpi::SmallPtrSet< PointeeType *, N > wpi::SmallPtrSet< PtrType, SmallSize > wpi::SmallSet< PointeeType *, N >

Public Types

using size_type = unsigned
 

Public Member Functions

SmallPtrSetImplBaseoperator= (const SmallPtrSetImplBase &)=delete
 
LLVM_NODISCARD bool empty () const
 
size_type size () const
 
void clear ()
 
- Public Member Functions inherited from wpi::DebugEpochBase
 DebugEpochBase ()
 
void incrementEpoch ()
 Calling incrementEpoch invalidates all handles pointing into the calling instance. More...
 
 ~DebugEpochBase ()
 The destructor calls incrementEpoch to make use-after-free bugs more likely to crash deterministically. More...
 

Protected Member Functions

 SmallPtrSetImplBase (const void **SmallStorage, const SmallPtrSetImplBase &that)
 
 SmallPtrSetImplBase (const void **SmallStorage, unsigned SmallSize, SmallPtrSetImplBase &&that)
 
 SmallPtrSetImplBase (const void **SmallStorage, unsigned SmallSize)
 
 ~SmallPtrSetImplBase ()
 
const void ** EndPointer () const
 
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. More...
 
bool erase_imp (const void *Ptr)
 erase_imp - If the set contains the specified pointer, remove it and return true, otherwise return false. More...
 
const void *const * find_imp (const void *Ptr) const
 Returns the raw pointer needed to construct an iterator. More...
 
void swap (SmallPtrSetImplBase &RHS)
 swap - Swaps the elements of two sets. More...
 
void CopyFrom (const SmallPtrSetImplBase &RHS)
 
void MoveFrom (unsigned SmallSize, SmallPtrSetImplBase &&RHS)
 

Static Protected Member Functions

static void * getTombstoneMarker ()
 
static void * getEmptyMarker ()
 

Protected Attributes

const void ** SmallArray
 SmallArray - Points to a fixed size set of buckets, used in 'small mode'. More...
 
const void ** CurArray
 CurArray - This is the current set of buckets. More...
 
unsigned CurArraySize
 CurArraySize - The allocated size of CurArray, always a power of two. More...
 
unsigned NumNonEmpty
 Number of elements in CurArray that contain a value or are a tombstone. More...
 
unsigned NumTombstones
 Number of tombstones in CurArray. More...
 

Friends

class SmallPtrSetIteratorImpl
 

Detailed Description

SmallPtrSetImplBase - This is the common code shared among all the SmallPtrSet<>'s, which is almost everything.

SmallPtrSet has two modes, one for small and one for large sets.

Small sets use an array of pointers allocated in the SmallPtrSet object, which is treated as a simple array of pointers. When a pointer is added to the set, the array is scanned to see if the element already exists, if not the element is 'pushed back' onto the array. If we run out of space in the array, we grow into the 'large set' case. SmallSet should be used when the sets are often small. In this case, no memory allocation is used, and only light-weight and cache-efficient scanning is used.

Large sets use a classic exponentially-probed hash table. Empty buckets are represented with an illegal pointer value (-1) to allow null pointers to be inserted. Tombstones are represented with another illegal pointer value (-2), to allow deletion. The hash table is resized when the table is 3/4 or more. When this happens, the table is doubled in size.

Member Typedef Documentation

◆ size_type

Constructor & Destructor Documentation

◆ SmallPtrSetImplBase() [1/3]

wpi::SmallPtrSetImplBase::SmallPtrSetImplBase ( const void **  SmallStorage,
const SmallPtrSetImplBase that 
)
protected

◆ SmallPtrSetImplBase() [2/3]

wpi::SmallPtrSetImplBase::SmallPtrSetImplBase ( const void **  SmallStorage,
unsigned  SmallSize,
SmallPtrSetImplBase &&  that 
)
protected

◆ SmallPtrSetImplBase() [3/3]

wpi::SmallPtrSetImplBase::SmallPtrSetImplBase ( const void **  SmallStorage,
unsigned  SmallSize 
)
inlineexplicitprotected

◆ ~SmallPtrSetImplBase()

wpi::SmallPtrSetImplBase::~SmallPtrSetImplBase ( )
inlineprotected

Member Function Documentation

◆ clear()

void wpi::SmallPtrSetImplBase::clear ( )
inline

◆ CopyFrom()

void wpi::SmallPtrSetImplBase::CopyFrom ( const SmallPtrSetImplBase RHS)
protected

◆ empty()

LLVM_NODISCARD bool wpi::SmallPtrSetImplBase::empty ( ) const
inline

◆ EndPointer()

const void ** wpi::SmallPtrSetImplBase::EndPointer ( ) const
inlineprotected

◆ erase_imp()

bool wpi::SmallPtrSetImplBase::erase_imp ( const void *  Ptr)
inlineprotected

erase_imp - If the set contains the specified pointer, remove it and return true, otherwise return false.

This is hidden from the client so that the derived class can check that the right type of pointer is passed in.

◆ find_imp()

const void *const * wpi::SmallPtrSetImplBase::find_imp ( const void *  Ptr) const
inlineprotected

Returns the raw pointer needed to construct an iterator.

If element not found, this will be EndPointer. Otherwise, it will be a pointer to the slot which stores Ptr;

◆ getEmptyMarker()

static void * wpi::SmallPtrSetImplBase::getEmptyMarker ( )
inlinestaticprotected

◆ getTombstoneMarker()

static void * wpi::SmallPtrSetImplBase::getTombstoneMarker ( )
inlinestaticprotected

◆ insert_imp()

std::pair< const void *const *, bool > wpi::SmallPtrSetImplBase::insert_imp ( const void *  Ptr)
inlineprotected

insert_imp - This returns true if the pointer was new to the set, false if it was already in the set.

This is hidden from the client so that the derived class can check that the right type of pointer is passed in.

◆ MoveFrom()

void wpi::SmallPtrSetImplBase::MoveFrom ( unsigned  SmallSize,
SmallPtrSetImplBase &&  RHS 
)
protected

◆ operator=()

SmallPtrSetImplBase & wpi::SmallPtrSetImplBase::operator= ( const SmallPtrSetImplBase )
delete

◆ size()

size_type wpi::SmallPtrSetImplBase::size ( ) const
inline

◆ swap()

void wpi::SmallPtrSetImplBase::swap ( SmallPtrSetImplBase RHS)
protected

swap - Swaps the elements of two sets.

Note: This method assumes that both sets have the same small size.

Friends And Related Function Documentation

◆ SmallPtrSetIteratorImpl

friend class SmallPtrSetIteratorImpl
friend

Member Data Documentation

◆ CurArray

const void** wpi::SmallPtrSetImplBase::CurArray
protected

CurArray - This is the current set of buckets.

If equal to SmallArray, then the set is in 'small mode'.

◆ CurArraySize

unsigned wpi::SmallPtrSetImplBase::CurArraySize
protected

CurArraySize - The allocated size of CurArray, always a power of two.

◆ NumNonEmpty

unsigned wpi::SmallPtrSetImplBase::NumNonEmpty
protected

Number of elements in CurArray that contain a value or are a tombstone.

If small, all these elements are at the beginning of CurArray and the rest is uninitialized.

◆ NumTombstones

unsigned wpi::SmallPtrSetImplBase::NumTombstones
protected

Number of tombstones in CurArray.

◆ SmallArray

const void** wpi::SmallPtrSetImplBase::SmallArray
protected

SmallArray - Points to a fixed size set of buckets, used in 'small mode'.


The documentation for this class was generated from the following file: