summaryrefslogtreecommitdiffhomepage
path: root/docs/clist_api.md
diff options
context:
space:
mode:
authorTyge Løvset <[email protected]>2021-09-09 08:28:10 +0200
committerTyge Løvset <[email protected]>2021-09-09 08:28:10 +0200
commit52cb5b409447d5c5c3b799b64315dd48fdd445ef (patch)
treeef1a26d5d0265b84a37e36907a4674beb94448f0 /docs/clist_api.md
parent180cc60feebea8126e1c2012092782b53e164648 (diff)
downloadSTC-modified-52cb5b409447d5c5c3b799b64315dd48fdd445ef.tar.gz
STC-modified-52cb5b409447d5c5c3b799b64315dd48fdd445ef.zip
Updated examples in docs.
Diffstat (limited to 'docs/clist_api.md')
-rw-r--r--docs/clist_api.md36
1 files changed, 17 insertions, 19 deletions
diff --git a/docs/clist_api.md b/docs/clist_api.md
index b57662ca..9d50b7ec 100644
--- a/docs/clist_api.md
+++ b/docs/clist_api.md
@@ -22,22 +22,18 @@ See the c++ class [std::list](https://en.cppreference.com/w/cpp/container/list)
## Header file and declaration
```c
+#define i_tag
+#define i_val // required
+#define i_cmp // required if i_val is a struct
+#define i_valdel
+#define i_valfrom
+#define i_valto
+#define i_valraw
#include <stc/clist.h>
-
-using_clist(X, Value);
-using_clist(X, Value, valueCompare);
-using_clist(X, Value, valueCompare, valueDel, valueClone = c_no_clone);
-using_clist(X, Value, valueCompareRaw, valueDel, valueFromRaw, valueToRaw, RawValue);
-
-using_clist_str()
-```
-The macro `using_clist()` must be instantiated in the global scope. `X` is a type tag name and
-will affect the names of all clist types and methods. E.g. declaring `using_clist(i, int);`, `X` should
-be replaced by `i` in all of the following documentation. `using_clist_str()` is a shorthand for
-```c
-using_clist(str, cstr, c_rawstr_compare, cstr_del, cstr_from, cstr_str, const char*)
```
+`X` should be replaced by the value of i_tag in all of the following documentation.
+
## Methods
```c
@@ -100,11 +96,11 @@ clist_X_value_t clist_X_value_clone(clist_X_value_t val);
Interleave *push_front()* / *push_back()* then *sort()*:
```c
+#define i_tag d
+#define i_val double
#include <stc/clist.h>
#include <stdio.h>
-using_clist(d, double);
-
int main() {
c_var (clist_d, list, {
10.0, 20.0, 30.0, 40.0, 50.0, 60.0, 70.0, 80.0, 90.0
@@ -138,10 +134,11 @@ sorted: 1 2 3 4 5 6 7 8 9 10 20 30 40 50 60 70 80 90
Use of *erase_at()* and *erase_range()*:
```c
// erasing from clist
+#define i_tag i
+#define i_val int
#include <stc/clist.h>
-#include <stdio.h>
-using_clist(i, int);
+#include <stdio.h>
int main ()
{
@@ -171,10 +168,11 @@ mylist contains: 10 30
Splice `[30, 40]` from *L2* into *L1* before `3`:
```c
+#define i_tag i
+#define i_val int
#include <stc/clist.h>
-#include <stdio.h>
-using_clist(i, int);
+#include <stdio.h>
int main() {
c_var (clist_i, L1, {1, 2, 3, 4, 5});