Packagecom.yworks.yfiles.util
Classpublic class Comparators
InheritanceComparators Inheritance YObject Inheritance Object

This class provides access to some Comparator instances that are commonly used in yFiles.



Public Methods
 MethodDefined By
  
Comparators(init:Boolean = true)
Comparators
  
compare(i1:int, i2:int):int
[static] Compares the specified integral numbers.
Comparators
  
[static] Compares the specified integral numbers.
Comparators
  
compare3(f1:Number, f2:Number):int
[static] Compares the specified floating point numbers.
Comparators
  
compare4(d1:Number, d2:Number):int
[static] Compares the specified floating point numbers.
Comparators
  
[static] Returns a comparator that compares to Objects of type Comparable.
Comparators
  
[static] Returns a comparator that compares objects of arbitrary type.
Comparators
  
[static] Returns a comparator that compares objects of arbitrary type.
Comparators
  
[static] Returns a comparator that compares objects of type com.yworks.yfiles.base.Edge.
Comparators
  
[static] Returns a comparator that compares objects of type com.yworks.yfiles.base.Edge.
Comparators
  
[static] Returns a comparator that compares objects of arbitrary type.
Comparators
  
[static] Returns a comparator that compares objects of type com.yworks.yfiles.base.Edge.
Comparators
  
[static] Returns a comparator that compares objects of type com.yworks.yfiles.base.Edge.
Comparators
 Inherited
equals(o:Object):Boolean
YObject
  
getClass():Class
[override]
Comparators
 Inherited
hashCode():int
YObject
  
[static]
Comparators
  
sort(data:List, c:Comparator):void
[static] Sorts the specified list of objects according to the order induced by the specified comparator.
Comparators
  
sort2(data:Vector.<Object>, c:Comparator):void
[static] Sorts the specified array of objects according to the order induced by the specified comparator.
Comparators
  
sort3(data:Vector.<Object>, fromIndex:int, toIndex:int, c:Comparator):void
[static] Sorts the specified array of objects according to the order induced by the specified comparator.
Comparators
Protected Methods
 MethodDefined By
  
Comparators
Constructor Detail
Comparators()Constructor
public function Comparators(init:Boolean = true)



Parameters
init:Boolean (default = true)
Method Detail
compare()method
public static function compare(i1:int, i2:int):int

Compares the specified integral numbers. Returns a negative integer, zero, or a positive integer as the first argument is less than, equal to, or greater than the second.

Parameters

i1:int — the first number to compare.
 
i2:int — the second number to compare.

Returns
int — a negative integer, zero, or a positive integer as the first argument is less than, equal to, or greater than the second.

See also

Comparator.compare()
compare2()method 
public static function compare2(l1:LongImpl, l2:LongImpl):int

Compares the specified integral numbers. Returns a negative integer, zero, or a positive integer as the first argument is less than, equal to, or greater than the second.

Parameters

l1:LongImpl — the first number to compare.
 
l2:LongImpl — the second number to compare.

Returns
int — a negative integer, zero, or a positive integer as the first argument is less than, equal to, or greater than the second.

See also

Comparator.compare()
compare3()method 
public static function compare3(f1:Number, f2:Number):int

Compares the specified floating point numbers. Returns a negative integer, zero, or a positive integer as the first argument is less than, equal to, or greater than the second.

Warning: This method does not handle NaN! If you need NaN-safe comparison, use com.yworks.bridge.util.Double.compare() instead.

Parameters

f1:Number — the first number to compare.
 
f2:Number — the second number to compare.

Returns
int — a negative integer, zero, or a positive integer as the first argument is less than, equal to, or greater than the second.

See also

compare4()method 
public static function compare4(d1:Number, d2:Number):int

Compares the specified floating point numbers. Returns a negative integer, zero, or a positive integer as the first argument is less than, equal to, or greater than the second.

Warning: This method does not handle NaN! If you need NaN-safe comparison, use com.yworks.bridge.util.Double.compare() instead.

Parameters

d1:Number — the first number to compare.
 
d2:Number — the second number to compare.

Returns
int — a negative integer, zero, or a positive integer as the first argument is less than, equal to, or greater than the second.

See also

createComparableComparator()method 
public static function createComparableComparator():Comparator

Returns a comparator that compares to Objects of type Comparable.

Returns
Comparator
createComparableDataComparator()method 
public static function createComparableDataComparator(dp:DataProvider):Comparator

Returns a comparator that compares objects of arbitrary type. Two objects are compared by comparing the Comparable instances the given data provider returns for each of these objects.

Parameters

dp:DataProvider — a data provider that must return a Comparable for each object that is being compared by this comparator.

Returns
Comparator — a comparator that compares arbitrary objects.
createDoubleDataComparator()method 
public static function createDoubleDataComparator(dp:DataProvider):Comparator

Returns a comparator that compares objects of arbitrary type. Two objects are compared by comparing the double value the given data provider returns for each of these objects.

Parameters

dp:DataProvider — a data provider that must return a double value for each object that is being compared by this comparator.

Returns
Comparator — a comparator that compares arbitrary objects.
createDoubleDataSourceComparator()method 
public static function createDoubleDataSourceComparator(dp:DataProvider):Comparator

Returns a comparator that compares objects of type com.yworks.yfiles.base.Edge. Two edges are compared by comparing their source nodes. Each source node e.source() in turn is compared by the double value provided by the given data provider: dp.getDouble(e.source()).

Parameters

dp:DataProvider — a data provider that must return a double value for the source node of each edge being compared.

Returns
Comparator — a comparator that compares edges.

See also

createDoubleDataTargetComparator()method 
public static function createDoubleDataTargetComparator(dp:DataProvider):Comparator

Returns a comparator that compares objects of type com.yworks.yfiles.base.Edge. Two edges are compared by comparing their target nodes. Each target node e.target() in turn is compared by the double value provided by the given data provider: dp.getDouble(e.target()).

Parameters

dp:DataProvider — a data provider that must return a double value for the target node of each edge being compared.

Returns
Comparator — a comparator that compares edges.

See also

createIntDataComparator()method 
public static function createIntDataComparator(dp:DataProvider):Comparator

Returns a comparator that compares objects of arbitrary type. Two objects are compared by comparing the int value the given data provider returns for each of these objects.

Parameters

dp:DataProvider — a data provider that must return an int value for each object that is being compared by this comparator.

Returns
Comparator — a comparator that compares arbitrary objects.
createIntDataSourceComparator()method 
public static function createIntDataSourceComparator(dp:DataProvider):Comparator

Returns a comparator that compares objects of type com.yworks.yfiles.base.Edge. Two edges are compared by comparing their source nodes. Each source node e.source() in turn is compared by the int value provided by the given data provider: dp.getInt(e.source()).

Parameters

dp:DataProvider — a data provider that must return an int value for the source node of each edge being compared.

Returns
Comparator — a comparator that compares edges.

See also

createIntDataTargetComparator()method 
public static function createIntDataTargetComparator(dp:DataProvider):Comparator

Returns a comparator that compares objects of type com.yworks.yfiles.base.Edge. Two edges are compared by comparing their target nodes. Each target node e.target() in turn is compared by the int value provided by the given data provider: dp.getInt(e.target()).

Parameters

dp:DataProvider — a data provider that must return an int value for the target node of each edge being compared.

Returns
Comparator — a comparator that compares edges.

See also

getClass()method 
override public function getClass():Class

Returns
Class
initComparators()method 
protected final function initComparators():void

newComparators()method 
public static function newComparators():Comparators

Returns
Comparators
sort()method 
public static function sort(data:List, c:Comparator):void

Sorts the specified list of objects according to the order induced by the specified comparator.

This sort is guaranteed to be stable: Equal elements will not be reordered as a result of the sort.

Implementation note: If the comparator is marked with the com.yworks.yfiles.util.Comparators_PartialOrder interface, this implementation is behavior-compatible with the pre-Java-7 version of com.yworks.bridge.util.Collections.sort() in the sense that it does not throw IllegalArgumentException if the specified comparator used for sorting does not define a total order.

Parameters

data:List — the list to be sorted.
 
c:Comparator — the comparator to determine the order of the list. A null value indicates that the elements' natural ordering (com.yworks.bridge.util.Comparable) should be used.

See also

sort2()method 
public static function sort2(data:Vector.<Object>, c:Comparator):void

Sorts the specified array of objects according to the order induced by the specified comparator.

This sort is guaranteed to be stable: Equal elements will not be reordered as a result of the sort.

Implementation note: If the comparator is marked with the com.yworks.yfiles.util.Comparators_PartialOrder interface, this implementation is behavior-compatible with the pre-Java-7 version of com.yworks.bridge.util.Arrays.sort() in the sense that it does not throw IllegalArgumentException if the specified comparator used for sorting does not define a total order.

Parameters

data:Vector.<Object> — the array to be sorted.
 
c:Comparator — the comparator to determine the order of the array. A null value indicates that the elements' natural ordering (com.yworks.bridge.util.Comparable) should be used.

See also

sort3()method 
public static function sort3(data:Vector.<Object>, fromIndex:int, toIndex:int, c:Comparator):void

Sorts the specified array of objects according to the order induced by the specified comparator.

This sort is guaranteed to be stable: Equal elements will not be reordered as a result of the sort.

Implementation note: If the comparator is marked with the com.yworks.yfiles.util.Comparators_PartialOrder interface, this implementation is behavior-compatible with the pre-Java-7 version of com.yworks.bridge.util.Arrays.sortObjectsRangeWithComparator() in the sense that it does not throw IllegalArgumentException if the specified comparator used for sorting does not define a total order.

Parameters

data:Vector.<Object> — the array to be sorted.
 
fromIndex:int — the index of the first element (inclusive) to be sorted.
 
toIndex:int — the index of the last element (exclusive) to be sorted.
 
c:Comparator — the comparator to determine the order of the array. A null value indicates that the elements' natural ordering (com.yworks.bridge.util.Comparable) should be used.


Throws
IllegalArgumentException — if fromIndex > toIndex.
 
RangeError — if fromIndex < 0 or toIndex > a.length.

See also