Loading...
Searching...
No Matches
listmap.h
Go to the documentation of this file.
1
14#ifndef IMQUIC_LISTMAP_H
15#define IMQUIC_LISTMAP_H
16
17#include <glib.h>
18
28
30typedef struct imquic_listmap {
34 GList *list;
36 GList *index;
38 GList *last;
40 GHashTable *table;
42 int length;
44 GDestroyNotify destroy;
50imquic_listmap *imquic_listmap_create(imquic_listmap_key type, GDestroyNotify destroy);
54
61int imquic_listmap_prepend(imquic_listmap *lm, void *key, void *item);
68int imquic_listmap_append(imquic_listmap *lm, void *key, void *item);
74int imquic_listmap_remove(imquic_listmap *lm, void *key);
79
84void *imquic_listmap_find(imquic_listmap *lm, void *key);
89gboolean imquic_listmap_contains(imquic_listmap *lm, void *item);
90
101void *imquic_listmap_next(imquic_listmap *lm, gboolean *found);
107void *imquic_listmap_prev(imquic_listmap *lm, gboolean *found);
108
109
110#endif
int imquic_listmap_append(imquic_listmap *lm, void *key, void *item)
Add a new item at the end of a imquic_listmap instance.
Definition listmap.c:83
int imquic_listmap_clear(imquic_listmap *lm)
Remove all items from a imquic_listmap instance.
Definition listmap.c:117
struct imquic_listmap imquic_listmap
Utility that implements a list and a map at the same time.
imquic_listmap * imquic_listmap_create(imquic_listmap_key type, GDestroyNotify destroy)
Create a new imquic_listmap instance.
Definition listmap.c:21
int imquic_listmap_prepend(imquic_listmap *lm, void *key, void *item)
Add a new item at the beginning of a imquic_listmap instance.
Definition listmap.c:66
void * imquic_listmap_prev(imquic_listmap *lm, gboolean *found)
Get the previous item from the listmap, assuming we're traversing.
Definition listmap.c:164
void * imquic_listmap_find(imquic_listmap *lm, void *key)
Look for an item via its key.
Definition listmap.c:130
int imquic_listmap_remove(imquic_listmap *lm, void *key)
Remove an item from a imquic_listmap instance.
Definition listmap.c:103
void imquic_listmap_traverse(imquic_listmap *lm)
Start traversing a listmap in an ordered way from the start.
Definition listmap.c:143
void * imquic_listmap_next(imquic_listmap *lm, gboolean *found)
Get the next item from the listmap, assuming we're traversing.
Definition listmap.c:148
void imquic_listmap_destroy(imquic_listmap *lm)
Destroy an existing imquic_listmap instance.
Definition listmap.c:42
gboolean imquic_listmap_contains(imquic_listmap *lm, void *item)
Check if a listmap contains a certain item.
Definition listmap.c:136
imquic_listmap_key
Type of keys for the map part, to figure out the hashing algorithm.
Definition listmap.h:20
@ IMQUIC_LISTMAP_NUMBER64
64-bit number
Definition listmap.h:26
@ IMQUIC_LISTMAP_NUMBER
Generic number (up to 32-bits)
Definition listmap.h:22
@ IMQUIC_LISTMAP_STRING
String.
Definition listmap.h:24
Utility that implements a list and a map at the same time.
Definition listmap.h:30
imquic_listmap_key type
Key type.
Definition listmap.h:32
GList * list
Linked list.
Definition listmap.h:34
GHashTable * table
Hashtable to implement the map part.
Definition listmap.h:40
GList * index
Current index in the list, when traversing.
Definition listmap.h:36
int length
Number of items in the listmap.
Definition listmap.h:42
GDestroyNotify destroy
Function to invoke when a stored item is removed.
Definition listmap.h:44
GList * last
Last item in the linked list (for appending without traversing the whole list)
Definition listmap.h:38