BLOG | DOCUMENTATION | TRAC

Home --> Documentations --> PJLIB Reference

list.h
Go to the documentation of this file.
1 /* $Id: list.h 4624 2013-10-21 06:37:30Z ming $ */
2 /*
3  * Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com)
4  * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org>
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19  */
20 #ifndef __PJ_LIST_H__
21 #define __PJ_LIST_H__
22 
28 #include <pj/types.h>
29 
31 
32 /*
33  * @defgroup PJ_DS Data Structure.
34  */
35 
62 #define PJ_DECL_LIST_MEMBER(type) \
63  \
64  type *prev; \
65  \
66  type *next
67 
68 
74 struct pj_list
75 {
77 } PJ_ATTR_MAY_ALIAS; /* may_alias avoids warning with gcc-4.4 -Wall -O2 */
78 
79 
89 {
90  ((pj_list*)node)->next = ((pj_list*)node)->prev = node;
91 }
92 
93 
103 {
104  return ((pj_list*)node)->next == node;
105 }
106 
107 
117 
118 
127 {
128  pj_list_insert_before(list, node);
129 }
130 
131 
139  pj_list_type *nodes);
140 
151 
152 
161 {
162  pj_list_insert_after(list, node);
163 }
164 
165 
173  pj_list_type *nodes);
174 
175 
191 
192 
209 
210 
216 PJ_IDECL(void) pj_list_erase(pj_list_type *node);
217 
218 
229  pj_list_type *node);
230 
231 
246 PJ_IDECL(pj_list_type*) pj_list_search(pj_list_type *list, void *value,
247  int (*comp)(void *value,
248  const pj_list_type *node)
249  );
250 
251 
260 
261 
266 #if PJ_FUNCTIONS_ARE_INLINED
267 # include "list_i.h"
268 #endif
269 
271 
272 #endif /* __PJ_LIST_H__ */
273 
void pj_list_erase(pj_list_type *node)
void pj_list_push_back(pj_list_type *list, pj_list_type *node)
Definition: list.h:126
pj_list_type * pj_list_find_node(pj_list_type *list, pj_list_type *node)
void pj_list_merge_first(pj_list_type *list1, pj_list_type *list2)
Declaration of basic types and utility.
void pj_list_insert_after(pj_list_type *pos, pj_list_type *node)
void pj_list_insert_nodes_after(pj_list_type *lst, pj_list_type *nodes)
pj_size_t pj_list_size(const pj_list_type *list)
#define PJ_END_DECL
Definition: config.h:1067
pj_list_type * pj_list_search(pj_list_type *list, void *value, int(*comp)(void *value, const pj_list_type *node))
#define PJ_DECL_LIST_MEMBER(type)
Definition: list.h:62
#define PJ_BEGIN_DECL
Definition: config.h:1066
int pj_list_empty(const pj_list_type *node)
Definition: list.h:102
#define PJ_INLINE(type)
Definition: config.h:960
void pj_list_insert_nodes_before(pj_list_type *lst, pj_list_type *nodes)
void pj_list_type
Definition: types.h:157
#define PJ_IDECL(type)
Definition: config.h:1115
void pj_list_init(pj_list_type *node)
Definition: list.h:88
void pj_list_push_front(pj_list_type *list, pj_list_type *node)
Definition: list.h:160
void pj_list_merge_last(pj_list_type *list1, pj_list_type *list2)
void pj_list_insert_before(pj_list_type *pos, pj_list_type *node)
Definition: list.h:74
size_t pj_size_t
Definition: types.h:58

 


PJLIB Open Source, high performance, small footprint, and very very portable framework
Copyright (C) 2006-2009 Teluu Inc.