diff options
| author | Tyge Løvset <[email protected]> | 2020-12-10 23:07:03 +0100 |
|---|---|---|
| committer | Tyge Løvset <[email protected]> | 2020-12-10 23:07:03 +0100 |
| commit | 95f9cb433cb65749af3f489563dc18a2a9fa00cc (patch) | |
| tree | 4ed5c5831f1495bb1e45f7b85947b983f0d98161 /docs | |
| parent | 8e1e7c94f5195d5e15260c4a05ab479fec2222a2 (diff) | |
| download | STC-modified-95f9cb433cb65749af3f489563dc18a2a9fa00cc.tar.gz STC-modified-95f9cb433cb65749af3f489563dc18a2a9fa00cc.zip | |
Reverted cuptr to cptr. Added some typedefs in docs in cmap and cset.
Diffstat (limited to 'docs')
| -rw-r--r-- | docs/clist_api.md | 4 | ||||
| -rw-r--r-- | docs/cmap_api.md | 22 | ||||
| -rw-r--r-- | docs/cptr_api.md | 38 | ||||
| -rw-r--r-- | docs/cset_api.md | 18 |
4 files changed, 40 insertions, 42 deletions
diff --git a/docs/clist_api.md b/docs/clist_api.md index ecae5ba2..26342fef 100644 --- a/docs/clist_api.md +++ b/docs/clist_api.md @@ -26,12 +26,10 @@ using_clist(str, cstr_t, cstr_del, cstr_compare_raw, const char*, cstr_to_raw, c | Type name | Type definition | Used to represent... | |:----------------------|:------------------------------------|:--------------------------| | `clist_X` | `struct { clist_X_node_t* last; }` | The clist type | -| `clist_X_node_t` | `struct { ... }` | clist node | | `clist_X_value_t` | `Value` | The clist element type | | `clist_X_input_t` | `clist_X_value_t` | clist input type | | `clist_X_rawvalue_t` | `RawValue` | clist raw value type | -| `clist_X_iter_t` | `struct { ... }` | clist iterator | - +| `clist_X_iter_t` | `struct { clist_value_t *val; ... }`| clist iterator | ## Constants and macros diff --git a/docs/cmap_api.md b/docs/cmap_api.md index f3046648..9cd40555 100644 --- a/docs/cmap_api.md +++ b/docs/cmap_api.md @@ -41,17 +41,17 @@ using_cmap(str, cstr_t, cstr_t, cstr_del, cstr_equals_raw, cstr_hash_raw, ## Types -| Type name | Type definition | Used to represent... | -|:---------------------|:-----------------------|:------------------------------| -| `cmap_X` | `struct { ... }` | The cmap type | -| `cmap_X_rawkey_t` | `RawKey` | The raw key type | -| `cmap_X_rawval_t` | `RawMapped` | The raw mapped type | -| `cmap_X_key_t` | `Key` | The key type | -| `cmap_X_mapped_t` | `Mapped` | The mapped type | -| `cmap_X_value_t` | `struct { ... }` | The value type | -| `cmap_X_input_t` | `struct { ... }` | RawKey + RawVal type | -| `cmap_X_result_t` | `struct { ... }` | Result of insert/put/emplace | -| `cmap_X_iter_t` | `struct { ... }` | Iterator type | +| Type name | Type definition | Used to represent... | +|:---------------------|:------------------------------------------------|:------------------------------| +| `cmap_X` | `struct { ... }` | The cmap type | +| `cmap_X_rawkey_t` | `RawKey` | The raw key type | +| `cmap_X_rawval_t` | `RawMapped` | The raw mapped type | +| `cmap_X_key_t` | `Key` | The key type | +| `cmap_X_mapped_t` | `Mapped` | The mapped type | +| `cmap_X_value_t` | `struct { Key first; Mapped second; }` | The value type | +| `cmap_X_input_t` | `struct { RawKey first; RawMapped second; }` | RawKey + RawVal type | +| `cmap_X_result_t` | `struct { cmap_X_value_t first; bool second; }` | Result of insert/put/emplace | +| `cmap_X_iter_t` | `struct { cmap_X_value_t *val; ... }` | Iterator type | ## Constants and macros diff --git a/docs/cptr_api.md b/docs/cptr_api.md index 6e86ce11..8caede2f 100644 --- a/docs/cptr_api.md +++ b/docs/cptr_api.md @@ -1,28 +1,28 @@ # Module cptr: Smart Pointers -This describes the API of the type **cuptr** and the shared pointer type **csptr**. Type **cuptr** is meant to be used like a c++ std::unique_ptr, while **csptr** is similar to c++ std::shared_ptr. +This describes the API of the pointer type **cptr** and the shared pointer type **csptr**. Type **cptr** is meant to be used like a c++ *std::unique_ptr*, while **csptr** is similar to c++ *std::shared_ptr*. -**cuptr** and **cuptr** objects can be used as items of containers. The pointed-to elements are automatically deleted when the container is deleted. **csptr** elements are only deleted if there are no other references to the element. **csptr** has thread-safe atomic use count, enabled by the *csptr_X_share(sp)* and *csptr_X_del(&sp)* methods. +**cptr** and **cptr** objects can be used as items of containers. The pointed-to elements are automatically deleted when the container is deleted. **csptr** elements are only deleted if there are no other references to the element. **csptr** has thread-safe atomic use count, enabled by the *csptr_X_share(sp)* and *csptr_X_del(&sp)* methods. ## Declaration ```c -#define using_cuptr(X, Value, valueDestroy=c_default_del, - valueCompare=c_default_compare) +#define using_cptr(X, Value, valueDestroy=c_default_del, + valueCompare=c_default_compare) #define using_csptr(X, Value, valueDestroy=c_default_del, valueCompare=c_default_compare) ``` -The macro `using_cuptr()` must be instantiated in the global scope. `X` is a type tag name and will -affect the names of all cuptr types and methods. E.g. declaring `using_cuptr(my, cvec_my);`, +The macro `using_cptr()` must be instantiated in the global scope. `X` is a type tag name and will +affect the names of all cptr types and methods. E.g. declaring `using_cptr(my, cvec_my);`, `X` should be replaced by `my` in all of the following documentation. Types -| Type name | Type definition | Used to represent... | -|:--------------------|:-----------------------|:-------------------------| -| `cuptr_X` | `cuptr_X_value_t *` | The cuptr type | -| `cuptr_X_value_t` | `Value` | The cuptr element type | +| Type name | Type definition | Used to represent... | +|:-------------------|:----------------------|:------------------------| +| `cptr_X` | `cptr_X_value_t *` | The cptr type | +| `cptr_X_value_t` | `Value` | The cptr element type | | Type name | Type definition | Used to represent... | @@ -43,10 +43,10 @@ All cptr definitions and prototypes may be included in your C source file by inc ## Methods ```c -cuptr_X cuptr_X_init(void); -void cuptr_X_reset(cuptr_X* self, cuptr_X_value_t* ptr); -void cuptr_X_del(cuptr_X* self); -int cuptr_X_compare(cuptr_X* x, cuptr_X* y); +cptr_X cptr_X_init(void); +void cptr_X_reset(cptr_X* self, cptr_X_value_t* ptr); +void cptr_X_del(cptr_X* self); +int cptr_X_compare(cptr_X* x, cptr_X* y); ``` ```c csptr_X csptr_X_from(csptr_X_value_t* ptr); @@ -59,7 +59,7 @@ int csptr_X_compare(csptr_X* x, csptr_X* y); ## Example -This shows 2 cvecs with two different pointer to Person. uvec: cuptr<Person>, and svec: csptr<Person>. +This shows 2 cvecs with two different pointer to Person. uvec: cptr<Person>, and svec: csptr<Person>. ```c #include <stc/cptr.h> #include <stc/cstr.h> @@ -82,8 +82,8 @@ int Person_compare(const Person* p, const Person* q) { using_cvec(pe, Person, Person_del, Person_compare); // unused -using_cuptr(pu, Person, Person_del, Person_compare); -using_cvec(pu, Person*, cuptr_pu_del, cuptr_pu_compare); +using_cptr(pu, Person, Person_del, Person_compare); +using_cvec(pu, Person*, cptr_pu_del, cptr_pu_compare); using_csptr(ps, Person, Person_del, Person_compare); using_cvec(ps, csptr_ps, csptr_ps_del, csptr_ps_compare); @@ -97,7 +97,7 @@ const char* names[] = { int main() { cvec_pu uvec = cvec_inits; for (int i=0;i<6; i+=2) cvec_pu_push_back(&uvec, Person_make(c_new(Person), names[i], names[i+1])); - puts("cvec of cuptr<Person>:"); + puts("cvec of cptr<Person>:"); cvec_pu_sort(&uvec); c_foreach (i, cvec_pu, uvec) printf(" %s %s\n", (*i.val)->name.str, (*i.val)->last.str); @@ -121,7 +121,7 @@ int main() { ``` Output: ``` -cvec of cuptr<Person>: +cvec of cptr<Person>: Annie Aniston Jane Jacobs Joe Jordan diff --git a/docs/cset_api.md b/docs/cset_api.md index bb5dfaff..1a4bf9f8 100644 --- a/docs/cset_api.md +++ b/docs/cset_api.md @@ -24,15 +24,15 @@ be replaced by `my` in all of the following documentation. ## Types
-| Type name | Type definition | Used to represent... |
-|:---------------------|:-------------------------|:-------------------------|
-| `cset_X` | `struct { ... }` | The cset type |
-| `cset_X_rawkey_t` | `RawKey` | The raw key type |
-| `cset_X_key_t` | `Key` | The key type |
-| `cset_X_value_t` | `Key` | The value type |
-| `cset_X_result_t` | `struct { ... }` | Result of insert/emplace |
-| `cset_X_input_t` | `cset_X_rawkey_t` | The input type (rawkey) |
-| `cset_X_iter_t` | `struct { ... }` | Iterator type |
+| Type name | Type definition | Used to represent... |
+|:---------------------|:--------------------------------------|:-------------------------|
+| `cset_X` | `struct { ... }` | The cset type |
+| `cset_X_rawkey_t` | `RawKey` | The raw key type |
+| `cset_X_key_t` | `Key` | The key type |
+| `cset_X_value_t` | `Key` | The value type |
+| `cset_X_result_t` | `struct { Key first; bool second; }` | Result of insert/emplace |
+| `cset_X_input_t` | `cset_X_rawkey_t` | The input type (rawkey) |
+| `cset_X_iter_t` | `struct { cset_X_value_t *val; ... }` | Iterator type |
## Constants and macros
|
