|
FORM
4.3
|
Go to the source code of this file.
Macros | |
| #define | VectorStruct(T) |
| #define | Vector(T, X) VectorStruct(T) X = { NULL, 0, 0 } |
| #define | DeclareVector(T, X) VectorStruct(T) X |
| #define | VectorInit(X) |
| #define | VectorFree(X) |
| #define | VectorPtr(X) ((X).ptr) |
| #define | VectorFront(X) ((X).ptr[0]) |
| #define | VectorBack(X) ((X).ptr[(X).size - 1]) |
| #define | VectorSize(X) ((X).size) |
| #define | VectorCapacity(X) ((X).capacity) |
| #define | VectorEmpty(X) ((X).size == 0) |
| #define | VectorClear(X) do { (X).size = 0; } while (0) |
| #define | VectorReserve(X, newcapacity) |
| #define | VectorPushBack(X, x) |
| #define | VectorPushBacks(X, src, n) |
| #define | VectorPopBack(X) do { (X).size --; } while (0) |
| #define | VectorInsert(X, index, x) |
| #define | VectorInserts(X, index, src, n) |
| #define | VectorErase(X, index) |
| #define | VectorErases(X, index, n) |
An implementation of dynamic array.
Example:
Definition in file vector.h.
| #define VectorStruct | ( | T | ) |
| #define Vector | ( | T, | |
| X | |||
| ) | VectorStruct(T) X = { NULL, 0, 0 } |
Defines and initialises a vector X of the type T. The user must call VectorFree(X) after the use of X.
| T | the type of elements. |
| X | the name of vector object |
| #define DeclareVector | ( | T, | |
| X | |||
| ) | VectorStruct(T) X |
Declares a vector X of the type T. The user must call VectorInit(X) before the use of X.
| T | the type of elements. |
| X | the name of vector object |
| #define VectorInit | ( | X | ) |
Initialises a vector X of the type T. The user must call VectorFree(X) after the use of X.
| X | the vector object. |
| #define VectorFree | ( | X | ) |
Frees the buffer allocated by the vector X.
| X | the vector object. |
Definition at line 130 of file vector.h.
Referenced by PF_FreeErrorMessageBuffers().
| #define VectorPtr | ( | X | ) | ((X).ptr) |
Returns the pointer to the buffer for the vector X. NULL when VectorCapacity(X) == 0.
| X | the vector object. |
| #define VectorFront | ( | X | ) | ((X).ptr[0]) |
Returns the first element of the vector X. Undefined when VectorSize(X) == 0.
| X | the vector object. |
| #define VectorBack | ( | X | ) | ((X).ptr[(X).size - 1]) |
Returns the last element of the vector X. Undefined when VectorSize(X) == 0.
| X | the vector object. |
| #define VectorSize | ( | X | ) | ((X).size) |
| #define VectorCapacity | ( | X | ) | ((X).capacity) |
| #define VectorEmpty | ( | X | ) | ((X).size == 0) |
| #define VectorClear | ( | X | ) | do { (X).size = 0; } while (0) |
| #define VectorReserve | ( | X, | |
| newcapacity | |||
| ) |
Requires that the capacity of the vector X is equal to or lager than newcapacity.
| X | the vector object. |
| newcapacity | the capacity to be reserved. |
| #define VectorPushBack | ( | X, | |
| x | |||
| ) |
| #define VectorPushBacks | ( | X, | |
| src, | |||
| n | |||
| ) |
Adds an n elements of src at the end of the vector X.
| X | the vector object. |
| src | the starting address of the buffer storing elements to be added. |
| n | the number of elements to be added. |
| #define VectorPopBack | ( | X | ) | do { (X).size --; } while (0) |
Removes the last element of the vector X. VectorSize(X) must be > 0.
| X | the vector object. |
| #define VectorInsert | ( | X, | |
| index, | |||
| x | |||
| ) |
Inserts an element x at the specified index of the vector X. The index must be 0 <= index < VectorSize(X).
| X | the vector object. |
| index | the position at which the element will be inserted. |
| x | the element to be inserted. |
| #define VectorInserts | ( | X, | |
| index, | |||
| src, | |||
| n | |||
| ) |
Inserts an n elements of src at the specified index of the vector X. The index must be 0 <= index < VectorSize(X).
| X | the vector object. |
| index | the position at which the elements will be inserted. |
| src | the starting address of the buffer storing elements to be inserted. |
| n | the number of elements to be inserted. |
| #define VectorErase | ( | X, | |
| index | |||
| ) |
Removes an element at the specified index of the vector X. The index must be 0 <= index < VectorSize(X).
| X | the vector object. |
| index | the position of the element to be removed. |
| #define VectorErases | ( | X, | |
| index, | |||
| n | |||
| ) |
Removes an n elements at the specified index of the vector X. The index must be 0 <= index < VectorSize(X) - n + 1.
| X | the vector object. |
| index | the starting position of the elements to be removed. |
| n | the number of elements to be removed. |
1.8.14