00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef GCONTAINER_H
00021 #define GCONTAINER_H
00022
00023 #ifdef HAVE_CONFIG_H
00024 # include <config.h>
00025 #endif
00026
00027 #include <glib.h>
00028
00030 typedef enum { GCONT_PTR_ARRAY, GCONT_LIST, GCONT_SLIST } GContType;
00031
00033 typedef struct {
00034 GContType type;
00035 int len;
00036 void *data;
00037 } GContainer;
00038
00040 typedef struct {
00041 GContType type;
00042 int index;
00043 union {
00044 GPtrArray *array;
00045 GSList *slistPtr;
00046 struct {
00047 GList *curr;
00048 GList *last;
00049 } list;
00050 } data;
00051 } GIterator;
00052
00053 GContainer* g_container_new(GContType type);
00054 GContainer* g_container_new_from_data(GContType type, void *data);
00055
00056 void g_container_add(GContainer *container, const gpointer data);
00057
00058 gboolean g_container_remove(GContainer *container, const gpointer data);
00059 gboolean g_container_remove_fast(GContainer *container, const gpointer data);
00060 gpointer g_container_remove_index(GContainer *container, guint index);
00061 gpointer g_container_remove_index_fast(GContainer *container, guint index);
00062
00063 gpointer g_container_index(const GContainer *container, guint index);
00064
00065 gboolean g_container_get_iter(GIterator *iter, const GContainer *container);
00066 gboolean g_container_get_iter_last(GIterator *iter, const GContainer *container);
00067
00068 gpointer g_iterator_get(const GIterator *iter);
00069 gpointer g_iterator_next(GIterator *iter);
00070 gpointer g_iterator_prev(GIterator *iter);
00071 gboolean g_iterator_hasNext(const GIterator *iter);
00072 gboolean g_iterator_hasPrev(const GIterator *iter);
00073
00075 void* g_container_free(GContainer *container, gboolean freeAssoc);
00076
00078 void g_container_copy(GContainer *dest, GContainer *src);
00080 void g_container_convert(GContType type, GContainer *container);
00082 void g_container_destroy(GContainer *array);
00084 void g_container_destroy_type(GContType type, void *array);
00085
00086 #endif