66 lines
1.5 KiB
C++
66 lines
1.5 KiB
C++
#ifndef INTERVAL_HDR
|
|
#define INTERVAL_HDR
|
|
|
|
#include "concordia/common/config.hpp"
|
|
|
|
/*!
|
|
Class representing interval of a sentence, i.e. a sequence of words
|
|
coming from that sentence. An interval only has its start and end indexes,
|
|
where the start index is inclusive and end index is exclusive. For example,
|
|
an interval [2,5] of the sentence "This is just for testing purposes" is:
|
|
"just for testing".
|
|
|
|
*/
|
|
|
|
class Interval {
|
|
public:
|
|
/*! Constructor.
|
|
\param start start index of the interval (0-based)
|
|
\param end end index of the interval (0-based)
|
|
*/
|
|
explicit Interval(const SUFFIX_MARKER_TYPE start,
|
|
const SUFFIX_MARKER_TYPE end);
|
|
|
|
/*! Destructor.
|
|
*/
|
|
virtual ~Interval();
|
|
|
|
/*! Checks if this interval intersects another.
|
|
\param interval another interval
|
|
\returns true if the two intervals intersect
|
|
*/
|
|
bool intersects(Interval & interval);
|
|
|
|
/*! Getter for interval length.
|
|
\returns end - start
|
|
*/
|
|
SUFFIX_MARKER_TYPE getLength();
|
|
|
|
/*! Getter for interval start.
|
|
\returns start
|
|
*/
|
|
SUFFIX_MARKER_TYPE getStart() const {
|
|
return _start;
|
|
}
|
|
|
|
/*! Getter for interval end.
|
|
\returns end
|
|
*/
|
|
SUFFIX_MARKER_TYPE getEnd() const {
|
|
return _end;
|
|
}
|
|
|
|
protected:
|
|
SUFFIX_MARKER_TYPE _start;
|
|
|
|
SUFFIX_MARKER_TYPE _end;
|
|
};
|
|
|
|
struct intervalEndComparator {
|
|
inline bool operator() (const Interval & lhs, const Interval & rhs) {
|
|
return (lhs.getEnd() < rhs.getEnd());
|
|
}
|
|
};
|
|
|
|
#endif
|