Skip to content

Commit

Permalink
remove redundant code, making it more generic
Browse files Browse the repository at this point in the history
  • Loading branch information
mjopenglsdl committed Jul 6, 2016
1 parent 3ee17cd commit c3e6e79
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions Queue/Queue.c
Original file line number Diff line number Diff line change
Expand Up @@ -74,19 +74,15 @@ int queue_pop(Queue_t * q, queue_callback_func_pop cb){
}

void * queue_front(Queue_t * q){
QueueItem_t * next = q->head;
QueueItem_t * tmp = q->head;

if(q->size == 0) return( (void *)0);

if(q->size == 1){
return(q->head->data);
}

while(next->next){
next = next->next;
while(tmp->next){
tmp = tmp->next;
}

return( next->data );
return( tmp->data );
}

void queue_for_each(Queue_t * q, queue_callback_func cb){
Expand Down

0 comments on commit c3e6e79

Please sign in to comment.