diff options
author | Jérémy Zurcher <jeremy@asynk.ch> | 2014-01-10 10:14:45 +0100 |
---|---|---|
committer | Jérémy Zurcher <jeremy@asynk.ch> | 2014-01-10 10:14:45 +0100 |
commit | 5e8e882c7092feaaf4a56506dbda611ed7755d28 (patch) | |
tree | a47d7137b90f719773c1efc253cd40f4d85a42bd /src/lib/eina_graph_private.h | |
parent | b9cc34a3cc89992ad211bd6e5d6da61c435f46c7 (diff) | |
download | eina_graph-5e8e882c7092feaaf4a56506dbda611ed7755d28.zip eina_graph-5e8e882c7092feaaf4a56506dbda611ed7755d28.tar.gz |
use eina_array for adjacents list instead of custom implementation
Diffstat (limited to 'src/lib/eina_graph_private.h')
-rw-r--r-- | src/lib/eina_graph_private.h | 42 |
1 files changed, 9 insertions, 33 deletions
diff --git a/src/lib/eina_graph_private.h b/src/lib/eina_graph_private.h index 1c4ea86..1925cf7 100644 --- a/src/lib/eina_graph_private.h +++ b/src/lib/eina_graph_private.h @@ -60,36 +60,6 @@ extern int _eina_graph_log_dom; #endif #define DBG(...) EINA_LOG_DOM_DBG(_eina_graph_log_dom, __VA_ARGS__) -typedef struct _Eina_Graph_Adjacents -{ - unsigned int *data; - unsigned int total; - unsigned int count; -} _Eina_Graph_Adjacents; - -static inline void -eina_graph_adjacents_free(_Eina_Graph_Adjacents *adjs) -{ - if (adjs->data) - free(adjs->data); - adjs->data = NULL; -} - -Eina_Bool -_eina_graph_adjacents_grow(_Eina_Graph_Adjacents *adjs, unsigned int step); - -static inline Eina_Bool -eina_graph_adjacents_push(_Eina_Graph_Adjacents *adjs, unsigned int v, unsigned int step) -{ - if (EINA_UNLIKELY((adjs->count + 1) > adjs->total)) - if (!_eina_graph_adjacents_grow(adjs, step)) - return EINA_FALSE; - - adjs->data[adjs->count++] = v; - - return EINA_TRUE; -} - static inline Eina_Bool eina_array_push_uint(Eina_Array *array, unsigned int v) { @@ -103,10 +73,17 @@ eina_array_push_uint(Eina_Array *array, unsigned int v) } static inline unsigned int +eina_array_uint_nth_get(const Eina_Array *array, unsigned int idx) +{ + return (unsigned int) (uintptr_t) + eina_array_data_get(array, idx); +} + +static inline unsigned int eina_array_top_uint_get(const Eina_Array *array) { return (unsigned int) (uintptr_t) - eina_array_data_get(array,eina_array_count_get(array) - 1 ); + eina_array_data_get(array, eina_array_count_get(array) - 1 ); } /*+ @@ -118,8 +95,7 @@ typedef struct _Eina_Graph { unsigned int vertices; unsigned int edges; - unsigned int step; - _Eina_Graph_Adjacents *adjs; + Eina_Array *adjs[]; } _Eina_Graph; typedef struct _Eina_Graph_DFS_Data |