Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Are there standard Queue implementations for C?

Is there any Queue data structure implementation that "comes" with C or will I have to develop my own (this is for a school project, thus I must use something that either exists in the standard gcc installation or have to implement one by myself!)

What about other general data structures like Linked Lists, Stacks, etc?

like image 287
devoured elysium Avatar asked Nov 15 '10 13:11

devoured elysium


3 Answers

Try this. Unix comes with several kinds of linked lists - you can use one of them to create other possibly list based structures such as a stack.

man queue
like image 191
Sudhanshu Avatar answered Sep 26 '22 23:09

Sudhanshu


You could use a named pipe. It's a FIFO data structure and is part of the posix standard. If all your want is enque to the back and remove from the front it will work. You'll need to keep track of message boundaries by hand though, perhaps by having the first element be the number of bytes in the next message.

like image 33
Paul Rubel Avatar answered Sep 23 '22 23:09

Paul Rubel


Use BSB lib. sys/queue.h and sys/tree.h have implementations of various lists and trees.

like image 43
Paul Avatar answered Sep 24 '22 23:09

Paul