EECS678: Project 2: Scheduler
libpriqueue.h
Go to the documentation of this file.
1 
4 #ifndef LIBPRIQUEUE_H_
5 #define LIBPRIQUEUE_H_
6 
7 #ifdef __cplusplus
8 extern "C" {
9 #endif
10 
11 struct node_t;
12 struct priqueue_t;
13 
21 typedef struct node_t {
22  void *data;
23  struct node_t *next;
24 } node_t;
25 
26 
36 typedef struct priqueue_t {
38  unsigned int size;
39  int (*comparer)(const void *, const void *);
40 } priqueue_t;
41 
42 
43 void priqueue_init(priqueue_t *q, int (*comparer)(const void *, const void *));
44 
45 unsigned int priqueue_offer(priqueue_t *q, void *ptr);
46 void *priqueue_peek(priqueue_t *q);
47 void *priqueue_poll(priqueue_t *q);
48 void *priqueue_at(priqueue_t *q, unsigned int index);
49 unsigned int priqueue_remove(priqueue_t *q, void *ptr);
50 void *priqueue_remove_at(priqueue_t *q, unsigned int index);
51 unsigned int priqueue_size(priqueue_t *q);
52 
54 
55 void priqueue_print(priqueue_t *q, char *str);
56 
57 #ifdef __cplusplus
58 }
59 #endif
60 
61 #endif /* LIBPQUEUE_H_ */
priqueue_at
void * priqueue_at(priqueue_t *q, unsigned int index)
Returns the element at the specified position in this list, or NULL if the queue does not contain an ...
Definition: libpriqueue.c:157
priqueue_poll
void * priqueue_poll(priqueue_t *q)
Retrieves and removes the head of this queue, or NULL if this queue is empty.
Definition: libpriqueue.c:113
priqueue_destroy
void priqueue_destroy(priqueue_t *q)
Destroys and frees all the memory associated with q.
Definition: libpriqueue.c:291
priqueue_offer
unsigned int priqueue_offer(priqueue_t *q, void *ptr)
Insert the specified element into this priority queue.
Definition: libpriqueue.c:48
node_t
priqueue_t node structure
Definition: libpriqueue.h:21
priqueue_t::comparer
int(* comparer)(const void *, const void *)
Definition: libpriqueue.h:39
node_t::data
void * data
Definition: libpriqueue.h:22
node_t::next
struct node_t * next
Definition: libpriqueue.h:23
priqueue_remove
unsigned int priqueue_remove(priqueue_t *q, void *ptr)
Removes all instances of ptr from the queue.
Definition: libpriqueue.c:184
priqueue_t::size
unsigned int size
Definition: libpriqueue.h:38
priqueue_init
void priqueue_init(priqueue_t *q, int(*comparer)(const void *, const void *))
Initializes the priqueue_t data structure.
Definition: libpriqueue.c:34
priqueue_remove_at
void * priqueue_remove_at(priqueue_t *q, unsigned int index)
Removes the specified index from the queue, moving later elements up a spot in the queue to fill the ...
Definition: libpriqueue.c:244
priqueue_t::root
node_t * root
Definition: libpriqueue.h:37
priqueue_size
unsigned int priqueue_size(priqueue_t *q)
Return the number of elements in the queue.
Definition: libpriqueue.c:281
priqueue_peek
void * priqueue_peek(priqueue_t *q)
Retrieves, but does not remove, the head of this queue, returning NULL if this queue is empty.
Definition: libpriqueue.c:100
priqueue_t
Priority Queue Structure.
Definition: libpriqueue.h:36