Package cpsc331.collections
Interface BoundedMaxHeap<T extends java.lang.Comparable<T>>
-
public interface BoundedMaxHeap<T extends java.lang.Comparable<T>>
Provides an interface for an bounded binary MaxHeap
BoundedMaxHeap Invariant: A finite multiset of values of ordered type T is stored in a bounded binary MaxHeap
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description T
deleteMax()
int
getCapacity()
int
getSize()
void
insert(T v)
-
-
-
Method Detail
-
insert
void insert(T v) throws HeapFullException
- Parameters:
v
- the value to be inserted into this binary MaxHeap- Throws:
HeapFullException
- if this bounded MaxHeap is already full
Precondition:
- The BoundedMaxHeap Invariant is satisfied.
- A value v with type T has been given as input.
- The BoundedMaxHeap Invariant is satisfied.
- If this BoundedMaxHeap is not already full then a copy of the value v has been inserted into the multiset represented by this binary MaxHeap, and no other changes have been made. A HeapFullException is thrown, and this bounded MaxHeap is not changed, otherwise.
-
deleteMax
T deleteMax() throws java.util.NoSuchElementException
- Returns:
- the value that was deleted from this BoundedMaxHeap
- Throws:
java.util.NoSuchElementException
- if this BoundedMaxHeap was already empty
Precondition:
- The BoundedMaxHeap Invariant is satisfied.
- The MaxHeap Invariant is satisfied.
- If this MinHeap was not empty then a copy of the largest element is removed from the multiset represented by this MaxHeap and returned as output, and no other changes to this multiset have been made. A NoSuChElementException is thrown if this heap was already empty, an it is not changed.
-
getSize
int getSize()
- Returns:
- the current size of this MaxHeap
Precondition:
- The BoundedMaxHeap Invariant is satisfied.
- This BoundedMaxHeap has not changed, so the BoundedMaxHeap Invariant is still satisfied.
- The size of this BoundedMaxHeap has been returned as output.
-
getCapacity
int getCapacity()
- Returns:
- the capacity of this BoundedMaxHeap
Precondition:
- The BoundedMaxHeap Invariant is satisfied.
- This BoundedMaxHeap has not changed, so the BoundedMaxHeap Invariant is still satisfied.
- The capacity of this BoundedMaxHeap has been returned as output.
-
-