temporal: add timecnt_t::increment() and Range::extent() (length+1)

This commit is contained in:
Paul Davis 2022-10-05 17:54:45 -06:00
parent b4d7ca06b8
commit 617a517a60
2 changed files with 7 additions and 1 deletions

View File

@ -152,7 +152,12 @@ class LIBTEMPORAL_API Range {
Range (timepos_t const & s, timepos_t const & e) : _start (s), _end (e) {}
Range (samplepos_t const s, samplepos_t const e) : _start (s), _end (e) {}
bool empty() const { return _start == _end; }
timecnt_t length() const { return _start.distance (_end); }
/* length semantics: start + length = end thus end - start aka * start.distance (end)
* extent semantics: 1 + (end - start)
*/
timecnt_t extent() const { return _start.distance (_end).increment(); }
RangeList subtract (RangeList &) const;

View File

@ -370,6 +370,7 @@ class LIBTEMPORAL_API timecnt_t {
timecnt_t & operator+= (timecnt_t const & t);
timecnt_t decrement () const { return timecnt_t (_distance - 1, _position); }
timecnt_t increment () const { return timecnt_t (_distance + 1, _position); }
//timecnt_t operator- (timepos_t const & t) const;
//timecnt_t operator+ (timepos_t const & t) const;