Project
Loading...
Searching...
No Matches
Interval.h
Go to the documentation of this file.
1// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3// All rights not expressly granted are reserved.
4//
5// This software is distributed under the terms of the GNU General Public
6// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7//
8// In applying this license CERN does not waive the privileges and immunities
9// granted to it by virtue of its status as an Intergovernmental Organization
10// or submit itself to any jurisdiction.
11
14
15#ifndef O2_MCH_CONTOUR_INTERVAL_H
16#define O2_MCH_CONTOUR_INTERVAL_H
17
18#include <vector>
19#include <ostream>
20#include "Helper.h"
21
22namespace o2
23{
24namespace mch
25{
26namespace contour
27{
28namespace impl
29{
30template <typename T>
32{
33 public:
34 Interval(T b = {}, T e = {}) : mBegin(b), mEnd(e)
35 {
36 if (b > e || areEqual(b, e)) {
37 throw std::invalid_argument("begin should be strictly < end");
38 }
39 }
40
42 {
43 return (i.begin() < mBegin || areEqual(i.begin(), mBegin)) && (mEnd < i.end() || areEqual(i.end(), mEnd));
44 }
45
46 T begin() const { return mBegin; }
47
48 T end() const { return mEnd; }
49
50 bool extend(const Interval& i)
51 {
52 if (areEqual(i.begin(), end())) {
53 mEnd = i.end();
54 return true;
55 } else {
56 return false;
57 }
58 }
59
60 bool operator==(const Interval& rhs) const { return areEqual(mBegin, rhs.mBegin) && areEqual(mEnd, rhs.mEnd); }
61
62 bool operator!=(const Interval& rhs) const { return !(rhs == *this); }
63
64 private:
65 T mBegin;
66 T mEnd;
67};
68
69template <typename T>
70inline std::ostream& operator<<(std::ostream& os, const Interval<T>& i)
71{
72 os << "[" << i.begin() << "," << i.end() << "]";
73 return os;
74}
75
76} // namespace impl
77} // namespace contour
78} // namespace mch
79} // namespace o2
80
81#endif
int32_t i
bool operator!=(const Interval &rhs) const
Definition Interval.h:62
bool isFullyContainedIn(Interval i) const
Definition Interval.h:41
bool operator==(const Interval &rhs) const
Definition Interval.h:60
bool extend(const Interval &i)
Definition Interval.h:50
GLuint GLuint end
Definition glcorearb.h:469
GLboolean GLboolean GLboolean b
Definition glcorearb.h:1233
bool areEqual(double a, double b)
Definition Helper.h:41
std::ostream & operator<<(std::ostream &os, const ManhattanEdge< T > &edge)
Definition Edge.h:150
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...