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: "Finite structures whose item count is subject to change";
	status: "See notice at end of class";
	names: storage;
	size: resizable;
	date: "$Date: 2007-03-30 19:10:11 +0000 (Fri, 30 Mar 2007) $";
	revision: "$Revision: 95354 $"

deferred class RESIZABLE [G]

inherit
	BOUNDED [G]

feature -- Measurement

	Growth_percentage: INTEGER is 50;
			-- Percentage by which structure will grow automatically

	Minimal_increase: INTEGER is 5;
			-- Minimal number of additional items

	additional_space: INTEGER is
			-- Proposed number of additional items
		do
			Result := (capacity * growth_percentage // 100).max (minimal_increase)
		ensure
			at_least_one: Result >= 1
		end;

feature -- Status report

	resizable: BOOLEAN is
			-- May capacity be changed? (Answer: yes.)
		do
			Result := true
		end;

feature -- Resizing

	automatic_grow is
			-- Change the capacity to accommodate at least
			-- Growth_percentage more items.
		do
			grow (capacity + additional_space)
		ensure
			increased_capacity: capacity >= old capacity + old capacity * growth_percentage // 100
		end;

	grow (i: INTEGER) is
			-- Ensure that capacity is at least i.
		deferred
		ensure
			new_capacity: capacity >= i
		end;

invariant

	increase_by_at_least_one: minimal_increase >= 1;

end -- class RESIZABLE