LoopableArray

p5ex~ LoopableArray

A class containing an array and several loop methods.

Constructor

new LoopableArray(initialCapacity)

Source:
Parameters:
Name Type Default Description
initialCapacity number 256

Methods

clear()

Clears the array.
Source:

get()

Returns a specific element. It is recommended to check that you are going to specify a valid index number before calling this method.
Source:
Returns:
The specified element.

getLast()

Returns the last element. It is recommended to check that this array is not empty before calling this method.
Source:
Returns:
The last element.

loop(callback)

Executes a provided function once for each array element.
Source:
Parameters:
Name Type Description
callback loopArrayCallBack

loopBackwards(callback)

Executes a provided function once for each array element in descending order.
Source:
Parameters:
Name Type Description
callback loopArrayCallBack

nestedLoopJoin(otherArray, callback)

Joins two arrays and executes a provided function once for each joined pair.
Source:
Parameters:
Name Type Description
otherArray LoopableArray
callback elementPairCallback

pop()

Removes and returns the last element. It is recommended to check that this array is not empty before calling this method.
Source:
Returns:
The last element.

push(element)

Adds one element to the end of the array and returns the new length of the array.
Source:
Parameters:
Name Type Description
element The element to add to the end of the array.

pushAll(otherLoopableArray)

Adds all elements from another LoopableArray and returns the new length of the array.
Source:
Parameters:
Name Type Description
otherLoopableArray LoopableArray

pushRawArray(array)

Adds elements to the end of the array and returns the new length of the array.
Source:
Parameters:
Name Type Description
array Array The elements to add to the end of the array.

roundRobin(callback)

Executes a provided function once for each pair within the array.
Source:
Parameters:
Name Type Description
callback elementPairCallback