Priority queues
In a priority queue a number of values are stored, each with a priority. You
can quickly find the values with minimum and maximum priority. Using this
data structure you can handle certain things in the order of priority. The
following functions exist:
ds_priority_create()
Creates a new priority queue. The function returns an integer as
an id that must be used in all other functions to access the particular
priority queue.
ds_priority_destroy(id)
Destroys the priority queue with the given id, freeing the memory used.
Don't forget to call this function when you are ready with the structure.
ds_priority_clear(id)
Clears the priority queue with the given id, removing all
data from it but not destroying it.
ds_priority_copy(id,source)
Copies the priority queue source into the priority queue with the given id.
ds_priority_size(id)
Returns the number of values stored in the priority queue.
ds_priority_empty(id)
Returns whether the priority queue is empty. This is the same as testing
whether the size is 0.
ds_priority_add(id,val,prio)
Adds the value with the given priority to the priority queue.
ds_priority_change_priority(id,val,prio)
Changes the priority of the given value in the priority queue.
ds_priority_find_priority(id,val)
Returns the priority of the given value in the priority queue.
ds_priority_delete_value(id,val)
Deletes the given value (with its priority) from the priority queue.
ds_priority_delete_min(id)
Returns the value with the smallest priority and deletes it from the priority queue.
ds_priority_find_min(id)
Returns the value with the smallest priority but does not delete it from the priority queue.
ds_priority_delete_max(id)
Returns the value with the largest priority and deletes it from the priority queue.
ds_priority_find_max(id)
Returns the value with the largest priority but does not delete it from the priority queue.
ds_priority_write(id)
Turns the data structure into a string and returns this string. The string can then
be used to e.g. save it to a file. This provides an easy mechanism for saving data
structures.
ds_priority_read(id,str)
Reads the data structure from the given string (as created by the previous call).