COIN-OR::LEMON - Graph Library

Changeset 209:765619b7cbb2 in lemon for lemon/concepts/maps.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/maps.h

    r114 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
     
    4848
    4949      /// Returns the value associated with the given key.
    50       Value operator[](const Key &) const { 
     50      Value operator[](const Key &) const {
    5151        return *static_cast<Value *>(0);
    5252      }
     
    5454      template<typename _ReadMap>
    5555      struct Constraints {
    56         void constraints() {
    57           Value val = m[key];
    58           val = m[key];
    59           typename _ReadMap::Value own_val = m[own_key];
    60           own_val = m[own_key];
    61 
    62           ignore_unused_variable_warning(key);
    63           ignore_unused_variable_warning(val);
    64           ignore_unused_variable_warning(own_key);
    65           ignore_unused_variable_warning(own_val);
    66         }
    67         const Key& key;
    68         const typename _ReadMap::Key& own_key;
    69         const _ReadMap& m;
     56        void constraints() {
     57          Value val = m[key];
     58          val = m[key];
     59          typename _ReadMap::Value own_val = m[own_key];
     60          own_val = m[own_key];
     61
     62          ignore_unused_variable_warning(key);
     63          ignore_unused_variable_warning(val);
     64          ignore_unused_variable_warning(own_key);
     65          ignore_unused_variable_warning(own_val);
     66        }
     67        const Key& key;
     68        const typename _ReadMap::Key& own_key;
     69        const _ReadMap& m;
    7070      };
    7171
     
    9494      template <typename _WriteMap>
    9595      struct Constraints {
    96         void constraints() {
    97           m.set(key, val);
    98           m.set(own_key, own_val);
    99 
    100           ignore_unused_variable_warning(key);
    101           ignore_unused_variable_warning(val);
    102           ignore_unused_variable_warning(own_key);
    103           ignore_unused_variable_warning(own_val);
    104         }
    105         const Key& key;
    106         const Value& val;
    107         const typename _WriteMap::Key& own_key;
    108         const typename _WriteMap::Value& own_val;
    109         _WriteMap& m;
     96        void constraints() {
     97          m.set(key, val);
     98          m.set(own_key, own_val);
     99
     100          ignore_unused_variable_warning(key);
     101          ignore_unused_variable_warning(val);
     102          ignore_unused_variable_warning(own_key);
     103          ignore_unused_variable_warning(own_val);
     104        }
     105        const Key& key;
     106        const Value& val;
     107        const typename _WriteMap::Key& own_key;
     108        const typename _WriteMap::Value& own_val;
     109        _WriteMap& m;
    110110      };
    111111    };
     
    117117    template<typename K, typename T>
    118118    class ReadWriteMap : public ReadMap<K,T>,
    119                         public WriteMap<K,T>
     119                        public WriteMap<K,T>
    120120    {
    121121    public:
     
    126126
    127127      /// Returns the value associated with the given key.
    128       Value operator[](const Key &) const { 
     128      Value operator[](const Key &) const {
    129129        return *static_cast<Value *>(0);
    130130      }
     
    135135      template<typename _ReadWriteMap>
    136136      struct Constraints {
    137         void constraints() {
    138           checkConcept<ReadMap<K, T>, _ReadWriteMap >();
    139           checkConcept<WriteMap<K, T>, _ReadWriteMap >();
    140         }
     137        void constraints() {
     138          checkConcept<ReadMap<K, T>, _ReadWriteMap >();
     139          checkConcept<WriteMap<K, T>, _ReadWriteMap >();
     140        }
    141141      };
    142142    };
     
    165165
    166166      /// Returns a reference to the value associated with the given key.
    167       Reference operator[](const Key &) { 
     167      Reference operator[](const Key &) {
    168168        return *static_cast<Value *>(0);
    169169      }
     
    179179      template<typename _ReferenceMap>
    180180      struct Constraints {
    181         void constraints() {
    182           checkConcept<ReadWriteMap<K, T>, _ReferenceMap >();
    183           ref = m[key];
    184           m[key] = val;
    185           m[key] = ref;
    186           m[key] = cref;
    187           own_ref = m[own_key];
    188           m[own_key] = own_val;
    189           m[own_key] = own_ref;
    190           m[own_key] = own_cref;
    191           m[key] = m[own_key];
    192           m[own_key] = m[key];
    193         }
    194         const Key& key;
    195         Value& val;
    196         Reference ref;
    197         ConstReference cref;
    198         const typename _ReferenceMap::Key& own_key;
    199         typename _ReferenceMap::Value& own_val;
    200         typename _ReferenceMap::Reference own_ref;
    201         typename _ReferenceMap::ConstReference own_cref;
    202         _ReferenceMap& m;
     181        void constraints() {
     182          checkConcept<ReadWriteMap<K, T>, _ReferenceMap >();
     183          ref = m[key];
     184          m[key] = val;
     185          m[key] = ref;
     186          m[key] = cref;
     187          own_ref = m[own_key];
     188          m[own_key] = own_val;
     189          m[own_key] = own_ref;
     190          m[own_key] = own_cref;
     191          m[key] = m[own_key];
     192          m[own_key] = m[key];
     193        }
     194        const Key& key;
     195        Value& val;
     196        Reference ref;
     197        ConstReference cref;
     198        const typename _ReferenceMap::Key& own_key;
     199        typename _ReferenceMap::Value& own_val;
     200        typename _ReferenceMap::Reference own_ref;
     201        typename _ReferenceMap::ConstReference own_cref;
     202        _ReferenceMap& m;
    203203      };
    204204    };
Note: See TracChangeset for help on using the changeset viewer.