de.lmu.ifi.dbs.elki.utilities.datastructures.heap
Class TiedTopBoundedHeap<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>
                  extended by de.lmu.ifi.dbs.elki.utilities.datastructures.heap.TiedTopBoundedHeap<E>
Type Parameters:
E - Object type
All Implemented Interfaces:
Serializable, Iterable<E>, Collection<E>, Queue<E>
Direct Known Subclasses:
KNNHeap

public class TiedTopBoundedHeap<E>
extends TopBoundedHeap<E>

A size-limited heap similar to TopBoundedHeap, discarding elements with the highest value. However, this variation keeps a list of tied elements.

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
private static long serialVersionUID
          Serial version
private  LinkedList<E> ties
          List to keep ties in.
 
Fields inherited from class de.lmu.ifi.dbs.elki.utilities.datastructures.heap.TopBoundedHeap
maxsize
 
Fields inherited from class de.lmu.ifi.dbs.elki.utilities.datastructures.heap.Heap
modCount, size
 
Constructor Summary
TiedTopBoundedHeap(int maxsize)
          Constructor for Comparable objects.
TiedTopBoundedHeap(int maxsize, Comparator<? super E> comparator)
          Constructor with comparator.
 
Method Summary
 void clear()
           
 boolean contains(Object o)
           
protected  void handleOverflow(E e)
          Handle an overflow in the structure.
 Iterator<E> iterator()
           
 E peek()
           
 E poll()
           
 int size()
           
 
Methods inherited from class de.lmu.ifi.dbs.elki.utilities.datastructures.heap.TopBoundedHeap
getMaxSize, offer
 
Methods inherited from class de.lmu.ifi.dbs.elki.utilities.datastructures.heap.Heap
castQueueElement, compare, compareExternal, compareExternalExternal, heapifyDown, heapifyUp, heapifyUpParent, putInQueue, removeAt, 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

ties

private LinkedList<E> ties
List to keep ties in.

Constructor Detail

TiedTopBoundedHeap

public TiedTopBoundedHeap(int maxsize,
                          Comparator<? super E> comparator)
Constructor with comparator.

Parameters:
maxsize - Maximum size of heap (unless tied)
comparator - Comparator

TiedTopBoundedHeap

public TiedTopBoundedHeap(int maxsize)
Constructor for Comparable objects.

Parameters:
maxsize - Maximum size of heap (unless tied)
Method Detail

size

public int size()
Specified by:
size in interface Collection<E>
Overrides:
size in class Heap<E>

clear

public void clear()
Specified by:
clear in interface Collection<E>
Overrides:
clear in class Heap<E>

contains

public boolean contains(Object o)
Specified by:
contains in interface Collection<E>
Overrides:
contains in class Heap<E>

iterator

public Iterator<E> iterator()
Specified by:
iterator in interface Iterable<E>
Specified by:
iterator in interface Collection<E>
Overrides:
iterator in class Heap<E>

peek

public E peek()
Specified by:
peek in interface Queue<E>
Overrides:
peek in class Heap<E>

poll

public E poll()
Specified by:
poll in interface Queue<E>
Overrides:
poll in class Heap<E>

handleOverflow

protected void handleOverflow(E e)
Description copied from class: TopBoundedHeap
Handle an overflow in the structure. This function can be overridden to get overflow treatment.

Overrides:
handleOverflow in class TopBoundedHeap<E>
Parameters:
e - Overflowing element.

Release 0.4.0 (2011-09-20_1324)