Packageorg.spicefactory.lib.collection
Classpublic class List
InheritanceList Inheritance flash.utils.Proxy

Simple List implementation that overcomes the limitations of the Array API which lacks essential methods like remove. Within the Spicefactory libraries and frameworks these collections are usually only used inside the implementations, but not exposed in the public APIs.

The List class supports for and for each loops as well as bracket access for reading and writing values.



Public Methods
 MethodDefined By
  
List(items:Array = null)
Creates a new instance.
List
  
add(item:*):void
Adds the specified item to this list, appending it as the last item.
List
  
Clones this list.
List
  
contains(item:*):Boolean
Indicates whether this list contains the specified item.
List
  
Returns the first item from this list.
List
  
Returns the last item from this list.
List
  
indexOf(item:*):int
Returns the index of the specified item or -1 if it is not in this list.
List
  
insert(index:uint, item:*):void
Inserts a new item at the specified index.
List
  
isEmpty():Boolean
Indicates whether this list is empty.
List
  
remove(item:*):Boolean
Removes the specified item from this list.
List
  
removeAll():void
Removes all items from this list.
List
  
removeAt(index:uint):*
Removes and returns the item at the specified index.
List
  
Removes and returns the first item from this list.
List
  
Removes and returns the last item from this list.
List
  
size():uint
Returns the number of items in this list.
List
  
sort(compareFunction:Function, options:uint = 0):void
Sorts the elements in this list, delegating to the sort method of the underlying Array.
List
  
sortOn(propertyNames:Array, options:uint):void
Sorts the elements in this list according to the values of the specified properties, delegating to the sortOn method of the underlying Array.
List
  
toArray():Array
Returns the items of this list as an Array.
List
Constructor Detail
List()Constructor
public function List(items:Array = null)

Creates a new instance.

Parameters
items:Array (default = null) — the items to populate the list with
Method Detail
add()method
public function add(item:*):void

Adds the specified item to this list, appending it as the last item.

Parameters

item:* — the item to add to this list

clone()method 
public function clone():List

Clones this list. Modifications in the clone are not reflected in the original list and vice versa.

Returns
List — a clone of this list
contains()method 
public function contains(item:*):Boolean

Indicates whether this list contains the specified item.

Parameters

item:* — the item to check

Returns
Boolean — true if this list contains the specified item
getFirst()method 
public function getFirst():*

Returns the first item from this list.

Returns
* — the first item in this list
getLast()method 
public function getLast():*

Returns the last item from this list.

Returns
* — the last item in this list
indexOf()method 
public function indexOf(item:*):int

Returns the index of the specified item or -1 if it is not in this list.

Parameters

item:* — the item to return the index for

Returns
int — the index of the specified item or -1 if it is not in this list
insert()method 
public function insert(index:uint, item:*):void

Inserts a new item at the specified index.

Parameters

index:uint — the 0-based index to insert the item at
 
item:* — the item to insert

isEmpty()method 
public function isEmpty():Boolean

Indicates whether this list is empty.

Returns
Boolean — true if this list does not contain any items.
remove()method 
public function remove(item:*):Boolean

Removes the specified item from this list.

Parameters

item:* — the item to remove from this list

Returns
Boolean — true if this list contained the specified item
removeAll()method 
public function removeAll():void

Removes all items from this list.

removeAt()method 
public function removeAt(index:uint):*

Removes and returns the item at the specified index.

Parameters

index:uint — the index to remove an item at

Returns
* — the removed item
removeFirst()method 
public function removeFirst():*

Removes and returns the first item from this list.

Returns
* — the removed item
removeLast()method 
public function removeLast():*

Removes and returns the last item from this list.

Returns
* — the removed item
size()method 
public function size():uint

Returns the number of items in this list.

Returns
uint — the number of items in this list
sort()method 
public function sort(compareFunction:Function, options:uint = 0):void

Sorts the elements in this list, delegating to the sort method of the underlying Array.

Parameters

compareFunction:Function — a comparison function as expected by Array.sort
 
options:uint (default = 0) — one or more options as accepted by Array.sort

sortOn()method 
public function sortOn(propertyNames:Array, options:uint):void

Sorts the elements in this list according to the values of the specified properties, delegating to the sortOn method of the underlying Array.

Parameters

propertyNames:Array — a list of property names with the first element representing the primary sort field
 
options:uint — one or more options as accepted by Array.sortOn

toArray()method 
public function toArray():Array

Returns the items of this list as an Array.

Returns
Array — the items of this list as an Array