47 template<
typename _linetype,
typename _valuetype>
50 typedef std::map<_linetype,_valuetype>
maptype;
55 _valuetype defaultvalue;
57 _valuetype &
getValue(
const _linetype &pnt);
58 const _valuetype &
getValue(
const _linetype &pnt)
const;
59 const _valuetype &
bounds(
const _linetype &pnt,_linetype &before,_linetype &after,
int &valid)
const;
60 _valuetype &
split(
const _linetype &pnt);
61 const _valuetype &
defaultValue(
void)
const {
return defaultvalue; }
63 _valuetype &
clearRange(
const _linetype &pnt1,
const _linetype &pnt2);
64 const_iterator
begin(
void)
const {
return database.begin(); }
65 const_iterator
end(
void)
const {
return database.end(); }
66 iterator
begin(
void) {
return database.begin(); }
67 iterator
end(
void) {
return database.end(); }
68 const_iterator
begin(
const _linetype &pnt)
const {
return database.lower_bound(pnt); }
69 iterator
begin(
const _linetype &pnt) {
return database.lower_bound(pnt); }
70 void clear(
void) { database.clear(); }
71 bool empty(
void)
const {
return database.empty(); }
79 template<
typename _linetype,
typename _valuetype>
86 iter = database.upper_bound(pnt);
87 if (iter == database.begin())
90 return (*iter).second;
98 template<
typename _linetype,
typename _valuetype>
105 iter = database.upper_bound(pnt);
106 if (iter == database.begin())
109 return (*iter).second;
115 template<
typename _linetype,
typename _valuetype>
122 iter = database.upper_bound(pnt);
123 if (iter != database.begin()) {
125 if ((*iter).first == pnt)
126 return (*iter).second;
127 _valuetype &newref( database[pnt] );
128 newref = (*iter).second;
131 _valuetype &newref( database[pnt] );
132 newref = defaultvalue;
142 template<
typename _linetype,
typename _valuetype>
151 _valuetype &ref( (*beg).second );
153 database.erase(beg,end);
170 template<
typename _linetype,
typename _valuetype>
172 bounds(
const _linetype &pnt,_linetype &before,_linetype &after,
int &valid)
const 174 if (database.empty()) {
180 enditer = database.upper_bound(pnt);
181 if (enditer != database.begin()) {
184 before = (*iter).first;
185 if (enditer == database.end())
188 after = (*enditer).first;
191 return (*iter).second;
194 after = (*enditer).first;
204 int main(
int argc,
char **argv)
222 iter = data.
begin(3);
223 while(iter!=data.
end()) {
224 cout << (*iter).second << endl;
std::map< _linetype, _valuetype > maptype
Defining the map from split points to value objects.
Definition: partmap.hh:50
const _valuetype & defaultValue(void) const
Get the default value object.
Definition: partmap.hh:61
_valuetype & split(const _linetype &pnt)
Introduce a new split point.
Definition: partmap.hh:117
void clear(void)
Clear all split points.
Definition: partmap.hh:70
iterator begin(void)
Beginning of split points.
Definition: partmap.hh:66
maptype::iterator iterator
A partmap iterator is an iterator into the map.
Definition: partmap.hh:51
_valuetype & getValue(const _linetype &pnt)
Get the value object at a point.
Definition: partmap.hh:81
_valuetype & defaultValue(void)
Get the default value object.
Definition: partmap.hh:62
maptype::const_iterator const_iterator
A constant iterator.
Definition: partmap.hh:52
_valuetype & clearRange(const _linetype &pnt1, const _linetype &pnt2)
Clear a range of split points.
Definition: partmap.hh:144
const_iterator begin(void) const
Beginning of split points.
Definition: partmap.hh:64
A map from a linear space to value objects.
Definition: partmap.hh:48
const _valuetype & bounds(const _linetype &pnt, _linetype &before, _linetype &after, int &valid) const
Get the value object for a given point and return the range over which the value object applies...
Definition: partmap.hh:172
iterator begin(const _linetype &pnt)
Get first split point after given point.
Definition: partmap.hh:69
const_iterator end(void) const
End of split points.
Definition: partmap.hh:65
const_iterator begin(const _linetype &pnt) const
Get first split point after given point.
Definition: partmap.hh:68
bool empty(void) const
Return true if there are no split points.
Definition: partmap.hh:71
iterator end(void)
End of split points.
Definition: partmap.hh:67