Package adams.data.instance
Class InstancePointComparator
- java.lang.Object
-
- adams.data.container.DataPointComparator
-
- adams.data.instance.InstancePointComparator
-
- All Implemented Interfaces:
Serializable
,Comparator
public class InstancePointComparator extends DataPointComparator
A comparator for InstancePoint objects.- Version:
- $Revision$
- Author:
- fracpete (fracpete at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected boolean
m_UseY
whether to compare Y or X.-
Fields inherited from class adams.data.container.DataPointComparator
m_Ascending
-
-
Constructor Summary
Constructors Constructor Description InstancePointComparator()
The default constructor uses comparison by X in ascending manner.InstancePointComparator(boolean useY, boolean ascending)
This constructor initializes the comparator either with comparison by X or by Y.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
compare(DataPoint o1, DataPoint o2)
Compares its two arguments for order.boolean
isUsingY()
Returns whether Y or X number is used for ordering.-
Methods inherited from class adams.data.container.DataPointComparator
isAscending
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface java.util.Comparator
equals, reversed, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLong
-
-
-
-
Constructor Detail
-
InstancePointComparator
public InstancePointComparator()
The default constructor uses comparison by X in ascending manner.
-
InstancePointComparator
public InstancePointComparator(boolean useY, boolean ascending)
This constructor initializes the comparator either with comparison by X or by Y. Either in ascending manner or descending.- Parameters:
useY
- if true then Y is used for comparison otherwise Xascending
- if true then the ordering is done in ascending manner, otherwise descending
-
-
Method Detail
-
isUsingY
public boolean isUsingY()
Returns whether Y or X number is used for ordering.- Returns:
- true if Y is used for ordering
-
compare
public int compare(DataPoint o1, DataPoint o2)
Compares its two arguments for order. Returns a negative integer, zero, or a positive integer as the first argument is less than, equal to, or greater than the second.- Specified by:
compare
in classDataPointComparator
- Parameters:
o1
- the first objecto2
- the second object- Returns:
- a negative integer, zero, or a positive integer as the first argument is less than, equal to, or greater than the second.
-
-