Combined list and map utility. More...
#include <stdint.h>
#include "internal/listmap.h"
#include "internal/utils.h"
#include "imquic/debug.h"
Functions | |
imquic_listmap * | imquic_listmap_create (imquic_listmap_key type, GDestroyNotify destroy) |
Create a new imquic_listmap instance. | |
void | imquic_listmap_destroy (imquic_listmap *lm) |
Destroy an existing imquic_listmap instance. | |
int | imquic_listmap_prepend (imquic_listmap *lm, void *key, void *item) |
Add a new item at the beginning of a imquic_listmap instance. | |
int | imquic_listmap_append (imquic_listmap *lm, void *key, void *item) |
Add a new item at the end of a imquic_listmap instance. | |
int | imquic_listmap_remove (imquic_listmap *lm, void *key) |
Remove an item from a imquic_listmap instance. | |
int | imquic_listmap_clear (imquic_listmap *lm) |
Remove all items from a imquic_listmap instance. | |
void * | imquic_listmap_find (imquic_listmap *lm, void *key) |
Look for an item via its key. | |
gboolean | imquic_listmap_contains (imquic_listmap *lm, void *item) |
Check if a listmap contains a certain item. | |
void | imquic_listmap_traverse (imquic_listmap *lm) |
Start traversing a listmap in an ordered way from the start. | |
void * | imquic_listmap_next (imquic_listmap *lm, gboolean *found) |
Get the next item from the listmap, assuming we're traversing. | |
void * | imquic_listmap_prev (imquic_listmap *lm, gboolean *found) |
Get the previous item from the listmap, assuming we're traversing. | |
Combined list and map utility.
Implementation of a generic structure that contains properties both of a map and a linked list (with quick pointers to the head to work a bit like a queue, when appending). Mostly to be used for tracking in an efficient way resources that must be ordered, but also quickly accessed via a key (e.g., sent packets by packet number).
int imquic_listmap_append | ( | imquic_listmap * | lm, |
void * | key, | ||
void * | item ) |
Add a new item at the end of a imquic_listmap instance.
lm | The imquic_listmap instance to append the item to |
key | The item key, for the map |
item | The item to add to the listmap |
int imquic_listmap_clear | ( | imquic_listmap * | lm | ) |
Remove all items from a imquic_listmap instance.
lm | The imquic_listmap instance to clear |
gboolean imquic_listmap_contains | ( | imquic_listmap * | lm, |
void * | item ) |
Check if a listmap contains a certain item.
lm | The imquic_listmap instance to search |
item | The item to find |
imquic_listmap * imquic_listmap_create | ( | imquic_listmap_key | type, |
GDestroyNotify | destroy ) |
Create a new imquic_listmap instance.
type | The imquic_listmap_key key type |
destroy | The function to invoke when a stored item is removed |
void imquic_listmap_destroy | ( | imquic_listmap * | lm | ) |
Destroy an existing imquic_listmap instance.
lm | The imquic_listmap instance to destroy |
void * imquic_listmap_find | ( | imquic_listmap * | lm, |
void * | key ) |
Look for an item via its key.
lm | The imquic_listmap instance to lookup |
key | The item key to lookup |
void * imquic_listmap_next | ( | imquic_listmap * | lm, |
gboolean * | found ) |
Get the next item from the listmap, assuming we're traversing.
[in] | lm | The imquic_listmap to get the next item from |
[out] | found | Set to TRUE if the item was found (to avoid ambiguities if the item itself is 0 or NULL) |
int imquic_listmap_prepend | ( | imquic_listmap * | lm, |
void * | key, | ||
void * | item ) |
Add a new item at the beginning of a imquic_listmap instance.
lm | The imquic_listmap instance to prepend the item to |
key | The item key, for the map |
item | The item to add to the listmap |
void * imquic_listmap_prev | ( | imquic_listmap * | lm, |
gboolean * | found ) |
Get the previous item from the listmap, assuming we're traversing.
[in] | lm | The imquic_listmap to get the previous item from |
[out] | found | Set to TRUE if the item was found (to avoid ambiguities if the item itself is 0 or NULL) |
int imquic_listmap_remove | ( | imquic_listmap * | lm, |
void * | key ) |
Remove an item from a imquic_listmap instance.
lm | The imquic_listmap instance to remove the item from |
key | The key of the item to remove |
void imquic_listmap_traverse | ( | imquic_listmap * | lm | ) |
Start traversing a listmap in an ordered way from the start.
lm | The imquic_listmap to start traversing |