immutable class I_INTERVAL < $IS_EQ, $NIL, $STR
A 1D i_interval, [first,last] which includes both end points Can also be viewed as start,n_elts All empty i_intervals (size=0) are essentially the same are reduced to the canonical case, start = 0 size = 0 The nil i_interval is represented by: Start= 0 and size = -1 i.e. negative i_intervals are not considered legal This interval can also behave like a read-only array of integers.

Flattened version is here



Readable Attributes
attr first: INT;
attr size: INT;

aget(i: INT): INT
contains(i: INT): BOOL
contains(i2: SAME): BOOL
**** Returns true if self contains "i2"
create(first,last: INT): SAME
**** This precondition allows us to create an empty i_interval i.e. size=0
empty: SAME
**** Return an empty i_interval - size = 0
intersection(i: SAME): SAME
**** Intersection of self with i For now assume that in both i_intervals the first index is less than the second. May want to relax this later
is_disjoint(i: SAME): BOOL
is_empty: BOOL
**** The nil i_interval is empty...
is_eq(r: SAME): BOOL
**** If either value is nil, return false. Check for empties, since there is no canonical empty.. and all empty i_intervals are considered equal
is_intersecting(i: SAME): BOOL
is_nil: BOOL
**** Nil if size is negative
last: INT
nil: SAME
**** Return a nil i_interval
shift_down(by: INT): I_INTERVAL
**** Shift the interval upwards by a the integer "by"
shift_up(by: INT): I_INTERVAL
**** Shift the interval upwards by a the integer "by"
str: STR
**** Print out the i_interval
union(i2: SAME): SAME
**** Union of self with i2. Returns an interval consisting of the two extreme points of the interval If the intervals self and "i2" do not intersect, the interval returned will contain points in neither self nor i2

create!(once start: INT,once sizes: ARRAY{INT}): I_INTERVAL
**** Yield successive integer intervals, starting at "start", with sizes specified by the "sizes" array. For eg.
elt!: INT
partition_equally!(once k: INT): I_INTERVAL
partition_lump_at_end!(once k: INT): I_INTERVAL
reverse_elt!: INT


check_non_nil(r: STR): BOOL
check_ok_create(f,l: INT): BOOL
equally!(once n,once k: INT): INT
**** Breakdown "n" over "k" partitions. If "k" does not evenly divide "n" then spread out the remainder starting at partition 1. Returns the size of successive partitions
attr first: INT;
lump_at_end!(once n,once k: INT): INT
**** Partition the integer range [0 to n] into k partitions Return the size of each partitiong Similar to evenly, but the "remainder" (i.e. n mod k) will be placed in the last bin rather than being spread out over the first "remainder" bins
attr size: INT;

The Sather Home Page