net.cscott.jutil

Class AbstractHeap<K,V>

public abstract class AbstractHeap<K,V> extends Object implements Heap<K,V>

AbstractHeap provides a skeletal implementation of the Heap interface, to minimize the effort required to implement this interface.

Version: $Id: AbstractHeap.java,v 1.3 2004/01/13 21:40:19 cananian Exp $

Author: C. Scott Ananian

Constructor Summary
protected AbstractHeap(Comparator<K> c)
Sole constructor, for invocation by subclass constructors.
Method Summary
abstract voidclear()
Comparator<K>comparator()
Returns the comparator used to compare keys in this Heap, or null if the keys' natural ordering is used.
abstract voiddecreaseKey(Entry<K,V> me, K newkey)
abstract voiddelete(Entry<K,V> me)
abstract Collection<Entry<K,V>>entries()
protected Comparator<Entry<K,V>>entryComparator()
Returns a comparator which can be used to compare Map.Entrys.
booleanequals(Object o)
Entry<K,V>extractMinimum()
inthashCode()
abstract Entry<K,V>insert(K key, V value)
protected voidinsert(Entry<K,V> me)
This method should insert the specified Map.Entry, which is not currently in the Heap, into the Heap.
booleanisEmpty()
protected Comparator<K>keyComparator()
Returns the comparator used to compare keys in this Heap.
abstract Entry<K,V>minimum()
protected KsetKey(Entry<K,V> me, K newkey)
This method should set the key for the specified Map.Entry to the given newkey.
abstract intsize()
StringtoString()
voidunion(Heap<? extends K,? extends V> h)
voidupdateKey(Entry<K,V> me, K newkey)

Constructor Detail

AbstractHeap

protected AbstractHeap(Comparator<K> c)
Sole constructor, for invocation by subclass constructors.

Method Detail

clear

public abstract void clear()

comparator

public Comparator<K> comparator()
Returns the comparator used to compare keys in this Heap, or null if the keys' natural ordering is used.

decreaseKey

public abstract void decreaseKey(Entry<K,V> me, K newkey)

delete

public abstract void delete(Entry<K,V> me)

entries

public abstract Collection<Entry<K,V>> entries()

entryComparator

protected Comparator<Entry<K,V>> entryComparator()
Returns a comparator which can be used to compare Map.Entrys. Will never return null.

equals

public boolean equals(Object o)

extractMinimum

public Entry<K,V> extractMinimum()

hashCode

public int hashCode()

insert

public abstract Entry<K,V> insert(K key, V value)

insert

protected void insert(Entry<K,V> me)
This method should insert the specified Map.Entry, which is not currently in the Heap, into the Heap. Implementation is optional, but it is required if you use the default implementation of updateKey().

isEmpty

public boolean isEmpty()

keyComparator

protected Comparator<K> keyComparator()
Returns the comparator used to compare keys in this Heap. Will never return null.

minimum

public abstract Entry<K,V> minimum()

setKey

protected K setKey(Entry<K,V> me, K newkey)
This method should set the key for the specified Map.Entry to the given newkey. Implementation is optional, but it is required if you use the default implementation of updateKey().

size

public abstract int size()

toString

public String toString()

union

public void union(Heap<? extends K,? extends V> h)

updateKey

public void updateKey(Entry<K,V> me, K newkey)
Copyright © 2003 C. Scott Ananian