GCC Middle and Back End API Reference
|
#include <vec.h>
Public Member Functions | |
unsigned | allocated (void) const |
unsigned | length (void) const |
bool | is_empty (void) const |
T * | address (void) |
const T * | address (void) const |
const T & | operator[] (unsigned) const |
T & | operator[] (unsigned) |
T & | last (void) |
bool | space (unsigned) const |
bool | iterate (unsigned, T *) const |
bool | iterate (unsigned, T **) const |
vec * | copy (ALONE_CXX_MEM_STAT_INFO) const |
void | splice (vec &) |
void | splice (vec *src) |
T * | quick_push (const T &) |
T & | pop (void) |
void | truncate (unsigned) |
void | quick_insert (unsigned, const T &) |
void | ordered_remove (unsigned) |
void | unordered_remove (unsigned) |
void | block_remove (unsigned, unsigned) |
void | qsort (int(*)(const void *, const void *)) |
unsigned | lower_bound (T, bool(*)(const T &, const T &)) const |
void | embedded_init (unsigned, unsigned=0) |
void | quick_grow (unsigned len) |
void | quick_grow_cleared (unsigned len) |
Static Public Member Functions | |
static size_t | embedded_size (unsigned) |
Data Fields | |
vec_prefix | m_vecpfx |
T | m_vecdata [1] |
Friends | |
struct | vec |
struct | va_gc |
struct | va_gc_atomic |
struct | va_heap |
Embeddable vector. These vectors are suitable to be embedded in other data structures so that they can be pre-allocated in a contiguous memory block. Embeddable vectors are implemented using the trailing array idiom, thus they are not resizeable without changing the address of the vector object itself. This means you cannot have variables or fields of embeddable vector type -- always use a pointer to a vector. The one exception is the final field of a structure, which could be a vector type. You will have to use the embedded_size & embedded_init calls to create such objects, and they will not be resizeable (so the 'safe' allocation variants are not available). Properties: - The whole vector and control data are allocated in a single contiguous block. It uses the trailing-vector idiom, so allocation must reserve enough space for all the elements in the vector plus its control data. - The vector cannot be re-allocated. - The vector cannot grow nor shrink. - No indirections needed for access/manipulation. - It requires 2 words of storage (prior to vector allocation).
|
inline |
Remove LEN elements starting at the IXth. Ordering is retained. This is an O(N) operation due to memmove.
References T.
|
inline |
Return a pointer to a copy of this vector.
|
inline |
Initialize the vector to contain room for ALLOC elements and NUM active elements.
|
inlinestatic |
Return the number of bytes needed to embed an instance of an embeddable vec inside another data structure. Use these methods to determine the required size and initialization of a vector V of type T embedded within another structure (as the final member): size_t vec<T, A, vl_embed>::embedded_size (unsigned alloc); void v->embedded_init (unsigned alloc, unsigned num); These allow the caller to perform the memory allocation.
References gt_pch_nx(), length(), and T.
|
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; vec<T, A>::iterate (v, ix, &ptr); ix++) continue;
Referenced by vec_alloc().
|
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.
Get the final element of the vector, which must not be empty.
References T.
Referenced by embedded_size().
unsigned vec< T, A, vl_embed >::lower_bound | ( | T | obj, |
bool(*)(const T &, const T &) | lessthan | ||
) | const |
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 len.
|
inline |
Index into vector. Return the IX'th element. IX must be in the domain of the vector.
Pop and return the last element off the end of the vector.
|
inline |
Sort the contents of this vector with qsort. CMP is the comparison function to pass to qsort.
Grow the vector to a specific length. LEN must be as long or longer than the current length. The new elements are uninitialized.
|
inline |
Grow the vector to a specific length. LEN must be as long or longer than the current length. The new elements are initialized to zero.
|
inline |
Insert an element, OBJ, at the IXth position of this vector. There must be sufficient space.
Referenced by vec_safe_iterate().
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.
Referenced by vec_safe_grow_cleared().
|
inline |
If this vector has space for NELEMS additional entries, return true. You usually only need to use this if you are doing your own vector reallocation, for instance on an embedded vector. This returns true in exactly the same circumstances that vec::reserve will.
Referenced by vec_safe_push().
void vec< T, A, vl_embed >::splice | ( | vec< T, A, vl_embed > * | src | ) |
Set the length of the vector to SIZE. The new length must be less than or equal to the current length. This is an O(1) operation.
|
inline |
Remove an element from the IXth position of this vector. Ordering of remaining elements is destroyed. This is an O(1) operation.
|
friend |
The allocator types also need access to our internals.
|
friend |
|
friend |
|
friend |
vec class can access our internal data and functions.
vec_prefix vec< T, A, vl_embed >::m_vecpfx |
FIXME - These fields should be private, but we need to cater to compilers that have stricter notions of PODness for types.