T - type of the objects in the heappublic class TopN<T> extends AbstractTopN<T>
capacity, size| Constructor and Description |
|---|
TopN(int capacity)
Constructor that assumes that the class T implements the Comparable interface.
|
TopN(int capacity,
Comparator<T> cmp)
Constructor in which the comparator is specified.
|
| Modifier and Type | Method and Description |
|---|---|
protected int |
compare(int i,
int j)
Compares the i-th element of the heap with the j-th element in the heap.
|
protected int |
compare(int i,
T e)
Compares the i-th element of the heap with the element
|
protected T |
get(int i)
Returns the i-th element in the heap.
|
protected void |
set(int i,
T e)
Sets the element in the i-th position of the heap.
|
protected void |
swap(int i,
int j)
Swaps the elements in the i-th and j-th element in the heap.
|
add, iterator, peek, reverseIterator, reverseStream, size, sortaddAll, clear, contains, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray, toStringclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitequals, hashCode, parallelStream, removeIf, spliterator, streampublic TopN(int capacity)
capacity - maximum capacity of the heappublic TopN(int capacity,
Comparator<T> cmp)
capacity - maximum capacity of the heapcmp - comparatorprotected T get(int i)
AbstractTopNget in class AbstractTopN<T>i - index of the elementprotected void set(int i,
T e)
AbstractTopNset in class AbstractTopN<T>i - indexe - elementprotected int compare(int i,
T e)
AbstractTopNcompare in class AbstractTopN<T>i - indexe - elementprotected int compare(int i,
int j)
AbstractTopNcompare in class AbstractTopN<T>i - indexj - indexprotected void swap(int i,
int j)
AbstractTopNswap in class AbstractTopN<T>i - indexj - indexCopyright © 2016. All rights reserved.