MinHeap< TKey, TValue > Class Template Reference

Priority queue implemented as a heap. More...

Collaboration diagram for MinHeap< TKey, TValue >:
[legend]

List of all members.

Public Types

typedef TKey Key
typedef TKey Key
typedef TValue Value
typedef TValue Value

Public Member Functions

void Init ()
 Initializes an empty priority queue.
void Init ()
 Initializes an empty priority queue.
bool is_empty () const
 Detects whether this queue is empty.
bool is_empty () const
 Detects whether this queue is empty.
Value Pop ()
 Pops and returns the lowest element off the heap.
Value Pop ()
 Pops and returns the lowest element off the heap.
void PopOnly ()
 Removes the lowest element from the heap.
void PopOnly ()
 Removes the lowest element from the heap.
void Put (Key key, Value value)
 Places a value at the specified priority.
void Put (Key key, Value value)
 Places a value at the specified priority.
void set_top (Value v)
 Replaces the top item on the heap.
void set_top (Value v)
 Replaces the top item on the heap.
index_t size () const
 Gets the size of the heap.
index_t size () const
 Gets the size of the heap.
Value top () const
 Gets the value at the top of the heap.
Value top () const
 Gets the value at the top of the heap.
Key top_key () const
 Gets the key at the top of the heap.
Key top_key () const
 Gets the key at the top of the heap.

Detailed Description

template<typename TKey, typename TValue = Empty>
class MinHeap< TKey, TValue >

Priority queue implemented as a heap.

Note that a heap isn't really a collection, but actually it is just a prioritization data structure. Storing large objects in will incur copy overheads, so Key and Value should probably be either primitives (integers, floats, pointers) or small structures.

Definition at line 53 of file heap.h.


Member Function Documentation

template<typename TKey, typename TValue = Empty>
void MinHeap< TKey, TValue >::Init (  )  [inline]

Initializes an empty priority queue.

Definition at line 81 of file heap.h.

template<typename TKey, typename TValue = Empty>
void MinHeap< TKey, TValue >::Init (  )  [inline]

Initializes an empty priority queue.

Definition at line 81 of file heap.h.

Referenced by GrainQueue< Grain >::Init().

template<typename TKey, typename TValue = Empty>
bool MinHeap< TKey, TValue >::is_empty (  )  const [inline]

Detects whether this queue is empty.

Definition at line 88 of file heap.h.

template<typename TKey, typename TValue = Empty>
bool MinHeap< TKey, TValue >::is_empty (  )  const [inline]

Detects whether this queue is empty.

Definition at line 88 of file heap.h.

template<typename TKey, typename TValue = Empty>
Value MinHeap< TKey, TValue >::Pop (  )  [inline]

Pops and returns the lowest element off the heap.

Returns:
the value associated with the highest priority

Definition at line 114 of file heap.h.

template<typename TKey, typename TValue = Empty>
Value MinHeap< TKey, TValue >::Pop (  )  [inline]

Pops and returns the lowest element off the heap.

Returns:
the value associated with the highest priority

Definition at line 114 of file heap.h.

Referenced by GrainQueue< Grain >::Pop().

template<typename TKey, typename TValue = Empty>
void MinHeap< TKey, TValue >::PopOnly (  )  [inline]

Removes the lowest element from the heap.

Simply pops the top value on the queue, without returning it.

Definition at line 128 of file heap.h.

template<typename TKey, typename TValue = Empty>
void MinHeap< TKey, TValue >::PopOnly (  )  [inline]

Removes the lowest element from the heap.

Simply pops the top value on the queue, without returning it.

Definition at line 128 of file heap.h.

Referenced by MinHeap< double, Grain * >::Pop().

template<typename TKey, typename TValue = Empty>
void MinHeap< TKey, TValue >::Put ( Key  key,
Value  value 
) [inline]

Places a value at the specified priority.

Parameters:
key the priority
value the value associated with the priority

Definition at line 98 of file heap.h.

template<typename TKey, typename TValue = Empty>
void MinHeap< TKey, TValue >::Put ( Key  key,
Value  value 
) [inline]

Places a value at the specified priority.

Parameters:
key the priority
value the value associated with the priority

Definition at line 98 of file heap.h.

Referenced by GrainQueue< Grain >::Put().

template<typename TKey, typename TValue = Empty>
void MinHeap< TKey, TValue >::set_top ( Value  v  )  [inline]

Replaces the top item on the heap.

Definition at line 154 of file heap.h.

template<typename TKey, typename TValue = Empty>
void MinHeap< TKey, TValue >::set_top ( Value  v  )  [inline]

Replaces the top item on the heap.

Definition at line 154 of file heap.h.

template<typename TKey, typename TValue = Empty>
index_t MinHeap< TKey, TValue >::size (  )  const [inline]

Gets the size of the heap.

Definition at line 161 of file heap.h.

template<typename TKey, typename TValue = Empty>
index_t MinHeap< TKey, TValue >::size (  )  const [inline]

Gets the size of the heap.

Definition at line 161 of file heap.h.

Referenced by GrainQueue< Grain >::Pop(), and GrainQueue< Grain >::size().

template<typename TKey, typename TValue = Empty>
Value MinHeap< TKey, TValue >::top (  )  const [inline]

Gets the value at the top of the heap.

Definition at line 140 of file heap.h.

template<typename TKey, typename TValue = Empty>
Value MinHeap< TKey, TValue >::top (  )  const [inline]

Gets the value at the top of the heap.

Definition at line 140 of file heap.h.

template<typename TKey, typename TValue = Empty>
Key MinHeap< TKey, TValue >::top_key (  )  const [inline]

Gets the key at the top of the heap.

Definition at line 147 of file heap.h.

template<typename TKey, typename TValue = Empty>
Key MinHeap< TKey, TValue >::top_key (  )  const [inline]

Gets the key at the top of the heap.

Definition at line 147 of file heap.h.


The documentation for this class was generated from the following files:
Generated on Mon Jan 24 12:04:40 2011 for FASTlib by  doxygen 1.6.3