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; }
62 _valuetype &defaultValue(
void) {
return defaultvalue; }
63 _valuetype &
clearRange(
const _linetype &pnt1,
const _linetype &pnt2);
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)
209 data.defaultValue() = 0;
222 iter = data.begin(3);
223 while(iter!=data.end()) {
224 cout << (*iter).second << endl;