COIN-OR::LEMON - Graph Library

source: lemon-0.x/src/hugo/skeletons/maps.h @ 794:d9ec436d11fe

Last change on this file since 794:d9ec436d11fe was 794:d9ec436d11fe, checked in by Alpar Juttner, 20 years ago

New doxygen module "skeletons" for the skeletons.

File size: 2.8 KB
RevLine 
[186]1// -*- c++ -*-
2#ifndef HUGO_MAPSKELETON_H
3#define HUGO_MAPSKELETON_H
4
[794]5///\ingroup skeletons
[242]6///\file
7///\brief Map concepts checking classes for testing and documenting.
8
[186]9namespace hugo {
[282]10
11  /// The namespace of HUGOlib concepts and concept checking classes
12  namespace skeleton {
[186]13 
[794]14    /// \addtogroup skeletons
15    /// @{
16
[282]17    /// Readable map concept
18    template<typename K, typename T>
[732]19    class ReadMap
[282]20    {
21    public:
22      /// Map's key type.
23      typedef K KeyType;   
24      /// Map's value type. (The type of objects associated with the keys).
25      typedef T ValueType;
[186]26
[282]27      /// Returns the value associated with a key.
28      ValueType operator[](const KeyType &k) const {return ValueType();}
[186]29
[732]30      ///Default constructor
31      ReadMap() {}
[282]32    };
33
34
35    /// Writable map concept
36    template<typename K, typename T>
[732]37    class WriteMap
[282]38    {
39    public:
40      /// Map's key type.
41      typedef K KeyType;   
42      /// Map's value type. (The type of objects associated with the keys).
43      typedef T ValueType;
44
45      /// Sets the value associated with a key.
46      void set(const KeyType &k,const ValueType &t) {}
47
[732]48      ///Default constructor
49      WriteMap() {}
[282]50    };
51
52    ///Read/Writeable map concept
53    template<typename K, typename T>
[732]54    class ReadWriteMap : public ReadMap<K,T>,
55                            public WriteMap<K,T>
[282]56    {
57    public:
58      /// Map's key type.
59      typedef K KeyType;   
60      /// Map's value type. (The type of objects associated with the keys).
61      typedef T ValueType;
62
63      /// Returns the value associated with a key.
64      ValueType operator[](const KeyType &k) const {return ValueType();}
65      /// Sets the value associated with a key.
66      void set(const KeyType &k,const ValueType &t) {}
67
[732]68      ///Default constructor
69      ReadWriteMap() {}
[282]70    };
[186]71 
72 
[282]73    ///Dereferable map concept
74    template<typename K, typename T>
[732]75    class ReferenceMap : public ReadWriteMap<K,T>
[282]76    {
77    public:
78      /// Map's key type.
79      typedef K KeyType;   
80      /// Map's value type. (The type of objects associated with the keys).
81      typedef T ValueType;
[732]82
83    protected:
84      ValueType tmp;
85    public:
[282]86      typedef ValueType& ReferenceType;
87      /// Map's const reference type.
88      typedef const ValueType& ConstReferenceType;
[186]89
[282]90      ///Returns a reference to the value associated to a key.
[732]91      ReferenceType operator[](const KeyType &i) { return tmp; }
[282]92      ///Returns a const reference to the value associated to a key.
[732]93      ConstReferenceType operator[](const KeyType &i) const
94      { return tmp; }
[282]95      /// Sets the value associated with a key.
96      void set(const KeyType &k,const ValueType &t) { operator[](k)=t; }
[186]97
[732]98      ///Default constructor
99      ReferenceMap() {}
[282]100    };
[794]101
102    // @}
103
[732]104  } //namespace skeleton
105} //namespace hugo
[186]106#endif // HUGO_MAPSKELETON_H
Note: See TracBrowser for help on using the repository browser.