Add containers hashing implementation

This commit is contained in:
2022-08-14 21:05:33 +03:00
parent 4e6d83c4cf
commit 5c39f4970c
3 changed files with 61 additions and 9 deletions
+16
View File
@@ -5,6 +5,22 @@
/*#####################################################################################################################*/
hash_t list_hash(const list_t* s) {
hash_t hash = 0;
if (!is_null(s->first)) {
hash = vnode_hash(&s->first->node, s->first->type);
if (s->first != s->last) {
hash += vnode_hash(&s->first->node, s->first->type);
hash ^= list_size(s);
} else hash ^= 1;
}
return hash + VTYPE_LIST;
}
void list_init(list_t* x) {
memset(x, 0, sizeof(*x));
}