Packagecom.yworks.bridge.util
Classpublic class TreeSet
InheritanceTreeSet Inheritance AbstractSet Inheritance AbstractCollection Inheritance YObject Inheritance Object
Implements SortedSet, Clonable

TreeSet is an implementation of SortedSet. All optional operations are supported, adding and removing. The elements can be any objects which are comparable to each other either using their natural order or a specified Comparator.



Public Properties
 PropertyDefined By
  empty : Boolean
[override] [read-only] Answers if this TreeSet has no elements, a size of zero.
TreeSet
  length : int
[override] [read-only] Answers the number of elements in this TreeSet.
TreeSet
Public Methods
 MethodDefined By
  
TreeSet(init:Boolean = true)
Constructs a new empty instance of TreeSet which uses natural ordering.
TreeSet
  
addAll(collection:Collection):Boolean
[override] Adds the objects in the specified Collection to this TreeSet.
TreeSet
  
addItem(object:Object):Boolean
[override] Adds the specified object to this TreeSet.
TreeSet
  
clear():void
[override] Removes all elements from this TreeSet, leaving it empty.
TreeSet
  
clone():Object
[override] Answers a new TreeSet with the same elements, size and comparator as this TreeSet.
TreeSet
  
Answers the Comparator used to compare elements in this TreeSet.
TreeSet
 Inherited
containsAll(collection:Collection):Boolean
Searches this Collection for all objects in the specified Collection.
AbstractCollection
  
containsItem(object:Object):Boolean
[override] Searches this TreeSet for the specified object.
TreeSet
 Inherited
equals(object:Object):Boolean
[override] Compares the specified object to this Set and answer if they are equal.
AbstractSet
  
first():Object
Answers the first element in this TreeSet.
TreeSet
  
getClass():Class
[override]
TreeSet
 Inherited
hashCode():int
[override] Answers an integer hash code for the receiver.
AbstractSet
  
headSet(end:Object):SortedSet
Answers a SortedSet of the specified portion of this TreeSet which contains elements less than the end element.
TreeSet
  
[override] Answers an Iterator on the elements of this TreeSet.
TreeSet
  
last():Object
Answers the last element in this TreeSet.
TreeSet
  
[static] Constructs a new empty instance of TreeSet which uses natural ordering.
TreeSet
  
[static] Constructs a new instance of TreeSet which uses natural ordering and containing the unique elements in the specified collection.
TreeSet
  
[static] Constructs a new empty instance of TreeSet which uses the specified Comparator.
TreeSet
  
[static] Constructs a new instance of TreeSet containing the elements in the specified SortedSet and using the same Comparator.
TreeSet
 Inherited
removeAll(collection:Collection):Boolean
[override] Removes all occurrences in this Collection of each object in the specified Collection.
AbstractSet
  
removeItem(object:Object):Boolean
[override] Removes an occurrence of the specified object from this TreeSet.
TreeSet
 Inherited
retainAll(collection:Collection):Boolean
Removes all objects from this Collection that are not contained in the specified Collection.
AbstractCollection
  
subSet(start:Object, end:Object):SortedSet
Answers a SortedSet of the specified portion of this TreeSet which contains elements greater or equal to the start element but less than the end element.
TreeSet
  
tailSet(start:Object):SortedSet
Answers a SortedSet of the specified portion of this TreeSet which contains elements greater or equal to the start element.
TreeSet
 Inherited
toArray():Vector.<Object>
Answers a new array containing all elements contained in this Collection.
AbstractCollection
 Inherited
toArray2(contents:Vector.<Object>):Vector.<Object>
Answers an array containing all elements contained in this Collection.
AbstractCollection
 Inherited
toString():String
Answers the string representation of this Collection.
AbstractCollection
Protected Methods
 MethodDefined By
  
cloneImpl(o:Object):void
[override]
TreeSet
 Inherited
AbstractCollection
 Inherited
AbstractSet
  
Initializes this object.
TreeSet
  
initTreeSet2(collection:Collection):void
Initializes this object.
TreeSet
  
initTreeSet3(comparator:Comparator):void
Initializes this object.
TreeSet
  
Initializes this object.
TreeSet
Property Detail
emptyproperty
empty:Boolean  [read-only] [override]

Answers if this TreeSet has no elements, a size of zero.


Implementation
    public function get empty():Boolean

See also

lengthproperty 
length:int  [read-only] [override]

Answers the number of elements in this TreeSet.


Implementation
    public function get length():int
Constructor Detail
TreeSet()Constructor
public function TreeSet(init:Boolean = true)

Constructs a new empty instance of TreeSet which uses natural ordering.

Parameters
init:Boolean (default = true) — An internally used switch to help handle proper instance initialization in inheritance chains where classes can have multiple constructor-like factory methods. This parameter can safely be ignored/omitted when calling the constructor.
Method Detail
addAll()method
override public function addAll(collection:Collection):Boolean

Adds the objects in the specified Collection to this TreeSet.

Parameters

collection:Collection — the Collection of objects

Returns
Boolean — true if this TreeSet is modified, false otherwise

Throws
TypeError — when an object in the Collection cannot be compared with the elements in this TreeSet
 
ReferenceError — when an object in the Collection is null and the comparator cannot handle null
addItem()method 
override public function addItem(object:Object):Boolean

Adds the specified object to this TreeSet.

Parameters

object:Object — the object to add

Returns
Boolean — true when this TreeSet did not already contain the object, false otherwise

Throws
TypeError — when the object cannot be compared with the elements in this TreeSet
 
ReferenceError — when the object is null and the comparator cannot handle null
clear()method 
override public function clear():void

Removes all elements from this TreeSet, leaving it empty.

See also

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

Answers a new TreeSet with the same elements, size and comparator as this TreeSet.

Returns
Object — a shallow copy of this TreeSet

See also

cloneImpl()method 
override protected function cloneImpl(o:Object):void

Parameters

o:Object

comparator()method 
public function comparator():Comparator

Answers the Comparator used to compare elements in this TreeSet.

Returns
Comparator — a Comparator or null if the natural ordering is used
containsItem()method 
override public function containsItem(object:Object):Boolean

Searches this TreeSet for the specified object.

Parameters

object:Object — the object to search for

Returns
Boolean — true if object is an element of this TreeSet, false otherwise

Throws
TypeError — when the object cannot be compared with the elements in this TreeSet
 
ReferenceError — when the object is null and the comparator cannot handle null
first()method 
public function first():Object

Answers the first element in this TreeSet.

Returns
Object — the first element

Throws
Error — when this TreeSet is empty
getClass()method 
override public function getClass():Class

Returns
Class
headSet()method 
public function headSet(end:Object):SortedSet

Answers a SortedSet of the specified portion of this TreeSet which contains elements less than the end element. The returned SortedSet is backed by this TreeSet so changes to one are reflected by the other.

Parameters

end:Object — the end element

Returns
SortedSet — a subset where the elements are less than end

Throws
TypeError — when the end object cannot be compared with the elements in this TreeSet
 
ReferenceError — when the end object is null and the comparator cannot handle null
initTreeSet1()method 
protected final function initTreeSet1():void

Initializes this object. See the documentation of the corresponding factory method newTreeSet1() for details.

See also

initTreeSet2()method 
protected final function initTreeSet2(collection:Collection):void

Initializes this object. See the documentation of the corresponding factory method newTreeSet2() for details.

Parameters

collection:Collection

See also

initTreeSet3()method 
protected final function initTreeSet3(comparator:Comparator):void

Initializes this object. See the documentation of the corresponding factory method newTreeSet3() for details.

Parameters

comparator:Comparator

See also

initTreeSet4()method 
protected final function initTreeSet4(_set:SortedSet):void

Initializes this object. See the documentation of the corresponding factory method newTreeSet4() for details.

Parameters

_set:SortedSet

See also

iterator()method 
override public function iterator():Iterator

Answers an Iterator on the elements of this TreeSet.

Returns
Iterator — an Iterator on the elements of this TreeSet

See also

last()method 
public function last():Object

Answers the last element in this TreeSet.

Returns
Object — the last element

Throws
Error — when this TreeSet is empty
newTreeSet1()method 
public static function newTreeSet1():TreeSet

Constructs a new empty instance of TreeSet which uses natural ordering.

Returns
TreeSet
newTreeSet2()method 
public static function newTreeSet2(collection:Collection):TreeSet

Constructs a new instance of TreeSet which uses natural ordering and containing the unique elements in the specified collection.

Parameters

collection:Collection — the collection of elements to add

Returns
TreeSet

Throws
TypeError — when an element in the Collection does not implement the Comparable interface, or the elements in the Collection cannot be compared
newTreeSet3()method 
public static function newTreeSet3(comparator:Comparator):TreeSet

Constructs a new empty instance of TreeSet which uses the specified Comparator.

Parameters

comparator:Comparator — the Comparator

Returns
TreeSet
newTreeSet4()method 
public static function newTreeSet4(_set:SortedSet):TreeSet

Constructs a new instance of TreeSet containing the elements in the specified SortedSet and using the same Comparator.

Parameters

_set:SortedSet — the SortedSet of elements to add

Returns
TreeSet
removeItem()method 
override public function removeItem(object:Object):Boolean

Removes an occurrence of the specified object from this TreeSet.

Parameters

object:Object — the object to remove

Returns
Boolean — true if this TreeSet is modified, false otherwise

Throws
TypeError — when the object cannot be compared with the elements in this TreeSet
 
ReferenceError — when the object is null and the comparator cannot handle null
subSet()method 
public function subSet(start:Object, end:Object):SortedSet

Answers a SortedSet of the specified portion of this TreeSet which contains elements greater or equal to the start element but less than the end element. The returned SortedSet is backed by this TreeSet so changes to one are reflected by the other.

Parameters

start:Object — the start element
 
end:Object — the end element

Returns
SortedSet — a subset where the elements are greater or equal to start and less than end

Throws
TypeError — when the start or end object cannot be compared with the elements in this TreeSet
 
ReferenceError — when the start or end object is null and the comparator cannot handle null
tailSet()method 
public function tailSet(start:Object):SortedSet

Answers a SortedSet of the specified portion of this TreeSet which contains elements greater or equal to the start element. The returned SortedSet is backed by this TreeSet so changes to one are reflected by the other.

Parameters

start:Object — the start element

Returns
SortedSet — a subset where the elements are greater or equal to start

Throws
TypeError — when the start object cannot be compared with the elements in this TreeSet
 
ReferenceError — when the start object is null and the comparator cannot handle null