INDEX CLUSTER FEATURES SHORT FRAMES NO FRAMES

indexing

description: "Two-dimensional arrays"
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: array2, matrix, table
cluster: eiffelbase
class ARRAY2 [G]
inherit

ISE_ARRAY [G]
rename
make as array_make,
item as array_item,
put as array_put,
force as array_force,
wipe_out as array_wipe_out,
resize as array_resize
export
{NONE}
all
{ARRAY2}
array_put
end

ISE_ARRAY [G]
rename
make as array_make,
item as array_item,
put as array_put,
force as array_force,
resize as array_resize
export
{NONE}
all
{ARRAY2}
array_put
redefine
wipe_out
select
wipe_out
end
creation

make
feature -- Initialization

make (nb_rows, nb_columns: INTEGER)
-- Create a two dimensional array which has `nb_rows'
-- rows and `nb_columns' columns,
-- with lower bounds starting at 1.
require
not_flat: nb_rows > 0
not_thin: nb_columns > 0
ensure
new_count: count = height * width

initialize (v: G)
-- Make each entry have value `v'.
feature -- Access

item (row, column: INTEGER): G
-- Entry at coordinates (`row', `column')
require
valid_row: (1 <= row) and (row <= height)
valid_column: (1 <= column) and (column <= width)
feature -- Measurement

height: INTEGER

width: INTEGER
feature -- Element change

put (v: G; row, column: INTEGER)
-- Assign item `v' at coordinates (`row', `column').
require
valid_row: 1 <= row and row <= height
valid_column: 1 <= column and column <= width

force (v: G; row, column: INTEGER)
-- Assign item `v' at coordinates (`row', `column').
-- Resize if necessary.
require
row_large_enough: 1 <= row
column_large_enough: 1 <= column
feature -- Removal

wipe_out
-- Remove all items.
feature -- Resizing

resize (nb_rows, nb_columns: INTEGER)
-- Rearrange array so that it can accommodate
-- `nb_rows' rows and `nb_columns' columns,
-- without losing any previously
-- entered items, nor changing their coordinates;
-- do nothing if not possible.
require
valid_row: nb_rows >= 1
valid_column: nb_columns >= 1
invariant

items_number: count = width * height
end -- class ARRAY2

INDEX CLUSTER FEATURES SHORT FRAMES NO FRAMES