org.graffiti.plugins.algorithms.mst
Interface Heap<E,K>

Type Parameters:
E - type of elements to be stored in this heap.
K - type of keys to be associated with elements.
All Superinterfaces:
Collection<E>, Iterable<E>
All Known Implementing Classes:
AbstractHeap, ArrayHeap

public interface Heap<E,K>
extends Collection<E>

An ordered collection that allows clients to change the key of an element.

Version:
$Revision$ $Date$
Author:
Harald Frankenberger

Nested Class Summary
static interface Heap.Entry<E,K>
          A heap entry.
 
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.
 Comparator<? super K> comparator()
          Returns the comparator of this heap or null if this heap uses the natural ordering of its elements.
 Collection<Heap.Entry<E,K>> entries()
          Returns a collection view of the entries of this heap.
 E getPeek()
          Returns the peek (i.e.
 E removePeek()
          Removes the peek (i.e.
 
Methods inherited from interface java.util.Collection
addAll, clear, contains, containsAll, equals, hashCode, isEmpty, iterator, remove, removeAll, retainAll, size, toArray, toArray
 

Method Detail

comparator

Comparator<? super K> comparator()
Returns the comparator of this heap or null if this heap uses the natural ordering of its elements.

Returns:
the comparator of this heap or null if this heap uses the natural ordering of its elements.

getPeek

E getPeek()
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.

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:
comparator()

add

boolean add(E element)
Adds the specified element to this heap setting its key to null.

Specified by:
add in interface Collection<E>
Throws:
NullPointerException - if this class does not support null keys.

add

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.

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

E removePeek()
Removes the peek (i.e. smallest) element from this heap.

Returns:
the peek (i.e. smallest) element of this heap.

entries

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

Returns:
a collection view of the entries of this heap.


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