diff options
Diffstat (limited to 'src/lib/eina_graph_private.h')
-rw-r--r-- | src/lib/eina_graph_private.h | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/src/lib/eina_graph_private.h b/src/lib/eina_graph_private.h index a75ed6b..75dfffb 100644 --- a/src/lib/eina_graph_private.h +++ b/src/lib/eina_graph_private.h @@ -60,4 +60,42 @@ 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; +} + +typedef struct _Eina_Graph +{ + unsigned int vertices; + unsigned int edges; + unsigned int step; + Eina_Graph_Adjacents *adjs; +} _Eina_Graph; + #endif /* _EINA_GRAPH_PRIVATE_H */ |