64 template<
typename _recordtype>
67 typedef typename _recordtype::linetype
linetype;
69 typedef typename _recordtype::inittype
inittype;
77 friend class PartIterator;
78 mutable linetype first;
82 mutable subsorttype subsort;
83 mutable typename std::list<_recordtype>::iterator value;
84 AddrRange(linetype l) : subsort(
false) { last = l; }
85 AddrRange(linetype l,
const subsorttype &s) : subsort(s) { last = l; }
87 bool operator<(
const AddrRange &op2)
const {
88 if (last != op2.last)
return (last < op2.last);
89 return (subsort < op2.subsort);
91 typename std::list<_recordtype>::iterator getValue(
void)
const {
return value; }
101 typename std::multiset<AddrRange>::const_iterator iter;
104 PartIterator(
typename std::multiset<AddrRange>::const_iterator i) { iter=i; }
113 iter = op2.iter;
return *
this;
116 return (iter==op2.iter);
119 return (iter!=op2.iter);
122 return (*iter).getValue(); }
128 std::multiset<AddrRange> tree;
129 std::list<_recordtype> record;
131 void zip(linetype i,
typename std::multiset<AddrRange>::iterator iter);
132 void unzip(linetype i,
typename std::multiset<AddrRange>::iterator iter);
134 bool empty(
void)
const {
return record.empty(); }
135 void clear(
void) { tree.clear(); record.clear(); }
136 typename std::list<_recordtype>::const_iterator
begin_list(
void)
const {
return record.begin(); }
137 typename std::list<_recordtype>::const_iterator
end_list(
void)
const {
return record.end(); }
138 typename std::list<_recordtype>::iterator
begin_list(
void) {
return record.begin(); }
139 typename std::list<_recordtype>::iterator
end_list(
void) {
return record.end(); }
141 const_iterator
begin(
void)
const {
return PartIterator(tree.begin()); }
142 const_iterator
end(
void)
const {
return PartIterator(tree.end()); }
145 std::pair<const_iterator,const_iterator>
find(linetype a)
const;
148 std::pair<const_iterator,const_iterator>
149 find(linetype a,
const subsorttype &subsort1,
const subsorttype &subsort2)
const;
152 const_iterator
find_begin(linetype point)
const;
155 const_iterator
find_end(linetype point)
const;
161 typename std::list<_recordtype>::iterator
insert(
const inittype &data,linetype a,linetype b);
164 void erase(
typename std::list<_recordtype>::iterator v);
167 void erase(const_iterator iter) {
erase( iter.getValueIter() ); }
175 template<
typename _recordtype>
180 while((*iter).last == i)
183 while((iter!=tree.end())&&((*iter).first==i)) {
194 template<
typename _recordtype>
198 typename std::multiset<AddrRange>::iterator hint = iter;
199 if ((*iter).last == i)
return;
202 while((iter!=tree.end())&&((*iter).first<=i)) {
204 (*iter).first = plus1;
205 typename std::multiset<AddrRange>::iterator newiter;
206 newiter = tree.
insert(hint,AddrRange(i,(*iter).subsort));
207 const AddrRange &newrange( *newiter );
209 newrange.a = (*iter).a;
210 newrange.b = (*iter).b;
211 newrange.value = (*iter).value;
220 template<
typename _recordtype>
221 typename std::list<_recordtype>::iterator
226 typename std::list<_recordtype>::iterator liter;
227 typename std::multiset<AddrRange>::iterator low = tree.lower_bound(AddrRange(f));
229 if (low != tree.end()) {
230 if ((*low).first < f)
234 record.push_front( _recordtype() );
235 record.front().initialize( data, a, b );
236 liter = record.begin();
238 AddrRange addrrange(b,(*liter).getSubsort());
241 addrrange.value = liter;
242 typename std::multiset<AddrRange>::iterator spot = tree.lower_bound(addrrange);
244 record.splice( (spot==tree.end()) ? record.end():(*spot).value,
247 while((low != tree.end())&&((*low).first<=b)) {
248 if (f <= (*low).last) {
249 if (f < (*low).first) {
252 addrrange.last = (*low).first-1;
253 tree.insert(low,addrrange);
256 if ((*low).last <= b) {
258 addrrange.last = (*low).last;
259 tree.insert(low,addrrange);
260 if ((*low).last==b)
break;
263 else if (b < (*low).last) {
273 tree.insert(addrrange);
280 template<
typename _recordtype>
287 bool rightsew =
true;
288 bool rightoverlap =
false;
289 bool leftoverlap =
false;
290 typename std::multiset<AddrRange>::iterator low = tree.lower_bound(AddrRange(a));
291 typename std::multiset<AddrRange>::iterator uplow = low;
294 while (uplow != tree.begin()) {
296 if ((*uplow).last != aminus1)
break;
297 if ((*uplow).b == aminus1) {
303 if ((*low).value == v)
308 else if ((*low).a == a)
312 else if ((*low).b == b)
316 }
while ((low != tree.end())&&((*low).first<=b));
317 if (low != tree.end()) {
321 if (leftsew&&leftoverlap)
322 zip(a-1,tree.lower_bound(AddrRange(a-1)));
323 if (rightsew&&rightoverlap)
324 zip(b,tree.lower_bound(AddrRange(b)));
330 template<
typename _recordtype>
335 AddrRange addrrange(point);
336 typename std::multiset<AddrRange>::const_iterator iter1,iter2;
338 iter1 = tree.lower_bound(addrrange);
340 if ((iter1==tree.end())||(point < (*iter1).first))
341 return std::pair<PartIterator,PartIterator>(PartIterator(iter1),PartIterator(iter1));
343 AddrRange addrend((*iter1).last,
subsorttype(
true));
344 iter2 = tree.upper_bound(addrend);
346 return std::pair<PartIterator,PartIterator>(PartIterator(iter1),PartIterator(iter2));
353 template<
typename _recordtype>
358 AddrRange addrrange(point,sub1);
359 typename std::multiset<AddrRange>::const_iterator iter1,iter2;
361 iter1 = tree.lower_bound(addrrange);
362 if ((iter1==tree.end())||(point < (*iter1).first))
363 return std::pair<PartIterator,PartIterator>(PartIterator(iter1),PartIterator(iter1));
365 AddrRange addrend((*iter1).last,sub2);
366 iter2 = tree.upper_bound(addrend);
368 return std::pair<PartIterator,PartIterator>(PartIterator(iter1),PartIterator(iter2));
373 template<
typename _recordtype>
378 AddrRange addrrange(point);
379 typename std::multiset<AddrRange>::const_iterator iter;
381 iter = tree.lower_bound(addrrange);
387 template<
typename _recordtype>
393 typename std::multiset<AddrRange>::const_iterator iter;
395 iter = tree.upper_bound(addrend);
396 if ((iter==tree.end())||(point < (*iter).first))
402 AddrRange addrbeyond((*iter).last,
subsorttype(
true));
403 return tree.upper_bound(addrbeyond);
409 template<
typename _recordtype>
414 AddrRange addrrange(point);
415 typename std::multiset<AddrRange>::const_iterator iter;
418 iter = tree.lower_bound(addrrange);
419 if (iter==tree.end())
return iter;
420 if ((*iter).first<=end)
PartIterator operator++(int i)
Post-increment the iterator.
Definition: rangemap.hh:107
const_iterator begin(void) const
Beginning of sub-ranges.
Definition: rangemap.hh:141
bool operator!=(const PartIterator &op2) const
Test inequality of iterators.
Definition: rangemap.hh:118
const_iterator find_overlap(linetype point, linetype end) const
Find first record overlapping given interval.
Definition: rangemap.hh:411
std::list< _recordtype >::iterator getValueIter(void) const
Get the recordtype iterator.
Definition: rangemap.hh:121
An iterator into the interval map container.
Definition: rangemap.hh:100
_recordtype::subsorttype subsorttype
The data-type used for subsorting.
Definition: rangemap.hh:68
PartIterator(typename std::multiset< AddrRange >::const_iterator i)
Construct given iterator.
Definition: rangemap.hh:104
const_iterator find_begin(linetype point) const
Find beginning of sub-ranges that contain the given boundary point.
Definition: rangemap.hh:375
PartIterator & operator--(void)
Pre-decrement the iterator.
Definition: rangemap.hh:109
const_iterator end(void) const
Ending of sub-ranges.
Definition: rangemap.hh:142
std::list< _recordtype >::const_iterator begin_list(void) const
Beginning of records.
Definition: rangemap.hh:136
PartIterator operator--(int i)
Post-decrement the iterator.
Definition: rangemap.hh:110
std::pair< const_iterator, const_iterator > find(linetype a) const
Find sub-ranges intersecting the given boundary point.
Definition: rangemap.hh:332
bool empty(void) const
Return true if the container is empty.
Definition: rangemap.hh:134
std::list< _recordtype >::iterator begin_list(void)
Beginning of records.
Definition: rangemap.hh:138
_recordtype::inittype inittype
The data-type containing initialization data for records.
Definition: rangemap.hh:69
bool operator==(const PartIterator &op2) const
Test equality of iterators.
Definition: rangemap.hh:115
An interval map container.
Definition: rangemap.hh:65
_recordtype & operator*(void)
Dereference to the recordtype object.
Definition: rangemap.hh:105
_recordtype::linetype linetype
Integer data-type defining the linear domain.
Definition: rangemap.hh:67
std::list< _recordtype >::const_iterator end_list(void) const
End of records.
Definition: rangemap.hh:137
void erase(const_iterator iter)
Erase a record given an iterator.
Definition: rangemap.hh:167
PartIterator(void)
Constructor.
Definition: rangemap.hh:103
void clear(void)
Clear all records from the container.
Definition: rangemap.hh:135
PartIterator const_iterator
The main sub-range iterator data-type.
Definition: rangemap.hh:125
const_iterator find_end(linetype point) const
Find ending of sub-ranges that contain the given boundary point.
Definition: rangemap.hh:389
PartIterator & operator++(void)
Pre-increment the iterator.
Definition: rangemap.hh:106
std::list< _recordtype >::iterator insert(const inittype &data, linetype a, linetype b)
Insert a new record into the container.
Definition: rangemap.hh:222
void erase(typename std::list< _recordtype >::iterator v)
Erase a given record from the container.
Definition: rangemap.hh:281
std::list< _recordtype >::iterator end_list(void)
End of records.
Definition: rangemap.hh:139
PartIterator & operator=(const PartIterator &op2)
Assign to the iterator.
Definition: rangemap.hh:112