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

Heap Class Template Reference
[Concepts]

#include <lemon/concept/heap.h>

List of all members.


Detailed Description

template<typename Item, typename Prio, typename ItemIntMap>
class lemon::concept::Heap< Item, Prio, ItemIntMap >

A concept structure describes the main interface of heaps.


Public Types

enum  state_enum
 Type to represent the items states. More...

Public Member Functions

 Heap (ItemIntMap &_iim)
 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 Item &i, const Prio &p)
 Insert an item into the heap with the given heap.
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.


Member Enumeration Documentation

enum state_enum
 

Each Item element have a state associated to it. It may be "in heap", "pre heap" or "post heap". The later 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...


Constructor & Destructor Documentation

Heap ItemIntMap &  _iim  )  [inline, explicit]
 

The constructor.

Parameters:
_iim should be given to the constructor, since it is used internally to handle the cross references. The value of the map should be PRE_HEAP (-1) for each element.


Member Function Documentation

int size  )  const [inline]
 

The number of items stored in the heap.

bool empty  )  const [inline]
 

Returns true if and only if the heap stores no items.

void push const Item &  i,
const Prio &  p
[inline]
 

Adds i to the heap with priority p.

Parameters:
i The item to insert.
p The priority of the item.

Item top  )  const [inline]
 

This method returns the item with minimum priority.

Precondition:
The heap must be nonempty.

Prio prio  )  const [inline]
 

It returns the minimum priority.

Precondition:
The heap must be nonempty.

void pop  )  [inline]
 

This method deletes the item with minimum priority.

Precondition:
The heap must be non-empty.

void erase const Item &  i  )  [inline]
 

This method deletes item i from the heap, if i was already stored in the heap.

Parameters:
i The item to erase.

Prio operator[] const Item &  i  )  const [inline]
 

This function returns the priority of item i.

Precondition:
i must be in the heap.
Parameters:
i The item.

void set const Item &  i,
const Prio &  p
[inline]
 

This method calls push(i, p) if i is not stored in the heap and sets the priority of i to p otherwise. It may throw an UnderFlowPriorityException.

Parameters:
i The item.
p The priority.

void decrease const Item &  i,
const Prio &  p
[inline]
 

This method decreases the priority of item i to p.

Precondition:
i must be stored in the heap with priority at least p.
Parameters:
i The item.
p The priority.

void increase const Item &  i,
const Prio &  p
[inline]
 

This method sets the priority of item i to p.

Precondition:
i must be stored in the heap with priority at most p relative to Compare.
Parameters:
i The item.
p The priority.

state_enum state const Item &  i  )  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.

Parameters:
i The item.


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