[Commit] tess sortlist.5c,1.1,1.2 sortlisttest.5c,1.1,1.2
Keith Packard
commit at keithp.com
Fri Jul 2 01:06:09 PDT 2004
Committed by: keithp
Update of /local/src/CVS/tess
In directory home.keithp.com:/tmp/cvs-serv32172
Modified Files:
sortlist.5c sortlisttest.5c
Log Message:
Switch to references for list head
Index: sortlist.5c
===================================================================
RCS file: /local/src/CVS/tess/sortlist.5c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- sortlist.5c 2 Jul 2004 06:53:34 -0000 1.1
+++ sortlist.5c 2 Jul 2004 08:06:07 -0000 1.2
@@ -38,7 +38,7 @@
}
}
- List add (List head, List before, List new)
+ void add (&List head, List before, List new)
{
List after;
@@ -60,16 +60,16 @@
after.elt->prev = new;
validate (head);
- return head;
}
- public List insert (List head, List new, Greater gt)
+ public void insert (&List head, List new, Greater gt)
{
if (head == List.nil)
{
new.elt->next = List.nil;
new.elt->prev = List.nil;
- return new;
+ head = new;
+ return;
}
List l = head;
@@ -80,10 +80,10 @@
l = l.elt->next;
}
- return add (head, p, new);
+ add (&head, p, new);
}
- public List delete (List head, List old)
+ public void delete (&List head, List old)
{
if (old.elt->prev != List.nil)
old.elt->prev.elt->next = old.elt->next;
@@ -92,17 +92,16 @@
if (old.elt->next != List.nil)
old.elt->next.elt->prev = old.elt->prev;
validate (head);
- return head;
}
- public List swap (List head, List a)
+ public void swap (&List head, List a)
{
List b = a.elt->next;
/* remove a */
- head = delete (head, a);
+ delete (&head, a);
/* add a after b */
- return add (head, b, a);
+ add (&head, b, a);
}
}
Index: sortlisttest.5c
===================================================================
RCS file: /local/src/CVS/tess/sortlisttest.5c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- sortlisttest.5c 2 Jul 2004 06:53:34 -0000 1.1
+++ sortlisttest.5c 2 Jul 2004 08:06:07 -0000 1.2
@@ -23,20 +23,20 @@
return a;
}
-public IntList insert_int (IntList head, int i) {
- return insert (head, (IntList.elt) &(IntListElt) { i = i }, int_gt);
+public void insert_int (&IntList head, int i) {
+ insert (&head, (IntList.elt) &(IntListElt) { i = i }, int_gt);
}
-public IntList insert_ints (IntList head, int[*] i) {
+public void insert_ints (&IntList head, int[*] i) {
for (int j = 0; j < dim(i); j++)
- head = insert_int (head, i[j]);
- return head;
+ insert_int (&head, i[j]);
}
public IntList rand_ints (int n)
{
IntList head = IntList.nil;
- return insert_ints (head, rand_array(n));
+ insert_ints (&head, rand_array(n));
+ return head;
}
public void dump_ints (IntList l)
More information about the Commit
mailing list