8 #ifndef Sawyer_Container_IntervalSetMap_H
9 #define Sawyer_Container_IntervalSetMap_H
11 #include <boost/foreach.hpp>
12 #include <Sawyer/IntervalMap.h>
13 #include <Sawyer/Sawyer.h>
78 template<
typename I,
typename S>
95 BOOST_FOREACH (
const typename Set::Value &member, node.
value().values()) {
96 retval.insert(member);
109 const Set &set = this->
get(node.
key().least());
126 bool exists(
const Interval &interval)
const {
127 return Super::contains(interval);
137 if (node.
value().exists(value))
149 if (interval.isEmpty())
152 if (!node.
value().exists(value))
166 void erase(
const Interval &interval) {
177 return erase(interval, set);
186 bool isErased =
false;
187 Interval worklist = interval;
188 while (!worklist.isEmpty()) {
190 if (iter == this->
nodes().end()) {
192 }
else if (worklist.least() < iter->
key().least()) {
196 Set set = this->
get(work.least());
197 if (set.erase(values)) {
201 if (work == worklist)
203 worklist =
Interval::hull(work.greatest()+1, worklist.greatest());
216 return insert(interval, set);
224 bool isInserted =
false;
225 Interval worklist = interval;
226 while (!worklist.isEmpty()) {
230 if (iter == this->
nodes().end()) {
232 }
else if (worklist.least() < iter->
key().least()) {
236 set = this->
get(work.least());
238 if (set.insert(values)) {
242 if (work == worklist)
244 worklist =
Interval::hull(work.greatest()+1, worklist.greatest());
252 void replace(
const Interval &interval,
const Set &set) {
An associative container whose keys are non-overlapping intervals.
bool exists(const Interval &interval) const
Determines if values are stored for an interval.
Interval intersection(const Interval &other) const
Intersection.
Value & value()
Value part of key/value node.
Mapping from integers to sets.
bool existsAnywhere(const Interval &interval, const typename Set::Value &value) const
Determines if a particular value is stored in an interval.
Name space for the entire library.
bool erase(const Interval &interval, const Set &values)
Erase specified values from the sets of an interval.
boost::iterator_range< ValueIterator > values()
Iterators for traversing values.
NodeIterator findFirstOverlap(const Interval &interval)
Find first interval that overlaps with the specified interval.
void replace(const Interval &interval, const Set &set)
Replace sets with a new set.
void erase(const Interval &erasure)
Erase the specified interval.
bool erase(const Interval &interval, const typename Set::Value &value)
Erases one value from a set over an interval.
void erase(const Interval &interval)
Erase sets for an interval.
void insert(Interval key, Value value, bool makeHole=true)
Insert a key/value pair.
static Interval hull(T v1, T v2)
Construct an interval from two endpoints.
Set getUnion(const Interval &interval) const
Union of values over an interval of keys.
const Key & key() const
Key part of key/value node.
boost::iterator_range< NodeIterator > nodes()
Iterators for traversing nodes.
bool insert(const Interval &interval, const typename Set::Value &value)
Insert one value to the sets of an interval.
bool existsEverywhere(const Interval &interval, const typename Set::Value &value) const
Determines if a particular value is stored everywhere in the interval.
Set getIntersection(const Interval &interval) const
Intersection of values over an interval of keys.
boost::iterator_range< NodeIterator > findAll(const Interval &interval)
Finds all nodes overlapping the specified interval.
bool insert(const Interval &interval, const Set &values)
Insert a set of values into the sets of an interval.
T Value
Type of values stored in this set.
S Set
Set type for values.
I Interval
Interval type for keys.
Bidirectional iterator over key/value nodes.