1 |
4 |
atypic |
/*
|
2 |
|
|
* Copyright (c) 2007 The Akuma Project
|
3 |
|
|
*
|
4 |
|
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
5 |
|
|
* of this software and associated documentation files (the "Software"), to
|
6 |
|
|
* deal in the Software without restriction, including without limitation the
|
7 |
|
|
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
8 |
|
|
* sell copies of the Software, and to permit persons to whom the Software is
|
9 |
|
|
* furnished to do so, subject to the following conditions:
|
10 |
|
|
*
|
11 |
|
|
* The above copyright notice and this permission notice shall be included in
|
12 |
|
|
* all copies or substantial portions of the Software.
|
13 |
|
|
*
|
14 |
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
15 |
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
16 |
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
17 |
|
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
18 |
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
19 |
|
|
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
20 |
|
|
* IN THE SOFTWARE.
|
21 |
|
|
*
|
22 |
|
|
* $Id: linkedlist.h 107 2007-05-13 17:01:30Z eirik $
|
23 |
|
|
*/
|
24 |
|
|
|
25 |
|
|
#ifndef _LINKEDLIST_H_
|
26 |
|
|
#define _LINKEDLIST_H_
|
27 |
|
|
|
28 |
|
|
struct llist_node {
|
29 |
|
|
struct llist_node *next;
|
30 |
|
|
void *obj;
|
31 |
|
|
};
|
32 |
|
|
typedef struct llist_node *llist_node_t;
|
33 |
|
|
|
34 |
|
|
struct llist_head {
|
35 |
|
|
llist_node_t head, tail;
|
36 |
|
|
};
|
37 |
|
|
typedef struct llist_head *llist_t;
|
38 |
|
|
|
39 |
|
|
|
40 |
|
|
llist_t llist_make(void);
|
41 |
|
|
int llist_add_tail(llist_t, void *);
|
42 |
|
|
int llist_add_head(llist_t, void *);
|
43 |
|
|
int llist_add_pos(llist_t, void *, int);
|
44 |
|
|
void llist_removen(int);
|
45 |
|
|
void llist_remove(void *);
|
46 |
|
|
void llist_destroy(llist_t);
|
47 |
|
|
void *llist_pop(llist_t);
|
48 |
|
|
int llist_empty(llist_t);
|
49 |
|
|
int llist_insert_list_head(llist_t, llist_t);
|
50 |
|
|
void *llist_getobj(llist_node_t);
|
51 |
|
|
void *llist_getelem(llist_t, int);
|
52 |
|
|
int llist_size(llist_t);
|
53 |
|
|
llist_t llist_copy(llist_t);
|
54 |
|
|
void llist_remove_elem(llist_t, int);
|
55 |
|
|
int llist_insert_list(llist_t, llist_t, int);
|
56 |
|
|
|
57 |
|
|
|
58 |
|
|
|
59 |
|
|
|
60 |
|
|
#define LLIST_FOREACH(_head, _node) \
|
61 |
|
|
for (_node = (_head)->head; \
|
62 |
|
|
(_node); \
|
63 |
|
|
(_node) = (_node)->next)
|
64 |
|
|
|
65 |
|
|
#endif /* _LINKEDLIST_H_ */
|