V - the type of the values stored in the heapP - the type of the prioritiespublic class FibonacciHeap<V,P> extends Object implements Iterable<ai.grakn.graql.internal.gremlin.spanningtree.datastructure.FibonacciHeap.Entry>
This implementation was inspired and informed by those of Nathan L. Fiedler (https://github.com/nlfiedler/graphmaker/blob/990227c766a9891be1d4669c582975f7c1a4db87/core/src/com/bluemarsh/graphmaker/core/util/FibonacciHeap.java), and Keith Schwarz (htiek@cs.stanford.edu) (http://www.keithschwarz.com/interesting/code/?dir=fibonacci-heap), but rewritten from scratch by Sam Thomson (sthomson@cs.cmu.edu).
| Modifier and Type | Field and Description |
|---|---|
static int |
MAX_CAPACITY |
| Modifier and Type | Method and Description |
|---|---|
Optional<ai.grakn.graql.internal.gremlin.spanningtree.datastructure.FibonacciHeap.Entry> |
add(V value,
P priority)
Inserts a new entry into the heap and returns the entry if heap is not full.
|
void |
clear()
Removes all elements from the heap.
|
Comparator<? super P> |
comparator()
Returns the comparator used to order the elements in this
queue.
|
static <T,C extends Comparable> |
create()
Create a new FibonacciHeap based on the natural ordering on `C`
|
static <T,C> FibonacciHeap<T,C> |
create(Comparator<? super C> comparator) |
void |
decreasePriority(ai.grakn.graql.internal.gremlin.spanningtree.datastructure.FibonacciHeap.Entry entry,
P newPriority)
Decreases the priority for an entry.
|
boolean |
isEmpty()
Returns true if the heap is empty, false otherwise.
|
Iterator<ai.grakn.graql.internal.gremlin.spanningtree.datastructure.FibonacciHeap.Entry> |
iterator()
Returns every entry in this heap, in no particular order.
|
static <U,P> FibonacciHeap<U,P> |
merge(FibonacciHeap<U,P> a,
FibonacciHeap<U,P> b)
Joins two Fibonacci heaps into a new one.
|
Optional<ai.grakn.graql.internal.gremlin.spanningtree.datastructure.FibonacciHeap.Entry> |
peekOption()
Returns the entry with the minimum priority, or absent if empty.
|
Optional<V> |
pollOption()
Removes the smallest element from the heap.
|
void |
remove(ai.grakn.graql.internal.gremlin.spanningtree.datastructure.FibonacciHeap.Entry entry)
Deletes `entry` from the heap.
|
int |
size()
Returns the number of elements in the heap.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitforEach, spliteratorpublic static final int MAX_CAPACITY
public static <T,C> FibonacciHeap<T,C> create(Comparator<? super C> comparator)
public static <T,C extends Comparable> FibonacciHeap<T,C> create()
public Comparator<? super P> comparator()
public void clear()
public void decreasePriority(ai.grakn.graql.internal.gremlin.spanningtree.datastructure.FibonacciHeap.Entry entry,
P newPriority)
public void remove(ai.grakn.graql.internal.gremlin.spanningtree.datastructure.FibonacciHeap.Entry entry)
public boolean isEmpty()
public Optional<ai.grakn.graql.internal.gremlin.spanningtree.datastructure.FibonacciHeap.Entry> add(V value, P priority)
public Optional<ai.grakn.graql.internal.gremlin.spanningtree.datastructure.FibonacciHeap.Entry> peekOption()
public Optional<V> pollOption()
public int size()
public static <U,P> FibonacciHeap<U,P> merge(FibonacciHeap<U,P> a, FibonacciHeap<U,P> b)
Copyright © 2017 Grakn Labs Ltd. All rights reserved.