# HG changeset patch # User klao # Date 1082577129 0 # Node ID 825647d4eca747611a7d2fc3890c8d2e97397a87 # Parent be6fe0ea99b537c778cbbe7db864bf8d73ca1c37 Remove function and some todos. diff -r be6fe0ea99b5 -r 825647d4eca7 src/work/klao/iter_map.h --- a/src/work/klao/iter_map.h Wed Apr 21 19:10:59 2004 +0000 +++ b/src/work/klao/iter_map.h Wed Apr 21 19:52:09 2004 +0000 @@ -14,9 +14,13 @@ namespace hugo { + /// \brief A map with "small integers" as value set which can enumarate it + /// value classes /// \todo Decide whether we need all the range checkings!!! + /// \todo Implement dynamic map behaviour. Is it necessary? Yes it is. + template class IterableMap { public: @@ -84,7 +88,7 @@ // FIXME: range check? size_t a = base[k]; if(a < bounds[N-1]) { - base.set(k, move(a, find(a), n)); + move(a, find(a), n); } else { insert(k, n); @@ -96,6 +100,17 @@ base.set(k, move(bounds[N-1]++, N-1, n)); } + /// This func is not very usable, but necessary to implement + /// dynamic map behaviour. + void remove(const KeyType& k) { + size_t a = base[k]; + if(a < bounds[N-1]) { + move(a, find(a), N); + data.pop_back(); + base.set(k, -1); + } + } + iterator begin(Val n) const { return data.begin() + (n ? bounds[n-1] : 0); } diff -r be6fe0ea99b5 -r 825647d4eca7 src/work/klao/iter_map_test.cc --- a/src/work/klao/iter_map_test.cc Wed Apr 21 19:10:59 2004 +0000 +++ b/src/work/klao/iter_map_test.cc Wed Apr 21 19:52:09 2004 +0000 @@ -225,5 +225,9 @@ cout << " " << a; } cout << endl; + + cout << "Removing 10 from the map...\n"; + test.remove(10); + print(test,2); } }