public class IdentifiableBinaryHeap<E extends Identifiable & java.lang.Comparable> extends java.lang.Object implements IdentifiablePriorityQueue<E>
Constructor and Description |
---|
IdentifiableBinaryHeap() |
IdentifiableBinaryHeap(int initialCapacity) |
Modifier and Type | Method and Description |
---|---|
void |
clear()
Empties the queue.
|
E |
deleteElementAt(int index) |
E |
deleteMin()
Deletes the minimum element in the queue.
|
int |
findElementIndex(E element) |
E |
findMin()
Finds the minimum element in the queue.
|
E |
getElement(long id)
Returns the element with the input ID, if the element exists; otherwise, returns null.
|
void |
insert(E element)
Inserts an element into the queue.
|
boolean |
isEmpty()
Determines whether the queue is empty or not.
|
E |
replaceElement(long id, E newElement)
Replace the old element of the specified id with a new element.
|
void |
setIndex(E element, int index) |
int |
size()
Returns the size of the queue.
|
java.lang.String |
toString() |
public IdentifiableBinaryHeap()
public IdentifiableBinaryHeap(int initialCapacity)
public void clear()
PriorityQueue
clear
in interface PriorityQueue<E extends Identifiable & java.lang.Comparable>
public E getElement(long id)
IdentifiablePriorityQueue
getElement
in interface IdentifiablePriorityQueue<E extends Identifiable & java.lang.Comparable>
id
- ID of the elementpublic void insert(E element)
PriorityQueue
insert
in interface PriorityQueue<E extends Identifiable & java.lang.Comparable>
public E replaceElement(long id, E newElement)
IdentifiablePriorityQueue
replaceElement
in interface IdentifiablePriorityQueue<E extends Identifiable & java.lang.Comparable>
id
- ID of the old elementnewElement
- new elementpublic int findElementIndex(E element)
public E deleteElementAt(int index)
public int size()
PriorityQueue
size
in interface PriorityQueue<E extends Identifiable & java.lang.Comparable>
public boolean isEmpty()
PriorityQueue
isEmpty
in interface PriorityQueue<E extends Identifiable & java.lang.Comparable>
public E findMin()
PriorityQueue
findMin
in interface PriorityQueue<E extends Identifiable & java.lang.Comparable>
public E deleteMin()
PriorityQueue
deleteMin
in interface PriorityQueue<E extends Identifiable & java.lang.Comparable>
public void setIndex(E element, int index)
public java.lang.String toString()
toString
in class java.lang.Object