nape.geom.RayResultList

type
class
Nape list of RayResult type objects

Internally this list is at present implemented as a linked list with object pooled nodes and iterators with various fast paths made for standard access patterns (For instance accessing successive elements runs in constant time when using random access functions)

Iteration of this list can be done in various ways, but the preferred way on all targets, is through use of the foreach function:
list.foreach(function (obj) {
});
This method is inlined so that in haxe no closure will need to be created.

In AS3, a closure would need to be created in general, so for performance reasons you 'may' choose to use iteration as follows:
for (var i:int = 0; i < list.length; i++) {
    var obj:RayResult = list.at(i);
}

NOTE: It is 'not' safe to modify a list whilst iterating over it. If you wish to remove elements during an iteration you should use the filter method, for example:
list.filter(function (obj) {
    // operate on object.
    // ...
    return (false if you want object to be removed);
});


In AS3, if you wish to avoid a closure generation, you can perform such an iteration in a safe manner as follows:
var i:int = 0;
while (i < list.length) {
    var obj:RayResult = list.at(i);
    // operate on object.
    // ...
    if (should remove obj) {
        list.remove(obj);
        continue;
    }
    else i++;
}
Or if you are always clearing the list entirely you could write:
while (!list.empty()) {
    var obj:RayResult = list.pop();
    // operate on object.
    // ...
}

Static Methods

static function fromArray(array:Array<RayResult>):RayResultList

+ Convert standard Array to Nape list.

static function fromVector(vector:flash.Vector<RayResult>):RayResultList

+ Convert flash.Vector to Nape list.

Constructor

function new()
Construct a new list.

Instance Properties

readonly var length : Int

Length of list.

Instance Methods

inline function add(obj:RayResult):Bool

+ Insert element into list in most effecient way.

function at(index:Int):RayResult

+ Random access to elements of list by index.

function clear():Void

Clear the list, removing all elements.

function copy(deep:Bool = null):RayResultList

+ Produce a possibly deep copy of list.

inline function empty():Bool

+ Test if list is empty or not.

function filter(lambda:RayResult -> Bool):RayResultList

+ Iterate over list filtering elements.

inline function foreach(lambda:RayResult -> Void):RayResultList

+ Iterate over list applying function.

function has(obj:RayResult):Bool

+ Check if element is already in the list

inline function iterator():RayResultIterator

+ Return Haxe iterator for list.

function merge(xs:RayResultList):Void

+ Merge given list into this one.

function pop():RayResult

+ Pop element from back of list.

function push(obj:RayResult):Bool

+ Push element to back of list.

function remove(obj:RayResult):Bool

+ Remove element from list.

function shift():RayResult

+ Pop element from front of list.

function unshift(obj:RayResult):Bool

+ Push element to front of list.