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 voidclear()Clear all the elements of this heap.Comparator<? super K>comparator()Returns the comparator used to order the keys in this heap, ornullif this heap uses the natural ordering of its keys.KdeleteMin()Delete and return an element with the minimum key.KfindMin()Find an element with the minimum key.voidinsert(K key)Insert a key into the heap.booleanisEmpty()Returnstrueif this heap is empty.longsize()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, ornullif this heap uses the natural ordering of its keys.- Returns:
- the comparator used to order the keys in this heap, or
nullif 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()
Returnstrueif this heap is empty.- Returns:
trueif this heap is empty,falseotherwise
-
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.
-
-