summaryrefslogtreecommitdiffhomepage
path: root/examples
diff options
context:
space:
mode:
authorTyge Løvset <[email protected]>2020-07-28 06:47:33 +0200
committerTyge Løvset <[email protected]>2020-07-28 06:47:33 +0200
commitb818bb967c6050d14a9c7058f02592a4ffeef9b4 (patch)
treec55c74d129692fdc6ab93d934fc252c7c8acbef7 /examples
parentb5351558ac6d5f78750fe93ed9390fed5efa2ac4 (diff)
downloadSTC-modified-b818bb967c6050d14a9c7058f02592a4ffeef9b4.tar.gz
STC-modified-b818bb967c6050d14a9c7058f02592a4ffeef9b4.zip
Lowercase naming
Diffstat (limited to 'examples')
-rw-r--r--examples/README.md6
-rw-r--r--examples/advanced.c6
-rw-r--r--examples/benchmark.c14
-rw-r--r--examples/bits.c12
-rw-r--r--examples/complex.c4
-rw-r--r--examples/demos.c26
-rw-r--r--examples/geek2.c2
-rw-r--r--examples/geek3.c2
-rw-r--r--examples/geek4.c20
-rw-r--r--examples/geek5.c4
-rw-r--r--examples/geek7.c2
-rw-r--r--examples/heap.c2
-rw-r--r--examples/inits.c6
-rw-r--r--examples/list.c2
-rw-r--r--examples/prime.c2
15 files changed, 55 insertions, 55 deletions
diff --git a/examples/README.md b/examples/README.md
index e222f8bc..ededc828 100644
--- a/examples/README.md
+++ b/examples/README.md
@@ -40,8 +40,8 @@ int vikingvw_equals(const VikingVw* x, const VikingVw* y) {
And the Viking data struct:
```
typedef struct Viking {
- cstr_t name;
- cstr_t country;
+ cstr name;
+ cstr country;
} Viking;
@@ -60,7 +60,7 @@ Viking viking_fromVw(VikingVw vw) {
```
With this in place, we use the full declare_cmap() macro to define {Viking -> int} hash map type:
```
-declare_cmap(vk, Viking, int, c_defaultDestroy, vikingvw_equals, vikingvw_hash,
+declare_cmap(vk, Viking, int, c_default_destroy, vikingvw_equals, vikingvw_hash,
viking_destroy, VikingVw, viking_getVw, 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 b5481f94..bba534ca 100644
--- a/examples/advanced.c
+++ b/examples/advanced.c
@@ -34,8 +34,8 @@ int vikingvw_equals(const VikingVw* x, const VikingVw* y) {
// Viking data struct -----------------------
typedef struct Viking {
- cstr_t name;
- cstr_t country;
+ cstr name;
+ cstr country;
} Viking;
@@ -53,7 +53,7 @@ Viking viking_fromVw(VikingVw vw) {
// Using the full declare_cmap() macro to define [Viking -> int] hash map type:
-declare_cmap(vk, Viking, int, c_defaultDestroy, vikingvw_equals, vikingvw_hash,
+declare_cmap(vk, Viking, int, c_default_destroy, vikingvw_equals, vikingvw_hash,
viking_destroy, VikingVw, viking_getVw, 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 7ac6481e..568ba880 100644
--- a/examples/benchmark.c
+++ b/examples/benchmark.c
@@ -14,12 +14,12 @@
// Visual Studio: compile with -TP to force C++: cl -TP -EHsc -O2 benchmark.c
-declare_cmap(ii, int64_t, int64_t, c_defaultDestroy, c_defaultEquals, c_fibonacciHash64);
+declare_cmap(ii, int64_t, int64_t, c_default_destroy, c_default_equals, c_fibonacci_hash64);
KHASH_MAP_INIT_INT64(ii, uint64_t)
size_t seed;
-static const float maxLoadFactor = 0.77f;
+static const float max_load_factor = 0.77f;
crandom64_t rng;
#define SEED(s) rng = crandom64_uniform_engine(seed)
@@ -27,12 +27,12 @@ crandom64_t rng;
#define CMAP_SETUP(tag, Key, Value) cmap_##tag map = cmap_init \
- ; cmap_##tag##_setLoadFactors(&map, maxLoadFactor, 0.0)
+ ; cmap_##tag##_set_load_factors(&map, max_load_factor, 0.0)
#define CMAP_PUT(tag, key, val) cmap_##tag##_put(&map, key, val)->value
#define CMAP_ERASE(tag, key) cmap_##tag##_erase(&map, key)
#define CMAP_FIND(tag, key) (cmap_##tag##_find(map, key) != NULL)
#define CMAP_SIZE(tag) cmap_size(map)
-#define CMAP_BUCKETS(tag) (map).bucketCount
+#define CMAP_BUCKETS(tag) (map).bucket_count
#define CMAP_CLEAR(tag) cmap_##tag##_destroy(&map)
#define KMAP_SETUP(tag, Key, Value) khash_t(ii)* map = kh_init(ii); khiter_t ki; int ret
@@ -43,7 +43,7 @@ crandom64_t rng;
#define KMAP_BUCKETS(tag) ((size_t) kh_n_buckets(map))
#define KMAP_CLEAR(tag) kh_destroy(ii, map)
-#define UMAP_SETUP(tag, Key, Value) std::unordered_map<Key, Value> map; map.max_load_factor(maxLoadFactor)
+#define UMAP_SETUP(tag, Key, Value) std::unordered_map<Key, Value> map; map.max_load_factor(max_load_factor)
#define UMAP_PUT(tag, key, val) (map[key] = val)
#define UMAP_FIND(tag, key) (map.find(key) != map.end())
#define UMAP_ERASE(tag, key) map.erase(key)
@@ -51,7 +51,7 @@ crandom64_t rng;
#define UMAP_BUCKETS(tag) map.bucket_count()
#define UMAP_CLEAR(tag) map.clear()
-#define BMAP_SETUP(tag, Key, Value) ska::bytell_hash_map<Key, Value> map; map.max_load_factor(maxLoadFactor)
+#define BMAP_SETUP(tag, Key, Value) ska::bytell_hash_map<Key, Value> map; map.max_load_factor(max_load_factor)
#define BMAP_PUT(tag, key, val) (map[key] = val)
#define BMAP_FIND(tag, key) (map.find(key) != map.end())
#define BMAP_ERASE(tag, key) map.erase(key)
@@ -59,7 +59,7 @@ crandom64_t rng;
#define BMAP_BUCKETS(tag) map.bucket_count()
#define BMAP_CLEAR(tag) map.clear()
-#define FMAP_SETUP(tag, Key, Value) ska::flat_hash_map<Key, Value> map; map.max_load_factor(maxLoadFactor)
+#define FMAP_SETUP(tag, Key, Value) ska::flat_hash_map<Key, Value> map; map.max_load_factor(max_load_factor)
#define FMAP_PUT(tag, key, val) (map[key] = val)
#define FMAP_FIND(tag, key) (map.find(key) != map.end())
#define FMAP_ERASE(tag, key) map.erase(key)
diff --git a/examples/bits.c b/examples/bits.c
index 7c048c80..fd074232 100644
--- a/examples/bits.c
+++ b/examples/bits.c
@@ -2,7 +2,7 @@
#include <stc/cbitset.h>
int main() {
- cbitset_t set = cbitset_make(23, true);
+ cbitset set = cbitset_make(23, true);
printf("count %zu, %zu\n", cbitset_count(set), set.size);
cbitset_reset(&set, 9);
cbitset_resize(&set, 43, false);
@@ -15,14 +15,14 @@ int main() {
cbitset_resize(&set, 77, true);
cbitset_resize(&set, 93, false);
cbitset_resize(&set, 102, true);
- cbitset_setTo(&set, 99, false);
+ cbitset_set_to(&set, 99, false);
printf("%4zu: ", set.size);
for (int i=0; i<set.size; ++i)
printf("%d", cbitset_test(set, i));
puts("");
- cbitset_t s2 = cbitset_from(set);
- cbitset_flipAll(&s2);
+ cbitset s2 = cbitset_from(set);
+ cbitset_flip_all(&s2);
cbitset_set(&s2, 16);
cbitset_set(&s2, 17);
cbitset_set(&s2, 18);
@@ -32,12 +32,12 @@ int main() {
puts("");
printf(" xor: ");
- cbitset_setXor(&set, s2);
+ cbitset_set_xor(&set, s2);
for (int i=0; i<set.size; ++i)
printf("%d", cbitset_test(set, i));
puts("");
- cbitset_setAll(&set, false);
+ cbitset_set_all(&set, false);
printf("%4zu: ", set.size);
for (int i=0; i<set.size; ++i)
printf("%d", cbitset_test(set, i));
diff --git a/examples/complex.c b/examples/complex.c
index 87caaa4e..6a6a268b 100644
--- a/examples/complex.c
+++ b/examples/complex.c
@@ -6,7 +6,7 @@
void check_destroy(float* v) {printf("destroy %g\n", *v);}
declare_carray(f, float, check_destroy); // normally omit the last argument - float type need no destroy.
-declare_clist(t2, carray2f, carray2f_destroy, c_noCompare);
+declare_clist(t2, carray2f, carray2f_destroy, c_no_compare);
declare_cmap(il, int, clist_t2, clist_t2_destroy);
declare_cmap_str(sm, cmap_il, cmap_il_destroy);
@@ -24,7 +24,7 @@ int main() {
// Put in some data.
carray2f_data(table, y)[x] = 3.1415927; // table[y][x]
- clist_t2_pushBack(&tableList, table);
+ clist_t2_push_back(&tableList, table);
cmap_il_put(&listMap, tableKey, tableList);
cmap_sm_put(&theMap, strKey, listMap);
}
diff --git a/examples/demos.c b/examples/demos.c
index 3a29f7d6..845f0cf0 100644
--- a/examples/demos.c
+++ b/examples/demos.c
@@ -8,7 +8,7 @@
void stringdemo1()
{
printf("\nSTRINGDEMO1\n");
- cstr_t cs = cstr_make("one-nine-three-seven-five");
+ cstr cs = cstr_make("one-nine-three-seven-five");
printf("%s.\n", cs.str);
cstr_insert(&cs, 3, "-two");
@@ -41,10 +41,10 @@ void vectordemo1()
cvec_ix bignums = cvec_init; // = (cvec_ix) cvec_init; if initializing after declaration.
cvec_ix_reserve(&bignums, 100);
for (size_t i = 0; i<=100; ++i)
- cvec_ix_pushBack(&bignums, i * i * i);
+ cvec_ix_push_back(&bignums, i * i * i);
printf("erase - %d: %zu\n", 100, bignums.data[100]);
- cvec_ix_popBack(&bignums); // erase the last
+ cvec_ix_pop_back(&bignums); // erase the last
for (size_t i = 0; i < cvec_size(bignums); ++i) {
if (i >= 90) printf("%zu: %zu\n", i, bignums.data[i]);
@@ -54,15 +54,15 @@ void vectordemo1()
-declare_cvec(cs, cstr_t, cstr_destroy, cstr_compare); // supply inline destructor of values
+declare_cvec(cs, cstr, cstr_destroy, cstr_compare); // supply inline destructor of values
void vectordemo2()
{
printf("\nVECTORDEMO2\n");
cvec_cs names = cvec_init;
- cvec_cs_pushBack(&names, cstr_make("Mary"));
- cvec_cs_pushBack(&names, cstr_make("Joe"));
- cvec_cs_pushBack(&names, cstr_make("Chris"));
+ cvec_cs_push_back(&names, cstr_make("Mary"));
+ cvec_cs_push_back(&names, cstr_make("Joe"));
+ cvec_cs_push_back(&names, cstr_make("Chris"));
cstr_assign(&names.data[1], "Jane"); // replace Joe
printf("names[1]: %s\n", names.data[1].str);
@@ -79,21 +79,21 @@ void listdemo1()
printf("\nLISTDEMO1\n");
clist_ix nums = clist_init, nums2 = clist_init;
for (int i = 0; i < 10; ++i)
- clist_ix_pushBack(&nums, i);
+ clist_ix_push_back(&nums, i);
for (int i = 100; i < 110; ++i)
- clist_ix_pushBack(&nums2, i);
+ clist_ix_push_back(&nums2, i);
c_foreach (i, clist_ix, nums)
printf("value: %d\n", i.item->value);
/* merge/append nums2 to nums */
- clist_ix_spliceAfter(&nums, clist_ix_last(&nums), &nums2);
+ clist_ix_splice_after(&nums, clist_ix_last(&nums), &nums2);
c_foreach (i, clist_ix, nums)
printf("spliced: %d\n", i.item->value);
*clist_ix_find(&nums, 100) *= 10;
clist_ix_sort(&nums); // Sort the array
clist_ix_remove(&nums, 105);
- clist_ix_popFront(&nums);
- clist_ix_pushFront(&nums, -99);
+ clist_ix_pop_front(&nums);
+ clist_ix_push_front(&nums, -99);
c_foreach (i, clist_ix, nums)
printf("sorted: %d\n", i.item->value);
clist_ix_destroy(&nums);
@@ -150,7 +150,7 @@ void mapdemo2()
}
-declare_cmap_str(ss, cstr_t, cstr_destroy);
+declare_cmap_str(ss, cstr, cstr_destroy);
void mapdemo3()
{
diff --git a/examples/geek2.c b/examples/geek2.c
index 988f1f98..c3a9ddfc 100644
--- a/examples/geek2.c
+++ b/examples/geek2.c
@@ -3,7 +3,7 @@
#include <stc/cmap.h>
#include <stc/cstr.h>
-declare_cmap_str(ss, cstr_t, cstr_destroy);
+declare_cmap_str(ss, cstr, cstr_destroy);
declare_cset_str();
int main()
diff --git a/examples/geek3.c b/examples/geek3.c
index b8de97c8..4c53a026 100644
--- a/examples/geek3.c
+++ b/examples/geek3.c
@@ -4,7 +4,7 @@
#include <stc/cstr.h>
declare_cmap_str(si, int);
-declare_cmap_str(ss, cstr_t, cstr_destroy);
+declare_cmap_str(ss, cstr, cstr_destroy);
int main ()
{
diff --git a/examples/geek4.c b/examples/geek4.c
index 87f9b919..dcf7edbf 100644
--- a/examples/geek4.c
+++ b/examples/geek4.c
@@ -39,7 +39,7 @@ Efficient Approach: For all the words of the first sentence, we can check if it
declare_cvec_str();
declare_cmap_str(sb, bool);
-declare_cvec(sb, cmapentry_sb, cmapentry_sb_destroy, c_noCompare);
+declare_cvec(sb, cmapentry_sb, cmapentry_sb_destroy, c_no_compare);
// Function to return the count of common words
// in all the sentences
@@ -59,11 +59,11 @@ int commonWords(cvec_str S)
// Extract all words of first string and store it in ans
while (i < cstr_size(S.data[0])) {
// To store separate words
- cstr_t word = cstr_init;
+ cstr word = cstr_init;
cmapentry_sb tmp = {cstr_init, false};
while (i < cstr_size(S.data[0]) && S.data[0].str[i] != ' ') {
- cstr_pushBack(&word, S.data[0].str[i]);
+ cstr_push_back(&word, S.data[0].str[i]);
i++;
}
@@ -75,7 +75,7 @@ int commonWords(cvec_str S)
if (!cstr_empty(word)) {
tmp.key = cstr_move(&word);
tmp.value = true;
- cvec_sb_pushBack(&ans, tmp);
+ cvec_sb_push_back(&ans, tmp);
}
}
@@ -89,9 +89,9 @@ int commonWords(cvec_str S)
i = 0;
while (i < cstr_size(S.data[j])) {
- cstr_t word = cstr_init;
+ cstr word = cstr_init;
while (i < cstr_size(S.data[j]) && S.data[j].str[i] != ' ') {
- cstr_pushBack(&word, S.data[j].str[i]);
+ cstr_push_back(&word, S.data[j].str[i]);
i++;
}
i++;
@@ -137,10 +137,10 @@ int commonWords(cvec_str S)
int main()
{
cvec_str S = cvec_init;
- cvec_str_pushBack(&S, cstr_make("there is a cow"));
- cvec_str_pushBack(&S, cstr_make("cow is our mother"));
- cvec_str_pushBack(&S, cstr_make("cow gives us milk and milk is sweet"));
- cvec_str_pushBack(&S, cstr_make("there is a boy who loves cow"));
+ cvec_str_push_back(&S, cstr_make("there is a cow"));
+ cvec_str_push_back(&S, cstr_make("cow is our mother"));
+ cvec_str_push_back(&S, cstr_make("cow gives us milk and milk is sweet"));
+ cvec_str_push_back(&S, cstr_make("there is a boy who loves cow"));
printf("%d\n", commonWords(S));
cvec_str_destroy(&S);
diff --git a/examples/geek5.c b/examples/geek5.c
index b1e2f2b9..d9885293 100644
--- a/examples/geek5.c
+++ b/examples/geek5.c
@@ -39,11 +39,11 @@ int NumOccurrences(const char* arr[], int n, const char* str, int L, int R)
// then create the entry
if (it == NULL) {
cvec_i A = cvec_init;
- cvec_i_pushBack(&A, i + 1);
+ cvec_i_push_back(&A, i + 1);
cmap_sv_put(&M, temp, A);
}
else {
- cvec_i_pushBack(&it->value, i + 1);
+ cvec_i_push_back(&it->value, i + 1);
}
}
diff --git a/examples/geek7.c b/examples/geek7.c
index 88cfa33c..36805dce 100644
--- a/examples/geek7.c
+++ b/examples/geek7.c
@@ -57,7 +57,7 @@ void findElementsAfterDel(int arr[], int m, int del[],
// If the frequency becomes 0,
// erase it from the map
if (e->value == 0)
- cmap_ii_eraseEntry(&mp, e);
+ cmap_ii_erase_entry(&mp, e);
}
// Else push it in the min heap
diff --git a/examples/heap.c b/examples/heap.c
index f91642ac..857ff1fb 100644
--- a/examples/heap.c
+++ b/examples/heap.c
@@ -14,7 +14,7 @@ int main()
cvec_f vec = cvec_init;
clock_t start = clock();
for (int i=0; i<N; ++i)
- cvec_f_pushBack(&vec, crandom32_uniform_int(&pcg));
+ cvec_f_push_back(&vec, crandom32_uniform_int(&pcg));
cvecpq_f_build(&vec);
printf("Built priority queue: %f secs\n", (clock() - start) / (float) CLOCKS_PER_SEC);
diff --git a/examples/inits.c b/examples/inits.c
index 5f8563c7..c7758926 100644
--- a/examples/inits.c
+++ b/examples/inits.c
@@ -4,12 +4,12 @@
#include <stc/cvec.h>
#include <stc/clist.h>
-declare_cmap(id, int, cstr_t, cstr_destroy); // Map of int -> cstr_t
+declare_cmap(id, int, cstr, cstr_destroy); // Map of int -> cstr
declare_cmap_str(cnt, int);
typedef struct {int x, y;} ipair_t;
-declare_cvec(ip, ipair_t, c_defaultDestroy, c_memCompare);
-declare_clist(ip, ipair_t, c_defaultDestroy, c_memCompare);
+declare_cvec(ip, ipair_t, c_default_destroy, c_mem_compare);
+declare_clist(ip, ipair_t, c_default_destroy, c_mem_compare);
int main(void) {
diff --git a/examples/list.c b/examples/list.c
index 2c8d17cd..352965b2 100644
--- a/examples/list.c
+++ b/examples/list.c
@@ -9,7 +9,7 @@ int main() {
crandom32_t pcg = crandom32_uniform_engine(time(NULL));
int n;
for (int i=0; i<10000000; ++i) // ten million
- clist_ix_pushBack(&list, crandom32_uniform_int(&pcg));
+ clist_ix_push_back(&list, crandom32_uniform_int(&pcg));
n = 100;
c_foreach (i, clist_ix, list)
if (n--) printf("%8d: %10zu\n", 100 - n, i.item->value); else break;
diff --git a/examples/prime.c b/examples/prime.c
index 611690ac..463203d2 100644
--- a/examples/prime.c
+++ b/examples/prime.c
@@ -10,7 +10,7 @@
static inline void sieveOfEratosthenes(size_t n)
{
- cbitset_t prime = cbitset_make(n + 1, true);
+ cbitset prime = cbitset_make(n + 1, true);
printf("computing prime numbers up to %zu\n", n);
cbitset_reset(&prime, 0);
cbitset_reset(&prime, 1);