ayttm-commits
[Top][All Lists]
Advanced

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

[Ayttm-commits] CVS: ayttm/src llist.c,1.1,1.2 llist.h,1.1,1.2


From: Philip S Tellis <address@hidden>
Subject: [Ayttm-commits] CVS: ayttm/src llist.c,1.1,1.2 llist.h,1.1,1.2
Date: Fri, 24 Jan 2003 05:14:34 -0500

Update of /cvsroot/ayttm/ayttm/src
In directory subversions:/tmp/cvs-serv18445/src

Modified Files:
        llist.c llist.h 
Log Message:
added prepend, find, insert_sorted and concat

Index: llist.c
===================================================================
RCS file: /cvsroot/ayttm/ayttm/src/llist.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- llist.c     23 Jan 2003 06:06:40 -0000      1.1
+++ llist.c     24 Jan 2003 10:14:30 -0000      1.2
@@ -18,7 +18,7 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  *
- * Most of this code was borrowed from elist.c in the eb-lite sources
+ * Some of this code was borrowed from elist.c in the eb-lite sources
  *
  */
 
@@ -49,6 +49,32 @@
        }
 }
 
+LList *l_list_prepend(LList * list, void *data)
+{
+       LList *n = malloc(sizeof(LList));
+
+       n->next = list;
+       list->prev = n;
+
+       return n;
+}
+
+LList *l_list_concat(LList * list, LList * add)
+{
+       LList *l;
+
+       if(!list)
+               return add;
+
+       for (l = list; l->next; l = l->next)
+               ;
+
+       l->next = add;
+       add->prev = l;
+
+       return list;
+}
+
 LList *l_list_remove(LList * list, void *data)
 {
        LList *n;
@@ -122,12 +148,42 @@
        }
 }
 
-LList *l_list_find_custom(LList * list, void *data, LListCompFunc comp)
+LList *l_list_find(LList * list, const void *data)
+{
+       LList *l;
+       for (l = list; l && l->data != data; l = l->next)
+               ;
+
+       return l;
+}
+
+LList *l_list_find_custom(LList * list, const void *data, LListCompFunc comp)
 {
        LList *l;
        for (l = list; l; l = l->next)
-               if (comp(l->data, (const void *) data) == 0)
+               if (comp(l->data, data) == 0)
                        return l;
 
        return NULL;
+}
+
+LList *l_list_insert_sorted(LList * list, void *data, LListCompFunc comp)
+{
+       LList *l, *n = malloc(sizeof(LList));
+       n->data = data;
+       for (l = list; l && comp(l->data, (const void *)data) <= 0; l = l->next)
+               ;
+
+
+       n->prev = l->prev;
+       n->next = l;
+       l->prev = n;
+
+       if(n->prev) {
+               n->prev->next = n;
+               return list;
+       } else {
+               return n;
+       }
+               
 }

Index: llist.h
===================================================================
RCS file: /cvsroot/ayttm/ayttm/src/llist.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- llist.h     23 Jan 2003 06:06:40 -0000      1.1
+++ llist.h     24 Jan 2003 10:14:30 -0000      1.2
@@ -42,16 +42,22 @@
 typedef int (*LListCompFunc) (const void *, const void *);
 
 LList *l_list_append(LList * list, void *data);
+LList *l_list_prepend(LList * list, void *data);
 LList *l_list_remove_link(LList * list, const LList * link);
 LList *l_list_remove(LList * list, void *data);
 
+LList *l_list_insert_sorted(LList * list, void * data, LListCompFunc comp);
+
 LList *l_list_copy(LList * list);
 
+LList *l_list_concat(LList * list, LList * add);
+
+LList *l_list_find(LList * list, const void *data);
+LList *l_list_find_custom(LList * list, const void *data, LListCompFunc comp);
+
 void l_list_free_1(LList * list);
 void l_list_free(LList * list);
-int l_list_length(LList * list);
-
-LList *l_list_find_custom(LList * list, void *data, LListCompFunc comp);
+int  l_list_length(LList * list);
 
 #ifdef __cplusplus
 }





reply via email to

[Prev in Thread] Current Thread [Next in Thread]