#ifndef UCX_KV_LIST_H
#define UCX_KV_LIST_H
#include "common.h"
#include "list.h"
#include "map.h"
#ifdef __cplusplus
extern "C" {
#endif
cx_attr_nodiscard cx_attr_malloc cx_attr_dealloc(cxListFree,
1)
CX_EXPORT CxList *cxKvListCreate(
const CxAllocator *allocator,
cx_compare_func comparator,
size_t elem_size);
cx_attr_nodiscard cx_attr_malloc cx_attr_dealloc(cxMapFree,
1)
CX_EXPORT CxMap *cxKvListCreateAsMap(
const CxAllocator *allocator,
cx_compare_func comparator,
size_t elem_size);
#define cxKvListCreateSimple(elem_size) cxKvListCreate(
NULL,
NULL, elem_size)
#define cxKvListCreateAsMapSimple(elem_size) cxKvListCreateAsMap(
NULL,
NULL, elem_size)
cx_attr_nodiscard cx_attr_nonnull cx_attr_returns_nonnull
CX_EXPORT CxList *cxKvListAsList(CxMap *map);
cx_attr_nodiscard cx_attr_nonnull cx_attr_returns_nonnull
CX_EXPORT CxMap *cxKvListAsMap(CxList *list);
cx_attr_nonnull
CX_EXPORT int cx_kv_list_set_key(CxList *list,
size_t index, CxHashKey key);
cx_attr_nonnull
CX_EXPORT int cx_kv_list_insert(CxList *list,
size_t index, CxHashKey key,
void *value);
#define cxKvListSetKey(list, index, key) cx_kv_list_set_key(list, index,
CX_HASH_KEY(key))
#define cxKvListInsert(list, index, key, value) cx_kv_list_insert(list, index,
CX_HASH_KEY(key), value)
cx_attr_nonnull
CX_EXPORT int cxKvListRemoveKey(CxList *list,
size_t index);
cx_attr_nonnull
CX_EXPORT const CxHashKey *cxKvListGetKey(CxList *list,
size_t index);
#define cxKvListAdd(list, key, value) cxKvListInsert(list, (list)->collection.size, key, value)
#ifdef __cplusplus
}
#endif
#endif