org.abora.gold.tumbler
Class Sequence

java.lang.Object
  |
  +--org.abora.gold.java.AboraHeaper
        |
        +--org.abora.gold.xpp.basic.Heaper
              |
              +--org.abora.gold.spaces.basic.Position
                    |
                    +--org.abora.gold.tumbler.Sequence

public class Sequence
extends Position

Represents an infinite sequence of integers (of which only a finite number can be
non-zero). They are lexically ordered, and there is a "decimal point" between the numbers
at -1 and 0.
Implementation note:
The array should have no zeros at either end, and noone else should have a pointer to it.


Field Summary
protected  PrimIntegerArray myNumbers
           
protected  IntegerVar myShift
           
protected static Sequence TheZero
           
 
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
Sequence(IntegerVar shift, PrimIntegerArray numbers)
           
Sequence(Rcvr receiver)
           
 
Method Summary
 int actualHashForEqual()
          since we redefine equal, subclasses had better redefine actualHashForEqual
 XnRegion asRegion()
          Essential.
 int comparePrefix(Sequence other, IntegerVar n)
          Compare my numbers up to and including index n with the corresponding numbers in the other
Sequence.
 CoordinateSpace coordinateSpace()
          Essential.
 IntegerVar count()
          How many numbers in the sequence, not counting leading or trailing zeros
 Sequence first()
          The sequence consisting of all numbers in this one up to but not including the first zero,
or the entire thing if there are no zeros
 IntegerVar firstIndex()
          The smallest index with a non-zero number.
static void info()
          {IntegerVar CLIENT} firstIndex
{IntegerVar CLIENT} integerAt: index {IntegerVar}
{PrimIntegerArray CLIENT} integers
{BooleanVar CLIENT} isZero
{IntegerVar CLIENT} lastIndex
{Sequence CLIENT} with: index {IntegerVar} with: number {IntegerVar}
static void initTimeNonInherited()
           
 IntegerVar integerAt(IntegerVar index)
          The number at the given index in the Sequence.
 PrimIntegerArray integers()
          Essential.
 boolean isEmpty()
          Whether there are no non-zero numbers in the Sequence
 boolean isEqual(Heaper other)
          Return true if the two objects are equal.
 boolean isGE(Position other)
          Whether this sequence is greater than or equal to the other sequence, using a lexical
comparison of their corresponding numbers.
 boolean isZero()
          Whether all the numbers in the sequence are zero
 IntegerVar lastIndex()
          The largest index with a non-zero number.
static void linkTimeNonInherited()
           
 Sequence minus(Sequence other)
          A sequence with the corresponding numbers subtracted from each other
 IntegerVar numberAt(IntegerVar index)
           
 PrimIntegerArray numbers()
           
static Sequence numbers(PrimIntegerArray digits)
           
static Sequence one(IntegerVar a)
          A single element Sequence
 Sequence plus(Sequence other)
          A sequence with the corresponding numbers added to each other
static void printArrayOn(java.io.PrintWriter oo, PrimIntegerArray numbers)
          Print a sequence of numbers separated by dots.
 void printOn(java.io.PrintWriter oo)
           
static void printOn(java.io.PrintWriter oo, IntegerVar shift, PrimIntegerArray numbers)
          Print a sequence of numbers separated by dots.
static void printZerosOn(java.io.PrintWriter oo, IntegerVar shift)
          Print a sequence of zeros separated by dots.
 Sequence rest()
          The sequence consisting of all numbers in this one after but not including the first zero,
or a null sequence if there are no zeros
 PrimIntegerArray secretNumbers()
          The array itself, for internal use
 void sendSelfTo(Xmtr xmtr)
          do nothing
 IntegerVar shift()
          The amount by which the numbers are shifted.
 Sequence shift(IntegerVar offset)
          Shift the numbers by some number of places.
static Sequence string(java.lang.String string)
           
static Sequence three(IntegerVar a, IntegerVar b, IntegerVar c)
          A three element Sequence
static Sequence two(IntegerVar a, IntegerVar b)
          A two element Sequence
static Sequence usingx(IntegerVar shift, PrimIntegerArray numbers)
          Don't need to make a copy of the array
 Sequence with(IntegerVar index, IntegerVar number)
          Change a single element of the sequence.
 Sequence withFirst(IntegerVar number)
          A Sequence with all my numbers followed by the given one
 Sequence withLast(IntegerVar number)
          A Sequence with all my numbers followed by the given one
 Sequence withRest(Sequence other)
          A sequence containing all the numbers in this one, followed by the other one, separated by
a single zero.
static Sequence zero()
           
 
Methods inherited from class org.abora.gold.spaces.basic.Position
isAfterOrEqual
 
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, 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

myShift

protected IntegerVar myShift

myNumbers

protected PrimIntegerArray myNumbers

TheZero

protected static Sequence TheZero
Constructor Detail

Sequence

public Sequence(IntegerVar shift,
                PrimIntegerArray numbers)

Sequence

public Sequence(Rcvr receiver)
Method Detail

asRegion

public XnRegion asRegion()
Description copied from class: Position
Essential. A region containing this position as its only element.

Overrides:
asRegion in class Position

coordinateSpace

public CoordinateSpace coordinateSpace()
Description copied from class: Position
Essential. The coordinate space this is a position in. This implies that a position
object is only a position in one particular coordinate space.

Overrides:
coordinateSpace in class Position

count

public IntegerVar count()
How many numbers in the sequence, not counting leading or trailing zeros


firstIndex

public IntegerVar firstIndex()
The smallest index with a non-zero number. Blasts if it is all zeros.


integerAt

public IntegerVar integerAt(IntegerVar index)
The number at the given index in the Sequence. Returns zeros beyond either end of the
array.


integers

public PrimIntegerArray integers()
Essential. The numbers in this Sequence. This is a copy of the array, so you may modify
it.
Note that two Sequences which are isEqual, may actually have arrays of numbers which have
different specs. Also, the array will not have any zeros at the beginning or end.


isZero

public boolean isZero()
Whether all the numbers in the sequence are zero


lastIndex

public IntegerVar lastIndex()
The largest index with a non-zero number. Blasts if it is all zeros.


shift

public IntegerVar shift()
The amount by which the numbers are shifted. Positive means less significant, negative
means more significant. This is contrary to the usual arithmetic notions, but it is the
right thing for arrays.


comparePrefix

public int comparePrefix(Sequence other,
                         IntegerVar n)
Compare my numbers up to and including index n with the corresponding numbers in the other
Sequence. Return -1, 0 or 1 depending on whether they are <, =, or > the other.


actualHashForEqual

public int actualHashForEqual()
Description copied from class: Position
since we redefine equal, subclasses had better redefine actualHashForEqual

Overrides:
actualHashForEqual in class Position

isEqual

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

Overrides:
isEqual in class Position

isGE

public boolean isGE(Position other)
Whether this sequence is greater than or equal to the other sequence, using a lexical
comparison of their corresponding numbers.

Overrides:
isGE in class Position

secretNumbers

public PrimIntegerArray secretNumbers()
The array itself, for internal use


printOn

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

first

public Sequence first()
The sequence consisting of all numbers in this one up to but not including the first zero,
or the entire thing if there are no zeros


minus

public Sequence minus(Sequence other)
A sequence with the corresponding numbers subtracted from each other


plus

public Sequence plus(Sequence other)
A sequence with the corresponding numbers added to each other


rest

public Sequence rest()
The sequence consisting of all numbers in this one after but not including the first zero,
or a null sequence if there are no zeros


shift

public Sequence shift(IntegerVar offset)
Shift the numbers by some number of places. Positive shifts make it less significant,
negative shifts make it more significant.


with

public Sequence with(IntegerVar index,
                     IntegerVar number)
Change a single element of the sequence.


withFirst

public Sequence withFirst(IntegerVar number)
A Sequence with all my numbers followed by the given one


withLast

public Sequence withLast(IntegerVar number)
A Sequence with all my numbers followed by the given one


withRest

public Sequence withRest(Sequence other)
A sequence containing all the numbers in this one, followed by the other one, separated by
a single zero.


isEmpty

public boolean isEmpty()
Whether there are no non-zero numbers in the Sequence


numberAt

public IntegerVar numberAt(IntegerVar index)

numbers

public PrimIntegerArray numbers()

sendSelfTo

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

Overrides:
sendSelfTo in class Heaper

numbers

public static Sequence numbers(PrimIntegerArray digits)

one

public static Sequence one(IntegerVar a)
A single element Sequence


string

public static Sequence string(java.lang.String string)

three

public static Sequence three(IntegerVar a,
                             IntegerVar b,
                             IntegerVar c)
A three element Sequence


two

public static Sequence two(IntegerVar a,
                           IntegerVar b)
A two element Sequence


zero

public static Sequence zero()

printArrayOn

public static void printArrayOn(java.io.PrintWriter oo,
                                PrimIntegerArray numbers)
Print a sequence of numbers separated by dots. Deal with strings specially.


printOn

public static void printOn(java.io.PrintWriter oo,
                           IntegerVar shift,
                           PrimIntegerArray numbers)
Print a sequence of numbers separated by dots. Deal with strings specially.


printZerosOn

public static void printZerosOn(java.io.PrintWriter oo,
                                IntegerVar shift)
Print a sequence of zeros separated by dots. Deal with large numbers specially.


usingx

public static Sequence usingx(IntegerVar shift,
                              PrimIntegerArray numbers)
Don't need to make a copy of the array


initTimeNonInherited

public static void initTimeNonInherited()

linkTimeNonInherited

public static void linkTimeNonInherited()

info

public static void info()
{IntegerVar CLIENT} firstIndex
{IntegerVar CLIENT} integerAt: index {IntegerVar}
{PrimIntegerArray CLIENT} integers
{BooleanVar CLIENT} isZero
{IntegerVar CLIENT} lastIndex
{Sequence CLIENT} with: index {IntegerVar} with: number {IntegerVar}



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