INDEX CLUSTER FEATURES SHORT FRAMES NO FRAMES

indexing

description: "Finite structures whose item count is subject to change"
title: "EiffelBase: library of reusable components for Eiffel. ", "Based on EiffelBase library for ISE Eiffel, ", "used with permission. "
project: "EiffelBase Library"
copyright: "(c) 1986-1997 Interactive Software Engineering Inc. ", "Modifications and extensions: ", "(c) 1997 Object Tools ", "All rights reserved. Duplication and distribution prohibited", "May be used only with Visual Eiffel under terms of user ", "license "
key: storage
cluster: eiffelbase
deferred class RESIZABLE [G]
inherit

BOUNDED [G]
end
feature -- Measurement

Growth_percentage: INTEGER

Minimal_increase: INTEGER

additional_space: INTEGER
-- Proposed number of additional items
--| Result is a reasonable value, resulting from a space-time tradeoff.
ensure
at_least_one: Result >= 1
feature -- Status report

resizable: BOOLEAN
-- May `capacity' be changed? (Answer: yes.)
feature -- Resizing

automatic_grow
-- Change the capacity to accommodate at least
-- `Growth_percentage' more items.
--| Trades space for time:
--| allocates fairly large chunks of memory but not very often.
ensure
increased_capacity: capacity >= capacity + capacity * growth_percentage // 100

grow (i: INTEGER)
-- Ensure that capacity is at least `i'.
ensure
new_capacity: capacity >= i
invariant

increase_by_at_least_one: minimal_increase >= 1
end -- class RESIZABLE

INDEX CLUSTER FEATURES SHORT FRAMES NO FRAMES