summaryrefslogtreecommitdiffhomepage
path: root/docs
diff options
context:
space:
mode:
authorTyge Løvset <[email protected]>2021-03-19 13:08:05 +0100
committerTyge Løvset <[email protected]>2021-03-19 13:08:05 +0100
commit60786d8b27e9c622c43ddc8e77575c0853728014 (patch)
tree7fd6ab6963de42b11276f4ce57fc177ba4496848 /docs
parent0183aa814b21de2f623b56d79ac0f44a2bbb0366 (diff)
downloadSTC-modified-60786d8b27e9c622c43ddc8e77575c0853728014.tar.gz
STC-modified-60786d8b27e9c622c43ddc8e77575c0853728014.zip
Added clear() to cpque, cstack, cqueue, cbits, even though not in STL. Code/docs formatting.
Diffstat (limited to 'docs')
-rw-r--r--docs/carray_api.md3
-rw-r--r--docs/cbits_api.md78
-rw-r--r--docs/cmap_api.md8
-rw-r--r--docs/cpque_api.md7
-rw-r--r--docs/cqueue_api.md4
-rw-r--r--docs/cset_api.md8
-rw-r--r--docs/csmap_api.md3
-rw-r--r--docs/csset_api.md3
-rw-r--r--docs/cstack_api.md2
-rw-r--r--docs/cstr_api.md8
-rw-r--r--docs/cvec_api.md3
11 files changed, 66 insertions, 61 deletions
diff --git a/docs/carray_api.md b/docs/carray_api.md
index 0e0d8996..356b09ad 100644
--- a/docs/carray_api.md
+++ b/docs/carray_api.md
@@ -29,12 +29,11 @@ All carray definitions and prototypes are available by including a single header
carray1X carray1X_init(size_t xdim, Value val);
carray2X carray2X_init(size_t ydim, size_t xdim, Value val);
carray3X carray3X_init(size_t zdim, size_t ydim, size_t xdim, Value val);
-
carray1X carray1X_from(Value* array, size_t xdim);
carray2X carray2X_from(Value* array, size_t ydim, size_t xdim);
carray3X carray3X_from(Value* array, size_t zdim, size_t ydim, size_t xdim);
-
carrayNX carrayNX_clone(carrayNX arr);
+
void carrayNX_del(carrayNX* self);
size_t carrayNX_size(carrayNX arr);
diff --git a/docs/cbits_api.md b/docs/cbits_api.md
index 5443feae..373b7327 100644
--- a/docs/cbits_api.md
+++ b/docs/cbits_api.md
@@ -20,45 +20,45 @@ All cbits definitions and prototypes are available by including a single header
cbits cbits_init(void);
cbits cbits_with_size(size_t size, bool value);
cbits cbits_from_str(const char* str);
-
-cbits cbits_clone(cbits_t other);
-void cbits_resize(cbits_t* self, size_t size, bool value);
-
-cbits cbits_intersect(cbits_t s1, cbits_t s2);
-cbits cbits_union(cbits_t s1, cbits_t s2);
-cbits cbits_xor(cbits_t s1, cbits_t s2);
-cbits cbits_not(cbits_t s1);
-
-void cbits_del(cbits_t* self);
-
-cbits* cbits_assign(cbits_t* self, cbits_t other);
-cbits* cbits_take(cbits_t* self, cbits_t other);
-cbits cbits_move(cbits_t* self);
-
-size_t cbits_size(cbits_t set);
-size_t cbits_count(cbits_t set);
-bool cbits_is_disjoint(cbits_t set, cbits_t other);
-bool cbits_is_subset(cbits_t set, cbits_t other);
-bool cbits_is_superset(cbits_t set, cbits_t other);
-char* cbits_to_str(cbits_t set, char* str, size_t start, intptr_t stop);
-
-bool cbits_test(cbits_t set, size_t i);
-bool cbits_at(cbits_t set, size_t i); // same as cbits_test()
-
-void cbits_set(cbits_t *self, size_t i);
-void cbits_reset(cbits_t *self, size_t i);
-void cbits_set_value(cbits_t *self, size_t i, bool value);
-void cbits_flip(cbits_t *self, size_t i);
-void cbits_set_all(cbits_t *self, bool value);
-void cbits_set_all64(cbits_t *self, uint64_t pattern);
-void cbits_flip_all(cbits_t *self);
-
-void cbits_intersect_with(cbits_t *self, cbits_t other);
-void cbits_union_with(cbits_t *self, cbits_t other);
-void cbits_xor_with(cbits_t *self, cbits_t other);
-
-cbits_iter_t cbits_begin(cbits_t* self);
-cbits_iter_t cbits_end(cbits_t* self);
+cbits cbits_clone(cbits other);
+
+void cbits_clear(cbits* self);
+void cbits_resize(cbits* self, size_t size, bool value);
+void cbits_del(cbits* self);
+
+cbits cbits_intersect(cbits s1, cbits s2);
+cbits cbits_union(cbits s1, cbits s2);
+cbits cbits_xor(cbits s1, cbits s2);
+cbits cbits_not(cbits s1);
+
+cbits* cbits_assign(cbits* self, cbits other);
+cbits* cbits_take(cbits* self, cbits other);
+cbits cbits_move(cbits* self);
+
+size_t cbits_size(cbits set);
+size_t cbits_count(cbits set);
+bool cbits_is_disjoint(cbits set, cbits other);
+bool cbits_is_subset(cbits set, cbits other);
+bool cbits_is_superset(cbits set, cbits other);
+char* cbits_to_str(cbits set, char* str, size_t start, intptr_t stop);
+
+bool cbits_test(cbits set, size_t i);
+bool cbits_at(cbits set, size_t i); // same as cbits_test()
+
+void cbits_set(cbits *self, size_t i);
+void cbits_reset(cbits *self, size_t i);
+void cbits_set_value(cbits *self, size_t i, bool value);
+void cbits_flip(cbits *self, size_t i);
+void cbits_set_all(cbits *self, bool value);
+void cbits_set_all64(cbits *self, uint64_t pattern);
+void cbits_flip_all(cbits *self);
+
+void cbits_intersect_with(cbits *self, cbits other);
+void cbits_union_with(cbits *self, cbits other);
+void cbits_xor_with(cbits *self, cbits other);
+
+cbits_iter_t cbits_begin(cbits* self);
+cbits_iter_t cbits_end(cbits* self);
void cbits_next(cbits_iter_t* it);
bool cbits_itval(cbits_iter_t it);
```
diff --git a/docs/cmap_api.md b/docs/cmap_api.md
index a1db1a25..952ae772 100644
--- a/docs/cmap_api.md
+++ b/docs/cmap_api.md
@@ -45,10 +45,10 @@ All cmap definitions and prototypes are available by including a single header f
```c
cmap_X cmap_X_init(void);
cmap_X cmap_X_with_capacity(size_t cap);
-void cmap_X_set_load_factors(cmap_X* self, float min_load, float max_load);
-
cmap_X cmap_X_clone(cmap_x map);
+
void cmap_X_clear(cmap_X* self);
+void cmap_X_set_load_factors(cmap_X* self, float min_load, float max_load);
void cmap_X_reserve(cmap_X* self, size_t size);
void cmap_X_swap(cmap_X* a, cmap_X* b);
void cmap_X_del(cmap_X* self); // destructor
@@ -188,7 +188,7 @@ Output:
```
### Example 3
-Demonstrate cmap with plain-old-data key type Vec3i and int as mapped type: cmap<Vec3i, int>.
+Demonstrate cmap with plain-old-data key type Vec3i and int as mapped type: cmap<Vec3i, int>.
```c
#include "stc/cmap.h"
#include <stdio.h>
@@ -303,7 +303,7 @@ int main()
{ {"Harald", "Iceland"}, 12 },
});
cmap_vk_emplace_or_assign(&vikings, (VikingRaw){"Bjorn", "Sweden"}, 10);
-
+
VikingRaw lookup = {"Einar", "Norway"};
cmap_vk_value_t *e = cmap_vk_find(&vikings, lookup).ref;
diff --git a/docs/cpque_api.md b/docs/cpque_api.md
index 7d40b08e..f6e5d26b 100644
--- a/docs/cpque_api.md
+++ b/docs/cpque_api.md
@@ -3,7 +3,7 @@
A priority queue is a container adaptor that provides constant time lookup of the largest (by default) element, at the expense of logarithmic insertion and extraction.
A user-provided argument `<`or `>` must be supplied to set the ordering, e.g. using `>` would cause the smallest element to appear as the top().
-See the c++ class [std::priority_queue](https://en.cppreference.com/w/cpp/container/priority_queue) for a functional reference.
+See the c++ class [std::priority_queue](https://en.cppreference.com/w/cpp/container/priority_queue) for a functional reference.
## Declaration
@@ -31,13 +31,14 @@ All cpque definitions and prototypes are available by including a single header
```c
cpque_X cpque_X_init(void);
cpque_X cpque_X_clone(cpque_X pq);
+
+void cpque_X_clear(cpque_X* self);
void cpque_X_make_heap(cpque_X* self);
void cpque_X_del(cpque_X* self); // destructor
size_t cpque_X_size(cpque_X pq);
bool cpque_X_empty(cpque_X pq);
-const
-cpque_X_value_t* cpque_X_top(const cpque_X* self);
+const cpque_X_value_t* cpque_X_top(const cpque_X* self);
void cpque_X_push(cpque_X* self, cpque_X_value_t value);
void cpque_X_emplace(cpque_X* self, cpque_X_rawvalue_t raw);
diff --git a/docs/cqueue_api.md b/docs/cqueue_api.md
index 30b6d4d0..d1f889f0 100644
--- a/docs/cqueue_api.md
+++ b/docs/cqueue_api.md
@@ -11,7 +11,7 @@ using_cqueue(X, ctype)
```
The macro `using_cqueue()` must be instantiated in the global scope. **cqueue** uses normally
a **cdeq_X** or **clist_X** type as underlying implementation, given as `ctype`. See example below for usage.
-`X` is a type tag name and will affect the names of all cqueue types and methods. E.g. declaring
+`X` is a type tag name and will affect the names of all cqueue types and methods. E.g. declaring
`using_cqueue(i, clist_i)`, `X` should be replaced by `i` in all of the following documentation.
## Header file
@@ -27,6 +27,8 @@ All cqueue definitions and prototypes are available by including a single header
```c
cqueue_X cqueue_X_init(void);
cqueue_X cqueue_X_clone(cqueue_X q);
+
+void cqueue_X_clear(cqueue_X* self);
void cqueue_X_del(cqueue_X* self); // destructor
size_t cqueue_X_size(cqueue_X q);
diff --git a/docs/cset_api.md b/docs/cset_api.md
index ebca71ae..31e2a33a 100644
--- a/docs/cset_api.md
+++ b/docs/cset_api.md
@@ -1,7 +1,7 @@
# STC [cset](../stc/cmap.h): Unordered Set
![Set](pics/set.jpg)
-A **cset** is an associative container that contains a set of unique objects of type Key. Search, insertion, and removal have average constant-time complexity. See the c++ class
+A **cset** is an associative container that contains a set of unique objects of type Key. Search, insertion, and removal have average constant-time complexity. See the c++ class
[std::unordered_set](https://en.cppreference.com/w/cpp/container/unordered_set) for a functional description.
## Declaration
@@ -31,10 +31,10 @@ All cset definitions and prototypes are available by including a single header f
```c
cset_X cset_X_init(void);
cset_X cset_X_with_capacity(size_t cap);
-void cset_X_set_load_factors(cset_X* self, float min_load, float max_load);
-
cset_X cset_X_clone(cset_x set);
+
void cset_X_clear(cset_X* self);
+void cset_X_set_load_factors(cset_X* self, float min_load, float max_load);
void cset_X_reserve(cset_X* self, size_t size);
void cset_X_swap(cset_X* a, cset_X* b);
void cset_X_del(cset_X* self); // destructor
@@ -103,7 +103,7 @@ int main ()
c_del(cset_str, &first, &second, &third, &fourth);
printf("fifth contains:\n\n");
- c_foreach (i, cset_str, fifth)
+ c_foreach (i, cset_str, fifth)
printf("%s\n", i.ref->str);
cset_str_del(&fifth);
diff --git a/docs/csmap_api.md b/docs/csmap_api.md
index d6eb0ddc..bd877ca1 100644
--- a/docs/csmap_api.md
+++ b/docs/csmap_api.md
@@ -47,6 +47,7 @@ All csmap definitions and prototypes are available by including a single header
```c
csmap_X csmap_X_init(void);
csmap_X csmap_X_clone(csmap_x map);
+
void csmap_X_clear(csmap_X* self);
void csmap_X_swap(csmap_X* a, csmap_X* b);
void csmap_X_del(csmap_X* self); // destructor
@@ -172,7 +173,7 @@ Output:
```
### Example 3
-Demonstrate csmap with plain-old-data key type Vec3i and int as mapped type: csmap<Vec3i, int>.
+Demonstrate csmap with plain-old-data key type Vec3i and int as mapped type: csmap<Vec3i, int>.
```c
#include "stc/csmap.h"
#include <stdio.h>
diff --git a/docs/csset_api.md b/docs/csset_api.md
index 21529f8c..3760a4c0 100644
--- a/docs/csset_api.md
+++ b/docs/csset_api.md
@@ -32,6 +32,7 @@ All csset definitions and prototypes are available by including a single header
```c
csset_X csset_X_init(void);
csset_X csset_X_clone(csset_x set);
+
void csset_X_clear(csset_X* self);
void csset_X_swap(csset_X* a, csset_X* b);
void csset_X_del(csset_X* self); // destructor
@@ -99,7 +100,7 @@ int main ()
c_del(csset_str, &first, &second, &third, &fourth);
printf("fifth contains:\n\n");
- c_foreach (i, csset_str, fifth)
+ c_foreach (i, csset_str, fifth)
printf("%s\n", i.ref->str);
csset_str_del(&fifth);
diff --git a/docs/cstack_api.md b/docs/cstack_api.md
index 60e9ce53..83e95199 100644
--- a/docs/cstack_api.md
+++ b/docs/cstack_api.md
@@ -28,6 +28,8 @@ All cstack definitions and prototypes are available by including a single header
```c
cstack_X cstack_X_init(void);
cstack_X cstack_X_clone(cstack_X st);
+
+void cstack_X_clear(cstack_X* self);
void cstack_X_del(cstack_X* self); // destructor
size_t cstack_X_size(cstack_X st);
diff --git a/docs/cstr_api.md b/docs/cstr_api.md
index e528aafb..c248e482 100644
--- a/docs/cstr_api.md
+++ b/docs/cstr_api.md
@@ -21,8 +21,8 @@ cstr cstr_with_size(size_t len, char fill); // repeat
cstr cstr_from(const char* str);
cstr cstr_from_n(const char* str, size_t n);
cstr cstr_from_fmt(const char* fmt, ...); // printf() formatting
-
cstr cstr_clone(cstr s);
+
cstr* cstr_take(cstr* self, cstr s); // take the constructed or moved string
cstr cstr_move(cstr* self); // move string to caller, leave empty string
void cstr_del(cstr *self); // destructor
@@ -37,12 +37,12 @@ void cstr_resize(cstr* self, size_t len, char fill);
void cstr_clear(cstr* self);
cstr* cstr_assign(cstr* self, const char* str);
-cstr* cstr_assign_s(cstr* self, cstr s);
+cstr* cstr_assign_s(cstr* self, cstr s); // cstr_take(self, cstr_clone(s))
cstr* cstr_assign_n(cstr* self, const char* str, size_t n);
cstr* cstr_append(cstr* self, const char* str);
cstr* cstr_append_s(cstr* self, cstr s);
-cstr* cstr_append_n(cstr* self, const char* str, size_t n); // appends len characters
+cstr* cstr_append_n(cstr* self, const char* str, size_t n); // appends n characters
void cstr_insert(cstr* self, size_t pos, const char* str);
void cstr_insert_s(cstr* self, size_t pos, cstr s);
@@ -88,7 +88,7 @@ const char* cstr_c_str(const cstr* x);
int cstr_compare_raw(const char** x, const char** y);
bool cstr_equals_raw(const char** x, const char** y);
uint64_t cstr_hash_raw(const char* const* x, size_t ignored);
-int c_strncasecmp(const char* s1, const char* s2, size_t n);
+int c_strncasecmp(const char* str1, const char* str2, size_t n);
char* c_strnstr(const char* str, const char* needle, size_t n);
char* c_strncasestr(const char* str, const char* needle, size_t n);
uint64_t c_strhash(const char* str);
diff --git a/docs/cvec_api.md b/docs/cvec_api.md
index ac9a0397..aa27f938 100644
--- a/docs/cvec_api.md
+++ b/docs/cvec_api.md
@@ -48,7 +48,6 @@ void cvec_X_shrink_to_fit(cvec_X* self);
void cvec_X_reserve(cvec_X* self, size_t cap);
void cvec_X_resize(cvec_X* self, size_t size, Value fill);
void cvec_X_swap(cvec_X* a, cvec_X* b);
-
void cvec_X_del(cvec_X* self); // destructor
bool cvec_X_empty(cvec_X vec);
@@ -205,7 +204,7 @@ int main(void) {
cvec_u vec = cvec_u_init();
cvec_u_push_back(&vec, (User) {cstr_from("admin"), 0});
cvec_u_push_back(&vec, (User) {cstr_from("joe"), 1});
-
+
cvec_u vec2 = cvec_u_clone(vec);
c_foreach (i, cvec_u, vec2)
printf("%s: %d\n", i.ref->name.str, i.ref->id);