COIN-OR::LEMON - Graph Library

Changeset 209:765619b7cbb2 in lemon-main for lemon/concepts/heap.h


Ignore:
Timestamp:
07/13/08 20:51:02 (16 years ago)
Author:
Alpar Juttner <alpar@…>
Branch:
default
Phase:
public
Message:

Apply unify-sources.sh to the source tree

File:
1 edited

Legend:

Unmodified
Added
Removed
  • lemon/concepts/heap.h

    r203 r209  
    1 /* -*- C++ -*-
    2  *
    3  * This file is a part of LEMON, a generic C++ optimization library
     1/* -*- mode: C++; indent-tabs-mode: nil; -*-
     2 *
     3 * This file is a part of LEMON, a generic C++ optimization library.
    44 *
    55 * Copyright (C) 2003-2008
     
    5353      /// the user.
    5454      ///
    55       /// The \c ItemIntMap must be initialized in such a way, that it 
     55      /// The \c ItemIntMap must be initialized in such a way, that it
    5656      /// assigns \c PRE_HEAP (<tt>-1</tt>) to every item.
    5757      enum State {
    58         IN_HEAP = 0,
    59         PRE_HEAP = -1,
    60         POST_HEAP = -2
     58        IN_HEAP = 0,
     59        PRE_HEAP = -1,
     60        POST_HEAP = -2
    6161      };
    62      
     62
    6363      /// \brief The constructor.
    6464      ///
     
    8686
    8787      /// \brief Inserts an item into the heap with the given priority.
    88       ///   
    89       /// Inserts the given item into the heap with the given priority. 
     88      ///
     89      /// Inserts the given item into the heap with the given priority.
    9090      /// \param i The item to insert.
    9191      /// \param p The priority of the item.
     
    113113      ///
    114114      /// Removes the given item from the heap if it is already stored.
    115       /// \param i The item to delete. 
     115      /// \param i The item to delete.
    116116      void erase(const Item &i) {}
    117117
    118118      /// \brief The priority of an item.
    119119      ///
    120       /// Returns the priority of the given item. 
     120      /// Returns the priority of the given item.
    121121      /// \pre \c i must be in the heap.
    122122      /// \param i The item.
     
    134134      /// \param p The priority.
    135135      void set(const Item &i, const Prio &p) {}
    136      
     136
    137137      /// \brief Decreases the priority of an item to the given value.
    138138      ///
     
    175175      struct Constraints {
    176176      public:
    177         void constraints() {
    178           typedef typename _Heap::Item OwnItem;
    179           typedef typename _Heap::Prio OwnPrio;
    180           typedef typename _Heap::State OwnState;
    181 
    182           Item item;
    183           Prio prio;
    184           item=Item();
    185           prio=Prio();
    186           ignore_unused_variable_warning(item);
    187           ignore_unused_variable_warning(prio);
    188 
    189           OwnItem own_item;
    190           OwnPrio own_prio;
    191           OwnState own_state;
    192           own_item=Item();
    193           own_prio=Prio();
    194           ignore_unused_variable_warning(own_item);
    195           ignore_unused_variable_warning(own_prio);
    196           ignore_unused_variable_warning(own_state);
    197 
    198           _Heap heap1(map);
    199           _Heap heap2 = heap1;
    200           ignore_unused_variable_warning(heap1);
    201           ignore_unused_variable_warning(heap2);
    202          
    203           int s = heap.size();
    204           ignore_unused_variable_warning(s);
    205           bool e = heap.empty();
    206           ignore_unused_variable_warning(e);
    207 
    208           prio = heap.prio();
    209           item = heap.top();
    210           prio = heap[item];
    211           own_prio = heap.prio();
    212           own_item = heap.top();
    213           own_prio = heap[own_item];
    214 
    215           heap.push(item, prio);
    216           heap.push(own_item, own_prio);
    217           heap.pop();
    218 
    219           heap.set(item, prio);
    220           heap.decrease(item, prio);
    221           heap.increase(item, prio);
    222           heap.set(own_item, own_prio);
    223           heap.decrease(own_item, own_prio);
    224           heap.increase(own_item, own_prio);
    225 
    226           heap.erase(item);
    227           heap.erase(own_item);
    228           heap.clear();
    229 
    230           own_state = heap.state(own_item);
    231           heap.state(own_item, own_state);
    232 
    233           own_state = _Heap::PRE_HEAP;
    234           own_state = _Heap::IN_HEAP;
    235           own_state = _Heap::POST_HEAP;
    236         }
    237 
    238         _Heap& heap;
    239         ItemIntMap& map;
     177        void constraints() {
     178          typedef typename _Heap::Item OwnItem;
     179          typedef typename _Heap::Prio OwnPrio;
     180          typedef typename _Heap::State OwnState;
     181
     182          Item item;
     183          Prio prio;
     184          item=Item();
     185          prio=Prio();
     186          ignore_unused_variable_warning(item);
     187          ignore_unused_variable_warning(prio);
     188
     189          OwnItem own_item;
     190          OwnPrio own_prio;
     191          OwnState own_state;
     192          own_item=Item();
     193          own_prio=Prio();
     194          ignore_unused_variable_warning(own_item);
     195          ignore_unused_variable_warning(own_prio);
     196          ignore_unused_variable_warning(own_state);
     197
     198          _Heap heap1(map);
     199          _Heap heap2 = heap1;
     200          ignore_unused_variable_warning(heap1);
     201          ignore_unused_variable_warning(heap2);
     202
     203          int s = heap.size();
     204          ignore_unused_variable_warning(s);
     205          bool e = heap.empty();
     206          ignore_unused_variable_warning(e);
     207
     208          prio = heap.prio();
     209          item = heap.top();
     210          prio = heap[item];
     211          own_prio = heap.prio();
     212          own_item = heap.top();
     213          own_prio = heap[own_item];
     214
     215          heap.push(item, prio);
     216          heap.push(own_item, own_prio);
     217          heap.pop();
     218
     219          heap.set(item, prio);
     220          heap.decrease(item, prio);
     221          heap.increase(item, prio);
     222          heap.set(own_item, own_prio);
     223          heap.decrease(own_item, own_prio);
     224          heap.increase(own_item, own_prio);
     225
     226          heap.erase(item);
     227          heap.erase(own_item);
     228          heap.clear();
     229
     230          own_state = heap.state(own_item);
     231          heap.state(own_item, own_state);
     232
     233          own_state = _Heap::PRE_HEAP;
     234          own_state = _Heap::IN_HEAP;
     235          own_state = _Heap::POST_HEAP;
     236        }
     237
     238        _Heap& heap;
     239        ItemIntMap& map;
    240240      };
    241241    };
Note: See TracChangeset for help on using the changeset viewer.