org.abora.white.collection.steppers
Class TableStepper

java.lang.Object
  |
  +--org.abora.white.xpp.basic.Heaper
        |
        +--org.abora.white.collection.steppers.Stepper
              |
              +--org.abora.white.collection.steppers.TableStepper
Direct Known Subclasses:
ArrayStepper, BucketArrayStepper, IntegerTableStepper, OffsetArrayStepper, OffsetScruTableStepper, PtrArrayStepper

public abstract class TableStepper
extends Stepper

For enumerating the key->value associations of a table. A typical use (for a table whose range elements were all Foos) might be: SPTR(TableStepper) stomp = table->stepper(); FOR_EACH(Foo,f,stomp, { doSomethingWith(stomp->key(), z); }); Each iteration of the loop would correspond to an association of the table (snapshotted at the time "->stepper()" was sent). For each association, "f" (a pointer to Foo) points at the range element, while "stomp->key()" provides the domain element. See ScruTable::stepper.


Field Summary
 
Fields inherited from class org.abora.white.collection.steppers.Stepper
TheEmptyStepper
 
Constructor Summary
TableStepper()
           
TableStepper(Rcvr rcvr)
           
 
Method Summary
static TableStepper ascending(PtrArray array)
          Note: this being a low level operation, and there being no lightweight form of immutable or lazily copied PtrArray, it is my caller's responsibility to pass me a PtrArray which will in fact not be changed during the life of this stepper.
abstract  Stepper copy()
          Return a new stepper which steps independently of me, but whose current value is the same as mine, and which must produce a future history of values which satisfies the same obligation that my contract obligates me to produce now.
static TableStepper descending(PtrArray array)
          Note: this being a low level operation, and there being no lightweight form of immutable or lazily copied PtrArray, it is my caller's responsibility to pass me a PtrArray which will in fact not be changed during the life of this stepper.
abstract  Heaper fetch()
          If I am exhausted (i.e., if (!! this->hasValue())), then return NULL.
abstract  boolean hasValue()
          Iff I have a current value (i.e.
 IntegerValue index()
          Unboxed version of TableStepper::key.
static void info()
          {Position CLIENT} position {PrimArray CLIENT} stepManyPairs: count {Int32 default: -1}
 Position key()
          A TableStepper actually enumerates the associations of a table.
abstract  Position position()
          A TableStepper actually enumerates the associations of a table.
abstract  void step()
          Essential.
 PrimArray stepManyPairs()
           
 PrimArray stepManyPairs(int count)
          An array of the remaining elements in alternating positions in the array [k1, v1, k2, v2, k3, v3, ...] Returns an array of up to count * 2 elements (or some arbitrary number if count is negative), and steps the stepper the corresponding number of times.
 
Methods inherited from class org.abora.white.collection.steppers.Stepper
actualHashForEqual, atEnd, emptyStepper, get, isEqual, itemStepper, stepMany, stepMany, theOne
 
Methods inherited from class org.abora.white.xpp.basic.Heaper
destroy, destruct, equals, hashForEqual, printContentsOn, printOn, sendSelfTo, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

TableStepper

public TableStepper()

TableStepper

public TableStepper(Rcvr rcvr)
Method Detail

key

public Position key()
A TableStepper actually enumerates the associations of a table. Through the normal Stepper protocol, it makes available the range element of the current association. Through this additional protocol, it make accessible the key of the current association. This message returns the same object as TwoStepper::other, the only difference being the static knowledge that it's a Position.


index

public IntegerValue index()
Unboxed version of TableStepper::key. See class comment in XuInteger.


position

public abstract Position position()
A TableStepper actually enumerates the associations of a table. Through the normal Stepper protocol, it makes available the range element of the current association. Through this additional protocol, it make accessible the key of the current association. This message returns the same object as TwoStepper::other, the only difference being the static knowledge that it's a Position.


copy

public abstract Stepper copy()
Description copied from class: Stepper
Return a new stepper which steps independently of me, but whose current value is the same as mine, and which must produce a future history of values which satisfies the same obligation that my contract obligates me to produce now. Typically, this will mean that he must produce the same future history that I'm going to produce. However, let's say that I am enumerating the elements of a partial order in some full order which is consistent with the partial order. If a copy of me is made after I'm part way through, then me and my copy may produce any future history compatable both with the partial order and the elements I've already produced by the time of the copy. Of course, a subclass or a Stepper creating message (like IntegerRegion::stepper()) may specify the more stringent requirement (that a copy must produce the same sequence). To prevent aliasing, Steppers should typically be passed by copy. See class comment.

Specified by:
copy in class Stepper

fetch

public abstract Heaper fetch()
Description copied from class: Stepper
If I am exhausted (i.e., if (!! this->hasValue())), then return NULL. Else return current element. I return wimpily since most items returned are held by collections. If I create a new object, I should cache it.

Specified by:
fetch in class Stepper

hasValue

public abstract boolean hasValue()
Description copied from class: Stepper
Iff I have a current value (i.e. this message returns true), then I am not exhasted. 'fetch' and 'get' will both return this value, and I can be 'step'ped to my next state. As I am stepped, eventually I may become exhausted (the reverse of all the above), which is a permanent condition. Note that not all steppers have to be exhaustable. A Stepper which enumerates all primes is perfectly reasonable. Assuming otherwise will create infinite loops. See class comment.

Specified by:
hasValue in class Stepper

step

public abstract void step()
Description copied from class: Stepper
Essential. If I am currently exhausted (see Stepper::hasValue()), then it is an error to step me. The result of doing so isn't currently specified (we probably should specify it to BLAST, but I know that the implementation doesn't currently live up to that spec). If I am not exhausted, then this advances me to my next state. If my current value (see Stepper::get()) was my final value, then I am now exhausted, otherwise my new current value is the next value.

Specified by:
step in class Stepper

stepManyPairs

public PrimArray stepManyPairs(int count)
An array of the remaining elements in alternating positions in the array [k1, v1, k2, v2, k3, v3, ...] Returns an array of up to count * 2 elements (or some arbitrary number if count is negative), and steps the stepper the corresponding number of times. You should check whether the stepper is atEnd, since it can stop before the number you give it because of some internal limit or grouping issue.


stepManyPairs

public PrimArray stepManyPairs()

info

public static void info()
{Position CLIENT} position {PrimArray CLIENT} stepManyPairs: count {Int32 default: -1}


ascending

public static TableStepper ascending(PtrArray array)
Note: this being a low level operation, and there being no lightweight form of immutable or lazily copied PtrArray, it is my caller's responsibility to pass me a PtrArray which will in fact not be changed during the life of this stepper. This is an unchecked an uncheckable precondition on my clients.


descending

public static TableStepper descending(PtrArray array)
Note: this being a low level operation, and there being no lightweight form of immutable or lazily copied PtrArray, it is my caller's responsibility to pass me a PtrArray which will in fact not be changed during the life of this stepper. This is an unchecked an uncheckable precondition on my clients.



Copyright © 2003 David G Jones. All Rights Reserved.
Original Udanax-Gold - Copyright © 1979-1999 Udanax.com. All rights reserved.