| 62 |
|
return(b); |
| 63 |
|
} |
| 64 |
|
|
| 65 |
+ |
/* attaches list a at the end of list b */ |
| 66 |
+ |
LIST |
| 67 |
+ |
*add_data(l,d,end) |
| 68 |
+ |
LIST *l; |
| 69 |
+ |
int d; |
| 70 |
+ |
LIST **end; |
| 71 |
+ |
|
| 72 |
+ |
{ |
| 73 |
+ |
LIST *list,*lptr; |
| 74 |
+ |
|
| 75 |
+ |
list = new_list(); |
| 76 |
+ |
SET_LIST_DATA(list,d); |
| 77 |
+ |
|
| 78 |
+ |
if(!l) |
| 79 |
+ |
{ |
| 80 |
+ |
if(end) |
| 81 |
+ |
*end = list; |
| 82 |
+ |
return(list); |
| 83 |
+ |
} |
| 84 |
+ |
if(end) |
| 85 |
+ |
lptr = *end; |
| 86 |
+ |
else |
| 87 |
+ |
{ |
| 88 |
+ |
lptr = l; |
| 89 |
+ |
while(LIST_NEXT(lptr)) |
| 90 |
+ |
lptr = LIST_NEXT(lptr); |
| 91 |
+ |
} |
| 92 |
+ |
LIST_NEXT(lptr) = list; |
| 93 |
+ |
if(end) |
| 94 |
+ |
*end = list; |
| 95 |
+ |
|
| 96 |
+ |
return(l); |
| 97 |
+ |
} |
| 98 |
+ |
|
| 99 |
|
/* Adds data to the end of a circular list. If set, "end" |
| 100 |
|
* is a pointer to the last element in the list |
| 101 |
|
*/ |
| 124 |
|
return(l); |
| 125 |
|
} |
| 126 |
|
|
| 93 |
– |
/* Pushes data element d at the top of the list- returns pointer |
| 94 |
– |
to new top of list |
| 95 |
– |
*/ |
| 96 |
– |
LIST |
| 97 |
– |
*push_data(l,d) |
| 98 |
– |
LIST *l; |
| 99 |
– |
int d; |
| 100 |
– |
{ |
| 101 |
– |
LIST * list; |
| 102 |
– |
|
| 103 |
– |
list = new_list(); |
| 104 |
– |
SET_LIST_DATA(list,d); |
| 105 |
– |
SET_LIST_NEXT(list,l); |
| 106 |
– |
return(list); |
| 107 |
– |
} |
| 127 |
|
|
| 128 |
+ |
|
| 129 |
|
/* frees the list */ |
| 130 |
|
LIST |
| 131 |
|
*free_list(l) |
| 139 |
|
return(NULL); |
| 140 |
|
} |
| 141 |
|
|
| 142 |
+ |
/* Pushes data element d at the top of the list- returns pointer |
| 143 |
+ |
to new top of list |
| 144 |
+ |
*/ |
| 145 |
+ |
LIST |
| 146 |
+ |
*push_data(l,d) |
| 147 |
+ |
LIST *l; |
| 148 |
+ |
int d; |
| 149 |
+ |
{ |
| 150 |
+ |
LIST *list; |
| 151 |
+ |
|
| 152 |
+ |
list = new_list(); |
| 153 |
+ |
SET_LIST_DATA(list,d); |
| 154 |
+ |
SET_LIST_NEXT(list,l); |
| 155 |
+ |
return(list); |
| 156 |
+ |
} |
| 157 |
|
/* Returns data element d at the top of the list- returns pointer |
| 158 |
|
to new top of list |
| 159 |
|
*/ |