[glib] Add a note of caution to the g_slist_delete_link() docs



commit 22e9f72a8e23c9469c2891e48e082be664429dac
Author: Matthias Clasen <mclasen redhat com>
Date:   Sat Jun 23 17:30:10 2012 -0400

    Add a note of caution to the g_slist_delete_link() docs

 glib/gslist.c |   12 ++++++++++++
 1 files changed, 12 insertions(+), 0 deletions(-)
---
diff --git a/glib/gslist.c b/glib/gslist.c
index 8d32d05..1b047ec 100644
--- a/glib/gslist.c
+++ b/glib/gslist.c
@@ -515,6 +515,12 @@ _g_slist_remove_link (GSList *list,
  * link is set to %NULL, so that it becomes a
  * self-contained list with one element.
  *
+ * <note>Removing arbitrary nodes from a singly-linked list
+ * requires time that is proportional to the length of the list
+ * (ie. O(n)). If you find yourself using g_slist_remove_link()
+ * frequently, you should consider a different data structure, such
+ * as the doubly-linked #GList.</note>
+ *
  * Returns: the new start of the #GSList, without the element
  */
 GSList*
@@ -533,6 +539,12 @@ g_slist_remove_link (GSList *list,
  * Compare this to g_slist_remove_link() which removes the node
  * without freeing it.
  *
+ * <note>Removing arbitrary nodes from a singly-linked list
+ * requires time that is proportional to the length of the list
+ * (ie. O(n)). If you find yourself using g_slist_delete_link()
+ * frequently, you should consider a different data structure, such
+ * as the doubly-linked #GList.</note>
+ *
  * Returns: the new head of @list
  */
 GSList*



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