|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectweka.core.InstanceComparator
public class InstanceComparator
A comparator for the Instance class. it can be used with or without the
class label. Missing values are sorted at the beginning.
Can be used as comparator in the sorting and binary search algorithms of
Arrays and Collections.
Relational values are compared instance by instance with a nested
InstanceComparator.
Instance,
Arrays,
Collections,
Serialized Form| Constructor Summary | |
|---|---|
InstanceComparator()
Initializes the comparator and includes the class in the comparison and all attributes included. |
|
InstanceComparator(boolean includeClass)
Initializes the comparator with all attributes included. |
|
InstanceComparator(boolean includeClass,
String range,
boolean invert)
Initializes the comparator. |
|
| Method Summary | |
|---|---|
int |
compare(Instance inst1,
Instance inst2)
compares the two instances, returns -1 if o1 is smaller than o2, 0 if equal and +1 if greater. |
boolean |
getIncludeClass()
Returns whether the class is included in the comparison. |
boolean |
getInvert()
Returns whether the matching sense of the attribute range is inverted. |
String |
getRange()
Returns the attribute range to use in the comparison. |
String |
getRevision()
Returns the revision string. |
static void |
main(String[] args)
for testing only. |
void |
setIncludeClass(boolean includeClass)
Sets whether the class should be included in the comparison. |
void |
setInvert(boolean value)
Sets whether to invert the matching sense of the attribute range. |
void |
setRange(String value)
Sets the attribute range to use for comparison. |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface java.util.Comparator |
|---|
equals |
| Constructor Detail |
|---|
public InstanceComparator()
public InstanceComparator(boolean includeClass)
includeClass - whether to include the class in the comparison
public InstanceComparator(boolean includeClass,
String range,
boolean invert)
includeClass - whether to include the class in the comparisonrange - the attribute range stringinverted - whether to invert the matching sense of the att range| Method Detail |
|---|
public void setIncludeClass(boolean includeClass)
includeClass - true if to include the class in the comparisonpublic boolean getIncludeClass()
public void setRange(String value)
value - the attribute rangepublic String getRange()
public void setInvert(boolean value)
invert - true if to invert the matching sensepublic boolean getInvert()
public int compare(Instance inst1,
Instance inst2)
compare in interface Comparator<Instance>inst1 - the first instance to compareinst2 - the second instance to compare
public String getRevision()
getRevision in interface RevisionHandler
public static void main(String[] args)
throws Exception
Exception
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||