Package weka.knowledgeflow.steps
Class Sorter.SortRule
java.lang.Object
weka.knowledgeflow.steps.Sorter.SortRule
- All Implemented Interfaces:
Comparator<weka.knowledgeflow.steps.Sorter.InstanceHolder>
- Enclosing class:
- Sorter
public static class Sorter.SortRule
extends Object
implements Comparator<weka.knowledgeflow.steps.Sorter.InstanceHolder>
Implements a sorting rule based on a single attribute
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionint
compare
(weka.knowledgeflow.steps.Sorter.InstanceHolder o1, weka.knowledgeflow.steps.Sorter.InstanceHolder o2) Compare two instances according to the ruleGet the name or index of the attribute to sort onboolean
Return true if the sort is descendingvoid
init
(Environment env, Instances structure) Initialize the rulevoid
setAttribute
(String att) Set the name or index of the attribute to sort onvoid
setDescending
(boolean d) Set whether the sort should be descending rather than ascendingtoString()
Prints the rule in human readable formatGets the rule in internal formatMethods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.util.Comparator
equals, reversed, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLong
-
Constructor Details
-
SortRule
Constructor- Parameters:
att
- the name or index of the attribute to compare ondescending
- true if order should be descending
-
SortRule
public SortRule()Constructor -
SortRule
Constructor- Parameters:
setup
- the definition of a sort rule
-
-
Method Details
-
toStringInternal
Gets the rule in internal format- Returns:
- the rule in internal format
-
toString
Prints the rule in human readable format -
setAttribute
Set the name or index of the attribute to sort on- Parameters:
att
- the name or index of tha attribute to sort on
-
getAttribute
Get the name or index of the attribute to sort on- Returns:
- the name or index of the attribute to sort on
-
setDescending
public void setDescending(boolean d) Set whether the sort should be descending rather than ascending- Parameters:
d
- true for a descending sort
-
getDescending
public boolean getDescending()Return true if the sort is descending- Returns:
- true if the sort is descending
-
init
Initialize the rule- Parameters:
env
- the environment variables to usestructure
- the structure of the instances that the rule will opperate on
-
compare
public int compare(weka.knowledgeflow.steps.Sorter.InstanceHolder o1, weka.knowledgeflow.steps.Sorter.InstanceHolder o2) Compare two instances according to the rule- Specified by:
compare
in interfaceComparator<weka.knowledgeflow.steps.Sorter.InstanceHolder>
- Parameters:
o1
- the first instanceo2
- the second instance- Returns:
- the result of the comparison
-