8.73. File tom/Trie

class tom.Trie

The Trie is a class providing the mechanism to store information in a trie on char strings. It does not by itself store any information, subclasses should be created to hold the information. The Trie is accompanied by its subclass ObjectTrie which can store objects in a trie.

inherits

State supers: State, Constants

instance tom.Trie

variables

int start;

The offset to the first element in next, i.e. the element with numeric value start resides at index 0 in next.

int beyond;

The value of the first element beyond the last element in next.

Any next;

If start == beyond, this is the suffix String which leads up to the value this node holds (if any). Otherwise, start > beyond and this is a MutableObjectArray pointing to the next nodes, and which is to be indexed with offset start.

methods


deferred boolean
  isEmpty;

Return YES iff we can hold a value, i.e. if we do not yet hold a value.


protected id
  createNode String str
       start int s
         end int e
     options int options;

Create the node for that part of the string str starting at s, and ending at e. The TRIE_LOOKUP_PREFIX option is ignored. If this node already exists, it is returned.

When the options include TRIE_FOLD_CASE, the str is inserted in lower case.


protected id
  findNode String str
     start int s
       end int e
   options int options;

Find the node for that part of the string str starting at s, and ending at e. Iff a prefix match is desired, the node returned is the longest prefix match.


protected void
  pushSuffix int options;

Push our suffix one node down.


OutputStream
  write OutputStream s;

Undocumented.


deferred OutputStream
  writeValue OutputStream s;

Undocumented.

class tom.ObjectTrie

An ObjectTrie is a Trie which can hold an object.

inherits

State supers: Trie

instance tom.ObjectTrie

variables

public mutable Any value;

Our value.

methods


boolean
  isEmpty;

Undocumented.


void
  pushSuffix int options;

Move our value with the suffix.


Any
       at String key
  options int options;

Undocumented.


void
      set All object
       at String key
  options int options;

Undocumented.


OutputStream
  writeValue OutputStream s;

Undocumented.


Any
  at String key;

Undocumented.


void
  set All object
   at String key;

Undocumented.