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

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.

本站文档由 北京智网畅联科技有限公司 整理、翻译并提供 · Documentation compiled and provided by Beijing ZNetLink Technology Co., Ltd.

交流群 · QQ Group:OPNET/智网妙算网络仿真交流群(群号 486383494)

原文档 © 2017 Riverbed Technology · 本站为公益翻译,由 AI 辅助完成,请仔细甄别

Original documentation © 2017 Riverbed Technology. Community translation, AI-assisted. Contact: jiazequn@znetlink.com