Packageorg.as3collections.lists
Classpublic class UniqueSortedList
InheritanceUniqueSortedList Inheritance UniqueList Inheritance UniqueCollection Inheritance Object
Implements ISortedList

UniqueSortedList works as a wrapper for a ISortedList object. It does not allow duplicated elements in the collection. It stores the wrapList constructor's argument in the wrappedList variable. So every method call to this class is forwarded to the wrappedList object. The methods that need to be checked for duplication are previously validated before forward the call. No error is thrown by the validation of duplication. The calls that are forwarded to the wrappedList returns the return of the wrappedList call.

You can also create unique and typed sorted lists. See below the link "ListUtil.getUniqueTypedSortedList()".

View the examples

See also

ListUtil.getUniqueSortedList()
ListUtil.getUniqueTypedSortedList()


Public Properties
 PropertyDefined By
 InheritedallEquatable : Boolean
[read-only] Indicates whether all elements in this collection implement the interface org.as3coreaddendum.system.IEquatable.
UniqueCollection
  comparator : IComparator
Defines the wrappedList comparator object to be used automatically to sort.
UniqueSortedList
 InheritedmodCount : int
[read-only] Returns the return of the call wrappedList.modCount.
UniqueList
  options : uint
Defines the wrappedList options to be used automatically to sort.
UniqueSortedList
Public Methods
 MethodDefined By
  
Constructor, creates a new TypedList object.
UniqueSortedList
 Inherited
add(element:*):Boolean
If wrappedCollection.contains(element) returns true, then this method returns false.
UniqueCollection
 Inherited
addAll(collection:ICollection):Boolean
If the specified collection is empty returns false.
UniqueCollection
 Inherited
addAllAt(index:int, collection:ICollection):Boolean
If the specified collection is empty returns false.
UniqueList
 Inherited
addAt(index:int, element:*):Boolean
If wrappedList.contains(element) returns true then returns false.
UniqueList
 Inherited
clear():void
Forwards the call to wrappedCollection.clear.
UniqueCollection
  
clone():*
[override] Creates and return a new UniqueSortedList object with the clone of the wrappedMap object.
UniqueSortedList
 Inherited
contains(o:*):Boolean
Forwards the call to wrappedCollection.contains.
UniqueCollection
 Inherited
containsAll(collection:ICollection):Boolean
Forwards the call to wrappedCollection.containsAll.
UniqueCollection
  
equals(other:*):Boolean
[override] Performs an arbitrary, specific evaluation of equality between this object and the other object.
UniqueSortedList
 Inherited
getAt(index:int):*
Forwards the call to wrappedList.getAt.
UniqueList
 Inherited
indexOf(element:*, fromIndex:int = 0):int
Forwards the call to wrappedList.indexOf.
UniqueList
 Inherited
isEmpty():Boolean
Forwards the call to wrappedCollection.isEmpty.
UniqueCollection
 Inherited
Forwards the call to wrappedCollection.iterator.
UniqueCollection
 Inherited
lastIndexOf(element:*, fromIndex:int = 0x7fffffff):int
Forwards the call to wrappedList.lastIndexOf.
UniqueList
 Inherited
Returns a list iterator of the elements in this list (in proper sequence), starting at the specified position in this list.
UniqueList
 Inherited
remove(o:*):Boolean
Forwards the call to wrappedCollection.remove.
UniqueCollection
 Inherited
removeAll(collection:ICollection):Boolean
Forwards the call to wrappedCollection.removeAll.
UniqueCollection
 Inherited
removeAt(index:int):*
Forwards the call to wrappedList.removeAt.
UniqueList
 Inherited
removeRange(fromIndex:int, toIndex:int):ICollection
Forwards the call to wrappedList.removeRange.
UniqueList
 Inherited
retainAll(collection:ICollection):Boolean
Forwards the call to wrappedCollection.retainAll.
UniqueCollection
 Inherited
reverse():void
Forwards the call to wrappedList.reverse.
UniqueList
 Inherited
setAt(index:int, element:*):*
If wrappedList.contains(element) returns true then returns false.
UniqueList
 Inherited
size():int
Forwards the call to wrappedCollection.size.
UniqueCollection
  
sort(compare:Function = null, options:uint = 0):Array
Forwards the call to wrappedList.sort.
UniqueSortedList
  
sortOn(fieldName:*, options:* = null):Array
Forwards the call to wrappedList.sortOn.
UniqueSortedList
  
subList(fromIndex:int, toIndex:int):IList
[override] Forwards the call to wrappedList.subList.
UniqueSortedList
 Inherited
toArray():Array
Forwards the call to wrappedCollection.toArray.
UniqueCollection
 Inherited
toString():String
Returns the string representation of this instance.
UniqueCollection
Property Detail
comparatorproperty
comparator:IComparator

Defines the wrappedList comparator object to be used automatically to sort.

If this value change the wrappedList is automatically reordered with the new value.


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

Defines the wrappedList options to be used automatically to sort.

If this value change the list is automatically reordered with the new value.


Implementation
    public function get options():uint
    public function set options(value:uint):void
Constructor Detail
UniqueSortedList()Constructor
public function UniqueSortedList(wrapList:ISortedList)

Constructor, creates a new TypedList object.

Parameters
wrapList:ISortedList — the target list to wrap.

Throws
ArgumentError — if the wrapList argument is null.
 
ArgumentError — if the type argument is null.
 
org.as3coreaddendum.errors:ClassCastError — if the types of one or more elements in the wrapList argument are incompatible with the type argument.
Method Detail
clone()method
override public function clone():*

Creates and return a new UniqueSortedList object with the clone of the wrappedMap object.

Returns
* — a new UniqueSortedList object with the clone of the wrappedMap object.
equals()method 
override public function equals(other:*):Boolean

Performs an arbitrary, specific evaluation of equality between this object and the other object.

This implementation considers two differente objects equal if:

This implementation takes care of the order of the elements in the list. So, for two lists are equal the order of elements returned by the iterator must be equal.

Parameters

other:* — the object to be compared for equality.

Returns
Booleantrue if the arbitrary evaluation considers the objects equal.
sort()method 
public function sort(compare:Function = null, options:uint = 0):Array

Forwards the call to wrappedList.sort.

Parameters

compare:Function (default = null)
 
options:uint (default = 0)

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

Forwards the call to wrappedList.sortOn.

Parameters

fieldName:*
 
options:* (default = null)

Returns
Array
subList()method 
override public function subList(fromIndex:int, toIndex:int):IList

Forwards the call to wrappedList.subList.

Parameters

fromIndex:int
 
toIndex:int

Returns
IList
Examples
     import org.as3collections.ISortedList;
     import org.as3collections.IListIterator;
     import org.as3collections.lists.SortedArrayList;
     import org.as3collections.lists.UniqueSortedList;
     import org.as3collections.utils.ListUtil;
     
     var l1:ISortedList = new SortedArrayList([3, 5, 1, 7], null, Array.NUMERIC);
     
     var list1:ISortedList = new UniqueSortedList(l1); // you can use this way
     
     //var list1:ISortedList = ListUtil.getUniqueSortedList(l1); // or you can use this way
     
     list1                       // [1,3,5,7]
     list1.size()                // 4
     
     list1.addAt(1, 4)           // true
     list1                       // [1,3,4,5,7]
     list1.size()                // 5
     
     list1.addAt(2, 3)           // false
     list1                       // [1,3,4,5,7]
     list1.size()                // 5
     
     list1.add(5)                // false
     list1                       // [1,3,4,5,7]
     list1.size()                // 5