summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorTyge Løvset <[email protected]>2021-01-20 20:32:26 +0100
committerTyge Løvset <[email protected]>2021-01-20 20:32:26 +0100
commit13c60c38e84e66585038d7509cb485ae33900db5 (patch)
tree4c203983295101621de3414025daa8a90f25584a
parent488df10580fdb2af78a65df12595ea3e5de9404c (diff)
parente78984b583e85273fdeb5461f2740ca895250314 (diff)
downloadSTC-modified-13c60c38e84e66585038d7509cb485ae33900db5.tar.gz
STC-modified-13c60c38e84e66585038d7509cb485ae33900db5.zip
Merge branch 'master' of https://github.com/tylo-work/C99Containers into master
-rw-r--r--docs/clist_api.md11
-rw-r--r--docs/cpque_api.md11
-rw-r--r--docs/cqueue_api.md12
-rw-r--r--docs/csmap_api.md14
4 files changed, 25 insertions, 23 deletions
diff --git a/docs/clist_api.md b/docs/clist_api.md
index 702f3344..a8dfbe64 100644
--- a/docs/clist_api.md
+++ b/docs/clist_api.md
@@ -85,6 +85,8 @@ clist_X_iter_t clist_X_begin(const clist_X* self);
clist_X_iter_t clist_X_end(const clist_X* self);
void clist_X_next(clist_X_iter_t* it);
clist_X_value_t* clist_X_itval(clist_X_iter_t it);
+
+ // non-std: return iterator n elements forward:
clist_X_iter_t clist_X_fwd(clist_X_iter it, size_t n);
clist_X_value_t clist_X_value_clone(clist_X_value_t val);
@@ -99,7 +101,7 @@ clist_X_value_t clist_X_value_clone(clist_X_value_t val);
| `clist_X_rawvalue_t` | `RawValue` | clist raw value type |
| `clist_X_iter_t` | `struct { clist_value_t *ref; ... }`| clist iterator |
-The `clist_X_splice_out(self, it1, it2)` can be combined with `clist_X_splice_after(self, it, other)` to mimic c++ `std::forward_list::splice_after(it, other, it1, it2)`. Note however that *it2* is included in elements to be spliced, unlike with *std::forward_list()*. Example: splice in `[2, 3]` from *L1* after `10` in *L2*:
+The `clist_X_splice_out(self, it1, it2)` can be combined with `clist_X_splice_after(self, it, other)` to mimic c++ `std::forward_list::splice_after(it, other, it1, it2)`. Note however that *it2* is included in elements to be spliced, unlike with *std::forward_list()*. E.g. splice in `[2, 3]` from *L1* after `10` in *L2*:
```c
c_init (clist_i, L1, {1, 2, 3, 4, 5});
c_init (clist_i, L2, {10, 20, 30, 40, 50});
@@ -117,18 +119,18 @@ clist_i_splice_after(&L2, clist_i_begin(&L2), &tmp);
```
## Example
+
+Interleave *push_front()* / *push_back()* then *sort()*:
```c
#include <stdio.h>
#include "stc/clist.h"
using_clist(d, double);
int main() {
- clist_d list = clist_inits;
- c_push_items(&list, clist_d, {
+ c_init (clist_d, list, {
10.0, 20.0, 30.0, 40.0, 50.0, 60.0, 70.0, 80.0, 90.0
});
- // Interleave push_front / push_back:
c_forrange (i, int, 1, 10) {
if (i & 1) clist_d_push_front(&list, (float) i);
else clist_d_push_back(&list, (float) i);
@@ -153,6 +155,7 @@ initial: 9 7 5 3 1 10 20 30 40 50 60 70 80 90 2 4 6 8
sorted: 1 2 3 4 5 6 7 8 9 10 20 30 40 50 60 70 80 90
```
### Example 2
+Show *erase_after()*, *erase_range_after()*:
```c
// erasing from clist
#include <stc/clist.h>
diff --git a/docs/cpque_api.md b/docs/cpque_api.md
index 276f1ce3..59203a63 100644
--- a/docs/cpque_api.md
+++ b/docs/cpque_api.md
@@ -1,19 +1,18 @@
# STC Container [cpque](../stc/cpque.h): Priority Queue
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 [std::priority_queue](https://en.cppreference.com/w/cpp/container/priority_queue) for a similar c++ class.
-
-Working with a priority_queue is similar to managing a heap in some random access container, with the benefit of not being able to accidentally invalidate the heap.
+See the c++ class [std::priority_queue](https://en.cppreference.com/w/cpp/container/priority_queue) for a functional reference.
## Declaration
```c
-#define using_cpque(X, ctype, heap_variant)
+#define using_cpque(X, ctype, direction)
```
The macro `using_cpque()` must be instantiated in the global scope.
**cpque** uses normally **cvec_X** or **cdeq_X** as underlying implementation, specified as `ctype`.
-The `heap_variant` must be given as `<` or `>`, specifying *max-heap* or *min-heap* for the priority queue to change the ordering, e.g. `>` would cause the smallest element to appear as the *cpque_X_top()*.
+The *direction* must be given as `<` or `>`, specifying *max-heap* or *min-heap* for the priority queue.
Note that the function `{ctype}_value_compare(x, y)` defined by the underlying vector type is used to
compare values (priorities). `X` is a type tag name and will affect the names of all cpque types and methods.
@@ -89,4 +88,4 @@ int main()
Output:
```
-873 -343 -231 -32 -4 3 5 6 18 23 31 54 68 87 99 105 107 125 128 147 150 155 167 178 181 188 213 216 272 284 287 302 306 311 313 326 329 331 344 348 363 367 374 385 396 399 401 407 412 477
-``` \ No newline at end of file
+```
diff --git a/docs/cqueue_api.md b/docs/cqueue_api.md
index 8e200b36..04454a0e 100644
--- a/docs/cqueue_api.md
+++ b/docs/cqueue_api.md
@@ -1,18 +1,18 @@
# STC Container [cqueue](../stc/cqueue.h): Queue
![Queue](pics/queue.jpg)
-This describes the API of the queue type **cqueue**.
-See [std::queue](https://en.cppreference.com/w/cpp/container/queue) for a similar c++ class.
+The **cqueue** is container adapter that gives the programmer the functionality of a queue - specifically, a FIFO (first-in, first-out) data structure. The class template acts as a wrapper to the underlying container - only a specific set of functions is provided. The queue pushes the elements on the back of the underlying container and pops them from the front.
-## Declaration
+See the c++ class [std::queue](https://en.cppreference.com/w/cpp/container/queue) for a functional reference.
+## Declaration
```c
#define 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`. `X` is a type tag name and
-will affect the names of all cqueue types and methods. E.g. declaring `using_cqueue(my, clist_my);`,
-`X` should be replaced by `my` in all of the following documentation.
+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
+`using_cqueue(my, clist_my)`, `X` should be replaced by `my` in all of the following documentation.
## Header file
diff --git a/docs/csmap_api.md b/docs/csmap_api.md
index db876ad6..3060811e 100644
--- a/docs/csmap_api.md
+++ b/docs/csmap_api.md
@@ -33,7 +33,7 @@ be replaced by `my` in all of the following documentation.
`using_csmap_strkey()` and `using_csmap_strval()` are special macros defined by
`using_csmap()`. The macro `using_csmap_str()` is a shorthand for
```c
-using_csmap(str, cstr_t, cstr_t, cstr_compare_raw, cstr_del, cstr_from, ...)
+using_csmap(str, cstr, cstr, cstr_compare_raw, cstr_del, cstr_from, ...)
```
## Header file
@@ -57,17 +57,17 @@ size_t csmap_X_size(csmap_X m);
void csmap_X_push_n(csmap_X* self, const csmap_X_rawvalue_t arr[], size_t size);
-csmap_X_result_t csmap_X_emplace(csmap_X* self, RawKey rkey, RawMapped rmapped); // no change if rkey in map
-csmap_X_result_t csmap_X_insert(csmap_X* self, csmap_X_rawvalue_t rval); // same
+csmap_X_result_t csmap_X_emplace(csmap_X* self, RawKey rkey, RawMapped rmapped); // no change if rkey in map
+csmap_X_result_t csmap_X_insert(csmap_X* self, csmap_X_rawvalue_t rval); // same, just different param
csmap_X_result_t csmap_X_insert_or_assign(csmap_X* self, RawKey rkey, RawMapped rmapped);
-csmap_X_result_t csmap_X_put(csmap_X* self, RawKey rkey, RawMapped rmapped); // same as insert_or_assign()
-csmap_X_result_t csmap_X_put_mapped(csmap_X* self, RawKey rkey, Mapped mapped); // same
-csmap_X_mapped_t* csmap_X_at(const csmap_X* self, RawKey rkey); // rkey must be in map.
+csmap_X_result_t csmap_X_put(csmap_X* self, RawKey rkey, RawMapped rmapped); // same as insert_or_assign()
+csmap_X_result_t csmap_X_put_mapped(csmap_X* self, RawKey rkey, Mapped mapped); // same, different param
+csmap_X_mapped_t* csmap_X_at(const csmap_X* self, RawKey rkey); // rkey must be in map.
size_t csmap_X_erase(csmap_X* self, RawKey rkey);
csmap_X_iter_t csmap_X_erase_at(csmap_X* self, csmap_X_iter_t pos);
-csmap_X_value_t* csmap_X_find(const csmap_X* self, RawKey rkey); // NULL if not found
+csmap_X_value_t* csmap_X_find(const csmap_X* self, RawKey rkey); // NULL if not found
csmap_X_value_t* csmap_X_find_it(const csmap_X* self, RawKey rkey, csmap_X_iter_t* out);
bool csmap_X_contains(const csmap_X* self, RawKey rkey);