**** 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

Ancestors
 \$STR \$NIL \$IS_NIL \$IS_EQ

Public

attr first: INT;
attr size: INT;

Features
aget(i: INT): INT
contains(i: INT): BOOL
 **** Returns true if self contains "i2"
 **** This precondition allows us to create an empty i_interval i.e. size=0
 **** Return an empty i_interval - size = 0
 **** 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
 **** The nil i_interval is empty...
 **** 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
 **** Nil if size is negative
last: INT
 **** Return a nil i_interval
 **** Shift the interval upwards by a the integer "by"
 **** Shift the interval upwards by a the integer "by"
 **** Print out the i_interval
 **** 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

Iters
 **** Yield successive integer intervals, starting at "start", with sizes specified by the "sizes" array. For eg. ___sz:ARRAY{INT}_:=_|2,3,2|; ___loop_#OUT+I_INTERVAL::create_successive!(1,sz)+"_";_end; ___does:__[1,2]_[3,5]_[6,7]
elt!: INT
partition_equally!(once k: INT): I_INTERVAL
partition_lump_at_end!(once k: INT): I_INTERVAL
reverse_elt!: INT

Private

check_non_nil(r: STR): BOOL
check_ok_create(f,l: INT): BOOL
 **** 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;
 **** 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;