[tracker] libtracker-common: Added tracker_gslist_with_string_data_equal()



commit 800b497037b798acc6aa96de1d4de54dd40d0ebc
Author: Martyn Russell <martyn lanedo com>
Date:   Tue Feb 9 23:58:31 2010 +0100

    libtracker-common: Added tracker_gslist_with_string_data_equal()

 src/libtracker-common/tracker-type-utils.c |   45 ++++++++++++++++++++++++++++
 src/libtracker-common/tracker-type-utils.h |    2 +
 2 files changed, 47 insertions(+), 0 deletions(-)
---
diff --git a/src/libtracker-common/tracker-type-utils.c b/src/libtracker-common/tracker-type-utils.c
index 5421666..f5bf266 100644
--- a/src/libtracker-common/tracker-type-utils.c
+++ b/src/libtracker-common/tracker-type-utils.c
@@ -687,6 +687,51 @@ tracker_gslist_to_string_list (GSList *list)
 	return strv;
 }
 
+gboolean
+tracker_gslist_with_string_data_equal (GSList *list1,
+                                       GSList *list2)
+{
+        GSList *sl;
+
+        if (list1 == list2) {
+                return TRUE;
+        }
+
+        if (g_slist_length (list1) != g_slist_length (list2)) {
+                return FALSE;
+        }
+
+        /* NOTE: This is probably not the most efficient way to do
+         * this, but we don't want to order the list first since that
+         * would involve creating new memory. This would make sense
+         * for large list operations I think. We don't expect to be
+         * doing much if any of that.
+         */
+        for (sl = list1; sl; sl = sl->next) {
+                const gchar *str;
+
+                str = sl->data;
+
+                /* If we are not still in the list, remove the dir */
+                if (!tracker_string_in_gslist (str, list2)) {
+                        return FALSE;
+                }
+        }
+
+        for (sl = list2; sl; sl = sl->next) {
+                const gchar *str;
+
+                str = sl->data;
+
+                /* If we are now in the list, add the dir */
+                if (!tracker_string_in_gslist (str, list1)) {
+                        return FALSE;
+                }
+        }
+
+        return TRUE;
+}
+
 GSList *
 tracker_gslist_copy_with_string_data (GSList *list)
 {
diff --git a/src/libtracker-common/tracker-type-utils.h b/src/libtracker-common/tracker-type-utils.h
index 8c45430..4d5ae19 100644
--- a/src/libtracker-common/tracker-type-utils.h
+++ b/src/libtracker-common/tracker-type-utils.h
@@ -53,6 +53,8 @@ gchar *  tracker_string_list_to_string         (gchar       **strv,
                                                 gchar         sep);
 gchar ** tracker_string_to_string_list         (const gchar  *str);
 gchar ** tracker_gslist_to_string_list         (GSList       *list);
+gboolean tracker_gslist_with_string_data_equal (GSList       *list1,
+                                                GSList       *list2);
 GSList * tracker_gslist_copy_with_string_data  (GSList       *list);
 GList *  tracker_glist_copy_with_string_data   (GList        *list);
 gchar *  tracker_string_boolean_to_string_gint (const gchar  *value);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]