COIN-OR::LEMON - Graph Library

source: lemon-0.x/src/include/skeletons/maps.h @ 280:19f3943521ab

Last change on this file since 280:19f3943521ab was 254:483ba4ffe90a, checked in by Alpar Juttner, 21 years ago
File size: 2.0 KB
Line 
1// -*- c++ -*-
2#ifndef HUGO_MAPSKELETON_H
3#define HUGO_MAPSKELETON_H
4
5///\file
6///\brief Map concepts checking classes for testing and documenting.
7
8namespace hugo {
9 
10  ///Readable map skeleton
11  template<typename K, typename T>
12  class ReadMapSkeleton
13  {
14  public:
15    /// Map value type.
16    typedef T ValueType;
17    /// Map key type.
18    typedef K KeyType;
19
20    ///Default constructor.
21    ReadMapSkeleton() {}
22   
23    ///Reads an element of the map.
24    ValueType operator[](const KeyType &i) const {return ValueType();}
25  };
26
27
28  ///Writeable map skeleton
29  template<typename K, typename T>
30  class WriteMapSkeleton
31  {
32  public:
33    /// Map value type.
34    typedef T ValueType;
35    /// Map key type.
36    typedef K KeyType;
37
38    ///Default constructor.
39    WriteMapSkeleton() {}
40    ///'Fill with' constructor.
41    WriteMapSkeleton(const ValueType &t) {}
42   
43    ///Write an element of a map.
44    void set(const KeyType &i,const ValueType &t) {}
45  };
46
47  ///Read/Write map skeleton.
48  template<typename K, typename T>
49  class ReadWriteMapSkeleton : public ReadMapSkeleton<K,T>,
50                               public WriteMapSkeleton<K,T>
51  {
52  public:
53    ///Default constructor.
54    ReadWriteMapSkeleton() : ReadMapSkeleton(), WriteMapSkeleton() {}
55    ///'Fill with' constructor.
56    ReadWriteMap(const ValueType &t) :ReadMapSkeleton(), WriteMapSkeleton(t) {}
57  };
58 
59 
60  ///Dereferable map skeleton
61  template<typename K, typename T>
62  class MemoryMapSkeleton : public ReadWriteMapSkeleton<K,T>
63  {
64  public:
65    /// Map value type.
66    typedef T ValueType;
67    /// Map key type.
68    typedef K KeyType;
69
70    ///Default constructor.
71    ReferenceMapSkeleton() : ReadWriteMapSkeleton() {}
72    ///'Fill with' constructor.
73    ReferenceMapSkeleton(const ValueType &t) : ReadWriteMapSkeleton(t) {}   
74
75    ///Give a reference to the value belonging to a key.
76    ValueType &operator[](const KeyType &i) {return *(ValueType*)0;}
77    ///Give a const reference to the value belonging to a key.
78    const ValueType &operator[](const KeyType &i) const {return *(T*)0;}
79  };
80
81
82
83}
84#endif // HUGO_MAPSKELETON_H
Note: See TracBrowser for help on using the repository browser.