8.35. File tom/HashTable

class tom.HashTable

inherits

State supers: State, Keyed

variables

const GOLDEN_BITS = -1640531527;

Thirty-two bits by which to multiply a hashvalue to make all bits, more or less, significant.

This (unsigned) value is (1 << 32) * frac (0.5 + 0.5 * sqrt (5)). The value of which the fractional part is taken is the golden ratio. (0x9e3779b9).

instance tom.HashTable

variables

public int length;

The number of stored objects.

int size_shift;

The 2log of the number of buckets.

MutableObjectArray buckets;

The buckets.

methods


id (self)
  init;

Designated initializer.


void
  empty;

Remove all elements from the table.


void
  do Block block;

Evaluate the block for each object element in this HashTable, by passing this method to the BucketElements.


Any
  at All key;

Return the key if present, or nil otherwise.


Any
  member All object;

A different name for at.


Any
  member All key
   equal selector cmp;

Like member, but the elements are compared using the selector cmp.


Any
  memq All key;

Like member, but the element is identified on reference equality.


void
  encodeUsingCoder Encoder coder;

Undocumented.


void
  initWithCoder Decoder coder;

Undocumented.


protected void
  adjust_length int inc
pre
  inc != 0;

Adjust the length of the hashtable, resizing if necessary.


protected void
  resize int new_shift;

Undocumented.


void
  resizing_add BucketElement elt;

Undocumented.

class tom.HashTableContainer

The HashTableContainer class is just a HashTable which knows how to mark its elements as a container. It is intended to be inherited by various class employing the HashTable class as a superclass for implementation reuse.

inherits

State supers: HashTable, Container

instance tom.HashTableContainer

methods


void
  gc_container_mark_elements;

Undocumented.

class tom.MutableHashTable

inherits

State supers: HashTableContainer, MutableKeyed

instance tom.MutableHashTable

methods


void
  add BucketElement elt;

Add elt to the receiving hashtable.


void
  remove BucketElement elt;

Remove elt from the receiving hashtable, if present.

class tom.HashTableEnumerator

inherits

State supers: State, Enumerator

methods


instance (id)
  with Indexed b;

Undocumented.

instance tom.HashTableEnumerator

variables

Indexed buckets;

The array the dictionary uses to store the buckets.

int next;

The next bucket index we shall use.

BucketElement elt;

The bucket element we're looking at.

methods


protected id
  init Indexed b;

Undocumented.


protected boolean
  next;

Update elt to point to the next bucket element.