Add Collection.*_iterator
authorMaciej Piechotka <uzytkownik2@gmail.com>
Fri, 2 Aug 2013 07:50:02 +0000 (09:50 +0200)
committerMaciej Piechotka <uzytkownik2@gmail.com>
Fri, 2 Aug 2013 07:50:02 +0000 (09:50 +0200)
gee/collection.vala

index f3c5a2d..3f15008 100644 (file)
@@ -245,6 +245,31 @@ public interface Gee.Collection<G> : Iterable<G> {
                return changed;
        }
 
+       [CCode (ordering = 16)]
+       public virtual bool add_all_iterator (Iterator<G> iter) {
+               bool changed = false;
+               iter.foreach ((val) => {
+                       changed |= add (val);
+                       return true;
+               });
+               return changed;
+       }
+
+       [CCode (ordering = 17)]
+       public virtual bool contains_all_iterator (Iterator<G> iter) {
+               return iter.foreach ((val) => {return contains (val);});
+       }
+
+       [CCode (ordering = 18)]
+       public virtual bool remove_all_iterator (Iterator<G> iter) {
+               bool changed = false;
+               return iter.foreach ((val) => {
+                       changed |= remove (val);
+                       return true;
+               });
+               return changed;
+       }
+
        private static bool[] to_bool_array (Collection<bool> coll) {
                bool[] array = new bool[coll.size];
                int index = 0;