diff options
| author | Tyge Løvset <[email protected]> | 2022-06-01 10:33:15 +0200 |
|---|---|---|
| committer | Tyge Løvset <[email protected]> | 2022-06-01 10:33:15 +0200 |
| commit | 5e4d94a2dda15733c89e7b3f52aa480cb2a341bd (patch) | |
| tree | 6812036a35b60d8bf0ad9a8ab20324e37bf688a5 /docs | |
| parent | d7a19420e0aec71a2a840f68a54549c8a951f929 (diff) | |
| parent | a42258b4d7bcfdcba0539be43f7d235186287bb5 (diff) | |
| download | STC-modified-5e4d94a2dda15733c89e7b3f52aa480cb2a341bd.tar.gz STC-modified-5e4d94a2dda15733c89e7b3f52aa480cb2a341bd.zip | |
Merge branch 'master' of github.com:tylov/STC
Diffstat (limited to 'docs')
| -rw-r--r-- | docs/cbits_api.md | 7 | ||||
| -rw-r--r-- | docs/cstr_api.md | 4 |
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); // " |
