pub fn fetchPut(self: *Self, key: Key, value: Value) ?Value
Sets the value associated with the key in the map, and returns the old value. If the key was not in the map, returns null.
self: *Self
key: Key
value: Value
580 581 582 583 584 585 586
pub fn fetchPut(self: *Self, key: Key, value: Value) ?Value { const index = Indexer.indexOf(key); const result: ?Value = if (self.bits.isSet(index)) self.values[index] else null; self.bits.set(index); self.values[index] = value; return result; }
Sets the value associated with the key in the map, and returns the old value. If the key was not in the map, returns null.