5.3 Class COMPARABLE |

indexing

description:"Objects that may be compared % %according to a total order relation";note:"The basic operation is<(less than); others % %are defined in terms of this operation andis_equal."

deferred class interface

COMPARABLE

-- Comparisonfeature

infix"<"(other:likeCurrent):BOOLEAN-- Is current object less thanother?requireother_exists:other/=Voiddeferredensureasymmetric:Resultimplies(notother<Current)

infix"<="(other:likeCurrent):BOOLEAN-- Is current object less than or equal toother?requireother_exists:other/=Voidensuredefinition:Result= (Current<other)oris_equal(other);

infix">="(other:likeCurrent):BOOLEAN-- Is current object greater than or equal toother?requireother_exists:other/=Voidensuredefinition:Result= (other<=Current)

infix">"(other:likeCurrent):BOOLEAN-- Is current object greater thanother?requireother_exists:other/=Voidensuredefinition:Result= (other<Current)

is_equal(other:likeCurrent):BOOLEAN-- Isotherattached to an object considered equal -- to current object? -- (Redefined fromGENERAL.)requireother_not_void:other/=Voidensuresymmetric:Resultimpliesother.is_equal(Current);consistent:standard_is_equal(other)impliesResult;trichotomy:Result= ((notCurrent<other)(and notother<Current))

max(other:likeCurrent):likeCurrent-- The greater of current object andotherrequireother_exists:other/=Voidensurecurrent_if_not_smaller: (Current>=other)(impliesResult=Current)other_if_smaller: (Current<other)(impliesResult=other)

min(other:likeCurrent):likeCurrent-- The smaller of current object andotherrequireother_exists:other/=Voidensurecurrent_if_not_greater: (Current<=other)(impliesResult=Current)other_if_greater: (Current>other)(impliesResult=other)

three_way_comparison(other:likeCurrent):INTEGER) -- If current object equal toother, 0; if smaller, -- -1; if greater, 1.requireother_exists:other/=Voidensureequal_zero: (Result=0) =is_equal(other);smaller_negative: (Result=-1) = (Current<other);greater_positive: (Result=1) = (Current>other)

invariant

irreflexive_comparison:(notCurrent<Current)

end

Copyright © 1995, Nonprofit
International Consortium for Eiffelmailto:nice@atlanta.twr.comLast Updated: 26 October 1997 |