Add containers hashing implementation
This commit is contained in:
@@ -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));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user