Search code examples
arrayseiffel

Eiffel - Two dimensional array


Is there a special class for a two-dimensional array in Eiffel? Now I do it like this, but I think there is an easier way.
columns: ARRAYED_LIST [ARRAYED_LIST [CHARACTER]]


Solution

  • There is a class ARRAY2. It has its own peculiarities, for example, you need to pass an object to fill the array on creation or when resizing it:

        make_filled (a_default_value: G; nb_rows, nb_columns: INTEGER_32)
        resize_with_default (a_default: G; nb_rows, nb_columns: INTEGER_32)
    

    But there are features item and put that allow for using a conventional syntax to manipulate elements:

        a [i, j] := a [i + 1, j - 8] + 35