]>
git.ipfire.org Git - thirdparty/squid.git/blob - src/base/Range.h
2 * Copyright (C) 1996-2019 The Squid Software Foundation and contributors
4 * Squid software is distributed under GPLv2+ license and includes
5 * contributions from numerous individuals and organizations.
6 * Please see the COPYING and CONTRIBUTORS files for details.
15 /* represents [start, end) */
17 template <class C
, class S
= size_t>
23 Range (C start_
, C end_
);
26 Range
intersection (Range
const &) const;
27 bool contains(C
const &) const;
31 template <class C
, class S
>
32 std::ostream
& operator << (std::ostream
&os
, Range
<C
, S
> const &aRange
)
34 os
<< "[" << aRange
.start
<< "," << aRange
.end
<< ")";
38 template<class C
, class S
>
39 Range
<C
, S
>::Range () : start(), end() {}
41 template<class C
, class S
>
42 Range
<C
, S
>::Range (C start_
, C end_
) : start(start_
), end(end_
) {}
44 template<class C
, class S
>
46 Range
<C
, S
>::intersection (Range
const &rhs
) const
48 Range
<C
, S
> result (max(start
, rhs
.start
), min(end
, rhs
.end
));
52 template<class C
, class S
>
54 Range
<C
, S
>::contains(C
const &value
) const {
56 return (start
<= value
&& value
<= end
);
59 template<class C
, class S
>
61 Range
<C
, S
>::size() const
63 return (S
) (end
> start
? end
- start
: 0);
66 #endif /* SQUID_RANGE_H */