Namespace buckets.arrays
Contains various functions for manipulating arrays.
Constructor Name and Description |
---|
Method Name and Description |
---|
buckets.arrays.contains(array, item, equalsFunction)
Returns true if the array contains the specified element.
|
buckets.arrays.copy(array)
Returns a shallow copy of the specified array.
|
buckets.arrays.equals(array1, array2, equalsFunction)
Returns true if the provided arrays are equal.
|
buckets.arrays.forEach(array, callback)
Executes the provided function once per element present in the array.
|
buckets.arrays.frequency(array, item, equalsFunction)
Returns the number of elements in the array equal
to the specified element.
|
buckets.arrays.indexOf(array, item, equalsFunction)
Returns the index of the first occurrence of the specified item
within the specified array.
|
buckets.arrays.lastIndexOf(array, item, equalsFunction)
Returns the index of the last occurrence of the specified element
within the specified array.
|
buckets.arrays.remove(array, item, equalsFunction)
Removes the first ocurrence of the specified element from the specified array.
|
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 array contains the specified element.
- Parameters:
- {*} array
- The array.
- {Object} item
- The element to search for.
- {function(Object|Object):boolean=} equalsFunction
- Optional function to check equality between two elements. Receives two arguments and returns true if they are equal.
- Returns:
- {boolean} True if the specified array contains the specified element.
<static>
{Array}
buckets.arrays.copy(array)
Returns a shallow 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 provided arrays are equal.
Two arrays are considered equal if both contain the same number
of elements and all corresponding pairs of elements
are equal and are in the same order.
- Parameters:
- {Array} array1
- {Array} array2
- {function(Object|Object):boolean=} equalsFunction
- Optional function to check equality between two elements. Receives two arguments and returns true if they are equal.
- Returns:
- {boolean} True if the two arrays are equal.
<static>
buckets.arrays.forEach(array, callback)
Executes the provided function once per element present in the array.
- Parameters:
- {Array} array
- The array.
- {function(Object):*} callback
- Function to execute, invoked with an element as argument. To break the iteration you can optionally return false in the callback.
<static>
{number}
buckets.arrays.frequency(array, item, equalsFunction)
Returns the number of elements in the array equal
to the specified element.
- Parameters:
- {Array} array
- The array.
- {Object} item
- The element.
- {function(Object|Object):boolean=} equalsFunction
- Optional function to check equality between two elements. Receives two arguments and returns true if they are equal.
- Returns:
- {number} The number of elements in the specified array. equal to the specified item.
<static>
{number}
buckets.arrays.indexOf(array, item, equalsFunction)
Returns the index of the first occurrence of the specified item
within the specified array.
- Parameters:
- {*} array
- The array.
- {*} item
- The element to search for.
- {function(Object|Object):boolean=} equalsFunction
- Optional function to check equality between two elements. Receives two arguments and returns true if they are equal.
- Returns:
- {number} The index of the first occurrence of the specified element or -1 if not found.
<static>
{number}
buckets.arrays.lastIndexOf(array, item, equalsFunction)
Returns the index of the last occurrence of the specified element
within the specified array.
- Parameters:
- {*} array
- The array.
- {Object} item
- The element to search for.
- {function(Object|Object):boolean=} equalsFunction
- Optional function to check equality between two elements. Receives two arguments and returns true if they are equal.
- Returns:
- {number} The index 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.
- {*} item
- The element to remove.
- {function(Object|Object):boolean=} equalsFunction
- Optional function to check equality between two elements. Receives two arguments and returns true if they are equal.
- 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.
- {number} i
- The index of the first element.
- {number} j
- The index of second element.
- Returns:
- {boolean} True if the array is defined and the indexes are valid.