|
|
Class: Magnitude
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
This is an abstract class definining common methods for
Objects which can be compared by a kind of less than relation.
queries
-
isAbstract
-
Return if this class is an abstract class.
True is returned for Magnitude here; false for subclasses.
Abstract subclasses must redefine again.
Compatibility-Squeak
-
min: aMin max: aMax
-
similar to clampBetween:and:
comparing
-
< 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 **
-
<= aMagnitude
-
return true, if the argument is greater or equal than the receiver
-
= 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 **
-
> aMagnitude
-
return true, if the argument is less than the receiver
-
>= aMagnitude
-
return true, if the argument is less or equal than the receiver
-
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)
-
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.
-
max: aMagnitude
-
return the receiver or the argument, whichever has greater magnitude
-
min: aMagnitude
-
return the receiver or the argument, whichever has lesser magnitude
iteration
-
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.
-
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.
-
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 #<)
-
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.
-
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.
-
to: stop count: aBlock
-
same as (self to:stop) count:aBlock
-
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.
-
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.
-
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
-
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.
-
in: anInterval
-
return whether the receiver is within the interval bounds
|