prg_vector_create()
Abstract
Creates a new vector with specified initial dimension.
Syntax
prg_vector_create (initial_size, destroy_proc, copy_proc)
| Argument | Type | Description |
|---|---|---|
initial_size |
unsigned long |
initial number of entries to provide in vector |
destroy_proc |
PrgT_Vector_Destroy_Proc |
procedure for deallocating elements in the vector |
copy_proc |
PrgT_Vector_Copy_Proc |
procedure for copying elements in the vector |
Return Type
PrgT_Vector *
Pointer to a vector that can be passed to most other functions in Prg_Vector
Header
prg_vector.h
Details
The vector is initially empty. The specified initial size is not the number of elements in the vector, but rather an initial estimate of how large the vector needs to be to contain elements that will be added. If elements are added beyond this initial size, the vector will be automatically resized, so it is not critical that the initial size be accurate. However, it is best to avoid resizing if possible, because it is computationally less efficient. The trade off, when the ultimate number of elements is unknown, is that choosing a larger value than necessary is wasteful of some memory. The initial size can be zero if desired, in which case the vector will be extended immediately when the first element is added.
The destroy procedure and copy procedure are handlers that are called by the system when the vector is destroyed or copied, respectively. The handlers provide proper treatment (copying or deallocating) for the elements stored in the vector. The prototypes for these procedures are given in PrgT_Vector_Copy_Proc and PrgT_Vector_Destroy_Proc.