(
items
)
- Parameters:
-
items < Array >
array of items this list will be responsible for
(
items
)
items
< Array >
array of items this list will be responsible for
protected
mixed
_item
(
i
)
item
, but is used by
methods added with ArrayList.addMethod()
.
i
< Integer >
Index of item to fetch
mixed
static
void
addMethod
(
dest
,
name
)
Adds a pass through method to dest (typically the prototype of a list class) that calls the named method on each item in the list with whatever parameters are passed in. Allows for API indirection via list instances.
Accepts a single string name or an array of string names.
list.each( function ( item ) {
item.methodName( 1, 2, 3 );
} );
// becomes
list.methodName( 1, 2, 3 );
Additionally, the pass through methods use the item retrieved by the
_item
method in case there is any special behavior that is
appropriate for API mirroring.
dest
< Object >
Object or prototype to receive the iterator method
name
< String | Array >
Name of method of methods to create
ArrayList
each
(
fn
,
context
)
Execute a function on each item of the list, optionally providing a custom execution context. Default context is the item.
The callback signature is callback( item, index )
.
fn
< Function >
the function to execute
context
< mixed >
optional override 'this' in the function
ArrayList
Integer
indexOf
(
needle
)
needle
< mixed >
The item to search for
Integer
Boolean
isEmpty
(
)
Boolean
mixed
item
(
i
)
i
< Integer >
index to fetch
mixed
Integer
size
(
)
Integer
Boolean
some
(
fn
,
context
)
Execute a function on each item of the list, optionally providing a custom execution context. Default context is the item.
The callback signature is callback( item, index )
.
Unlike each
, if the callback returns true, the
iteratation will stop.
fn
< Function >
the function to execute
context
< mixed >
optional override 'this' in the function
Boolean