A collection of nodes.

Systems within the engine access the components of entities via NodeLists. A NodeList contains a node for each Entity in the engine that has all the components required by the node. To iterate over a NodeList, start from the head and step to the next on each loop, until the returned value is null. Or just use for in syntax.

for (node in nodeList) { // do stuff }

It is safe to remove items from a nodelist during the loop. When a Node is removed form the NodeList it's previous and next properties still point to the nodes that were before and after it in the NodeList just before it was removed.

Constructor

new ()

Variables

read onlyempty:Bool

true if the list is empty, false otherwise.

read onlyhead:TNode

The first item in the node list, or null if the list contains no nodes.

read onlynodeAdded:Signal1<TNode>

A signal that is dispatched whenever a node is added to the node list.

The signal will pass a single parameter to the listeners - the node that was added.

read onlynodeRemoved:Signal1<TNode>

A signal that is dispatched whenever a node is removed from the node list.

The signal will pass a single parameter to the listeners - the node that was removed.

read onlytail:TNode

The last item in the node list, or null if the list contains no nodes.

Methods

add (node:TNode):Void

insertionSort (sortFunction:SortFunction<TNode>):Void

Performs an insertion sort on the node list. In general, insertion sort is very efficient with short lists and with lists that are mostly sorted, but is inefficient with large lists that are randomly ordered.

The sort function takes two nodes and returns an Int.

function sortFunction( node1 : MockNode, node2 : MockNode ) : Int

If the returned number is less than zero, the first node should be before the second. If it is greater than zero the second node should be before the first. If it is zero the order of the nodes doesn't matter and the original order will be retained.

This insertion sort implementation runs in place so no objects are created during the sort.

inline iterator ():GenericListIterator<TNode>

mergeSort (sortFunction:SortFunction<TNode>):Void

Performs a merge sort on the node list. In general, merge sort is more efficient than insertion sort with long lists that are very unsorted.

The sort function takes two nodes and returns an Int.

function sortFunction( node1 : MockNode, node2 : MockNode ) : Int

If the returned number is less than zero, the first node should be before the second. If it is greater than zero the second node should be before the first. If it is zero the order of the nodes doesn't matter.

This merge sort implementation creates and uses a single Vector during the sort operation.

remove (node:TNode):Void

swap (node1:TNode, node2:TNode):Void

Swaps the positions of two nodes in the list. Useful when sorting a list.