Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a library for C that provides priority queues? [closed]

Is there a library for C that provides priority queues? I'm interested in open source libraries that are commonly installed on Linux machines, something of the kind of glib, which provides some data structures.

like image 990
Adrian Panasiuk Avatar asked Dec 17 '11 12:12

Adrian Panasiuk


People also ask

Is there priority queue in C?

Also, you will learn about it's implementations in Python, Java, C, and C++. A priority queue is a special type of queue in which each element is associated with a priority value. And, elements are served on the basis of their priority. That is, higher priority elements are served first.

Is queue a library in C?

C is not an object-oriented language, and it doesn't have standard libraries for things like queues. For C++, look for the std::queue. You can, of course, make queue-like structure in C, but you'll wind up doing a lot of the work yourself.

Which data structure is best for implementing a priority queue?

The binary heap is the most efficient method for implementing the priority queue in the data structure.

How do you implement PriorityQueue?

Priority Queues can be implemented using common data structures like arrays, linked-lists, heaps and binary trees. The list is so created so that the highest priority element is always at the head of the list. The list is arranged in descending order of elements based on their priority.


2 Answers

Some random link:

  • PQLib
  • libpqueue
  • pqueue-heap-c

Edit:

In general, books dealing with Linux Kernel and Linux System Programming contain valuable materials related to queues and their implemention details.

like image 188
menjaraz Avatar answered Oct 13 '22 01:10

menjaraz


You may be able to just use message queues, depending on how big the queues need to be.

With posix message queues (see man mq_overview) you can set message priorities.

Alternately, with System V message queues (msgget(), msgsnd(), msgrcv()), you can use the message type as a priority and try retrieving each priority (type) in sequence from highest priority to lowest.

In either case they're standard IPC, and should be available on any normal Linux distribution.

like image 39
Dmitri Avatar answered Oct 12 '22 23:10

Dmitri