A vector is the same as an array. The main difference between TQPtrVector and TQMemArray is that TQPtrVector stores pointers to the elements, whereas TQMemArray stores the elements themselves (i.e. TQMemArray is value-based and TQPtrVector is pointer-based).
Items are added to the vector using insert() or fill(). Items are removed with remove(). You can get a pointer to an item at a particular index position using at().
.PP
Unless otherwise stated, all functions that remove items from the vector will also delete the element pointed to if auto-deletion is enabled. By default, auto-deletion is disabled; see setAutoDelete(). This behaviour can be changed in a subclass by reimplementing the virtual function deleteItem().
.PP
Functions that compare items (find() and sort() for example) will do so using the virtual function compareItems(). The default implementation of this function only compares the pointer values. Reimplement compareItems() in a subclass to get searching and sorting based on the item contents. You can perform a linear search for a pointer in the vector using findRef(), or a binary search (of a sorted vector) using bsearch(). You can count the number of times an item appears in the vector with contains() or containsRef().
In a sorted array, finds the first occurrence of \fId\fR using a binary search. For a sorted array, this is generally much faster than find(), which performs a linear search.
.PP
Returns the position of \fId\fR, or -1 if \fId\fR could not be found. \fId\fR must not be 0.
.PP
Compares items using the virtual function compareItems().
Inserts item \fId\fR in all positions in the vector. Any existing items are removed. If \fId\fR is 0, the vector becomes empty.
.PP
If \fIsize\fR >= 0, the vector is first resized to \fIsize\fR. By default, \fIsize\fR is -1.
.PP
Returns TRUE if successful, i.e. \fIsize\fR is the same as the current size, or \fIsize\fR is larger and the memory has successfully been allocated; otherwise returns FALSE.
Finds the first occurrence of item \fId\fR in the vector using a linear search. The search starts at position \fIi\fR, which must be less than size(). \fIi\fR is by default 0; i.e. the search starts at the start of the vector.
.PP
Returns the position of \fId\fR, or -1 if \fId\fR could not be found.
.PP
Compares items using the virtual function compareItems().
.PP
Use the much faster bsearch() to search a sorted vector.
Finds the first occurrence of the item pointer \fId\fR in the vector using a linear search. The search starts at position \fIi\fR, which must be less than size(). \fIi\fR is by default 0; i.e. the search starts at the start of the vector.
.PP
Returns the position of \fId\fR, or -1 if \fId\fR could not be found.
.PP
This function does \fInot\fR use compareItems() to compare items.
.PP
Use the much faster bsearch() to search a sorted vector.
Sets position \fIi\fR in the vector to contain the item \fId\fR. \fIi\fR must be less than size(). Any previous element in position \fIi\fR is removed.
Sets the collection to auto-delete its contents if \fIenable\fR is TRUE and to never delete them if \fIenable\fR is FALSE.
.PP
If auto-deleting is turned on, all the items in a collection are deleted when the collection itself is deleted. This is convenient if the collection has the only pointer to the items.
.PP
The default setting is FALSE, for safety. If you turn it on, be careful about copying the collection - you might find yourself with two collections deleting the same items.
.PP
Note that the auto-delete setting may also affect other functions in subclasses. For example, a subclass that has a remove() function will remove the item from its data structure, and if auto-delete is enabled, will also delete the item.
Returns the item at position \fIi\fR in the vector, and removes that item from the vector. \fIi\fR must be less than size(). If there is no item at position \fIi\fR, 0 is returned.
.PP
Unlike remove(), this function does \fInot\fR call deleteItem() for the removed item.