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 dictionaryentry[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, missinginstance)
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 = originalequivalence
the size = originalthe size
entries = duplicate(originalentries)
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(originalkey, originalvalue)
var current : copy
var tail : originalnext
while tail is_not null
cell copy : entry cell[key type, value type] • new(tailkey, tailvalue)
currentnext = cell copy
current = cell copy
tail = tailnext
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[dictionaryentry[key type, value type]] elements()
if is empty
return empty[dictionaryentry[key type, value type]] • new()
for var entry : entries; entry is_not null; entry = entrynext
resultappend(base dictionary entry[key type, value type] • new(entry))
return resultfrozen copy()
implement value type or null get(key type key)
assert key is_not null
for var entry : entries; entry is_not null; entry = entrynext
if equivalence(key, entrykey)
return entryvalue
return missinginstance
implement boolean contains key(key type key)
assert key is_not null
for var entry : entries; entry is_not null; entry = entrynext
if equivalence(key, entrykey)
return true
return false
implement immutable set[key type] keys()
for var entry : entries; entry is_not null; entry = entrynext
resultadd(entrykey)
return resultfrozen copy()
implement readonly collection[value type] values()
for var entry : entries; entry is_not null; entry = entrynext
resultappend(entryvalue)
return resultfrozen copy()