Squeak Class Documentation category index | class index  
 
Interval
  category: Collections-Sequenceable
  superclass: SequenceableCollection
  subclasses: TextLineInterval

I represent a finite arithmetic progression.

instance methods
  accessing
  at:
at:put:
first
includes:
increment
last
rangeIncludes:
size

  adding
  add:

  comparing
  =
hash
hashMappedBy:

  copying
  copy
shallowCopy

  enumerating
  collect:
do:
reverseDo:

  printing
  printOn:
storeOn:

  private
  setFrom:to:by:
species
valuesInclude:

  removing
  remove:

class methods
  instance creation
  from:to:
from:to:by:
new
newFrom:

instance methods
  accessing top  
 

at:

Answer the anInteger'th element.


 

at:put:

Storing into an Interval is not allowed.


 

first

Refer to the comment in SequenceableCollection|first.


 

includes:

Determine if aNumber is an element of this interval.


 

increment

Answer the receiver's interval increment.


 

last

Refer to the comment in SequenceableCollection|last.


 

rangeIncludes:

Return true if the number lies in the interval between start and stop.


 

size

Answer how many elements the receiver contains.


  adding top  
 

add:

Adding to an Interval is not allowed.


  comparing top  
 

=

Answer true if my species and anInterval species are equal, and
if our starts, steps and sizes are equal.


 

hash

Hash is reimplemented because = is implemented.


 

hashMappedBy:

My hash is independent of my oop.


  copying top  
 

copy

Return a copy of me. Override the superclass because my species is
Array and copy, as inherited from SequenceableCollection, uses
copyFrom:to:, which creates a new object of my species.


 

shallowCopy

Without this method, #copy would return an array instead of a new interval.
The whole problem is burried in the class hierarchy and every fix will worsen
the problem, so once the whole issue is resolved one should come back to this
method fix it.


  enumerating top  
 

collect:

Evaluate aBlock with each of the receiver's elements as the argument.
Collect the resulting values into a collection like the receiver. Answer
the new collection.


 

do:

Refer to the comment in Collection|do:.


 

reverseDo:

Evaluate aBlock for each element of my interval, in reverse order.


  printing top  
 

printOn:

Append a sequence of characters that identify the receiver to aStream.


 

storeOn:

This is possible because we know numbers store and print the same.


  private top  
 

setFrom:to:by:


 

species

Answer the preferred class for reconstructing the receiver. For example,
collections create new collections whenever enumeration messages such as
collect: or select: are invoked. The new kind of collection is determined by
the species of the original collection. Species and class are not always the
same. For example, the species of Interval is Array.


 

valuesInclude:

Private - answer whether or not aNumber is one of the enumerated values in this interval.


  removing top  
 

remove:

Removing from an Interval is not allowed.


class methods
  instance creation top  
 

from:to:

Answer an instance of me, starting at startNumber, ending at
stopNumber, and with an interval increment of 1.


 

from:to:by:

Answer an instance of me, starting at startNumber, ending at
stopNumber, and with an interval increment of stepNumber.


 

new

Primitive. Create and answer with a new instance of the receiver
(a class) with no indexable fields. Fail if the class is indexable. Override
SequenceableCollection new. Essential. See Object documentation
whatIsAPrimitive.


 

newFrom:

Answer an instance of me containing the same elements as aCollection.