de.lmu.ifi.dbs.elki.utilities.datastructures.heap
Class TopBoundedHeap<E>

java.lang.Object
  extended by java.util.AbstractCollection<E>
      extended by java.util.AbstractQueue<E>
          extended by de.lmu.ifi.dbs.elki.utilities.datastructures.heap.Heap<E>
              extended by de.lmu.ifi.dbs.elki.utilities.datastructures.heap.TopBoundedHeap<E>
Type Parameters:
E - Element type. Should be Comparable or a Comparator needs to be given.
All Implemented Interfaces:
Serializable, Iterable<E>, Collection<E>, Queue<E>
Direct Known Subclasses:
TiedTopBoundedHeap

public class TopBoundedHeap<E>
extends Heap<E>

Heap class that is bounded in size from the top. It will keep the bottom k Elements only.

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class de.lmu.ifi.dbs.elki.utilities.datastructures.heap.Heap
Heap.Itr
 
Field Summary
protected  int maxsize
          Maximum size
private static long serialVersionUID
          Serial version
 
Fields inherited from class de.lmu.ifi.dbs.elki.utilities.datastructures.heap.Heap
modCount, size
 
Constructor Summary
TopBoundedHeap(int maxsize)
          Constructor with maximum size only.
TopBoundedHeap(int maxsize, Comparator<? super E> comparator)
          Constructor with maximum size and Comparator.
 
Method Summary
 int getMaxSize()
           
protected  void handleOverflow(E e)
          Handle an overflow in the structure.
 boolean offer(E e)
           
 
Methods inherited from class de.lmu.ifi.dbs.elki.utilities.datastructures.heap.Heap
castQueueElement, clear, compare, compareExternal, compareExternalExternal, contains, heapifyDown, heapifyUp, heapifyUpParent, iterator, peek, poll, putInQueue, removeAt, size, swap, toSortedArrayList
 
Methods inherited from class java.util.AbstractQueue
add, addAll, element, remove
 
Methods inherited from class java.util.AbstractCollection
containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.Collection
containsAll, equals, hashCode, isEmpty, remove, removeAll, retainAll, toArray, toArray
 

Field Detail

serialVersionUID

private static final long serialVersionUID
Serial version

See Also:
Constant Field Values

maxsize

protected int maxsize
Maximum size

Constructor Detail

TopBoundedHeap

public TopBoundedHeap(int maxsize)
Constructor with maximum size only.

Parameters:
maxsize - Maximum size

TopBoundedHeap

public TopBoundedHeap(int maxsize,
                      Comparator<? super E> comparator)
Constructor with maximum size and Comparator.

Parameters:
maxsize - Maximum size
comparator - Comparator
Method Detail

offer

public boolean offer(E e)
Specified by:
offer in interface Queue<E>
Overrides:
offer in class Heap<E>

handleOverflow

protected void handleOverflow(E e)
Handle an overflow in the structure. This function can be overridden to get overflow treatment.

Parameters:
e - Overflowing element.

getMaxSize

public int getMaxSize()
Returns:
the maximum size

Release 0.4.0 (2011-09-20_1324)