8.67. File tom/Sorted

class tom.SortedKeyed

The SortedKeyed class keeps its elements in ascending order.

inherits

State supers: Keyed

instance tom.SortedKeyed

methods


deferred Enumerator
  between (Comparable, Comparable) (start, last);

Enumerate the elements in an interval. nil at the either end signifies the first or the last element.


deferred Any
  lowest;

Undocumented.


deferred Any
  highest;

Undocumented.


deferred redeclare Any
  at Comparable object;

Undocumented.


deferred redeclare Any
  member Comparable object;

Undocumented.


deferred redeclare Any
  memq Comparable object;

Undocumented.

class tom.MutableSortedKeyed

inherits

State supers: SortedKeyed, MutableKeyed

instance tom.MutableSortedKeyed

methods


redeclare void
  add Comparable object;

Undocumented.


redeclare void
  remove Comparable object;

Undocumented.

class tom.SortedMapped

inherits

State supers: Mapped, SortedKeyed

instance tom.SortedMapped

methods


deferred Enumerator
  valuesOfKeysBetween (Comparable, Comparable) (start, last)
         includeLeft: boolean incleft = TRUE
        includeRight: boolean incright = TRUE;

Enumerate the values in an interval.

class tom.MutableSortedMapped

inherits

State supers: MutableSortedKeyed, MutableMapped

instance tom.MutableSortedMapped

methods


deferred redeclare void
  set All value
   at Comparable key;

Undocumented.

class tom.SortedObjectArray

inherits

State supers: SortedKeyed

instance tom.SortedObjectArray

variables

public MutableObjectArray contents;

The array we employ to actually store the contents.

methods


boolean (result)
  verifySortedContents;

Undocumented.


id
  initWithSortedEnumerator Enumerator e
post
  [self verifySortedContents];

Undocumented.


id
  initWithEnumerator Enumerator e;

Undocumented.


ObjectArray
  allKeys;

Undocumented.


(boolean, int)
  indexOf Comparable object;

The guts of the binary search algorithm.


Any
  at Comparable object;

Undocumented.


Enumerator
  valuesOfKeysBetween (Comparable, Comparable) (start, last)
         includeLeft: boolean incleft = TRUE
        includeRight: boolean incright = TRUE;

Undocumented.


Any
  lowest
pre
  [contents length] != 0;

Undocumented.


Any
  highest
pre
  [contents length] != 0;

Undocumented.

class tom.MutableSortedObjectArray

inherits

State supers: MutableSortedKeyed, SortedObjectArray

instance tom.MutableSortedObjectArray

methods


void
  empty;

Undocumented.


void
  freeze;

Undocumented.


void
  add Comparable object;

Add an object.

Note that adding elements one-by-one to a MutableSortedObjectArray will work as an insertion sort, with quadratic performance. Use addElementsFrom with another sorted set instead, as it is much more efficient. Also, do not use addElementsFromEnumerator unless you know that the enumerator is sorted (and then use addElementsFromSortedEnumerator.


void
  addElementsFrom Collection object;

addElementsFrom performs in time proportional to the *sum* of the number of elements in both collections, if the other collection is a SortedKeyed. Otherwise the complexity is equal to the *product* of the number of the elements.


void
  addElementsFromSortedEnumerator Enumerator j
post
  [self verifySortedContents];

Undocumented.


void
  removeElementsFrom Collection object;

Undocumented.


void
  removeElementsFromSortedEnumerator Enumerator j
post
  [self verifySortedContents];

Undocumented.


void
  keepElementsFrom Collection object;

Undocumented.