note description: "Two-dimensional arrays" library: "Free implementation of ELKS library" legal: "See notice at end of class." status: "See notice at end of class." names: array2, matrix, table representation: array access: index, row_and_column, membership size: resizable contents: generic date: "$Date: 2017-03-23 19:18:26 +0000 (Thu, 23 Mar 2017) $" revision: "$Revision: 100033 $" class interface ARRAY2 [G] create make, make_filled feature -- Initialization make_filled (a_default_value: G; nb_rows, nb_columns: INTEGER_32) -- Create a two dimensional array which has nb_rows -- rows and nb_columns columns, -- with lower bounds starting at 1 filled with value a_default_value. require nb_rows_non_negative: nb_rows >= 0 nb_columns_non_negative: nb_columns >= 0 both_zero_or_both_non_zero: not (nb_rows = 0 xor nb_columns = 0) ensure new_count: count = height * width filled: filled_with (a_default_value) initialize (v: G) -- Make each entry have value v. feature -- Access item alias "[]" (row, column: INTEGER_32): G assign put -- Entry at coordinates (row, column) require valid_row: (1 <= row) and (row <= height) valid_column: (1 <= column) and (column <= width) feature -- Measurement height: INTEGER_32 -- Number of rows width: INTEGER_32 -- Number of columns feature -- Element change put (v: like item; row, column: INTEGER_32) -- Assign item v at coordinates (row, column). require valid_row: 1 <= row and row <= height valid_column: 1 <= column and column <= width force (v: like item; row, column: INTEGER_32) -- Assign item v at coordinates (row, column). -- Resize if necessary. require row_large_enough: 1 <= row column_large_enough: 1 <= column has_default: ({G}).has_default feature -- Removal wipe_out -- Remove all items. feature -- Resizing resize_with_default (a_default: G; nb_rows, nb_columns: INTEGER_32) -- 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 new values are smaller. require valid_row: nb_rows >= 1 valid_column: nb_columns >= 1 ensure no_smaller_height: height >= old height no_smaller_width: width >= old width invariant items_number: count = width * height note copyright: "Copyright (c) 1984-2017, Eiffel Software and others" license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)" source: "[ Eiffel Software 5949 Hollister Ave., Goleta, CA 93117 USA Telephone 805-685-1006, Fax 805-685-6869 Website http://www.eiffel.com Customer support http://support.eiffel.com ]" end -- class ARRAY2
Generated by ISE EiffelStudio