]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
glib-2.0: Add GenericArray.find_custom() as variant of find_with_equal_func()
authorCorentin Noël <corentin@elementary.io>
Tue, 3 Nov 2020 16:22:48 +0000 (17:22 +0100)
committerRico Tzschichholz <ricotz@ubuntu.com>
Sun, 3 Jan 2021 12:11:01 +0000 (13:11 +0100)
This allows the needle to be a different type as the actual element type.
The implementation of ArraySearchFunc<G,T> is more customizable this way.

vapi/glib-2.0.vapi

index 221e48f5b3081f502f45381d2ef502522bc98e25..e08111e4ed1c95f25ed4bb6390fb6e2a88fe3ac2 100644 (file)
@@ -5078,6 +5078,9 @@ namespace GLib {
                public void** pdata;
        }
 
+       [CCode (cname = "GEqualFunc", has_target = false)]
+       public delegate bool ArraySearchFunc<G,T> (G element, T needle);
+
        [Compact]
        [CCode (cname = "GPtrArray", cprefix = "g_ptr_array_", ref_function = "g_ptr_array_ref", unref_function = "g_ptr_array_unref", type_id = "G_TYPE_PTR_ARRAY")]
        [GIR (name = "PtrArray")]
@@ -5089,6 +5092,9 @@ namespace GLib {
                [Version (since = "2.54")]
                public bool find (G needle, out uint index = null);
                [Version (since = "2.54")]
+               [CCode (cname = "g_ptr_array_find_with_equal_func")]
+               public bool find_custom<T> (T needle, GLib.ArraySearchFunc<G,T>? equal_func, out uint index = null);
+               [Version (since = "2.54")]
                public bool find_with_equal_func (G needle, GLib.EqualFunc<G>? equal_func, out uint index = null);
                public void foreach (GLib.Func<G> func);
                [CCode (cname = "g_ptr_array_index")]