Phaser. ArraySet

new ArraySet(list)

ArraySet is a Set data structure (items must be unique within the set) that also maintains order. This allows specific items to be easily added or removed from the Set.

Item equality (and uniqueness) is determined by the behavior of Array.indexOf.

This used primarily by the Input subsystem.

Parameters:
Name Type Argument Default Description
list any[] <optional>
(new array)

The backing array: if specified the items in the list must be unique, per Array.indexOf, and the ownership of the array should be relinquished to the ArraySet.

Source - utils/ArraySet.js, line 19

Members

first :any

Returns the first item and resets the cursor to the start.

Source - utils/ArraySet.js, line 176

list :any[]

The backing array.

Type:
  • any[]
Source - utils/ArraySet.js, line 32

next :any

Returns the the next item (based on the cursor) and advances the cursor.

Source - utils/ArraySet.js, line 201

position :integer

Current cursor position as established by first and next.

Default Value:
  • 0
Source - utils/ArraySet.js, line 26

total :integer

Number of items in the ArraySet. Same as list.length.

Source - utils/ArraySet.js, line 162

Methods

add(item) → {any}

Adds a new element to the end of the list. If the item already exists in the list it is not moved.

Parameters:
Name Type Description
item any

The element to add to this list.

Returns:
any -

The item that was added.

Source - utils/ArraySet.js, line 38

callAll(key, parameter)

Calls a function on all members of this list, using the member as the context for the callback.

If the key property is present it must be a function. The function is invoked using the item as the context.

Parameters:
Name Type Argument Description
key string

The name of the property with the function to call.

parameter * <repeatable>

Additional parameters that will be passed to the callback.

Source - utils/ArraySet.js, line 134

exists(item) → {boolean}

Checks for the item within this list.

Parameters:
Name Type Description
item any

The element to get the list index for.

Returns:
boolean -

True if the item is found in the list, otherwise false.

Source - utils/ArraySet.js, line 70

getIndex(item) → {integer}

Gets the index of the item in the list, or -1 if it isn't in the list.

Parameters:
Name Type Description
item any

The element to get the list index for.

Returns:
integer -

The index of the item or -1 if not found.

Source - utils/ArraySet.js, line 57

remove(item) → {any}

Removes the given element from this list if it exists.

Parameters:
Name Type Description
item any

The item to be removed from the list.

Returns:
any -

item - The item that was removed.

Source - utils/ArraySet.js, line 94

reset()

Removes all the items.

Source - utils/ArraySet.js, line 83

setAll(key, value)

Sets the property key to the given value on all members of this list.

Parameters:
Name Type Description
key any

The propety of the item to set.

value any

The value to set the property to.

Source - utils/ArraySet.js, line 113
Phaser Copyright © 2012-2014 Photon Storm Ltd.
Documentation generated by JSDoc 3.3.0-dev on Thu Dec 04 2014 11:32:27 GMT-0000 (GMT) using the DocStrap template.