类 FibonacciMinPQ<Key>
- java.lang.Object
-
- edu.princeton.cs.algs4.FibonacciMinPQ<Key>
-
- 所有已实现的接口:
java.lang.Iterable<Key>
public class FibonacciMinPQ<Key> extends java.lang.Object implements java.lang.Iterable<Key>
-
-
构造器概要
构造器 构造器 说明 FibonacciMinPQ()
Initializes an empty priority queue Worst case is O(1)FibonacciMinPQ(java.util.Comparator<Key> C)
Initializes an empty priority queue Worst case is O(1)FibonacciMinPQ(java.util.Comparator<Key> C, Key[] a)
Initializes a priority queue with given keys Worst case is O(n)FibonacciMinPQ(Key[] a)
Initializes a priority queue with given keys Worst case is O(n)
-
方法概要
修饰符和类型 方法 说明 Key
delMin()
Deletes the minimum key Worst case is O(log(n)) (amortized)void
insert(Key key)
Insert a key in the queue Worst case is O(1)boolean
isEmpty()
Whether the priority queue is empty Worst case is O(1)java.util.Iterator<Key>
iterator()
Gets an Iterator over the Keys in the priority queue in ascending order The Iterator does not implement the remove() method iterator() : Worst case is O(n) next() : Worst case is O(log(n)) (amortized) hasNext() : Worst case is O(1)Key
minKey()
Gets the minimum key currently in the queue Worst case is O(1)int
size()
Number of elements currently on the priority queue Worst case is O(1)FibonacciMinPQ<Key>
union(FibonacciMinPQ<Key> that)
Merges two heaps together This operation is destructive Worst case is O(1)
-
-
-
构造器详细资料
-
FibonacciMinPQ
public FibonacciMinPQ(java.util.Comparator<Key> C)
Initializes an empty priority queue Worst case is O(1)- 参数:
C
- a Comparator over the Keys
-
FibonacciMinPQ
public FibonacciMinPQ()
Initializes an empty priority queue Worst case is O(1)
-
FibonacciMinPQ
public FibonacciMinPQ(Key[] a)
Initializes a priority queue with given keys Worst case is O(n)- 参数:
a
- an array of keys
-
-
方法详细资料
-
isEmpty
public boolean isEmpty()
Whether the priority queue is empty Worst case is O(1)- 返回:
- true if the priority queue is empty, false if not
-
size
public int size()
Number of elements currently on the priority queue Worst case is O(1)- 返回:
- the number of elements on the priority queue
-
insert
public void insert(Key key)
Insert a key in the queue Worst case is O(1)- 参数:
key
- a Key
-
minKey
public Key minKey()
Gets the minimum key currently in the queue Worst case is O(1)- 返回:
- the minimum key currently in the priority queue
- 抛出:
java.util.NoSuchElementException
- if the priority queue is empty
-
delMin
public Key delMin()
Deletes the minimum key Worst case is O(log(n)) (amortized)- 返回:
- the minimum key
- 抛出:
java.util.NoSuchElementException
- if the priority queue is empty
-
union
public FibonacciMinPQ<Key> union(FibonacciMinPQ<Key> that)
Merges two heaps together This operation is destructive Worst case is O(1)- 参数:
that
- a Fibonacci heap- 返回:
- the union of the two heaps
-
iterator
public java.util.Iterator<Key> iterator()
Gets an Iterator over the Keys in the priority queue in ascending order The Iterator does not implement the remove() method iterator() : Worst case is O(n) next() : Worst case is O(log(n)) (amortized) hasNext() : Worst case is O(1)- 指定者:
iterator
在接口中java.lang.Iterable<Key>
- 返回:
- an Iterator over the Keys in the priority queue in ascending order
-
-