indexing
description: "Routines that ought to be in class FIXED_ARRAY. A fixed array is a zero-based indexed sequence of values, equipped with features `put%', `item%' and `count%'."
library: "Gobo Eiffel Kernel Library"
author: "Eric Bezault <ericb@gobo.demon.co.uk>"
copyright: "Copyright (c) 1999, Eric Bezault"
class interface
KL_FIXED_ARRAY_ROUTINES [G]
feature -- Initialization
make (n: INTEGER): like fixed_array_type
-- Create a new fixed array being able to contain n items.
require
non_negative_n: n >= 0
ensure
fixed_array_not_void: Result /= void;
valid_fixed_array: valid_fixed_array (Result);
count_set: Result.count = n
make_from_array (an_array: ARRAY [G]): like fixed_array_type
-- Create a new fixed array with items from an_array.
require
an_array_not_void: an_array /= void
ensure
fixed_array_not_void: Result /= void;
valid_fixed_array: valid_fixed_array (Result);
count_set: Result.count = an_array.count
feature -- Status report
valid_fixed_array (an_array: like fixed_array_type): BOOLEAN
-- Make sure that the lower bound of an_array is zero.
require
an_array_not_void: an_array /= void
feature -- Removal
clear_all (an_array: like fixed_array_type)
-- Reset all items to default values.
require
an_array_not_void: an_array /= void;
valid_fixed_array: valid_fixed_array (an_array)
feature -- Resizing
resize (an_array: like fixed_array_type; n: INTEGER): like fixed_array_type
-- Resize an_array so that it contains n items.
-- Do not lose any previously entered items.
-- Note: the returned fixed array might be an_array
-- or a newly created fixed array where items from
-- an_array have been copied to.
require
an_array_not_void: an_array /= void;
valid_fixed_array: valid_fixed_array (an_array);
n_large_enough: n >= an_array.count
ensure
fixed_array_not_void: Result /= void;
valid_fixed_array: valid_fixed_array (Result);
count_set: Result.count = n
feature -- Conversion
to_fixed_array (an_array: ARRAY [G]): like fixed_array_type
-- Fixed array filled with items from an_array.
-- The fixed array and an_array may share internal
-- data. Use make_from_array if this is a concern.
require
an_array_not_void: an_array /= void
ensure
fixed_array_not_void: Result /= void;
valid_fixed_array: valid_fixed_array (Result);
count_set: Result.count >= an_array.count
feature -- Type anchors
fixed_array_type: SPECIAL [G]
-- (from KL_IMPORTED_FIXED_ARRAY_TYPE)
invariant
-- from GENERAL
reflexive_equality: standard_is_equal (Current);
reflexive_conformance: conforms_to (Current);
end -- class KL_FIXED_ARRAY_ROUTINES