summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authortylov <[email protected]>2023-07-18 01:36:51 +0200
committertylov <[email protected]>2023-07-18 01:36:51 +0200
commit313c1d7bb9b92e75801429c1f7f132589860292e (patch)
treeb68451b728c7e06275388348e8ccb90d5a1c5a7f
parent23eeedb3fc298602732f394adba6a43c876ca7d8 (diff)
downloadSTC-modified-313c1d7bb9b92e75801429c1f7f132589860292e.tar.gz
STC-modified-313c1d7bb9b92e75801429c1f7f132589860292e.zip
Renamed i_native_cmp => i_cmp_native
Added c_all_of(), c_any_of(), c_none_of() to algo/filter.h
-rw-r--r--README.md4
-rw-r--r--docs/carc_api.md24
-rw-r--r--docs/cbox_api.md29
-rw-r--r--docs/cdeq_api.md23
-rw-r--r--docs/clist_api.md21
-rw-r--r--docs/cmap_api.md39
-rw-r--r--docs/cpque_api.md18
-rw-r--r--docs/cqueue_api.md16
-rw-r--r--docs/cset_api.md26
-rw-r--r--docs/csmap_api.md36
-rw-r--r--docs/csset_api.md18
-rw-r--r--docs/cstack_api.md16
-rw-r--r--docs/cvec_api.md23
-rw-r--r--include/stc/algo/coroutine.h13
-rw-r--r--include/stc/algo/filter.h16
-rw-r--r--include/stc/priv/template.h8
-rw-r--r--include/stc/priv/template2.h2
-rw-r--r--misc/benchmarks/various/csort_bench.c2
-rw-r--r--misc/examples/arc_demo.c2
-rw-r--r--misc/examples/arcvec_erase.c2
-rw-r--r--misc/examples/demos.c2
-rw-r--r--misc/examples/intrusive.c2
-rw-r--r--misc/examples/list.c2
-rw-r--r--misc/examples/lower_bound.c2
-rw-r--r--misc/examples/new_list.c2
-rw-r--r--misc/examples/new_sptr.c2
26 files changed, 191 insertions, 159 deletions
diff --git a/README.md b/README.md
index b7e06790..6bbe50ee 100644
--- a/README.md
+++ b/README.md
@@ -252,7 +252,7 @@ struct Point { float x, y; };
#include <stc/cvec.h> // cvec_pnt: vector of struct Point
#define i_key int
-#define i_native_cmp // enable sort/search. Use native `<` and `==` operators
+#define i_cmp_native // enable sort/search. Use native `<` and `==` operators
#include <stc/clist.h> // clist_int: singly linked list
#define i_key int
@@ -619,7 +619,7 @@ STC is generally very memory efficient. Memory usage for the different container
- cspan: Support for column-major (fortran order) multidim spans and transposed views.
- Removed default comparison for clist, cvec and cdeq (as with cstack and cqueue).
- Using i_key_str, i_keyclass, i_keyboxed still expects comparisons defined.
- - Define i_native_cmp to enable built-in i_key types comparisons (<, ==).
+ - Define i_cmp_native to enable built-in i_key types comparisons (<, ==).
- cstr and csview are now shared linked by default. Static linking by defining i_static.
- New cdeq and cqueue implementation(s), using circular buffer.
- Renamed i_extern => i_import.
diff --git a/docs/carc_api.md b/docs/carc_api.md
index 8b7b67a1..fb79019a 100644
--- a/docs/carc_api.md
+++ b/docs/carc_api.md
@@ -20,15 +20,21 @@ See similar c++ class [std::shared_ptr](https://en.cppreference.com/w/cpp/memory
## Header file and declaration
```c
-#define i_type // full typename of the carc
-#define i_key // element type: REQUIRED
-
-#define i_keyraw // convertion "raw" type - defaults to i_key
-#define i_keyto // convertion func i_key* => i_keyraw: REQUIRED IF i_keyraw defined.
-#define i_keyfrom // convertion func i_keyraw => i_key
-
-#define i_opt c_no_atomic // Non-atomic reference counting, like Rust Rc.
-#define i_tag // alternative typename: carc_{i_tag}. i_tag defaults to i_key
+#define i_key <t> // element type: REQUIRED. Note: i_val* may be specified instead of i_key*.
+#define i_type <t> // carc container type name
+#define i_cmp <f> // three-way compareison. REQUIRED IF i_key is a non-integral type
+ // Note that containers of carcs will "inherit" i_cmp
+ // when using carc in containers with i_valboxed MyArc - ie. the i_type.
+#define i_cmp_native // define instead of i_cmp only when i_key is an integral/native-type.
+#define i_keydrop <f> // destroy element func - defaults to empty destruct
+#define i_keyclone <f> // REQUIRED if i_keydrop is defined, unless 'i_opt c_no_clone' is defined.
+
+#define i_keyraw <t> // convertion type (lookup): default to {i_key}
+#define i_keyto <f> // convertion func i_key* => i_keyraw: REQUIRED IF i_keyraw defined.
+#define i_keyfrom <f> // from-raw func.
+
+#define i_opt c_no_atomic // Non-atomic reference counting, like Rust Rc.
+#define i_tag <s> // alternative typename: carc_{i_tag}. i_tag defaults to i_key
#include <stc/carc.h>
```
`X` should be replaced by the value of `i_tag` in all of the following documentation.
diff --git a/docs/cbox_api.md b/docs/cbox_api.md
index b6c76d2f..0e6fca64 100644
--- a/docs/cbox_api.md
+++ b/docs/cbox_api.md
@@ -14,18 +14,23 @@ See similar c++ class [std::unique_ptr](https://en.cppreference.com/w/cpp/memory
## Header file and declaration
```c
-#define i_type // full typename of the cbox
-#define i_key // element type: REQUIRED
-#define i_cmp // three-way compare two i_key* : REQUIRED IF i_key is a non-integral type
-#define i_keydrop // destroy element func - defaults to empty destruct
-#define i_keyclone // REQUIRED if i_keydrop is defined, unless 'i_opt c_no_clone' is defined.
-
-#define i_keyraw // convertion type (lookup): default to {i_key}
-#define i_keyto // convertion func i_key* => i_keyraw: REQUIRED IF i_keyraw defined.
-#define i_keyfrom // from-raw func.
-
-#define i_keyclass // alt. to i_key: REQUIRES that {i_key}_clone, {i_key}_drop, {i_keyraw}_cmp exist.
-#define i_tag // alternative typename: cbox_{i_tag}. i_tag defaults to i_key
+#define i_key <t> // element type: REQUIRED. Note: i_val* may be specified instead of i_key*.
+#define i_type <t> // cbox container type name
+#define i_cmp <f> // three-way compareison. REQUIRED IF i_key is a non-integral type
+ // Note that containers of carcs will "inherit" i_cmp
+ // when using carc in containers with i_valboxed MyArc - ie. the i_type.
+#define i_cmp_native // define instead of i_cmp only when i_key is an integral/native-type.
+#define i_keydrop <f> // destroy element func - defaults to empty destruct
+#define i_keyclone <f> // REQUIRED if i_keydrop is defined, unless 'i_opt c_no_clone' is defined.
+
+#define i_keyraw <t> // convertion type (lookup): default to {i_key}
+#define i_keyto <f> // convertion func i_key* => i_keyraw: REQUIRED IF i_keyraw defined.
+#define i_keyfrom <f> // from-raw func.
+
+#define i_tag <s> // alternative typename: cbox_{i_tag}. i_tag defaults to i_key
+#define i_keyclass <t> // Use instead of i_key when functions {i_key}_clone,
+ // {i_key}_drop and {i_keyraw}_cmp exist.
+#define i_keyboxed <t> // Use instead of i_key when key is a carc- or a cbox-type.
#include <stc/cbox.h>
```
`X` should be replaced by the value of `i_tag` in all of the following documentation.
diff --git a/docs/cdeq_api.md b/docs/cdeq_api.md
index c6de6cd6..38de7f66 100644
--- a/docs/cdeq_api.md
+++ b/docs/cdeq_api.md
@@ -10,17 +10,18 @@ See the c++ class [std::deque](https://en.cppreference.com/w/cpp/container/deque
## Header file and declaration
```c
-#define i_type // full typename of the container
-#define i_key // value: REQUIRED
-#define i_cmp // three-way compare two i_keyraw* : REQUIRED IF i_keyraw is a non-integral type
-#define i_keydrop // destroy value func - defaults to empty destruct
-#define i_keyclone // REQUIRED IF i_keydrop defined
-
-#define i_keyraw // convertion "raw" type - defaults to i_key
-#define i_keyfrom // convertion func i_keyraw => i_key
-#define i_keyto // convertion func i_key* => i_keyraw
-
-#define i_tag // alternative typename: cdeq_{i_tag}. i_tag defaults to i_key
+#define i_key <t> // element type: REQUIRED. Note: i_val* may be specified instead of i_key*.
+#define i_type <t> // cdeq container type name
+#define i_cmp <f> // three-way compare of two i_keyraw*.
+#define i_cmp_native // define instead of i_cmp only when i_key is an integral/native-type.
+#define i_keydrop <f> // destroy value func - defaults to empty destruct
+#define i_keyclone <f> // REQUIRED IF i_keydrop is defined
+
+#define i_keyraw <t> // convertion "raw" type - defaults to i_key
+#define i_keyfrom <f> // convertion func i_keyraw => i_key
+#define i_keyto <f> // convertion func i_key* => i_keyraw
+
+#define i_tag <s> // alternative typename: cdeq_{i_tag}. i_tag defaults to i_key
#include <stc/cdeq.h>
```
`X` should be replaced by the value of `i_tag` in all of the following documentation.
diff --git a/docs/clist_api.md b/docs/clist_api.md
index 3d785789..d8d614c2 100644
--- a/docs/clist_api.md
+++ b/docs/clist_api.md
@@ -22,16 +22,17 @@ See the c++ class [std::list](https://en.cppreference.com/w/cpp/container/list)
## Header file and declaration
```c
-#define i_type // container type name (default: clist_{i_key})
-#define i_key // value: REQUIRED
-#define i_cmp // three-way compare two i_keyraw* : REQUIRED IF i_keyraw is a non-integral type
-#define i_keydrop // destroy value func - defaults to empty destruct
-#define i_keyclone // REQUIRED IF i_keydrop defined
-
-#define i_keyraw // convertion "raw" type (default: {i_key})
-#define i_keyto // convertion func i_key* => i_keyraw
-#define i_keyfrom // convertion func i_keyraw => i_key
-#define i_tag // alternative typename: cpque_{i_tag}. i_tag defaults to i_key
+#define i_key <t> // element type: REQUIRED. Note: i_val* may be specified instead of i_key*.
+#define i_type <t> // clist container type name
+#define i_cmp <f> // three-way compare two i_keyraw*
+#define i_cmp_native // define instead of i_cmp only when i_key is an integral/native-type.
+#define i_keydrop <f> // destroy value func - defaults to empty destruct
+#define i_keyclone <f> // REQUIRED IF i_keydrop defined
+
+#define i_keyraw <t> // convertion "raw" type (default: {i_key})
+#define i_keyto <f> // convertion func i_key* => i_keyraw
+#define i_keyfrom <f> // convertion func i_keyraw => i_key
+#define i_tag <s> // alternative typename: cpque_{i_tag}. i_tag defaults to i_key
#include <stc/clist.h>
```
diff --git a/docs/cmap_api.md b/docs/cmap_api.md
index eca350b4..17f27662 100644
--- a/docs/cmap_api.md
+++ b/docs/cmap_api.md
@@ -17,26 +17,25 @@ See the c++ class [std::unordered_map](https://en.cppreference.com/w/cpp/contain
## Header file and declaration
```c
-#define i_type // container type name (default: cmap_{i_key})
-#define i_key // hash key: REQUIRED
-#define i_val // map value: REQUIRED
-#define i_hash // hash func i_keyraw*: REQUIRED IF i_keyraw is non-pod type
-#define i_eq // equality comparison two i_keyraw*: REQUIRED IF i_keyraw is a
- // non-integral type. Three-way i_cmp may alternatively be specified.
-#define i_keydrop // destroy key func - defaults to empty destruct
-#define i_keyclone // REQUIRED IF i_keydrop defined
-#define i_keyraw // convertion "raw" type - defaults to i_key
-#define i_keyfrom // convertion func i_keyraw => i_key
-#define i_keyto // convertion func i_key* => i_keyraw
-
-#define i_valdrop // destroy value func - defaults to empty destruct
-#define i_valclone // REQUIRED IF i_valdrop defined
-#define i_valraw // convertion "raw" type - defaults to i_val
-#define i_valfrom // convertion func i_valraw => i_val
-#define i_valto // convertion func i_val* => i_valraw
-
-#define i_tag // alternative typename: cmap_{i_tag}. i_tag defaults to i_val
-#define i_expandby // default 1. If 2, table expand 2x (else 1.5x)
+#define i_key <t> // key type: REQUIRED.
+#define i_val <t> // mapped value type: REQUIRED.
+#define i_type <t> // container type name (default: cmap_{i_key})
+#define i_hash <f> // hash func i_keyraw*: REQUIRED IF i_keyraw is non-pod type
+#define i_eq <f> // equality comparison two i_keyraw*: REQUIRED IF i_keyraw is a
+ // non-integral type. Three-way i_cmp may alternatively be specified.
+#define i_keydrop <f> // destroy key func - defaults to empty destruct
+#define i_keyclone <f> // REQUIRED IF i_keydrop defined
+#define i_keyraw <t> // convertion "raw" type - defaults to i_key
+#define i_keyfrom <f> // convertion func i_keyraw => i_key
+#define i_keyto <f> // convertion func i_key* => i_keyraw
+
+#define i_valdrop <f> // destroy value func - defaults to empty destruct
+#define i_valclone <f> // REQUIRED IF i_valdrop defined
+#define i_valraw <t> // convertion "raw" type - defaults to i_val
+#define i_valfrom <f> // convertion func i_valraw => i_val
+#define i_valto <f> // convertion func i_val* => i_valraw
+
+#define i_tag <s> // alternative typename: cmap_{i_tag}. i_tag defaults to i_val
#include <stc/cmap.h>
```
`X` should be replaced by the value of `i_tag` in all of the following documentation.
diff --git a/docs/cpque_api.md b/docs/cpque_api.md
index 5b63dfd1..4cde927b 100644
--- a/docs/cpque_api.md
+++ b/docs/cpque_api.md
@@ -8,17 +8,17 @@ See the c++ class [std::priority_queue](https://en.cppreference.com/w/cpp/contai
## Header file and declaration
```c
-#define i_type // define type name of the container (default cpque_{i_key})
-#define i_key // value: REQUIRED
-#define i_less // compare two i_key* : REQUIRED IF i_key/i_keyraw is a non-integral type
-#define i_keydrop // destroy value func - defaults to empty destruct
-#define i_keyclone // REQUIRED IF i_keydrop defined
+#define i_key <t> // element type: REQUIRED. Note: i_val* may be specified instead of i_key*.
+#define i_type <t> // cpque container type name
+#define i_less <f> // compare two i_key* : REQUIRED IF i_key/i_keyraw is a non-integral type
+#define i_keydrop <f> // destroy value func - defaults to empty destruct
+#define i_keyclone <f> // REQUIRED IF i_keydrop defined
-#define i_keyraw // convertion type
-#define i_keyfrom // convertion func i_keyraw => i_key
-#define i_keyto // convertion func i_key* => i_keyraw.
+#define i_keyraw <t> // convertion type
+#define i_keyfrom <f> // convertion func i_keyraw => i_key
+#define i_keyto <f> // convertion func i_key* => i_keyraw.
-#define i_tag // alternative typename: cpque_{i_tag}. i_tag defaults to i_key
+#define i_tag <s> // alternative typename: cpque_{i_tag}. i_tag defaults to i_key
#include <stc/cpque.h>
```
`X` should be replaced by the value of `i_tag` in all of the following documentation.
diff --git a/docs/cqueue_api.md b/docs/cqueue_api.md
index b324e5fc..1834baf9 100644
--- a/docs/cqueue_api.md
+++ b/docs/cqueue_api.md
@@ -7,16 +7,16 @@ See the c++ class [std::queue](https://en.cppreference.com/w/cpp/container/queue
## Header file and declaration
```c
-#define i_type // container type name (default: cqueue_{i_key})
-#define i_key // value: REQUIRED
-#define i_keydrop // destroy value func - defaults to empty destruct
-#define i_keyclone // REQUIRED IF i_keydrop defined
+#define i_key <t> // element type: REQUIRED. Note: i_val* may be specified instead of i_key*.
+#define i_type <t> // cqueue container type name
+#define i_keydrop <f> // destroy value func - defaults to empty destruct
+#define i_keyclone <f> // REQUIRED IF i_keydrop defined
-#define i_keyraw // convertion "raw" type - defaults to i_key
-#define i_keyfrom // convertion func i_keyraw => i_key
-#define i_keyto // convertion func i_key* => i_keyraw
+#define i_keyraw <t> // convertion "raw" type - defaults to i_key
+#define i_keyfrom <f> // convertion func i_keyraw => i_key
+#define i_keyto <f> // convertion func i_key* => i_keyraw
-#define i_tag // alternative typename: cqueue_{i_tag}. i_tag defaults to i_key
+#define i_tag <s> // alternative typename: cqueue_{i_tag}. i_tag defaults to i_key
#include <stc/cqueue.h>
```
`X` should be replaced by the value of `i_tag` in all of the following documentation.
diff --git a/docs/cset_api.md b/docs/cset_api.md
index e894ad4f..928d63a8 100644
--- a/docs/cset_api.md
+++ b/docs/cset_api.md
@@ -7,19 +7,19 @@ A **cset** is an associative container that contains a set of unique objects of
## Header file and declaration
```c
-#define i_type // container type name (default: cset_{i_key})
-#define i_key // hash key: REQUIRED.
-#define i_hash // hash func: REQUIRED IF i_keyraw is a non-pod type.
-#define i_eq // equality comparison two i_keyraw*: !i_cmp is used if not defined.
-#define i_keydrop // destroy key func - defaults to empty destruct
-#define i_keyclone // REQUIRED IF i_keydrop defined
-
-#define i_keyraw // convertion "raw" type - defaults to i_key
-#define i_keyfrom // convertion func i_keyraw => i_key - defaults to plain copy
-#define i_keyto // convertion func i_key* => i_keyraw - defaults to plain copy
-
-#define i_tag // alternative typename: cmap_{i_tag}. i_tag defaults to i_key
-#define i_expandby // default 1. If 2, table expand 2x (else 1.5x)
+#define i_key <t> // element type: REQUIRED. Note: i_val* may be specified instead of i_key*.
+#define i_type <t> // container type name
+#define i_hash <f> // hash func i_keyraw*: REQUIRED IF i_keyraw is non-pod type
+#define i_eq <f> // equality comparison two i_keyraw*: REQUIRED IF i_keyraw is a
+ // non-integral type. Three-way i_cmp may alternatively be specified.
+#define i_keydrop <f> // destroy key func: defaults to empty destruct
+#define i_keyclone <f> // clone func: REQUIRED IF i_keydrop defined
+
+#define i_keyraw <t> // convertion "raw" type - defaults to i_key
+#define i_keyfrom <f> // convertion func i_keyraw => i_key - defaults to plain copy
+#define i_keyto <f> // convertion func i_key* => i_keyraw - defaults to plain copy
+
+#define i_tag <s> // alternative typename: cmap_{i_tag}. i_tag defaults to i_key
#include <stc/cset.h>
```
`X` should be replaced by the value of `i_tag` in all of the following documentation.
diff --git a/docs/csmap_api.md b/docs/csmap_api.md
index 099d7dfc..afaf49f3 100644
--- a/docs/csmap_api.md
+++ b/docs/csmap_api.md
@@ -15,24 +15,24 @@ See the c++ class [std::map](https://en.cppreference.com/w/cpp/container/map) fo
## Header file and declaration
```c
-#define i_type // container type name (default: cmap_{i_key})
-#define i_key // key: REQUIRED
-#define i_val // value: REQUIRED
-#define i_cmp // three-way compare two i_keyraw* : REQUIRED IF i_keyraw is a non-integral type
-
-#define i_keydrop // destroy key func - defaults to empty destruct
-#define i_keyclone // REQUIRED IF i_valdrop defined
-#define i_keyraw // convertion "raw" type - defaults to i_key
-#define i_keyfrom // convertion func i_keyraw => i_key
-#define i_keyto // convertion func i_key* => i_keyraw
-
-#define i_valdrop // destroy value func - defaults to empty destruct
-#define i_valclone // REQUIRED IF i_valdrop defined
-#define i_valraw // convertion "raw" type - defaults to i_val
-#define i_valfrom // convertion func i_valraw => i_val
-#define i_valto // convertion func i_val* => i_valraw
-
-#define i_tag // alternative typename: csmap_{i_tag}. i_tag defaults to i_val
+#define i_key <t> // key type: REQUIRED.
+#define i_val <t> // mapped value type: REQUIRED.
+#define i_type <t> // container type name (default: cmap_{i_key})
+#define i_cmp <f> // three-way compare two i_keyraw* : REQUIRED IF i_keyraw is a non-integral type
+
+#define i_keydrop <f> // destroy key func - defaults to empty destruct
+#define i_keyclone <f> // REQUIRED IF i_valdrop defined
+#define i_keyraw <t> // convertion "raw" type - defaults to i_key
+#define i_keyfrom <f> // convertion func i_keyraw => i_key
+#define i_keyto <f> // convertion func i_key* => i_keyraw
+
+#define i_valdrop <f> // destroy value func - defaults to empty destruct
+#define i_valclone <f> // REQUIRED IF i_valdrop defined
+#define i_valraw <t> // convertion "raw" type - defaults to i_val
+#define i_valfrom <f> // convertion func i_valraw => i_val
+#define i_valto <f> // convertion func i_val* => i_valraw
+
+#define i_tag <s> // alternative typename: csmap_{i_tag}. i_tag defaults to i_val
#include <stc/csmap.h>
```
`X` should be replaced by the value of `i_tag` in all of the following documentation.
diff --git a/docs/csset_api.md b/docs/csset_api.md
index aef3af3c..21e38f61 100644
--- a/docs/csset_api.md
+++ b/docs/csset_api.md
@@ -8,17 +8,17 @@ See the c++ class [std::set](https://en.cppreference.com/w/cpp/container/set) fo
## Header file and declaration
```c
-#define i_type // full typename of the container
-#define i_key // key: REQUIRED
-#define i_cmp // three-way compare two i_keyraw* : REQUIRED IF i_keyraw is a non-integral type
-#define i_keydrop // destroy key func - defaults to empty destruct
-#define i_keyclone // REQUIRED IF i_keydrop defined
+#define i_key <t> // element type: REQUIRED. Note: i_val* may be specified instead of i_key*.
+#define i_type <t> // container type name
+#define i_cmp <f> // three-way compare two i_keyraw* : REQUIRED IF i_keyraw is a non-integral type
+#define i_keydrop <f> // destroy key func - defaults to empty destruct
+#define i_keyclone <f> // REQUIRED IF i_keydrop defined
-#define i_keyraw // convertion "raw" type - defaults to i_key
-#define i_keyfrom // convertion func i_keyraw => i_key - defaults to plain copy
-#define i_keyto // convertion func i_key* => i_keyraw - defaults to plain copy
+#define i_keyraw <t> // convertion "raw" type - defaults to i_key
+#define i_keyfrom <f> // convertion func i_keyraw => i_key - defaults to plain copy
+#define i_keyto <f> // convertion func i_key* => i_keyraw - defaults to plain copy
-#define i_tag // alternative typename: csset_{i_tag}. i_tag defaults to i_key
+#define i_tag <s> // alternative typename: csset_{i_tag}. i_tag defaults to i_key
#include <stc/csset.h>
```
`X` should be replaced by the value of `i_tag` in all of the following documentation.
diff --git a/docs/cstack_api.md b/docs/cstack_api.md
index e799b152..fb629392 100644
--- a/docs/cstack_api.md
+++ b/docs/cstack_api.md
@@ -8,16 +8,16 @@ See the c++ class [std::stack](https://en.cppreference.com/w/cpp/container/stack
## Header file and declaration
```c
-#define i_type // full typename of the container
-#define i_key // value: REQUIRED
-#define i_keydrop // destroy value func - defaults to empty destruct
-#define i_keyclone // REQUIRED IF i_keydrop defined
+#define i_key <t> // element type: REQUIRED. Note: i_val* may be specified instead of i_key*.
+#define i_type <t> // container type name
+#define i_keydrop <f> // destroy value func - defaults to empty destruct
+#define i_keyclone <f> // REQUIRED IF i_keydrop defined
-#define i_keyraw // convertion "raw" type - defaults to i_key
-#define i_keyfrom // convertion func i_keyraw => i_key
-#define i_keyto // convertion func i_key* => i_keyraw
+#define i_keyraw <t> // convertion "raw" type - defaults to i_key
+#define i_keyfrom <f> // convertion func i_keyraw => i_key
+#define i_keyto <f> // convertion func i_key* => i_keyraw
-#define i_tag // alternative typename: cstack_{i_tag}. i_tag defaults to i_key
+#define i_tag <s> // alternative typename: cstack_{i_tag}. i_tag defaults to i_key
#include <stc/cstack.h>
```
`X` should be replaced by the value of `i_tag` in all of the following documentation.
diff --git a/docs/cvec_api.md b/docs/cvec_api.md
index d38ef23f..9cba74b5 100644
--- a/docs/cvec_api.md
+++ b/docs/cvec_api.md
@@ -12,17 +12,18 @@ See the c++ class [std::vector](https://en.cppreference.com/w/cpp/container/vect
## Header file and declaration
```c
-#define i_type // full typename of the container
-#define i_key // value: REQUIRED
-#define i_cmp // three-way compare two i_keyraw* : REQUIRED IF i_keyraw is a non-integral type
-#define i_keydrop // destroy value func - defaults to empty destruct
-#define i_keyclone // REQUIRED IF i_keydrop defined
-
-#define i_keyraw // convertion "raw" type - defaults to i_key
-#define i_keyfrom // convertion func i_keyraw => i_key
-#define i_keyto // convertion func i_key* => i_keyraw
-
-#define i_tag // alternative typename: cvec_{i_tag}. i_tag defaults to i_key
+#define i_type <t> // container type name
+#define i_key <t> // element type: REQUIRED. Note: i_val* may be specified instead of i_key*.
+#define i_cmp <f> // three-way compare two i_keyraw*
+#define i_cmp_native // define instead of i_cmp only when i_key is an integral/native-type.
+#define i_keydrop <f> // destroy value func - defaults to empty destruct
+#define i_keyclone <f> // REQUIRED IF i_keydrop defined
+
+#define i_keyraw <t> // convertion "raw" type - defaults to i_key
+#define i_keyfrom <f> // convertion func i_keyraw => i_key
+#define i_keyto <f> // convertion func i_key* => i_keyraw
+
+#define i_tag <s> // alternative typename: cvec_{i_tag}. i_tag defaults to i_key
#include <stc/cvec.h>
```
`X` should be replaced by the value of `i_tag` in all of the following documentation.
diff --git a/include/stc/algo/coroutine.h b/include/stc/algo/coroutine.h
index 3a5382f3..e4c0915c 100644
--- a/include/stc/algo/coroutine.h
+++ b/include/stc/algo/coroutine.h
@@ -178,17 +178,22 @@ typedef struct { intptr_t count; } cco_sem;
#ifdef _WIN32
#ifdef __cplusplus
- #define _c_LINKC extern "C" __declspec(dllimport)
+ #define _c_LINKC extern "C" __declspec(dllimport)
#else
- #define _c_LINKC __declspec(dllimport)
+ #define _c_LINKC __declspec(dllimport)
+ #endif
+ #if _WIN32_WINNT < _WIN32_WINNT_WIN8 || defined __TINYC__
+ #define _c_getsystime GetSystemTimeAsFileTime
+ #else
+ #define _c_getsystime GetSystemTimePreciseAsFileTime
#endif
struct _FILETIME;
- _c_LINKC void GetSystemTimePreciseAsFileTime(struct _FILETIME*);
+ _c_LINKC void _c_getsystime(struct _FILETIME*);
_c_LINKC void Sleep(unsigned long);
static inline double cco_time(void) { /* seconds since epoch */
unsigned long long quad; /* 64-bit value representing 1/10th usecs since Jan 1 1601, 00:00 UTC */
- GetSystemTimePreciseAsFileTime((struct _FILETIME*)&quad);
+ _c_getsystime((struct _FILETIME*)&quad);
return (double)(quad - 116444736000000000ULL)*1e-7; /* time diff Jan 1 1601-Jan 1 1970 in 1/10th usecs */
}
diff --git a/include/stc/algo/filter.h b/include/stc/algo/filter.h
index 4a227927..1a62c3e1 100644
--- a/include/stc/algo/filter.h
+++ b/include/stc/algo/filter.h
@@ -85,6 +85,21 @@ int main(void)
if (it.ref == _endref) it.ref = NULL; \
} while (0)
+#define c_all_of(boolptr, it, C, cnt, pred) do { \
+ C##_iter it; \
+ c_find_if_4(it, C, cnt, !(pred)); \
+ *(boolptr) = it.ref == NULL; \
+} while (0)
+#define c_any_of(boolptr, it, C, cnt, pred) do { \
+ C##_iter it; \
+ c_find_if_4(it, C, cnt, pred); \
+ *(boolptr) = it.ref != NULL; \
+} while (0)
+#define c_none_of(boolptr, it, C, cnt, pred) do { \
+ C##_iter it; \
+ c_find_if_4(it, C, cnt, pred); \
+ *(boolptr) = it.ref == NULL; \
+} while (0)
// Use with: clist, cmap, cset, csmap, csset:
#define c_erase_if(it, C, cnt, pred) do { \
@@ -95,7 +110,6 @@ int main(void)
} \
} while (0)
-
// Use with: cstack, cvec, cdeq, cqueue:
#define c_eraseremove_if(it, C, cnt, pred) do { \
C* _cnt = &cnt; \
diff --git a/include/stc/priv/template.h b/include/stc/priv/template.h
index 30ed5732..ccdce718 100644
--- a/include/stc/priv/template.h
+++ b/include/stc/priv/template.h
@@ -103,7 +103,7 @@
#define i_no_emplace
#endif
#if c_option(c_native_cmp)
- #define i_native_cmp
+ #define i_cmp_native
#endif
#if c_option(c_no_clone) || defined _i_carc
#define i_no_clone
@@ -203,10 +203,10 @@
#endif
#ifndef i_no_cmp
- #if defined i_cmp || defined i_less || defined i_native_cmp
+ #if defined i_cmp || defined i_less || defined i_cmp_native
#define _i_has_cmp
#endif
- #if defined i_eq || defined i_native_cmp
+ #if defined i_eq || defined i_cmp_native
#define _i_has_eq
#endif
@@ -228,7 +228,7 @@
#endif
#endif
-#if !defined i_hash && (!(defined _i_cbox || defined _i_carc) || defined i_native_cmp)
+#if !defined i_hash && (!(defined _i_cbox || defined _i_carc) || defined i_cmp_native)
#define i_hash c_default_hash
#endif
diff --git a/include/stc/priv/template2.h b/include/stc/priv/template2.h
index def5d01e..351defde 100644
--- a/include/stc/priv/template2.h
+++ b/include/stc/priv/template2.h
@@ -67,7 +67,7 @@
#undef i_realloc
#undef i_free
-#undef i_native_cmp
+#undef i_cmp_native
#undef i_no_cmp
#undef i_no_hash
#undef i_no_clone
diff --git a/misc/benchmarks/various/csort_bench.c b/misc/benchmarks/various/csort_bench.c
index f6b7f1db..793a0503 100644
--- a/misc/benchmarks/various/csort_bench.c
+++ b/misc/benchmarks/various/csort_bench.c
@@ -48,7 +48,7 @@ int main(int argc, char *argv[]) {
Ints a = Ints_with_capacity(size);
for (i = 0; i < size; i++)
- *Ints_push(&a, romutrio(s) & (1U << 30) - 1);
+ Ints_push(&a, romutrio(s) & (1U << 30) - 1);
testsort(&a, size, "random");
for (i = 0; i < 20; i++)
printf(" %d", (int)*Ints_at(&a, i));
diff --git a/misc/examples/arc_demo.c b/misc/examples/arc_demo.c
index 87d64e67..929a48a1 100644
--- a/misc/examples/arc_demo.c
+++ b/misc/examples/arc_demo.c
@@ -11,7 +11,7 @@ void int_drop(int* x) {
#define i_type Arc // set type name to be defined (instead of 'carc_int')
#define i_key int
#define i_keydrop int_drop // optional, just to display the elements destroyed
-#define i_native_cmp // use int comparison (x < y, x == y).
+#define i_cmp_native // use int comparison (x < y, x == y).
#include <stc/carc.h> // Arc
#define i_keyboxed Arc // note: use i_keyboxed instead of i_key for carc/cbox elements
diff --git a/misc/examples/arcvec_erase.c b/misc/examples/arcvec_erase.c
index addef8b7..ba54c1c7 100644
--- a/misc/examples/arcvec_erase.c
+++ b/misc/examples/arcvec_erase.c
@@ -5,7 +5,7 @@ void show_drop(int* x) { printf("drop: %d\n", *x); }
#define i_type Arc
#define i_key int
#define i_keydrop show_drop
-#define i_native_cmp // enable sort/search for int type
+#define i_cmp_native // enable sort/search for int type
#include <stc/carc.h> // Shared pointer to int
#define i_type Vec
diff --git a/misc/examples/demos.c b/misc/examples/demos.c
index ecc89f2e..1a604d9f 100644
--- a/misc/examples/demos.c
+++ b/misc/examples/demos.c
@@ -74,7 +74,7 @@ void vectordemo2(void)
#define i_key int
#define i_tag ix
-#define i_native_cmp
+#define i_cmp_native
#include <stc/clist.h>
void listdemo1(void)
diff --git a/misc/examples/intrusive.c b/misc/examples/intrusive.c
index 4fca654b..c22ed260 100644
--- a/misc/examples/intrusive.c
+++ b/misc/examples/intrusive.c
@@ -4,7 +4,7 @@
#define i_type List
#define i_key int
-#define i_native_cmp
+#define i_cmp_native
#include <stc/clist.h>
void printList(List list) {
diff --git a/misc/examples/list.c b/misc/examples/list.c
index fa33305a..ad8bebb8 100644
--- a/misc/examples/list.c
+++ b/misc/examples/list.c
@@ -5,7 +5,7 @@
#define i_type DList
#define i_key double
-#define i_native_cmp
+#define i_cmp_native
#include <stc/clist.h>
int main(void) {
diff --git a/misc/examples/lower_bound.c b/misc/examples/lower_bound.c
index e5d816e9..bea828f2 100644
--- a/misc/examples/lower_bound.c
+++ b/misc/examples/lower_bound.c
@@ -1,7 +1,7 @@
#include <stdio.h>
#define i_key int
-#define i_native_cmp
+#define i_cmp_native
#include <stc/cvec.h>
#define i_key int
diff --git a/misc/examples/new_list.c b/misc/examples/new_list.c
index 9676e7b4..2112bf1f 100644
--- a/misc/examples/new_list.c
+++ b/misc/examples/new_list.c
@@ -27,7 +27,7 @@ int point_cmp(const Point* a, const Point* b) {
#include <stc/clist.h>
#define i_key float
-#define i_native_cmp // use < and == operators for comparison
+#define i_cmp_native // use < and == operators for comparison
#include <stc/clist.h>
void MyStruct_drop(MyStruct* s);
diff --git a/misc/examples/new_sptr.c b/misc/examples/new_sptr.c
index 7fef5d1f..3c6fa16c 100644
--- a/misc/examples/new_sptr.c
+++ b/misc/examples/new_sptr.c
@@ -15,7 +15,7 @@ uint64_t Person_hash(const Person* p);
#define i_type IPtr
#define i_key int
#define i_keydrop(x) printf("drop: %d\n", *x)
-#define i_native_cmp
+#define i_cmp_native
#include <stc/carc.h>
#define i_type IPStack