org.abora.white.spaces.integers
Class IntegerPos

java.lang.Object
  |
  +--org.abora.white.xpp.basic.Heaper
        |
        +--org.abora.white.spaces.basic.Position
              |
              +--org.abora.white.spaces.integers.IntegerPos

public class IntegerPos
extends Position

Because of the constraints of C++, we have two very different types representing integers in our system. XuInteger is the boxed representation which must be used in any context which only knows that it is dealing with a Position. XuInteger is a Heaper with all that implies. Specifically, one can take advantage of all the advantages of polymorphism (leading to uses by code that only knows it is dealing with a Position), but at the cost of representing each value by a heap allocated object to which pointers are passed. Such a representation is referred to as "boxed" because the pointer combined with the storage structure overhead of maintaining a heap allocated object constitutes a "box" between the user of the data (the guy holding onto the pointer), and the actual data (which is inside the Heaper). In contrast, IntegerValue is the efficient, unboxed representation of an integer. (actually, it is only unboxed so long as it fits within some size limit such as 32 bits. Those IntegerValues that exceed this limit pay their own boxing cost to store their representation on the heap. This need not concern us here.) See "The Var vs Heaper distinction" and IntegerValue. When we know that we are dealing specifically with an integer, we`d like to be able to stick with IntegerValues without having to convert them to XuIntegers. However, we`d like to be able to do everything that we could normally do if we had an XuInteger. For this purpose, many messages (such as Position * Dsp::of(Position*)) have an additional overloading (IntegerValue Dsp::of(IntegerValue)) whose semantics is defined in terms of converting the argument to an XuInteger, applying the original operation, and converting the result (which is asserted to be an XuInteger) back to an IntegerValue. Dsp even provides a default implementation to do exactly that. However, if we actually rely on this default implementation then we are defeating the whole purpose of avoiding boxing overhead. Instead, IntegerDsp overrides this to provide an efficient implementation. Any particular case may at the moment simply be relying on the default. The point is to get interfaces defined early which allow efficiency tuning to proceed in a modular fashion later. Should any particular reliance on the default actually prove to be an efficiency issue, we will deal with it then.


Field Summary
protected  IntegerValue myValue
           
protected static IntegerPos TheZero
           
 
Constructor Summary
IntegerPos(IntegerValue newValue)
           
IntegerPos(Rcvr receiver)
           
 
Method Summary
 int actualHashForEqual()
          This must use an external function so other parts of the system can compute the hash from an integerVar without boxing.
 int asInt32()
          Unboxed version as an integer.
 IntegerValue asIntegerVar()
          Essential.
 XnRegion asRegion()
          Essential.
 CoordinateSpace coordinateSpace()
          Essential.
static java.lang.String exportName()
           
static void info()
          {IntegerValue CLIENT INLINE} value
static int integerHash(IntegerValue value)
          NOTE: Do NOT change this without also changing the implementation of hashForEqual in XuInteger!!!!!!.
 boolean isEqual(Heaper other)
          Return true if the two objects are equal.
 boolean isGE(Position other)
          Just the full ordering you'd expect on integers
static IntegerPos make(IntegerValue newValue)
          Box an integer.
static IntegerPos make(long newValue)
           
 void printOn(java.io.PrintWriter oo)
          This should rarely be overridden.
 void sendSelfTo(Xmtr xmtr)
           
 IntegerValue value()
          Essential.
static IntegerPos zero()
          Box an integer.
 
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
 

Field Detail

myValue

protected IntegerValue myValue

TheZero

protected static IntegerPos TheZero
Constructor Detail

IntegerPos

public IntegerPos(IntegerValue newValue)

IntegerPos

public IntegerPos(Rcvr receiver)
Method Detail

actualHashForEqual

public int actualHashForEqual()
This must use an external function so other parts of the system can compute the hash from an integerVar without boxing.

Overrides:
actualHashForEqual in class Position

isEqual

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

Specified by:
isEqual in class Position

isGE

public boolean isGE(Position other)
Just the full ordering you'd expect on integers


asInt32

public int asInt32()
Unboxed version as an integer. See class comment


asIntegerVar

public IntegerValue asIntegerVar()
Essential. Unboxed version. See class comment


asRegion

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

Specified by:
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.

Specified by:
coordinateSpace in class Position

value

public IntegerValue value()
Essential. Unboxed version. See class comment


printOn

public void printOn(java.io.PrintWriter oo)
Description copied from class: Heaper
This should rarely be overridden. In Tofu, it prints ClassName(...), where ... is either produced by printInsideOn or is ??? if printInsideOn it not overridden.

Overrides:
printOn in class Heaper

sendSelfTo

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

make

public static IntegerPos make(IntegerValue newValue)
Box an integer. See XuInteger class comment. you can also create an integer in smalltalk by sending the integer message to a Smalltalk integer


make

public static IntegerPos make(long newValue)

zero

public static IntegerPos zero()
Box an integer. See XuInteger class comment. you can also create an integer in smalltalk by sending the integer message to a Smalltalk integer. This should return the canonical zero eventually.


integerHash

public static int integerHash(IntegerValue value)
NOTE: Do NOT change this without also changing the implementation of hashForEqual in XuInteger!!!!!!.


info

public static void info()
{IntegerValue CLIENT INLINE} value


exportName

public static java.lang.String exportName()


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