diff options
| author | Tyge Løvset <[email protected]> | 2020-11-30 15:18:26 +0100 |
|---|---|---|
| committer | Tyge Løvset <[email protected]> | 2020-11-30 15:18:26 +0100 |
| commit | 479c68a7946e5a07648ff2d716f4f61837f595d1 (patch) | |
| tree | da57a51af7983e4e9702b28802ea92485833989c | |
| parent | c7253fa4c12adf0639c1ed3a0cd2b2ea28ee194f (diff) | |
| download | STC-modified-479c68a7946e5a07648ff2d716f4f61837f595d1.tar.gz STC-modified-479c68a7946e5a07648ff2d716f4f61837f595d1.zip | |
Added cvec api docs.
| -rw-r--r-- | docs/clist_api.md | 113 | ||||
| -rw-r--r-- | docs/cstr_api.md | 11 | ||||
| -rw-r--r-- | docs/cvec_api.md | 105 |
3 files changed, 169 insertions, 60 deletions
diff --git a/docs/clist_api.md b/docs/clist_api.md index d30c5338..5d6f789d 100644 --- a/docs/clist_api.md +++ b/docs/clist_api.md @@ -2,47 +2,49 @@ UNDER CONSTRUCTION! -This describes the API of string type **clist_xx**. +This describes the API of circular singly linked list type **clist**. ## Instantiation ```c -#define using_clist(xx, Value, ...) - #define using_clist_str() -#define using_clist(xx, Value, valueDestroy=c_default_del, +#define using_clist(z, Value, valueDestroy=c_default_del, valueCompareRaw=c_default_compare, RawValue=Value, valueToRaw=c_default_to_raw, valueFromRaw=c_default_from_raw) ``` The macro `using_clist()` can be instantiated with 2, 3, 4, or 7 arguments. Defaults are given above for args not specified. -Note that xx can be any name, it's a tag and will affect the names of all clist types and methods, -e.g. for `using_clist(my, int);` 'xx' should be replaced by 'my' in all the following. -`using_clist_str()` is a predefined definition of clist_using(str, cstr_t, ...). +Note that `z` can be any name, it's a tag and will affect the names of all clist types and methods, +e.g. for `using_clist(my, int);` `_z` should be replaced by `_my` in all the following documentation. +`using_clist_str()` is a predefined macro for `clist_using(str, cstr_t, ...)`. ## Types -| cstr | Type definition | Used to represent... | +| Type name | Type definition | Used to represent... | |:----------------------|:---------------------------------------|:------------------------------------| -| `clist_xx` | `struct { clist_xx_node_t* last; }` | The clist type | -| `clist_xx_node_t` | `struct {` | | -| | ` struct clist_xx_node* next;` | | -| | ` clist_xx_value_t value;` | | -| | `}` | clist node | -| `clist_xx_value_t` | `Value` | The clist element type | -| `clist_xx_iter_t` | `struct {` | | -| | ` clist_xx_node_t* const* _last;` | | -| | ` clist_xx_value_t* val;` | | -| | ` int _state;` | | -| | `}` | clist iterator | - -## Constants - -| cstr constant name | Numerical values | +| `clist_z` | `struct { clist_z_node_t* last; }` | The clist type | +| `clist_z_node_t` | `struct {` | clist node | +| | ` struct clist_z_node* next;` | | +| | ` clist_z_value_t value;` | | +| | `}` | | +| `clist_z_value_t` | `Value` | The clist element type | +| `clist_z_input_t` | `clist_z_value_t` | clist input type | +| `clist_z_rawvalue_t` | `RawValue` | clist raw value type | +| `clist_z_iter_t` | `struct {` | clist iterator | +| | ` clist_z_node_t* const* _...;` | | +| | ` clist_z_value_t* val;` | | +| | ` int _...;` | | +| | `}` | | + + +## Constants and macros + +| Name | Value | |:---------------------------|:-----------------| | `clist_inits` | `{NULL}` | +| `clist_empty(list)` | `true` if empty | ## Header file @@ -55,50 +57,49 @@ All clist definitions and prototypes may be included in your C source file by in ### Construction -The interfaces to create a clist_xx object: +The interfaces to create a clist_z object: ```c -clist_xx clist_xx_init(void); -bool clist_xx_empty(clist_xx ls); -size_t clist_xx_size(clist_xx ls); - -void clist_xx_clear(clist_xx* self); -void clist_xx_del(clist_xx* self); +clist_z clist_z_init(void); -Value clist_xx_value_from_raw(RawValue rawValue); +void clist_z_clear(clist_z* self); +void clist_z_del(clist_z* self); -void clist_xx_push_n(clist_xx *self, const clist_xx_input_t in[], size_t size); -void clist_xx_push_back(clist_xx* self, Value value); -void clist_xx_emplace_back(clist_xx* self, RawValue rawValue); +bool clist_z_empty(clist_z list); +size_t clist_z_size(clist_z list); +Value clist_z_value_from_raw(RawValue val); -void clist_xx_push_front(clist_xx* self, Value value); -void clist_xx_emplace_front(clist_xx* self, RawValue rawValue); +void clist_z_push_n(clist_z *self, const clist_z_input_t in[], size_t size); +void clist_z_push_back(clist_z* self, Value value); +void clist_z_emplace_back(clist_z* self, RawValue val); -void clist_xx_pop_front(clist_xx* self); +void clist_z_push_front(clist_z* self, Value value); +void clist_z_emplace_front(clist_z* self, RawValue val); +void clist_z_pop_front(clist_z* self); -clist_xx_iter_t clist_xx_insert_after(clist_xx* self, clist_xx_iter_t pos, Value value); -clist_xx_iter_t clist_xx_emplace_after(clist_xx* self, clist_xx_iter_t pos, RawValue rawValue); +clist_z_iter_t clist_z_insert_after(clist_z* self, clist_z_iter_t pos, Value val); +clist_z_iter_t clist_z_emplace_after(clist_z* self, clist_z_iter_t pos, RawValue val); -clist_xx_iter_t clist_xx_erase_after(clist_xx* self, clist_xx_iter_t pos); -clist_xx_iter_t clist_xx_erase_range_after(clist_xx* self, clist_xx_iter_t pos, clist_xx_iter_t finish); +clist_z_iter_t clist_z_erase_after(clist_z* self, clist_z_iter_t pos); +clist_z_iter_t clist_z_erase_range_after(clist_z* self, clist_z_iter_t pos, clist_z_iter_t finish); -void clist_xx_splice_front(clist_xx* self, clist_xx* other); -void clist_xx_splice_back(clist_xx* self, clist_xx* other); -void clist_xx_splice_after(clist_xx* self, clist_xx_iter_t pos, clist_xx* other); +void clist_z_splice_front(clist_z* self, clist_z* other); +void clist_z_splice_back(clist_z* self, clist_z* other); +void clist_z_splice_after(clist_z* self, clist_z_iter_t pos, clist_z* other); -clist_xx_iter_t clist_xx_find(const clist_xx* self, RawValue val); -clist_xx_iter_t clist_xx_find_before(const clist_xx* self, clist_xx_iter_t first, clist_xx_iter_t finish, RawValue val); +clist_z_iter_t clist_z_find(const clist_z* self, RawValue val); +clist_z_iter_t clist_z_find_before(const clist_z* self, clist_z_iter_t first, clist_z_iter_t finish, RawValue val); -size_t clist_xx_remove(clist_xx* self, RawValue val); +size_t clist_z_remove(clist_z* self, RawValue val); -void clist_xx_sort(clist_xx* self); +void clist_z_sort(clist_z* self); -Value* clist_xx_front(clist_xx* self); -Value* clist_xx_back(clist_xx* self); +Value* clist_z_front(clist_z* self); +Value* clist_z_back(clist_z* self); -clist_xx_iter_t clist_xx_before_begin(const clist_xx* self); -clist_xx_iter_t clist_xx_begin(const clist_xx* self); -clist_xx_iter_t clist_xx_last(const clist_xx* self); -clist_xx_iter_t clist_xx_end(const clist_xx* self); -void clist_xx_next(clist_xx_iter_t* it); -clist_xx_value_t* clist_xx_itval(clist_xx_iter_t it); +clist_z_iter_t clist_z_before_begin(const clist_z* self); +clist_z_iter_t clist_z_begin(const clist_z* self); +clist_z_iter_t clist_z_last(const clist_z* self); +clist_z_iter_t clist_z_end(const clist_z* self); +void clist_z_next(clist_z_iter_t* it); +clist_z_value_t* clist_z_itval(clist_z_iter_t it); ``` diff --git a/docs/cstr_api.md b/docs/cstr_api.md index 30bff0c7..b6a516a6 100644 --- a/docs/cstr_api.md +++ b/docs/cstr_api.md @@ -4,17 +4,20 @@ This describes the API of string type **cstr_t**. ## Types -| cstr | Type definition | Used to represent... | +| Type name | Type definition | Used to represent... | |:------------------|:---------------------------------------|:-------------------------------------| | `cstr_t` | `struct { const char *str; }` | The string type | | `cstr_value_t` | `char` | The string element type | -| `cstr_iter_t` | `struct { char *val; }` | String iterator | +| `cstr_iter_t` | `struct { cstr_value_t *val; }` | cstr_t iterator | -## Constants +## Constants and macros -| cstr constant name | Numerical values | +| Name | Value / Returns | |:---------------------------|:-----------------| | `cstr_npos` | `-1ULL` | +| `cstr_size(str) | | +| `cstr_capacity(str) | | +| `cstr_empty(str) | | ## Header file diff --git a/docs/cvec_api.md b/docs/cvec_api.md new file mode 100644 index 00000000..44e09de5 --- /dev/null +++ b/docs/cvec_api.md @@ -0,0 +1,105 @@ +# Introduction + +UNDER CONSTRUCTION! + +This describes the API of vector type **cvec**. + +## Instantiation + +```c +#define using_cvec_str() + +#define using_cvec(z, Value, valueDestroy=c_default_del, + valueCompareRaw=c_default_compare, + RawValue=Value, + valueToRaw=c_default_to_raw, + valueFromRaw=c_default_from_raw) +``` +The macro `using_cvec()` can be instantiated with 2, 3, 4, or 7 arguments. Defaults are given above for args not specified. +Note that `z` can be any name, it's a tag and will affect the names of all cvec types and methods, +e.g. for `using_cvec(my, int);` `_z` should be replaced by `_my` in all the following documentation. +`using_cvec_str()` is a predefined macro for `cvec_using(str, cstr_t, ...)`. + +## Types + +| Type name | Type definition | Used to represent... | +|:---------------------|:------------------------------------- --|:------------------------------------| +| `cvec_z` | `struct { cvec_z_value_t* data; }` | The cvec type | +| `cvec_z_value_t` | `Value` | The cvec element type | +| `cvec_z_input_t` | `cvec_z_value_t` | cvec input type | +| `cvec_z_rawvalue_t` | `RawValue` | cvec raw value type | +| `cvec_z_iter_t` | `struct { cvec_z_value_t* val; }` | cvec iterator | + +## Constants and macros + +| Name | Value | +|:---------------------------|:-----------------| +| `cvec_inits` | `{NULL}` | +| `cvec_size(v) | | +| `cvec_capacity(v)` | | +| `cvec_empty(v)` | | + +## Header file + +All cvec definitions and prototypes may be included in your C source file by including a single header file. + +```c +#include "stc/cvec.h" +``` +## Methods + +### Construction + +The interface for cvec: +```c +cvec_z cvec_z_init(void); +cvec_z cvec_z_with_size(size_t size, Value null_val); +cvec_z cvec_z_with_capacity(size_t size); + +void cvec_z_clear(cvec_z* self); +void cvec_z_reserve(cvec_z* self, size_t cap); +void cvec_z_resize(cvec_z* self, size_t size, Value fill_val); +void cvec_z_swap(cvec_z* a, cvec_z* b); + +void cvec_z_del(cvec_z* self); + +bool cvec_z_empty(cvec_z vec); +size_t cvec_z_size(cvec_z vec); +size_t cvec_z_capacity(cvec_z vec); +Value cvec_z_value_from_raw(RawValue val); + +void cvec_z_push_n(cvec_z *self, const cvec_z_input_t in[], size_t size); +void cvec_z_push_back(cvec_z* self, Value value); +void cvec_z_emplace_back(cvec_z* self, RawValue val); +void cvec_z_pop_back(cvec_z* self); + +cvec_z_iter_t cvec_z_insert_range(cvec_z* self, cvec_z_iter_t pos, cvec_z_iter_t first, cvec_z_iter_t finish); +cvec_z_iter_t cvec_z_insert_range_p(cvec_z* self, cvec_z_value_t* pos, const cvec_z_value_t* pfirst, const cvec_z_value_t* pfinish); +cvec_z_iter_t cvec_z_insert_at(cvec_z* self, cvec_z_iter_t pos, Value value); +cvec_z_iter_t cvec_z_insert_at_idx(cvec_z* self, size_t idx, Value value); +cvec_z_iter_t cvec_z_emplace_at(cvec_z* self, cvec_z_iter_t pos, RawValue val); +cvec_z_iter_t cvec_z_emplace_at_idx(cvec_z* self, size_t idx, RawValue val); + +cvec_z_iter_t cvec_z_erase_range(cvec_z* self, cvec_z_iter_t first, cvec_z_iter_t finish); +cvec_z_iter_t cvec_z_erase_range_p(cvec_z* self, cvec_z_value_t* first, cvec_z_value_t* finish); +cvec_z_iter_t cvec_z_erase_at(cvec_z* self, cvec_z_iter_t pos); +cvec_z_iter_t cvec_z_erase_at_idx(cvec_z* self, size_t idx); +cvec_z_iter_t cvec_z_erase_range_idx(cvec_z* self, size_t ifirst, size_t ifinish); + +cvec_z_iter_t cvec_z_find(const cvec_z* self, RawValue val); +cvec_z_iter_t cvec_z_find_in_range(const cvec_z* self, cvec_z_iter_t first, cvec_z_iter_t finish, RawValue val); + +cvec_z_value_t* cvec_z_at(cvec_z* self, size_t i); + +void cvec_z_sort(cvec_z* self); +void cvec_z_sort_with(cvec_z* self, size_t ifirst, size_t ifinish, int(*cmp)(const cvec_z_value_t*, const cvec_z_value_t*)); + +Value* cvec_z_front(cvec_z* self); +Value* cvec_z_back(cvec_z* self); + +cvec_z_iter_t cvec_z_begin(const cvec_z* self); +cvec_z_iter_t cvec_z_last(const cvec_z* self); +cvec_z_iter_t cvec_z_end(const cvec_z* self); +void cvec_z_next(cvec_z_iter_t* it); +cvec_z_value_t* cvec_z_itval(cvec_z_iter_t it); +``` |
