Back to index

php5  5.3.10
zend_llist.h
Go to the documentation of this file.
00001 /*
00002    +----------------------------------------------------------------------+
00003    | Zend Engine                                                          |
00004    +----------------------------------------------------------------------+
00005    | Copyright (c) 1998-2012 Zend Technologies Ltd. (http://www.zend.com) |
00006    +----------------------------------------------------------------------+
00007    | This source file is subject to version 2.00 of the Zend license,     |
00008    | that is bundled with this package in the file LICENSE, and is        | 
00009    | available through the world-wide-web at the following url:           |
00010    | http://www.zend.com/license/2_00.txt.                                |
00011    | If you did not receive a copy of the Zend license and are unable to  |
00012    | obtain it through the world-wide-web, please send a note to          |
00013    | license@zend.com so we can mail you a copy immediately.              |
00014    +----------------------------------------------------------------------+
00015    | Authors: Andi Gutmans <andi@zend.com>                                |
00016    |          Zeev Suraski <zeev@zend.com>                                |
00017    +----------------------------------------------------------------------+
00018 */
00019 
00020 /* $Id: zend_llist.h 321634 2012-01-01 13:15:04Z felipe $ */
00021 
00022 #ifndef ZEND_LLIST_H
00023 #define ZEND_LLIST_H
00024 
00025 typedef struct _zend_llist_element {
00026        struct _zend_llist_element *next;
00027        struct _zend_llist_element *prev;
00028        char data[1]; /* Needs to always be last in the struct */
00029 } zend_llist_element;
00030 
00031 typedef void (*llist_dtor_func_t)(void *);
00032 typedef int (*llist_compare_func_t)(const zend_llist_element **, const zend_llist_element ** TSRMLS_DC);
00033 typedef void (*llist_apply_with_args_func_t)(void *data, int num_args, va_list args TSRMLS_DC);
00034 typedef void (*llist_apply_with_arg_func_t)(void *data, void *arg TSRMLS_DC);
00035 typedef void (*llist_apply_func_t)(void * TSRMLS_DC);
00036 
00037 typedef struct _zend_llist {
00038        zend_llist_element *head;
00039        zend_llist_element *tail;
00040        size_t count;
00041        size_t size;
00042        llist_dtor_func_t dtor;
00043        unsigned char persistent;
00044        zend_llist_element *traverse_ptr;
00045 } zend_llist;
00046 
00047 typedef zend_llist_element* zend_llist_position;
00048 
00049 BEGIN_EXTERN_C()
00050 ZEND_API void zend_llist_init(zend_llist *l, size_t size, llist_dtor_func_t dtor, unsigned char persistent);
00051 ZEND_API void zend_llist_add_element(zend_llist *l, void *element);
00052 ZEND_API void zend_llist_prepend_element(zend_llist *l, void *element);
00053 ZEND_API void zend_llist_del_element(zend_llist *l, void *element, int (*compare)(void *element1, void *element2));
00054 ZEND_API void zend_llist_destroy(zend_llist *l);
00055 ZEND_API void zend_llist_clean(zend_llist *l);
00056 ZEND_API void *zend_llist_remove_tail(zend_llist *l);
00057 ZEND_API void zend_llist_copy(zend_llist *dst, zend_llist *src);
00058 ZEND_API void zend_llist_apply(zend_llist *l, llist_apply_func_t func TSRMLS_DC);
00059 ZEND_API void zend_llist_apply_with_del(zend_llist *l, int (*func)(void *data));
00060 ZEND_API void zend_llist_apply_with_argument(zend_llist *l, llist_apply_with_arg_func_t func, void *arg TSRMLS_DC);
00061 ZEND_API void zend_llist_apply_with_arguments(zend_llist *l, llist_apply_with_args_func_t func TSRMLS_DC, int num_args, ...);
00062 ZEND_API int zend_llist_count(zend_llist *l);
00063 ZEND_API void zend_llist_sort(zend_llist *l, llist_compare_func_t comp_func TSRMLS_DC);
00064 
00065 /* traversal */
00066 ZEND_API void *zend_llist_get_first_ex(zend_llist *l, zend_llist_position *pos);
00067 ZEND_API void *zend_llist_get_last_ex(zend_llist *l, zend_llist_position *pos);
00068 ZEND_API void *zend_llist_get_next_ex(zend_llist *l, zend_llist_position *pos);
00069 ZEND_API void *zend_llist_get_prev_ex(zend_llist *l, zend_llist_position *pos);
00070 
00071 #define zend_llist_get_first(l) zend_llist_get_first_ex(l, NULL)
00072 #define zend_llist_get_last(l) zend_llist_get_last_ex(l, NULL)
00073 #define zend_llist_get_next(l) zend_llist_get_next_ex(l, NULL)
00074 #define zend_llist_get_prev(l) zend_llist_get_prev_ex(l, NULL)
00075 
00076 END_EXTERN_C()
00077 
00078 #endif /* ZEND_LLIST_H */
00079 
00080 /*
00081  * Local variables:
00082  * tab-width: 4
00083  * c-basic-offset: 4
00084  * indent-tabs-mode: t
00085  * End:
00086  */