MCPcopy Create free account
hub / github.com/RedisGraph/RedisGraph / Map_HashCode

Function Map_HashCode

src/datatypes/map.c:266–286  ·  view source on GitHub ↗

this method referenced by Java ArrayList.hashCode() method, which takes into account the hashing of nested values

Source from the content-addressed store, hash-verified

264// this method referenced by Java ArrayList.hashCode() method, which takes
265// into account the hashing of nested values
266XXH64_hash_t Map_HashCode
267(
268 SIValue map
269) {
270 // sort the map by key, so that {a:1, b:1} and {b:1, a:1}
271 // have the same hash value
272 uint key_count = Map_KeyCount(map);
273 qsort(map.map, key_count, sizeof(Pair),
274 (int(*)(const void*, const void*))_key_cmp);
275
276 SIType t = T_MAP;
277 XXH64_hash_t hashCode = XXH64(&t, sizeof(t), 0);
278
279 for(uint i = 0; i < key_count; i++) {
280 Pair p = map.map[i];
281 hashCode = 31 * hashCode + SIValue_HashCode(p.key);
282 hashCode = 31 * hashCode + SIValue_HashCode(p.val);
283 }
284
285 return hashCode;
286}
287
288void Map_ToString
289(

Callers 1

SIValue_HashUpdateFunction · 0.85

Calls 2

Map_KeyCountFunction · 0.85
SIValue_HashCodeFunction · 0.85

Tested by

no test coverage detected