WPILibC++ 2024.3.2
wpi::SmallVectorBase Class Reference

This is all the stuff common to all SmallVectors. More...

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

Inheritance diagram for wpi::SmallVectorBase:
wpi::SmallVectorTemplateCommon< std::pair< KeyT, ValueT > > wpi::SmallVectorTemplateCommon< char > wpi::SmallVectorTemplateCommon< frc2::Subsystem * > wpi::SmallVectorTemplateCommon< frc2::Command * > wpi::SmallVectorTemplateCommon< std::unique_ptr< frc2::Command > > wpi::SmallVectorTemplateCommon< frc::Pose2d > wpi::SmallVectorTemplateCommon< std::string > wpi::SmallVectorTemplateCommon< wpi::SmallString< 16 > > wpi::SmallVectorTemplateCommon< WPI_EventHandle > wpi::SmallVectorTemplateCommon< size_t > wpi::SmallVectorTemplateCommon< uint8_t > wpi::SmallVectorTemplateCommon< wpi::uv::Buffer > wpi::SmallVectorTemplateCommon< T, typename >

Public Member Functions

size_t size () const
 
size_t capacity () const
 
bool empty () const
 

Protected Member Functions

 SmallVectorBase ()=delete
 
 SmallVectorBase (void *FirstEl, size_t TotalCapacity)
 
void * mallocForGrow (void *FirstEl, size_t MinSize, size_t TSize, size_t &NewCapacity)
 This is a helper for grow() that's out of line to reduce code duplication. More...
 
void grow_pod (void *FirstEl, size_t MinSize, size_t TSize)
 This is an implementation of the grow() method which only works on POD-like data types and is out of line to reduce code duplication. More...
 
void * replaceAllocation (void *NewElts, size_t TSize, size_t NewCapacity, size_t VSize=0)
 If vector was first created with capacity 0, getFirstEl() points to the memory right after, an area unallocated. More...
 
void set_size (size_t N)
 Set the array size to N, which the current array must have enough capacity for. More...
 

Static Protected Member Functions

static constexpr size_t SizeTypeMax ()
 The maximum value of the Size_T used. More...
 

Protected Attributes

void * BeginX
 
unsigned Size = 0
 
unsigned Capacity
 

Detailed Description

This is all the stuff common to all SmallVectors.

The template parameter specifies the type which should be used to hold the Size and Capacity of the SmallVector, so it can be adjusted. Using 32 bit size is desirable to shrink the size of the SmallVector. Using 64 bit size is desirable for cases like SmallVector<char>, where a 32 bit size would limit the vector to ~4GB. SmallVectors are used for buffering bitcode output - which can exceed 4GB.

Constructor & Destructor Documentation

◆ SmallVectorBase() [1/2]

wpi::SmallVectorBase::SmallVectorBase ( )
protecteddelete

◆ SmallVectorBase() [2/2]

wpi::SmallVectorBase::SmallVectorBase ( void *  FirstEl,
size_t  TotalCapacity 
)
inlineprotected

Member Function Documentation

◆ capacity()

size_t wpi::SmallVectorBase::capacity ( ) const
inline

◆ empty()

bool wpi::SmallVectorBase::empty ( ) const
inline

◆ grow_pod()

void wpi::SmallVectorBase::grow_pod ( void *  FirstEl,
size_t  MinSize,
size_t  TSize 
)
protected

This is an implementation of the grow() method which only works on POD-like data types and is out of line to reduce code duplication.

This function will report a fatal error if it cannot increase capacity.

◆ mallocForGrow()

void * wpi::SmallVectorBase::mallocForGrow ( void *  FirstEl,
size_t  MinSize,
size_t  TSize,
size_t &  NewCapacity 
)
protected

This is a helper for grow() that's out of line to reduce code duplication.

This function will report a fatal error if it can't grow at least to MinSize.

◆ replaceAllocation()

void * wpi::SmallVectorBase::replaceAllocation ( void *  NewElts,
size_t  TSize,
size_t  NewCapacity,
size_t  VSize = 0 
)
protected

If vector was first created with capacity 0, getFirstEl() points to the memory right after, an area unallocated.

If a subsequent allocation, that grows the vector, happens to return the same pointer as getFirstEl(), get a new allocation, otherwise isSmall() will falsely return that no allocation was done (true) and the memory will not be freed in the destructor. If a VSize is given (vector size), also copy that many elements to the new allocation - used if realloca fails to increase space, and happens to allocate precisely at BeginX. This is unlikely to be called often, but resolves a memory leak when the situation does occur.

◆ set_size()

void wpi::SmallVectorBase::set_size ( size_t  N)
inlineprotected

Set the array size to N, which the current array must have enough capacity for.

This does not construct or destroy any elements in the vector.

◆ size()

size_t wpi::SmallVectorBase::size ( ) const
inline

◆ SizeTypeMax()

static constexpr size_t wpi::SmallVectorBase::SizeTypeMax ( )
inlinestaticconstexprprotected

The maximum value of the Size_T used.

Member Data Documentation

◆ BeginX

void* wpi::SmallVectorBase::BeginX
protected

◆ Capacity

unsigned wpi::SmallVectorBase::Capacity
protected

◆ Size

unsigned wpi::SmallVectorBase::Size = 0
protected

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