GCC Middle and Back End API Reference
|
#include <vec.h>
Public Member Functions | |
void | create (unsigned nelems CXX_MEM_STAT_INFO) |
void | release (void) |
bool | exists (void) const |
bool | is_empty (void) const |
unsigned | length (void) const |
T * | address (void) |
const T * | address (void) const |
const T & | operator[] (unsigned ix) const |
bool | operator!= (const vec &other) const |
bool | operator== (const vec &other) const |
T & | operator[] (unsigned ix) |
T & | last (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 (vec &) |
void | safe_splice (vec &CXX_MEM_STAT_INFO) |
T * | quick_push (const T &) |
T * | safe_push (const T &CXX_MEM_STAT_INFO) |
T & | pop (void) |
void | truncate (unsigned) |
void | safe_grow (unsigned CXX_MEM_STAT_INFO) |
void | safe_grow_cleared (unsigned 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 *)) |
unsigned | lower_bound (T, bool(*)(const T &, const T &)) const |
bool | using_auto_storage () const |
Data Fields | |
vec< T, va_heap, vl_embed > * | m_vec |
Space efficient vector. These vectors can grow dynamically and are allocated together with their control data. They are suited to be included in data structures. Prior to initial allocation, they only take a single word of storage. These vectors are implemented as a pointer to an embeddable vector. The semantics allow for this pointer to be NULL to represent empty vectors. This way, empty vectors occupy minimal space in the structure containing them. Properties: - The whole vector and control data are allocated in a single contiguous block. - The whole vector may be re-allocated. - Vector data may grow and shrink. - Access and manipulation requires a pointer test and indirection. - It requires 1 word of storage (prior to vector allocation). Limitations: These vectors must be PODs because they are stored in unions. (http://en.wikipedia.org/wiki/Plain_old_data_structures). As long as we use C++03, we cannot have constructors nor destructors in classes that are stored in unions.
|
inline |
Remove LEN elements starting at the IXth. Ordering is retained. This is an O(N) operation due to memmove.
|
inline |
Return a copy of this vector.
|
inline |
Memory allocation and deallocation for the embedded vector. Needed because we cannot have proper ctors/dtors defined.
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.
Vector operations.
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 va_heap::reserve().
|
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.
|
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.
|
inline |
|
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 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.
Same as vec::safe_grow but without reallocation of the internal vector. If the vector cannot be extended, a runtime assertion will be triggered.
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.
|
inline |
Insert an element, OBJ, at the IXth position of this vector. There must be sufficient space.
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.
Free the memory occupied by the embedded vector.
|
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.
For now play a game with va_heap::reserve to hide our auto storage if any, this is necessary because it doesn't have enough information to know the embedded vector is in auto storage, and so should not be freed.
|
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.
|
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.
|
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.
|
inline |
Insert an element, OBJ, at the IXth position of the vector. Reallocate the embedded vector, if necessary.
|
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.
|
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 vec_alloc().
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.
Remove an element from the IXth position of this vector. Ordering of remaining elements is destroyed. This is an O(1) operation.
FIXME - This field should be private, but we need to cater to compilers that have stricter notions of PODness for types.
Referenced by vec_free().