fx.collections: update header directories

This commit is contained in:
2026-05-02 21:01:51 +01:00
parent b951577f48
commit c78ea4bfa6
26 changed files with 444 additions and 205 deletions
@@ -9,10 +9,10 @@
#ifndef FX_DS_ARRAY_H_
#define FX_DS_ARRAY_H_
#include <fx/core/iterator.h>
#include <fx/core/macros.h>
#include <fx/core/misc.h>
#include <fx/core/status.h>
#include <fx/iterator.h>
#include <fx/macros.h>
#include <fx/misc.h>
#include <fx/status.h>
FX_DECLS_BEGIN;
@@ -51,11 +51,13 @@ FX_TYPE_DEFAULT_CONSTRUCTOR(fx_array, FX_TYPE_ARRAY);
* @return A pointer to the new fx_array, or NULL if an error occurred.
*/
FX_API fx_array *fx_array_create_with_values(
fx_object *const *values, size_t nr_values);
fx_object *const *values,
size_t nr_values);
/**
* Remove all object references from an fx_array, resetting the size of the array to zero.
* The reference counts of all objects in the array will be decremented.
* Remove all object references from an fx_array, resetting the size of the
* array to zero. The reference counts of all objects in the array will be
* decremented.
*
* @param array The fx_array to clear.
*/
@@ -116,11 +118,12 @@ FX_API fx_status fx_array_remove(fx_array *array, size_t at);
/**
* Removes the object at the beginning of an fx_array. The reference count
* of the removed object will be decremented. The remaining objects will be moved
* to fill the empty space created by the object's removal.
* of the removed object will be decremented. The remaining objects will be
* moved to fill the empty space created by the object's removal.
*
* @param array The fx_array to remove the object from.
* @return FX_SUCCESS if the object was removed, or a status code describing any error that occurred.
* @return FX_SUCCESS if the object was removed, or a status code describing any
* error that occurred.
*/
FX_API fx_status fx_array_remove_front(fx_array *array);
@@ -129,7 +132,8 @@ FX_API fx_status fx_array_remove_front(fx_array *array);
* of the removed object will be decremented.
*
* @param array The fx_array to remove the object from.
* @return FX_SUCCESS if the object was removed, or a status code describing any error that occurred.
* @return FX_SUCCESS if the object was removed, or a status code describing any
* error that occurred.
*/
FX_API fx_status fx_array_remove_back(fx_array *array);
@@ -162,8 +166,8 @@ FX_API fx_object *fx_array_pop(fx_array *array, size_t at);
FX_API fx_object *fx_array_pop_front(fx_array *array);
/**
* Removes the object at the end of an fx_array, and returns a pointer to it. The
* reference count of the removed object will NOT be decremented. The caller
* Removes the object at the end of an fx_array, and returns a pointer to it.
* The reference count of the removed object will NOT be decremented. The caller
* becomes the owner of the array's reference to the object.
*
* @param array The fx_array to remove the object from.
@@ -1,7 +1,7 @@
#ifndef FX_DS_BITBUFFER_H_
#define FX_DS_BITBUFFER_H_
#include <fx/core/macros.h>
#include <fx/macros.h>
FX_DECLS_BEGIN;
@@ -13,12 +13,18 @@ FX_TYPE_CLASS_DECLARATION_END(fx_bitbuffer);
FX_API fx_status fx_bitbuffer_put_bit(fx_bitbuffer *buf, int bit);
FX_API fx_status fx_bitbuffer_put_bool(fx_bitbuffer *buf, bool b);
FX_API fx_status fx_bitbuffer_put_int(
fx_bitbuffer *buf, uint64_t v, unsigned int nr_bits);
FX_API fx_status
fx_bitbuffer_put_int(fx_bitbuffer *buf, uint64_t v, unsigned int nr_bits);
FX_API fx_status fx_bitbuffer_put_bytes(
fx_bitbuffer *buf, const void *p, size_t len, size_t bits_per_byte);
fx_bitbuffer *buf,
const void *p,
size_t len,
size_t bits_per_byte);
FX_API fx_status fx_bitbuffer_put_string(
fx_bitbuffer *buf, const char *p, size_t len, size_t bits_per_char);
fx_bitbuffer *buf,
const char *p,
size_t len,
size_t bits_per_char);
FX_DECLS_END;
@@ -1,8 +1,8 @@
#ifndef FX_DS_BITMAP_H_
#define FX_DS_BITMAP_H_
#include <fx/core/macros.h>
#include <fx/core/misc.h>
#include <fx/macros.h>
#include <fx/misc.h>
#include <stdbool.h>
FX_DECLS_BEGIN;
@@ -21,7 +21,10 @@ FX_API fx_bitmap *fx_bitmap_create(size_t nr_bits);
FX_API void fx_bitmap_set_bit(fx_bitmap *map, size_t bit);
FX_API void fx_bitmap_clear_bit(fx_bitmap *map, size_t bit);
FX_API void fx_bitmap_set_range(fx_bitmap *map, size_t first_bit, size_t nbits);
FX_API void fx_bitmap_clear_range(fx_bitmap *map, size_t first_bit, size_t nbits);
FX_API void fx_bitmap_clear_range(
fx_bitmap *map,
size_t first_bit,
size_t nbits);
FX_API void fx_bitmap_set_all(fx_bitmap *map);
FX_API void fx_bitmap_clear_all(fx_bitmap *map);
@@ -1,7 +1,7 @@
#ifndef FX_DS_BUFFER_H_
#define FX_DS_BUFFER_H_
#include <fx/core/macros.h>
#include <fx/macros.h>
#include <stddef.h>
FX_DECLS_BEGIN;
@@ -18,16 +18,19 @@ FX_API fx_type fx_buffer_get_type(void);
FX_API fx_buffer *fx_buffer_create(size_t item_sz);
FX_API fx_buffer *fx_buffer_create_from_bytes(const void *p, size_t len);
FX_API fx_buffer *fx_buffer_create_from_array(
const void *p, size_t item_sz, size_t len);
const void *p,
size_t item_sz,
size_t len);
FX_API void *fx_buffer_steal(fx_buffer *buf);
FX_API fx_status fx_buffer_reserve(fx_buffer *buf, size_t capacity);
FX_API fx_status fx_buffer_resize(fx_buffer *buf, size_t length);
FX_API fx_status fx_buffer_append(fx_buffer *dest, const void *p, size_t count);
FX_API fx_status fx_buffer_prepend(fx_buffer *dest, const void *p, size_t count);
FX_API fx_status fx_buffer_insert(
fx_buffer *dest, const void *p, size_t count, size_t at);
FX_API fx_status
fx_buffer_prepend(fx_buffer *dest, const void *p, size_t count);
FX_API fx_status
fx_buffer_insert(fx_buffer *dest, const void *p, size_t count, size_t at);
FX_API fx_status fx_buffer_remove(fx_buffer *dest, size_t at, size_t count);
FX_API fx_status fx_buffer_clear(fx_buffer *buf);
@@ -1,9 +1,9 @@
#ifndef FX_DS_DATETIME_H_
#define FX_DS_DATETIME_H_
#include <fx/core/macros.h>
#include <fx/core/status.h>
#include <ctype.h>
#include <fx/macros.h>
#include <fx/status.h>
FX_DECLS_BEGIN;
@@ -24,7 +24,8 @@ FX_TYPE_DEFAULT_CONSTRUCTOR(fx_datetime, FX_TYPE_DATETIME);
FX_API fx_datetime *fx_datetime_parse(fx_datetime_format format, const char *s);
FX_API void fx_datetime_to_string(
const fx_datetime *dt, fx_datetime_format format,
const fx_datetime *dt,
fx_datetime_format format,
FX_TYPE_FWDREF(fx_stream) * dest);
FX_API bool fx_datetime_is_localtime(const fx_datetime *dt);
@@ -1,12 +1,12 @@
#ifndef FX_DS_DICT_H_
#define FX_DS_DICT_H_
#include <fx/core/bst.h>
#include <fx/core/macros.h>
#include <fx/core/misc.h>
#include <fx/core/queue.h>
#include <fx/core/status.h>
#include <fx/ds/string.h>
#include <fx/bst.h>
#include <fx/collections/string.h>
#include <fx/macros.h>
#include <fx/misc.h>
#include <fx/queue.h>
#include <fx/status.h>
FX_DECLS_BEGIN;
@@ -27,9 +27,10 @@ FX_TYPE_CLASS_DECLARATION_END(fx_dict_iterator)
#define FX_DICT_ITEM(k, v) {.key = (k), .value = (v)}
#define FX_DICT_ITEM_END {.key = NULL, .value = NULL}
#define fx_dict_foreach(it, dict) \
for (int z__fx_unique_name() = fx_dict_iterator_begin(dict, it); \
(it)->key != NULL; fx_dict_iterator_next(it))
#define fx_dict_foreach(it, dict) \
for (int z__fx_unique_name() = fx_dict_iterator_begin(dict, it); \
(it)->key != NULL; \
fx_dict_iterator_next(it))
typedef struct fx_dict_item {
const fx_string *key;
@@ -46,7 +47,8 @@ FX_API fx_dict *fx_dict_create_with_items(const fx_dict_item *items);
#endif
FX_API fx_status fx_dict_put(fx_dict *dict, const char *key, fx_object *value);
FX_API fx_status fx_dict_put_sk(fx_dict *dict, const fx_string *key, fx_object *value);
FX_API fx_status
fx_dict_put_sk(fx_dict *dict, const fx_string *key, fx_object *value);
FX_API fx_object *fx_dict_at(const fx_dict *dict, const char *key);
FX_API fx_object *fx_dict_at_sk(const fx_dict *dict, const fx_string *key);
FX_API fx_object *fx_dict_get(fx_dict *dict, const char *key);
@@ -1,11 +1,11 @@
#ifndef FX_DS_HASHMAP_H_
#define FX_DS_HASHMAP_H_
#include <fx/core/bst.h>
#include <fx/core/macros.h>
#include <fx/core/misc.h>
#include <fx/core/queue.h>
#include <fx/core/status.h>
#include <fx/bst.h>
#include <fx/macros.h>
#include <fx/misc.h>
#include <fx/queue.h>
#include <fx/status.h>
#include <stddef.h>
FX_DECLS_BEGIN;
@@ -27,14 +27,15 @@ FX_TYPE_CLASS_DECLARATION_END(fx_hashmap_iterator)
#define FX_HASHMAP_KEY(k, ks) {.key_data = (k), .key_size = (ks)}
#define FX_HASHMAP_VALUE(v, vs) {.value_data = (v), .value_size = (vs)}
#define FX_HASHMAP_ITEM(k, ks, v, vs) \
#define FX_HASHMAP_ITEM(k, ks, v, vs) \
{.key = FX_HASHMAP_KEY(k, ks), .value = FX_HASHMAP_VALUE(v, vs)}
#define FX_HASHMAP_ITEM_END {.key = {0}, .value = {0}}
#define fx_hashmap_foreach(it, hashmap) \
for (int z__fx_unique_name() = fx_hashmap_iterator_begin(hashmap, it); \
(it)->key != NULL; fx_hashmap_iterator_next(it))
#define fx_hashmap_foreach(it, hashmap) \
for (int z__fx_unique_name() = fx_hashmap_iterator_begin(hashmap, it); \
(it)->key != NULL; \
fx_hashmap_iterator_next(it))
typedef void (*fx_hashmap_key_destructor)(void *);
typedef void (*fx_hashmap_value_destructor)(void *);
@@ -63,15 +64,21 @@ FX_API fx_type fx_hashmap_get_type(void);
FX_API fx_type fx_hashmap_iterator_get_type(void);
FX_API fx_hashmap *fx_hashmap_create(
fx_hashmap_key_destructor key_dtor, fx_hashmap_value_destructor value_dtor);
fx_hashmap_key_destructor key_dtor,
fx_hashmap_value_destructor value_dtor);
FX_API fx_hashmap *fx_hashmap_create_with_items(const fx_hashmap_item *items);
FX_API fx_status fx_hashmap_put(
fx_hashmap *hashmap, const fx_hashmap_key *key, const fx_hashmap_value *value);
fx_hashmap *hashmap,
const fx_hashmap_key *key,
const fx_hashmap_value *value);
FX_API const fx_hashmap_value *fx_hashmap_get(
const fx_hashmap *hashmap, const fx_hashmap_key *key);
const fx_hashmap *hashmap,
const fx_hashmap_key *key);
FX_API bool fx_hashmap_has_key(const fx_hashmap *hashmap, const fx_hashmap_key *key);
FX_API bool fx_hashmap_has_key(
const fx_hashmap *hashmap,
const fx_hashmap_key *key);
FX_API size_t fx_hashmap_get_size(const fx_hashmap *hashmap);
FX_API bool fx_hashmap_is_empty(const fx_hashmap *hashmap);
@@ -1,9 +1,9 @@
#ifndef FX_DS_LIST_H_
#define FX_DS_LIST_H_
#include <fx/core/iterator.h>
#include <fx/core/macros.h>
#include <fx/core/status.h>
#include <fx/iterator.h>
#include <fx/macros.h>
#include <fx/status.h>
FX_DECLS_BEGIN;
@@ -39,9 +39,13 @@ FX_API fx_list_entry *fx_list_prev(const fx_list_entry *entry);
FX_API size_t fx_list_length(const fx_list *q);
FX_API fx_list_entry *fx_list_insert_before(
fx_list *q, void *ptr, fx_list_entry *before);
fx_list *q,
void *ptr,
fx_list_entry *before);
FX_API fx_list_entry *fx_list_insert_after(
fx_list *q, void *ptr, fx_list_entry *after);
fx_list *q,
void *ptr,
fx_list_entry *after);
FX_API fx_list_entry *fx_list_push_front(fx_list *q, void *ptr);
FX_API fx_list_entry *fx_list_push_back(fx_list *q, void *ptr);
@@ -1,7 +1,7 @@
#ifndef FX_DS_NUMBER_H
#define FX_DS_NUMBER_H
#include <fx/core/macros.h>
#include <fx/macros.h>
#include <stdbool.h>
FX_DECLS_BEGIN;
@@ -133,7 +133,9 @@ static inline fx_number *fx_number_create_size_t(size_t value)
FX_API fx_number_type fx_number_get_number_type(const fx_number *number);
FX_API int fx_number_get_value(
const fx_number *number, fx_number_type type, void *value_ptr);
const fx_number *number,
fx_number_type type,
void *value_ptr);
static inline int8_t fx_number_get_int8(const fx_number *number)
{
@@ -2,11 +2,11 @@
#define FX_DS_STRING_H_
#include <ctype.h>
#include <fx/core/encoding.h>
#include <fx/core/iterator.h>
#include <fx/core/macros.h>
#include <fx/core/status.h>
#include <fx/core/stringstream.h>
#include <fx/encoding.h>
#include <fx/iterator.h>
#include <fx/macros.h>
#include <fx/status.h>
#include <fx/stringstream.h>
FX_DECLS_BEGIN;
@@ -1,10 +1,10 @@
#ifndef FX_DS_TREE_H_
#define FX_DS_TREE_H_
#include <fx/core/macros.h>
#include <fx/core/misc.h>
#include <fx/core/queue.h>
#include <fx/ds/string.h>
#include <fx/collections/string.h>
#include <fx/macros.h>
#include <fx/misc.h>
#include <fx/queue.h>
FX_DECLS_BEGIN;
@@ -22,7 +22,7 @@ FX_TYPE_CLASS_DECLARATION_END(fx_tree_iterator)
#define FX_TREE_NODE_INIT ((fx_tree_node) {0})
#define FX_TREE_CONTAINER(t, m, v) \
#define FX_TREE_CONTAINER(t, m, v) \
((void *)((v) ? (uintptr_t)(v) - (offsetof(t, m)) : 0))
typedef struct fx_tree_node {
@@ -50,7 +50,8 @@ FX_API fx_iterator *fx_tree_node_begin(fx_tree_node *node);
FX_API const fx_iterator *fx_tree_node_cbegin(const fx_tree_node *node);
FX_API fx_iterator *fx_tree_node_begin_recursive(fx_tree_node *node);
FX_API const fx_iterator *fx_tree_node_cbegin_recursive(const fx_tree_node *node);
FX_API const fx_iterator *fx_tree_node_cbegin_recursive(
const fx_tree_node *node);
FX_DECLS_END;
@@ -1,9 +1,9 @@
#ifndef FX_DS_UUID_H_
#define FX_DS_UUID_H_
#include <fx/core/macros.h>
#include <fx/core/status.h>
#include <fx/ds/string.h>
#include <fx/collections/string.h>
#include <fx/macros.h>
#include <fx/status.h>
#define FX_UUID_NBYTES 16
#define FX_UUID_STRING_MAX 37
@@ -29,19 +29,34 @@ FX_API fx_type fx_uuid_get_type(void);
FX_TYPE_DEFAULT_CONSTRUCTOR(fx_uuid, FX_TYPE_UUID);
FX_API fx_uuid *fx_uuid_create_from_bytes(
unsigned char u00, unsigned char u01, unsigned char u02,
unsigned char u03, unsigned char u04, unsigned char u05,
unsigned char u06, unsigned char u07, unsigned char u08,
unsigned char u09, unsigned char u10, unsigned char u11, unsigned char u12,
unsigned char u13, unsigned char u14, unsigned char u15);
FX_API fx_uuid *fx_uuid_create_from_bytev(const unsigned char bytes[FX_UUID_NBYTES]);
unsigned char u00,
unsigned char u01,
unsigned char u02,
unsigned char u03,
unsigned char u04,
unsigned char u05,
unsigned char u06,
unsigned char u07,
unsigned char u08,
unsigned char u09,
unsigned char u10,
unsigned char u11,
unsigned char u12,
unsigned char u13,
unsigned char u14,
unsigned char u15);
FX_API fx_uuid *fx_uuid_create_from_bytev(
const unsigned char bytes[FX_UUID_NBYTES]);
FX_API fx_uuid *fx_uuid_create_from_uuid_bytes(const fx_uuid_bytes *bytes);
FX_API fx_uuid *fx_uuid_create_from_string(const fx_string *string);
FX_API fx_uuid *fx_uuid_create_from_cstr(const char *s);
FX_API fx_status fx_uuid_to_cstr(const fx_uuid *uuid, char out[FX_UUID_STRING_MAX]);
FX_API fx_status fx_uuid_to_cstr(
const fx_uuid *uuid,
char out[FX_UUID_STRING_MAX]);
FX_API void fx_uuid_get_bytes(
const fx_uuid *uuid, unsigned char bytes[FX_UUID_NBYTES]);
const fx_uuid *uuid,
unsigned char bytes[FX_UUID_NBYTES]);
FX_API void fx_uuid_get_uuid_bytes(const fx_uuid *uuid, fx_uuid_bytes *bytes);
FX_API fx_uuid_bytes *fx_uuid_ptr(fx_uuid *uuid);
View File