org.abora.gold.collection.tables
Class ImmuTable

java.lang.Object
  |
  +--org.abora.gold.java.AboraHeaper
        |
        +--org.abora.gold.xpp.basic.Heaper
              |
              +--org.abora.gold.collection.tables.ScruTable
                    |
                    +--org.abora.gold.collection.tables.ImmuTable
Direct Known Subclasses:
ImmuTableOnMu, OffsetImmuTable

public class ImmuTable
extends ScruTable

ImmuTable are to ScruTables much like ImmuSets are to ScruSets. See ImmuSet.
The ImmuTable subclass of tables represents all tables which CANNOT be side-effected
during operations on them. They are intended to represent mathematical abstractions (such
as vectors) and are intended to be used in a functional-programming style. Operations are
provided for building new ImmuTables out of old ones.


Field Summary
 
Fields inherited from class org.abora.gold.collection.tables.ScruTable
NotInTableSignal, WrongCoordSpaceSignal
 
Fields inherited from class org.abora.gold.xpp.basic.Heaper
AllBlasts, BecomeMap, GarbageCount, InGC, InitializedClasses, InitializingClasses, LastMemory, NextClientRequestNumber, NotOneElementSignal, PackageTable, PromiseNameTable, StringHashSBoxes
 
Fields inherited from class org.abora.gold.java.AboraHeaper
ActiveClubs, CurrentAuthor, CurrentBertCanopyCache, CurrentBertCrum, CurrentChunk, CurrentGrandMap, CurrentKeyMaster, CurrentPacker, CurrentSensorCanopyCache, CurrentServer, CurrentSession, CurrentSessions, CurrentTrace, InitialEditClub, InitialOwner, InitialReadClub, InitialSponsor, InsideTransactionFlag
 
Constructor Summary
ImmuTable()
           
 
Method Summary
 int actualHashForEqual()
          See ScruTable::isEqual
 ImmuTable asImmuTable()
          Return a side-effect-free snapshot of my current contents.
See ScruSet::asImmuSet.
 MuTable asMuTable()
          Return a side-effectable version of the same table.
See ScruSet::asMuSet.
 ImmuTable combineWith(ImmuTable other)
          Similar to unionWith.
 CoordinateSpace coordinateSpace()
          The kind of elements used to index into the table are Positions of this
coordinate space.
 ScruTable copy()
          don't need to actually make a copy, as this is immutable
 IntegerVar count()
          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'.
 XnRegion domain()
          Return an XuRegion representing a snapshot of the current domain.
'table->domain()->hasMember(p)' iff 'table->fetch(p) !!= NULL'.
 ScruTable emptySize(IntegerVar size)
          The idea of a 'size' argument would seem kind of ridiculous here as the resulting empty
table can't be changed.
 Heaper fetch(Position key)
          Return the range element at the domain position key.
 boolean includesIntKey(IntegerVar aKey)
          Unboxed version.
 boolean includesKey(Position aKey)
          includesKey is used to test for the presence of a key->value pair in the
table.
 Heaper intFetch(IntegerVar key)
          Unboxed version.
 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 Heaper make(CoordinateSpace cs)
          An empty ImmuTable whose domain space is 'cs'.
static Heaper make(java.lang.Object something)
          (something isKindOf: MuTable)
ifTrue: [^self make.MuTable: something].
static ImmuTable offsetImmuTable(ImmuTable aTable, Dsp aDsp)
           
 XnRegion runAt(Position key)
          Return the length of the run starting at position key.
 XnRegion runAtInt(IntegerVar key)
          Unboxed version.
 TableStepper stepper(OrderSpec order)
          Return a TableStepper which will enumerate my key->value mappings.
 ScruTable subTable(XnRegion reg)
          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.
 ScruTable transformedBy(Dsp dsp)
          Return a ScruTable with the domain of the receiver transformed by the Dsp.
'table->transformedBy(d)->fetch(p)' is equivalent to
'table->fetch(d->of(p))'.
See ScruTable::subTable for caveats regarding whether we return a snapshot
or a view.
 ImmuTable with(ImmuTable other)
          Please use ImmuTable::combineWith instead.
 ImmuTable without(Position index)
          Return a new table just like the current one except with the association whose
key is 'index'.
 
Methods inherited from class org.abora.gold.collection.tables.ScruTable
asOrderedCollection, backfollowFrom, contentsEqual, contentsHash, dox, get, intGet, printOn, printOnWithSimpleSyntax, printOnWithSyntax, problems, range, stepper, theOne
 
Methods inherited from class org.abora.gold.xpp.basic.Heaper
abstractDeclarationFor, abstractTypeFor, addMethodAttributeToInOf, addPackage, addPackageCategory, allClientProtocolOn, argumentTypesFor, arrow, blast, blast, BLAST, cachePromiseNameTable, cachePromiseNameTableIn, canYouBecome, cast, cleanPromiseClasses, cleanupGarbage, clientClassesDo, clientFunctionsOn, clientMethodsOn, clientProtocol, clientProtocolDo, clientProtocolOn, clientProtocolOn, collectibleClasses, compare, compileClientSubclasses, compileConstantPromiseMethods, compileCreateFromRcvr, compileEQ, compileGeneratedClassMethod, compileGeneratedMethod, compileHook, compilePromise, compilePromiseDefaultMethods, compilePromiseFluidDeclarations, compilePromiseHandlers, compilePromiseMethods, compileRequestCreateMsgInArguments, compileRequestEvaluateMsgInReturningArguments, compileRPCSpecialistEvaluateMsgForReturningArguments, compileSendSelfTo, compileSendSelfToSendHook, compileStubbleMethods, compileSubclassStubbleMethods, computeMangle, computePreorder, constantTypeValue, convert, convertCopyDeclarations, convertDeferredDeclarations, convertProxyDeclarations, convertSubclassCopyDeclarations, convertSubclassDeferredDeclarations, convertSubclassProxyDeclarations, copyReferencesToType, create, create, create, create, create, create, create, create, create, create, createRequestClassArguments, definesProxyMethods, delete, deref, destroy, destruct, destructor, enum, enumFlags, equals, exportName, fetchAttribute, fetchPackage, fetchSuperCategory, fileOutClientProtocol, findCategory, findSenderAndReceiverMethods, findTailInto, flushPromiseNameTable, foo, freezeClientClasses, freezeClientProtocol, freezeStProtocol, frozenClasses, garbageCollect, garbageCollectFrom, gcOpportunity, gcOpportunity, generatedCategory, generatePromiseNames, getCategory, getOrMakePackage, getSuperCategory, handlerSignaturesFrom, hash, hashForEqual, hasProxyMethods, info_clientClasses, info_clientSideClasses, info_promiseClasses, info_stProtocol, inGC, initializedClasses, initializingClasses, initPackages, initStringHashSBoxes, inspectPieces, instanceSize, IntegerVar, isByProxy, isConstructed, isDestructed, isEqualOrSubclassOf, isGenerated, isIntType, isKindOf, isRawType, isUnlocked, linkTimeNonInherited, makeClassTable, makeFillTable, makeRequestTable, mangle, markChildren, markCount, markInstances, mayBecome, mayBecomeAnySubclassOf, new1, newX, nonCopyVariables, notWorking, pack, packageClasses, packagingCategory, parseExportName, passe, pointerToStaticMember, pointerToStaticMember, pointerToVirtualMember, preorderMax, preorderNumber, PROBLEM, promiseClass, promiseDefaultValue, promiseName, promiseNameTable, promiseToAbstract, registerPackageCategory, removeGeneratedCode, removeStubbleMethods, removeSubclassGeneratedCode, removeSubclassStubbleMethods, requestProcedure, requestProceduresFrom, returnTypeFor, rootName, scheduleTermination, sendProxyTo, sendSelfTo, serverNameFor, setGC, signal, signals, smalltalkSelector, stClientProtocol, stubbleSelectorTokenReturnsArguments, subclassNonCopyVariables, takeOop, togglePromiseName, togglePromiseOfParse, unimplemented, unmangle, verifyFreeze, wipeStubble
 
Methods inherited from class org.abora.gold.java.AboraHeaper
asOop, basicInspect, displayString, error, hack, halt, inspect, knownBug, mightNotImplement, REQUIRES, shouldImplement, shouldNotImplement, stubbleForSubclassResponsibility, thingToDo, willNotImplement
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ImmuTable

public ImmuTable()
Method Detail

coordinateSpace

public 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.

Overrides:
coordinateSpace in class ScruTable

count

public IntegerVar 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.

Overrides:
count in class ScruTable

domain

public 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'.

Overrides:
domain in class ScruTable

fetch

public 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.

Overrides:
fetch in class ScruTable

intFetch

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

Overrides:
intFetch in class ScruTable

runAt

public 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.

Overrides:
runAt in class ScruTable

runAtInt

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

Overrides:
runAtInt in class ScruTable

subTable

public 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.

Overrides:
subTable in class ScruTable

transformedBy

public ScruTable transformedBy(Dsp dsp)
Return a ScruTable with the domain of the receiver transformed by the Dsp.
'table->transformedBy(d)->fetch(p)' is equivalent to
'table->fetch(d->of(p))'.
See ScruTable::subTable for caveats regarding whether we return a snapshot
or a view. All the same caveats apply.
In this case of transforming an ImmuTable, it makes sense to return an ImmuTable.

Overrides:
transformedBy in class ScruTable

copy

public ScruTable copy()
don't need to actually make a copy, as this is immutable

Overrides:
copy in class ScruTable

emptySize

public ScruTable emptySize(IntegerVar size)
The idea of a 'size' argument would seem kind of ridiculous here as the resulting empty
table can't be changed.

Overrides:
emptySize in class ScruTable

combineWith

public ImmuTable combineWith(ImmuTable other)
Similar to unionWith. In particular, if 'a = b->combineWith(c);', then:
'a->domain()->isEqual(b->domain()->unionWith(c->domain())' and
'a->range()->isSubsetOf(b->range()->unionWith(c->range())'.
(Note that the domain case uses XuRegion::unionWith, while the range case
uses ImmuSet::unionWith.)
Despite this correspondence, unionWith is symmetrical while combineWith is not.
Given that the two input tables have different associations for a given key,
one gets to dominate. I need to specify which one here, but the code seems
inconsistent on this question. Until this is resolved, console youself with the
thought that if the tables don't conflict we have a simple unionWith of the two
sets of associations (and the 'isSubsetOf' above can be replaced with 'isEqual').


without

public ImmuTable without(Position index)
Return a new table just like the current one except with the association whose
key is 'index'.


actualHashForEqual

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

Overrides:
actualHashForEqual in class ScruTable

includesIntKey

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

Overrides:
includesIntKey in class ScruTable

includesKey

public 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 boolean isEmpty()
Description copied from class: ScruTable
Is there anything in the table?
'table->isEmpty()' iff 'table->domain()->isEmpty()'.

Overrides:
isEmpty 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.

Overrides:
isEqual in class ScruTable

stepper

public 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);
});
}

Overrides:
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.

Overrides:
asImmuTable in class ScruTable

asMuTable

public MuTable asMuTable()
Description copied from class: ScruTable
Return a side-effectable version of the same table.
See ScruSet::asMuSet.

Overrides:
asMuTable in class ScruTable

with

public ImmuTable with(ImmuTable other)
Please use ImmuTable::combineWith instead. 'with' was an innapropriate name
because its use elsewhere (see ImmuSet::with and XuRegion::with) implies that
the argument is a single element to be added, not a collection of elements to
be added.


make

public static Heaper make(CoordinateSpace cs)
An empty ImmuTable whose domain space is 'cs'.


offsetImmuTable

public static ImmuTable offsetImmuTable(ImmuTable aTable,
                                        Dsp aDsp)

make

public static Heaper make(java.lang.Object something)
(something isKindOf: MuTable)
ifTrue: [^self make.MuTable: something].



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