ROSE  0.9.9.109
IntervalSet.h
1 // WARNING: Changes to this file must be contributed back to Sawyer or else they will
2 // be clobbered by the next update from Sawyer. The Sawyer repository is at
3 // https://github.com/matzke1/sawyer.
4 
5 
6 
7 
8 #ifndef Sawyer_IntervalSet_H
9 #define Sawyer_IntervalSet_H
10 
11 #include <Sawyer/IntervalMap.h>
12 #include <Sawyer/Optional.h>
13 #include <Sawyer/Sawyer.h>
14 
15 #include <boost/integer_traits.hpp>
16 #include <boost/iterator/iterator_facade.hpp>
17 #include <boost/serialization/access.hpp>
18 #include <boost/serialization/nvp.hpp>
19 
20 namespace Sawyer {
21 namespace Container {
22 
54 template<class I>
55 class IntervalSet {
56  // We use an IntervalMap to do all our work, always storing int(0) as the value.
57  typedef IntervalMap<I, int> Map;
58  Map map_;
59 
60 private:
61  friend class boost::serialization::access;
62 
63  template<class S>
64  void serialize(S &s, const unsigned /*version*/) {
65  s & BOOST_SERIALIZATION_NVP(map_);
66  }
67 
68 public:
69  typedef I Interval;
70  typedef typename I::Value Scalar;
76  class ConstIntervalIterator: public boost::iterator_facade<ConstIntervalIterator, const Interval,
77  boost::bidirectional_traversal_tag> {
78  typedef typename IntervalMap<Interval, int>::ConstNodeIterator MapNodeIterator;
79  MapNodeIterator iter_;
80  public:
82  private:
83  friend class boost::iterator_core_access;
84  friend class IntervalSet;
85  explicit ConstIntervalIterator(MapNodeIterator iter): iter_(iter) {}
86  const Interval& dereference() const { return iter_->key(); }
87  bool equal(const ConstIntervalIterator &other) const { return iter_ == other.iter_; }
88  void increment() { ++iter_; }
89  void decrement() { --iter_; }
90  MapNodeIterator base() const { return iter_; }
91  };
92 
100  class ConstScalarIterator: public boost::iterator_facade<ConstScalarIterator, const typename Interval::Value,
101  boost::bidirectional_traversal_tag> {
102  ConstIntervalIterator iter_;
103  typename Interval::Value offset_;
104  mutable typename Interval::Value value_; // so dereference() can return a reference
105  public:
106  ConstScalarIterator(): offset_(0) {}
107  ConstScalarIterator(ConstIntervalIterator iter): iter_(iter), offset_(0) {}
108  private:
109  friend class boost::iterator_core_access;
110  friend class IntervalSet;
111  const typename Interval::Value& dereference() const {
112  ASSERT_require2(iter_->least() <= iter_->greatest(), "stored interval cannot be empty");
113  ASSERT_require(iter_->least() + offset_ <= iter_->greatest());
114  value_ = iter_->least() + offset_;
115  return value_; // must return a reference
116  }
117  bool equal(const ConstScalarIterator &other) const {
118  return iter_ == other.iter_ && offset_ == other.offset_;
119  }
120  void increment() {
121  ASSERT_require2(iter_->least() <= iter_->greatest(), "stored interval cannot be empty");
122  if (iter_->least() + offset_ == iter_->greatest()) {
123  ++iter_;
124  offset_ = 0;
125  } else {
126  ++offset_;
127  }
128  }
129  void decrement() {
130  ASSERT_require2(iter_->least() <= iter_->greatest(), "stored interval cannot be empty");
131  if (0==offset_) {
132  --iter_;
133  offset_ = width(*iter_);
134  } else {
135  --offset_;
136  }
137  }
138  };
139 
141  // Constructors
143 
148 
152  template<class Interval2>
154  typedef typename IntervalSet<Interval2>::ConstIntervalIterator OtherIntervalIterator;
155  for (OtherIntervalIterator otherIter=other.intervals().begin(); otherIter!=other.intervals().end(); ++otherIter)
156  insert(*otherIter);
157  }
158 
163  template<class Interval2, class T, class Policy>
165  typedef typename IntervalMap<Interval2, T, Policy>::ConstNodeIterator OtherNodeIterator;
166  for (OtherNodeIterator otherIter=other.nodes().begin(); otherIter!=other.nodes().end(); ++otherIter)
167  insert(otherIter->key());
168  }
169 
174  template<class Iterator>
175  IntervalSet(const boost::iterator_range<Iterator> &intervals) {
176  for (Iterator iter=intervals.begin(); iter!=intervals.end(); ++iter)
177  insert(*iter);
178  }
179 
184  template<class Interval2>
186  clear();
187  typedef typename IntervalSet<Interval2>::ConstIntervalIterator OtherIntervalIterator;
188  for (OtherIntervalIterator otherIter=other.intervals().begin(); otherIter!=other.intervals().end(); ++otherIter)
189  insert(*otherIter);
190  return *this;
191  }
192 
199  template<class Interval2, class T, class Policy>
201  clear();
202  typedef typename IntervalMap<Interval2, T, Policy>::ConstNodeIterator OtherNodeIterator;
203  for (OtherNodeIterator otherIter=other.nodes().begin(); otherIter!=other.nodes().end(); ++otherIter)
204  insert(otherIter->key());
205  return *this;
206  }
207 
212  template<class Iterator>
213  IntervalSet& operator=(const boost::iterator_range<Iterator> &intervals) {
214  clear();
215  for (Iterator iter=intervals.begin(); iter!=intervals.end(); ++iter)
216  insert(*iter);
217  return *this;
218  }
219 
221  // Iteration
223 
225  boost::iterator_range<ConstIntervalIterator> intervals() const {
226  return boost::iterator_range<ConstIntervalIterator>(ConstIntervalIterator(map_.nodes().begin()),
227  ConstIntervalIterator(map_.nodes().end()));
228  }
229 
231  boost::iterator_range<ConstScalarIterator> scalars() const {
232  return boost::iterator_range<ConstScalarIterator>(ConstScalarIterator(intervals().begin()),
233  ConstScalarIterator(intervals().end()));
234  }
235 
239  ConstIntervalIterator lowerBound(const typename Interval::Value &scalar) const {
240  return ConstIntervalIterator(map_.lowerBound(scalar));
241  }
242 
246  ConstIntervalIterator upperBound(const typename Interval::Value &scalar) const {
247  return ConstIntervalIterator(map_.upperBound(scalar));
248  }
249 
253  ConstIntervalIterator findPrior(const typename Interval::Value &scalar) const {
254  return ConstIntervalIterator(map_.findPrior(scalar));
255  }
256 
260  ConstIntervalIterator find(const typename Interval::Value &scalar) const {
261  return ConstIntervalIterator(map_.find(scalar));
262  }
263 
267  boost::iterator_range<ConstIntervalIterator> findAll(const Interval &interval) const {
268  boost::iterator_range<typename Map::ConstNodeIterator> range = map_.findAll(interval);
269  return boost::iterator_range<ConstIntervalIterator>(ConstIntervalIterator(range.begin()),
270  ConstIntervalIterator(range.end()));
271  }
272 
276  ConstIntervalIterator findFirstOverlap(const Interval &interval) const {
277  return ConstIntervalIterator(map_.findFirstOverlap(interval));
278  }
285  std::pair<ConstIntervalIterator, ConstIntervalIterator>
286  findFirstOverlap(ConstIntervalIterator thisIter, const IntervalSet &other, ConstIntervalIterator otherIter) const {
287  std::pair<typename Map::ConstNodeIterator, typename Map::ConstNodeIterator> found =
288  map_.findFirstOverlap(thisIter.base(), other.map_, otherIter.base());
289  return std::make_pair(ConstIntervalIterator(found.first), ConstIntervalIterator(found.second));
290  }
291 
293  // Size
295 
299  bool isEmpty() const {
300  return map_.isEmpty();
301  }
302 
308  typename Interval::Value size() const {
309  return map_.size();
310  }
311 
316  size_t nIntervals() const {
317  return map_.nIntervals();
318  }
319 
321  Interval hull() const {
322  return map_.hull();
323  }
324 
326  // Predicates
328 
334  template<class Interval2>
335  bool isOverlapping(const Interval2 &interval) const {
336  return map_.isOverlapping(interval);
337  }
338 
339  template<class Interval2>
340  bool isOverlapping(const IntervalSet<Interval2> &other) const {
341  return map_.isOverlapping(other.map_);
342  }
343 
344  template<class Interval2, class T2, class Policy2>
346  return map_.isOverlapping(other);
347  }
355  template<class Interval2>
356  bool isDistinct(const Interval2 &interval) const {
357  return !isOverlapping();
358  }
359 
360  template<class Interval2>
361  bool isDistinct(const IntervalSet<Interval2> &other) const {
362  return !isOverlapping(other);
363  }
364 
365  template<class Interval2, class T2, class Policy2>
367  return !isOverlapping(other);
368  }
374  bool exists(const typename Interval::Value &scalar) const {
375  return find(scalar)!=intervals().end();
376  }
377 
383  bool contains(const typename Interval::Value &scalar) const {
384  return exists(scalar);
385  }
386 
387  template<class Interval2>
388  bool contains(const Interval2 &interval) const {
389  return map_.contains(interval);
390  }
391 
392  template<class Interval2>
393  bool contains(const IntervalSet<Interval2> &other) const {
394  return map_.contains(other.map_);
395  }
396 
397  template<class Interval2, class T2, class Policy2>
399  return map_.contains(other);
400  }
403  // Searching
406 
408  Scalar least() const {
409  ASSERT_forbid(isEmpty());
410  return map_.least();
411  }
412 
414  Scalar greatest() const {
415  ASSERT_forbid(isEmpty());
416  return map_.greatest();
417  }
418 
423  Optional<Scalar> least(Scalar lowerLimit) const {
424  return map_.least(lowerLimit);
425  }
426 
431  Optional<Scalar> greatest(Scalar upperLimit) const {
432  return map_.greatest(upperLimit);
433  }
434 
439  Optional<Scalar> leastNonExistent(Scalar lowerLimit) const {
440  return map_.leastUnmapped(lowerLimit);
441  }
442 
447  Optional<Scalar> greatestNonExistent(Scalar upperLimit) const {
448  return map_.greatestUnmapped(upperLimit);
449  }
450 
460  ConstIntervalIterator firstFit(const typename Interval::Value &size, ConstIntervalIterator start) const {
461  return ConstIntervalIterator(map_.firstFit(size, start.iter_));
462  }
463 
474  ConstIntervalIterator bestFit(const typename Interval::Value &size, ConstIntervalIterator start) const {
475  return ConstIntervalIterator(map_.bestFit(size, start.iter_));
476  }
477 
478 
479 
481  // Modifiers
483 
487  void clear() {
488  map_.clear();
489  }
490 
494  void invert() {
496  }
497 
501  void invert(const Interval &restricted) {
502  IntervalSet inverted;
503  if (!restricted.isEmpty()) {
504  typename Interval::Value pending = restricted.least();
505  bool insertTop = true;
506  for (typename Map::ConstIntervalIterator iter=map_.lowerBound(restricted.least());
507  iter!=map_.intervals().end(); ++iter) {
508  if (iter->least() > restricted.greatest())
509  break;
510  if (pending < iter->least())
511  inverted.insert(Interval::hull(pending, iter->least()-1));
512  if (iter->greatest() < restricted.greatest()) {
513  pending = iter->greatest() + 1;
514  } else {
515  insertTop = false;
516  break;
517  }
518  }
519  if (insertTop)
520  inverted.insert(Interval::hull(pending, restricted.greatest()));
521  }
522  std::swap(map_, inverted.map_);
523  }
524 
531  template<class Interval2>
532  void insert(const Interval2 &interval) {
533  map_.insert(interval, 0);
534  }
535 
536  template<class Interval2>
538  typedef typename IntervalSet<Interval2>::ConstIntervalIterator OtherIterator;
539  for (OtherIterator otherIter=other.intervals().begin(); otherIter!=other.intervals().end(); ++otherIter)
540  map_.insert(*otherIter, 0);
541  }
542 
543  template<class Interval2, class T, class Policy>
545  typedef typename IntervalMap<Interval2, T, Policy>::ConstIntervalIterator OtherIterator;
546  for (OtherIterator otherIter=other.intervals().begin(); otherIter!=other.intervals().end(); ++otherIter)
547  map_.insert(*otherIter, 0);
548  }
557  template<class Interval2>
558  void erase(const Interval2 &interval) {
559  map_.erase(interval);
560  }
561 
562  template<class Interval2>
564  ASSERT_forbid2((void*)&other==(void*)this, "use IntervalSet::clear() instead");
565  typedef typename IntervalSet<Interval2>::ConstIntervalIterator OtherIntervalIterator;
566  for (OtherIntervalIterator otherIter=other.intervals().begin(); otherIter!=other.intervals().end(); ++otherIter)
567  map_.erase(*otherIter);
568  }
569 
570  template<class Interval2, class T, class Policy>
572  typedef typename IntervalMap<Interval2, T, Policy>::ConstIntervalIterator OtherIntervalIterator;
573  for (OtherIntervalIterator otherIter=other.intervals().begin(); otherIter!=other.intervals().end(); ++otherIter)
574  map_.erase(otherIter->first);
575  }
585  template<class Interval2>
586  void intersect(const Interval2 &interval) {
587  if (isEmpty())
588  return;
589  if (interval.isEmpty()) {
590  clear();
591  return;
592  }
593  if (hull().least() < interval.least())
594  map_.erase(Interval::hull(hull().least(), interval.least()-1));
595  if (hull().greatest() > interval.greatest())
596  map_.erase(Interval::hull(interval.greatest(), hull().greatest()));
597  }
598 
599  template<class Interval2>
601  other.invert(hull());
602  map_.eraseMultiple(other.map_);
603  }
604 
605  template<class Interval2, class T, class Policy>
606  void intersect(const IntervalMap<Interval2, T, Policy> &other);// FIXME[Robb Matzke 2014-04-12]: not implemented yet
610  // Operators
613 
615  bool operator==(const IntervalSet &other) const {
616  return !(*this!=other);
617  }
618 
620  bool operator!=(const IntervalSet &other) const {
621  if (map_.nIntervals()!=other.map_.nIntervals())
622  return true;
623  for (ConstIntervalIterator ai=intervals().begin(), bi=other.intervals().begin(); ai!=intervals().end(); ++ai, ++bi) {
624  if (*ai!=*bi)
625  return true;
626  }
627  return false;
628  }
629 
632  IntervalSet tmp = *this;
633  tmp.invert();
634  return tmp;
635  }
636 
641  insertMultiple(other);
642  return *this;
643  }
644 
648  IntervalSet& operator|=(const Interval &interval) {
649  insert(interval);
650  return *this;
651  }
652 
654  IntervalSet operator|(const IntervalSet &other) const {
655  if (nIntervals() < other.nIntervals()) {
656  IntervalSet tmp = other;
657  tmp.insertMultiple(*this);
658  return tmp;
659  }
660  IntervalSet tmp = *this;
661  tmp.insertMultiple(other);
662  return tmp;
663  }
664 
668  IntervalSet operator|(const Interval &interval) const {
669  IntervalSet retval = *this;
670  retval.insert(interval);
671  return retval;
672  }
673 
678  intersect(other);
679  return *this;
680  }
681 
685  IntervalSet& operator&=(const Interval &interval) {
686  intersect(interval);
687  return *this;
688  }
689 
691  IntervalSet operator&(const IntervalSet &other) const {
692  if (nIntervals() < other.nIntervals()) {
693  IntervalSet tmp = other;
694  tmp.intersect(*this);
695  return tmp;
696  }
697  IntervalSet tmp = *this;
698  tmp.intersect(other);
699  return tmp;
700  }
701 
703  IntervalSet operator&(const Interval &interval) const {
704  IntervalSet retval = *this;
705  retval.intersect(interval);
706  return retval;
707  }
708 
713  eraseMultiple(other);
714  return *this;
715  }
716 
720  IntervalSet& operator-=(const Interval &interval) {
721  erase(interval);
722  return *this;
723  }
724 
728  IntervalSet operator-(const IntervalSet &other) const {
729  IntervalSet tmp = *this;
730  tmp.eraseMultiple(other);
731  return tmp;
732  }
733 };
734 
735 } // namespace
736 } // namespace
737 
738 #endif
NodeIterator upperBound(const typename Interval::Value &scalar)
Find the first node whose interval begins above the specified scalar key.
Definition: IntervalMap.h:321
NodeIterator firstFit(const typename Interval::Value &size, NodeIterator start)
Find the first fit node at or after a starting point.
Definition: IntervalMap.h:486
IntervalSet operator|(const IntervalSet &other) const
Union of two sets.
Definition: IntervalSet.h:654
Interval hull() const
Returns the range of values in this map.
Definition: IntervalSet.h:321
boost::iterator_range< ConstIntervalIterator > intervals() const
Iterators for traversing keys.
Definition: IntervalMap.h:291
IntervalSet & operator-=(const Interval &interval)
In-place subtraction of an interval.
Definition: IntervalSet.h:720
size_t nIntervals() const
Number of storage nodes.
Definition: IntervalSet.h:316
IntervalSet & operator-=(const IntervalSet &other)
In-place subtraction.
Definition: IntervalSet.h:712
ConstIntervalIterator upperBound(const typename Interval::Value &scalar) const
Find the first node whose interval begins above the specified scalar key.
Definition: IntervalSet.h:246
ConstIntervalIterator bestFit(const typename Interval::Value &size, ConstIntervalIterator start) const
Find the best fit node at or after a starting point.
Definition: IntervalSet.h:474
Optional< Scalar > greatestNonExistent(Scalar upperLimit) const
Returns the limited-maximum scalar not contained in this set.
Definition: IntervalSet.h:447
bool isEmpty() const
True if interval is empty.
Definition: Interval.h:197
NodeIterator findPrior(const typename Interval::Value &scalar)
Find the last node whose interval starts at or below the specified scalar key.
Definition: IntervalMap.h:340
IntervalSet & operator&=(const Interval &interval)
In-place intersection with an interval.
Definition: IntervalSet.h:685
IntervalSet operator-(const IntervalSet &other) const
Subtract another set from this one.
Definition: IntervalSet.h:728
IntervalSet & operator&=(const IntervalSet &other)
In-place intersection.
Definition: IntervalSet.h:677
IntervalSet operator~() const
Return inverse of specified set.
Definition: IntervalSet.h:631
bool contains(const IntervalMap< Interval2, T2, Policy2 > &other) const
Determines whether this set fully contains the argument.
Definition: IntervalSet.h:398
ConstIntervalIterator lowerBound(const typename Interval::Value &scalar) const
Find the first node whose interval ends at or above the specified scalar key.
Definition: IntervalSet.h:239
IntervalSet()
Default constructor.
Definition: IntervalSet.h:147
Interval::Value least() const
Returns the minimum scalar key.
Definition: IntervalMap.h:686
bool exists(const typename Interval::Value &scalar) const
Determines if a value exists in the set.
Definition: IntervalSet.h:374
IntervalSet operator&(const IntervalSet &other) const
Intersection of two sets.
Definition: IntervalSet.h:691
Optional< Scalar > least(Scalar lowerLimit) const
Returns the limited-minimum scalar contained in this set.
Definition: IntervalSet.h:423
bool isEmpty() const
Determine whether the container is empty.
Definition: IntervalSet.h:299
Holds a value or nothing.
Definition: Optional.h:49
NodeIterator bestFit(const typename Interval::Value &size, NodeIterator start)
Find the best fit node at or after a starting point.
Definition: IntervalMap.h:518
bool contains(const Interval2 &interval) const
Determines whether this set fully contains the argument.
Definition: IntervalSet.h:388
bool isOverlapping(const IntervalMap< Interval2, T2, Policy2 > &other) const
Determines whether this set overlaps with the argument.
Definition: IntervalSet.h:345
IntervalSet operator&(const Interval &interval) const
Intersection of set with interval.
Definition: IntervalSet.h:703
bool operator!=(const IntervalSet &other) const
Determines if two sets contain different elements.
Definition: IntervalSet.h:620
IntervalSet(const boost::iterator_range< Iterator > &intervals)
Construct from an iterator range.
Definition: IntervalSet.h:175
bool isDistinct(const IntervalSet< Interval2 > &other) const
Determines whether this set is distinct from the argument.
Definition: IntervalSet.h:361
Interval::Value size() const
Returns the number of values represented by this container.
Definition: IntervalMap.h:681
bool isEmpty() const
Determine if the container is empty.
Definition: IntervalMap.h:665
Interval::Value greatest() const
Returns the maximum scalar key.
Definition: IntervalMap.h:692
void insertMultiple(const IntervalSet< Interval2 > &other)
Insert specified values.
Definition: IntervalSet.h:537
IntervalSet(const IntervalSet< Interval2 > &other)
Copy constructor.
Definition: IntervalSet.h:153
A container holding a set of values.
Definition: IntervalSet.h:55
IntervalSet & operator|=(const IntervalSet &other)
In-place union.
Definition: IntervalSet.h:640
void insert(const Interval2 &interval)
Insert specified values.
Definition: IntervalSet.h:532
Name space for the entire library.
Definition: Access.h:11
void eraseMultiple(const IntervalSet< Interval2 > &other)
Remove specified values.
Definition: IntervalSet.h:563
Optional< typename Interval::Value > leastUnmapped(typename Interval::Value lowerLimit) const
Returns the limited-minimum unmapped scalar key.
Definition: IntervalMap.h:724
T least() const
Returns lower limit.
Definition: Interval.h:185
IntervalSet operator|(const Interval &interval) const
Union of set with interval.
Definition: IntervalSet.h:668
NodeIterator findFirstOverlap(const Interval &interval)
Find first interval that overlaps with the specified interval.
Definition: IntervalMap.h:415
ConstIntervalIterator findPrior(const typename Interval::Value &scalar) const
Find the last node whose interval starts at or below the specified scalar key.
Definition: IntervalSet.h:253
IntervalSet(const IntervalMap< Interval2, T, Policy > &other)
Construct from an IntervalMap.
Definition: IntervalSet.h:164
void clear()
Empties the container.
Definition: IntervalMap.h:764
void erase(const Interval &erasure)
Erase the specified interval.
Definition: IntervalMap.h:770
IntervalSet & operator=(const IntervalMap< Interval2, T, Policy > &other)
Assignment from an IntervalMap.
Definition: IntervalSet.h:200
boost::iterator_range< ConstScalarIterator > scalars() const
Iterator range for all scalar values logically represented by this set.
Definition: IntervalSet.h:231
void insert(Interval key, Value value, bool makeHole=true)
Insert a key/value pair.
Definition: IntervalMap.h:838
void erase(const Interval2 &interval)
Remove specified values.
Definition: IntervalSet.h:558
static Interval whole()
Construct an interval that covers the entire domain.
Definition: Interval.h:167
static Interval hull(T v1, T v2)
Construct an interval from two endpoints.
Definition: Interval.h:150
ConstIntervalIterator findFirstOverlap(const Interval &interval) const
Finds first node that overlaps with the specified interval.
Definition: IntervalSet.h:276
Optional< Scalar > greatest(Scalar upperLimit) const
Returns the limited-maximum scalar contained in this set.
Definition: IntervalSet.h:431
bool isOverlapping(const IntervalSet< Interval2 > &other) const
Determines whether this set overlaps with the argument.
Definition: IntervalSet.h:340
Optional< typename Interval::Value > greatestUnmapped(typename Interval::Value upperLimit) const
Returns the limited-maximum unmapped scalar key.
Definition: IntervalMap.h:739
bool contains(const typename Interval::Value &scalar) const
Determines whether this set fully contains the argument.
Definition: IntervalSet.h:383
void intersect(const Interval2 &interval)
Interset with specified values.
Definition: IntervalSet.h:586
void eraseMultiple(const IntervalMap< Interval2, T, Policy > &other)
Remove specified values.
Definition: IntervalSet.h:571
boost::iterator_range< NodeIterator > nodes()
Iterators for traversing nodes.
Definition: IntervalMap.h:283
Optional< Scalar > leastNonExistent(Scalar lowerLimit) const
Returns the limited-minimum scalar not contained in this set.
Definition: IntervalSet.h:439
Interval hull() const
Returns the range of values in this map.
Definition: IntervalMap.h:753
IntervalSet & operator=(const boost::iterator_range< Iterator > &intervals)
Assignment from an iterator range.
Definition: IntervalSet.h:213
bool isOverlapping(const Interval2 &interval) const
Determines whether this set overlaps with the argument.
Definition: IntervalSet.h:335
void clear()
Remove all values.
Definition: IntervalSet.h:487
boost::iterator_range< NodeIterator > findAll(const Interval &interval)
Finds all nodes overlapping the specified interval.
Definition: IntervalMap.h:390
IntervalSet & operator=(const IntervalSet< Interval2 > &other)
Assignment from another set.
Definition: IntervalSet.h:185
boost::iterator_range< ConstIntervalIterator > intervals() const
Iterator range for all intervals actually stored by this set.
Definition: IntervalSet.h:225
Scalar least() const
Returns the minimum scalar contained in this set.
Definition: IntervalSet.h:408
IntervalSet & operator|=(const Interval &interval)
In-place union with interval.
Definition: IntervalSet.h:648
bool isDistinct(const IntervalMap< Interval2, T2, Policy2 > &other) const
Determines whether this set is distinct from the argument.
Definition: IntervalSet.h:366
bool isDistinct(const Interval2 &interval) const
Determines whether this set is distinct from the argument.
Definition: IntervalSet.h:356
Bidirectional iterator over keys.
Definition: Sawyer/Map.h:173
void insertMultiple(const IntervalMap< Interval2, T, Policy > &other)
Insert specified values.
Definition: IntervalSet.h:544
size_t nIntervals() const
Number of nodes in the container.
Definition: IntervalMap.h:673
void invert(const Interval &restricted)
Invert and intersect.
Definition: IntervalSet.h:501
NodeIterator lowerBound(const typename Interval::Value &scalar)
Find the first node whose interval ends at or above the specified scalar key.
Definition: IntervalMap.h:308
Interval::Value size() const
Number of scalar elements represented.
Definition: IntervalSet.h:308
bool contains(const IntervalSet< Interval2 > &other) const
Determines whether this set fully contains the argument.
Definition: IntervalSet.h:393
ConstIntervalIterator firstFit(const typename Interval::Value &size, ConstIntervalIterator start) const
Find the first fit node at or after a starting point.
Definition: IntervalSet.h:460
T greatest() const
Returns upper limit.
Definition: Interval.h:191
NodeIterator find(const typename Interval::Value &scalar)
Find the node containing the specified scalar key.
Definition: IntervalMap.h:367
bool operator==(const IntervalSet &other) const
Determines if two sets contain the same elements.
Definition: IntervalSet.h:615
void intersect(IntervalSet< Interval2 > other)
Interset with specified values.
Definition: IntervalSet.h:600
Scalar greatest() const
Returns the maximum scalar contained in this set.
Definition: IntervalSet.h:414
ConstIntervalIterator find(const typename Interval::Value &scalar) const
Find the node containing the specified scalar key.
Definition: IntervalSet.h:260
I::Value Scalar
Type of scalar values stored in this set.
Definition: IntervalSet.h:70
void eraseMultiple(const IntervalMap< Interval, T2, Policy2 > &other)
Erase intervals specified in another IntervalMap.
Definition: IntervalMap.h:827
boost::iterator_range< ConstIntervalIterator > findAll(const Interval &interval) const
Finds all nodes overlapping the specified interval.
Definition: IntervalSet.h:267
Bidirectional iterator over key/value nodes.
Definition: Sawyer/Map.h:154
std::pair< ConstIntervalIterator, ConstIntervalIterator > findFirstOverlap(ConstIntervalIterator thisIter, const IntervalSet &other, ConstIntervalIterator otherIter) const
Find first nodes that overlap.
Definition: IntervalSet.h:286