Compare specifies the ordering of the priorities. In a heap one can change the priority of an item, add or erase an item, etc.The methods increase and erase are not efficient in a Fibonacci heap. In case of many calls to these operations, it is better to use a binary heap.
| _Prio | Type of the priority of the items. | |
| _ItemIntMap | A read and writable Item int map, used internally to handle the cross references. | |
| _Compare | A class for the ordering of the priorities. The default is std::less<_Prio>. |
#include <lemon/fib_heap.h>
Public Types | |
| enum | State { IN_HEAP = 0, PRE_HEAP = -1, POST_HEAP = -2 } |
| Status of the nodes. More... | |
Public Member Functions | |
| FibHeap (ItemIntMap &_iimap) | |
| The constructor. | |
| FibHeap (ItemIntMap &_iimap, const Compare &_comp) | |
| The constructor. | |
| int | size () const |
| The number of items stored in the heap. | |
| bool | empty () const |
| Checks if the heap stores no items. | |
| void | clear () |
| Make empty this heap. | |
| void | set (const Item &item, const Prio &value) |
item gets to the heap with priority value independently if item was already there. | |
| void | push (const Item &item, const Prio &value) |
Adds item to the heap with priority value. | |
| Item | top () const |
Returns the item with minimum priority relative to Compare. | |
| const Prio & | prio () const |
Returns the minimum priority relative to Compare. | |
| const Prio & | operator[] (const Item &item) const |
Returns the priority of item. | |
| void | pop () |
Deletes the item with minimum priority relative to Compare. | |
| void | erase (const Item &item) |
Deletes item from the heap. | |
| void | decrease (Item item, const Prio &value) |
Decreases the priority of item to value. | |
| void | increase (Item item, const Prio &value) |
Increases the priority of item to value. | |
| State | state (const Item &item) const |
Returns if item is in, has already been in, or has never been in the heap. | |
| void | state (const Item &i, State st) |
Sets the state of the item in the heap. | |
| enum State |
| FibHeap | ( | ItemIntMap & | _iimap | ) | [inline, explicit] |
_iimap should be given to the constructor, since it is used internally to handle the cross references.
| FibHeap | ( | ItemIntMap & | _iimap, | |
| const Compare & | _comp | |||
| ) | [inline] |
_iimap should be given to the constructor, since it is used internally to handle the cross references. _comp is an object for ordering of the priorities.
| int size | ( | ) | const [inline] |
Returns the number of items stored in the heap.
| bool empty | ( | ) | const [inline] |
Returns true if and only if the heap stores no items.
| void clear | ( | ) | [inline] |
Make empty this heap. It does not change the cross reference map. If you want to reuse a heap what is not surely empty you should first clear the heap and after that you should set the cross reference map for each item to PRE_HEAP.
| void set | ( | const Item & | item, | |
| const Prio & | value | |||
| ) | [inline] |
| void push | ( | const Item & | item, | |
| const Prio & | value | |||
| ) | [inline] |
Adds item to the heap with priority value.
item must not be stored in the heap. | Item top | ( | ) | const [inline] |
This method returns the item with minimum priority relative to Compare.
| const Prio& prio | ( | ) | const [inline] |
It returns the minimum priority relative to Compare.
| const Prio& operator[] | ( | const Item & | item | ) | const [inline] |
It returns the priority of item.
item must be in the heap. | void pop | ( | ) | [inline] |
This method deletes the item with minimum priority relative to Compare from the heap.
| void erase | ( | const Item & | item | ) | [inline] |
This method deletes item from the heap, if item was already stored in the heap. It is quite inefficient in Fibonacci heaps.
| void decrease | ( | Item | item, | |
| const Prio & | value | |||
| ) | [inline] |
This method decreases the priority of item to value.
item must be stored in the heap with priority at least value relative to Compare. | void increase | ( | Item | item, | |
| const Prio & | value | |||
| ) | [inline] |
This method sets the priority of item to value. Though there is no precondition on the priority of item, this method should be used only if it is indeed necessary to increase (relative to Compare) the priority of item, because this method is inefficient.
| State state | ( | const Item & | item | ) | const [inline] |
This method returns PRE_HEAP if item has never been in the heap, IN_HEAP if it is in the heap at the moment, and POST_HEAP otherwise. In the latter case it is possible that item will get back to the heap again.
| void state | ( | const Item & | i, | |
| State | st | |||
| ) | [inline] |
Sets the state of the item in the heap. It can be used to manually clear the heap when it is important to achive the better time complexity.
| i | The item. | |
| st | The state. It should not be IN_HEAP. |
1.5.9