File: set_compare_abstract.h

package info (click to toggle)
concurrentqueue 1.0.3%2Bds-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 2,648 kB
  • sloc: cpp: 37,303; makefile: 88; ansic: 67; python: 46; sh: 18
file content (96 lines) | stat: -rw-r--r-- 3,089 bytes parent folder | download | duplicates (14)
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
// Copyright (C) 2005  Davis E. King (davis@dlib.net)
// License: Boost Software License   See LICENSE.txt for the full license.
#undef DLIB_SET_COMPARe_ABSTRACT_
#ifdef DLIB_SET_COMPARe_ABSTRACT_

#include "set_kernel_abstract.h"

#include "../algs.h"


namespace dlib
{

    template <
        typename set_base
        >
    class set_compare : public set_base
    {

        /*!
            REQUIREMENTS ON set_base
                must be an implementation of set/set_kernel_abstract.h

            POINTERS AND REFERENCES TO INTERNAL DATA
                operator== and operator< invalidate pointers or references to 
                data members.

            WHAT THIS EXTENSION DOES FOR set
                This gives a set the ability to compare itself to other 
                sets using the < and == operators. 

                The < operator is conceptually weird for sets.  It is useful 
                though because it allows you to make sets of sets since
                sets require that their containing type implement operator<.

                Also note that it is the case that for any two sets a and b 
                if (a<b) == false and (b<a) == false then a == b. 

                Also note that unless specified otherwise, no member functions
                of this object throw exceptions.
               

            NOTATION
                For the purposes of defining what these operators do I will 
                use the operator[] to reference the elements of the sets.
                operator[] is defined to access the elements of the set in 
                the same order they would be enumerated by the enumerable 
                interface.
        !*/

        public:

            bool operator< (
                const set_compare& rhs
            ) const;
            /*!
                ensures
                    - #at_start() == true
                    - if (size() < rhs.size()) then
                        - returns true
                    - else if (size() > rhs.size()) then
                        - returns false
                    - else
                        - returns true if there exists an integer j such that 0 <= j < size() 
                          and for all integers i such that 0 <= i < j where it is true that
                          (*this)[i] == rhs[i] and (*this)[j] < rhs[j] 
                        - returns false if there is no j that will satisfy the above conditions.                    
            !*/

            bool operator== (
                const set_compare& rhs
            ) const;
            /*!
                ensures
                    - #at_start() == true
                    - returns true if *this and rhs contain the same elements.
                      returns false otherwise.
            !*/
    };


    template <
        typename set_base
        >
    inline void swap (
        set_compare<set_base>& a, 
        set_compare<set_base>& b 
    ) { a.swap(b); } 
    /*!
        provides a global swap function
    !*/

}

#endif // DLIB_SET_COMPARe_ABSTRACT_