|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Object | +--jdsl.BTHeap
A Heap implementation of PriorityQueue. This heap is based on a Binary Tree.
| Constructor Summary | |
BTHeap()
comparator(). |
|
BTHeap(Comparator comparator)
comparator(). |
|
| Method Summary | |
Comparator |
comparator()
Retrieves the Comparator. |
protected void |
downheap(Position p)
Performs the downheap operation starting at p. |
java.util.Iterator |
elements()
Returns an Iterator of all the elements within this
Container. |
BinaryTree |
getBinaryTree()
Returns the underlying binary tree() in this heap. |
BinaryTree |
getTree()
Returns the underlying BinaryTree. |
void |
insert(Locator locator)
Inserts a Locator into this Container. |
Locator |
insert(java.lang.Object key,
java.lang.Object element)
Inserts a <key, element> pair into this Container. |
void |
insertItem(java.lang.Object key,
java.lang.Object element)
Add a (key,element) pair to the set maintained by the priority queue, making whatever internal adjustments are necessary. |
boolean |
isEmpty()
Tests if the container is empty. |
java.util.Iterator |
keys()
Returns an Iterator of all the keys within this Container. |
java.util.Iterator |
locators()
Returns an Iterator of all the Locators within this
Container. |
Locator |
makeLocator(java.lang.Object key,
java.lang.Object element)
For when you need a locator that can be inserted into this KeyBasedContainer but don't want to insert it quite yet. |
Locator |
min()
Allows access to element with first priority without removing it from the PriorityQueue. |
java.lang.Object |
minElement()
Inspect the element (not the key) with first priority, without modifying the priority queue. |
java.lang.Object |
minKey()
Inspect the key with first priority, without modifying the priority queue. |
Container |
newContainer()
|
protected Position |
nextInsert()
Retrieves the Position that the Heap will insert at next. |
protected void |
nextInsert(Position p)
Changes the position that the Heap will insert at next |
void |
remove(Locator locator)
Removes an element from this Container. |
java.lang.Object |
removeMinElement()
Remove a (key,element) pair with first priority, making whatever internal adjustments are necessary. |
java.lang.Object |
replaceElement(Locator loc,
java.lang.Object newElement)
Takes constant time -- even in key-based containers, since the element can be changed independently of the key. |
java.lang.Object |
replaceKey(Locator locator,
java.lang.Object key)
Changes the mapping of a Locator's element to a new key. |
Comparator |
setComparator(Comparator c)
This method establishes a ContainerInterfaces.Comparator that an ordered container should use to compare its elements. |
int |
size()
Number of elements in the container. |
protected void |
size(int size)
Changes the current size. |
protected BinaryTree |
tree()
Retrieve the BinaryTree. |
protected void |
upheap(Position p)
Performs the upheap operation starting at p. |
| Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
| Constructor Detail |
public BTHeap()
public BTHeap(Comparator comparator)
| Method Detail |
protected BinaryTree tree()
getBinaryTree
because it is not part of the BinaryTreeBased interface and
the return type is different.BinaryTreegetBinaryTreepublic Comparator comparator()
Comparator.Comparator that is used by this
PriorityQueue.protected Position nextInsert()
Position that the Heap will insert at next.Position to insert at.protected void nextInsert(Position p)
p - The new next insertion Positionprotected void size(int size)
size - The new size.
public Locator min()
throws EmptyContainerException
public java.lang.Object minElement()
throws EmptyContainerException
public java.lang.Object minKey()
throws EmptyContainerException
public void insertItem(java.lang.Object key,
java.lang.Object element)
throws InvalidKeyException
key - An object comparable under the implementation's
comparison schemeelement - An arbitrary object the client associates with
the key
public java.lang.Object removeMinElement()
throws EmptyContainerException
public BinaryTree getTree()
public Comparator setComparator(Comparator c)
c - A ContainerInterfaces.Comparator appropriate to the
elements stored by the containerpublic BinaryTree getBinaryTree()
protected void upheap(Position p)
p.p - The Position to start upheaping at.protected void downheap(Position p)
p.p - The Position to start downheaping at.
public void insert(Locator locator)
throws InvalidKeyException,
InvalidLocatorException,
ContainedLocatorException
locator - The Locator that is inserted into this Container.
public Locator insert(java.lang.Object key,
java.lang.Object element)
throws InvalidKeyException
key is an explicit key. That is, it is mapped to
element and used to position element within
this Container.key - The key used to position the element
within this Container.element - The element to be inserted into this
Container.element
within this Container.key
is not a type accepted by this Container (For
example: This Container is unable to use
key as a key).
public void remove(Locator locator)
throws InvalidLocatorException,
UncontainedLocatorException
locator - The Locator which points to a particular element within
this Container.locator is invalid
(For example: It does not actually reference an element in this
Container).locator is not
contained.
public java.lang.Object replaceKey(Locator locator,
java.lang.Object key)
throws InvalidLocatorException,
InvalidKeyException,
UncontainedLocatorException
locator's element will now be mapped to
key. The original key this element was mapped to is returned
Note: this method does not necessarily remove the old key (other
elements within this Container may be mapped to it).locator - The Locator which points to a particular
element within this Container.key - The new key to which locator's
element should be mapped.locator's element
was mapped.locator is
invalid (For example: It does not actually reference
an element in this Container).key
is not a type accepted by this Container (e.g. If
this Container is unable to use key
as a key).locator isn't
contained.
public java.lang.Object replaceElement(Locator loc,
java.lang.Object newElement)
throws InvalidLocatorException,
UncontainedLocatorException
loc - Locator at which replacement should occurnewElement - Element now to be stored at Locator locloc is uncontained.public java.util.Iterator locators()
Locators within this
Container. If this Container is empty then an empty
Iterator is returned.Locators stored in the
container. Note: this Iterator may be empty.elements,
Iteratorpublic java.util.Iterator keys()
Iterator is returned.elements,
Iterator
public Locator makeLocator(java.lang.Object key,
java.lang.Object element)
throws InvalidKeyException
key - the key that represents the element in this locator.element - the element for this locator.public java.util.Iterator elements()
Iterator of all the elements within this
Container. If this Container is empty then an empty Iterator is
returned.locators,
Iteratorpublic Container newContainer()
public int size()
public boolean isEmpty()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||