src/include/bin_heap.h
changeset 274 28728f3945c5
parent 258 94bafec4f56f
child 430 60e4627e8c74
     1.1 --- a/src/include/bin_heap.h	Thu Apr 01 15:32:31 2004 +0000
     1.2 +++ b/src/include/bin_heap.h	Thu Apr 01 21:06:53 2004 +0000
     1.3 @@ -1,3 +1,5 @@
     1.4 +// -*- C++ -*- //
     1.5 +
     1.6  /* FIXME: Copyright ... 
     1.7   *
     1.8   * This implementation is heavily based on STL's heap functions and
     1.9 @@ -59,12 +61,16 @@
    1.10  #ifndef BIN_HEAP_HH
    1.11  #define BIN_HEAP_HH
    1.12  
    1.13 +///\file
    1.14 +///\brief Binary Heap implementation.
    1.15 +
    1.16  #include <vector>
    1.17  #include <utility>
    1.18  #include <functional>
    1.19  
    1.20  namespace hugo {
    1.21  
    1.22 +  /// A Binary Heap implementation.
    1.23    template <typename Item, typename Prio, typename ItemIntMap,
    1.24  	    typename Compare = std::less<Prio> >
    1.25    class BinHeap {
    1.26 @@ -85,6 +91,8 @@
    1.27       * The ItemIntMap _should_ be initialized in such way, that it maps
    1.28       * PRE_HEAP (-1) to any element to be put in the heap...
    1.29       */
    1.30 +    ///\todo it is used nowhere
    1.31 +    ///
    1.32      enum state_enum {
    1.33        IN_HEAP = 0,
    1.34        PRE_HEAP = -1,
    1.35 @@ -140,11 +148,10 @@
    1.36      void push(const Item &i, const Prio &p) { push(PairType(i,p)); }
    1.37  
    1.38      Item top() const {
    1.39 -      // FIXME: test size>0 ?
    1.40        return data[0].first;
    1.41      }
    1.42 -    Prio topPrio() const {
    1.43 -      // FIXME: test size>0 ?
    1.44 +    /// Returns the prio of the top element of the heap.
    1.45 +    Prio prio() const {
    1.46        return data[0].second;
    1.47      }
    1.48  
    1.49 @@ -156,13 +163,11 @@
    1.50        rmidx(iim[i]);
    1.51      }
    1.52  
    1.53 -    Prio get(const Item &i) const {
    1.54 +    Prio operator[](const Item &i) const {
    1.55        int idx = iim[i];
    1.56        return data[idx].second;
    1.57      }
    1.58 -    Prio operator[](const Item &i) const {
    1.59 -      return get(i);
    1.60 -    }
    1.61 +
    1.62      void set(const Item &i, const Prio &p) {
    1.63        int idx = iim[i];
    1.64        if( idx < 0 ) {