Array2D Class Reference
Defines a two-dimensional array with the elements organized into rows and columns. The array is defined with a limited number of operations similar those provided in other languages. The elements of the array, which store Python references, can be accessed using normal subscript notation, x[i, j]. The class is implemented as an array of arrays. Public Methods
Detailed DescriptionArray2D(nrows, ncols)
Creates a two-dimensional array with elements organized into rows and columns. The number of rows and columns in the array are provided as arguments. The elements are initialized to
None . The elements of the array are accessed by row and column position with the first element of each row and each column having an index of 0.
numRows()
Returns the number of rows in the 2-D array.
numCols()
Returns the number of columns in the 2-D array.
clear()
Clears the array by setting every element to
None .clear(value)
Sets every element to a given value. All of the elements in the array will reference the same object, not separate copies.
__getitem__: value = x[row, col]
Returns the value stored in an element of the array.
__setitem__: x[row, col] = value
Stores a new value into a specific element of the array. The contents of the array element in the given row and column is changed to
value .
|