#include <lemon/linear_heap.h>
_Item | Type of the items to be stored. | |
_ItemIntMap | A read and writable Item int map, used internally to handle the cross references. | |
minimize | If the given parameter is true then the heap gives back the lowest priority. |
Public Types | |
enum | state_enum |
Type to represent the items states. More... | |
Public Member Functions | |
LinearHeap (ItemIntMap &_index) | |
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 | clear () |
Make empty this heap. | |
void | push (const Pair &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 priority. | |
Item | top () const |
Returns the item with minimum priority. | |
Prio | prio () const |
Returns the minimum priority. | |
void | pop () |
Deletes the item with minimum priority. | |
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. | |
void | state (const Item &i, state_enum st) |
Sets the state of the item 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 number of items stored in the heap. |
|
Returns |
|
Make empty this heap. |
|
Adds
|
|
Adds
|
|
This method returns the item with minimum priority.
|
|
It returns the minimum priority.
|
|
This method deletes the item with minimum priority from the heap.
|
|
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
|
|
Sets the state of the
|