SoDaRadio-5.0.3-master:8901fb5
src
RangeMap.hxx
Go to the documentation of this file.
1
#ifndef RANGE_MAP_HDR
2
#define RANGE_MAP_HDR
3
/*
4
Copyright (c) 2014, Matthew H. Reilly (kb1vc)
5
All rights reserved.
6
7
Redistribution and use in source and binary forms, with or without
8
modification, are permitted provided that the following conditions are
9
met:
10
11
Redistributions of source code must retain the above copyright
12
notice, this list of conditions and the following disclaimer.
13
Redistributions in binary form must reproduce the above copyright
14
notice, this list of conditions and the following disclaimer in
15
the documentation and/or other materials provided with the
16
distribution.
17
18
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22
HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29
*/
30
40
#include <map>
41
42
namespace
SoDa
{
47
template
<
typename
Tk>
class
Range
{
48
public
:
49
Range
(Tk _min, Tk _max) {
50
min
= _min;
51
max
= _max;
52
}
53
54
Range
(Tk _c) {
55
min
= _c;
56
max
= _c;
57
}
58
59
Tk
getMin
()
const
{
return
min
; }
60
Tk
getMax
()
const
{
return
max
; }
61
62
63
64
private
:
65
Tk
min
,
max
;
66
};
67
68
template
<
typename
Tk>
struct
leftOfRange
:
public
std::binary_function< Range<Tk>, Range<Tk>, bool>
69
{
70
bool
operator() (
Range<Tk>
const
& l,
71
Range<Tk>
const
& r)
const
{
72
return
((l.
getMin
() < r.
getMin
()) && (l.
getMax
() <= r.
getMin
()));
73
}
74
};
75
76
template
<
typename
Tk,
typename
Tv>
class
RangeMap
:
public
std::map<Range<Tk>, Tv, leftOfRange<Tk> > {
77
public
:
78
RangeMap
() :
std
::map<
Range
<Tk>, Tv,
leftOfRange
<Tk> >() {
79
}
80
81
protected
:
82
};
83
}
84
85
86
#endif
SoDa::RangeMap::RangeMap
RangeMap()
Definition:
RangeMap.hxx:78
SoDa::Range::getMin
Tk getMin() const
Definition:
RangeMap.hxx:59
std
STL namespace.
SoDa::Range::max
Tk max
Definition:
RangeMap.hxx:65
SoDa::Range::Range
Range(Tk _min, Tk _max)
Definition:
RangeMap.hxx:49
SoDa::Range::getMax
Tk getMax() const
Definition:
RangeMap.hxx:60
SoDa::leftOfRange
Definition:
RangeMap.hxx:68
SoDa
Definition:
AudioALSA.cxx:42
SoDa::Range::Range
Range(Tk _c)
Definition:
RangeMap.hxx:54
SoDa::Range::min
Tk min
Definition:
RangeMap.hxx:65
SoDa::Range
a template class for mapping ranges to thingies This represents an open interval – thanks to suggest...
Definition:
RangeMap.hxx:47
SoDa::RangeMap
Definition:
RangeMap.hxx:76
Generated on Sun Sep 24 2017 12:16:38 for SoDaRadio-5.0.3-master:8901fb5 by
1.8.13