|
Search this API | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object y.util.Comparators
public class Comparators
This class provides access to some Comparator instances that are commonly used in yFiles.
Nested Class Summary | |
---|---|
static interface |
Comparators.PartialOrder
Tag interface to mark Comparator or comparable implementations that do not
define a total order but only a partial order. |
Constructor Summary | |
---|---|
Comparators()
|
Method Summary | |
---|---|
static int |
compare(double d1,
double d2)
Compares the specified floating point numbers. |
static int |
compare(float f1,
float f2)
Compares the specified floating point numbers. |
static int |
compare(int i1,
int i2)
Compares the specified integral numbers. |
static int |
compare(long l1,
long l2)
Compares the specified integral numbers. |
static java.util.Comparator |
createComparableComparator()
Returns a Comparator that compares to Objects of type
Comparable. |
static java.util.Comparator |
createComparableDataComparator(DataProvider dp)
Returns a Comparator that compares objects of arbitrary type. |
static java.util.Comparator |
createDoubleDataComparator(DataProvider dp)
Returns a Comparator that compares objects of arbitrary type. |
static java.util.Comparator |
createDoubleDataSourceComparator(DataProvider dp)
Returns a Comparator that compares objects of type
Edge . |
static java.util.Comparator |
createDoubleDataTargetComparator(DataProvider dp)
Returns a Comparator that compares objects of type
Edge . |
static java.util.Comparator |
createIntDataComparator(DataProvider dp)
Returns a Comparator that compares objects of arbitrary type. |
static java.util.Comparator |
createIntDataSourceComparator(DataProvider dp)
Returns a Comparator that compares objects of type
Edge . |
static java.util.Comparator |
createIntDataTargetComparator(DataProvider dp)
Returns a Comparator that compares objects of type
Edge . |
static void |
sort(java.util.List data,
java.util.Comparator c)
Sorts the specified list of objects according to the order induced by the specified Comparator . |
static void |
sort(java.lang.Object[] data,
java.util.Comparator c)
Sorts the specified array of objects according to the order induced by the specified Comparator . |
static void |
sort(java.lang.Object[] data,
int fromIndex,
int toIndex,
java.util.Comparator c)
Sorts the specified array of objects according to the order induced by the specified Comparator . |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Comparators()
Method Detail |
---|
public static java.util.Comparator createIntDataSourceComparator(DataProvider dp)
Comparator
that compares objects of type
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())
.
dp
- a data provider that must return an int value for
the source node of each edge being compared.
Comparator
that compares edges.public static java.util.Comparator createIntDataTargetComparator(DataProvider dp)
Comparator
that compares objects of type
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())
.
dp
- a data provider that must return an int value for
the target node of each edge being compared.
Comparator
that compares edges.public static java.util.Comparator createDoubleDataSourceComparator(DataProvider dp)
Comparator
that compares objects of type
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())
.
dp
- a data provider that must return a double value for
the source node of each edge being compared.
Comparator
that compares edges.public static java.util.Comparator createDoubleDataTargetComparator(DataProvider dp)
Comparator
that compares objects of type
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())
.
dp
- a data provider that must return a double value for
the target node of each edge being compared.
Comparator
that compares edges.public static java.util.Comparator createIntDataComparator(DataProvider dp)
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.
dp
- a data provider that must return an int value for
each object that is being compared by this comparator.
Comparator
that compares arbitrary objects.public static java.util.Comparator createDoubleDataComparator(DataProvider dp)
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.
dp
- a data provider that must return a double value for
each object that is being compared by this comparator.
Comparator
that compares arbitrary objects.public static java.util.Comparator createComparableComparator()
Comparator
that compares to Objects of type
Comparable.
public static java.util.Comparator createComparableDataComparator(DataProvider dp)
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.
dp
- a data provider that must return a Comparable
for
each object that is being compared by this comparator.
Comparator
that compares arbitrary objects.public static int compare(int i1, int i2)
i1
- the first number to compare.i2
- the second number to compare.
Comparator.compare(Object, Object)
public static int compare(long l1, long l2)
l1
- the first number to compare.l2
- the second number to compare.
Comparator.compare(Object, Object)
public static int compare(float f1, float f2)
Warning: This method does not handle NaN
!
If you need NaN
-safe comparison, use
Float.compare(float, float)
instead.
f1
- the first number to compare.f2
- the second number to compare.
Comparator.compare(Object, Object)
public static int compare(double d1, double d2)
Warning: This method does not handle NaN
!
If you need NaN
-safe comparison, use
Double.compare(double, double)
instead.
d1
- the first number to compare.d2
- the second number to compare.
Comparator.compare(Object, Object)
public static void sort(java.util.List data, java.util.Comparator c)
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 Comparators.PartialOrder
interface,
this implementation is behavior-compatible with the pre-Java-7 version of
Collections.sort(java.util.List, java.util.Comparator)
in the sense that it does not throw IllegalArgumentException
if the specified Comparator
used for sorting does not define a total order.
data
- the list to be sorted.c
- the Comparator
to determine the order of the list.
A null
value indicates that the elements'
natural ordering
should be used.Comparators.PartialOrder
public static void sort(java.lang.Object[] data, java.util.Comparator c)
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 Comparators.PartialOrder
interface,
this implementation is behavior-compatible with the pre-Java-7 version of
Arrays.sort(Object[], java.util.Comparator)
in the sense
that it does not throw IllegalArgumentException
if the
specified Comparator
used for sorting does not define a total order.
data
- the array to be sorted.c
- the Comparator
to determine the order of the array.
A null
value indicates that the elements'
natural ordering
should be used.Comparators.PartialOrder
public static void sort(java.lang.Object[] data, int fromIndex, int toIndex, java.util.Comparator c)
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 Comparators.PartialOrder
interface,
this implementation is behavior-compatible with the pre-Java-7 version of
Arrays.sort(Object[], int, int, java.util.Comparator)
in the sense that it does not throw IllegalArgumentException
if the specified Comparator
used for sorting does not define a total order.
data
- the array to be sorted.fromIndex
- the index of the first element (inclusive) to be sorted.toIndex
- the index of the last element (exclusive) to be sorted.c
- the Comparator
to determine the order of the array.
A null
value indicates that the elements'
natural ordering
should be used.
java.lang.IllegalArgumentException
- if fromIndex > toIndex
.
java.lang.ArrayIndexOutOfBoundsException
- if fromIndex < 0
or
toIndex > a.length
.Comparators.PartialOrder
|
© Copyright 2000-2022, yWorks GmbH. All rights reserved. |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |