waitui/library/list/include/waitui/list_generic.h
Rick Barenthin 219812f20e
All checks were successful
continuous-integration/drone/push Build is passing
feat(hashtable): add a hashtable implementation
This is a generic hashtable implementation.

Reviewed-on: #12
PR #12
2022-07-27 19:10:09 +02:00

79 lines
3.2 KiB
C

/**
* @file list_generic.h
* @author rick
* @date 26.07.22
* @brief File for the generic List implementation
*/
#ifndef WAITUI_LIST_GENERIC_H
#define WAITUI_LIST_GENERIC_H
// -----------------------------------------------------------------------------
// Public defines
// -----------------------------------------------------------------------------
#define INTERFACE_LIST_TYPEDEF(type) \
typedef waitui_list type##_list; \
typedef waitui_list_iter type##_list_iter
#define INTERFACE_LIST_NEW(type) extern type##_list *type##_list_new()
#define INTERFACE_LIST_DESTROY(type) \
extern void type##_list_destroy(type##_list **this)
#define INTERFACE_LIST_PUSH(type) \
extern int type##_list_push(type##_list *this, type *type##Element)
#define INTERFACE_LIST_POP(type) extern type *type##_list_pop(type##_list *this)
#define INTERFACE_LIST_UNSHIFT(type) \
extern int type##_list_unshift(type##_list *this, type *type##Element)
#define INTERFACE_LIST_SHIFT(type) \
extern type *type##_list_shift(type##_list *this)
#define INTERFACE_LIST_PEEK(type) \
extern type *type##_list_peek(type##_list *this)
#define INTERFACE_LIST_GET_ITERATOR(type) \
extern type##_list_iter *type##_list_getIterator(type##_list *this)
#define INTERFACE_LIST_ITER_HAS_NEXT(type) \
extern bool type##_list_iter_hasNext(type##_list_iter *this)
#define INTERFACE_LIST_ITER_NEXT(type) \
extern type *type##_list_iter_next(type##_list_iter *this)
#define INTERFACE_LIST_ITER_DESTROY(type) \
extern void type##_list_iter_destroy(type##_list_iter **this)
/**
* @brief Define for quickly created list implementations for a value type
* @param[in] kind Whether to create interface list definition
* or actual implementation
* @param[in] type For what type to create the list
*/
#define CREATE_LIST_TYPE(kind, type) \
kind##_LIST_TYPEDEF(type); \
kind##_LIST_NEW(type); \
kind##_LIST_DESTROY(type); \
kind##_LIST_PUSH(type); \
kind##_LIST_POP(type); \
kind##_LIST_UNSHIFT(type); \
kind##_LIST_SHIFT(type); \
kind##_LIST_PEEK(type); \
kind##_LIST_GET_ITERATOR(type); \
kind##_LIST_ITER_HAS_NEXT(type); \
kind##_LIST_ITER_NEXT(type); \
kind##_LIST_ITER_DESTROY(type);
#endif//WAITUI_LIST_GENERIC_H