/* * SOaLDhS: Statically-allocated, Open-addressing, Linear probing, Dynamic hash, sentinels */ record KVPair[K, V] { K key; V value; } record MapSOaLDhS[K, V, S; capacity, sentinel] { S(K*) hash; KVPair[capacity] data; } MapSOaLDhS_add: [K, V, S; capacity, sentinel]u1(MapSOaLDhS[K, V, S; capacity, sentinel]* this, K* key, V* value) -> { S index = ((*this).hash)(value); index = index & (capacity - 1); loop { KVPair[K, V]* pair = &((*this).data[index]); if(((*pair).key == *key) || ((*pair).value == sentinel)) { (*pair).key = *key; (*pair).value = *value; } index = index + 1; } return 1; }; @instantiate MapSOaLDhS_add[ugpr, ugpr, ugpr; 128, 0]; MapSOaLDhS[ugpr, ugpr, ugpr; 128, 0] map;