File: map_pair.h

package info (click to toggle)
mldemos 0.5.1-3
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 32,224 kB
  • ctags: 46,525
  • sloc: cpp: 306,887; ansic: 167,718; ml: 126; sh: 109; makefile: 2
file content (74 lines) | stat: -rw-r--r-- 1,929 bytes parent folder | download | duplicates (12)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
// Copyright (C) 2003  Davis E. King (davis@dlib.net)
// License: Boost Software License   See LICENSE.txt for the full license.
#ifndef DLIB_MAP_PAIr_INTERFACE_
#define DLIB_MAP_PAIr_INTERFACE_

namespace dlib
{

// ----------------------------------------------------------------------------------------
    
    template <
        typename T1,
        typename T2
        >
    class map_pair  
    {
        /*!
            POINTERS AND REFERENCES TO INTERNAL DATA
                None of the functions in map_pair will invalidate
                pointers or references to internal data when called.

            WHAT THIS OBJECT REPRESENTS
                this object is used to return the key/value pair used in the 
                map and hash_map containers when using the enumerable interface.

                note that the enumerable interface is defined in
                interfaces/enumerable.h
        !*/

    public:
        typedef T1 key_type;
        typedef T2 value_type;

        virtual ~map_pair(
        )=0;

        virtual const T1& key( 
        ) const =0;
        /*!
            ensures
                - returns a const reference to the key
        !*/

        virtual const T2& value(
        ) const =0;
        /*!
            ensures
                - returns a const reference to the value associated with key
        !*/

        virtual T2& value(
        )=0;
        /*!
            ensures
                - returns a non-const reference to the value associated with key
        !*/

    protected:

        // restricted functions
        map_pair<T1,T2>& operator=(const map_pair<T1,T2>&) {return *this;} // no assignment operator

    };

    // destructor does nothing
    template <typename T1,typename T2> 
    map_pair<T1,T2>::~map_pair () {}

// ----------------------------------------------------------------------------------------

}

#endif // DLIB_MAP_PAIr_INTERFACE_