[libgee] Fix Collection.remove_all_array for primitives
- From: Maciej Marcin Piechotka <mpiechotka src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libgee] Fix Collection.remove_all_array for primitives
- Date: Sun, 18 Aug 2013 19:26:45 +0000 (UTC)
commit 558869a3125a7216f30685de0f61feb02babb1f3
Author: Maciej Piechotka <uzytkownik2 gmail com>
Date: Sat Aug 3 11:02:42 2013 +0200
Fix Collection.remove_all_array for primitives
gee/collection.vala | 121 +++++++++++++++++++++++++++++++++++++++++++++++++--
1 files changed, 117 insertions(+), 4 deletions(-)
---
diff --git a/gee/collection.vala b/gee/collection.vala
index b404de9..f748504 100644
--- a/gee/collection.vala
+++ b/gee/collection.vala
@@ -288,11 +288,36 @@ public interface Gee.Collection<G> : Iterable<G> {
*/
[CCode (ordering = 15)]
public virtual bool remove_all_array (G[] array) {
- bool changed = false;
- foreach (unowned G item in array) {
- changed |= remove (item);
+ var t = typeof (G);
+ if (t == typeof (bool)) {
+ return remove_all_bool_array ((Collection<bool>) this, (bool [])array);
+ } else if (t == typeof (char)) {
+ return remove_all_char_array ((Collection<char>) this, (char [])array);
+ } else if (t == typeof (uchar)) {
+ return remove_all_uchar_array ((Collection<uchar>) this, (uchar [])array);
+ } else if (t == typeof (int)) {
+ return remove_all_int_array ((Collection<int>) this, (int [])array);
+ } else if (t == typeof (uint)) {
+ return remove_all_uint_array ((Collection<uint>) this, (uint [])array);
+ } else if (t == typeof (int64)) {
+ return remove_all_int64_array ((Collection<int64?>) this, (int64? [])array);
+ } else if (t == typeof (uint64)) {
+ return remove_all_uint64_array ((Collection<uint64?>) this, (uint64? [])array);
+ } else if (t == typeof (long)) {
+ return remove_all_long_array ((Collection<long>) this, (long [])array);
+ } else if (t == typeof (ulong)) {
+ return remove_all_ulong_array ((Collection<ulong>) this, (ulong [])array);
+ } else if (t == typeof (float)) {
+ return remove_all_float_array ((Collection<float>) this, (float? [])array);
+ } else if (t == typeof (double)) {
+ return remove_all_double_array ((Collection<double>) this, (double? [])array);
+ } else {
+ bool changed = false;
+ foreach (unowned G item in array) {
+ changed |= remove (item);
+ }
+ return changed;
}
- return changed;
}
[CCode (ordering = 16)]
@@ -620,5 +645,93 @@ public interface Gee.Collection<G> : Iterable<G> {
}
return true;
}
+
+ private static bool remove_all_bool_array (Collection<bool> coll, bool[] arr) {
+ bool changed = false;
+ foreach (bool el in arr) {
+ changed |= coll.remove (el);
+ }
+ return changed;
+ }
+
+ private static bool remove_all_char_array (Collection<char> coll, char[] arr) {
+ bool changed = false;
+ foreach (char el in arr) {
+ changed |= coll.remove (el);
+ }
+ return changed;
+ }
+
+ private static bool remove_all_uchar_array (Collection<uchar> coll, uchar[] arr) {
+ bool changed = false;
+ foreach (uchar el in arr) {
+ changed |= coll.remove (el);
+ }
+ return changed;
+ }
+
+ private static bool remove_all_int_array (Collection<int> coll, int[] arr) {
+ bool changed = false;
+ foreach (int el in arr) {
+ changed |= coll.remove (el);
+ }
+ return changed;
+ }
+
+ private static bool remove_all_uint_array (Collection<uint> coll, uint[] arr) {
+ bool changed = false;
+ foreach (uint el in arr) {
+ changed |= coll.remove (el);
+ }
+ return changed;
+ }
+
+ private static bool remove_all_int64_array (Collection<int64?> coll, int64?[] arr) {
+ bool changed = false;
+ foreach (unowned int64? el in arr) {
+ changed |= coll.remove (el);
+ }
+ return changed;
+ }
+
+ private static bool remove_all_uint64_array (Collection<uint64?> coll, uint64?[] arr) {
+ bool changed = false;
+ foreach (unowned uint64? el in arr) {
+ changed |= coll.remove (el);
+ }
+ return changed;
+ }
+
+ private static bool remove_all_long_array (Collection<long> coll, long[] arr) {
+ bool changed = false;
+ foreach (long el in arr) {
+ changed |= coll.remove (el);
+ }
+ return changed;
+ }
+
+ private static bool remove_all_ulong_array (Collection<ulong> coll, ulong[] arr) {
+ bool changed = false;
+ foreach (ulong el in arr) {
+ changed |= coll.remove (el);
+ }
+ return changed;
+ }
+
+ private static bool remove_all_float_array (Collection<float?> coll, float?[] arr) {
+ bool changed = false;
+ foreach (unowned float? el in arr) {
+ changed |= coll.remove (el);
+ }
+ return changed;
+ }
+
+ private static bool remove_all_double_array (Collection<double?> coll, double?[] arr) {
+ bool changed = false;
+ foreach (unowned double? el in arr) {
+ changed |= coll.remove (el);
+ }
+ return changed;
+ }
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]