org.abora.gold.collection.tables
Class Pair

java.lang.Object
  |
  +--org.abora.gold.java.AboraHeaper
        |
        +--org.abora.gold.xpp.basic.Heaper
              |
              +--org.abora.gold.collection.tables.Pair

public class Pair
extends Heaper

Sometimes you just want to pass around two things where the language only makes it
convenient to pass around one. I know that the proper object-oriented (or even
"structured") thing to do would be to create a type specific to the particular kind of
pair which is being used for a particular purpose. However, sometimes it just seems like
too much trouble. By using Pairs, we import the sins of Lisp. At least we don''t have
RPLACA and RPLACD. Unlike Lisp''s cons cell''s "car" and "cdr", we call our two parts the
"left" part and the "right" part. "pair(a,b)->left()" yields a and "pair(a,b)->right()"
yields b.
Give us feedback: Should Pairs be removed? Do you know of any justification for them
other than a bad simulation of "multiple-return-values" (as in Common Lisp, Forth,
Postscript)?
The Pair code is currently in a state of transition. Old code (which we have yet to fix)
uses Pairs with NULLs in their parts. Pairs will be changed to outlaw this usage.
"fetchLeft" and "fetchRight" exist to support this obsolete usage, but will be retired.
Don''t use them.


Field Summary
protected  Heaper leftPart
           
protected  Heaper rightPart
           
 
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
Pair(Heaper a)
          create a new pair
Pair(Heaper a, Heaper b)
          create a new pair
Pair(Rcvr receiver)
           
 
Method Summary
 int actualHashForEqual()
           
 Heaper fetchLeft()
          Returns the left part which obsoletely may be NULL
 Heaper fetchRight()
          Returns the right part which obsoletely may be NULL
static void inspectPieces()
          Return pieces to be used in a tree browser.
 boolean isEqual(Heaper other)
          Return true if the two objects are equal.
 Heaper left()
          Returns the left part.
static Heaper make(Heaper left, Heaper right)
          Create a new pair.
static Pair pairWithNulls(Heaper left, Heaper right)
          Create a new pair.
 void printOn(java.io.PrintWriter oo)
           
 Pair reversed()
          Returns a new pair which is the left-right reversal of me.
pair(a,b)->reversed() is the same as pair(b,a).
Only works on non-obsolete Pairs--those whose parts are non-NULL
 Heaper right()
          Returns the right part.
 void sendSelfTo(Xmtr xmtr)
          do nothing
 
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, instanceSize, IntegerVar, isByProxy, isConstructed, isDestructed, 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, PROBLEM, problems, promiseClass, promiseDefaultValue, promiseName, promiseNameTable, promiseToAbstract, registerPackageCategory, removeGeneratedCode, removeStubbleMethods, removeSubclassGeneratedCode, removeSubclassStubbleMethods, requestProcedure, requestProceduresFrom, returnTypeFor, rootName, scheduleTermination, sendProxyTo, 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
 

Field Detail

leftPart

protected Heaper leftPart

rightPart

protected Heaper rightPart
Constructor Detail

Pair

public Pair(Heaper a,
            Heaper b)
create a new pair


Pair

public Pair(Heaper a)
create a new pair


Pair

public Pair(Rcvr receiver)
Method Detail

actualHashForEqual

public int actualHashForEqual()
Overrides:
actualHashForEqual in class Heaper

isEqual

public boolean isEqual(Heaper other)
Description copied from class: Heaper
Return true if the two objects are equal.

Overrides:
isEqual in class Heaper

left

public Heaper left()
Returns the left part. Lispers may think 'car'.


reversed

public Pair reversed()
Returns a new pair which is the left-right reversal of me.
pair(a,b)->reversed() is the same as pair(b,a).
Only works on non-obsolete Pairs--those whose parts are non-NULL


right

public Heaper right()
Returns the right part. Lispers may think 'cdr'.


inspectPieces

public static void inspectPieces()
Return pieces to be used in a tree browser.


printOn

public void printOn(java.io.PrintWriter oo)
Overrides:
printOn in class Heaper

fetchLeft

public Heaper fetchLeft()
Returns the left part which obsoletely may be NULL


fetchRight

public Heaper fetchRight()
Returns the right part which obsoletely may be NULL


sendSelfTo

public void sendSelfTo(Xmtr xmtr)
Description copied from class: Heaper
do nothing

Overrides:
sendSelfTo in class Heaper

make

public static Heaper make(Heaper left,
                          Heaper right)
Create a new pair. Since it used to be normal to allow either left or right to be
NULL (it is now obsolete but supported for the moment), and it is impossible to
do a static check, this (normal) pseudo-constructor does a dynamic check. If
you encounter this error, the quick fix is use the obsolete pseudo-constructor
(pairWithNulls). The better fix is to stop using NULLs.


pairWithNulls

public static Pair pairWithNulls(Heaper left,
                                 Heaper right)
Create a new pair. Either may be NULL in order to support broken old code.



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