#include <lemon/bin_heap.h>
Compare
specifies the ordering of the priorities. In a heap one can change the priority of an item, add or erase an item, etc.
Item | Type of the items to be stored. | |
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> . |
Public Types | |
enum | state_enum |
Type to represent the items states. More... | |
Public Member Functions | |
BinHeap (ItemIntMap &_iim) | |
The constructor. | |
BinHeap (ItemIntMap &_iim, const Compare &_comp) | |
The constructor. | |
int | size () const |
Returns the number of items stored in the heap. | |
bool | empty () const |
Checks if the heap stores no items. | |
void | push (const PairType &p) |
Insert a pair of item and priority into the heap. | |
void | push (const Item &i, const Prio &p) |
Insert an item into the heap with the given heap. | |
Item | top () const |
Returns the item with minimum priority relative to Compare . | |
Prio | prio () const |
Returns the minimum priority relative to Compare . | |
void | pop () |
Deletes the item with minimum priority relative to Compare . | |
void | erase (const Item &i) |
Deletes i from the heap. | |
Prio | operator[] (const Item &i) const |
Returns the priority of i . | |
void | set (const Item &i, const Prio &p) |
i gets to the heap with priority p independently if i was already there. | |
void | decrease (const Item &i, const Prio &p) |
Decreases the priority of i to p . | |
void | increase (const Item &i, const Prio &p) |
Increases the priority of i to p . | |
state_enum | state (const Item &i) const |
Returns if item is in, has already been in, or has never been in the heap. |
|
Each Item element have a state associated to it. It may be "in heap", "pre heap" or "post heap". The latter two are indifferent from the heap's point of view, but may be useful to the user. The ItemIntMap should be initialized in such way that it maps PRE_HEAP (-1) to any element to be put in the heap... |
|
The constructor.
|
|
The constructor.
|
|
The number of items stored in the heap. |
|
Returns |
|
Adds
|
|
Adds
|
|
This method returns the item with minimum priority relative to
|
|
It returns the minimum priority relative to
|
|
This method deletes the item with minimum priority relative to
|
|
This method deletes item
|
|
This function returns the priority of item
|
|
This method calls push(
|
|
This method decreases the priority of item
|
|
This method sets the priority of item
|
|
This method returns PRE_HEAP if
|