next up previous contents index
Next: Stacks ( stack ) Up: Basic Data Types Previous: One Dimensional Arrays (

     
Two Dimensional Arrays ( array2 )

Definition

An instance A of the parameterized data type array2<E> is a mapping from a set of pairs I = [a..b] x [c..d], called the index set of A, to the set of variables of data type E, called the element type of A, for two fixed intervals of integers [a..b] and [c..d]. A(i, j) is called the element at position (i, j).

#include < LEDA/array2.h >

Creation

array2<E> A(int a, int b, int c, int d)
    creates an instance A of type array2<E> with index set [a..b] x [c..d].
array2<E> A(int n, int m) creates an instance A of type array2<E> with index set [0..n - 1] x [0..m - 1].

Operations

E& A(int i, int j) returns A(i, j).
Precondition: a < = i < = b and c < = j < = d.
int  A.low1() returns a.
int  A.high1() returns b.
int  A.low2() returns c.
int  A.high2() returns d.

Implementation

Two dimensional arrays are implemented by C++vectors. All operations take time O(1), the space requirement is O(I*sizeof (E)).


next up previous contents index
Next: Stacks ( stack ) Up: Basic Data Types Previous: One Dimensional Arrays (
LEDA research project
1999-04-23