Package oracle.spatial.network.lod
Class IdentifiableBinaryHeap<E extends Identifiable & java.lang.Comparable>
- java.lang.Object
-
- oracle.spatial.network.lod.IdentifiableBinaryHeap<E>
-
- All Implemented Interfaces:
BinaryHeap.IndexKeeper<E>,IdentifiablePriorityQueue<E>,PriorityQueue<E>
public class IdentifiableBinaryHeap<E extends Identifiable & java.lang.Comparable> extends java.lang.Object implements IdentifiablePriorityQueue<E>, BinaryHeap.IndexKeeper<E>
a binary Min. heap priority queue implementation Note the elements have to implement the Identifiable and Comparable interface (int compareTo(Object obj) )
-
-
Constructor Summary
Constructors Constructor Description IdentifiableBinaryHeap()IdentifiableBinaryHeap(int initialCapacity)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclear()Empties the queue.EdeleteElementAt(int index)EdeleteMin()Deletes the minimum element in the queue.intfindElementIndex(E element)EfindMin()Finds the minimum element in the queue.EgetElement(long id)Returns the element with the input ID, if the element exists; otherwise, returns null.voidinsert(E element)Inserts an element into the queue.booleanisEmpty()Determines whether the queue is empty or not.EreplaceElement(long id, E newElement)Replace the old element of the specified id with a new element.voidsetIndex(E element, int index)intsize()Returns the size of the queue.java.lang.StringtoString()
-
-
-
Method Detail
-
clear
public void clear()
Description copied from interface:PriorityQueueEmpties the queue.- Specified by:
clearin interfacePriorityQueue<E extends Identifiable & java.lang.Comparable>
-
getElement
public E getElement(long id)
Description copied from interface:IdentifiablePriorityQueueReturns the element with the input ID, if the element exists; otherwise, returns null.- Specified by:
getElementin interfaceIdentifiablePriorityQueue<E extends Identifiable & java.lang.Comparable>- Parameters:
id- ID of the element- Returns:
-
insert
public void insert(E element)
Description copied from interface:PriorityQueueInserts an element into the queue.- Specified by:
insertin interfacePriorityQueue<E extends Identifiable & java.lang.Comparable>
-
replaceElement
public E replaceElement(long id, E newElement)
Description copied from interface:IdentifiablePriorityQueueReplace the old element of the specified id with a new element. The ID of the new element does not need to be the same as the old element. If the old element does not exist in the queue, then simply insert the new element into the queue.- Specified by:
replaceElementin interfaceIdentifiablePriorityQueue<E extends Identifiable & java.lang.Comparable>- Parameters:
id- ID of the old elementnewElement- new element- Returns:
-
findElementIndex
public int findElementIndex(E element)
-
deleteElementAt
public E deleteElementAt(int index)
-
size
public int size()
Description copied from interface:PriorityQueueReturns the size of the queue.- Specified by:
sizein interfacePriorityQueue<E extends Identifiable & java.lang.Comparable>- Returns:
-
isEmpty
public boolean isEmpty()
Description copied from interface:PriorityQueueDetermines whether the queue is empty or not.- Specified by:
isEmptyin interfacePriorityQueue<E extends Identifiable & java.lang.Comparable>- Returns:
-
findMin
public E findMin()
Description copied from interface:PriorityQueueFinds the minimum element in the queue. This method is non-destructive peeking. The queue is left untouched.- Specified by:
findMinin interfacePriorityQueue<E extends Identifiable & java.lang.Comparable>- Returns:
- the minimum element in the queue. If the queue is empty, return null.
-
deleteMin
public E deleteMin()
Description copied from interface:PriorityQueueDeletes the minimum element in the queue.- Specified by:
deleteMinin interfacePriorityQueue<E extends Identifiable & java.lang.Comparable>- Returns:
- the minimum element in the queue. If the queue is empty, return null.
-
setIndex
public void setIndex(E element, int index)
- Specified by:
setIndexin interfaceBinaryHeap.IndexKeeper<E extends Identifiable & java.lang.Comparable>
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-