Zimlet JavaScript API Reference - AjxVector

Class AjxVector


This class represents a vector.

Defined in: AjxVector.js.

Class Summary
Constructor Attributes Constructor Name and Description
 
AjxVector(array)
Creates a vector.
Method Summary
Method Attributes Method Name and Description
 
add(obj, index, noDuplicates)
Adds a object to the vector.
 
addList(list)
Adds the given array.
 
binarySearch(valueToFind, sortFunc)
Performs a binary search.
 
Clones the vector.
 
contains(obj)
Checks if the vector contains an object.
 
containsLike(obj, keyFunc)
Returns true if the vector contains the given object, using the given function to compare objects.
 
filter(func, context)
Returns an AjxVector with all the members of the given array for which the filtering function returns true.
<static>  
AjxVector.fromArray(list)
Creates a vector from a given array.
 
get(index)
Gets the object at a given index.
 
Gets an array of the vector.
 
Gets the last object in the vector.
 
getNext(obj)
Gets the next object in the vector after a given object.
 
getPrev(obj)
Gets the previous object in the vector before a given object.
 
indexOf(obj, func)
Returns the index of the obj given w/in vector
 
join(sep)
Joins the vector.
 
lastIndexOf(obj, func)
Returns the last index of the obj given w/in vector
 
lastIndexOfLike(obj, keyFunc)
Returns the last index of the obj given w/in vector
 
map(f, obj)
Return a new AjxVector which contains the results of calling f (optionally in the context obj) for each element of this array.
 
remove(obj)
Removes the object.
 
Removes all objects from vector.
 
removeAt(index)
Removes the object at the given index.
 
Removes the last object in the vector.
 
replace(index, newObj)
Replaces the object at a given index.
 
replaceObject(obj, newObj)
Replaces an object.
 
Reverses the order of the objects in the vector.
 
size()
Gets the size of the vector.
 
some(f, obj)
Return true if the given function returns true for a member of this vector, otherwise false.
 
sort(sortFunc)
Sorts the vector.
 
sub(f, obj)
Return a new AjxVector containing the elements from this vector except those for which f(el) returns true.
 
toString(sep, compress)
Returns a string representation of the object.
Class Detail
AjxVector(array)
Creates a vector.
Parameters:
array
Method Detail
add(obj, index, noDuplicates)
Adds a object to the vector.
Parameters:
{Object} obj
the object
{number} index
the index where to add
{boolean} noDuplicates
if true, confirm the object is not in vector before adding

addList(list)
Adds the given array.
Parameters:
{array} list
an array

{number} binarySearch(valueToFind, sortFunc)
Performs a binary search.
Parameters:
{Object} valueToFind
the value
{function} sortFunc
the sort function
Returns:
{number} the index

{AjxVector} clone()
Clones the vector.
Returns:
{AjxVector} the new vector

{boolean} contains(obj)
Checks if the vector contains an object.
Parameters:
{Object} obj
the object
Returns:
{boolean} true if the object is found

{boolean} containsLike(obj, keyFunc)
Returns true if the vector contains the given object, using the given function to compare objects. The comparison function should return a type for which the equality test (==) is meaningful, such as a string or a base type.
Parameters:
{Object} obj
the object being looked for
{function} keyFunc
a function for transforming objects
Returns:
{boolean} true if the object is found

{Array} filter(func, context)
Returns an AjxVector with all the members of the given array for which the filtering function returns true.
Parameters:
{Function} func
filtering function
{Object} context
scope for filtering function
Returns:
{Array} array of members for which the filtering function returns true

<static> {AjxVector} AjxVector.fromArray(list)
Creates a vector from a given array.
Parameters:
{array} list
an array
Returns:
{AjxVector} the vector

{Object} get(index)
Gets the object at a given index.
Parameters:
{number} index
the index
Returns:
{Object} the object or null if not found

{array} getArray()
Gets an array of the vector.
Returns:
{array} an array

{Object} getLast()
Gets the last object in the vector.
Returns:
{Object} the object or null if vector is empty

{Object} getNext(obj)
Gets the next object in the vector after a given object.
Parameters:
{Object} obj
the object
Returns:
{Object} the object or null if object not found

{Object} getPrev(obj)
Gets the previous object in the vector before a given object.
Parameters:
{Object} obj
the object
Returns:
{Object} the object or null if object not found

{number} indexOf(obj, func)
Returns the index of the obj given w/in vector
Parameters:
{Object} obj
the object being looked for
{function} func
(optional) a function for transforming objects
Returns:
{number} the index or -1 if not found

{string} join(sep)
Joins the vector.
Parameters:
{string} sep
the string separator
Returns:
{string} a string representation of the vector

{number} lastIndexOf(obj, func)
Returns the last index of the obj given w/in vector
Parameters:
{Object} obj
the object being looked for
{function} func
(optional) a function for transforming objects
Returns:
{number} the index or -1 if not found

{number} lastIndexOfLike(obj, keyFunc)
Returns the last index of the obj given w/in vector
Parameters:
{Object} obj
the object being looked for
{function} keyFunc
a function for transforming objects
Returns:
{number} the index or -1 if not found

{AjxVector} map(f, obj)
Return a new AjxVector which contains the results of calling f (optionally in the context obj) for each element of this array.
  • If "f" is a string, then for each element el:
    • if el[f] is a function, call el[f] and push the result in the returned array.
    • otherwise push el[f]
Parameters:
{function} f
the function
{Object} obj
the obj context
Returns:
{AjxVector} the resulting vector

{boolean} remove(obj)
Removes the object.
Parameters:
{Object} obj
the object to remove
Returns:
{boolean} true if the object is removed

removeAll()
Removes all objects from vector.

{Object} removeAt(index)
Removes the object at the given index.
Parameters:
{number} index
the index
Returns:
{Object} the object at the index or null if no object at index

removeLast()
Removes the last object in the vector.

{Object} replace(index, newObj)
Replaces the object at a given index.
Parameters:
{number} index
the index
{Object} newObj
the new object
Returns:
{Object} the old object

{Object} replaceObject(obj, newObj)
Replaces an object.
Parameters:
{Object} obj
the object to replace
{Object} newObj
the new object
Returns:
{Object} the replaced object or null if not replaced

reverse()
Reverses the order of the objects in the vector.

{number} size()
Gets the size of the vector.
Returns:
{number} the size

some(f, obj)
Return true if the given function returns true for a member of this vector, otherwise false.
Parameters:
{function} f
the function
{Object} obj
the obj context

sort(sortFunc)
Sorts the vector.
Parameters:
{function} sortFunc
the function

{AjxVector} sub(f, obj)
Return a new AjxVector containing the elements from this vector except those for which f(el) returns true. Otherwise said, "SUBtracts" from this vector those elements for which f(el) returns true.
Parameters:
{function} f
the function
{Object} obj
the obj context
Returns:
{AjxVector} the resulting vector

{string} toString(sep, compress)
Returns a string representation of the object.
Parameters:
{string} sep
the seperator
{boolean} compress
if true, compress
Returns:
{string} a string representation of the object

Documentation generated by JsDoc Toolkit 2.3.0 on Tue Jun 28 2016 21:01:30 GMT-0400 (EDT)