org.abora.gold.collection.steppers
Class Accumulator

java.lang.Object
  |
  +--org.abora.gold.java.AboraHeaper
        |
        +--org.abora.gold.xpp.basic.Heaper
              |
              +--org.abora.gold.collection.steppers.Accumulator
Direct Known Subclasses:
BoxAccumulator, EdgeAccumulator, IntegerEdgeAccumulator, PtrArrayAccumulator, SetAccumulator, TableAccumulator, UnionRecruiter

public class Accumulator
extends Heaper

An Accumulator is a thing which collects a sequence of objects one at a time for some
purpose. Typically, this purpose is to construct a new object out of all the collected
objects. When used in this way, one can think of the Accumulator as being sort of like a
pseudo-constructor which is spread out in time, and whose arguments are identified by the
sequence they occur in. Accumulators are typically used in loops.
A (future) example of an Accumulator which is not like "a pseudo-constructor spread out in
time" is a communications stream between two threads (or even coroutines) managed by an
Accumulator / Stepper pair. The producer process produces by putting objects into his
Accumulator, and the consuming process consumes by pulling values out of his Stepper. If
you want to stretch the analogy, I suppose you can see the Accumulator of the pair as a
pseudo-constructor which constructs the Stepper, but *overlapped* in time.
It is normally considered bad style for two methods/functions to be pointing at the same
Acumulator. As long as Accumulators are used locally and without aliasing (i.e., as if
they were pass-by-value Vars), these implementationally side-effecty objects can be
understood applicatively. If a copy of an Accumulator can be passed instead of a pointer
to the same one, this is to be prefered. This same comment applies even more so for
Steppers.
Example: To build a set consisting of some transform of the elements of an existing set
(what Smalltalk would naturally do with "collect:"), a natural form for the loop would be:
SPTR(Accumulator) acc = setAccumulator();
FOR_EACH(Heaper,each,oldSet->stepper(), {
acc->step (transform (each));
});
return CAST(ImmuSet,acc->value());
See class Stepper for documentation of FOR_EACH.


Field Summary
 
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
Accumulator()
           
 
Method Summary
 int actualHashForEqual()
           
 Accumulator copy()
          Return a new Accumulator just like the current one, except that
from now on they accumulate separately
 boolean isEqual(java.lang.Object other)
           
static Accumulator ptrArray()
          An accumulator that returns a PtrArray of the object put into it, in sequence
 void step(Heaper someObj)
          Accumulate a new object into the Accumulator
 Heaper value()
          Return the object that results from accumulating all those objects
 
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, isEqual, isEqualOrSubclassOf, isGenerated, isIntType, isKindOf, isRawType, isUnlocked, linkTimeNonInherited, make, makeClassTable, makeFillTable, makeRequestTable, mangle, markChildren, markCount, markInstances, mayBecome, mayBecomeAnySubclassOf, new1, newX, nonCopyVariables, notWorking, pack, packageClasses, packagingCategory, parseExportName, passe, pointerToStaticMember, pointerToStaticMember, pointerToVirtualMember, preorderMax, preorderNumber, printOn, PROBLEM, problems, 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

Accumulator

public Accumulator()
Method Detail

step

public void step(Heaper someObj)
Accumulate a new object into the Accumulator


value

public Heaper value()
Return the object that results from accumulating all those objects


copy

public Accumulator copy()
Return a new Accumulator just like the current one, except that
from now on they accumulate separately


actualHashForEqual

public int actualHashForEqual()
Overrides:
actualHashForEqual in class Heaper

isEqual

public boolean isEqual(java.lang.Object other)

ptrArray

public static Accumulator ptrArray()
An accumulator that returns a PtrArray of the object put into it, in sequence



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