Mutable dictionary backed by a linked list.
public class list dictionary[readonly value key type, value value type]
extends base list dictionary[key type, value type]
implements dictionary[key type, value type]
public overload list dictionary(equivalence relation[key type] equivalence)
super(equivalence)
public overload list dictionary()
super(runtime util • default equivalence !> equivalence relation[key type])
public overload list dictionary(key type the key, value type the value)
super(the key, the value, runtime util • default equivalence !> equivalence relation[key type])
implement immutable dictionary[key type, value type] frozen copy()
implement void clear()
implement value type or null put(key type key, value type value)
var entry : entries
if entry is null
entries = entry cell[key type, value type] • new(key, value)
the size = 1
return missing • instance
loop
if equivalence(key, entry • key)
old value : entry • value
entry • set value(value)
return old value
next : entry • next
if next is null
entry • next = entry cell[key type, value type] • new(key, value)
the size += 1
return missing • instance
else
entry = next
implement value type or null remove(key type key)
var entry : entries
if entry is null
return missing • instance
if equivalence(key, entry • key)
old value : entry • value
entries = entry • next
assert new size is nonnegative
the size = new size
return old value
loop
next entry : entry • next
if next entry is null
return missing • instance
if equivalence(key, next entry • key)
old value : next entry • value
entry • next = next entry • next
assert new size is nonnegative
the size = new size
return old value
entry = next entry