LLVM 19.0.0git
Public Member Functions | List of all members
llvm::SmallVector< T, N > Class Template Reference

This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small. More...

#include "llvm/ADT/SmallVector.h"

Inherits llvm::SmallVectorImpl< T >, and llvm::SmallVectorStorage< T, N >.

Public Member Functions

 SmallVector ()
 
 ~SmallVector ()
 
 SmallVector (size_t Size)
 
 SmallVector (size_t Size, const T &Value)
 
template<typename ItTy , typename = EnableIfConvertibleToInputIterator<ItTy>>
 SmallVector (ItTy S, ItTy E)
 
template<typename RangeTy >
 SmallVector (const iterator_range< RangeTy > &R)
 
 SmallVector (std::initializer_list< T > IL)
 
template<typename U , typename = std::enable_if_t<std::is_convertible<U, T>::value>>
 SmallVector (ArrayRef< U > A)
 
 SmallVector (const SmallVector &RHS)
 
SmallVectoroperator= (const SmallVector &RHS)
 
 SmallVector (SmallVector &&RHS)
 
 SmallVector (SmallVectorImpl< T > &&RHS)
 
SmallVectoroperator= (SmallVector &&RHS)
 
SmallVectoroperator= (SmallVectorImpl< T > &&RHS)
 
SmallVectoroperator= (std::initializer_list< T > IL)
 
- Public Member Functions inherited from llvm::SmallVectorImpl< T >
 SmallVectorImpl (const SmallVectorImpl &)=delete
 
void clear ()
 
void resize (size_type N)
 
void resize_for_overwrite (size_type N)
 Like resize, but T is POD, the new values won't be initialized.
 
void truncate (size_type N)
 Like resize, but requires that N is less than size().
 
void resize (size_type N, ValueParamT NV)
 
void reserve (size_type N)
 
void pop_back_n (size_type NumItems)
 
T pop_back_val ()
 
void swap (SmallVectorImpl &RHS)
 
template<typename ItTy , typename = EnableIfConvertibleToInputIterator<ItTy>>
void append (ItTy in_start, ItTy in_end)
 Add the specified range to the end of the SmallVector.
 
void append (size_type NumInputs, ValueParamT Elt)
 Append NumInputs copies of Elt to the end.
 
void append (std::initializer_list< T > IL)
 
void append (const SmallVectorImpl &RHS)
 
void assign (size_type NumElts, ValueParamT Elt)
 
template<typename ItTy , typename = EnableIfConvertibleToInputIterator<ItTy>>
void assign (ItTy in_start, ItTy in_end)
 
void assign (std::initializer_list< T > IL)
 
void assign (const SmallVectorImpl &RHS)
 
iterator erase (const_iterator CI)
 
iterator erase (const_iterator CS, const_iterator CE)
 
iterator insert (iterator I, T &&Elt)
 
iterator insert (iterator I, const T &Elt)
 
iterator insert (iterator I, size_type NumToInsert, ValueParamT Elt)
 
template<typename ItTy , typename = EnableIfConvertibleToInputIterator<ItTy>>
iterator insert (iterator I, ItTy From, ItTy To)
 
void insert (iterator I, std::initializer_list< T > IL)
 
template<typename... ArgTypes>
reference emplace_back (ArgTypes &&... Args)
 
SmallVectorImploperator= (const SmallVectorImpl &RHS)
 
SmallVectorImploperator= (SmallVectorImpl &&RHS)
 
bool operator== (const SmallVectorImpl &RHS) const
 
bool operator!= (const SmallVectorImpl &RHS) const
 
bool operator< (const SmallVectorImpl &RHS) const
 
bool operator> (const SmallVectorImpl &RHS) const
 
bool operator<= (const SmallVectorImpl &RHS) const
 
bool operator>= (const SmallVectorImpl &RHS) const
 
- Public Member Functions inherited from llvm::SmallVectorTemplateBase< T, bool >
void push_back (const T &Elt)
 
void push_back (T &&Elt)
 
void pop_back ()
 
- Public Member Functions inherited from llvm::SmallVectorTemplateCommon< T, typename >
iterator begin ()
 
const_iterator begin () const
 
iterator end ()
 
const_iterator end () const
 
reverse_iterator rbegin ()
 
const_reverse_iterator rbegin () const
 
reverse_iterator rend ()
 
const_reverse_iterator rend () const
 
size_type size_in_bytes () const
 
size_type max_size () const
 
size_t capacity_in_bytes () const
 
pointer data ()
 Return a pointer to the vector's buffer, even if empty().
 
const_pointer data () const
 Return a pointer to the vector's buffer, even if empty().
 
reference operator[] (size_type idx)
 
const_reference operator[] (size_type idx) const
 
reference front ()
 
const_reference front () const
 
reference back ()
 
const_reference back () const
 
- Public Member Functions inherited from llvm::SmallVectorBase< SmallVectorSizeType< T > >
size_t size () const
 
size_t capacity () const
 
bool empty () const
 

Additional Inherited Members

- Public Types inherited from llvm::SmallVectorImpl< T >
using iterator = typename SuperClass::iterator
 
using const_iterator = typename SuperClass::const_iterator
 
using reference = typename SuperClass::reference
 
using size_type = typename SuperClass::size_type
 
- Public Types inherited from llvm::SmallVectorTemplateCommon< T, typename >
using size_type = size_t
 
using difference_type = ptrdiff_t
 
using value_type = T
 
using iterator = T *
 
using const_iterator = const T *
 
using const_reverse_iterator = std::reverse_iterator< const_iterator >
 
using reverse_iterator = std::reverse_iterator< iterator >
 
using reference = T &
 
using const_reference = const T &
 
using pointer = T *
 
using const_pointer = const T *
 
- Protected Types inherited from llvm::SmallVectorImpl< T >
using ValueParamT = typename SuperClass::ValueParamT
 
- Protected Types inherited from llvm::SmallVectorTemplateBase< T, bool >
using ValueParamT = const T &
 
- Protected Member Functions inherited from llvm::SmallVectorImpl< T >
 SmallVectorImpl (unsigned N)
 
void assignRemote (SmallVectorImpl &&RHS)
 
 ~SmallVectorImpl ()
 
- Protected Member Functions inherited from llvm::SmallVectorTemplateBase< T, bool >
 SmallVectorTemplateBase (size_t Size)
 
void grow (size_t MinSize=0)
 Grow the allocated memory (without initializing new elements), doubling the size of the allocated memory.
 
TmallocForGrow (size_t MinSize, size_t &NewCapacity)
 Create a new allocation big enough for MinSize and pass back its size in NewCapacity.
 
void moveElementsForGrow (T *NewElts)
 Move existing elements over to the new allocation NewElts, the middle section of grow().
 
void takeAllocationForGrow (T *NewElts, size_t NewCapacity)
 Transfer ownership of the allocation, finishing up grow().
 
const TreserveForParamAndGetAddress (const T &Elt, size_t N=1)
 Reserve enough space to add one element, and return the updated element pointer in case it was a reference to the storage.
 
TreserveForParamAndGetAddress (T &Elt, size_t N=1)
 Reserve enough space to add one element, and return the updated element pointer in case it was a reference to the storage.
 
void growAndAssign (size_t NumElts, const T &Elt)
 
template<typename... ArgTypes>
TgrowAndEmplaceBack (ArgTypes &&... Args)
 
- Protected Member Functions inherited from llvm::SmallVectorTemplateCommon< T, typename >
void * getFirstEl () const
 Find the address of the first element.
 
 SmallVectorTemplateCommon (size_t Size)
 
void grow_pod (size_t MinSize, size_t TSize)
 
bool isSmall () const
 Return true if this is a smallvector which has not had dynamic memory allocated for it.
 
void resetToSmall ()
 Put this vector in a state of being small.
 
bool isReferenceToRange (const void *V, const void *First, const void *Last) const
 Return true if V is an internal reference to the given range.
 
bool isReferenceToStorage (const void *V) const
 Return true if V is an internal reference to this vector.
 
bool isRangeInStorage (const void *First, const void *Last) const
 Return true if First and Last form a valid (possibly empty) range in this vector's storage.
 
bool isSafeToReferenceAfterResize (const void *Elt, size_t NewSize)
 Return true unless Elt will be invalidated by resizing the vector to NewSize.
 
void assertSafeToReferenceAfterResize (const void *Elt, size_t NewSize)
 Check whether Elt will be invalidated by resizing the vector to NewSize.
 
void assertSafeToAdd (const void *Elt, size_t N=1)
 Check whether Elt will be invalidated by increasing the size of the vector by N.
 
void assertSafeToReferenceAfterClear (const T *From, const T *To)
 Check whether any part of the range will be invalidated by clearing.
 
template<class ItTy , std::enable_if_t<!std::is_same< std::remove_const_t< ItTy >, T * >::value, bool > = false>
void assertSafeToReferenceAfterClear (ItTy, ItTy)
 
void assertSafeToAddRange (const T *From, const T *To)
 Check whether any part of the range will be invalidated by growing.
 
template<class ItTy , std::enable_if_t<!std::is_same< std::remove_const_t< ItTy >, T * >::value, bool > = false>
void assertSafeToAddRange (ItTy, ItTy)
 
- Protected Member Functions inherited from llvm::SmallVectorBase< SmallVectorSizeType< T > >
 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.
 
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.
 
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.
 
void set_size (size_t N)
 Set the array size to N, which the current array must have enough capacity for.
 
void set_allocation_range (void *Begin, size_t N)
 Set the array data pointer to Begin and capacity to N.
 
- Static Protected Member Functions inherited from llvm::SmallVectorTemplateBase< T, bool >
static void destroy_range (T *S, T *E)
 
template<typename It1 , typename It2 >
static void uninitialized_move (It1 I, It1 E, It2 Dest)
 Move the range [I, E) into the uninitialized memory starting with "Dest", constructing elements as needed.
 
template<typename It1 , typename It2 >
static void uninitialized_copy (It1 I, It1 E, It2 Dest)
 Copy the range [I, E) onto the uninitialized memory starting with "Dest", constructing elements as needed.
 
static T && forward_value_param (T &&V)
 
static const Tforward_value_param (const T &V)
 
- Static Protected Member Functions inherited from llvm::SmallVectorTemplateCommon< T, typename >
template<class U >
static const TreserveForParamAndGetAddressImpl (U *This, const T &Elt, size_t N)
 Reserve enough space to add one element, and return the updated element pointer in case it was a reference to the storage.
 
- Static Protected Member Functions inherited from llvm::SmallVectorBase< SmallVectorSizeType< T > >
static constexpr size_t SizeTypeMax ()
 The maximum value of the Size_T used.
 
- Protected Attributes inherited from llvm::SmallVectorBase< SmallVectorSizeType< T > >
void * BeginX
 
SmallVectorSizeType< TSize
 
SmallVectorSizeType< TCapacity
 
- Static Protected Attributes inherited from llvm::SmallVectorTemplateBase< T, bool >
static constexpr bool TakesParamByValue = false
 

Detailed Description

template<typename T, unsigned N = CalculateSmallVectorDefaultInlinedElements<T>::value>
class llvm::SmallVector< T, N >

This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.

It contains some number of elements in-place, which allows it to avoid heap allocation when the actual number of elements is below that threshold. This allows normal "small" cases to be fast without losing generality for large inputs.

Note
In the absence of a well-motivated choice for the number of inlined elements N, it is recommended to use SmallVector<T> (that is, omitting the N). This will choose a default number of inlined elements reasonable for allocation on the stack (for example, trying to keep sizeof(SmallVector<T>) around 64 bytes).
Warning
This does not attempt to be exception safe.
See also
https://llvm.org/docs/ProgrammersManual.html#llvm-adt-smallvector-h

Definition at line 1208 of file SmallVector.h.

Constructor & Destructor Documentation

◆ SmallVector() [1/10]

template<typename T , unsigned N = CalculateSmallVectorDefaultInlinedElements<T>::value>
llvm::SmallVector< T, N >::SmallVector ( )
inline

Definition at line 1211 of file SmallVector.h.

◆ ~SmallVector()

template<typename T , unsigned N = CalculateSmallVectorDefaultInlinedElements<T>::value>
llvm::SmallVector< T, N >::~SmallVector ( )
inline

Definition at line 1213 of file SmallVector.h.

◆ SmallVector() [2/10]

template<typename T , unsigned N = CalculateSmallVectorDefaultInlinedElements<T>::value>
llvm::SmallVector< T, N >::SmallVector ( size_t  Size)
inlineexplicit

Definition at line 1218 of file SmallVector.h.

References Size.

◆ SmallVector() [3/10]

template<typename T , unsigned N = CalculateSmallVectorDefaultInlinedElements<T>::value>
llvm::SmallVector< T, N >::SmallVector ( size_t  Size,
const T Value 
)
inline

Definition at line 1223 of file SmallVector.h.

References Size.

◆ SmallVector() [4/10]

template<typename T , unsigned N = CalculateSmallVectorDefaultInlinedElements<T>::value>
template<typename ItTy , typename = EnableIfConvertibleToInputIterator<ItTy>>
llvm::SmallVector< T, N >::SmallVector ( ItTy  S,
ItTy  E 
)
inline

Definition at line 1229 of file SmallVector.h.

References E.

◆ SmallVector() [5/10]

template<typename T , unsigned N = CalculateSmallVectorDefaultInlinedElements<T>::value>
template<typename RangeTy >
llvm::SmallVector< T, N >::SmallVector ( const iterator_range< RangeTy > &  R)
inlineexplicit

Definition at line 1234 of file SmallVector.h.

◆ SmallVector() [6/10]

template<typename T , unsigned N = CalculateSmallVectorDefaultInlinedElements<T>::value>
llvm::SmallVector< T, N >::SmallVector ( std::initializer_list< T IL)
inline

Definition at line 1239 of file SmallVector.h.

◆ SmallVector() [7/10]

template<typename T , unsigned N = CalculateSmallVectorDefaultInlinedElements<T>::value>
template<typename U , typename = std::enable_if_t<std::is_convertible<U, T>::value>>
llvm::SmallVector< T, N >::SmallVector ( ArrayRef< U >  A)
inlineexplicit

Definition at line 1245 of file SmallVector.h.

References A.

◆ SmallVector() [8/10]

template<typename T , unsigned N = CalculateSmallVectorDefaultInlinedElements<T>::value>
llvm::SmallVector< T, N >::SmallVector ( const SmallVector< T, N > &  RHS)
inline

Definition at line 1249 of file SmallVector.h.

References RHS.

◆ SmallVector() [9/10]

template<typename T , unsigned N = CalculateSmallVectorDefaultInlinedElements<T>::value>
llvm::SmallVector< T, N >::SmallVector ( SmallVector< T, N > &&  RHS)
inline

Definition at line 1259 of file SmallVector.h.

References RHS.

◆ SmallVector() [10/10]

template<typename T , unsigned N = CalculateSmallVectorDefaultInlinedElements<T>::value>
llvm::SmallVector< T, N >::SmallVector ( SmallVectorImpl< T > &&  RHS)
inline

Definition at line 1264 of file SmallVector.h.

References RHS.

Member Function Documentation

◆ operator=() [1/4]

template<typename T , unsigned N = CalculateSmallVectorDefaultInlinedElements<T>::value>
SmallVector & llvm::SmallVector< T, N >::operator= ( const SmallVector< T, N > &  RHS)
inline

Definition at line 1254 of file SmallVector.h.

References RHS.

◆ operator=() [2/4]

template<typename T , unsigned N = CalculateSmallVectorDefaultInlinedElements<T>::value>
SmallVector & llvm::SmallVector< T, N >::operator= ( SmallVector< T, N > &&  RHS)
inline

Definition at line 1269 of file SmallVector.h.

References N, RHS, and Size.

◆ operator=() [3/4]

template<typename T , unsigned N = CalculateSmallVectorDefaultInlinedElements<T>::value>
SmallVector & llvm::SmallVector< T, N >::operator= ( SmallVectorImpl< T > &&  RHS)
inline

Definition at line 1287 of file SmallVector.h.

References RHS.

◆ operator=() [4/4]

template<typename T , unsigned N = CalculateSmallVectorDefaultInlinedElements<T>::value>
SmallVector & llvm::SmallVector< T, N >::operator= ( std::initializer_list< T IL)
inline

Definition at line 1292 of file SmallVector.h.


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