[Lemon-commits] [lemon_svn] klao: r495 - hugo/trunk/src/work/klao

Lemon SVN svn at lemon.cs.elte.hu
Mon Nov 6 20:39:45 CET 2006


Author: klao
Date: Wed Apr 21 21:52:09 2004
New Revision: 495

Modified:
   hugo/trunk/src/work/klao/iter_map.h
   hugo/trunk/src/work/klao/iter_map_test.cc

Log:
Remove function and some todos.


Modified: hugo/trunk/src/work/klao/iter_map.h
==============================================================================
--- hugo/trunk/src/work/klao/iter_map.h	(original)
+++ hugo/trunk/src/work/klao/iter_map.h	Wed Apr 21 21:52:09 2004
@@ -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<typename KeyIntMap, uint8_t N, typename Val = uint8_t>
   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);
     }

Modified: hugo/trunk/src/work/klao/iter_map_test.cc
==============================================================================
--- hugo/trunk/src/work/klao/iter_map_test.cc	(original)
+++ hugo/trunk/src/work/klao/iter_map_test.cc	Wed Apr 21 21:52:09 2004
@@ -225,5 +225,9 @@
       cout << " " << a;
     }
     cout << endl;
+
+    cout << "Removing 10 from the map...\n";
+    test.remove(10);
+    print(test,2);
   }
 }



More information about the Lemon-commits mailing list