49 lines
1.2 KiB
C
49 lines
1.2 KiB
C
#ifndef INCLUDED_C_ADJLIST_H
|
|||
|
|
#define INCLUDED_C_ADJLIST_H
|
||
|
|
|
||
|
|
#ifndef INCLUDED_C_TYPES_H
|
||
|
|
#include <c_Types.h>
|
||
|
|
#endif /*INCLUDED_C_TYPES_H*/
|
||
|
|
|
||
|
|
#ifndef INCLUDED_C_ALLOCATOR_H
|
||
|
|
#include <c_Allocator.h>
|
||
|
|
#endif /*INCLUDED_C_ALLOCATOR_H*/
|
||
|
|
|
||
|
|
/* ------------------------------------------------------------------------------------------------------------------ */
|
||
|
|
/* */
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
typedef struct {
|
||
|
|
c_uint_t* array;
|
||
|
|
c_size_t capacity;
|
||
|
|
c_size_t size;
|
||
|
|
c_Allocator_t allocator;
|
||
|
|
}c_AdjList_t;
|
||
|
|
|
||
|
|
/* ------------------------------------------------------------------------------------------------------------------ */
|
||
|
|
/* */
|
||
|
|
|
||
|
|
|
||
|
|
c_err_t c_AdjList_Init(c_AdjList_t* self, c_size_t capacity, c_Allocator_t* allocator);
|
||
|
|
|
||
|
|
void c_AdjList_Destroy(c_AdjList_t* self);
|
||
|
|
|
||
|
|
c_err_t c_AdjList_Resize(c_AdjList_t* self, c_size_t new_capacity);
|
||
|
|
|
||
|
|
c_err_t c_AdjList_Append(c_AdjList_t* self, c_uint_t value);
|
||
|
|
|
||
|
|
c_err_t c_AdjList_Set(c_AdjList_t* self, c_size_t index, c_uint_t value);
|
||
|
|
|
||
|
|
c_err_t c_AdjList_Get(c_AdjList_t* self, c_size_t index, c_uint_t* value);
|
||
|
|
|
||
|
|
c_err_t c_AdjList_Remove(c_AdjList_t* self, c_size_t index);
|
||
|
|
|
||
|
|
C_STATIC_FORCE_INLINE
|
||
|
|
c_bool_t c_AdjList_IsEmpty(c_AdjList_t* self) {
|
||
|
|
if (!self) return C_TRUE;
|
||
|
|
return self->size==0;
|
||
|
|
}
|
||
|
|
|
||
|
|
#endif /*INCLUDED_C_ADJLIST_H*/
|