GCC Middle and Back End API Reference
vec< T, va_heap, vl_ptr > Struct Template Reference

#include <vec.h>

Inheritance diagram for vec< T, va_heap, vl_ptr >:
Collaboration diagram for vec< T, va_heap, vl_ptr >:

Public Types

using pop_ret_type

Public Member Functions

 vec ()=default
 vec (const vec &)=default
 vec (vnull)
 ~vec ()=default
vecoperator= (const vec &)=default
template<size_t N>
 vec (auto_vec< T, N > &)=delete
template<size_t N>
void operator= (auto_vec< T, N > &)=delete
void create (unsigned nelems CXX_MEM_STAT_INFO)
void release (void)
bool exists (void) const
bool is_empty (void) const
unsigned allocated (void) const
unsigned length (void) const
Taddress (void)
const Taddress (void) const
Tbegin ()
const Tbegin () const
Tend ()
const Tend () const
const Toperator[] (unsigned ix) const
const Tlast (void) const
bool operator!= (const vec &other) const
bool operator== (const vec &other) const
Toperator[] (unsigned ix)
Tlast (void)
bool space (int nelems) const
bool iterate (unsigned ix, T *p) const
bool iterate (unsigned ix, T **p) const
vec copy (ALONE_CXX_MEM_STAT_INFO) const
bool reserve (unsigned, bool=false CXX_MEM_STAT_INFO)
bool reserve_exact (unsigned CXX_MEM_STAT_INFO)
void splice (const vec &)
void safe_splice (const vec &CXX_MEM_STAT_INFO)
Tquick_push (const T &)
Tsafe_push (const T &CXX_MEM_STAT_INFO)
pop_ret_type pop (void)
void truncate (unsigned)
void safe_grow (unsigned, bool=false CXX_MEM_STAT_INFO)
void safe_grow_cleared (unsigned, bool=false CXX_MEM_STAT_INFO)
void quick_grow (unsigned)
void quick_grow_cleared (unsigned)
void quick_insert (unsigned, const T &)
void safe_insert (unsigned, const T &CXX_MEM_STAT_INFO)
void ordered_remove (unsigned)
void unordered_remove (unsigned)
void block_remove (unsigned, unsigned)
void qsort (int(*)(const void *, const void *))
void sort (int(*)(const void *, const void *, void *), void *)
void stablesort (int(*)(const void *, const void *, void *), void *)
Tbsearch (const void *key, int(*compar)(const void *, const void *))
Tbsearch (const void *key, int(*compar)(const void *, const void *, void *), void *)
unsigned lower_bound (T, bool(*)(const T &, const T &)) const
bool contains (const T &search) const
void reverse (void)
bool using_auto_storage () const

Data Fields

vec< T, va_heap, vl_embed > * m_vec

Member Typedef Documentation

◆ pop_ret_type

template<typename T>
using vec< T, va_heap, vl_ptr >::pop_ret_type
Initial value:
typename std::conditional <std::is_trivially_destructible <T>::value,
T &, void>::type
static struct token T
Definition gengtype-parse.cc:45
Definition gengtype.h:252

Constructor & Destructor Documentation

◆ vec() [1/4]

◆ vec() [2/4]

template<typename T>
vec< T, va_heap, vl_ptr >::vec ( const vec< T, va_heap, vl_ptr > & )
default

References vec().

◆ vec() [3/4]

template<typename T>
vec< T, va_heap, vl_ptr >::vec ( vnull )
inline

References m_vec.

◆ ~vec()

template<typename T>
vec< T, va_heap, vl_ptr >::~vec ( )
default

◆ vec() [4/4]

template<typename T>
template<size_t N>
vec< T, va_heap, vl_ptr >::vec ( auto_vec< T, N > & )
delete

Member Function Documentation

◆ address() [1/2]

template<typename T>
T * vec< T, va_heap, vl_ptr >::address ( void )
inline

References m_vec, NULL, and T.

Referenced by begin(), begin(), operator==(), and reverse().

◆ address() [2/2]

template<typename T>
const T * vec< T, va_heap, vl_ptr >::address ( void ) const
inline

References m_vec, NULL, and T.

◆ allocated()

template<typename T>
unsigned vec< T, va_heap, vl_ptr >::allocated ( void ) const
inline

References m_vec.

◆ begin() [1/2]

template<typename T>
T * vec< T, va_heap, vl_ptr >::begin ( )
inline

References address(), and T.

◆ begin() [2/2]

template<typename T>
const T * vec< T, va_heap, vl_ptr >::begin ( ) const
inline

References address(), and T.

◆ block_remove()

template<typename T>
void vec< T, va_heap, vl_ptr >::block_remove ( unsigned ix,
unsigned len )
inline
Remove LEN elements starting at the IXth. Ordering is retained. This is an O(N) operation due to memmove.

References m_vec, and vec().

◆ bsearch() [1/2]

template<typename T>
T * vec< T, va_heap, vl_ptr >::bsearch ( const void * key,
int(* cmp )(const void *, const void *) )
inline
Search the contents of the sorted vector with a binary search. CMP is the comparison function to pass to bsearch.

References m_vec, NULL, and vec().

◆ bsearch() [2/2]

template<typename T>
T * vec< T, va_heap, vl_ptr >::bsearch ( const void * key,
int(* cmp )(const void *, const void *, void *),
void * data )
inline
Search the contents of the sorted vector with a binary search. CMP is the comparison function to pass to bsearch.

References m_vec, NULL, and vec().

◆ contains()

template<typename T>
bool vec< T, va_heap, vl_ptr >::contains ( const T & search) const
inline
Return true if SEARCH is an element of V. Note that this is O(N) in the size of the vector and so should be used with care.

References m_vec, T, and vec().

◆ copy()

template<typename T>
vec< T, va_heap, vl_ptr > vec< T, va_heap, vl_ptr >::copy ( ALONE_CXX_MEM_STAT_INFO ) const
inline
Return a copy of this vector.

References ALONE_MEM_STAT_DECL, ALONE_PASS_MEM_STAT, length(), m_vec, and vec().

◆ create()

template<typename T>
void vec< T, va_heap, vl_ptr >::create ( unsigned nelems MEM_STAT_DECL)
inline
Create the internal vector and reserve NELEMS for it. This is exactly like vec::reserve, but the internal vector is unconditionally allocated from scratch. The old one, if it existed, is lost.

References m_vec, MEM_STAT_DECL, NULL, PASS_MEM_STAT, reserve_exact(), and vec().

Referenced by operator=().

◆ end() [1/2]

template<typename T>
T * vec< T, va_heap, vl_ptr >::end ( )
inline

References begin(), length(), and T.

◆ end() [2/2]

template<typename T>
const T * vec< T, va_heap, vl_ptr >::end ( ) const
inline

References begin(), length(), and T.

◆ exists()

template<typename T>
bool vec< T, va_heap, vl_ptr >::exists ( void ) const
inline

References m_vec, and NULL.

◆ is_empty()

template<typename T>
bool vec< T, va_heap, vl_ptr >::is_empty ( void ) const
inline

References m_vec.

◆ iterate() [1/2]

template<typename T>
bool vec< T, va_heap, vl_ptr >::iterate ( unsigned ix,
T ** ptr ) const
inline
Return iteration condition and update *PTR to point to the IX'th element of this vector. Use this to iterate over the elements of a vector as follows, for (ix = 0; v->iterate (ix, &ptr); ix++) continue; This variant is for vectors of objects.

References m_vec, T, and vec().

◆ iterate() [2/2]

template<typename T>
bool vec< T, va_heap, vl_ptr >::iterate ( unsigned ix,
T * ptr ) const
inline
Return iteration condition and update PTR to point to the IX'th element of this vector. Use this to iterate over the elements of a vector as follows, for (ix = 0; v.iterate (ix, &ptr); ix++) continue;

References m_vec, T, and vec().

◆ last() [1/2]

template<typename T>
T & vec< T, va_heap, vl_ptr >::last ( void )
inline

References m_vec, and T.

◆ last() [2/2]

template<typename T>
const T & vec< T, va_heap, vl_ptr >::last ( void ) const
inline

References m_vec, and T.

◆ length()

template<typename T>
unsigned vec< T, va_heap, vl_ptr >::length ( void ) const
inline

References m_vec.

Referenced by copy(), end(), end(), reverse(), safe_grow(), and safe_grow_cleared().

◆ lower_bound()

template<typename T>
unsigned vec< T, va_heap, vl_ptr >::lower_bound ( T obj,
bool(* lessthan )(const T &, const T &) ) const
inline
Find and return the first position in which OBJ could be inserted without changing the ordering of this vector. LESSTHAN is a function that returns true if the first argument is strictly less than the second.

References m_vec, T, and vec().

◆ operator!=()

template<typename T>
bool vec< T, va_heap, vl_ptr >::operator!= ( const vec< T, va_heap, vl_ptr > & other) const
inline

References vec().

◆ operator=() [1/2]

template<typename T>
template<size_t N>
void vec< T, va_heap, vl_ptr >::operator= ( auto_vec< T, N > & )
delete

◆ operator=() [2/2]

template<typename T>
vec & vec< T, va_heap, vl_ptr >::operator= ( const vec< T, va_heap, vl_ptr > & )
default

References vec().

◆ operator==()

template<typename T>
bool vec< T, va_heap, vl_ptr >::operator== ( const vec< T, va_heap, vl_ptr > & other) const
inline

References address(), and vec().

◆ operator[]() [1/2]

template<typename T>
T & vec< T, va_heap, vl_ptr >::operator[] ( unsigned ix)
inline

References m_vec, and T.

◆ operator[]() [2/2]

template<typename T>
const T & vec< T, va_heap, vl_ptr >::operator[] ( unsigned ix) const
inline

References m_vec, and T.

◆ ordered_remove()

template<typename T>
void vec< T, va_heap, vl_ptr >::ordered_remove ( unsigned ix)
inline
Remove an element from the IXth position of this vector. Ordering of remaining elements is preserved. This is an O(N) operation due to a memmove.

References m_vec, and vec().

◆ pop()

template<typename T>
vec< T, va_heap, vl_ptr >::pop_ret_type vec< T, va_heap, vl_ptr >::pop ( void )
inline
Pop and return a reference to the last element off the end of the vector. If T has non-trivial destructor, this method just pops last element and returns void.

References m_vec, and vec().

◆ qsort()

template<typename T>
void vec< T, va_heap, vl_ptr >::qsort ( int(* cmp )(const void *, const void *))
inline
Sort the contents of this vector with qsort. CMP is the comparison function to pass to qsort.

References m_vec, and vec().

◆ quick_grow()

template<typename T>
void vec< T, va_heap, vl_ptr >::quick_grow ( unsigned len)
inline
Same as vec::safe_grow but without reallocation of the internal vector. If the vector cannot be extended, a runtime assertion will be triggered.

References gcc_checking_assert, m_vec, and vec().

◆ quick_grow_cleared()

template<typename T>
void vec< T, va_heap, vl_ptr >::quick_grow_cleared ( unsigned len)
inline
Same as vec::quick_grow_cleared but without reallocation of the internal vector. If the vector cannot be extended, a runtime assertion will be triggered.

References gcc_checking_assert, m_vec, and vec().

◆ quick_insert()

template<typename T>
void vec< T, va_heap, vl_ptr >::quick_insert ( unsigned ix,
const T & obj )
inline
Insert an element, OBJ, at the IXth position of this vector. There must be sufficient space.

References m_vec, T, and vec().

Referenced by safe_insert().

◆ quick_push()

template<typename T>
T * vec< T, va_heap, vl_ptr >::quick_push ( const T & obj)
inline
Push OBJ (a new element) onto the end of the vector. There must be sufficient space in the vector. Return a pointer to the slot where OBJ was inserted.

References m_vec, T, and vec().

Referenced by safe_push().

◆ release()

template<typename T>
void vec< T, va_heap, vl_ptr >::release ( void )
inline
Free the memory occupied by the embedded vector.

References m_vec, va_heap::release(), using_auto_storage(), and vec().

Referenced by operator=().

◆ reserve()

template<typename T>
bool vec< T, va_heap, vl_ptr >::reserve ( unsigned ,
bool = false CXX_MEM_STAT_INFO )
inline
Ensure that the vector has at least RESERVE slots available (if EXACT is false), or exactly RESERVE slots available (if EXACT is true). This may create additional headroom if EXACT is false. Note that this can cause the embedded vector to be reallocated. Returns true iff reallocation actually occurred.

References m_vec, MEM_STAT_DECL, NULL, PASS_MEM_STAT, va_heap::reserve(), space(), using_auto_storage(), vec(), and vec_copy_construct().

Referenced by reserve_exact(), safe_grow(), safe_grow_cleared(), safe_insert(), and safe_push().

◆ reserve_exact()

template<typename T>
bool vec< T, va_heap, vl_ptr >::reserve_exact ( unsigned CXX_MEM_STAT_INFO)
inline
Ensure that this vector has exactly NELEMS slots available. This will not create additional headroom. Note this can cause the embedded vector to be reallocated. Returns true iff reallocation actually occurred.

References MEM_STAT_DECL, PASS_MEM_STAT, reserve(), and vec().

Referenced by create(), and safe_splice().

◆ reverse()

template<typename T>
void vec< T, va_heap, vl_ptr >::reverse ( void )
inline
Reverse content of the vector.

References address(), i, length(), T, and vec().

◆ safe_grow()

template<typename T>
void vec< T, va_heap, vl_ptr >::safe_grow ( unsigned ,
bool = false CXX_MEM_STAT_INFO )
inline
Grow the vector to a specific length. LEN must be as long or longer than the current length. The new elements are uninitialized. Reallocate the internal vector, if needed.

References gcc_checking_assert, length(), m_vec, MEM_STAT_DECL, PASS_MEM_STAT, reserve(), and vec().

◆ safe_grow_cleared()

template<typename T>
void vec< T, va_heap, vl_ptr >::safe_grow_cleared ( unsigned ,
bool = false CXX_MEM_STAT_INFO )
inline
Grow the embedded vector to a specific length. LEN must be as long or longer than the current length. The new elements are initialized to zero. Reallocate the internal vector, if needed.

References gcc_checking_assert, length(), m_vec, MEM_STAT_DECL, PASS_MEM_STAT, reserve(), and vec().

◆ safe_insert()

template<typename T>
void vec< T, va_heap, vl_ptr >::safe_insert ( unsigned ,
const T & CXX_MEM_STAT_INFO )
inline
Insert an element, OBJ, at the IXth position of the vector. Reallocate the embedded vector, if necessary.

References MEM_STAT_DECL, PASS_MEM_STAT, quick_insert(), reserve(), T, and vec().

◆ safe_push()

template<typename T>
T * vec< T, va_heap, vl_ptr >::safe_push ( const T & CXX_MEM_STAT_INFO)
inline
Push a new element OBJ onto the end of this vector. Reallocates the embedded vector, if needed. Return a pointer to the slot where OBJ was inserted.

References MEM_STAT_DECL, PASS_MEM_STAT, quick_push(), reserve(), T, and vec().

◆ safe_splice()

template<typename T>
void vec< T, va_heap, vl_ptr >::safe_splice ( const vec< T, va_heap, vl_ptr > & CXX_MEM_STAT_INFO)
inline
Copy the elements in SRC to the end of this vector as if by memcpy. SRC and this vector must be allocated with the same mechanism. If there is not enough headroom in this vector, it will be reallocated as needed.

References MEM_STAT_DECL, reserve_exact(), splice(), and vec().

◆ sort()

template<typename T>
void vec< T, va_heap, vl_ptr >::sort ( int(* cmp )(const void *, const void *, void *),
void * data )
inline
Sort the contents of this vector with qsort. CMP is the comparison function to pass to qsort.

References m_vec, and vec().

◆ space()

template<typename T>
bool vec< T, va_heap, vl_ptr >::space ( int nelems) const
inline

References m_vec.

Referenced by reserve().

◆ splice()

template<typename T>
void vec< T, va_heap, vl_ptr >::splice ( const vec< T, va_heap, vl_ptr > & )
inline
Copy the elements from SRC to the end of this vector as if by memcpy. SRC and this vector must be allocated with the same memory allocation mechanism. This vector is assumed to have sufficient headroom available.

References m_vec, and vec().

Referenced by safe_splice().

◆ stablesort()

template<typename T>
void vec< T, va_heap, vl_ptr >::stablesort ( int(* cmp )(const void *, const void *, void *),
void * data )
inline
Sort the contents of this vector with gcc_stablesort_r. CMP is the comparison function to pass to qsort.

References m_vec, and vec().

◆ truncate()

template<typename T>
void vec< T, va_heap, vl_ptr >::truncate ( unsigned size)
inline
Set the length of the vector to LEN. The new length must be less than or equal to the current length. This is an O(1) operation.

References gcc_checking_assert, m_vec, and vec().

◆ unordered_remove()

template<typename T>
void vec< T, va_heap, vl_ptr >::unordered_remove ( unsigned ix)
inline
Remove an element from the IXth position of this vector. Ordering of remaining elements is destroyed. This is an O(1) operation.

References m_vec, and vec().

◆ using_auto_storage()

template<typename T>
bool vec< T, va_heap, vl_ptr >::using_auto_storage ( ) const
inline

References m_vec, and vec().

Referenced by release(), and reserve().

Field Documentation

◆ m_vec


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