ezarrays Python Module Reference

 

Array2D Class Reference

ArrayEZ ArraysMultiArray

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

Array2D(nrows, ncols)
Creates a two-dimensional array with elements organized into rows and columns.
value = x[row, col]
Returns the value stored in an element of the array.
x[row, col] = value
Stores a new value into a specific element of the array.
clear()
Clears the array by setting every element to None.
clear(value)
Sets every element to a given value.
numCols()
Returns the number of columns in the 2-D array.
numRows()
Returns the number of rows in the 2-D array.

Detailed Description

Array2D(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.
Parameters:
nrows
The number of rows in the array, which must be >= 1.
ncols
The number of columns in the array, which must be >= 1.
numRows()
Returns the number of rows in the 2-D array.
Returns:
The number of rows in the array.
numCols()
Returns the number of columns in the 2-D array.
Returns:
The number of columns in the 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.
Parameters:
value
The value to be stored in each element of the array.
__getitem__: value = x[row, col]
Returns the value stored in an element of the array.
Parameters:
row
The row index of the element whose value is to be returned. It must be >= 0 and less than the number of rows in the array.
col
The column index of the element whose value is to be returned. It must be >= 0 and less than the number of columns in the array.
Returns:
The value stored in the given array element.
Exceptions:
IndexError
__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.
Parameters:
row
The row index of the element to be changed. It must be >= 0 and less than the number of rows in the array.
col
The column index of the element to be changed. It must be >= 0 and less than the number of columns in the array.
value
The new value to be stored in the given element.
Exceptions:
IndexError



ArrayEZ ArraysMultiArray
Print -- Recent Changes
Page last modified on March 06, 2013, at 04:20 PM