|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Object | +--xxl.cursors.ReplacementSelection
Replacement Selection takes an Iterator as its input and creates sorted runs as its output. This technique is described in "Donald Knuth.: Sorting and Searching. Addison-Wesley 1970." Replacement-selection is especially useful for external sorting. Recall, that an external merge-sort is performed by first producing n sorted input-runs. These runs are then recursively merged to a single output-run. The runs produced by ReplacementSelection tend to be twice as big as the available memory or even bigger.
| Field Summary | |
protected java.lang.Object[] |
array
|
protected java.util.Comparator |
comparator
|
protected Cursor |
cursor
|
protected Heap |
heap
|
protected int |
n
|
protected int |
size
|
| Constructor Summary | |
ReplacementSelection(Cursor cursor,
int size,
java.util.Comparator comparator)
Creates a new instance of ReplacementSelection. |
|
ReplacementSelection(java.util.Iterator iterator,
int size)
Creates a new instance of ReplacementSelection. |
|
ReplacementSelection(java.util.Iterator iterator,
int size,
java.util.Comparator comparator)
Creates a new instance of ReplacementSelection. |
|
ReplacementSelection(PeekIterator peekIterator,
int size,
java.util.Comparator comparator)
Creates a new instance of ReplacementSelection. |
|
| Method Summary | |
protected void |
check()
Checks whether there are more elements to process. |
void |
close()
Closes the Cursor. |
boolean |
hasNext()
Returns true if the iteration has more elements. |
protected void |
init()
Initializes the ReplacementSelection-Object. |
static void |
main(java.lang.String[] args)
|
java.lang.Object |
next()
Returns the next element in the iteration. |
java.lang.Object |
peek()
Shows the next element in the iteration without removing it. |
void |
remove()
Removes from the underlying collection the last element returned by the iterator (unsupported operation). |
void |
reset()
Resets the Cursor to its initial state. |
boolean |
supportsPeek()
Returns true if the peek operation is supported by this PeekIterator. |
void |
update(java.lang.Object object)
Replaces the object that was returned by the last call to next() or peek(). |
| Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
| Field Detail |
protected java.lang.Object[] array
protected int n
protected int size
protected Cursor cursor
protected java.util.Comparator comparator
protected Heap heap
| Constructor Detail |
public ReplacementSelection(Cursor cursor,
int size,
java.util.Comparator comparator)
cursor - the input-Cursorsize - the number of elements that can be kept in memorycomparator - the Comparator used to compare elements
public ReplacementSelection(java.util.Iterator iterator,
int size)
iterator - the input-Iteratorsize - the number of elements that can be kept in memory
public ReplacementSelection(java.util.Iterator iterator,
int size,
java.util.Comparator comparator)
iterator - the input-Iteratorsize - the number of elements that can be kept in memorycomparator - the Comparator used to compare elements
public ReplacementSelection(PeekIterator peekIterator,
int size,
java.util.Comparator comparator)
peekIterator - the input-PeekIteratorsize - the number of elements that can be kept in memorycomparator - the Comparator used to compare elements| Method Detail |
protected void init()
protected void check()
throws java.util.NoSuchElementException
public void close()
public boolean hasNext()
public java.lang.Object next()
throws java.util.NoSuchElementException
public java.lang.Object peek()
throws java.util.NoSuchElementException
public void remove()
throws java.lang.UnsupportedOperationException
public void reset()
throws java.lang.UnsupportedOperationException
public boolean supportsPeek()
public void update(java.lang.Object object)
throws java.lang.UnsupportedOperationException
object - the object that replaces the object returned
by the last call to next() or peek()public static void main(java.lang.String[] args)
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||