org.graffiti.plugins.algorithms.mst
Class AbstractHeap<E,K>

java.lang.Object
  extended by java.util.AbstractCollection<E>
      extended by org.graffiti.plugins.algorithms.mst.AbstractHeap<E,K>
Type Parameters:
E -
K -
All Implemented Interfaces:
Iterable<E>, Collection<E>, Heap<E,K>
Direct Known Subclasses:
ArrayHeap

public abstract class AbstractHeap<E,K>
extends AbstractCollection<E>
implements Heap<E,K>

This class provides a skeleton implementation of the Heap interface to minimize the effort required to implement this interface.

Version:
$Revision$ $Date$
Author:
Harald

Method Summary
 boolean add(E element)
          Adds the specified element to this heap setting its key to null.
 Heap.Entry<E,K> add(E element, K key)
          Adds the specified element with the specified key to this heap; returns a new heap entry to enable clients to modify the element's key.
abstract  Comparator<? super K> comparator()
          Returns the comparator of this heap or null if this heap uses the natural ordering of its elements.
abstract  Collection<Heap.Entry<E,K>> entries()
          Returns a collection view of the entries of this heap.
 E getPeek()
          Returns the peek (i.e.
 Iterator<E> iterator()
           
 E removePeek()
          Removes the peek (i.e.
 int size()
           
 
Methods inherited from class java.util.AbstractCollection
addAll, clear, contains, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray, toString
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.Collection
addAll, clear, contains, containsAll, equals, hashCode, isEmpty, remove, removeAll, retainAll, toArray, toArray
 

Method Detail

size

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

comparator

public abstract Comparator<? super K> comparator()
Description copied from interface: Heap
Returns the comparator of this heap or null if this heap uses the natural ordering of its elements.

Specified by:
comparator in interface Heap<E,K>
Returns:
the comparator of this heap or null if this heap uses the natural ordering of its elements.

iterator

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

getPeek

public E getPeek()
Description copied from interface: Heap
Returns the peek (i.e. smallest) element of this heap according to the order specified by this heap's comparator or the natural order of its elements if this heap's comparator is null.

Specified by:
getPeek in interface Heap<E,K>
Returns:
the peek (i.e. smallest) element of this heap according to the order specified by this heap's comparator or the natural order of its elements if this heap's comparator is null.
See Also:
Heap.comparator()

add

public boolean add(E element)
Description copied from interface: Heap
Adds the specified element to this heap setting its key to null.

Specified by:
add in interface Collection<E>
Specified by:
add in interface Heap<E,K>
Overrides:
add in class AbstractCollection<E>

add

public Heap.Entry<E,K> add(E element,
                           K key)
Description copied from interface: Heap
Adds the specified element with the specified key to this heap; returns a new heap entry to enable clients to modify the element's key.

Specified by:
add in interface Heap<E,K>
Parameters:
element - the element to be added to this heap
key - the key to be associated with the specified element
Returns:
a new heap entry to enable clients to modify the element's key.

removePeek

public E removePeek()
Description copied from interface: Heap
Removes the peek (i.e. smallest) element from this heap.

Specified by:
removePeek in interface Heap<E,K>
Returns:
the peek (i.e. smallest) element of this heap.

entries

public abstract Collection<Heap.Entry<E,K>> entries()
Description copied from interface: Heap
Returns a collection view of the entries of this heap. The returned collection supports remove but does not support add.

Specified by:
entries in interface Heap<E,K>
Returns:
a collection view of the entries of this heap.


Generated at 2012-05-30 11:01:25 PM CEST