eXept Software AG Logo

Smalltalk/X Webserver

Documentation of class 'Magnitude':

Home

everywhere
www.exept.de
for:
[back]

Class: Magnitude


Inheritance:

   Object
   |
   +--Magnitude
      |
      +--AbstractTime
      |
      +--ArithmeticValue
      |
      +--Character
      |
      +--Date
      |
      +--LookupKey

Package:
stx:libbasic
Category:
Magnitude-General
Version:
rev: 1.25 date: 2009/08/10 13:30:08
user: cg
file: Magnitude.st directory: libbasic
module: stx stc-classLibrary: libbasic
Author:
Claus Gittinger

Description:


This is an abstract class definining common methods for
Objects which can be compared by a kind of less than relation.


Class protocol:

queries
o  isAbstract
Return if this class is an abstract class.
True is returned for Magnitude here; false for subclasses.
Abstract subclasses must redefine again.


Instance protocol:

Compatibility-Squeak
o  min: aMin max: aMax
similar to clampBetween:and:

comparing
o  < aMagnitude
Compare the receiver with the argument and return true if the
receiver is less than the argument. Otherwise return false.

** This method raises an error - it must be redefined in concrete classes **

o  <= aMagnitude
return true, if the argument is greater or equal than the receiver

o  = aMagnitude
Compare the receiver with the argument and return true if the
receiver is equal to the argument. Otherwise return false.

** This method raises an error - it must be redefined in concrete classes **

o  > aMagnitude
return true, if the argument is less than the receiver

o  >= aMagnitude
return true, if the argument is less or equal than the receiver

o  clampBetween: min and: max
return the receiver if its between min .. max,
or min if its less than min, or max of its greater than max.
This is only a lazy-typers helper for: ((something min:max) max:min)

o  compare: arg ifLess: lessBlock ifEqual: equalBlock ifGreater: greaterBlock
three-way compare - thanks to Self for this idea.
Can be redefined in subclasses to do it with a single comparison if
comparison is expensive.

o  max: aMagnitude
return the receiver or the argument, whichever has greater magnitude

o  min: aMagnitude
return the receiver or the argument, whichever has lesser magnitude

iteration
o  downTo: stop by: step do: aBlock
For each element of the interval from the receiver down to the argument stop,
decrementing by step, evaluate aBlock, passing the number as argument.

o  downTo: stop do: aBlock
For each element of the interval from the receiver down to the argument stop,
evaluate aBlock, passing the number as argument.

o  to: stop by: incr do: aBlock
For each element of the interval from the receiver up to the argument stop, incrementing
by step, evaluate aBlock passing the element as argument.

Not all Magnitudes do implement #negative and #+ however,
so should this method go to ArithmethicValue?

Only use #<, to speed up things (for subclasses only defining #<)

o  to: stop by: incr doWithBreak: aBlock
For each element of the interval from the receiver up to the argument stop, incrementing
by step, evaluate aBlock passing the element as argument.
Pass a break argument, to allow for premature exit of the loop.

o  to: stop by: incr doWithExit: aBlock
For each element of the interval from the receiver up to the argument stop, incrementing
by step, evaluate aBlock passing the element as argument.
Pass a break argument, to allow for premature exit of the loop.

o  to: stop count: aBlock
same as (self to:stop) count:aBlock

o  to: stop do: aBlock
For each element of the interval from the receiver up to the argument stop,
evaluate aBlock, passing the number as argument.

o  to: stop doWithBreak: aBlock
For each element of the interval from the receiver up to the argument stop,
evaluate aBlock, passing the number as argument.
Pass a break argument, to allow for premature exit of the loop.

o  to: stop doWithExit: aBlock
For each element of the interval from the receiver up to the argument stop,
evaluate aBlock, passing the number as argument.
An exitBlock is passed as second argument, which allows for the loop to be terminated early.

testing
o  between: min and: max
return whether the receiver is less than or equal to the argument max
and greater than or equal to the argument min.

o  in: anInterval
return whether the receiver is within the interval bounds



ST/X 6.1.1; WebServer 1.620 at exept:8081; Wed, 23 May 2012 19:56:46 GMT