bin_heap< T, Pred > Class Template Reference

Binary heap. More...

List of all members.

Public Member Functions

 bin_heap (const Pred &prd)
 Creates empty binary heap.
 bin_heap (const Pred &prd, const int est_size)
 Creates empty binary heap.
 bin_heap (const bin_heap< T, Pred > &bh)
 Copy constructor.
bin_heap< T, Pred > & operator= (const bin_heap< T, Pred > &bh)
 Assigns bh to this binary heap.
 ~bin_heap ()
 Destructor.
void push (const T &ins)
 Inserts ins in heap.
void pop ()
 Removes the element on top of the heap.
const T & top () const
 Returns a reference to the element at the top of the heap.
void changeKey (const T &cha)
 Reconstructs heap condition after changing key value of cha externally.
bool is_empty () const
 Checks if heap is empty.


Detailed Description

template<class T, class Pred>
class bin_heap< T, Pred >

Binary heap.

Author:
Christian Bachmaier chris@infosun.fmi.uni-passau.de

Constructor & Destructor Documentation

template<class T, class Pred>
bin_heap< T, Pred >::bin_heap ( const Pred &  prd  )  [inline]

Creates empty binary heap.

Parameters:
prd binary predicate to compare two Ts

template<class T, class Pred>
bin_heap< T, Pred >::bin_heap ( const Pred &  prd,
const int  est_size 
) [inline]

Creates empty binary heap.

Parameters:
prd binary predicate to compare two Ts
est_size estimated maximal size of heap

template<class T, class Pred>
bin_heap< T, Pred >::bin_heap ( const bin_heap< T, Pred > &  bh  )  [inline]

Copy constructor.

Parameters:
bh binary heap to copy


Member Function Documentation

template<class T, class Pred>
bin_heap< T, Pred > & bin_heap< T, Pred >::operator= ( const bin_heap< T, Pred > &  bh  )  [inline]

Assigns bh to this binary heap.

All elements in this heap will be deleted. The predicate of this heap must be physically the same as the one of bh.

Parameters:
bh binary heap
Returns:
this heap

template<class T, class Pred>
void bin_heap< T, Pred >::push ( const T &  ins  )  [inline]

Inserts ins in heap.

Parameters:
ins data element to be inserted

template<class T, class Pred>
const T & bin_heap< T, Pred >::top (  )  const [inline]

Returns a reference to the element at the top of the heap.

Returns:
top element of the heap

template<class T, class Pred>
void bin_heap< T, Pred >::changeKey ( const T &  cha  )  [inline]

Reconstructs heap condition after changing key value of cha externally.

Parameters:
cha element with changed key value
Note:
changeKey doesn't operate if cha is a primitive data structure, because it represents its key value itself, or if one object is stored more than once in the data structure.
See also:
dijkstra

template<class T, class Pred>
bool bin_heap< T, Pred >::is_empty (  )  const [inline]

Checks if heap is empty.

Returns:
true iff empty