Package org.jheaps.array
Class AbstractArrayHeap<K>
java.lang.Object
org.jheaps.array.AbstractArrayWeakHeap<K>
org.jheaps.array.AbstractArrayHeap<K>
- Type Parameters:
K
- the type of keys maintained by this heap
- All Implemented Interfaces:
Serializable
,Heap<K>
- Direct Known Subclasses:
BinaryArrayHeap
,DaryArrayHeap
,MinMaxBinaryArrayDoubleEndedHeap
Abstract implementation of a heap using an array representation.
-
Field Summary
FieldsFields inherited from class org.jheaps.array.AbstractArrayWeakHeap
array, comparator, DOWNSIZING_MIN_HEAP_CAPACITY, MAX_HEAP_CAPACITY, MIN_HEAP_CAPACITY, minCapacity, size
-
Constructor Summary
ConstructorsConstructorDescriptionAbstractArrayHeap
(Comparator<? super K> comparator, int capacity) Construct a new heap -
Method Summary
Methods inherited from class org.jheaps.array.AbstractArrayWeakHeap
checkCapacity, clear, comparator, ensureCapacity, fixdown, fixdownWithComparator, fixup, fixupWithComparator, isEmpty, size
-
Field Details
-
serialVersionUID
private static final long serialVersionUID- See Also:
-
-
Constructor Details
-
AbstractArrayHeap
Construct a new heap- Parameters:
comparator
- the comparator to usecapacity
- the initial capacity
-
-
Method Details
-
initCapacity
protected void initCapacity(int capacity) Initialize the array representation- Specified by:
initCapacity
in classAbstractArrayWeakHeap<K>
- Parameters:
capacity
- the capacity
-
findMin
Find an element with the minimum key.- Returns:
- an element with the minimum key
-
insert
Insert a key into the heap.- Parameters:
key
- the key to insert
-
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
-