Created
May 6, 2013 13:42
-
-
Save MarkyC/5525231 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| typedef struct Node Node; | |
| typedef struct FIFOQ FIFOQ; | |
| struct Node { | |
| char data; // the data for this Node | |
| off_t offset; // offset of data byte in the file | |
| Node *next; // next Node in the queue | |
| }; | |
| struct FIFOQ { | |
| Node *head; // first Node in the queue | |
| Node *tail; // last Node in the queue | |
| int size; // number of Nodes | |
| }; | |
| ...... | |
| /** Pops the top Node. Returns NULL if queue is empty */ | |
| Node * q_pop (FIFOQ *q) { | |
| if (q->size <= 0) return NULL; // return null if empty queue | |
| Node * result = q->head; // remove head Node | |
| q->head = q->head->next; // set new head to the next in line | |
| q->size--; // decrement size | |
| return result; // return old head Node | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment