Class: LinkedList

Phaser. LinkedList

new LinkedList()

A basic Linked List data structure.

This implementation modifies the prev and next properties of each item added:

  • The prev and next properties must be writable and should not be used for any other purpose.
  • Items cannot be added to multiple LinkedLists at the same time.
  • Only objects can be added.
Source:
src/utils/LinkedList.js line 18

Members

first :object

First element in the list.

Type:
  • object
Source:
src/utils/LinkedList.js line 39

last :object

Last element in the list.

Type:
  • object
Source:
src/utils/LinkedList.js line 46

next :object

Next element in the list.

Type:
  • object
Source:
src/utils/LinkedList.js line 25

prev :object

Previous element in the list.

Type:
  • object
Source:
src/utils/LinkedList.js line 32

total :integer

Number of elements in the list.

Type:
  • integer
Source:
src/utils/LinkedList.js line 53

Methods

add(item)

Adds a new element to this linked list.

Parameters:
Name Type Description
item object

The element to add to this list. Can be a Phaser.Sprite or any other object you need to quickly iterate through.

Source:
src/utils/LinkedList.js line 59
Returns:

The item that was added.

Type
object

callAll(callback)

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

Parameters:
Name Type Description
callback function

The function to call.

Source:
src/utils/LinkedList.js line 156

remove(item)

Removes the given element from this linked list if it exists.

Parameters:
Name Type Description
item object

The item to be removed from the list.

Source:
src/utils/LinkedList.js line 107

reset()

Resets the first, last, next and previous node pointers in this list.

Source:
src/utils/LinkedList.js line 92