Packagesystem.data.lists
Classpublic class SortedArrayList
InheritanceSortedArrayList Inheritance ArrayList Inheritance ArrayCollection Inheritance Object
Implements Sortable

A SortedArrayList stores is elements in order with a Comparator object.



Public Properties
 PropertyDefined By
  comparator : Comparator
Determinates the Comparator object used in the map to sort the entries.
SortedArrayList
 InheritedmodCount : int
This property is a protector used in the ListIterator object of this List.
ArrayList
  options : uint
Indicates the options to sort the elements in the list.
SortedArrayList
Public Methods
 MethodDefined By
  
SortedArrayList(init:* = null, comp:Comparator = null, opts:uint = 0)
Creates a new SortedArrayList instance.
SortedArrayList
  
add(o:*):Boolean
[override] Inserts an element in the collection.
SortedArrayList
  
addAll(c:Collection):Boolean
[override] Appends all of the elements in the specified collection to the end of this Collection, in the order that they are returned by the specified collection's iterator (optional operation).
SortedArrayList
  
addAt(index:uint, o:*):void
[override] Inserts the specified element at the specified position in this list (optional operation).
SortedArrayList
 Inherited
clear():void
[override] Removes all elements in the collection.
ArrayList
  
clone():*
[override] Returns a shallow copy of the instance.
SortedArrayList
 Inherited
contains(o:*):Boolean
Returns true if this collection contains the specified element.
ArrayCollection
 Inherited
Returns true if this collection contains all of the elements of the specified collection.
ArrayCollection
 Inherited
ensureCapacity(capacity:uint):void
Increases the capacity of this ArrayList instance, if necessary, to ensure that it can hold at least the number of elements specified by the minimum capacity argument.
ArrayList
 Inherited
equals(o:*):Boolean
Compares the specified object with this object for equality.
ArrayCollection
 Inherited
get(key:*):*
Returns the element from this collection at the passed key index.
ArrayCollection
 Inherited
indexOf(o:*, fromIndex:uint = 0):int
Returns the index of an element in the collection.
ArrayCollection
 Inherited
isEmpty():Boolean
Returns true if this collection contains no elements.
ArrayCollection
 Inherited
Returns the iterator reference of the object.
ArrayCollection
 Inherited
lastIndexOf(o:*, fromIndex:int = 0x7FFFFFFF):int
Returns the index in this list of the last occurrence of the specified element, or -1 if this list does not contain this element.
ArrayList
 Inherited
listIterator(position:uint = 0):ListIterator
Returns a ListIterator of the elements in this list (in proper sequence).
ArrayList
 Inherited
remove(o:*):*
[override] Removes a single instance of the specified element from this collection, if it is present (optional operation).
ArrayList
 Inherited
Removes from this Collection all the elements that are contained in the specified Collection (optional operation).
ArrayCollection
 Inherited
removeAt(id:uint, len:int = 1):*
Removes from this list all the elements that are contained between the specific id position and the end of this list (optional operation).
ArrayList
 Inherited
removeRange(fromIndex:uint, toIndex:uint):*
Removes from this List all of the elements whose index is between fromIndex, inclusive and toIndex, exclusive.
ArrayList
 Inherited
Retains only the elements in this Collection that are contained in the specified Collection (optional operation).
ArrayCollection
 Inherited
set(index:uint, o:*):*
Replaces the element at the specified position in this list with the specified element (optional operation).
ArrayList
 Inherited
size():uint
Returns the number of elements in this collection.
ArrayCollection
  
sort(compare:* = null, opts:uint = 0):Array
Sorts the elements in the list.
SortedArrayList
  
sortOn(fieldName:*, opts:* = null):Array
Sorts the elements in the list according to one or more fields in the array.
SortedArrayList
 Inherited
subList(fromIndex:uint, toIndex:uint):List
Returns a view of the portion of this list between the specified fromIndex, inclusive, and toIndex, exclusive.
ArrayList
 Inherited
toArray():Array
Returns an array containing all of the elements in this collection.
ArrayCollection
 Inherited
toSource(indent:int = 0):String
Returns the source code string representation of the object.
ArrayCollection
 Inherited
toString():String
Returns the string representation of this instance.
ArrayCollection
Property Detail
comparatorproperty
comparator:Comparator

Determinates the Comparator object used in the map to sort the entries.


Implementation
    public function get comparator():Comparator
    public function set comparator(value:Comparator):void
optionsproperty 
options:uint

Indicates the options to sort the elements in the list.


Implementation
    public function get options():uint
    public function set options(value:uint):void
Constructor Detail
SortedArrayList()Constructor
public function SortedArrayList(init:* = null, comp:Comparator = null, opts:uint = 0)

Creates a new SortedArrayList instance.

Example :

         import system.data.lists.SortedArrayList ;
         
         import system.comparators.AlphaComparator ;
         import system.comparators.NumberComparator ;
         
         trace( "-----" ) ;
         
         var list:SortedArrayList ;
         
         list = new SortedArrayList( [ 4 , 3 , 12, 24 ] ) ;
         
         trace( list ) ;
         
         list.comparator = new NumberComparator() ;
         
         trace( list ) ;
         
         trace( "-----" ) ;
         
         list = new SortedArrayList( ["pink" , "red" , "blue" , "black" ] ) ;
         
         trace( list ) ;
         
         list.sort( new AlphaComparator() ) ;
         
         trace( list ) ;
         

Parameters
init:* (default = null) — An optional Array or Collection or Iterable object to fill the collection. This parameter can be an uint value to determinates the default capacity of the list.
 
comp:Comparator (default = null) — The Comparator object used in the map to sort the entries.
 
opts:uint (default = 0) — The options to sort the elements in the list.
Method Detail
add()method
override public function add(o:*):Boolean

Inserts an element in the collection.

Parameters

o:*

Returns
Boolean
addAll()method 
override public function addAll(c:Collection):Boolean

Appends all of the elements in the specified collection to the end of this Collection, in the order that they are returned by the specified collection's iterator (optional operation).

Parameters

c:Collection

Returns
Booleantrue if this list changed as a result of the call.
addAt()method 
override public function addAt(index:uint, o:*):void

Inserts the specified element at the specified position in this list (optional operation).

Parameters

index:uint
 
o:*

clone()method 
override public function clone():*

Returns a shallow copy of the instance.

Returns
* — a shallow copy of the instance.
sort()method 
public function sort(compare:* = null, opts:uint = 0):Array

Sorts the elements in the list.

Parameters

compare:* (default = null)
 
opts:uint (default = 0)

Returns
Array
sortOn()method 
public function sortOn(fieldName:*, opts:* = null):Array

Sorts the elements in the list according to one or more fields in the array.

Parameters

fieldName:* — A string that identifies a field to be used as the sort value, or an array in which the first element represents the primary sort field, the second represents the secondary sort field, and so on.
 
opts:* (default = null) — One or more numbers or names of defined constants, separated by the bitwise OR (|) operator, that change the sorting behavior. The following values are acceptable for the options parameter:

  • Array.CASEINSENSITIVE or 1
  • Array.DESCENDING or 2
  • Array.UNIQUESORT or 4
  • Array.RETURNINDEXEDARRAY or 8
  • Array.NUMERIC or 16
  • Returns
    Array — The return value depends on whether you pass any parameters :

  • If you specify a value of 4 or Array.UNIQUESORT for the options parameter, and two or more elements being sorted have identical sort fields, a value of 0 is returned and the array is not modified.
  • If you specify a value of 8 or Array.RETURNINDEXEDARRAY for the options parameter, an array is returned that reflects the results of the sort and the array is not modified.
  • Otherwise, nothing is returned and the array is modified to reflect the sort order.