summaryrefslogtreecommitdiffhomepage
path: root/examples/box.c
diff options
context:
space:
mode:
authorTyge Løvset <[email protected]>2022-04-22 12:20:31 +0200
committerTyge Løvset <[email protected]>2022-04-22 12:20:31 +0200
commit8f57f3d331de4cb4aa7d06862c2de3424eb1ba5b (patch)
tree1a730578475e4d6e260948578cd0c2a5fd4463f4 /examples/box.c
parent182099800f230f876fb46dac9f1f49a4fe3c3981 (diff)
downloadSTC-modified-8f57f3d331de4cb4aa7d06862c2de3424eb1ba5b.tar.gz
STC-modified-8f57f3d331de4cb4aa7d06862c2de3424eb1ba5b.zip
Readded push()/emplace() to all containers missing them. Made _hash function required for i_key_bind, _eq is derived from _cmp.
Diffstat (limited to 'examples/box.c')
-rw-r--r--examples/box.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/examples/box.c b/examples/box.c
index d2d98218..4a43b149 100644
--- a/examples/box.c
+++ b/examples/box.c
@@ -7,6 +7,10 @@ Person Person_new(const char* name, const char* last) {
return (Person){.name = cstr_from(name), .last = cstr_from(last)};
}
+uint64_t Person_hash(const Person* a, size_t n) {
+ return cstr_hash(&a->name, 0) ^ cstr_hash(&a->last, 0);
+}
+
int Person_cmp(const Person* a, const Person* b) {
int c = cstr_cmp(&a->name, &b->name);
return c ? c : cstr_cmp(&a->last, &b->last);