EiffelBase class
(HTML page generated by ISE Eiffel 4.2)
Eiffel Class
indexing
description: "Data structures whose items may be compared according to a partial order relation";
status: "See notice at end of class";
names: comparable_struct;
access: min, max;
contents: generic;
date: "$Date: 2007-03-30 19:10:11 +0000 (Fri, 30 Mar 2007) $";
revision: "$Revision: 95354 $"
deferred class COMPARABLE_STRUCT [G -> COMPARABLE]
inherit
BILINEAR [G]
feature -- Measurement
min: like item is
-- Minimum item
require
min_max_available
do
from
start;
Result := item;
forth
until
off
loop
if item < Result then
Result := item
end;
forth
end
end;
max: like item is
-- Maximum item
require
min_max_available
do
from
start;
Result := item;
forth
until
off
loop
if item > Result then
Result := item
end;
forth
end
end;
min_max_available: BOOLEAN is
-- Can min and max be computed?
do
Result := notempty
ensure
Result implies notempty
end;
feature {NONE} -- Inapplicable
index: INTEGER is
do
end;
invariant
empty_constraint: min_max_available implies notempty;
end -- class COMPARABLE_STRUCT
|