|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--net.aerith.misao.util.SortableArray
The SortableArray
represents a virtual array of data
values with a function to sort data.
Field Summary | |
protected static int |
COMPARE_EQUAL
The number which represents the comparison result is the first data and the second data are equal. |
protected static int |
COMPARE_LARGER
The number which represents the comparison result is the first data is larger than the second data. |
protected static int |
COMPARE_SMALLER
The number which represents the comparison result is the first data is smaller than the second data. |
private static int |
SORT_ASCENDANT
The sorting direction number used in quick_sort indicating the ascending order. |
private static int |
SORT_DESCENDANT
The sorting direction number used in quick_sort indicating the descending order. |
protected ArrayIndex |
sort_index
The index of sorting result. |
Constructor Summary | |
SortableArray()
|
Method Summary | |
protected abstract int |
compare(int index1,
int index2)
Compares the two data represented by the specified index and returns which is smaller. |
abstract int |
getArraySize()
Gets the size of this array. |
private void |
quick_sort(int first,
int last,
int direction)
Sorts part of the data between the specified first and last location in order of the specified direction. |
protected abstract void |
sort()
Sorts this array itself based on the sorted index. |
ArrayIndex |
sortAscendant()
Sorts data in ascendant order. |
ArrayIndex |
sortDescendant()
Sorts data in descendant order. |
Methods inherited from class java.lang.Object |
|
Field Detail |
protected ArrayIndex sort_index
private static final int SORT_ASCENDANT
private static final int SORT_DESCENDANT
protected static final int COMPARE_EQUAL
protected static final int COMPARE_SMALLER
protected static final int COMPARE_LARGER
Constructor Detail |
public SortableArray()
Method Detail |
public abstract int getArraySize()
protected abstract int compare(int index1, int index2)
index1
- the index to represent the first data to compare.index2
- the index to represent the second data to compare.protected abstract void sort()
public ArrayIndex sortAscendant()
ArrayIndex index = array.sortAscendant();then the k-th value in the sorted buffer was originally at the index.get(k)-th location.
public ArrayIndex sortDescendant()
ArrayIndex index = array.sortDescendant();then the k-th value in the sorted buffer was originally at the index.get(k)-th location.
private void quick_sort(int first, int last, int direction)
first
- the first index of part to sort.last
- the last index of part to sort.direction
- the sorting direction.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |