8.79. File tom/behaviours

class tom.Comparable

inherits

Behaviour supers: All

instance tom.Comparable

inherits

Behaviour supers: All

methods


deferred int
  compare id other
pre
  other != nil;

Return 0 if the other is considered equal by the receiving object. 1 if the receiver considers himself larger, and -1 when smaller.


void
  set_index int index
    in_heap Heap h;

Functionality used by Heap to keep track of the index of its elements. Instances of HeapElement actually remember the index. The default implementation just ignores it.


int
  index_in_heap Heap heap;

Return the index of this element in the heap. Instances of HeapElement can do this O(1) instead of the O(n) of Comparable. On the other hand, Comparable can reside in any number of Heap, and it is only removal other than through root extraction which has become slower.

class tom.Container

A container is an object which gets to mark its elements after normal marking has been done. This is very usable for unique string tables, DO proxies, etc; actually: all cases where an object having become garbage implying it should be removed from its container, and the container itself is not allowed to reference the object in a normal way (since then it would never become garbage).

In short, a the combo of garbage collector and container implements weak referencing.

instance tom.Container

methods


deferred void
  gc_container_mark_elements;

The container mark method.


boolean
  isContainer;

Return TRUE iff the receiving object is a container.


void
  setIsContainer boolean container_p;

Set this object to be a container, or not, depending on container_p.


void
  setStackNotify boolean notify_p;

State that this container wants to be notified when it is conservatively pinpointed.


boolean
  wantsStackNotify;

Does this container receive stack notifications?


void
  gc_stack_notify;

Be notified of a reference from the stack, as request by setStackNotify. Default implementation does nothing.

class tom.Copying

The Copying class defines an interface to copying objects.

Copying inherits from State since class objects should not be copyable. Inheriting from State ensures that the Copying instance methods can not be inherited by class objects.

inherits

State supers: State

instance tom.Copying

methods


id
  copy;

Return a shallow copy of the receiving object.


id
  deepCopy;

Return a deep copy of the receiving object.


id
    deepen int level
  mutably: boolean mutable_p = NO;

Intended to be called on a recently acquired copy of an object, deepen mutable: deepens the copy. Iff the optional mutable_p is TRUE, the deepened copies will also be mutable. The default implementation does nothing.

The level should be less than 0 for an infinite deepen. length == 0 is a nop; iff length > 0, every element of the copy is copied and deepened with level - 1.

The value returned is self.


id
  initCopy;

Initialize the receiver just after it has been created as the result of a copy. The default implementation does nothing but return self.


id
  initAsCopyOf All other;

Initialize the receiver just after it has been created as the result of a mutableCopy of the other object. The default implementation does nothing but returning self.


Any
  mutableCopy;

Return a mutable (shallow) copy of the receiving object. For objects which do not discern between mutable and immutable variants, the default implementation returns [self copy].

Mutable copying asks the receiving object for its mutableCopyClass. If this class is isa, self is sent a copy. Otherwise, an instance of the class is allocated and sent an initAsCopyOf.


class (State)
  mutableCopyClass;

Return the class of the object resulting from a mutable copy of this object. The default implementation simply returns isa.

class tom.Enumerable

inherits

State supers: State

methods


instance (id)
  withEnumerable Enumerable other;

Invoke self's withEnumerator with an enumerator from the other.


instance (id)
  withEnumerator Enumerator e;

Return a newly allocated instance of the receiving class, filled with the elements from the Enumerator e.

instance tom.Enumerable

methods


deferred protected id
  initWithEnumerator Enumerator e;

Initialize with the elements from the Enumerator e.


deferred Enumerator
  enumerator;

Return an Enumerator on the receiving object.

class tom.Enumerator

instance tom.Enumerator

methods


deferred (boolean, Any)
  next;

Return a tuple containing the next object, preceded by a boolean value indicating whether the end of the enumerable has been reached; if the boolean is TRUE, the end has not yet been reached.


(boolean, byte)
  next;

Default implementations for direct value retrieving enumerators.


(boolean, char)
  next;

Undocumented.


(boolean, int)
  next;

Undocumented.


(boolean, long)
  next;

Undocumented.


(boolean, float)
  next;

Undocumented.


(boolean, double)
  next;

Undocumented.


(boolean, pointer)
  next;

Undocumented.

class tom.MapEnumerator

inherits

State supers: Enumerator

instance tom.MapEnumerator

methods


deferred (boolean, Any, Any)
  next;

MapEnumerator allows iteration over both keys and values.