libdom
Loading...
Searching...
No Matches
list.h
Go to the documentation of this file.
1/*
2 * This file is part of libdom test suite.
3 * Licensed under the MIT License,
4 * http://www.opensource.org/licenses/mit-license.php
5 * Copyright 2007 James Shaw <jshaw@netsurf-browser.org>
6 */
7
8#ifndef list_h_
9#define list_h_
10
11#include <stdbool.h>
12
13#include "comparators.h"
14
15/* The element type in the list
16 *
17 * The high byte is used for category type
18 * The low byte is used for concrete type
19 */
20typedef enum TYPE {
21 INT = 0x0001,
22 STRING = 0x0100,
23 DOM_STRING = 0x0101,
24 NODE = 0x0200
26
27
28struct list_elt {
29 void* data;
30 struct list_elt* next;
31};
32
33typedef struct list {
34 unsigned int size;
36 struct list_elt* head;
37 struct list_elt* tail;
39
40struct list* list_new(TYPE type);
41void list_destroy(struct list* list);
42
46void list_add(struct list* list, void* data);
47
55bool list_remove(struct list* list, void* data);
56
57struct list* list_clone(struct list* list);
61bool list_contains(struct list* list, void* data,
63
67bool list_contains_all(struct list* superList, struct list* subList,
69
70#endif
int(* comparator)(const void *a, const void *b)
Definition comparators.h:15
Definition list.h:28
struct list_elt * next
Definition list.h:30
void * data
Definition list.h:29
Definition list.h:33
struct list_elt * tail
Definition list.h:37
unsigned int size
Definition list.h:34
TYPE type
Definition list.h:35
struct list_elt * head
Definition list.h:36
bool list_contains(struct list *list, void *data, comparator comparator)
Definition list.c:133
void list_add(struct list *list, void *data)
Definition list.c:61
bool list_remove(struct list *list, void *data)
Definition list.c:86
TYPE
Definition list.h:20
@ NODE
Definition list.h:24
@ DOM_STRING
Definition list.h:23
@ STRING
Definition list.h:22
@ INT
Definition list.h:21
void list_destroy(struct list *list)
Definition list.c:46
bool list_contains_all(struct list *superList, struct list *subList, comparator comparator)
Definition list.c:145
struct list list
struct list * list_new(TYPE type)
Definition list.c:35
struct list * list_clone(struct list *list)
Definition list.c:120