Class PairingHeap<E extends Comparable<E>>
java.lang.Object
smile.util.PairingHeap<E>
- Type Parameters:
E- the type of the heap elements.
- All Implemented Interfaces:
Iterable<E>, Collection<E>, Queue<E>
A pairing heap is a type of heap data structure with relatively simple
implementation and excellent practical amortized performance. Pairing
heaps are heap-ordered multiway tree structures, and can be considered
simplified Fibonacci heaps. They are considered a robust choice for
implementing such algorithms as Prim's MST algorithm.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionclassA multiway tree node in the pairing heap. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanbooleanaddAll(Collection<? extends E> c) Adds a new element to the pairing heap.voidclear()booleanbooleancontainsAll(Collection<?> c) element()booleanisEmpty()iterator()booleanpeek()poll()voidrebuild()Rebuilds the pairing heap.remove()booleanbooleanremoveAll(Collection<?> c) booleanretainAll(Collection<?> c) intsize()Object[]toArray()<T> T[]toArray(T[] a) Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface Collection
equals, hashCode, parallelStream, removeIf, spliterator, stream, toArray
-
Constructor Details
-
PairingHeap
public PairingHeap()Constructor.
-
-
Method Details
-
size
public int size()- Specified by:
sizein interfaceCollection<E extends Comparable<E>>
-
isEmpty
public boolean isEmpty()- Specified by:
isEmptyin interfaceCollection<E extends Comparable<E>>
-
addNode
Adds a new element to the pairing heap.- Parameters:
value- a new element.- Returns:
- a Node corresponding to the newly added element.
-
rebuild
public void rebuild()Rebuilds the pairing heap. Assumes that all elements inside the pairing heap are out of order due to side-channel updates. -
add
- Specified by:
addin interfaceCollection<E extends Comparable<E>>- Specified by:
addin interfaceQueue<E extends Comparable<E>>
-
offer
-
peek
-
element
-
poll
-
remove
-
clear
public void clear()- Specified by:
clearin interfaceCollection<E extends Comparable<E>>
-
addAll
- Specified by:
addAllin interfaceCollection<E extends Comparable<E>>
-
contains
- Specified by:
containsin interfaceCollection<E extends Comparable<E>>
-
containsAll
- Specified by:
containsAllin interfaceCollection<E extends Comparable<E>>
-
retainAll
- Specified by:
retainAllin interfaceCollection<E extends Comparable<E>>
-
removeAll
- Specified by:
removeAllin interfaceCollection<E extends Comparable<E>>
-
remove
- Specified by:
removein interfaceCollection<E extends Comparable<E>>
-
toArray
- Specified by:
toArrayin interfaceCollection<E extends Comparable<E>>
-
toArray
public <T> T[] toArray(T[] a) - Specified by:
toArrayin interfaceCollection<E extends Comparable<E>>
-
iterator
- Specified by:
iteratorin interfaceCollection<E extends Comparable<E>>- Specified by:
iteratorin interfaceIterable<E extends Comparable<E>>
-