Use a double-linked list for the linked blocking queue so insertions are done in O(1) time

This commit is contained in:
Cameron Gutman
2014-04-02 22:47:49 -04:00
parent 761f324465
commit 8dcf4372f4
6 changed files with 27 additions and 18 deletions
+3 -1
View File
@@ -9,7 +9,8 @@
#define LBQ_NO_MEMORY 3
typedef struct _LINKED_BLOCKING_QUEUE_ENTRY {
struct _LINKED_BLOCKING_QUEUE_ENTRY *next;
struct _LINKED_BLOCKING_QUEUE_ENTRY *flink;
struct _LINKED_BLOCKING_QUEUE_ENTRY *blink;
void* data;
} LINKED_BLOCKING_QUEUE_ENTRY, *PLINKED_BLOCKING_QUEUE_ENTRY;
@@ -19,6 +20,7 @@ typedef struct _LINKED_BLOCKING_QUEUE {
int sizeBound;
int currentSize;
PLINKED_BLOCKING_QUEUE_ENTRY head;
PLINKED_BLOCKING_QUEUE_ENTRY tail;
} LINKED_BLOCKING_QUEUE, *PLINKED_BLOCKING_QUEUE;
int LbqInitializeLinkedBlockingQueue(PLINKED_BLOCKING_QUEUE queueHead, int sizeBound);