org.abora.white.collection.tables
Class MuTable

java.lang.Object
  |
  +--org.abora.white.xpp.basic.Heaper
        |
        +--org.abora.white.collection.tables.ScruTable
              |
              +--org.abora.white.collection.tables.MuTable
Direct Known Subclasses:
HashTable, IntegerTable

public abstract class MuTable
extends ScruTable

MuTable represents the base class for all side-effectable tables. It provides the basic change protocol for tables. See MuSet.


Constructor Summary
protected MuTable()
          Create a new table with an unspecified number of initial domain positions.
protected MuTable(Rcvr receiver)
           
 
Method Summary
 int actualHashForEqual()
          See ScruTable::isEqual
 ImmuTable asImmuTable()
          Return a side-effect-free snapshot of my current contents.
 MuTable asMuTable()
          Note that muTable->asMuTable() returns a copy of the original.
 void atIntIntroduce(IntegerValue key, Heaper value)
          Unboxed version.
 void atIntReplace(IntegerValue key, Heaper value)
          Unboxed version.
 void atIntroduce(Position key, Heaper value)
          Associate key with value unless key is already associated with another value.
 Heaper atIntStore(IntegerValue aKey, Heaper anObject)
          Unboxed version.
 void atReplace(Position key, Heaper value)
          Associate key with value only if key is already associated with a value.
abstract  Heaper atStore(Position key, Heaper value)
          Associate value with key, whether or not there is a previous association.
abstract  CoordinateSpace coordinateSpace()
          The kind of elements used to index into the table are Positions of this coordinate space.
abstract  ScruTable copy()
          A new one whose initial state is my current state, but that doesn't track changes.
abstract  IntegerValue count()
          Return the number of domain elements, which is to say, the number of associations.
abstract  XnRegion domain()
          Return an XuRegion representing a snapshot of the current domain.
abstract  ScruTable emptySize(IntegerValue size)
          Return an empty table just like the current one.
abstract  Heaper fetch(Position key)
          Return the range element at the domain position key.
 boolean includesIntKey(IntegerValue aKey)
          Unboxed version.
abstract  boolean includesKey(Position aKey)
          includesKey is used to test for the presence of a key->value pair in the table.
 Heaper intFetch(IntegerValue key)
          Unboxed version.
 void intRemove(IntegerValue anIdx)
          Unboxed version.
 void introduceAll(ScruTable other)
           
 void introduceAll(ScruTable table, Dsp dsp)
           
 void introduceAll(ScruTable table, Dsp dsp, XnRegion region)
          'MuTable::introduceAll is to 'MuTable::introduce' as 'MuTable::storeAll' is to 'MuTable::store'.
 boolean intWipe(IntegerValue anIdx)
          Unboxed version.
abstract  boolean isEmpty()
          Is there anything in the table? 'table->isEmpty()' iff 'table->domain()->isEmpty()'.
 boolean isEqual(Heaper other)
          All MuTable subclasses have equality based on identity (now and forever equal.
static MuTable make(CoordinateSpace cs)
          A new empty MuTable whose domain space is 'cs'.
static MuTable make(CoordinateSpace cs, XnRegion reg)
          Semantically identical to 'muTable(cs)'.
static void problems()
           
 void remove(Position anIdx)
          Remove a key->value association from the table.
 void removeAll(XnRegion region)
           
 void replaceAll(ScruTable other)
           
 void replaceAll(ScruTable other, Dsp dsp)
           
 void replaceAll(ScruTable table, Dsp dsp, XnRegion region)
          'MuTable::replaceAll is to 'MuTable::replace' as 'MuTable::storeAll' is to 'MuTable::store'.
abstract  XnRegion runAt(Position key)
          Return the length of the run starting at position key.
 XnRegion runAtInt(IntegerValue index)
          Unboxed version.
 void sendSelfTo(Xmtr xmtr)
           
abstract  TableStepper stepper(OrderSpec order)
          Return a TableStepper which will enumerate my key->value mappings.
 void storeAll(ScruTable other)
           
 void storeAll(ScruTable table, Dsp dsp)
           
 void storeAll(ScruTable table, Dsp dsp, XnRegion region)
          I 'store' into myself (see MuTable::store) all the associations from 'table'.
abstract  ScruTable subTable(XnRegion reg)
          Return a table which contains only the intersection of this table's domain and the domain specified by 'region'.
abstract  boolean wipe(Position anIdx)
          Remove a key->value association from the table.
 void wipeAll(XnRegion region)
          I 'wipe' from myself all associations whose key is in 'region'.
 
Methods inherited from class org.abora.white.collection.tables.ScruTable
backfollowFrom, contentsEqual, contentsHash, get, intGet, printOn, printOnWithSimpleSyntax, printOnWithSyntax, range, stepper, theOne, transformedBy
 
Methods inherited from class org.abora.white.xpp.basic.Heaper
destroy, destruct, equals, hashForEqual, printContentsOn, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

MuTable

protected MuTable()
Create a new table with an unspecified number of initial domain positions.


MuTable

protected MuTable(Rcvr receiver)
Method Detail

atIntroduce

public void atIntroduce(Position key,
                        Heaper value)
Associate key with value unless key is already associated with another value. If so, blast.


atReplace

public void atReplace(Position key,
                      Heaper value)
Associate key with value only if key is already associated with a value. Otherwise blast.


atStore

public abstract Heaper atStore(Position key,
                               Heaper value)
Associate value with key, whether or not there is a previous association. Return the old range element if the position was previously occupied, NULL otherwise


coordinateSpace

public abstract CoordinateSpace coordinateSpace()
Description copied from class: ScruTable
The kind of elements used to index into the table are Positions of this coordinate space. Therefore, the domain of this table is an XuRegion in this coordinate space.

Specified by:
coordinateSpace in class ScruTable

count

public abstract IntegerValue count()
Description copied from class: ScruTable
Return the number of domain elements, which is to say, the number of associations. 'table->count()' should be equivalent to 'table->domain()->count()'. Used to say: 'Return the number of range elements'. This seems clearly wrong.

Specified by:
count in class ScruTable

domain

public abstract XnRegion domain()
Description copied from class: ScruTable
Return an XuRegion representing a snapshot of the current domain. 'table->domain()->hasMember(p)' iff 'table->fetch(p) !!= NULL'.

Specified by:
domain in class ScruTable

fetch

public abstract Heaper fetch(Position key)
Description copied from class: ScruTable
Return the range element at the domain position key. The routine will return NULL if the position is not in the table.

Specified by:
fetch in class ScruTable

remove

public void remove(Position anIdx)
Remove a key->value association from the table. Blast if the key is not present.


subTable

public abstract ScruTable subTable(XnRegion reg)
Description copied from class: ScruTable
Return a table which contains only the intersection of this table's domain and the domain specified by 'region'. table->subTable(r)->domain()->isEqual( table->domain()->intersect(r) ). It is unspecified whether the resulting table starts as a snapshot of a subset of me, after which we go our own ways; or whether the resulting table is a view onto a subset of me, such that changes to me are also visible to him. Of course, subclasses may specify more. If you want to ensure snapshot behavior, do 'table->subTable(r)->asImmuTable()'. NOTE: In the future we may specify snapshot behavior or we may specify view behavior. As a client this shouldn't effect you. However, if you implement a new kind of ScruTable, please let us know. Also, if you have an opinion as to which way you'd like the specification tightened up, please tell us.

Specified by:
subTable in class ScruTable

wipe

public abstract boolean wipe(Position anIdx)
Remove a key->value association from the table. Do not blast (or do anything else) if the key is not in my current domain. Return TRUE if the association was present and removed, Return FALSE if the association was not there


introduceAll

public void introduceAll(ScruTable table,
                         Dsp dsp,
                         XnRegion region)
'MuTable::introduceAll is to 'MuTable::introduce' as 'MuTable::storeAll' is to 'MuTable::store'. See MuTable::storeAll. In addition to the functionality provided by MuTable::storeAll, I BLAST *if* all the associations I'm being asked to store override existing associations of mine. If I BLAST for this reason, then I guarantee that I haven't changed myself at all.


replaceAll

public void replaceAll(ScruTable table,
                       Dsp dsp,
                       XnRegion region)
'MuTable::replaceAll is to 'MuTable::replace' as 'MuTable::storeAll' is to 'MuTable::store'. See MuTable::storeAll. In addition to the functionality provided by MuTable::storeAll, I BLAST *unless* all the associations I'm being asked to store override existing associations of mine. If I BLAST for this reason, then I guarantee that I haven't changed myself at all.


storeAll

public void storeAll(ScruTable table,
                     Dsp dsp,
                     XnRegion region)
I 'store' into myself (see MuTable::store) all the associations from 'table'. If 'region' is provided, then I only store those associations from 'table' whose key is inside 'region'. If 'dsp' is provided, then I transform the keys (from the remaining associations) by dsp before storing into myself.


wipeAll

public void wipeAll(XnRegion region)
I 'wipe' from myself all associations whose key is in 'region'. See MuTable::wipe


includesKey

public abstract boolean includesKey(Position aKey)
Description copied from class: ScruTable
includesKey is used to test for the presence of a key->value pair in the table. This routine returns true if there is a value present at the specified key, and false otherwise. 'table->includesKey(p)' iff 'table->domain()->hasMember(p)'.

Overrides:
includesKey in class ScruTable

isEmpty

public abstract boolean isEmpty()
Description copied from class: ScruTable
Is there anything in the table? 'table->isEmpty()' iff 'table->domain()->isEmpty()'.

Specified by:
isEmpty in class ScruTable

stepper

public abstract TableStepper stepper(OrderSpec order)
Description copied from class: ScruTable
Return a TableStepper which will enumerate my key->value mappings. The Stepper component of the TableStepper protocol will just enumerate my values (as that is what I'm a container *of*--the keys are simply how I organize my contents). TableStepper provides additional protocol to ascetain the current key. See TableStepper and XuRegion::stepper. The TableStepper I produce given an order must enumerate keys according to the same rules which specify how XuRegion::stepper must enumerate positions. I am not asserting that the actual orders are the same, only that the correctness criteria on the allowable orders are the same. Keeping in mind that we are talking about equivalence of specification and not equivalence of particular behavior, the following two statements are equivalent: { SPTR(TableStepper) stomp = table->stepper(o); SPTR(Position) key; FOR_EACH(Heaper,val,stomp, { key = stomp->key(); doSomethingWith(key, val); }); } and { SPTR(Heaper) val; SPTR(ImmuTable) snapShot = table->asImmuTable(); FOR_EACH(Position,key,(snapShot->domain()->stepper(o)), { val = snapShot->get (key); doSomethingWith(key, val); }); }

Specified by:
stepper in class ScruTable

asImmuTable

public ImmuTable asImmuTable()
Description copied from class: ScruTable
Return a side-effect-free snapshot of my current contents. See ScruSet::asImmuSet.

Specified by:
asImmuTable in class ScruTable

asMuTable

public MuTable asMuTable()
Note that muTable->asMuTable() returns a copy of the original. The two are now free to change independently.

Specified by:
asMuTable in class ScruTable

runAt

public abstract XnRegion runAt(Position key)
Description copied from class: ScruTable
Return the length of the run starting at position key. A run is defined as a contiguous (charming) sequence of domain positions mapping to equal (isEqual) objects. Charming is defined as: Given a charming region R, for all a,c which are elements of R and a >= b >= c, b is an element of R. Where '>=' is according to the 'isGE' message. NOTE: We may retire the above definition of charming. The possible changes will only effect spaces which aren't fully ordered. OrderedRegions, TreeRegions, and IntegerRegions will be unaffected, as any future definition of 'runAt' will be equivalent for them.

Specified by:
runAt in class ScruTable

copy

public abstract ScruTable copy()
Description copied from class: ScruTable
A new one whose initial state is my current state, but that doesn't track changes. Note that there is no implication that these can be 'destroy'ed separately, because (for example) an ImmuTable just returns itself

Specified by:
copy in class ScruTable

emptySize

public abstract ScruTable emptySize(IntegerValue size)
Description copied from class: ScruTable
Return an empty table just like the current one. The 'size' argument is a hint about how big the count of the table will probably become (so that the new table can be prepared to grow to that size efficiently).

Specified by:
emptySize in class ScruTable

atIntIntroduce

public void atIntIntroduce(IntegerValue key,
                           Heaper value)
Unboxed version. See class comment for XuInteger


atIntReplace

public void atIntReplace(IntegerValue key,
                         Heaper value)
Unboxed version. See class comment for XuInteger


atIntStore

public Heaper atIntStore(IntegerValue aKey,
                         Heaper anObject)
Unboxed version. See class comment for XuInteger


includesIntKey

public boolean includesIntKey(IntegerValue aKey)
Description copied from class: ScruTable
Unboxed version. See class comment for XuInteger

Overrides:
includesIntKey in class ScruTable

intFetch

public Heaper intFetch(IntegerValue key)
Description copied from class: ScruTable
Unboxed version. See class comment for XuInteger

Overrides:
intFetch in class ScruTable

intRemove

public void intRemove(IntegerValue anIdx)
Unboxed version. See class comment for XuInteger


intWipe

public boolean intWipe(IntegerValue anIdx)
Unboxed version. See class comment for XuInteger


runAtInt

public XnRegion runAtInt(IntegerValue index)
Description copied from class: ScruTable
Unboxed version. See class comment for XuInteger

Overrides:
runAtInt in class ScruTable

introduceAll

public void introduceAll(ScruTable other)

introduceAll

public void introduceAll(ScruTable table,
                         Dsp dsp)

removeAll

public void removeAll(XnRegion region)

replaceAll

public void replaceAll(ScruTable other)

replaceAll

public void replaceAll(ScruTable other,
                       Dsp dsp)

storeAll

public void storeAll(ScruTable other)

storeAll

public void storeAll(ScruTable table,
                     Dsp dsp)

actualHashForEqual

public int actualHashForEqual()
Description copied from class: ScruTable
See ScruTable::isEqual

Overrides:
actualHashForEqual in class ScruTable

isEqual

public boolean isEqual(Heaper other)
Description copied from class: ScruTable
All MuTable subclasses have equality based on identity (now and forever equal. Many ScruTable subclasses will represent an aspect of another table. Therefore they have hashForEqual and isEqual: based on both their contained table, and the aspect that they represent. Thus, two similar views onto the same MuTable are now (and forever) equal. The hashForEqual: must use exactly the same aspects for the hash as get used for isEqual:. ImmuTables all use contentBased comparison operations.

Specified by:
isEqual in class ScruTable

sendSelfTo

public void sendSelfTo(Xmtr xmtr)
Overrides:
sendSelfTo in class Heaper

problems

public static void problems()

make

public static MuTable make(CoordinateSpace cs)
A new empty MuTable whose domain space is 'cs'.


make

public static MuTable make(CoordinateSpace cs,
                           XnRegion reg)
Semantically identical to 'muTable(cs)'. 'reg' just provides a hint as to what part of the domain space the new table should expect to be occupied.



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