Vector class

Homepage Containers

Introduction

The Vector class is designed to be a dynamic array (an Array that grows as needed)

Structure

  1. "Class values"
  2. Size - number of objects the Vector currently holds.
  3. Capacity - number of objects the Vector can hold.
  4. Capacity increment - amount the capacity is automatically incremented when its size becomes greater than its capacity. Specify 0 (the default) to double the capacity each time.
  5. Vector data - an array to store the Vector's elements

Vector implements the List interface.

Functions

New and Destroy

Vector_new(InitialCapacity = 10, CapacityIncrement = 0):
Creates an empty Vector object with the specified initial capacity and capacity increment.

Vector_new1(ListObject):
Creates a new Vector object containing the elements of the specified List object.

Vector_destroy(VectorObject):
Destroys the Vector object and frees its memory.

Miscellaneous functions

Vector_add(VectorObject, object)
Vector_add(VectorObject, index, object):
Inserts the object at the specified position.

Vector_addAll(VectorObject, list)
Vector_addAll(VectorObject, index, list):
Inserts all the elements in the specified List to this List at the specified position.

Vector_clear(VectorObject):
Destroys (and removes) each item in the Vector, setting the new size to zero.

Size functions

Vector_size(VectorObject):
Returns the number of elements in the Vector object.

Vector_capacity(VectorObject):
Returns the number of elements the Vector object can hold.

Getters

Vector_get(VectorObject, index, useFunction = ""):
Returns the value for the object stored in the Vector at the specified position.

Vector_getAddress(VectorObject, index, useFunction = ""):
Returns the address for the object stored in the Vector at the specified position.

Setters

Vector_set(VectorObject, index, object = 0):
Destroys the element stored at the specified position in the Vector object, and replaces it with the new object.

Vector_replace(VectorObject, index, object = 0):
Replaces the element stored at the specified position with the new object.


Vector_remove(VectorObject, index):
Destroys the element stored at the specific position in the Vector object, and removes it.

Vector_discard(VectorObject, index):
Removes (without destroying) the element stored at the specific position.

Search functions

Functions that start with an "S", by default, are case-sensitive. They are functionally equivalent to the respective function (the one without the "S") with true passed for the CaseSensitive parameter. They are provided for a convenient way to perform case-sensitive matching.

Functions that start with "regex" use a regular expression, instead of a value, to perform the matching. Apart from this, they are functionally equivalent to the respective function (the one without the "regex").


Vector_indexOf(VectorObject, searchValue, startIndex = 1, useFunction = "getValue", CaseSensitive = false):
Searches for the first occurrence, starting with startIndex, for which the specified function returns the search value, and returns the index for this element.

Vector_SindexOf(VectorObject, searchValue, startIndex = 1, useFunction = "getValue", CaseSensitive = true):
Searches for the first occurrence, starting with startIndex, for which the specified function returns the search value, and returns the index for this element.

Vector_regexIndexOf(VectorObject, compareRegEx, startIndex = 1, useFunction = "getValue"):
Searches for the first occurrence, starting with startIndex, for which the specified function's return matches compareRegEx, and returns the index for this element.


Vector_findObject(VectorObject, searchObject, startIndex = 1):
Searches for the first occurrence, starting with startIndex, of the specified object, and returns the index for this element.

Vector_firstUnset(VectorObject, startIndex = 1):
Searches for the first occurrence of an unset element, and returns the index for this element.


Vector_findMatch(VectorObject, searchValue, startIndex = 1, useFunction = "getValue", CaseSensitive = false):
Searches for the first occurrence, starting with startIndex, for which the specified function returns the search value, and returns the address for this element.

Vector_SfindMatch(VectorObject, searchValue, startIndex = 1, useFunction = "getValue", CaseSensitive = true):
Searches for the first occurrence, starting with startIndex, for which the specified function returns the search value, and returns the address for this element.

Vector_regexFindMatch(VectorObject, compareRegEx, startIndex = 1, useFunction = "getValue"):
Searches for the first occurrence, starting with startIndex, for which the specified function's return matches compareRegEx, and returns the address for this element.



Vector_lastIndexOf(VectorObject, searchValue, startIndex = 0, useFunction = "getValue", CaseSensitive = false):
Searches for the last occurrence, starting with startIndex, for which the specified function returns the search value, and returns the index for this element.

Vector_SlastIndexOf(VectorObject, searchValue, startIndex = 0, useFunction = "getValue", CaseSensitive = true):
Searches for the last occurrence, starting with startIndex, for which the specified function returns the search value, and returns the index for this element.

Vector_regexLastindexOf(VectorObject, compareRegEx, startIndex = 0, useFunction = "getValue"):
Searches for the last occurrence, starting with startIndex, for which the specified function's return matches compareRegEx, and returns the index for this element.


Vector_findLastObject(VectorObject, searchObject, startIndex = 0):
Searches for the last occurrence, starting with startIndex, of the specified object, and returns the index for this element.

Vector_lastUnset(VectorObject, startIndex = 0):
Searches for the last occurrence of an unset element, and returns the index for this element.


Vector_findLastMatch(VectorObject, searchValue, startIndex = 0, useFunction = "getValue", CaseSensitive = false):
Searches for the last occurrence, starting with startIndex, for which the specified function returns the search value, and returns the address for this element.

Vector_SfindLastMatch(VectorObject, searchValue, startIndex = 0, useFunction = "getValue", CaseSensitive = true):
Searches for the last occurrence, starting with startIndex, for which the specified function returns the search value, and returns the address for this element.

Vector_regexFindLastMatch(VectorObject, compareRegEx, startIndex = 0, useFunction = "getValue"):
Searches for the last occurrence, starting with startIndex, for which the specified function's return matches compareRegEx, and returns the address for this element.


Homepage  |  Containers