[glib: 3/8] Add some notes on complexity in glib/glist.c




commit 4d9cd832d1d9bab439de88368d2f52b3ee937071
Author: Emmanuel Fleury <emmanuel fleury gmail com>
Date:   Tue Aug 6 18:52:57 2019 +0200

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

 glib/glist.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
---
diff --git a/glib/glist.c b/glib/glist.c
index 474331ab5..68673768d 100644
--- a/glib/glist.c
+++ b/glib/glist.c
@@ -40,7 +40,12 @@
  * @short_description: linked lists that can be iterated over in both directions
  *
  * The #GList structure and its associated functions provide a standard
- * doubly-linked list data structure.
+ * doubly-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 #GList over
+ * #GSList (singly linked list) is that the worst case on access/search
+ * operations is divided by two which comes at a cost in space as we need
+ * to retain two pointers in place of one.
  *
  * Each element in the list contains a piece of data, together with
  * pointers which link to the previous and next elements in the list.


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