Concordia
interval.hpp
1 #ifndef INTERVAL_HDR
2 #define INTERVAL_HDR
3 
4 #include "concordia/common/config.hpp"
5 #include <iostream>
6 
16 class Interval {
17 public:
22  explicit Interval(const SUFFIX_MARKER_TYPE start,
23  const SUFFIX_MARKER_TYPE end);
24 
27  virtual ~Interval();
28 
33  bool intersects(Interval & interval);
34 
39  bool contains(Interval & interval);
40 
44  SUFFIX_MARKER_TYPE getLength();
45 
49  SUFFIX_MARKER_TYPE getStart() const {
50  return _start;
51  }
52 
56  SUFFIX_MARKER_TYPE getEnd() const {
57  return _end;
58  }
59 
60  friend std::ostream & operator << (std::ostream & o,
61  const Interval & interval) {
62  return o << "[" << interval.getStart()
63  << "," << interval.getEnd() << ")";
64  }
65 
66 protected:
67  SUFFIX_MARKER_TYPE _start;
68 
69  SUFFIX_MARKER_TYPE _end;
70 };
71 
72 struct intervalEndComparator {
73  inline bool operator() (const Interval & lhs, const Interval & rhs) {
74  return (lhs.getEnd() < rhs.getEnd());
75  }
76 };
77 
78 #endif
Interval(const SUFFIX_MARKER_TYPE start, const SUFFIX_MARKER_TYPE end)
Definition: interval.cpp:4
virtual ~Interval()
Definition: interval.cpp:10
SUFFIX_MARKER_TYPE getLength()
Definition: interval.cpp:22
Definition: interval.hpp:16
SUFFIX_MARKER_TYPE getStart() const
Definition: interval.hpp:49
bool contains(Interval &interval)
Definition: interval.cpp:18
SUFFIX_MARKER_TYPE getEnd() const
Definition: interval.hpp:56
bool intersects(Interval &interval)
Definition: interval.cpp:13