Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

FibHeap Class Template Reference
[Auxiliary Data Structures]

#include <lemon/fib_heap.h>

List of all members.


Detailed Description

template<typename Item, typename Prio, typename ItemIntMap, typename Compare>
class lemon::FibHeap< Item, Prio, ItemIntMap, Compare >

This class implements the Fibonacci heap data structure. A heap is a data structure for storing items with specified values called priorities in such a way that finding the item with minimum priority is efficient. 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.

Parameters:
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>.
See also:
BinHeap

Dijkstra

Author:
Jacint Szabo


Public Types

enum  state_enum { 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 set (Item const item, PrioType const value)
 item gets to the heap with priority value independently if item was already there.
void push (Item const item, PrioType const value)
 Adds item to the heap with priority value.
Item top () const
 Returns the item with minimum priority relative to Compare.
PrioType prio () const
 Returns the minimum priority relative to Compare.
PrioType & operator[] (const Item &item)
 Returns the priority of item.
const PrioType & 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, PrioType const value)
 Decreases the priority of item to value.
void increase (Item item, PrioType const value)
 Increases the priority of item to value.
state_enum state (const Item &item) const
 Returns if item is in, has already been in, or has never been in the heap.


Member Enumeration Documentation

enum state_enum
 

Enumerator:
IN_HEAP  The node is in the heap.
PRE_HEAP  The node has never been in the heap.
POST_HEAP  The node was in the heap but it got out of it.


Constructor & Destructor Documentation

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.


Member Function Documentation

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.

Item top  )  const [inline]
 

This method returns the item with minimum priority relative to Compare.

Precondition:
The heap must be nonempty.

PrioType prio  )  const [inline]
 

It returns the minimum priority relative to Compare.

Precondition:
The heap must be nonempty.

PrioType& operator[] const Item &  item  )  [inline]
 

This function returns the priority of item.

Precondition:
item must be in the heap.

const PrioType& operator[] const Item &  item  )  const [inline]
 

It returns the priority of item.

Precondition:
item must be in the heap.

void increase Item  item,
PrioType const   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_enum 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.


The documentation for this class was generated from the following file:
Generated on Sat Aug 27 14:15:31 2005 for LEMON by  doxygen 1.4.4