Add the implementation for HashSet.foreach
authorMaciej Piechotka <uzytkownik2@gmail.com>
Mon, 15 Jul 2013 17:45:26 +0000 (19:45 +0200)
committerMaciej Piechotka <uzytkownik2@gmail.com>
Mon, 15 Jul 2013 17:45:26 +0000 (19:45 +0200)
gee/hashset.vala

index 65c8f40..b196c58 100644 (file)
@@ -165,6 +165,20 @@ public class Gee.HashSet<G> : AbstractSet<G> {
                resize ();
        }
 
+       /**
+        * {@inheritDoc}
+        */
+       public override bool foreach (ForallFunc f) {
+               for (int i = 0; i < _array_size; i++) {
+                       for (unowned Node<G>? current = _nodes[i]; current != null; current = current.next) {
+                               if (!f (current.key)) {
+                                       return false;
+                               }
+                       }
+               }
+               return true;
+       }
+
        private inline bool remove_helper (G key) {
                Node<G>** node = lookup_node (key);
                if (*node != null) {