summaryrefslogtreecommitdiffhomepage
path: root/docs
diff options
context:
space:
mode:
Diffstat (limited to 'docs')
-rw-r--r--docs/cbits_api.md7
-rw-r--r--docs/cstr_api.md4
2 files changed, 7 insertions, 4 deletions
diff --git a/docs/cbits_api.md b/docs/cbits_api.md
index 613c2d8c..b18526f3 100644
--- a/docs/cbits_api.md
+++ b/docs/cbits_api.md
@@ -64,6 +64,7 @@ void cbits_xor(cbits* self, const cbits* other); // set
## Example
```c
+#define i_implement // implementation of cbits_count() only once.
#include <stc/cbits.h>
#include <stdio.h>
#include <math.h>
@@ -76,7 +77,7 @@ cbits sieveOfEratosthenes(size_t n)
for (size_t i = 3; i <= q; i += 2) {
for (size_t j = i; j < n; j += 2) {
- if (cbits_test(bits, j>>1)) {
+ if (cbits_test(&bits, j>>1)) {
i = j;
break;
}
@@ -94,14 +95,14 @@ int main(void)
clock_t t1 = clock();
cbits primes = sieveOfEratosthenes(n + 1);
- size_t nprimes = cbits_count(primes);
+ size_t nprimes = cbits_count(&primes);
clock_t t2 = clock();
printf("number of primes: %" PRIuMAX ", time: %f\n", nprimes, (float)(t2 - t1)/CLOCKS_PER_SEC);
printf(" 2");
for (size_t i = 3; i < 1000; i += 2)
- if (cbits_test(primes, i>>1)) printf(" %" PRIuMAX "", i);
+ if (cbits_test(&primes, i>>1)) printf(" %" PRIuMAX "", i);
puts("");
cbits_drop(&primes);
diff --git a/docs/cstr_api.md b/docs/cstr_api.md
index cd827dc6..6f851911 100644
--- a/docs/cstr_api.md
+++ b/docs/cstr_api.md
@@ -3,6 +3,8 @@
A **cstr** object represent sequences of characters. It supports an interface similar to that of a standard container of bytes, but adding features specifically designed to operate with strings of single-byte characters, terminated by the null character.
+**cstr** has basic support for *UTF8* encoded strings, and has a set of compact and efficient functions for handling case-foldings and comparisons of UTF strings. The **cstr** type uses short strings optimization (sso), which eliminates heap memory allocation for strings shorter than 24 bytes (sizeof(cstr) is also 24).
+
See the c++ class [std::basic_string](https://en.cppreference.com/w/cpp/string/basic_string) for a functional description.
## Header file
@@ -51,7 +53,7 @@ cstr cstr_tolower(const cstr* self); // returns
cstr cstr_toupper(const cstr* self); // returns new uppercase utf8 cstr
void cstr_lowercase(cstr* self); // transform cstr to lowercase utf8
void cstr_uppercase(cstr* self); // transform cstr to uppercase utf8
-bool cstr_iequals(cstr s, const char* str); // case-insensitive comparison
+bool cstr_iequals(cstr s, const char* str); // utf8 case-insensitive comparison
bool cstr_istarts_with(cstr s, const char* str); // "
bool cstr_iends_with(cstr s, const char* str); // "
int cstr_icmp(const cstr* s1, const cstr* s2); // "