Class PTArrayUtil
Object
|
+--PTArrayUtil
- class
PTArrayUtil
Static class containing array utility methods.
Usage:
PTArrayUtil.removeElementAt(array, 4);
Defined in PTUtil.js
Field Summary |
<static> <final> Object |
VERSION
|
Constructor Summary |
PTArrayUtil
()
PTArrayUtil static object constructor
|
Method Summary |
<static> Boolean
|
isArrayLike(arr)
Checks if an object resembles an Array, in that it is a numerically indexed list of objects.
|
<static> void
|
moveElement(arr,sourceIndex,targetIndex)
Moves an element in an array from one position to another, adjusting positions of other elements
|
<static> Number
|
push(arr,items)
Adds the arguments as new elements to the end of the Array.
|
<static> Object
|
removeElementAt(arr,index)
Remove an element from an array at a given index
|
<static> Object
|
shift(arr)
Removes first element of an array and moves other elements down one position, shortening the length of the Array by one.
|
<static> Array
|
splice(arr, start, deleteCount, variableNumberOfOtherArguments)
Inserts elements into an array at a specific index.
|
VERSION
<static> <final> Object VERSION
PTArrayUtil
PTArrayUtil()
PTArrayUtil static object constructor
isArrayLike
<static> Boolean isArrayLike(arr)
Checks if an object resembles an Array, in that it is a numerically indexed list of objects. Some objects (for example Function.arguments) which have numerically-indexed sub-objects and which have a length property are enough like Array objects that we can use them in PTArrayUtil. This method identifies such objects.
moveElement
<static> void moveElement(arr,sourceIndex,targetIndex)
Moves an element in an array from one position to another, adjusting positions of other elements
Parameters:
sourceIndex
- the index of the array element to move
targetIndex
- where to move the array element to
push
<static> Number push(arr,items)
Adds the arguments as new elements to the end of the Array. Custom implementation of Array.push for MSIE 5.0., which doesn't natively support Array.push().
Parameters:
items
- Object or array of objects to append.
removeElementAt
<static> Object removeElementAt(arr,index)
Remove an element from an array at a given index
Parameters:
index
- Index of element to remove
shift
<static> Object shift(arr)
Removes first element of an array and moves other elements down one position, shortening the length of the Array by one. Custom implementation of Array.shift for MSIE 5.0., which doesn't natively support Array.shift().
splice
<static> Array splice(arr, start, deleteCount, variableNumberOfOtherArguments)
Inserts elements into an array at a specific index. This is a custom implementation of Array.splice for MSIE 5.0., which doesn't natively support Array.splice().
Parameters:
arr
- Array to splice (Array)
start
- Start index of splice (integer)
deleteCount
- Number of items to remove (integer)
variableNumberOfOtherArguments
- Any number of arguments may be passed in here, and all will be splices into the array at the start point.
Returns:
Elements which were removed from the Array
Documentation generated by
JSDoc on Wed Aug 24 10:17:38 2005