summaryrefslogtreecommitdiffhomepage
path: root/docs
diff options
context:
space:
mode:
authorTyge Løvset <[email protected]>2022-04-24 20:50:53 +0200
committerGitHub <[email protected]>2022-04-24 20:50:53 +0200
commit81b541b85f85b48660ceb461b851f1fb09d68344 (patch)
tree909d8c7cdeb5fc6daad007d4cd46e65d4af1c6e4 /docs
parent91385d449d03145cfe8cc91f2704d4b24c63d37e (diff)
parent8aeec88bd7f15069a388f7fc8fe0008af4d1ab44 (diff)
downloadSTC-modified-81b541b85f85b48660ceb461b851f1fb09d68344.tar.gz
STC-modified-81b541b85f85b48660ceb461b851f1fb09d68344.zip
Merge pull request #21 from tylov/keyval
Version 3.5 RC
Diffstat (limited to 'docs')
-rw-r--r--docs/cdeq_api.md2
-rw-r--r--docs/clist_api.md1
-rw-r--r--docs/cmap_api.md20
-rw-r--r--docs/cset_api.md1
-rw-r--r--docs/csmap_api.md3
-rw-r--r--docs/csset_api.md1
-rw-r--r--docs/cstr_api.md1
-rw-r--r--docs/csview_api.md2
8 files changed, 18 insertions, 13 deletions
diff --git a/docs/cdeq_api.md b/docs/cdeq_api.md
index 3cd4fece..aa528aa2 100644
--- a/docs/cdeq_api.md
+++ b/docs/cdeq_api.md
@@ -51,7 +51,9 @@ cdeq_X_value* cdeq_X_emplace_front(cdeq_X* self, i_valraw raw);
void cdeq_X_pop_front(cdeq_X* self);
cdeq_X_value* cdeq_X_push_back(cdeq_X* self, i_val value);
+cdeq_X_value* cdeq_X_push(cdeq_X* self, i_val value); // alias for push_back()
cdeq_X_value* cdeq_X_emplace_back(cdeq_X* self, i_valraw raw);
+cdeq_X_value* cdeq_X_emplace(cdeq_X* self, i_valraw raw); // alias for emplace_back()
void cdeq_X_pop_back(cdeq_X* self);
cdeq_X_iter cdeq_X_insert(cdeq_X* self, size_t idx, i_val value); // move value
diff --git a/docs/clist_api.md b/docs/clist_api.md
index cae3e66b..c785fbe5 100644
--- a/docs/clist_api.md
+++ b/docs/clist_api.md
@@ -57,6 +57,7 @@ void clist_X_pop_front(clist_X* self);
void clist_X_push_back(clist_X* self, i_val value); // note: no pop_back()
void clist_X_push(clist_X* self, i_val value); // alias for push_back()
void clist_X_emplace_back(clist_X* self, i_valraw raw);
+void clist_X_emplace(clist_X* self, i_valraw raw); // alias for emplace_back()
clist_X_iter clist_X_insert_at(clist_X* self, clist_X_iter it, i_val value); // return iter to new elem
clist_X_iter clist_X_emplace_at(clist_X* self, clist_X_iter it, i_valraw raw);
diff --git a/docs/cmap_api.md b/docs/cmap_api.md
index 69257779..07f1c140 100644
--- a/docs/cmap_api.md
+++ b/docs/cmap_api.md
@@ -67,11 +67,10 @@ cmap_X_iter cmap_X_find(const cmap_X* self, i_keyraw rkey);
cmap_X_result cmap_X_insert(cmap_X* self, i_key key, i_val mapped); // no change if key in map
cmap_X_result cmap_X_insert_or_assign(cmap_X* self, i_key key, i_val mapped); // always update mapped
-cmap_X_result cmap_X_put(cmap_X* self, i_key key, i_val mapped); // alias for insert_or_assign
+cmap_X_result cmap_X_push(cmap_X* self, cmap_X_value entry); // similar to insert
cmap_X_result cmap_X_emplace(cmap_X* self, i_keyraw rkey, i_valraw rmapped); // no change if rkey in map
cmap_X_result cmap_X_emplace_or_assign(cmap_X* self, i_keyraw rkey, i_valraw rmapped); // always update rmapped
-cmap_X_result cmap_X_put_raw(cmap_X* self, i_keyraw rkey, i_valraw rmapped); // alias for emplace_or_assign
size_t cmap_X_erase(cmap_X* self, i_keyraw rkey); // return 0 or 1
cmap_X_iter cmap_X_erase_at(cmap_X* self, cmap_X_iter it); // return iter after it
@@ -90,8 +89,6 @@ uint64_t c_strhash(const char *str); /
// hash template parameter functions:
uint64_t c_default_hash(const void *data, size_t len); // key is any integral type
-uint64_t c_hash32(const void* data, size_t is4); // key is one 32-bit int
-uint64_t c_hash64(const void* data, size_t is8); // key is one 64-bit int
// equalto template parameter functions:
bool c_default_eq(const i_keyraw* a, const i_keyraw* b); // *a == *b
@@ -276,8 +273,9 @@ typedef struct {
#define Viking_init() ((Viking){cstr_null, cstr_null})
-static inline bool Viking_eq(const Viking* a, const Viking* b) {
- return cstr_equals_s(a->name, b->name) && cstr_equals_s(a->country, b->country);
+static inline int Viking_cmp(const Viking* a, const Viking* b) {
+ int c = cstr_cmp(&a->name, &b->name);
+ return c ? c : cstr_cmp(&a->country, &b->country);
}
static inline uint32_t Viking_hash(const Viking* a, int ignored) {
@@ -298,7 +296,7 @@ static inline void Viking_drop(Viking* vk) {
#define i_key_bind Viking
#define i_val int
// i_key_bind auto-binds:
-// #define i_eq Viking_eq
+// #define i_cmp Viking_cmp
// #define i_hash Viking_hash
// #define i_keyfrom Viking_clone
// #define i_keydrop Viking_drop
@@ -361,8 +359,10 @@ static inline uint64_t RViking_hash(const RViking* raw, size_t ignore) {
uint64_t hash = c_strhash(raw->name) ^ (c_strhash(raw->country) >> 15);
return hash;
}
-static inline bool RViking_eq(const RViking* rx, const RViking* ry) {
- return strcmp(rx->name, ry->name) == 0 && strcmp(rx->country, ry->country) == 0;
+
+static inline int RViking_cmp(const RViking* rx, const RViking* ry) {
+ int c = strcmp(rx->name, ry->name);
+ return c ? c : strcmp(rx->country, ry->country);
}
static inline Viking Viking_from(RViking raw) {
@@ -379,7 +379,7 @@ static inline RViking Viking_toraw(const Viking* vk) {
#define i_keyraw RViking
// i_key_bind macro will make these functions auto-bind:
// #define i_hash RViking_hash
-// #define i_eq RViking_eq
+// #define i_cmp RViking_cmp
// #define i_keyfrom Viking_from // uses _from because i_keyraw is defined
// #define i_keyto Viking_toraw
// #define i_keydrop Viking_drop
diff --git a/docs/cset_api.md b/docs/cset_api.md
index e429c5ae..d9b412da 100644
--- a/docs/cset_api.md
+++ b/docs/cset_api.md
@@ -46,6 +46,7 @@ cset_X_value* cset_X_get_mut(cset_X* self, i_keyraw rkey);
cset_X_iter cset_X_find(const cset_X* self, i_keyraw rkey);
cset_X_result cset_X_insert(cset_X* self, i_key key);
+cset_X_result cset_X_push(cset_X* self, i_key key); // alias for insert.
cset_X_result cset_X_emplace(cset_X* self, i_keyraw rkey);
size_t cset_X_erase(cset_X* self, i_keyraw rkey); // return 0 or 1
diff --git a/docs/csmap_api.md b/docs/csmap_api.md
index 012a7d58..ab9eb2ee 100644
--- a/docs/csmap_api.md
+++ b/docs/csmap_api.md
@@ -63,11 +63,10 @@ csmap_X_value* csmap_X_back(const csmap_X* self);
csmap_X_result csmap_X_insert(csmap_X* self, i_key key, i_val mapped); // no change if key in map
csmap_X_result csmap_X_insert_or_assign(csmap_X* self, i_key key, i_val mapped); // always update mapped
-csmap_X_result csmap_X_put(csmap_X* self, i_key key, i_val mapped); // alias for insert_or_assign()
+csmap_X_result csmap_X_push(csmap_X* self, csmap_X_value entry); // similar to insert()
csmap_X_result csmap_X_emplace(csmap_X* self, i_keyraw rkey, i_valraw rmapped); // no change if rkey in map
csmap_X_result csmap_X_emplace_or_assign(csmap_X* self, i_keyraw rkey, i_valraw rmapped); // always update rmapped
-csmap_X_result csmap_X_put_raw(csmap_X* self, i_keyraw rkey, i_valraw rmapped); // alias for emplace_or_assign
size_t csmap_X_erase(csmap_X* self, i_keyraw rkey);
csmap_X_iter csmap_X_erase_at(csmap_X* self, csmap_X_iter it); // returns iter after it
diff --git a/docs/csset_api.md b/docs/csset_api.md
index 0ce8e811..57d23ee6 100644
--- a/docs/csset_api.md
+++ b/docs/csset_api.md
@@ -42,6 +42,7 @@ csset_X_value* csset_X_find_it(const csset_X* self, i_keyraw rkey, csset_X
csset_X_iter csset_X_lower_bound(const csset_X* self, i_keyraw rkey); // find closest entry >= rkey
csset_X_result csset_X_insert(csset_X* self, i_key key);
+csset_X_result csset_X_push(csset_X* self, i_key key); // alias for insert()
csset_X_result csset_X_emplace(csset_X* self, i_keyraw rkey);
size_t csset_X_erase(csset_X* self, i_keyraw rkey);
diff --git a/docs/cstr_api.md b/docs/cstr_api.md
index 4f7c689e..85a872fe 100644
--- a/docs/cstr_api.md
+++ b/docs/cstr_api.md
@@ -22,6 +22,7 @@ cstr cstr_from_n(const char* str, size_t n); // constru
cstr cstr_with_capacity(size_t cap);
cstr cstr_with_size(size_t len, char fill); // repeat fill len times
cstr cstr_from_fmt(const char* fmt, ...); // printf() formatting
+cstr cstr_from_replace_all_sv(csview sv, csview find, csview repl);
cstr cstr_clone(cstr s);
cstr* cstr_take(cstr* self, cstr s); // take the constructed or moved string
diff --git a/docs/csview_api.md b/docs/csview_api.md
index a472194f..5211e2f6 100644
--- a/docs/csview_api.md
+++ b/docs/csview_api.md
@@ -76,7 +76,7 @@ uint32_t utf8_decode(uint32_t *state, uint32_t *codep, const uint32_t byt
#### Extended cstr methods
```c
cstr cstr_from_sv(csview sv); // construct cstr from csview
-csview cstr_to_sv(const cstr* self); // convert to csview from const cstr*
+csview cstr_sv(const cstr* self); // convert to csview from const cstr*
cstr cstr_from_replace_all_sv(csview sv, csview find, csview replace);
csview cstr_substr(const cstr* s, intptr_t pos, size_t n); // negative pos count from end