summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorTyge Løvset <[email protected]>2021-01-21 08:26:54 +0100
committerTyge Løvset <[email protected]>2021-01-21 08:26:54 +0100
commit50da396d04714a18fa087ebbd1f2316958dbd6bd (patch)
tree0349909bf35183e2eced05ca0d3ce909f700c23e
parent9473eae780011ef520066ddcd36bb555e8e616e4 (diff)
downloadSTC-modified-50da396d04714a18fa087ebbd1f2316958dbd6bd.tar.gz
STC-modified-50da396d04714a18fa087ebbd1f2316958dbd6bd.zip
Reverted namings: crand to crandom, and copt to coption.
-rw-r--r--README.md2
-rw-r--r--benchmarks/cdeq_benchmark.cpp2
-rw-r--r--benchmarks/cmap_benchmark.cpp2
-rw-r--r--benchmarks/cmap_benchmark2.cpp2
-rw-r--r--benchmarks/cpque_benchmark.cpp2
-rw-r--r--benchmarks/crand_benchmark.cpp2
-rw-r--r--benchmarks/crand_benchmark2.cpp2
-rw-r--r--benchmarks/vector_vs_deque.cpp2
-rw-r--r--docs/coption_api.md (renamed from docs/copt_api.md)30
-rw-r--r--docs/cpque_api.md2
-rw-r--r--docs/crandom_api.md (renamed from docs/crand_api.md)8
-rw-r--r--examples/birthday.c2
-rw-r--r--examples/cbits_prime.c39
-rw-r--r--examples/crandom_ex.c51
-rw-r--r--examples/csmap_ex.c2
-rw-r--r--examples/ex_gauss1.c2
-rw-r--r--examples/ex_gauss2.c2
-rw-r--r--examples/list.c2
-rw-r--r--examples/phonebook.c72
-rw-r--r--examples/priority.c2
-rw-r--r--examples/queue.c2
-rw-r--r--examples/random.c2
-rw-r--r--stc/clist.h2
-rw-r--r--stc/coption.h (renamed from stc/copt.h)30
-rw-r--r--stc/cpque.h2
-rw-r--r--stc/cqueue.h2
-rw-r--r--stc/crandom.h (renamed from stc/crand.h)6
27 files changed, 219 insertions, 57 deletions
diff --git a/README.md b/README.md
index 11b98ff9..8cbf2b82 100644
--- a/README.md
+++ b/README.md
@@ -26,7 +26,7 @@ This is a compact headers-only library with the all of the "standard" data conta
Others:
- [***ccommon*** - General definitions](docs/ccommon_api.md)
- [***copt*** - Implements ***copt_get()***, similar to posix **getopt_long()**](docs/copt_api.md)
-- [***crand*** - A very efficent modern **pseudo-random number generator**](docs/crand_api.md)
+- [***crandom*** - A very efficent modern **pseudo-random number generator**](docs/crandom_api.md)
The usage of the containers is similar to the c++ standard containers in STL, so it should be easy if you are familiar with them.
All containers mentioned above are generic, except for **cstr** and **cbits**. No casting is used, and containers are therefore
diff --git a/benchmarks/cdeq_benchmark.cpp b/benchmarks/cdeq_benchmark.cpp
index f44a40a6..ea1c69b3 100644
--- a/benchmarks/cdeq_benchmark.cpp
+++ b/benchmarks/cdeq_benchmark.cpp
@@ -3,7 +3,7 @@
#include <deque>
#include <vector>
#include <stc/cdeq.h>
-#include <stc/crand.h>
+#include <stc/crandom.h>
enum {N = 1000000000, M = 12345, P = 5000, R = 2000};
using_cdeq(i, int);
diff --git a/benchmarks/cmap_benchmark.cpp b/benchmarks/cmap_benchmark.cpp
index 47f60b00..967c8abe 100644
--- a/benchmarks/cmap_benchmark.cpp
+++ b/benchmarks/cmap_benchmark.cpp
@@ -1,6 +1,6 @@
#include <stdio.h>
#include <time.h>
-#include <stc/crand.h>
+#include <stc/crandom.h>
#include <stc/cstr.h>
#include <stc/cmap.h>
#include "others/khash.h"
diff --git a/benchmarks/cmap_benchmark2.cpp b/benchmarks/cmap_benchmark2.cpp
index 33f5c675..54d6e7d9 100644
--- a/benchmarks/cmap_benchmark2.cpp
+++ b/benchmarks/cmap_benchmark2.cpp
@@ -1,4 +1,4 @@
-#include <stc/crand.h>
+#include <stc/crandom.h>
#include <stc/cstr.h>
#include <stc/cmap.h>
#include <cmath>
diff --git a/benchmarks/cpque_benchmark.cpp b/benchmarks/cpque_benchmark.cpp
index 396d763d..d3c00803 100644
--- a/benchmarks/cpque_benchmark.cpp
+++ b/benchmarks/cpque_benchmark.cpp
@@ -1,6 +1,6 @@
#include <stdio.h>
#include <time.h>
-#include <stc/crand.h>
+#include <stc/crandom.h>
#include <stc/cvec.h>
#include <stc/cpque.h>
diff --git a/benchmarks/crand_benchmark.cpp b/benchmarks/crand_benchmark.cpp
index 3d42c62b..136dcf30 100644
--- a/benchmarks/crand_benchmark.cpp
+++ b/benchmarks/crand_benchmark.cpp
@@ -1,7 +1,7 @@
#include <cstdint>
#include <iostream>
#include <ctime>
-#include <stc/crand.h>
+#include <stc/crandom.h>
static inline uint64_t rotl64(const uint64_t x, const int k)
{ return (x << k) | (x >> (64 - k)); }
diff --git a/benchmarks/crand_benchmark2.cpp b/benchmarks/crand_benchmark2.cpp
index 2692e760..6a517a0b 100644
--- a/benchmarks/crand_benchmark2.cpp
+++ b/benchmarks/crand_benchmark2.cpp
@@ -1,7 +1,7 @@
#include <stdio.h>
#include <time.h>
#include <random>
-#include "stc/crand.h"
+#include "stc/crandom.h"
#include "others/pcg_random.hpp"
static struct stc32_state { stc64_t rng; uint64_t spare; unsigned n; } stc32_global =
diff --git a/benchmarks/vector_vs_deque.cpp b/benchmarks/vector_vs_deque.cpp
index c9e612f2..a488b7ab 100644
--- a/benchmarks/vector_vs_deque.cpp
+++ b/benchmarks/vector_vs_deque.cpp
@@ -8,7 +8,7 @@
#include <stc/cvec.h>
#include <stc/cdeq.h>
#include <stc/cstr.h>
-#include <stc/crand.h>
+#include <stc/crandom.h>
typedef struct {const char* first; int second;} Si;
using_cvec(si, Si, c_no_compare);
diff --git a/docs/copt_api.md b/docs/coption_api.md
index df49f66d..66038b38 100644
--- a/docs/copt_api.md
+++ b/docs/coption_api.md
@@ -1,6 +1,6 @@
-# STC Module [copt](../stc/copt.h): Command line argument parsing
+# STC Module [copt](../stc/coption.h): Command line argument parsing
-This describes the API of the *copt_get()* function for command line argument parsing.
+This describes the API of the *coption_get()* function for command line argument parsing.
See [getopt_long](https://www.freebsd.org/cgi/man.cgi?getopt_long(3)) for a similar posix function.
## Types
@@ -12,39 +12,39 @@ enum {
copt_optional_argument = 2
};
typedef struct {
- int ind; /* equivalent to optind */
- int opt; /* equivalent to optopt */
- const char *arg; /* equivalent to optarg */
+ int ind; /* equivalent to posix optind */
+ int opt; /* equivalent to posix optopt */
+ const char *arg; /* equivalent to posix optarg */
const char *faulty; /* points to the faulty option, if any */
int longindex; /* index of long option; or -1 if short */
...
-} copt_t;
+} coption;
typedef struct {
const char *name;
int has_arg;
int val;
-} copt_long_t;
+} coption_long;
-const copt_t copt_inits;
+const coption coption_inits;
```
## Methods
```c
-copt_t copt_init(void);
-int copt_get(copt_t *opt, int argc, char *argv[],
- const char *shortopts, const copt_long_t *longopts);
+coption coption_init(void);
+int coption_get(coption *opt, int argc, char *argv[],
+ const char *shortopts, const coption_long *longopts);
```
## Example
```c
#include <stdio.h>
-#include "stc/copt.h"
+#include "stc/coption.h"
int main(int argc, char *argv[]) {
- static copt_long_t long_options[] = {
+ static coption_long long_options[] = {
{"verbose", copt_no_argument, 'V'},
{"help", copt_no_argument, 'H'},
{"add", copt_no_argument, 'a'},
@@ -54,9 +54,9 @@ int main(int argc, char *argv[]) {
{"file", copt_required_argument, 'f'},
{NULL}
};
- copt_t opt = copt_inits;
+ coption opt = coption_init();
int c;
- while ((c = copt_get(&opt, argc, argv, ":if:lr", long_options)) != -1) {
+ while ((c = coption_get(&opt, argc, argv, ":if:lr", long_options)) != -1) {
switch (c) {
case 'V': case 'H':
case 'a': case 'b':
diff --git a/docs/cpque_api.md b/docs/cpque_api.md
index 59203a63..080d580e 100644
--- a/docs/cpque_api.md
+++ b/docs/cpque_api.md
@@ -60,7 +60,7 @@ cpque_X_value_t cpque_X_value_clone(cpque_X_value_t val);
```c
#include <stdio.h>
#include "stc/cpque.h"
-#include "stc/crand.h"
+#include "stc/crandom.h"
using_cvec(i, int64_t);
using_cpque(i, cvec_i, >); // adaptor type, '>' = min-heap
diff --git a/docs/crand_api.md b/docs/crandom_api.md
index 995c5fa0..c8ad34ff 100644
--- a/docs/crand_api.md
+++ b/docs/crandom_api.md
@@ -1,7 +1,7 @@
-# STC Module [crand](../stc/crand.h): Pseudo Random Number Generators
+# STC Module [crandom](../stc/crandom.h): Pseudo Random Number Generators
![Random](pics/random.jpg)
-This describes the API of module **crand**. It contains **stc64**, a *64-bit PRNG*, and can generate
+This describes the API of module **crandom**. It contains **stc64**, a *64-bit PRNG*, and can generate
bounded uniform and normal distributed random numbers. See [random](https://en.cppreference.com/w/cpp/header/random)
for similar c++ functionality.
@@ -34,7 +34,7 @@ xoshiro and pcg (Vigna/O'Neill) PRNGs: https://www.pcg-random.org/posts/on-vigna
All cstr definitions and prototypes may be included in your C source file by including a single header file.
```c
-#include "stc/crand.h"
+#include "stc/crandom.h"
```
## Methods
@@ -67,7 +67,7 @@ RNG, around 68% of the values fall within the range [*mean* - *stddev*, *mean* +
#include <stdio.h>
#include <time.h>
#include <math.h>
-#include "stc/crand.h"
+#include "stc/crandom.h"
#include "stc/cstr.h"
#include "stc/cmap.h"
#include "stc/cvec.h"
diff --git a/examples/birthday.c b/examples/birthday.c
index dc94fa53..45786fa9 100644
--- a/examples/birthday.c
+++ b/examples/birthday.c
@@ -2,7 +2,7 @@
#include <stdio.h>
#include <time.h>
-#include <stc/crand.h>
+#include <stc/crandom.h>
#include <stc/cmap.h>
using_cmap(ic, uint64_t, uint8_t);
diff --git a/examples/cbits_prime.c b/examples/cbits_prime.c
new file mode 100644
index 00000000..5c5d3969
--- /dev/null
+++ b/examples/cbits_prime.c
@@ -0,0 +1,39 @@
+#include <stdio.h>
+#include <stc/cbits.h>
+
+static inline cbits sieveOfEratosthenes(size_t n)
+{
+ cbits primes = cbits_with_size(n + 1, true);
+ cbits_reset(&primes, 0);
+ cbits_reset(&primes, 1);
+
+ c_forrange (i, size_t, 2, n+1) {
+ // If primes[i] is not changed, then it is a prime
+ if (cbits_test(primes, i) && i*i <= n) {
+ c_forrange (j, size_t, i*i, n+1, i) {
+ cbits_reset(&primes, j);
+ }
+ }
+ }
+ return primes;
+}
+
+
+int main(void)
+{
+ int n = 100000000;
+ printf("computing prime numbers up to %u\n", n);
+
+ cbits primes = sieveOfEratosthenes(n);
+ puts("done");
+
+ size_t np = cbits_count(primes);
+ printf("number of primes: %zu\n", np);
+
+ printf("2 ");
+ c_forrange (i, int, 3, 1001, 2) {
+ if (cbits_test(primes, i)) printf("%d ", i);
+ }
+ puts("");
+ cbits_del(&primes);
+} \ No newline at end of file
diff --git a/examples/crandom_ex.c b/examples/crandom_ex.c
new file mode 100644
index 00000000..c923debd
--- /dev/null
+++ b/examples/crandom_ex.c
@@ -0,0 +1,51 @@
+#include <stdio.h>
+#include <time.h>
+#include <math.h>
+#include <stc/crandom.h>
+#include <stc/cstr.h>
+
+int main()
+{
+ enum {R = 30};
+ const size_t N = 1000000000;
+ uint64_t seed = 1234; // time(NULL);
+ stc64_t rng = stc64_init(seed);
+
+ uint64_t sum = 0;
+
+ stc64_normalf_t dist2 = stc64_normalf_init(R / 2.0, R / 6.0);
+ size_t N2 = 10000000;
+ int hist[R] = {0};
+ sum = 0;
+ c_forrange (N2) {
+ int n = round((stc64_normalf(&rng, &dist2) + 0.5));
+ sum += n;
+ if (n >= 0 && n < R) ++hist[n];
+ }
+ cstr_t bar = cstr_inits;
+ c_forrange (i, int, R) {
+ cstr_resize(&bar, hist[i] * 25ull * R / N2, '*');
+ printf("%3d %s\n", i, bar.str);
+ }
+
+ clock_t diff, before;
+
+ sum = 0;
+ before = clock();
+ c_forrange (N) {
+ sum += stc64_rand(&rng);
+ }
+ diff = clock() - before;
+ printf("random : %f secs, %zu %f\n", (float) diff / CLOCKS_PER_SEC, N, (double) sum / N);
+
+ stc64_uniform_t dist1 = stc64_uniform_init(0, 1000);
+ sum = 0;
+ before = clock();
+ c_forrange (N) {
+ sum += stc64_uniform(&rng, &dist1);
+ }
+ diff = clock() - before;
+ printf("uniform: %f secs, %zu %f\n", (float) diff / CLOCKS_PER_SEC, N, (double) sum / N);
+
+ cstr_del(&bar);
+} \ No newline at end of file
diff --git a/examples/csmap_ex.c b/examples/csmap_ex.c
index aa78028b..ea8fd81c 100644
--- a/examples/csmap_ex.c
+++ b/examples/csmap_ex.c
@@ -1,6 +1,6 @@
#include <stc/csmap.h>
#include <stc/cstr.h>
-#include <stc/crand.h>
+#include <stc/crandom.h>
#include <stdio.h>
using_csmap(i, int, size_t);
diff --git a/examples/ex_gauss1.c b/examples/ex_gauss1.c
index 4139210c..85d818d5 100644
--- a/examples/ex_gauss1.c
+++ b/examples/ex_gauss1.c
@@ -1,7 +1,7 @@
#include <stdio.h>
#include <time.h>
#include <math.h>
-#include "stc/crand.h"
+#include "stc/crandom.h"
#include "stc/cstr.h"
#include "stc/cmap.h"
#include "stc/cvec.h"
diff --git a/examples/ex_gauss2.c b/examples/ex_gauss2.c
index cff0cef3..434a7e5e 100644
--- a/examples/ex_gauss2.c
+++ b/examples/ex_gauss2.c
@@ -1,7 +1,7 @@
#include <stdio.h>
#include <time.h>
#include <math.h>
-#include "stc/crand.h"
+#include "stc/crandom.h"
#include "stc/cstr.h"
#include "stc/csmap.h"
diff --git a/examples/list.c b/examples/list.c
index 9d6e8d89..394d0b38 100644
--- a/examples/list.c
+++ b/examples/list.c
@@ -1,7 +1,7 @@
#include <stdio.h>
#include <time.h>
#include <stc/clist.h>
-#include <stc/crand.h>
+#include <stc/crandom.h>
using_clist(fx, double);
int main() {
diff --git a/examples/phonebook.c b/examples/phonebook.c
new file mode 100644
index 00000000..91d01072
--- /dev/null
+++ b/examples/phonebook.c
@@ -0,0 +1,72 @@
+// The MIT License (MIT)
+// Copyright (c) 2018 Maksim Andrianov
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to
+// deal in the Software without restriction, including without limitation the
+// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+// sell copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+// IN THE SOFTWARE.
+
+// Program to emulates the phone book.
+
+#include <stdio.h>
+#include <stc/cmap.h>
+#include <stc/cstr.h>
+
+using_cmap_str();
+
+void print_phone_book(cmap_str phone_book)
+{
+ c_foreach (i, cmap_str, phone_book)
+ printf("%s\t- %s\n", i.ref->first.str, i.ref->second.str);
+}
+
+int main(int argc, char **argv)
+{
+ bool erased;
+ cmap_str phone_book = cmap_inits;
+ c_push_items(&phone_book, cmap_str, {
+ {"Lilia Friedman", "(892) 670-4739"},
+ {"Tariq Beltran", "(489) 600-7575"},
+ {"Laiba Juarez", "(303) 885-5692"},
+ {"Elliott Mooney", "(945) 616-4482"},
+ });
+
+ printf("Phone book:\n");
+ print_phone_book(phone_book);
+
+ c_try_emplace(&phone_book, cmap_str, "Zak Byers", cstr_from("(551) 396-1880"));
+ c_try_emplace(&phone_book, cmap_str, "Zak Byers", cstr_from("(551) 396-1990"));
+
+ printf("\nPhone book after adding Zak Byers:\n");
+ print_phone_book(phone_book);
+
+ if (cmap_str_find(&phone_book, "Tariq Beltran") != NULL)
+ printf("\nTariq Beltran is in phone book\n");
+
+ erased = cmap_str_erase(&phone_book, "Tariq Beltran");
+ erased = cmap_str_erase(&phone_book, "Elliott Mooney");
+
+ printf("\nPhone book after erasing Tariq and Elliott:\n");
+ print_phone_book(phone_book);
+
+ cmap_str_insert_or_assign(&phone_book, "Zak Byers", "(555) 396-188");
+
+ printf("\nPhone book after update phone of Zak Byers:\n");
+ print_phone_book(phone_book);
+
+ cmap_str_del(&phone_book);
+ puts("done");
+} \ No newline at end of file
diff --git a/examples/priority.c b/examples/priority.c
index 4eceb29f..548cb06d 100644
--- a/examples/priority.c
+++ b/examples/priority.c
@@ -4,7 +4,7 @@
#include <stc/cvec.h>
#include <stc/cpque.h>
#include <stc/cmap.h>
-#include <stc/crand.h>
+#include <stc/crandom.h>
using_cvec(i, int64_t);
using_cpque(i, cvec_i, >); // min-heap (increasing values)
diff --git a/examples/queue.c b/examples/queue.c
index 8c0a8777..23640a39 100644
--- a/examples/queue.c
+++ b/examples/queue.c
@@ -1,4 +1,4 @@
-#include <stc/crand.h>
+#include <stc/crandom.h>
#include <stc/cqueue.h>
#include <stdio.h>
diff --git a/examples/random.c b/examples/random.c
index 7325e023..c923debd 100644
--- a/examples/random.c
+++ b/examples/random.c
@@ -1,7 +1,7 @@
#include <stdio.h>
#include <time.h>
#include <math.h>
-#include <stc/crand.h>
+#include <stc/crandom.h>
#include <stc/cstr.h>
int main()
diff --git a/stc/clist.h b/stc/clist.h
index 89bbc75c..1673d71e 100644
--- a/stc/clist.h
+++ b/stc/clist.h
@@ -31,7 +31,7 @@
#include <stdio.h>
#include <stc/clist.h>
- #include <stc/crand.h>
+ #include <stc/crandom.h>
using_clist(ix, int64_t);
int main() {
diff --git a/stc/copt.h b/stc/coption.h
index 5fc8fe4d..27ec880b 100644
--- a/stc/copt.h
+++ b/stc/coption.h
@@ -20,24 +20,24 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
-#ifndef COPT__H__
-#define COPT__H__
+#ifndef COPTION__H__
+#define COPTION__H__
/*
// Inspired by https://attractivechaos.wordpress.com/2018/08/31/a-survey-of-argument-parsing-libraries-in-c-c
// Fixed major bugs with option arguments (both long and short).
// Added arg->faulty output field, and has a more consistent API.
//
-// copt_get() is similar to GNU's getopt_long(). Each call parses one option and
+// coption_get() is similar to GNU's getopt_long(). Each call parses one option and
// returns the option name. opt->arg points to the option argument if present.
// The function returns -1 when all command-line arguments are parsed. In this case,
// opt->ind is the index of the first non-option argument.
#include <stdio.h>
-#include <stc/copt.h>
+#include <stc/coption.h>
int main(int argc, char *argv[])
{
- copt_long_t longopts[] = {
+ coption_long longopts[] = {
{"foo", copt_no_argument, 'f'},
{"bar", copt_required_argument, 'b'},
{"opt", copt_optional_argument, 'o'},
@@ -46,8 +46,8 @@ int main(int argc, char *argv[])
const char* optstr = "xy:z::123";
printf("program -x -y ARG -z [ARG] -1 -2 -3 --foo --bar ARG --opt [ARG] [ARGUMENTS]\n");
int c;
- copt_t opt = copt_init();
- while ((c = copt_get(&opt, argc, argv, optstr, longopts)) != -1) {
+ coption opt = coption_init();
+ while ((c = coption_get(&opt, argc, argv, optstr, longopts)) != -1) {
switch (c) {
case '?': printf("error: unknown option: %s\n", opt.faulty); break;
case ':': printf("error: missing argument for %s\n", opt.faulty); break;
@@ -77,16 +77,16 @@ typedef struct {
int longindex; /* idx of long option; or -1 if short */
int _i, _pos, _nargs;
char _faulty[4];
-} copt_t;
+} coption;
typedef struct {
const char *name;
int has_arg;
int val;
-} copt_long_t;
+} coption_long;
-static const copt_t copt_inits = {1, 0, NULL, NULL, -1, 1, 0, 0, {'-', '?', '\0'}};
-static inline copt_t copt_init(void) { return copt_inits; }
+static const coption coption_inits = {1, 0, NULL, NULL, -1, 1, 0, 0, {'-', '?', '\0'}};
+static inline coption coption_init(void) { return coption_inits; }
static void _copt_permute(char *argv[], int j, int n) { /* move argv[j] over n elements to the left */
int k;
@@ -96,13 +96,13 @@ static void _copt_permute(char *argv[], int j, int n) { /* move argv[j] over n e
argv[j - k] = p;
}
-/* @param opt output; must be initialized to copt_init() on first call
+/* @param opt output; must be initialized to coption_init() on first call
* @return ASCII val for a short option; longopt.val for a long option;
* -1 if argv[] is fully processed; '?' for an unknown option or
* an ambiguous long option; ':' if an option argument is missing
*/
-static int copt_get(copt_t *opt, int argc, char *argv[],
- const char *shortopts, const copt_long_t *longopts) {
+static int coption_get(coption *opt, int argc, char *argv[],
+ const char *shortopts, const coption_long *longopts) {
int optc = -1, i0, j, posixly_correct = (shortopts[0] == '+');
if (!posixly_correct) {
while (opt->_i < argc && (argv[opt->_i][0] != '-' || argv[opt->_i][1] == '\0'))
@@ -122,7 +122,7 @@ static int copt_get(copt_t *opt, int argc, char *argv[],
opt->opt = 0, optc = '?', opt->_pos = -1;
if (longopts) { /* parse long options */
int k, n_exact = 0, n_partial = 0;
- const copt_long_t *o = 0, *o_exact = 0, *o_partial = 0;
+ const coption_long *o = 0, *o_exact = 0, *o_partial = 0;
for (j = 2; argv[opt->_i][j] != '\0' && argv[opt->_i][j] != '='; ++j) {} /* find the end of the option name */
for (k = 0; longopts[k].name != 0; ++k)
if (strncmp(&argv[opt->_i][2], longopts[k].name, j - 2) == 0) {
diff --git a/stc/cpque.h b/stc/cpque.h
index 41113b7a..54ca04a7 100644
--- a/stc/cpque.h
+++ b/stc/cpque.h
@@ -23,7 +23,7 @@
/* Priority-Queue adapter (implemented as heap), default uses cvec.
- #include <stc/crand.h>
+ #include <stc/crandom.h>
#include <stc/cpque.h>
using_cvec(f, float);
using_cpque(f, cvec_f, >); // min-heap (increasing values)
diff --git a/stc/cqueue.h b/stc/cqueue.h
index fe202698..2c49b066 100644
--- a/stc/cqueue.h
+++ b/stc/cqueue.h
@@ -25,7 +25,7 @@
/* Queue adapter, default uses clist.
- #include <stc/crand.h>
+ #include <stc/crandom.h>
#include <stc/cqueue.h>
using_cdeq(i, int);
using_cqueue(i, cdeq_i);
diff --git a/stc/crand.h b/stc/crandom.h
index 727c61ac..c92a7de6 100644
--- a/stc/crand.h
+++ b/stc/crandom.h
@@ -24,8 +24,8 @@
#define CRANDOM__H__
/*
-// crand: Pseudo-random number generator
-#include "stc/crand.h"
+// crandom: Pseudo-random number generator
+#include "stc/crandom.h"
int main() {
uint64_t seed = 123456789;
stc64_t rng = stc64_init(seed);
@@ -112,7 +112,7 @@ STC_API double stc64_normalf(stc64_t* rng, stc64_normalf_t* dist);
#if !defined(STC_HEADER) || defined(STC_IMPLEMENTATION)
-/* PRNG crand: by Tyge Løvset, NORCE Research, 2020.
+/* PRNG crandom: by Tyge Løvset, NORCE Research, 2020.
* Extremely fast PRNG suited for parallel usage with Weyl-sequence parameter.
* Faster than sfc64, wyhash64, and xoshiro256** on most platforms.
* 256bit state, updates only 192bit per rng.