This site contains older material on Eiffel. For the main Eiffel page, see http://www.eiffel.com.

EiffelBase class
(HTML page generated by ISE Eiffel 4.2)

Eiffel Class
indexing
	description: "Structures whose items are sorted according to a total order relation";
	status: "See notice at end of class";
	names: sorted_struct, comparable_struct;
	access: index, membership, min, max;
	contents: generic;
	date: "$Date: 2007-03-30 11:10:11 -0800 (Fri, 30 Mar 2007) $";
	revision: "$Revision: 95354 $"

deferred class SORTED_STRUCT [G -> COMPARABLE]

inherit
	COMPARABLE_STRUCT [G]
		undefine
			search, off
		redefine
			min, max
		end;
	INDEXABLE [G, INTEGER]
		rename
			item as i_th,
			put as put_i_th,
			bag_put as putt
		redefine
			putt
		end;
	LINEAR [G]

feature -- Measurement

	min: like item is
			-- Minimum item
		require
			is_sorted: sorted
		do
			start;
			Result := item
		end;

	max: like item is
			-- Maximum item
		require
			is_sorted: sorted
		do
			finish;
			Result := item
		end;

	median: like item is
			-- Median element
		deferred
		ensure
			median_present: has (Result)
		end;

feature -- Status report

	sorted: BOOLEAN is
			-- Is structure sorted?
		local
			m: like item
		do
			if empty then
				Result := true
			else
				from
					start;
					m := item;
					forth
				until
					exhausted or else (item < m)
				loop
					m := item;
					forth
				end;
				Result := exhausted
			end
		end;

feature -- Transformation

	sort is
			-- Sort structure.
		deferred
		ensure
			is_sorted: sorted
		end;

feature {NONE} -- Inapplicable

	putt (v: like item) is
		do
		end;

end -- class SORTED_STRUCT