#include <stddef.h>
#include <stdlib.h>
Go to the source code of this file.
◆ vector_t
typedef struct vector_t vector_t 
◆ vector_at()
void ** vector_at 
( 
vector_t *  v, 


size_t  idx ) 
Return a pointer to where the vector element at 'idx' is stored. This can be used to set the value of the element or to read it. If the index is past the end of the vector, then the vector is automatically expanded and filled with NULL pointers as needed. If no element at idx
has been previously set, then the value pointed to by the returned pointer will be NULL.
 Parameters

v  The vector. 
idx  The index into the vector. 
 Returns
 A pointer to the element at 'idx', which is itself a pointer.
◆ vector_free()
Free the memory held by the given vector, invalidating it.
 Parameters

◆ vector_new()
vector_t vector_new 
( 
size_t  initial_capacity  ) 

Allocate and initialize a new vector.
 Parameters

initial_capacity  The desired initial capacity to allocate. Must be more than 0 
Allocate and initialize a new vector.
 Parameters

initial_capacity  The desired initial capacity to allocate. 
◆ vector_pop()
Remove and return some pointer that is contained in the given vector, or return NULL if the given vector is empty.
 Parameters

◆ vector_push()
void vector_push 
( 
vector_t *  v, 


void *  element ) 
Add the given element to the vector. The given element should be nonnull.
 Parameters

v  A vector that is to grow. 
element  An element that the vector should contain. 
Add the given element to the vector.
 Parameters

v  A vector that is to grow. 
element  An element that the vector should contain. 
◆ vector_pushall()
void vector_pushall 
( 
vector_t *  v, 


void **  array, 


size_t  size ) 
Add all elements of the given array to the vector. Elements should be nonnull.
 Parameters

v  A vector that is to grow. 
array  An array of items to be added to the vector. 
size  The size of the given array. 
◆ vector_size()
Return the size of the vector.
 Parameters

 Returns
 size_t The size of the vector.
◆ vector_vote()
Vote on whether this vector should be given less memory. If v
contains few elements, it becomes more likely to shrink.
It is suggested that this function be called when the number of elements in v
reaches a local maximum.
 Parameters
