Index - All Packages - All Categories - All Classes

Class IntegerRegion

An IntegerRegion can be thought of as the disjoint union of intervals and inequalities. The interesting cases to look at are:

The distinctions:
1) The empty region
2) The full region
3) A "left" inequality -- eg., everything less that 3.
4) A "right" inequality -- eg., everything greater than or equal to 7

The non-distinction simple regions:
5) An interval -- eg., from 3 inclusive to 7 exclusive

The non-simple regions:
6) A disjoint union of (in order) an optional left inequality, a set of
intervals, and an optional right inequality.

If a non-empty region has a least element, then it "isBoundedLeft". Otherwise it extends leftwards indefinitely. Similarly, if a non-empty region has a greatest element, then it "isBoundedRight". Otherwise it extends rightwards indefinitely. (We may figuratively speak of the region extending towards + or - infinity, but we have purposely avoided introducing any value which represents an infinity.)

Looking at cases again:
1) "isBoundedLeft" and "isBoundedRight" since it doesn't extent
indenfinitely in either direction. (A danger to watch out for is that
this still has niether a greatest nor a least element).
2) niether.
3) "isBoundedRight"
4) "isBoundedLeft"
5) "isBoundedLeft" and "isBoundedRight"
6) "isBoundedLeft" iff doesn't include a left inequality,
"isBoundedRight" iff doesn't include a right inequality.

An efficiency note: Currently many of the method which could be doing an O(log) binary search (such as hasMember) are instead doing a linear search. This will be fixed if it turns out to be a problem in practice.

See OrderedRegion.

Package: Udanax-Gold
All Superclasses: Object Heaper XnRegion
Protocols: Object
Categories: Xanadu-Spaces-Integers

Class Methods

above: start with: inclusive

Essential. Make a region that contains all integers greater than (or equal if inclusive is true) to start.

after: start

The region containing all position greater than or equal to start

allIntegers

The full region of this space

badlyViolatePrivacyOfIntegerRegionTransitions: reg

used for an efficiency hack in PointRegion. Don't use.

before: end

The region of all integers less than end. Does not include end.

below: stop with: inclusive

Make a region that contains all integers less than (or equal if inclusive is true) to stop.

infostProtocol



Overrides: XnRegion class

initTimeNonInherited


integerExtent: start with: n

The region of all integers which are >= start and < start + n

interval: left with: right

The region of all integers which are >= left and < right

linkTimeNonInherited


make

No integers, the empty region

make: singleton

The region with just this one position. Equivalent to using a converter
to convert this position to a region.

make: left with: right

The region of all integers which are >= left and < right

usingx: startsInside with: transitionCount with: transitions



Instance Methods

actualHashForEqual



Overrides: XnRegion

actualStepper: order

Iff I am bounded left am I enumerable in ascending order. Similarly, only if I am bounded right am I enumerable in descending order.

Overrides: XnRegion

asSimpleRegion

Will always return the smallest simple region which contains all my positions

Overrides: XnRegion

beforeLast

the region before the last element of the set.
What on earth is this for? (Yes, I've looked at senders)

chooseOne: order



Overrides: XnRegion

compacted

transform the region into a simple region with left bound 0
(or -inf if unbounded).
What on earth is this for? (Yes, I've looked at senders)

compactor

A mapping to transform the region into a simple region with left bound 0 (or -inf if unbounded). The domain of the mapping is precisely this region.
This is primarily used in XuText Waldos, which only deal with contiguous zero-based regions of data.

complement



Overrides: XnRegion

coordinateSpace



Overrides: XnRegion

count



Overrides: XnRegion

create: startsInside with: count with: transitions


createRcvr: receiver


destroy



Overrides: Heaper

distinctions



Overrides: XnRegion

edgeStepper

Do not send from outside the module. This should not be exported
outside the module, but to not export it in this case is some trouble.

hasIntMember: key

Unboxed version. See class comment for XuInteger

hasMember: pos



Overrides: XnRegion

intersect: region



Overrides: XnRegion

intersects: region



Overrides: XnRegion

intervals


intervals: order

Essential. Break this into an ascending sequence of disjoint intervals (which may be unbounded).

isBoundedAbove

Either I extend indefinitely to plus infinity, or I am bounded above, not both.
The empty region is bounded above despite the fact that it has no upper edge.

isBoundedBelow

Either I extend indefinitely to minus infinity, or I am bounded below, not both.
The empty region is bounded below despite the fact that it has no lower bound.

isCompacted

True if this is either empty or a simple region with lower bound of either 0 or -infinity. Equivalent to
this->compacted()->isEqual (this)

isEmpty



Overrides: XnRegion

isEnumerable: order

Actually uses the 'order' argument correctly to enumerate the
positions. Treats nil the same as ascending. Iff I am bounded left
am I enumerable in ascending order. Similarly, only if I am bounded
right am I enumerable in descending order.

Overrides: XnRegion

isEqual: other



Overrides: XnRegion

isFinite



Overrides: XnRegion

isFull



Overrides: XnRegion

isInterval

Whether this Region is a non-empty interval, ie. if A, B in the Region and A <= C <= B then C is in the Region. This includes inequalities (eg. ) and the fullRegion in addition to ordinary two-ended intervals.

isSimple

Inequalities and intervals are both simple. See class comment

Overrides: XnRegion

isSubsetOf: other



Overrides: XnRegion

nearestIntHole: index

This is a hack for finding the smallest available index to allocate that is not in a particular region (a table domain, for example).

printOn: oo



Overrides: Object

runAt: pos

The region starting from pos (inclusive) and going until the next transition. If I contain pos, then I return the longest contiguous region starting at pos of positions I contain. If I don't contain pos, then I return the longest contiguous region starting at pos of positions I do not contain.

secretTransitions

The actuall array. DO NOT MODIFY

sendSelfTo: xmtr


simpleRegionAtIndex: i

the simple region at the given index in the transition array

simpleRegions: order

Treats nil the same as ascending. For the moment, will only work
with an ascending OrderSpec. If a descending OrderSpec is provided,
it will currently BLAST, but later will work correctly.

Returns a stepper on a disjoint set of simple regions in ascending
order. No difference with disjointSimpleRegions

Overrides: XnRegion

simpleUnion: otherRegion

The result is the smallest simple region which satisfies the spec in XuRegion::simpleUnion

Overrides: XnRegion

start

I have a start only if I'm not empty and I am isBoundedBelow. I report as my start the smallest position I *do* contain, which is one greater than the largest position I do not contain. The lower bound of the interval from 3 inclusive to 7 exclusive is 3.
See 'stop', you may be surprised.

startsInside


stop

I have a stop only if I'm not empty and I am isBoundedAbove. I report as my stop the smallest position I *do not* contain, which is one greater than the largest position I do contain. The ustop of the interval from 3 inclusive to 7 exclusive is 7.
See 'start', you may be surprised.

transitionCount

Do not send from outside the module. This should not be exported
outside the module, but to not export it in this case is some trouble.
It is used for an efficiency hack in PointRegion.

unionWith: region



Overrides: XnRegion

with: position



Overrides: XnRegion

withInt: pos




Index - All Packages - All Categories - All Classes