summaryrefslogtreecommitdiffhomepage
path: root/docs
diff options
context:
space:
mode:
authorTyge Løvset <[email protected]>2020-12-05 15:10:52 +0100
committerTyge Løvset <[email protected]>2020-12-05 15:10:52 +0100
commit17196445c8e3b0186d61abfa04cf97529233b1a2 (patch)
tree7e1bcaec45c4dde00c272857038c945fe0a97d86 /docs
parent029441f7b9128e7aeb5af3ba629287c9a709b19a (diff)
downloadSTC-modified-17196445c8e3b0186d61abfa04cf97529233b1a2.tar.gz
STC-modified-17196445c8e3b0186d61abfa04cf97529233b1a2.zip
Some text improvements. Renamed method c_default_hash16 to c_default_hash.
Diffstat (limited to 'docs')
-rw-r--r--docs/cmap_api.md8
-rw-r--r--docs/crandom_api.md49
-rw-r--r--docs/cset_api.md4
-rw-r--r--docs/cstr_api.md86
4 files changed, 75 insertions, 72 deletions
diff --git a/docs/cmap_api.md b/docs/cmap_api.md
index 6582143e..f3046648 100644
--- a/docs/cmap_api.md
+++ b/docs/cmap_api.md
@@ -7,7 +7,7 @@ Elements are pairs of keys and mapped values. Implemented as open hashing withou
```c
#define using_cmap(X, Key, Mapped, mappedDestroy=c_default_del,
keyEqualsRaw=c_default_equals,
- keyHashRaw=c_default_hash16,
+ keyHashRaw=c_default_hash,
keyDestroy=c_default_del,
RawKey=Key,
keyToRaw=c_default_to_raw,
@@ -18,7 +18,7 @@ Elements are pairs of keys and mapped values. Implemented as open hashing withou
#define using_cmap_strkey(X, Mapped, mappedDestroy=c_default_del)
#define using_cmap_strval(X, Key, keyEquals=c_default_equals,
- keyHash=c_default_hash16,
+ keyHash=c_default_hash,
keyDestroy=c_default_del,
RawKey=Key,
keyToRaw=c_default_to_raw,
@@ -30,6 +30,8 @@ Default values are given above for args not specified. `X` is a type tag name an
will affect the names of all cmap types and methods. E.g. declaring `using_cmap(my, int);`, `X` should
be replaced by `my` in all of the following documentation.
+`c_default_hash` requires Key to be 16-bit aligned, and size to be a multiple of 16. There is also a `c_default_hash32` which is slightly faster.
+
`using_cmap_strkey()` and `using_cmap_strval()` are special macros defined by
`using_cmap()`. The macro `using_cmap_str()` is a shorthand for
```c
@@ -108,7 +110,7 @@ void cmap_X_next(cmap_X_iter_t* it);
cmap_X_mapped_t* cmap_X_itval(cmap_X_iter_t it);
cmap_bucket_t cmap_X_bucket(const cmap_X* self, const cmap_X_rawkey_t* rkeyPtr);
-uint32_t c_default_hash16(const void *data, size_t len);
+uint32_t c_default_hash(const void *data, size_t len);
uint32_t c_default_hash32(const void* data, size_t len);
```
diff --git a/docs/crandom_api.md b/docs/crandom_api.md
index 2cb3c586..d31f19c8 100644
--- a/docs/crandom_api.md
+++ b/docs/crandom_api.md
@@ -25,33 +25,34 @@ All cstr definitions and prototypes may be included in your C source file by inc
## Methods
```c
-(1) crand_rng32_t crand_rng32_init(uint64_t seed);
-(2) crand_rng32_t crand_rng32_with_seq(uint64_t seed, uint64_t seq);
-(3) uint32_t crand_i32(crand_rng32_t* rng);
-(4) float crand_f32(crand_rng32_t* rng);
-(5) crand_uniform_i32_t crand_uniform_i32_init(int32_t low, int32_t high);
-(6) int32_t crand_uniform_i32(crand_rng32_t* rng, crand_uniform_i32_t* dist);
-(7) uint32_t crand_unbiased_i32(crand_rng32_t* rng, crand_uniform_i32_t* dist);
-(8) crand_uniform_f32_t crand_uniform_f32_init(float low, float high); /* */
-(9) float crand_uniform_f32(crand_rng32_t* rng, crand_uniform_f32_t* dist);
+ 1) crand_rng32_t crand_rng32_init(uint64_t seed);
+ 2) crand_rng32_t crand_rng32_with_seq(uint64_t seed, uint64_t seq);
+ 3) uint32_t crand_i32(crand_rng32_t* rng);
+ 4) float crand_f32(crand_rng32_t* rng);
+ 5) crand_uniform_i32_t crand_uniform_i32_init(int32_t low, int32_t high);
+ 6) int32_t crand_uniform_i32(crand_rng32_t* rng, crand_uniform_i32_t* dist);
+ 7) uint32_t crand_unbiased_i32(crand_rng32_t* rng, crand_uniform_i32_t* dist);
+ 8) crand_uniform_f32_t crand_uniform_f32_init(float low, float high); /* */
+ 9) float crand_uniform_f32(crand_rng32_t* rng, crand_uniform_f32_t* dist);
```
-(1-2) PRNG 32-bit engine initializers. (3) Integer random number generator with range \[0, 2^32). (5) Integer generator with range \[low, high].
-(7) Unbiased version, see https://github.com/lemire/fastrange. (8) 32-bit float random number in range \[low, high), 23 bits resolution numbers.
+`1-2)` PRNG 32-bit engine initializers. `3)` Integer RNG with range \[0, 2^32). `4)` Float RNG with range \[0, 1).
+`5-6)` Uniform integer RNG with range \[`low`, `high`]. `7)` Unbiased version, see https://github.com/lemire/fastrange.
+`8-9)` Uniform float RNG with range \[`low`, `high`).
```c
-(1) crand_rng64_t crand_rng64_with_seq(uint64_t seed, uint64_t seq);
-(2) crand_rng64_t crand_rng64_init(uint64_t seed);
-(3) uint64_t crand_i64(crand_rng64_t* rng);
-(4) double crand_f64(crand_rng64_t* rng);
-(5) crand_uniform_i64_t crand_uniform_i64_init(int64_t low, int64_t high);
-(6) int64_t crand_uniform_i64(crand_rng64_t* rng, crand_uniform_i64_t* dist);
-(7) crand_uniform_f64_t crand_uniform_f64_init(double low, double high);
-(8) double crand_uniform_f64(crand_rng64_t* rng, crand_uniform_f64_t* dist);
-(9) crand_normal_f64_t crand_normal_f64_init(double mean, double stddev);
-(10) double crand_normal_f64(crand_rng64_t* rng, crand_normal_f64_t* dist);
+ 1) crand_rng64_t crand_rng64_with_seq(uint64_t seed, uint64_t seq);
+ 2) crand_rng64_t crand_rng64_init(uint64_t seed);
+ 3) uint64_t crand_i64(crand_rng64_t* rng);
+ 4) double crand_f64(crand_rng64_t* rng);
+ 5) crand_uniform_i64_t crand_uniform_i64_init(int64_t low, int64_t high);
+ 6) int64_t crand_uniform_i64(crand_rng64_t* rng, crand_uniform_i64_t* dist);
+ 7) crand_uniform_f64_t crand_uniform_f64_init(double low, double high);
+ 8) double crand_uniform_f64(crand_rng64_t* rng, crand_uniform_f64_t* dist);
+ 9) crand_normal_f64_t crand_normal_f64_init(double mean, double stddev);
+10) double crand_normal_f64(crand_rng64_t* rng, crand_normal_f64_t* dist);
```
-(1-2) PRNG 64-bit engine initializers. (3) Integer generator, range \[0, 2^64),
-(4) 64-bit float random numbers, 52 bit resolution. (5-8) Initializers and generators of uniform random numbers. (5) has range \[low, high].
-(7) has range \[low, high). (9-10) Initializer and generator for normal-distributed random numbers.
+`1-2)` PRNG 64-bit engine initializers. `3)` Integer generator, range \[0, 2^64). `4)` Double RNG with range \[0, 1).
+`5-6)` Uniform integer RNG with range \[`low`, `high`]. `7-8)` Uniform double RNG with range \[`low`, `high`).
+`9-10)` Normal-distributed double RNG with range [`mean`-`stddev`, `mean`+`stddev`].
The method `crand_i64(crand_rng64_t* rng)` is an extremely fast PRNG suited for parallel usage, featuring
a Weyl-sequence as part of the state. It is faster than *sfc64*, *wyhash64*, *pcg*, and the *xoroshiro*
diff --git a/docs/cset_api.md b/docs/cset_api.md
index ca3e91e3..bb5dfaff 100644
--- a/docs/cset_api.md
+++ b/docs/cset_api.md
@@ -9,7 +9,7 @@ Same base implementation as cmap, but contains and uses keys only.
#define using_cset_str()
#define using_cset(X, Key, keyEqualsRaw=c_default_equals,
- keyHashRaw=c_default_hash16,
+ keyHashRaw=c_default_hash,
keyDestroy=c_default_del,
RawKey=Key,
keyToRaw=c_default_to_raw,
@@ -88,7 +88,7 @@ cset_X_value_t* cset_X_itval(cset_X_iter_t it);
cset_bucket_t cset_X_bucket(const cset_X* self, const cset_X_rawkey_t* rkeyPtr);
-uint32_t c_default_hash16(const void *data, size_t len);
+uint32_t c_default_hash(const void *data, size_t len);
uint32_t c_default_hash32(const void* data, size_t len);
```
diff --git a/docs/cstr_api.md b/docs/cstr_api.md
index 6815abfe..88b1b746 100644
--- a/docs/cstr_api.md
+++ b/docs/cstr_api.md
@@ -27,55 +27,55 @@ All cstr definitions and prototypes may be included in your C source file by inc
## Methods
```c
-(1) cstr_t cstr_init(void);
-(2) cstr_t cstr_with_capacity(size_t cap);
-(3) cstr_t cstr_with_size(size_t len, char fill);
-(4) cstr_t cstr_from(const char* str);
-(5) cstr_t cstr_from_n(const char* str, size_t len);
-(6) cstr_t cstr_from_fmt(const char* fmt, ...);
-(7) cstr_t cstr_clone(cstr_t s);
-(8) void cstr_del(cstr_t *self);
+ 1) cstr_t cstr_init(void);
+ 2) cstr_t cstr_with_capacity(size_t cap);
+ 3) cstr_t cstr_with_size(size_t len, char fill);
+ 4) cstr_t cstr_from(const char* str);
+ 5) cstr_t cstr_from_n(const char* str, size_t len);
+ 6) cstr_t cstr_from_fmt(const char* fmt, ...);
+ 7) cstr_t cstr_clone(cstr_t s);
+ 8) void cstr_del(cstr_t *self);
```
-(1) Create an empty string, (2) with capacity. (3) Create a string by repeating `fill` character `len` times.
-(4) Construct a string from `str`, and (5) limit the length by `len` and `strlen(str)`.
-(6) Construct a string from the format specified by `fmt` and arguments, using `printf()` formatting.
-(7) Construct a new string by cloning another string. (8) Free the allocated memory used by string.
+`1)` Create an empty string, `2)` with capacity. `3)` Create a string by repeating `fill` character `len` times.
+`4)` Construct a string from `str`, and `5)` limit the length by `len` and `strlen(str)`.
+`6)` Construct a string from the format specified by `fmt` and arguments, using `printf()` formatting.
+`7)` Construct a new string by cloning another string. `8)` Free the allocated memory used by string.
```c
size_t cstr_size(cstr_t s);
size_t cstr_length(cstr_t s);
size_t cstr_capacity(cstr_t s);
bool cstr_empty(cstr_t s);
-(5) char* cstr_front(cstr_t* self);
-(6) char* cstr_back(cstr_t* self);
+ 5) char* cstr_front(cstr_t* self);
+ 6) char* cstr_back(cstr_t* self);
```
-These returns properties of a string. (5-6) returns reference, ie. pointer to the char.
+These returns properties of a string. `5-6)` returns reference, ie. pointer to the char.
```c
-(1) size_t cstr_reserve(cstr_t* self, size_t capacity);
-(2) void cstr_resize(cstr_t* self, size_t len, char fill);
-(3) void cstr_clear(cstr_t* self);
-(4) cstr_t* cstr_assign(cstr_t* self, const char* str);
-(5) cstr_t* cstr_assign_n(cstr_t* self, const char* str, size_t len);
-(6) cstr_t* cstr_take(cstr_t* self, cstr_t s);
-(7) cstr_t cstr_move(cstr_t* self);
+ 1) size_t cstr_reserve(cstr_t* self, size_t capacity);
+ 2) void cstr_resize(cstr_t* self, size_t len, char fill);
+ 3) void cstr_clear(cstr_t* self);
+ 4) cstr_t* cstr_assign(cstr_t* self, const char* str);
+ 5) cstr_t* cstr_assign_n(cstr_t* self, const char* str, size_t len);
+ 6) cstr_t* cstr_take(cstr_t* self, cstr_t s);
+ 7) cstr_t cstr_move(cstr_t* self);
```
-(1-3) Reserve, resize, clear string. (4) Assign `str` to string, (5) assign substring `str` limited by
-`len` and `strlen(str)`. (6) Take the constructed or moved string `s`, i.e., no allocation takes place.
-(7) Explicitly move string to the caller of the method; string becomes empty after move.
+`1-3)` Reserve, resize, clear string. `4)` Assign `str` to string, `5)` assign substring `str` limited by
+`len` and `strlen(str)`. `6)` Take the constructed or moved string `s`, i.e., no allocation takes place.
+`7)` Explicitly move string to the caller of the method; string becomes empty after move.
```c
-(1) cstr_t* cstr_append(cstr_t* self, const char* str);
-(2) cstr_t* cstr_append_n(cstr_t* self, const char* str, size_t len);
-(3) cstr_t* cstr_push_back(cstr_t* self, char ch);
-(4) void cstr_pop_back(cstr_t* self);
-(5) void cstr_insert(cstr_t* self, size_t pos, const char* str);
-(6) void cstr_insert_n(cstr_t* self, size_t pos, const char* str, size_t n);
-(7) void cstr_erase(cstr_t* self, size_t pos, size_t n);
-(8) void cstr_replace(cstr_t* self, size_t pos, size_t len, const char* str);
-(9) void cstr_replace_n(cstr_t* self, size_t pos, size_t len, const char* str, size_t n);
+ 1) cstr_t* cstr_append(cstr_t* self, const char* str);
+ 2) cstr_t* cstr_append_n(cstr_t* self, const char* str, size_t len);
+ 3) cstr_t* cstr_push_back(cstr_t* self, char ch);
+ 4) void cstr_pop_back(cstr_t* self);
+ 5) void cstr_insert(cstr_t* self, size_t pos, const char* str);
+ 6) void cstr_insert_n(cstr_t* self, size_t pos, const char* str, size_t n);
+ 7) void cstr_erase(cstr_t* self, size_t pos, size_t n);
+ 8) void cstr_replace(cstr_t* self, size_t pos, size_t len, const char* str);
+ 9) void cstr_replace_n(cstr_t* self, size_t pos, size_t len, const char* str, size_t n);
```
-(1) Append `str` to stirng. (2) Append substring `str` limited by `len`. (3), Append character `ch`.
-(4) Erase last character. (5) Insert string at a positions, (6) string limited by n characters.
-(7) Erase n characters at position pos. (8) Replace len characters at position pos with str,
-(9) replacement str limited by n characters.
+`1)` Append `str` to string. `2)` Append substring `str` limited by `len`. `3)`, Append character `ch`.
+`4)` Erase last character. `5)` Insert string at a positions, `6)` string limited by n characters.
+`7)` Erase n characters at position pos. `8)` Replace len characters at position pos with str,
+`9)` replacement str limited by n characters.
```c
int cstr_compare(const cstr_t *s1, const cstr_t *s2);
bool cstr_equals(cstr_t s, const char* str);
@@ -91,19 +91,19 @@ These returns properties of a string. (5-6) returns reference, ie. pointer to th
bool cstr_ends_with(cstr_t s, const char* substr);
bool cstr_iends_with(cstr_t s, const char* substr);
```
-Methods prefixed by i does case-insensitive search.
+Compare and search methods. Methods prefixed by `i` does case-insensitive compare/search.
```c
cstr_iter_t cstr_begin(cstr_t* self);
cstr_iter_t cstr_end(cstr_t* self);
void cstr_next(cstr_iter_t* it);
char* cstr_itval(cstr_iter_t it);
```
-Iterator methods, typically used via the general macro `c_foreach`.
+Iterator methods, typically used via the general `c_foreach` macro.
```c
-(1) bool cstr_getline(cstr_t *self, FILE *stream);
-(2) bool cstr_getdelim(cstr_t *self, int delim, FILE *stream);
+ 1) bool cstr_getline(cstr_t *self, FILE *stream);
+ 2) bool cstr_getdelim(cstr_t *self, int delim, FILE *stream);
```
-Reads a line of text from stream and stores it in string. Line is separated by delim, which is '\n' in (1).
+`1-2)` Read a line of text from stream and store it in string. Line is separated by delim, which is '\n' in `1)`.
```c
const char* cstr_to_raw(const cstr_t* x);
int cstr_compare_raw(const char** x, const char** y);