Vector
Description
The Vector class lets you access and manipulate a vector. The data type of a Vector's elements is known as the Vector's base type. The base type can be any class, including built in classes and custom classes. The base type is specified when declaring a Vector variable as well as when creating an instance by calling the class constructor.
API overview
Constructor
Constants
Constants
CASEINSENSITIVE: Number |
static
Sorting constant - String comparison in sort will be case insensitive |
DESCENDING: Number |
static
Sorting constant - The sort will be in descending order |
NUMERIC: Number |
static
Sorting constant - Sorts the vector by numeric values instead of doing string conversion on numbers |
RETURNINDEXEDARRAY: Number |
static
Sorting constant - Original vector is unmodified by the sort, instead returns a Vector.<Number> of sorted indices |
UNIQUESORT: Number |
static
Sorting constant - Ensures that all the elements in the sort are unique, if they are not the sort function will return 0 and the original array will be unmodified |
Functions
Public functions
clear (): Void |
native Clear the Vector resizing to zero in the process |
concat ( args: Vector.<Object> ): Vector |
native Concatenates the Vectors specified in the parameters list with the elements in this Vector and creates a new Vector |
contains ( value: Object ): Boolean |
native Indicates whether or not the vector contains the value |
every ( callback: Function , thisObject: Object = null ): Boolean |
Executes a callback function for every element of a vector stopping at the first false return of the callback |
filter ( callback: Function , thisObject: Object = null ): Vector |
Executes a callback function for every element of a vector, for every true result add the element to new return Vector |
forEach ( callback: Function , thisObject: Object = null ): Void |
Executes a callback function for every element of a vector |
indexOf ( o: Object , startIndex: Number = 0 ): Number |
native Searches for an item in the Vector and returns the index position of the item |
join ( sep: String = , ): String |
Converts the elements in the Vector to strings, inserts the specified separator between the elements, concatenates them, and returns the resulting string |
lastIndexOf ( o: Object , startIndex: Number = ): Number |
Searches backwards for an item in the Vector and returns the index of the item or -1 if it can't be found |
map ( callback: Function , thisObject: Object = null ): Vector |
Executes a callback function for every element of a vector, storing the result of the call into new return Vector |
pop (): Object |
native Removes the last element from the Vector and returns that element |
push ( args: Vector.<Object> ): Number |
Adds one or more elements to the end of the Vector and returns the new length of the Vector |
pushSingle ( value: Object ): Object | native |
remove ( value: Object ): Void |
native Removes an object from the Vector |
reverse (): Vector |
Reverses the elements of a Vector, returns the original Vector |
setFixed (): Void |
native Sets the the fised length of the Vector to the current length, optimizing vector operations |
shift (): Object |
native Removes the first element from the Vector and returns that element |
slice ( startIndex: Number = 0 , endIndex: Number = 16777215 ): Vector |
native Returns a new Vector that consists of a range of elements from the original Vector, without modifying the original Vector |
some ( callback: Function , thisObject: Object = null ): Boolean |
Executes a callback function for every element of a vector stopping at the first true return of the callback |
sort ( sortBehavior: Object = 0 ): Object |
native Sorts the elements in the Vector |
splice ( startIndex: Number , deleteCount: Number , items: Vector.<Object> ): Vector |
native Adds elements to and removes elements from the Vector |
unshift ( args: Vector.<Object> ): Number |
Adds one or more elements to the beginning of the vector, shifting the other elements to the right |
Constructor
Vector ( size: Number = 0 )
Attributes
Constants
CASEINSENSITIVE: Number
static
Sorting constant - String comparison in sort will be case insensitive.
NUMERIC: Number
static
Sorting constant - Sorts the vector by numeric values instead of doing string conversion on numbers.
RETURNINDEXEDARRAY: Number
static
Sorting constant - Original vector is unmodified by the sort, instead returns a Vector.<Number> of sorted indices.
UNIQUESORT: Number
static
Sorting constant - Ensures that all the elements in the sort are unique, if they are not the sort function will return 0 and the original array will be unmodified.
Functions
concat ( args: Vector.<Object> ): Vector
native
Concatenates the Vectors specified in the parameters list with the elements in this Vector and creates a new Vector.
Parameters
args: Vector.<Object> | A Vector with the same base type as this Vector that contains the elements from this Vector followed by elements from the Vectors in the parameters list. |
contains ( value: Object ): Boolean
native
Indicates whether or not the vector contains the value.
@note This has been updated to work for numbers/string/etc, but untested.
Parameters
value: Object | The value to query. |
Returns
Boolean | True if the value is contained by the Vector, false otherwise. |
every ( callback: Function , thisObject: Object = null ): Boolean
Executes a callback function for every element of a vector stopping at the first false return of the callback.
Parameters
callback: Function | A callback in the form of function(item:Object, index:Number, v:Vector):Boolean which will be called on each element of the vector. |
thisObject: Object = null | is the callback is an instance method and not a local or static function, thisObject must be specified. |
filter ( callback: Function , thisObject: Object = null ): Vector
Executes a callback function for every element of a vector, for every true result add the element to new return Vector
Parameters
callback: Function | A callback in the form of function(item:Object, index:Number, v:Vector):Boolean which will be called on each element of the vector |
thisObject: Object = null | is the callback is an instance method and not a local or static function, thisObject must be specified |
Returns
Vector | Returns a new Vector with elements from the original vector which pass the callback function test |
forEach ( callback: Function , thisObject: Object = null ): Void
Executes a callback function for every element of a vector
Parameters
callback: Function | A callback in the form of function(item:Object, index:Number, v:Vector):Void which will be called on each element of the vector |
thisObject: Object = null | is the callback is an instance method and not a local or static function, thisObject must be specified |
getFullTypeName
(): String
Inherited from Object
native
Gets the fully qualified type name of the Object. The fully qualified type name includes the package of the type.
Returns
String | fully qualified type name of the Object. |
getType
(): Type
Inherited from Object
native
Gets the Type that describes the Object.
Returns
Type | The Type that describes the object. |
getTypeName
(): String
Inherited from Object
native
Gets the type name of the Object.
Returns
String | type name of the Object. |
indexOf ( o: Object , startIndex: Number = 0 ): Number
native
Searches for an item in the Vector and returns the index position of the item.
Parameters
o: Object | The item to find in the Vector. |
startIndex: Number = 0 | The location in the Vector from which to start searching for the item. If this parameter is negative, it is treated as length + fromIndex, meaning the search starts -fromIndex items from the end and searches from that position forward to the end of the Vector. |
join ( sep: String = , ): String
Converts the elements in the Vector to strings, inserts the specified separator between the elements, concatenates them, and returns the resulting string.
Parameters
sep: String = , |
lastIndexOf ( o: Object , startIndex: Number = ): Number
Searches backwards for an item in the Vector and returns the index of the item or -1 if it can't be found.
Parameters
o: Object | The item to find in the Vector. |
startIndex: Number = | The index of the vector to start the search. If no startIndex is given, the search begins at the last element of the vector. |
map ( callback: Function , thisObject: Object = null ): Vector
Executes a callback function for every element of a vector, storing the result of the call into new return Vector
Parameters
callback: Function | A callback in the form of function(item:Object, index:Number, v:Vector):Boolean which will be called on each element of the vector |
thisObject: Object = null | is the callback is an instance method and not a local or static function, thisObject must be specified |
Returns
Vector | Returns a new Vector with elements are the return values of the callback, the vector will have the same number of elements as the source Vector |
pop (): Object
native
Removes the last element from the Vector and returns that element.
Returns
Object | The value of the last element in the specified Vector. |
push ( args: Vector.<Object> ): Number
Adds one or more elements to the end of the Vector and returns the new length of the Vector.
Parameters
args: Vector.<Object> | Arbitrary list of items to add to the Vector. |
Returns
Number | The new length of the Vector. |
remove ( value: Object ): Void
native
Removes an object from the Vector.
Parameters
value: Object | The value to remove. |
setFixed (): Void
native
Sets the the fised length of the Vector to the current length, optimizing vector operations.
shift (): Object
native
Removes the first element from the Vector and returns that element. The remaining Vector elements are moved from their original position, i, to i - 1.
Returns
Object | The first element in the Vector. |
slice ( startIndex: Number = 0 , endIndex: Number = 16777215 ): Vector
native
Returns a new Vector that consists of a range of elements from the original Vector, without modifying the original Vector.
Parameters
startIndex: Number = 0 | A number specifying the index of the starting point for the slice. If startIndex is a negative number, the starting point begins at the end of the Vector, where -1 is the last element. |
endIndex: Number = 16777215 | A number specifying the index of the ending point for the slice. If you omit this parameter, the slice includes all elements from the starting point to the end of the Vector. If endIndex is a negative number, the ending point is specified from the end of the Vector, where -1 is the last element. |
some ( callback: Function , thisObject: Object = null ): Boolean
Executes a callback function for every element of a vector stopping at the first true return of the callback
Parameters
callback: Function | A callback in the form of function(item:Object, index:Number, v:Vector):Boolean which will be called on each element of the vector |
thisObject: Object = null | is the callback is an instance method and not a local or static function, thisObject must be specified |
sort ( sortBehavior: Object = 0 ): Object
native
Sorts the elements in the Vector.
or a sorting function in the form of function (x:Object, y:Object):Number where x/y can be of any type, sort function should return 0 on equality, 1 on x>y and -1 on x<y.
By default, Array.sort() sorts in the following manner:
Sorting is case-sensitive (Z precedes a). Sorting is ascending (a precedes b). The array is modified to reflect the sort order; multiple elements that have identical sort fields are placed consecutively in the sorted array in no particular order. All elements, regardless of data type, are sorted as if they were strings, so 100 precedes 99, because "1" is a lower string value than "9".
Parameters
sortBehavior: Object = 0 | Either a bitwise or of sorting constants (CASEINSENSITIVE, DESCENDING, UNIQUESORT, RETURNINDEXEDARRAY, NUMERIC) |
splice ( startIndex: Number , deleteCount: Number , items: Vector.<Object> ): Vector
native
Adds elements to and removes elements from the Vector. This method modifies the Vector without making a copy.
Parameters
startIndex: Number | An integer that specifies the index of the element in the Vector where the insertion or deletion begins. You can use a negative integer to specify a position relative to the end of the Vector (for example, -1 for the last element of the Vector). |
deleteCount: Number | An integer that specifies the number of elements to be deleted. This number includes the element specified in the startIndex parameter. If you do not specify a value for the deleteCount parameter, the method deletes all of the values from the startIndex element to the last element in the Vector. (The default value is uint.MAX_VALUE.) If the value is 0, no elements are deleted. |
items: Vector.<Object> | An optional list of one or more comma-separated values to insert into the Vector at the position specified in the startIndex parameter. |
Returns
Vector | A Vector containing the elements that were removed from the original Vector. |