Base class for the dictionary backed by a linked list.
public abstract class base list dictionary[readonly value key type, value value type]
implements readonly dictionary[key type, value type]
protected class entry cell[readonly value key type, value value type]
implements dictionary • entry[key type, value type]
private key type the key
private var value type the value
protected var entry cell[key type, value type] or null next
public overload entry cell(key type the key, value type the value, entry cell[key type, value type] or null next)
this • the key = the key
this • the value = the value
this • next = next
public overload entry cell(key type the key, value type the value)
this(the key, the value, missing • instance)
override key type key()
return the key
override value type value()
return the value
protected void set value(value type new value)
this • the value = new value
protected equivalence relation[key type] equivalence
protected var nonnegative the size
protected var entry cell[key type, value type] or null entries
protected overload base list dictionary(base list dictionary[key type, value type] original)
this • equivalence = original • equivalence
the size = original • the size
entries = duplicate(original • entries)
private entry cell[key type, value type] or null duplicate(entry cell[key type, value type] or null original) raw
if original is null
return original
copy : entry cell[key type, value type] • new(original • key, original • value)
var current : copy
var tail : original • next
while tail is_not null
cell copy : entry cell[key type, value type] • new(tail • key, tail • value)
current • next = cell copy
current = cell copy
tail = tail • next
return copy
The number of elements in the collection.
implement nonnegative size => the size
Specifies whether the collection has zero elements.
implement boolean is empty => the size == 0
Specifies whether the collection has more than zero elements. Shortcut for !is_empty.
implement boolean is not empty => the size != 0
Enumerates elements in some collection-defined order. This method returns a snapshot of the collection state, so subsequent mutations of the collection do not cause changes in the returned list.
implement immutable list[dictionary • entry[key type, value type]] elements()
if is empty
return empty[dictionary • entry[key type, value type]] • new()
for var entry : entries; entry is_not null; entry = entry • next
result • append(base dictionary entry[key type, value type] • new(entry))
return result • frozen copy()
implement value type or null get(key type key)
assert key is_not null
for var entry : entries; entry is_not null; entry = entry • next
if equivalence(key, entry • key)
return entry • value
return missing • instance
implement boolean contains key(key type key)
assert key is_not null
for var entry : entries; entry is_not null; entry = entry • next
if equivalence(key, entry • key)
return true
return false
implement immutable set[key type] keys()
for var entry : entries; entry is_not null; entry = entry • next
result • add(entry • key)
return result • frozen copy()
implement readonly collection[value type] values()
for var entry : entries; entry is_not null; entry = entry • next
result • append(entry • value)
return result • frozen copy()