org.abora.white.spaces.cross
Class GenericCrossRegion

java.lang.Object
  |
  +--org.abora.white.xpp.basic.Heaper
        |
        +--org.abora.white.spaces.basic.XnRegion
              |
              +--org.abora.white.spaces.cross.CrossRegion
                    |
                    +--org.abora.white.spaces.cross.GenericCrossRegion

public class GenericCrossRegion
extends CrossRegion

Represents a region as a two-dimensional array of crosses of subregions. Was NOT.A.TYPE but that obstructed compilation. I think this might work better if the array is lexically sorted, but I am not sure there is any meaningful way to do so. Thus there is no sorting assumed in the algorithms, although the protocol may occasionally suggest that there might be. Eventually this implementation may save space by using NULL to represent repetitions of a sub region such that fetchBoxProjection (box, dim) == NULL only if box > 0 && boxProjection (box, dim)->isEqual (boxProjection (box - 1, dim)) && (dim == 0 || fetchBoxProjection (box, dim - 1) == NULL)


Field Summary
protected  int myCount
           
protected  PtrArray myRegions
           
protected  CrossSpace mySpace
           
 
Constructor Summary
GenericCrossRegion(CrossSpace space, int count, PtrArray regions)
           
GenericCrossRegion(Rcvr receiver)
           
 
Method Summary
 int actualHashForEqual()
          To avoid overly burdensome canonicalization rules, my hash is calculated from the hash of my projections
 Stepper actualStepper(OrderSpec order)
          Only called if I've already said I'm enumerable in the originally stated order.
 XnRegion asSimpleRegion()
          Return a simple region containing all positions contained by myself.
 int boxCount()
           
 Stepper boxes()
          Essential.
 XnRegion boxProjection(int box, int dimension)
          A region is at a given 2D place in the array
 BoxProjectionStepper boxProjectionStepper()
          A stepper over all projections of all boxes in the region
 BoxStepper boxStepper()
          A stepper over all boxes
 XnRegion complement()
          Essential.
 CoordinateSpace coordinateSpace()
          Essential.
 IntegerValue count()
          How many positions do I contain? If I am not 'isFinite', then this message will BLAST.
 CrossSpace crossSpace()
           
 ScruSet distinctions()
          Break it up into a set of non-full distinctions.
static CrossRegion empty(GenericCrossSpace space)
           
static CrossRegion full(GenericCrossSpace space, PtrArray subSpaces)
          Only used during construction; must pass the array in explicitly since the space isnt initialized yet
 boolean hasBoxProjection(XnRegion other, int box, int dimension)
          Whether a region is at a given 2D place in the array.
 boolean hasMember(Position position)
          Do I contain this position? More than anything else, the behavior of this message is the defining characteristic of an XuRegion.
 XnRegion intersect(XnRegion region)
          Essential.
 boolean intersects(XnRegion other)
          Essential.
 boolean isBox()
          Whether this Region is a box, i.e.
 boolean isDistinction()
          Am I a distinction.
 boolean isEmpty()
          Every coordinate space has exactly one empty region.
 boolean isEnumerable(OrderSpec order)
          See comment in XuRegion::stepper.
 boolean isEqual(Heaper other)
          Two regions are equal iff they contain exactly the same set of positions
 boolean isFinite()
          Essential.
 boolean isFull()
          true if this is the largest possible region in this space -- the region that contains all positions in the space.
 boolean isSimple()
          Am I a simple region.
 boolean isSubsetOf(XnRegion other)
          I'm a subset of other if I don't have any positions that he doesn't.
static CrossRegion make(CrossSpace space, int count, PtrArray regions)
           
 void printOn(java.io.PrintWriter oo)
          This should rarely be overridden.
 XnRegion projection(int index)
          The answer is the projection of this region into the specified dimension of the cross space
 PtrArray projections()
          Essential.
 PtrArray secretRegions()
          The array holding the regions.
 void sendSelfTo(Xmtr xmtr)
           
 Stepper simpleRegions(OrderSpec order)
          Break myself up into a finite set of non-empty simple regions which, when unionWith'ed together will yield me.
 Position theOne()
          Iff I contain exactly one position, return it.
 XnRegion unionWith(XnRegion region)
          The result has as members exactly those positions which are members of either of the original two regions.
 
Methods inherited from class org.abora.white.spaces.cross.CrossRegion
info, simpleUnion
 
Methods inherited from class org.abora.white.spaces.basic.XnRegion
chooseMany, chooseMany, chooseOne, chooseOne, delta, disjointSimpleRegions, disjointSimpleRegions, immuSet, isEnumerable, minus, simpleRegions, stepper, stepper, with, without
 
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

mySpace

protected CrossSpace mySpace

myCount

protected int myCount

myRegions

protected PtrArray myRegions
Constructor Detail

GenericCrossRegion

public GenericCrossRegion(CrossSpace space,
                          int count,
                          PtrArray regions)

GenericCrossRegion

public GenericCrossRegion(Rcvr receiver)
Method Detail

coordinateSpace

public CoordinateSpace coordinateSpace()
Description copied from class: XnRegion
Essential. The coordinate space in which this is a region

Specified by:
coordinateSpace in class CrossRegion

count

public IntegerValue count()
Description copied from class: XnRegion
How many positions do I contain? If I am not 'isFinite', then this message will BLAST.

Specified by:
count in class CrossRegion

projection

public XnRegion projection(int index)
Description copied from class: CrossRegion
The answer is the projection of this region into the specified dimension of the cross space

Overrides:
projection in class CrossRegion

projections

public PtrArray projections()
Description copied from class: CrossRegion
Essential. The answer is the projection of this region into each dimension of the cross space. Note that two regions which are different can have the same projections.

Specified by:
projections in class CrossRegion

theOne

public Position theOne()
Description copied from class: XnRegion
Iff I contain exactly one position, return it. Otherwise BLAST. The idea for this message is taken from the THE function of ONTIC (reference McAllester)

Overrides:
theOne in class XnRegion

crossSpace

public CrossSpace crossSpace()

boxCount

public int boxCount()

boxProjection

public XnRegion boxProjection(int box,
                              int dimension)
A region is at a given 2D place in the array


boxProjectionStepper

public BoxProjectionStepper boxProjectionStepper()
A stepper over all projections of all boxes in the region


boxStepper

public BoxStepper boxStepper()
A stepper over all boxes


hasBoxProjection

public boolean hasBoxProjection(XnRegion other,
                                int box,
                                int dimension)
Whether a region is at a given 2D place in the array. Searches forward and backward through adjacent boxes which have the same hash value


secretRegions

public PtrArray secretRegions()
The array holding the regions. DO NOT MODIFY


actualHashForEqual

public int actualHashForEqual()
Description copied from class: CrossRegion
To avoid overly burdensome canonicalization rules, my hash is calculated from the hash of my projections

Overrides:
actualHashForEqual in class CrossRegion

hasMember

public boolean hasMember(Position position)
Description copied from class: XnRegion
Do I contain this position? More than anything else, the behavior of this message is the defining characteristic of an XuRegion. All other messages (except for the simplicity characterization) should be specifiable in terms of the behavior of this message. What an XuRegion *is* (mostly) is a finite decision procedure for accepting or rejecting any given position.

Specified by:
hasMember in class CrossRegion

intersects

public boolean intersects(XnRegion other)
Description copied from class: XnRegion
Essential. tell whether it has any points in common

Overrides:
intersects in class XnRegion

isDistinction

public boolean isDistinction()
Description copied from class: XnRegion
Am I a distinction. See XuRegion class comment for implications of being a distinction.

Overrides:
isDistinction in class XnRegion

isEmpty

public boolean isEmpty()
Description copied from class: XnRegion
Every coordinate space has exactly one empty region. It is the one containing no positions. It and only it responds 'true' to this message.

Specified by:
isEmpty in class CrossRegion

isEnumerable

public boolean isEnumerable(OrderSpec order)
Description copied from class: XnRegion
See comment in XuRegion::stepper. a->stepper(os) won't BLAST iff a->isEnumerable(os)

Specified by:
isEnumerable in class CrossRegion

isEqual

public boolean isEqual(Heaper other)
Description copied from class: XnRegion
Two regions are equal iff they contain exactly the same set of positions

Specified by:
isEqual in class CrossRegion

isFinite

public boolean isFinite()
Description copied from class: XnRegion
Essential. Do I contain a finite number of positions? If I do, then the 'count' message will say how many, and I will gladly provide a stepper which will step over all of them. I.e., isFinite implies isEnumerable.

Specified by:
isFinite in class CrossRegion

isFull

public boolean isFull()
Description copied from class: XnRegion
true if this is the largest possible region in this space -- the region that contains all positions in the space. Note that in a space which has no positions (which is perfectly valid), the one XuRegion would be both empty (since it has no positions) and full (since it has all the positions in the space).

Overrides:
isFull in class XnRegion

isSimple

public boolean isSimple()
Description copied from class: XnRegion
Am I a simple region. See XuRegion class comment for implications of being simple.

Specified by:
isSimple in class CrossRegion

isSubsetOf

public boolean isSubsetOf(XnRegion other)
Description copied from class: XnRegion
I'm a subset of other if I don't have any positions that he doesn't. Note that if we are equal, then I am still a subset of him. If you want to know if I'm a strict subset, you can ask a->isSubsetOf(b) && !! a->isEqual(b)

Overrides:
isSubsetOf in class XnRegion

asSimpleRegion

public XnRegion asSimpleRegion()
Description copied from class: XnRegion
Return a simple region containing all positions contained by myself. If I am simple, then the result must be me. Otherwise, the resulting region will contain more positions than I do, but it must contain all those that I do. It would be good for the resulting simple region to not contain many more points than it needs in order to satisfy these constraints; but this is a preference, not a specification. Particular spaces may specify stronger guarantees, but as far as class XuRegion is concerned it is correct (though silly) for this message to always return the full region for the space.

Specified by:
asSimpleRegion in class CrossRegion

complement

public XnRegion complement()
Description copied from class: XnRegion
Essential. Return a region of containing exactly those positions not in this region. The complement of a distinction must be a distinction.

Specified by:
complement in class CrossRegion

intersect

public XnRegion intersect(XnRegion region)
Description copied from class: XnRegion
Essential. The intersection of two simple regions must be simple. The intersection of two distinctions must therefore be a simple region. The result has exactly those members which both the original regions have.

Specified by:
intersect in class CrossRegion

unionWith

public XnRegion unionWith(XnRegion region)
Description copied from class: XnRegion
The result has as members exactly those positions which are members of either of the original two regions. No matter how simple the two original regions are, the result may be non-simple. The only reason this is called 'unionWith' instead of 'union' is that the latter is a C++ keyword.

Specified by:
unionWith in class CrossRegion

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

boxes

public Stepper boxes()
Description copied from class: CrossRegion
Essential. Divide this Region up into a disjoint sequence of boxes. A box is a region which is the cross of its projections.

Specified by:
boxes in class CrossRegion

distinctions

public ScruSet distinctions()
Description copied from class: XnRegion
Break it up into a set of non-full distinctions. It is an error to send this to a non-simple region. A full region will respond with the null set. Other distinctions will respond with a singleton set containing themselves, and simple regions will respond with a set of distinctions which, when intersected together, yield the original region.

Specified by:
distinctions in class CrossRegion

isBox

public boolean isBox()
Description copied from class: CrossRegion
Whether this Region is a box, i.e. is equal to the cross of its projections.

Specified by:
isBox in class CrossRegion

simpleRegions

public Stepper simpleRegions(OrderSpec order)
Description copied from class: XnRegion
Break myself up into a finite set of non-empty simple regions which, when unionWith'ed together will yield me. May be sent to any region. If I am isEmpty, I will respond with the empty stepper. Otherwise, if I am simple I will respond with a stepper producing just myself. Please only use NULL for the 'order' argument for now unless the documentation for a particular region or coordinate space says that it will deal with the 'order' argument meaningfully. When no order is specified then I may return the simple regions in any order. When the ordering functionality is implemented, then I am constrained to produce the simple regions in an order consistent with the argument's ordering of my positions. When the simple regions don't overlap, and don't surround each other in the ordering, then the meaning is clear. Otherwise, there are several plausible options for how we should specify this message.

Specified by:
simpleRegions in class CrossRegion

actualStepper

public Stepper actualStepper(OrderSpec order)
Description copied from class: XnRegion
Only called if I've already said I'm enumerable in the originally stated order. Also, if the originally stated order was NULL, I get a guaranteed non-null order. Subclasses which override 'stepper' to a method which doesn't send 'actualStepper' may override 'actualStepper' to a stub method which always BLASTs.

Specified by:
actualStepper in class CrossRegion

sendSelfTo

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

empty

public static CrossRegion empty(GenericCrossSpace space)

full

public static CrossRegion full(GenericCrossSpace space,
                               PtrArray subSpaces)
Only used during construction; must pass the array in explicitly since the space isnt initialized yet


make

public static CrossRegion make(CrossSpace space,
                               int count,
                               PtrArray regions)


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