|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjava.lang.Number
edu.iastate.metnet.metaomgraph.SortableData
public class SortableData
Class for sorting data in ascending or descending order while retaining information about the data's original order. When sorting in ascending order, the compareTo() method behaves normally (returns 1 when this value is greater than the compare-to value). When sorting descending, however, it works backwards (that is, returns 1 when this value is less than the compare-to value). This way, Arrays.sort() will sort an array of this data in the requested order. Furthermore, this class can be sorted by the data or by the original index by calling the setSortByData() method. If setSortByData(true) is called, then
| Constructor Summary | |
|---|---|
SortableData(double value,
int index)
Constructs a new object that sorts by data in ascending order. |
|
SortableData(double value,
int index,
boolean ascending)
Constructs a new object that sorts by data. |
|
SortableData(double value,
int index,
boolean ascending,
boolean sortByData)
Constructor. |
|
| Method Summary | |
|---|---|
int |
compareTo(java.lang.Object arg0)
|
double |
doubleValue()
|
float |
floatValue()
|
int |
getIndex()
|
double |
getValue()
|
double |
getValueToCompare()
Returns the data value if sortByData is true. |
int |
intValue()
|
boolean |
isAscending()
|
boolean |
isSortByData()
|
long |
longValue()
|
void |
setAscending(boolean ascending)
Determines whether to sort in ascending or descending order |
void |
setIndex(int index)
Sets this object's index |
void |
setSortByData(boolean sortByData)
Sets whether to sort by data or by index. |
void |
setValue(double value)
Sets a new data value for this object |
| Methods inherited from class java.lang.Number |
|---|
byteValue, shortValue |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public SortableData(double value,
int index)
value - The dataindex - The original index of the data
public SortableData(double value,
int index,
boolean ascending)
value - The dataindex - The original index of the dataascending - When true, Arrays.sort() will sort this data in ascending
order. When false, Arrays.sort() will sort in descending
order.
public SortableData(double value,
int index,
boolean ascending,
boolean sortByData)
value - The dataindex - The original index of the dataascending - When true, Arrays.sort() will sort in ascending order. When
false, Arrays.sort() will sort in descending order.sortByData - When true, Arrays.sort() will sort this object by its data
value. When false, Arrays.sort() will sort by the index.| Method Detail |
|---|
public int compareTo(java.lang.Object arg0)
compareTo in interface java.lang.Comparablepublic double getValueToCompare()
public double doubleValue()
doubleValue in class java.lang.Numberpublic float floatValue()
floatValue in class java.lang.Numberpublic int intValue()
intValue in class java.lang.Numberpublic long longValue()
longValue in class java.lang.Numberpublic boolean isAscending()
public void setAscending(boolean ascending)
ascending - If true, future sorts will be done in ascending order. If
false, future sorts will be done in descending order.public int getIndex()
public void setIndex(int index)
index - The new indexpublic boolean isSortByData()
public void setSortByData(boolean sortByData)
sortByData - public double getValue()
public void setValue(double value)
value - The new data value
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||