COIN-OR::LEMON - Graph Library

Changeset 1902:e9af75c90c28 in lemon-0.x for lemon/linear_heap.h


Ignore:
Timestamp:
01/25/06 13:10:18 (18 years ago)
Author:
Balazs Dezso
Branch:
default
Phase:
public
Convert:
svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@2477
Message:

state setting function for heaps

If we know that which elements were in the heap then
we can clear it in better time complexity.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • lemon/linear_heap.h

    r1875 r1902  
    284284    }
    285285
     286    /// \brief Sets the state of the \c item in the heap.
     287    ///
     288    /// Sets the state of the \c item in the heap. It can be used to
     289    /// manually clear the heap when it is important to achive the
     290    /// better time complexity.
     291    /// \param i The item.
     292    /// \param st The state. It should not be \c IN_HEAP.
     293    void state(const Item& i, state_enum st) {
     294      switch (st) {
     295      case POST_HEAP:
     296      case PRE_HEAP:
     297        if (state(i) == IN_HEAP) {
     298          erase(i);
     299        }
     300        index[i] = st;
     301        break;
     302      }
     303    }
     304
    286305  private:
    287306
     
    460479    }
    461480
     481    void state(const Item& i, state_enum st) {
     482      switch (st) {
     483      case POST_HEAP:
     484      case PRE_HEAP:
     485        if (state(i) == IN_HEAP) {
     486          erase(i);
     487        }
     488        index[i] = st;
     489        break;
     490      }
     491    }
     492
    462493  private:
    463494
Note: See TracChangeset for help on using the changeset viewer.