Namespace buckets.arrays
Contains various functions for manipulating arrays.
Defined in: <../buckets.js>.
Constructor Attributes | Constructor Name and Description |
---|---|
Method Attributes | Method Name and Description |
---|---|
<static> |
buckets.arrays.contains(array, item, equalsFunction)
Returns true if the specified array contains the specified element.
|
<static> |
buckets.arrays.copy(array)
Returns shallow a copy of the specified array.
|
<static> |
buckets.arrays.equals(array1, array2, equalsFunction)
Returns true if the two specified arrays are equal to one another.
|
<static> |
buckets.arrays.forEach(array, callback)
Executes the provided function once for each element present in this array
starting from index 0 to length - 1.
|
<static> |
buckets.arrays.frequency(array, item, equalsFunction)
Returns the number of elements in the specified array equal
to the specified object.
|
<static> |
buckets.arrays.indexOf(array, item, equalsFunction)
Returns the position of the first occurrence of the specified item
within the specified array.
|
<static> |
buckets.arrays.lastIndexOf(array, item, equalsFunction)
Returns the position of the last occurrence of the specified element
within the specified array.
|
<static> |
buckets.arrays.remove(array, item, equalsFunction)
Removes the first ocurrence of the specified element from the specified array.
|
<static> |
buckets.arrays.swap(array, i, j)
Swaps the elements at the specified positions in the specified array.
|
Method Detail
<static>
{boolean}
buckets.arrays.contains(array, item, equalsFunction)
Returns true if the specified array contains the specified element.
- Parameters:
- {*} array
- the array in which to search the element.
- {Object} item
- the element to search.
- {function(Object|Object):boolean=} equalsFunction
- optional function to check equality between 2 elements.
- Returns:
- {boolean} true if the specified array contains the specified element.
<static>
{Array}
buckets.arrays.copy(array)
Returns shallow a copy of the specified array.
- Parameters:
- {*} array
- the array to copy.
- Returns:
- {Array} a copy of the specified array
<static>
{boolean}
buckets.arrays.equals(array1, array2, equalsFunction)
Returns true if the two specified arrays are equal to one another.
Two arrays are considered equal if both arrays contain the same number
of elements, and all corresponding pairs of elements in the two
arrays are equal and are in the same order.
- Parameters:
- {Array} array1
- one array to be tested for equality.
- {Array} array2
- the other array to be tested for equality.
- {function(Object|Object):boolean=} equalsFunction
- optional function used to check equality between elemements in the arrays.
- Returns:
- {boolean} true if the two arrays are equal
<static>
buckets.arrays.forEach(array, callback)
Executes the provided function once for each element present in this array
starting from index 0 to length - 1.
- Parameters:
- {Array} array
- The array in which to iterate.
- {function(Object):*} callback
- function to execute, it is invoked with one argument: the element value, to break the iteration you can optionally return false.
<static>
{number}
buckets.arrays.frequency(array, item, equalsFunction)
Returns the number of elements in the specified array equal
to the specified object.
- Parameters:
- {Array} array
- the array in which to determine the frequency of the element.
- {Object} item
- the element whose frequency is to be determined.
- {function(Object|Object):boolean=} equalsFunction
- optional function used to check equality between 2 elements.
- Returns:
- {number} the number of elements in the specified array equal to the specified object.
<static>
{number}
buckets.arrays.indexOf(array, item, equalsFunction)
Returns the position of the first occurrence of the specified item
within the specified array.
- Parameters:
- {*} array
- the array in which to search the element.
- {Object} item
- the element to search.
- {function(Object|Object):boolean=} equalsFunction
- optional function used to check equality between 2 elements.
- Returns:
- {number} the position of the first occurrence of the specified element within the specified array, or -1 if not found.
<static>
{number}
buckets.arrays.lastIndexOf(array, item, equalsFunction)
Returns the position of the last occurrence of the specified element
within the specified array.
- Parameters:
- {*} array
- the array in which to search the element.
- {Object} item
- the element to search.
- {function(Object|Object):boolean=} equalsFunction
- optional function used to check equality between 2 elements.
- Returns:
- {number} the position of the last occurrence of the specified element within the specified array or -1 if not found.
<static>
{boolean}
buckets.arrays.remove(array, item, equalsFunction)
Removes the first ocurrence of the specified element from the specified array.
- Parameters:
- {*} array
- the array in which to search element.
- {Object} item
- the element to search.
- {function(Object|Object):boolean=} equalsFunction
- optional function to check equality between 2 elements.
- Returns:
- {boolean} true if the array changed after this call.
<static>
{boolean}
buckets.arrays.swap(array, i, j)
Swaps the elements at the specified positions in the specified array.
- Parameters:
- {Array} array
- The array in which to swap elements.
- {number} i
- the index of one element to be swapped.
- {number} j
- the index of the other element to be swapped.
- Returns:
- {boolean} true if the array is defined and the indexes are valid.