Mercurial > almixer_isolated
comparison LinkedList.c @ 17:d58eb38c771b
Needed new Front and Back (non-popping) functions for LinkedList.
author | Eric Wing <ewing . public |-at-| gmail . com> |
---|---|
date | Sat, 06 Nov 2010 04:00:44 -0700 |
parents | b27f7ff5e44b |
children | 14c22fc3c753 |
comparison
equal
deleted
inserted
replaced
16:038baa026db3 | 17:d58eb38c771b |
---|---|
181 } | 181 } |
182 | 182 |
183 tail_node = linked_list->tailPtr; | 183 tail_node = linked_list->tailPtr; |
184 return_data = tail_node->dataPtr; | 184 return_data = tail_node->dataPtr; |
185 | 185 |
186 if(1 == linked_list->currentSize) | 186 if(1 == linked_list->currentSize) |
187 { | 187 { |
188 LinkedList_Clear(linked_list); | 188 LinkedList_Clear(linked_list); |
189 } | 189 } |
190 else | 190 else |
191 { | 191 { |
196 linked_list->currentSize = linked_list->currentSize - 1; | 196 linked_list->currentSize = linked_list->currentSize - 1; |
197 } | 197 } |
198 return return_data; | 198 return return_data; |
199 } | 199 } |
200 | 200 |
201 | |
202 void* LinkedList_Front(LinkedList* linked_list) | |
203 { | |
204 LinkedListNode* head_node; | |
205 void* return_data; | |
206 | |
207 if(NULL == linked_list) | |
208 { | |
209 return 0; | |
210 } | |
211 if(0 == linked_list->currentSize) | |
212 { | |
213 return NULL; | |
214 } | |
215 | |
216 head_node = linked_list->headPtr; | |
217 return_data = head_node->dataPtr; | |
218 | |
219 return return_data; | |
220 } | |
221 | |
222 void* LinkedList_Back(LinkedList* linked_list) | |
223 { | |
224 LinkedListNode* tail_node; | |
225 void* return_data; | |
226 | |
227 if(NULL == linked_list) | |
228 { | |
229 return NULL; | |
230 } | |
231 if(0 == linked_list->currentSize) | |
232 { | |
233 return NULL; | |
234 } | |
235 | |
236 tail_node = linked_list->tailPtr; | |
237 return_data = tail_node->dataPtr; | |
238 | |
239 return return_data; | |
240 } | |
241 | |
242 | |
201 size_t LinkedList_Size(LinkedList* linked_list) | 243 size_t LinkedList_Size(LinkedList* linked_list) |
202 { | 244 { |
203 if(NULL == linked_list) | 245 if(NULL == linked_list) |
204 { | 246 { |
205 return 0; | 247 return 0; |