summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorTyge Løvset <[email protected]>2020-09-15 23:12:58 +0200
committerTyge Løvset <[email protected]>2020-09-15 23:12:58 +0200
commit0ce57669673a5a22d8207ec884bcebb97cb18448 (patch)
treed76c4b38431efee766d97ba572fa3127a3e05976
parentf4435af2fc9e9187f7be0149c2eb916db27cb257 (diff)
downloadSTC-modified-0ce57669673a5a22d8207ec884bcebb97cb18448.tar.gz
STC-modified-0ce57669673a5a22d8207ec884bcebb97cb18448.zip
Simplified declare_ statement e.g. c_cmap(...)
-rw-r--r--README.md40
-rw-r--r--examples/README.md4
-rw-r--r--examples/advanced.c4
-rw-r--r--examples/benchmark.c2
-rw-r--r--examples/birthday.c6
-rw-r--r--examples/complex.c8
-rw-r--r--examples/demos.c16
-rw-r--r--examples/ex_gaussian.c4
-rw-r--r--examples/geek1.c2
-rw-r--r--examples/geek2.c4
-rw-r--r--examples/geek3.c4
-rw-r--r--examples/geek4.c6
-rw-r--r--examples/geek5.c4
-rw-r--r--examples/geek6.c2
-rw-r--r--examples/geek7.c6
-rw-r--r--examples/heap.c4
-rw-r--r--examples/inits.c12
-rw-r--r--examples/list.c2
-rw-r--r--examples/mapmap.c4
-rw-r--r--examples/phonebook.c2
-rw-r--r--examples/priority.c4
-rw-r--r--examples/queue.c4
-rw-r--r--examples/stack.c8
-rw-r--r--examples/words.c6
-rw-r--r--stc/carray.h18
-rw-r--r--stc/clist.h30
-rw-r--r--stc/cmap.h78
-rw-r--r--stc/cpqueue.h6
-rw-r--r--stc/cqueue.h6
-rw-r--r--stc/cstack.h6
-rw-r--r--stc/cvec.h20
31 files changed, 161 insertions, 161 deletions
diff --git a/README.md b/README.md
index ca9a3bd0..9184a2e4 100644
--- a/README.md
+++ b/README.md
@@ -24,7 +24,7 @@ The usage of the containers is vert similar to the C++ standard containers, so i
All containers mentioned above, except cstr_t and cbitset_t are generic and typesafe (similar to templates in C++). No casting is used. A simple example:
```
#include <stc/cvec.h>
-cdef_cvec(i, int);
+c_cvec(i, int);
int main(void) {
cvec_i vec = cvec_ini;
@@ -55,10 +55,10 @@ Because it is headers only, files can simply be included in your program. The fu
#include <stc/clist.h>
#include "Vec3.h"
-cdef_cmap(ii, int, int);
-cdef_cset(ix, int64_t);
-cdef_cvec(i, int);
-cdef_clist(v3, Vec3);
+c_cmap(ii, int, int);
+c_cset(ix, int64_t);
+c_cvec(i, int);
+c_clist(v3, Vec3);
...
```
Performance
@@ -118,7 +118,7 @@ cmap discussion
You can customize the destroy-, hash- and equals- function. **cmap/cset** also supports a few other arguments in the declare-statement that allows to define a convertion from a raw/literal type to the key-type specified. This is very useful when e.g. having cstr as key, as it enables the usage of string literals as key in *put() and find()* functions, instead of requering a constructed cstr. Without it, the code would become:
```
-cdef_cmap(si, cstr_t, int); // don't do this.
+c_cmap(si, cstr_t, int); // don't do this.
...
cmap_si_put(&map, cstr("mykey"), 12);
```
@@ -129,12 +129,12 @@ int x = cmap_si_find(&map, lookup)->value;
cstr_destroy(&lookup);
```
To avoid this, use
-- *cdef_cmap_strkey(tag, valuetype)*
-- *cdef_cmap_strval(tag, keytype)*
-- *cdef_cmap_str()* // cstr_t -> cstr_t
-- *cdef_cset_str()* // cstr_t set
+- *c_cmap_strkey(tag, valuetype)*
+- *c_cmap_strval(tag, keytype)*
+- *c_cmap_str()* // cstr_t -> cstr_t
+- *c_cset_str()* // cstr_t set
```
-cdef_cmap_strkey(si, int);
+c_cmap_strkey(si, int);
...
cmap_si map = cmap_ini;
cmap_si_put(&map, "mykey", 12); // constructs a cstr_t key from the const char* internally.
@@ -142,9 +142,9 @@ int x = cmap_si_find(&map, "mykey")->value; // no allocation of string key happe
cmap_si_destroy(&map);
```
An alternative is to use *char* * as key type, but then you must manage allcoated memory of the hash char* keys yourself.
-Note that this predefined customization is also available for **cvec** and **clist**. See *cdef_cvec_str()*, *cdef_clist_str()*.
+Note that this predefined customization is also available for **cvec** and **clist**. See *c_cvec_str()*, *c_clist_str()*.
-To customize your own cmap type to work like cmap_str, you may want to look at **examples/advanced.c**. It demonstrates how to use a custom struct as a hash map key, using the optional parameters to cdef_cmap().
+To customize your own cmap type to work like cmap_str, you may want to look at **examples/advanced.c**. It demonstrates how to use a custom struct as a hash map key, using the optional parameters to c_cmap().
Example usages
--------------
@@ -181,7 +181,7 @@ int main() {
**cvec** of *int64_t*.
```
#include <stc/cvec.h>
-cdef_cvec(ix, int64_t); // ix is just an example type tag name.
+c_cvec(ix, int64_t); // ix is just an example type tag name.
int main() {
cvec_ix bignums = cvec_ini; // use cvec_ix_init() if initializing after declaration.
@@ -200,7 +200,7 @@ int main() {
```
#include <stc/cstr.h>
#include <stc/cvec.h>
-cdef_cvec_str();
+c_cvec_str();
int main() {
cvec_str names = cvec_ini;
@@ -220,7 +220,7 @@ int main() {
```
#include <stdio.h>
#include <stc/cmap.h>
-cdef_cmap(ii, int, int);
+c_cmap(ii, int, int);
int main() {
cmap_ii nums = cmap_ini;
@@ -235,7 +235,7 @@ int main() {
```
#include <stc/cstr.h>
#include <stc/cmap.h>
-cdef_cset_str(); // cstr set. See the discussion above.
+c_cset_str(); // cstr set. See the discussion above.
int main() {
cset_str words = cset_ini;
@@ -254,7 +254,7 @@ int main() {
```
#include <stc/cstr.h>
#include <stc/cmap.h>
-cdef_cmap_str();
+c_cmap_str();
int main() {
cmap_str table = cmap_ini;
@@ -276,7 +276,7 @@ int main() {
#include <time.h>
#include <stc/clist.h>
#include <stc/crandom.h>
-cdef_clist(fx, double);
+c_clist(fx, double);
int main() {
clist_fx list = clist_ini;
@@ -313,7 +313,7 @@ int main() {
```
#include <stdio.h>
#include <stc/carray.h>
-cdef_carray(f, float);
+c_carray(f, float);
int main()
{
diff --git a/examples/README.md b/examples/README.md
index 5c9c990a..98e366df 100644
--- a/examples/README.md
+++ b/examples/README.md
@@ -51,9 +51,9 @@ static inline Viking viking_fromVw(VikingVw vw) { // note: parameter is by value
Viking vk = {cstr(vw.name), cstr(vw.country)}; return vk;
}
```
-With this in place, we use the full cdef_cmap() macro to define {Viking -> int} hash map type:
+With this in place, we use the full c_cmap() macro to define {Viking -> int} hash map type:
```
-cdef_cmap(vk, Viking, int, c_default_destroy, vikingvw_equals, vikingvw_hash,
+c_cmap(vk, Viking, int, c_default_destroy, vikingvw_equals, vikingvw_hash,
viking_destroy, VikingVw, viking_toVw, viking_fromVw);
```
cmap_vk uses vikingvw_hash() for hash value calculations, and vikingvw_equals() for equality test. cmap_vk_destroy() will free all memory allocated for Viking keys and the hash table values.
diff --git a/examples/advanced.c b/examples/advanced.c
index ab2cec5f..1f4907c6 100644
--- a/examples/advanced.c
+++ b/examples/advanced.c
@@ -50,8 +50,8 @@ Viking viking_fromVw(VikingVw vw) {
Viking vk = {cstr(vw.name), cstr(vw.country)}; return vk;
}
-// Using the full cdef_cmap() macro to define [Viking -> int] hash map type:
-cdef_cmap(vk, Viking, int, c_default_destroy, vikingvw_equals, vikingvw_hash,
+// Using the full c_cmap() macro to define [Viking -> int] hash map type:
+c_cmap(vk, Viking, int, c_default_destroy, vikingvw_equals, vikingvw_hash,
viking_destroy, VikingVw, viking_toVw, viking_fromVw);
// cmap_vk uses vikingvw_hash() for hash value calculations, and vikingvw_equals() for equality test.
diff --git a/examples/benchmark.c b/examples/benchmark.c
index 04995de0..55cae17f 100644
--- a/examples/benchmark.c
+++ b/examples/benchmark.c
@@ -22,7 +22,7 @@ static inline uint32_t fibonacci_hash(const void* data, size_t len) {
}
// cmap and khash template expansion
-cdef_cmap(ii, int64_t, int64_t, c_default_destroy, c_default_equals, fibonacci_hash);
+c_cmap(ii, int64_t, int64_t, c_default_destroy, c_default_equals, fibonacci_hash);
KHASH_MAP_INIT_INT64(ii, int64_t)
diff --git a/examples/birthday.c b/examples/birthday.c
index c6a9e541..e2d2600a 100644
--- a/examples/birthday.c
+++ b/examples/birthday.c
@@ -7,7 +7,7 @@
#include <stc/cvec.h>
#include <stc/cstr.h>
-cdef_cmap(ic, uint64_t, uint8_t);
+c_cmap(ic, uint64_t, uint8_t);
const static uint64_t seed = 1234;
const static uint64_t N = 1ull << 27;
@@ -29,8 +29,8 @@ void repeats(void)
}
-cdef_cmap(x, uint32_t, uint64_t);
-cdef_cvec(x, uint64_t);
+c_cmap(x, uint32_t, uint64_t);
+c_cvec(x, uint64_t);
void distribution(void)
{
diff --git a/examples/complex.c b/examples/complex.c
index f129884a..d3f2cf4e 100644
--- a/examples/complex.c
+++ b/examples/complex.c
@@ -5,10 +5,10 @@
void check_destroy(float* v) {printf("destroy %g\n", *v);}
-cdef_carray(f, float, check_destroy); // normally omit the last argument - float type need no destroy.
-cdef_clist(y, carray2f, carray2f_destroy, c_no_compare);
-cdef_cmap(g, int, clist_y, clist_y_destroy);
-cdef_cmap_strkey(s, cmap_g, cmap_g_destroy);
+c_carray(f, float, check_destroy); // normally omit the last argument - float type need no destroy.
+c_clist(y, carray2f, carray2f_destroy, c_no_compare);
+c_cmap(g, int, clist_y, clist_y_destroy);
+c_cmap_strkey(s, cmap_g, cmap_g_destroy);
int main() {
int xdim = 4, ydim = 6;
diff --git a/examples/demos.c b/examples/demos.c
index b3ed91bb..78636864 100644
--- a/examples/demos.c
+++ b/examples/demos.c
@@ -34,7 +34,7 @@ void stringdemo1()
}
-cdef_cvec(ix, int64_t); // ix is just an example tag name.
+c_cvec(ix, int64_t); // ix is just an example tag name.
void vectordemo1()
{
@@ -55,7 +55,7 @@ void vectordemo1()
-cdef_cvec_str();
+c_cvec_str();
void vectordemo2()
{
@@ -73,7 +73,7 @@ void vectordemo2()
cvec_str_destroy(&names);
}
-cdef_clist(ix, int);
+c_clist(ix, int);
void listdemo1()
{
@@ -100,7 +100,7 @@ void listdemo1()
clist_ix_destroy(&nums);
}
-cdef_cset(i, int);
+c_cset(i, int);
void setdemo1()
{
@@ -115,7 +115,7 @@ void setdemo1()
}
-cdef_cmap(ii, int, int);
+c_cmap(ii, int, int);
void mapdemo1()
{
@@ -128,7 +128,7 @@ void mapdemo1()
}
-cdef_cmap_strkey(si, int); // Shorthand macro for the general cdef_cmap expansion.
+c_cmap_strkey(si, int); // Shorthand macro for the general c_cmap expansion.
void mapdemo2()
{
@@ -150,7 +150,7 @@ void mapdemo2()
}
-cdef_cmap_str();
+c_cmap_str();
void mapdemo3()
{
@@ -172,7 +172,7 @@ void mapdemo3()
}
-cdef_carray(f, float);
+c_carray(f, float);
void arraydemo1()
{
diff --git a/examples/ex_gaussian.c b/examples/ex_gaussian.c
index 402fba32..63e16f3c 100644
--- a/examples/ex_gaussian.c
+++ b/examples/ex_gaussian.c
@@ -7,14 +7,14 @@
#include <stc/cvec.h>
// Declare int -> int hashmap. Uses typetag 'i' for ints.
-cdef_cmap(i, int, size_t);
+c_cmap(i, int, size_t);
// Declare int vector with map entries that can be sorted by map keys.
static int compare(cmap_i_entry_t *a, cmap_i_entry_t *b) {
return c_default_compare(&a->key, &b->key);
}
// Vector: typetag 'e' for (map) entry
-cdef_cvec(e, cmap_i_entry_t, c_default_destroy, compare);
+c_cvec(e, cmap_i_entry_t, c_default_destroy, compare);
int main()
{
diff --git a/examples/geek1.c b/examples/geek1.c
index 50e23032..8da51f47 100644
--- a/examples/geek1.c
+++ b/examples/geek1.c
@@ -12,7 +12,7 @@ int a[] = { 1, 2, 2, 3, 2, 4, 10 };
#include <stdio.h>
#include <stc/cmap.h>
-cdef_cmap(ii, int, int);
+c_cmap(ii, int, int);
// Function to maximize the number of pairs
int findMaximumPairs(int a[], int n, int k)
diff --git a/examples/geek2.c b/examples/geek2.c
index 8b1ff2aa..778960f3 100644
--- a/examples/geek2.c
+++ b/examples/geek2.c
@@ -3,8 +3,8 @@
#include <stc/cmap.h>
#include <stc/cstr.h>
-cdef_cmap_str();
-cdef_cset_str();
+c_cmap_str();
+c_cset_str();
int main()
{
diff --git a/examples/geek3.c b/examples/geek3.c
index 4e83a8ec..a3b41ee1 100644
--- a/examples/geek3.c
+++ b/examples/geek3.c
@@ -3,8 +3,8 @@
#include <stc/cmap.h>
#include <stc/cstr.h>
-cdef_cmap_strkey(si, int);
-cdef_cmap_strkey(ss, cstr_t, cstr_destroy);
+c_cmap_strkey(si, int);
+c_cmap_strkey(ss, cstr_t, cstr_destroy);
int main ()
{
diff --git a/examples/geek4.c b/examples/geek4.c
index 3c4c085f..91fb122d 100644
--- a/examples/geek4.c
+++ b/examples/geek4.c
@@ -37,9 +37,9 @@ Efficient Approach: For all the words of the first sentence, we can check if it
#include <stc/cvec.h>
#include <stc/cstr.h>
-cdef_cvec_str();
-cdef_cmap_strkey(sb, bool);
-cdef_cvec(sb, cmap_sb_entry_t, cmap_sb_entry_destroy, c_no_compare);
+c_cvec_str();
+c_cmap_strkey(sb, bool);
+c_cvec(sb, cmap_sb_entry_t, cmap_sb_entry_destroy, c_no_compare);
// Function to return the count of common words
// in all the sentences
diff --git a/examples/geek5.c b/examples/geek5.c
index d8b520c6..f19edf8c 100644
--- a/examples/geek5.c
+++ b/examples/geek5.c
@@ -21,8 +21,8 @@ Output: 0
#include <stc/cvec.h>
#include <stc/cstr.h>
-cdef_cvec(i, int);
-cdef_cmap_strkey(sv, cvec_i, cvec_i_destroy);
+c_cvec(i, int);
+c_cmap_strkey(sv, cvec_i, cvec_i_destroy);
// Function to return the number of occurrences of
diff --git a/examples/geek6.c b/examples/geek6.c
index f03053ca..a973312c 100644
--- a/examples/geek6.c
+++ b/examples/geek6.c
@@ -30,7 +30,7 @@ operation in almost O(1) time complexity.
#include <stdio.h>
#include <stc/cmap.h>
-cdef_cset(i, int);
+c_cset(i, int);
// Function to find the smallest positive
// missing number
diff --git a/examples/geek7.c b/examples/geek7.c
index cb0b35a0..eb78b43b 100644
--- a/examples/geek7.c
+++ b/examples/geek7.c
@@ -27,9 +27,9 @@ After inserting all the elements excluding the ones which are to be deleted, Pop
#include <stc/cvec.h>
#include <stc/cpqueue.h>
-cdef_cmap(ii, int, int);
-cdef_cvec(i, int);
-cdef_cpqueue(i, cvec_i, >);
+c_cmap(ii, int, int);
+c_cvec(i, int);
+c_cpqueue(i, cvec_i, >);
// Find k minimum element from arr[0..m-1] after deleting
// elements from del[0..n-1]
diff --git a/examples/heap.c b/examples/heap.c
index fc067a41..99806c17 100644
--- a/examples/heap.c
+++ b/examples/heap.c
@@ -4,8 +4,8 @@
#include <stc/cvec.h>
#include <stc/cpqueue.h>
-cdef_cvec(f, float);
-cdef_cpqueue(f, cvec_f, >);
+c_cvec(f, float);
+c_cpqueue(f, cvec_f, >);
int main()
{
diff --git a/examples/inits.c b/examples/inits.c
index 37b08624..5fdb5c30 100644
--- a/examples/inits.c
+++ b/examples/inits.c
@@ -5,19 +5,19 @@
#include <stc/cpqueue.h>
#include <stc/clist.h>
-cdef_cmap(id, int, cstr_t, cstr_destroy); // Map of int -> cstr_t
-cdef_cmap_strkey(cnt, int);
+c_cmap(id, int, cstr_t, cstr_destroy); // Map of int -> cstr_t
+c_cmap_strkey(cnt, int);
typedef struct {int x, y;} ipair_t;
inline static int ipair_compare(const ipair_t* a, const ipair_t* b) {
int c = c_default_compare(&a->x, &b->x);
return c != 0 ? c : c_default_compare(&a->y, &b->y);
}
-cdef_cvec(ip, ipair_t, c_default_destroy, ipair_compare);
-cdef_clist(ip, ipair_t, c_default_destroy, ipair_compare);
+c_cvec(ip, ipair_t, c_default_destroy, ipair_compare);
+c_clist(ip, ipair_t, c_default_destroy, ipair_compare);
-cdef_cvec(f, float);
-cdef_cpqueue(f, cvec_f, >);
+c_cvec(f, float);
+c_cpqueue(f, cvec_f, >);
int main(void) {
diff --git a/examples/list.c b/examples/list.c
index c77be371..cea8c7f6 100644
--- a/examples/list.c
+++ b/examples/list.c
@@ -2,7 +2,7 @@
#include <time.h>
#include <stc/clist.h>
#include <stc/crandom.h>
-cdef_clist(fx, double);
+c_clist(fx, double);
int main() {
int k, n = 100000;
diff --git a/examples/mapmap.c b/examples/mapmap.c
index 4e71f6c0..94f4139e 100644
--- a/examples/mapmap.c
+++ b/examples/mapmap.c
@@ -3,8 +3,8 @@
#include <stc/cmap.h>
#include <stc/cstr.h>
-cdef_cmap_str();
-cdef_cmap_strkey(cfg, cmap_str, cmap_str_destroy);
+c_cmap_str();
+c_cmap_strkey(cfg, cmap_str, cmap_str_destroy);
int main(void) {
cmap_cfg config = cmap_ini;
diff --git a/examples/phonebook.c b/examples/phonebook.c
index 716d4e92..04ba2094 100644
--- a/examples/phonebook.c
+++ b/examples/phonebook.c
@@ -25,7 +25,7 @@
#include <stc/cmap.h>
#include <stc/cstr.h>
-cdef_cmap_str();
+c_cmap_str();
void print_phone_book(cmap_str phone_book)
{
diff --git a/examples/priority.c b/examples/priority.c
index ffc4f97b..6e39e63b 100644
--- a/examples/priority.c
+++ b/examples/priority.c
@@ -6,8 +6,8 @@
#include <stc/cmap.h>
#include <stc/crandom.h>
-cdef_cvec(i, int64_t);
-cdef_cpqueue(i, cvec_i, >); // min-heap (increasing values)
+c_cvec(i, int64_t);
+c_cpqueue(i, cvec_i, >); // min-heap (increasing values)
int main() {
size_t N = 10000000;
diff --git a/examples/queue.c b/examples/queue.c
index a912d8ea..addecaa6 100644
--- a/examples/queue.c
+++ b/examples/queue.c
@@ -2,8 +2,8 @@
#include <stc/cqueue.h>
#include <stdio.h>
-cdef_clist(i, int);
-cdef_cqueue(i, clist_i); // min-heap (increasing values)
+c_clist(i, int);
+c_cqueue(i, clist_i); // min-heap (increasing values)
int main() {
int n = 10000000;
diff --git a/examples/stack.c b/examples/stack.c
index a60e5564..ba7de082 100644
--- a/examples/stack.c
+++ b/examples/stack.c
@@ -3,10 +3,10 @@
#include <stc/cstr.h>
#include <stc/cstack.h>
-cdef_cvec(i, int);
-cdef_cvec(c, char);
-cdef_cstack(i, cvec_i);
-cdef_cstack(c, cvec_c);
+c_cvec(i, int);
+c_cvec(c, char);
+c_cstack(i, cvec_i);
+c_cstack(c, cvec_c);
int main() {
cstack_i stack = cstack_i_init();
diff --git a/examples/words.c b/examples/words.c
index ad37f72e..65e7e02d 100644
--- a/examples/words.c
+++ b/examples/words.c
@@ -4,9 +4,9 @@
#include <stc/clist.h>
#include <stc/cvec.h>
-cdef_cvec_str();
-cdef_clist_str();
-cdef_cmap_strkey(si, int);
+c_cvec_str();
+c_clist_str();
+c_cmap_strkey(si, int);
int main1()
diff --git a/stc/carray.h b/stc/carray.h
index 3106b99a..e2f404eb 100644
--- a/stc/carray.h
+++ b/stc/carray.h
@@ -30,7 +30,7 @@
Multi-dimensional generic array allocated as one block of heap-memory.
// demo:
#include <stc/carray.h>
-cdef_carray(f, float);
+c_carray(f, float);
int main()
{
@@ -68,7 +68,7 @@ STC_INLINE size_t _carray3_size(const size_t* zdim) {
}
-#define cdef_carray_common(D, X, Value, valueDestroy) \
+#define c_carray_common(D, X, Value, valueDestroy) \
typedef struct { Value *get; } carray##D##X##_iter_t; \
\
STC_INLINE carray##D##X##_iter_t \
@@ -91,12 +91,12 @@ STC_INLINE size_t _carray3_size(const size_t* zdim) {
} \
}
-#define cdef_carray(...) c_MACRO_OVERLOAD(cdef_carray, __VA_ARGS__)
-#define cdef_carray_2(X, Value) \
- cdef_carray_3(X, Value, c_default_destroy)
+#define c_carray(...) c_MACRO_OVERLOAD(c_carray, __VA_ARGS__)
+#define c_carray_2(X, Value) \
+ c_carray_3(X, Value, c_default_destroy)
-#define cdef_carray_3(X, Value, valueDestroy) \
+#define c_carray_3(X, Value, valueDestroy) \
\
typedef Value carray1##X##_value_t; \
typedef carray1##X##_value_t carray2##X##_value_t, carray3##X##_value_t; \
@@ -116,9 +116,9 @@ STC_INLINE size_t _carray3_size(const size_t* zdim) {
size_t _xdim, _yxdim, _zdim; \
} carray3##X; \
\
- cdef_carray_common(1, X, Value, valueDestroy) \
- cdef_carray_common(2, X, Value, valueDestroy) \
- cdef_carray_common(3, X, Value, valueDestroy) \
+ c_carray_common(1, X, Value, valueDestroy) \
+ c_carray_common(2, X, Value, valueDestroy) \
+ c_carray_common(3, X, Value, valueDestroy) \
\
STC_INLINE carray1##X \
carray1##X##_make(size_t xdim, Value val) { \
diff --git a/stc/clist.h b/stc/clist.h
index 827d9096..2ab42a38 100644
--- a/stc/clist.h
+++ b/stc/clist.h
@@ -35,7 +35,7 @@
#include <stdio.h>
#include <stc/clist.h>
#include <stc/crandom.h>
- cdef_clist(ix, int64_t);
+ c_clist(ix, int64_t);
int main() {
clist_ix list = clist_ini;
@@ -56,19 +56,19 @@
}
*/
-#define cdef_clist(...) c_MACRO_OVERLOAD(cdef_clist, __VA_ARGS__)
+#define c_clist(...) c_MACRO_OVERLOAD(c_clist, __VA_ARGS__)
-#define cdef_clist_2(X, Value) \
- cdef_clist_3(X, Value, c_default_destroy)
-#define cdef_clist_3(X, Value, valueDestroy) \
- cdef_clist_4(X, Value, valueDestroy, c_default_compare)
-#define cdef_clist_4(X, Value, valueDestroy, valueCompare) \
- cdef_clist_7(X, Value, valueDestroy, Value, \
- valueCompare, c_default_to_raw, c_default_from_raw)
-#define cdef_clist_str() cdef_clist_7(str, cstr_t, cstr_destroy, const char*, \
- cstr_compare_raw, cstr_to_raw, cstr)
+#define c_clist_2(X, Value) \
+ c_clist_3(X, Value, c_default_destroy)
+#define c_clist_3(X, Value, valueDestroy) \
+ c_clist_4(X, Value, valueDestroy, c_default_compare)
+#define c_clist_4(X, Value, valueDestroy, valueCompare) \
+ c_clist_7(X, Value, valueDestroy, Value, \
+ valueCompare, c_default_to_raw, c_default_from_raw)
+#define c_clist_str() c_clist_7(str, cstr_t, cstr_destroy, const char*, \
+ cstr_compare_raw, cstr_to_raw, cstr)
-#define cdef_clist_types(X, Value) \
+#define c_clist_types(X, Value) \
typedef Value clist_##X##_value_t; \
\
typedef struct clist_##X##_node { \
@@ -97,12 +97,12 @@
__pos = ctype##_emplace_after(__self, __pos, __arr[__i]); \
} while (0)
-cdef_clist_types(void, int);
+c_clist_types(void, int);
STC_API size_t _clist_size(const clist_void* self);
-#define cdef_clist_7(X, Value, valueDestroy, RawValue, valueCompareRaw, valueToRaw, valueFromRaw) \
+#define c_clist_7(X, Value, valueDestroy, RawValue, valueCompareRaw, valueToRaw, valueFromRaw) \
\
- cdef_clist_types(X, Value); \
+ c_clist_types(X, Value); \
typedef RawValue clist_##X##_rawvalue_t; \
typedef clist_##X##_rawvalue_t clist_##X##_input_t; \
\
diff --git a/stc/cmap.h b/stc/cmap.h
index 3cc227cf..20147f51 100644
--- a/stc/cmap.h
+++ b/stc/cmap.h
@@ -23,8 +23,8 @@
/*
#include <stdio.h>
#include <stc/cmap.h>
-cdef_cset(sx, int); // Set of int
-cdef_cmap(mx, int, char); // Map of int -> char
+c_cset(sx, int); // Set of int
+c_cmap(mx, int, char); // Map of int -> char
int main(void) {
cset_sx s = cset_ini;
@@ -77,73 +77,73 @@ int main(void) {
enum {chash_HASH = 0x7f, chash_USED = 0x80};
typedef struct {size_t idx; uint32_t hx;} cmap_bucket_t, cset_bucket_t;
-#define cdef_cmap(...) \
- c_MACRO_OVERLOAD(cdef_cmap, __VA_ARGS__)
+#define c_cmap(...) \
+ c_MACRO_OVERLOAD(c_cmap, __VA_ARGS__)
-#define cdef_cmap_3(X, Key, Mapped) \
- cdef_cmap_4(X, Key, Mapped, c_default_destroy)
+#define c_cmap_3(X, Key, Mapped) \
+ c_cmap_4(X, Key, Mapped, c_default_destroy)
-#define cdef_cmap_4(X, Key, Mapped, valueDestroy) \
- cdef_cmap_6(X, Key, Mapped, valueDestroy, c_default_equals, c_default_hash16)
+#define c_cmap_4(X, Key, Mapped, valueDestroy) \
+ c_cmap_6(X, Key, Mapped, valueDestroy, c_default_equals, c_default_hash16)
-#define cdef_cmap_6(X, Key, Mapped, valueDestroy, keyEquals, keyHash) \
- cdef_cmap_10(X, Key, Mapped, valueDestroy, keyEquals, keyHash, \
- c_default_destroy, Key, c_default_to_raw, c_default_from_raw)
+#define c_cmap_6(X, Key, Mapped, valueDestroy, keyEquals, keyHash) \
+ c_cmap_10(X, Key, Mapped, valueDestroy, keyEquals, keyHash, \
+ c_default_destroy, Key, c_default_to_raw, c_default_from_raw)
-#define cdef_cmap_10(X, Key, Mapped, valueDestroy, keyEqualsRaw, keyHashRaw, \
- keyDestroy, RawKey, keyToRaw, keyFromRaw) \
+#define c_cmap_10(X, Key, Mapped, valueDestroy, keyEqualsRaw, keyHashRaw, \
+ keyDestroy, RawKey, keyToRaw, keyFromRaw) \
_declare_CHASH(X, cmap, Key, Mapped, valueDestroy, keyEqualsRaw, keyHashRaw, \
keyDestroy, RawKey, keyToRaw, keyFromRaw, Mapped, c_default_from_raw)
/* cset: */
-#define cdef_cset(...) \
- c_MACRO_OVERLOAD(cdef_cset, __VA_ARGS__)
+#define c_cset(...) \
+ c_MACRO_OVERLOAD(c_cset, __VA_ARGS__)
-#define cdef_cset_2(X, Key) \
- cdef_cset_4(X, Key, c_default_equals, c_default_hash16)
+#define c_cset_2(X, Key) \
+ c_cset_4(X, Key, c_default_equals, c_default_hash16)
-#define cdef_cset_4(X, Key, keyEquals, keyHash) \
- cdef_cset_5(X, Key, keyEquals, keyHash, c_default_destroy)
+#define c_cset_4(X, Key, keyEquals, keyHash) \
+ c_cset_5(X, Key, keyEquals, keyHash, c_default_destroy)
-#define cdef_cset_5(X, Key, keyEquals, keyHash, keyDestroy) \
- cdef_cset_8(X, Key, keyEquals, keyHash, keyDestroy, \
- Key, c_default_to_raw, c_default_from_raw)
+#define c_cset_5(X, Key, keyEquals, keyHash, keyDestroy) \
+ c_cset_8(X, Key, keyEquals, keyHash, keyDestroy, \
+ Key, c_default_to_raw, c_default_from_raw)
-#define cdef_cset_8(X, Key, keyEqualsRaw, keyHashRaw, keyDestroy, \
- RawKey, keyToRaw, keyFromRaw) \
+#define c_cset_8(X, Key, keyEqualsRaw, keyHashRaw, keyDestroy, \
+ RawKey, keyToRaw, keyFromRaw) \
_declare_CHASH(X, cset, Key, Key, void, keyEqualsRaw, keyHashRaw, \
- keyDestroy, RawKey, keyToRaw, keyFromRaw, void, c_default_from_raw)
+ keyDestroy, RawKey, keyToRaw, keyFromRaw, void, c_default_from_raw)
/* cset_str, cmap_str, cmap_strkey, cmap_strval: */
-#define cdef_cset_str() \
+#define c_cset_str() \
_declare_CHASH_strkey(str, cset, cstr_t, void)
-#define cdef_cmap_str() \
+#define c_cmap_str() \
_declare_CHASH(str, cmap, cstr_t, cstr_t, cstr_destroy, cstr_equals_raw, cstr_hash_raw, \
- cstr_destroy, const char*, cstr_to_raw, cstr, const char*, cstr)
+ cstr_destroy, const char*, cstr_to_raw, cstr, const char*, cstr)
-#define cdef_cmap_strkey(...) \
- c_MACRO_OVERLOAD(cdef_cmap_strkey, __VA_ARGS__)
+#define c_cmap_strkey(...) \
+ c_MACRO_OVERLOAD(c_cmap_strkey, __VA_ARGS__)
-#define cdef_cmap_strkey_2(X, Mapped) \
+#define c_cmap_strkey_2(X, Mapped) \
_declare_CHASH_strkey(X, cmap, Mapped, c_default_destroy)
-#define cdef_cmap_strkey_3(X, Mapped, ValueDestroy) \
+#define c_cmap_strkey_3(X, Mapped, ValueDestroy) \
_declare_CHASH_strkey(X, cmap, Mapped, ValueDestroy)
-#define cdef_cmap_strval(...) \
- c_MACRO_OVERLOAD(cdef_cmap_strval, __VA_ARGS__)
+#define c_cmap_strval(...) \
+ c_MACRO_OVERLOAD(c_cmap_strval, __VA_ARGS__)
-#define cdef_cmap_strval_2(X, Key) \
- cdef_cmap_strval_4(X, Key, c_default_equals, c_default_hash16)
+#define c_cmap_strval_2(X, Key) \
+ c_cmap_strval_4(X, Key, c_default_equals, c_default_hash16)
-#define cdef_cmap_strval_4(X, Key, keyEquals, keyHash) \
+#define c_cmap_strval_4(X, Key, keyEquals, keyHash) \
_declare_CHASH(X, cmap, Key, cstr_t, cstr_destroy, keyEquals, keyHash, \
- c_default_destroy, Key, c_default_to_raw, c_default_from_raw, const char*, cstr)
+ c_default_destroy, Key, c_default_to_raw, c_default_from_raw, const char*, cstr)
#define _declare_CHASH_strkey(X, ctype, Mapped, valueDestroy) \
_declare_CHASH(X, ctype, cstr_t, Mapped, valueDestroy, cstr_equals_raw, cstr_hash_raw, \
- cstr_destroy, const char*, cstr_to_raw, cstr, Mapped, c_default_from_raw)
+ cstr_destroy, const char*, cstr_to_raw, cstr, Mapped, c_default_from_raw)
#define CSET_ONLY_cset(...) __VA_ARGS__
#define CSET_ONLY_cmap(...)
diff --git a/stc/cpqueue.h b/stc/cpqueue.h
index d5f5a9e6..e65c67e0 100644
--- a/stc/cpqueue.h
+++ b/stc/cpqueue.h
@@ -25,8 +25,8 @@
#include <stc/crandom.h>
#include <stc/cpqueue.h>
- cdef_cvec(f, float);
- cdef_cpqueue(f, cvec_f, >); // min-heap (increasing values)
+ c_cvec(f, float);
+ c_cpqueue(f, cvec_f, >); // min-heap (increasing values)
int main() {
crand_rng32_t gen = crand_rng32_init(1234);
@@ -50,7 +50,7 @@
#include "cvec.h"
-#define cdef_cpqueue(X, ctype, cmpOpr) /* cmpOpr: < or > */ \
+#define c_cpqueue(X, ctype, cmpOpr) /* cmpOpr: < or > */ \
\
typedef struct ctype cpqueue_##X; \
typedef ctype##_value_t cpqueue_##X##_value_t; \
diff --git a/stc/cqueue.h b/stc/cqueue.h
index dfdab1cd..c4e095d8 100644
--- a/stc/cqueue.h
+++ b/stc/cqueue.h
@@ -25,8 +25,8 @@
#include <stc/crandom.h>
#include <stc/cqueue.h>
- cdef_clist(i, int);
- cdef_cqueue(i, clist_i); // min-heap (increasing values)
+ c_clist(i, int);
+ c_cqueue(i, clist_i); // min-heap (increasing values)
int main() {
int n = 10000000;
@@ -58,7 +58,7 @@
#include "clist.h"
-#define cdef_cqueue(X, ctype) \
+#define c_cqueue(X, ctype) \
\
typedef struct ctype cqueue_##X; \
typedef ctype##_value_t cqueue_##X##_value_t; \
diff --git a/stc/cstack.h b/stc/cstack.h
index 65ccc45f..97e7a0e2 100644
--- a/stc/cstack.h
+++ b/stc/cstack.h
@@ -26,8 +26,8 @@
#include <stc/cstack.h>
#include <stdio.h>
- cdef_cvec(i, int);
- cdef_cstack(i, cvec_i);
+ c_cvec(i, int);
+ c_cstack(i, cvec_i);
int main() {
cstack_i stack = cstack_i_init();
@@ -47,7 +47,7 @@
#include "cvec.h"
-#define cdef_cstack(X, ctype) \
+#define c_cstack(X, ctype) \
\
typedef struct ctype cstack_##X; \
typedef ctype##_value_t cstack_##X##_value_t; \
diff --git a/stc/cvec.h b/stc/cvec.h
index 1adb3cca..bc6c2ab3 100644
--- a/stc/cvec.h
+++ b/stc/cvec.h
@@ -32,18 +32,18 @@
#define cvec_capacity(v) _cvec_safe_capacity((v).data)
#define cvec_empty(v) (cvec_size(v) == 0)
-#define cdef_cvec(...) c_MACRO_OVERLOAD(cdef_cvec, __VA_ARGS__)
-#define cdef_cvec_2(X, Value) \
- cdef_cvec_3(X, Value, c_default_destroy)
-#define cdef_cvec_3(X, Value, valueDestroy) \
- cdef_cvec_4(X, Value, valueDestroy, c_default_compare)
-#define cdef_cvec_4(X, Value, valueDestroy, valueCompare) \
- cdef_cvec_7(X, Value, valueDestroy, valueCompare, Value, c_default_to_raw, c_default_from_raw)
-#define cdef_cvec_str() \
- cdef_cvec_7(str, cstr_t, cstr_destroy, cstr_compare_raw, const char*, cstr_to_raw, cstr)
+#define c_cvec(...) c_MACRO_OVERLOAD(c_cvec, __VA_ARGS__)
+#define c_cvec_2(X, Value) \
+ c_cvec_3(X, Value, c_default_destroy)
+#define c_cvec_3(X, Value, valueDestroy) \
+ c_cvec_4(X, Value, valueDestroy, c_default_compare)
+#define c_cvec_4(X, Value, valueDestroy, valueCompare) \
+ c_cvec_7(X, Value, valueDestroy, valueCompare, Value, c_default_to_raw, c_default_from_raw)
+#define c_cvec_str() \
+ c_cvec_7(str, cstr_t, cstr_destroy, cstr_compare_raw, const char*, cstr_to_raw, cstr)
-#define cdef_cvec_7(X, Value, valueDestroy, valueCompareRaw, RawValue, valueToRaw, valueFromRaw) \
+#define c_cvec_7(X, Value, valueDestroy, valueCompareRaw, RawValue, valueToRaw, valueFromRaw) \
\
typedef struct cvec_##X { \
Value* data; \