Base class for the dictionary backed by a linked list.
public abstract class base hash set[readonly value element type]
implements readonly set[element type]
namespace parameters
default size : 16
protected class hash cell[readonly value element type]
protected element type the value
public overload hash cell(element type the value, integer the hash, hash cell[element type] or null next)
Wrapper of an array that implements on-demand resizing and copy-on-write semantics.
The same set_state can be shared by multiple instances of base_hash_sets.
protected class set state[readonly value element type]
import ideal • machine • elements • array
Specifies whether this instance of set_state is writable.
A single non-writable copy can be shared among multiple instances of base_hash_set.
var boolean writable
Specifies how many elements are stored in this set_state.
The size is less or equal to the_buckets.size.
var nonnegative size
Construct a dictionary state with an array of specified size.
overload set state(nonnegative initial size)
Construct a dictionary state with a table of default size.
overload set state()
this(parameters • default size)
Make sure the array is of at least the specified size.
void reserve(nonnegative reserve size)
if the buckets • size >= reserve size
if new size < reserve size
for var nonnegative i : 0; i < old buckets • size; i += 1
return
new size = reserve size
old buckets • scrub(0, old buckets • size)
protected set state[element type] copy()
for var nonnegative i : 0; i < the buckets • size; i += 1
while bucket is_not null
new cell : hash cell[element type] • new(bucket • the value, bucket • the hash, result • the buckets[i])
return result
protected overload base hash set(equivalence with hash[element type] equivalence)
this • equivalence = equivalence
protected overload base hash set(equivalence with hash[element type] equivalence, set state[element type] state)
this • equivalence = equivalence
this • state = state
Specifies whether the collection has more than zero elements.
Shortcut for !is_empty.
implement boolean is not empty => state • 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[element type] elements()
if is empty
for var nonnegative i : 0; i < state • the buckets • size; i += 1
return empty[element type] • new()
return result • frozen copy()