#include "alg/sequence_location.hpp"
+
+#include <cstdlib>
SequenceLocation::SequenceLocation(
const boost::shared_ptr<Sequence> s,
int l,
- int c
+ int r
) : sequence(s),
left(l),
- count(c)
+ right(r)
{
}
SequenceLocation::SequenceLocation(
const Sequence& s,
int l,
- int c
+ int r
) : left(l),
- count(c)
+ right(r)
{
boost::shared_ptr<Sequence> copy(new Sequence(s));
sequence = copy;
SequenceLocation::SequenceLocation(const SequenceLocation& o)
: sequence(o.sequence),
left(o.left),
- count(o.count)
+ right(o.right)
{
}
{
if (this != &o) {
sequence = o.sequence;
- left = o.left;
- count = o.count;
+ left = o.getLeft();
+ right = o.getRight();
}
return *this;
}
Sequence SequenceLocation::getSelectedSequence() const
{
- return sequence->subseq(left, count);
+ return sequence->subseq(getLeft(), getCount());
}
void SequenceLocation::setLeft(int l)
return left;
}
-void SequenceLocation::setCount(int c)
+void SequenceLocation::setCount(SequenceLocation::size_type c)
{
- count = c;
+ right = left + c;
}
-int SequenceLocation::getCount() const
+SequenceLocation::size_type SequenceLocation::getCount() const
{
- return count;
+ return std::max(right - left, 0);
}
void SequenceLocation::setRight(int r)
{
- count = r-left;
+ right = r;
}
int SequenceLocation::getRight() const
{
- return left+count;
+ return right;
+}
+
+SequenceLocation::size_type SequenceLocation::size() const
+{
+ return getCount();
}