+
Point of view
All features
deferred class COMPARABLE
Summary
All classes handling COMPARABLE objects with a total order relation should inherit from this class.
Direct parents
Insert list: ANY
Known children
Inherit list: ABSTRACT_STRING, FLOAT, INTEGRAL, MUTABLE_BIG_INTEGER, NATURAL_GENERAL, NUMBER, REPOSITORY_TRANSIENT_OBJECT, UNICODE_STRING
Insert list: CHARACTER, COMMAND_LINE_CONTEXT, MICROSECOND_TIME, TIME
Overview
Features
{ANY}
  • is_equal (other: COMPARABLE): BOOLEAN
    Is other attached to an object considered equal to current object?
  • infix "<" (other: COMPARABLE): BOOLEAN
    Is Current strictly less than other?
  • infix "<=" (other: COMPARABLE): BOOLEAN
    Is Current less than or equal other?
  • infix ">" (other: COMPARABLE): BOOLEAN
    Is Current strictly greater than other?
  • infix ">=" (other: COMPARABLE): BOOLEAN
    Is Current greater than or equal than other?
  • in_range (lower: COMPARABLE, upper: COMPARABLE): BOOLEAN
    Return True if Current is in range [lower..upper]
    See also min, max, compare.
  • compare (other: COMPARABLE): INTEGER_32
    If current object equal to other, 0 if smaller, -1; if greater, 1.
  • three_way_comparison (other: COMPARABLE): INTEGER_32
    If current object equal to other, 0 if smaller, -1; if greater, 1.
  • min (other: COMPARABLE): COMPARABLE
    Minimum of Current and other.
  • max (other: COMPARABLE): COMPARABLE
    Maximum of Current and other.
  • bounded_by (a_min: COMPARABLE, a_max: COMPARABLE): COMPARABLE
    A value that is equal to Current if it is between the limits set by a_min and a_max.
is_equal (other: COMPARABLE): BOOLEAN
effective function
{ANY}
Is other attached to an object considered equal to current object?
require
  • other /= Void
ensure
  • trichotomy: Result = not Current < other and not other < Current
  • commutative: generating_type = other.generating_type implies Result = other.is_equal(Current)
infix "<" (other: COMPARABLE): BOOLEAN
deferred function
{ANY}
Is Current strictly less than other?
See also >, <=, >=, min, max.
require
  • other_exists: other /= Void
ensure
  • asymmetric: Result implies not other < Current
infix "<=" (other: COMPARABLE): BOOLEAN
effective function
{ANY}
Is Current less than or equal other?
See also >=, <, >, min, max.
require
  • other_exists: other /= Void
ensure
  • definition: Result = Current < other or is_equal(other)
infix ">" (other: COMPARABLE): BOOLEAN
effective function
{ANY}
Is Current strictly greater than other?
See also <, >=, <=, min, max.
require
  • other_exists: other /= Void
ensure
  • definition: Result = other < Current
infix ">=" (other: COMPARABLE): BOOLEAN
effective function
{ANY}
Is Current greater than or equal than other?
See also <=, >, <, min, max.
require
  • other_exists: other /= Void
ensure
  • definition: Result = other <= Current
in_range (lower: COMPARABLE, upper: COMPARABLE): BOOLEAN
effective function
{ANY}
Return True if Current is in range [lower..upper]
See also min, max, compare.
ensure
  • Result = Current >= lower and Current <= upper
compare (other: COMPARABLE): INTEGER_32
effective function
{ANY}
If current object equal to other, 0 if smaller, -1; if greater, 1.
See also min, max, in_range.
require
  • other_exists: other /= Void
ensure
  • equal_zero: Result = 0 = is_equal(other)
  • smaller_negative: Result = -1 = Current < other
  • greater_positive: Result = 1 = Current > other
three_way_comparison (other: COMPARABLE): INTEGER_32
effective function
{ANY}
If current object equal to other, 0 if smaller, -1; if greater, 1.
See also min, max, in_range.
require
  • other_exists: other /= Void
ensure
  • equal_zero: Result = 0 = is_equal(other)
  • smaller_negative: Result = -1 = Current < other
  • greater_positive: Result = 1 = Current > other
min (other: COMPARABLE): COMPARABLE
effective function
{ANY}
Minimum of Current and other.
See also max, in_range.
require
  • other /= Void
ensure
  • Result <= Current and then Result <= other
  • compare(Result) = 0 or else other.compare(Result) = 0
max (other: COMPARABLE): COMPARABLE
effective function
{ANY}
Maximum of Current and other.
See also min, in_range.
require
  • other /= Void
ensure
  • Result >= Current and then Result >= other
  • compare(Result) = 0 or else other.compare(Result) = 0
bounded_by (a_min: COMPARABLE, a_max: COMPARABLE): COMPARABLE
effective function
{ANY}
A value that is equal to Current if it is between the limits set by a_min and a_max.
Otherwise it's a_min if Current is smaller or a_max if Current is greater It's a shortcut for Current.min(a_max).max(a_min) also known as "clamp" in the widespread C library Glib
ensure
  • correctness: Result.in_range(a_min, a_max)