[glib: 4/8] Add some notes on complexity in glib/gslist.c




commit 69e5e12c9528242f361fb46ce3efff8f82bf43f1
Author: Emmanuel Fleury <emmanuel fleury gmail com>
Date:   Tue Aug 6 19:09:18 2019 +0200

    Add some notes on complexity in glib/gslist.c
    
    Related to issue #3

 glib/gslist.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
---
diff --git a/glib/gslist.c b/glib/gslist.c
index 15b7936c6..c0df55ff5 100644
--- a/glib/gslist.c
+++ b/glib/gslist.c
@@ -39,7 +39,12 @@
  * @short_description: linked lists that can be iterated in one direction
  *
  * The #GSList structure and its associated functions provide a
- * standard singly-linked list data structure.
+ * standard singly-linked list data structure. The benefit of this
+ * data-structure is to provide insertion/deletion operations in O(1)
+ * complexity where access/search operations are in O(n). The benefit
+ * of #GSList over #GList (doubly linked list) is that they are lighter
+ * in space as they only need to retain one pointer but it double the
+ * cost of the worst case access/search operations.
  *
  * Each element in the list contains a piece of data, together with a
  * pointer which links to the next element in the list. Using this


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