Package org.jheaps
Interface Heap<K>
-
- Type Parameters:
K
- the type of keys maintained by this heap
- All Known Subinterfaces:
DoubleEndedHeap<K>
,DoubleEndedValueHeap<K,V>
,MergeableHeap<K>
,ValueHeap<K,V>
- All Known Implementing Classes:
BigIntegerRadixHeap
,BinaryArrayBulkInsertWeakHeap
,BinaryArrayHeap
,BinaryArrayIntegerValueHeap
,BinaryArrayWeakHeap
,BinaryTreeSoftHeap
,DaryArrayHeap
,DoubleRadixHeap
,IntegerRadixHeap
,LongRadixHeap
,MinMaxBinaryArrayDoubleEndedHeap
public interface Heap<K>
A heap.- Author:
- Dimitrios Michail
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
clear()
Clear all the elements of this heap.Comparator<? super K>
comparator()
Returns the comparator used to order the keys in this heap, ornull
if this heap uses the natural ordering of its keys.K
deleteMin()
Delete and return an element with the minimum key.K
findMin()
Find an element with the minimum key.void
insert(K key)
Insert a key into the heap.boolean
isEmpty()
Returnstrue
if this heap is empty.long
size()
Returns the number of elements in this heap.
-
-
-
Method Detail
-
comparator
Comparator<? super K> comparator()
Returns the comparator used to order the keys in this heap, ornull
if this heap uses the natural ordering of its keys.- Returns:
- the comparator used to order the keys in this heap, or
null
if this heap uses the natural ordering of its keys
-
insert
void insert(K key)
Insert a key into the heap.- Parameters:
key
- the key to insert
-
findMin
K findMin()
Find an element with the minimum key.- Returns:
- an element with the minimum key
- Throws:
NoSuchElementException
- if the heap is empty
-
deleteMin
K deleteMin()
Delete and return an element with the minimum key. If multiple such elements exists, only one of them will be deleted.- Returns:
- the deleted element with the minimum key
- Throws:
NoSuchElementException
- if the heap is empty
-
isEmpty
boolean isEmpty()
Returnstrue
if this heap is empty.- Returns:
true
if this heap is empty,false
otherwise
-
size
long size()
Returns the number of elements in this heap.- Returns:
- the number of elements in this heap
-
clear
void clear()
Clear all the elements of this heap.
-
-