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

#include <vec.h>

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
 
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
Definition gengtype.h:252

Constructor & Destructor Documentation

◆ vec() [1/4]

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

◆ vec() [2/4]

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

◆ vec() [3/4]

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

◆ ~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 NULL.

◆ address() [2/2]

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

References NULL.

◆ allocated()

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

◆ begin() [1/2]

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

◆ begin() [2/2]

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

◆ 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.   

◆ 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 NULL.

◆ 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 NULL.

◆ 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.   

◆ 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_PASS_MEM_STAT.

◆ 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 NULL, and PASS_MEM_STAT.

◆ end() [1/2]

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

References begin().

◆ end() [2/2]

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

References begin().

◆ exists()

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

References NULL.

◆ is_empty()

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

◆ 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.   

◆ 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;   

◆ last()

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

◆ length()

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

◆ 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.   

◆ operator!=()

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

◆ 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

◆ operator==()

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

◆ operator[]() [1/2]

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

◆ operator[]() [2/2]

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

◆ 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.   

◆ 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.   

◆ 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.   

◆ 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.

◆ 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.

◆ 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.   

◆ 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.   

◆ release()

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

References va_heap::release().

◆ 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 NULL, PASS_MEM_STAT, va_heap::reserve(), and vec_copy_construct().

◆ 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 PASS_MEM_STAT.

◆ reverse()

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

References i.

◆ 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, and PASS_MEM_STAT.

◆ 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, and PASS_MEM_STAT.

◆ 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 PASS_MEM_STAT.

◆ 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 PASS_MEM_STAT.

◆ 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.   

◆ 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.   

◆ space()

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

◆ 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.   

◆ 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.   

◆ 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.

◆ 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.   

◆ using_auto_storage()

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

Field Documentation

◆ m_vec

template<typename T >
vec<T, va_heap, vl_embed>* vec< T, va_heap, vl_ptr >::m_vec

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