Package org.basex.util
Class MinHeap<K,V>
- java.lang.Object
-
- org.basex.util.MinHeap<K,V>
-
- Type Parameters:
K
- key typeV
- value type
public final class MinHeap<K,V> extends Object
A min-heap.- Author:
- BaseX Team 2005-24, BSD License, Leo Woerteler
-
-
Constructor Summary
Constructors Constructor Description MinHeap(Comparator<K> comp)
Constructs a heap with the given initial capacity and order.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
insert(K key, V value)
Inserts the given key/value pair into the heap.boolean
isEmpty()
Checks if this heap is empty.V
removeMin()
Removes the minimum from this heap.int
size()
Size of this heap.String
toString()
-
-
-
Constructor Detail
-
MinHeap
public MinHeap(Comparator<K> comp)
Constructs a heap with the given initial capacity and order.- Parameters:
comp
- comparator
-
-
Method Detail
-
insert
public void insert(K key, V value)
Inserts the given key/value pair into the heap.- Parameters:
key
- keyvalue
- value
-
removeMin
public V removeMin()
Removes the minimum from this heap.- Returns:
- the removed entry's value
-
size
public int size()
Size of this heap.- Returns:
- number of entries
-
isEmpty
public boolean isEmpty()
Checks if this heap is empty.- Returns:
true
if heap is empty,false
otherwise
-
-