31.01.2014 Views

Version 5.0 The LEDA User Manual

Version 5.0 The LEDA User Manual

Version 5.0 The LEDA User Manual

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

7.5 Two-Dimensional Maps ( map2 )<br />

1. Definition<br />

An instance M of the parameterized data type map2 is an injective mapping<br />

from the pairs in I1 × I2, called the index type of M, to the set of variables of data type<br />

E, called the element type of M. I must be a pointer, item, or handle type or the type<br />

int. We use M(i, j) to denote the variable indexed by (i, j) and we use dom(M) to denote<br />

the set of “used indices”. This set is empty at the time of creation and is modified by<br />

map2 accesses.<br />

Related data types are map, d arrays, h arrays, and dictionaries.<br />

#include < <strong>LEDA</strong>/core/map2.h ><br />

2. Types<br />

map2 :: item<br />

the item type.<br />

map2 :: index type1<br />

the first index type.<br />

map2 :: index type2<br />

the second index type .<br />

map2 :: element type<br />

the element type.<br />

3. Creation<br />

map2 M;<br />

creates an injective function m from I1 × I2 to the set of<br />

unused variables of type E, sets xdef to the default value of<br />

type E (if E has no default value then xdef stays undefined)<br />

and dom(M) to the empty set, and initializes M with m.<br />

map2 M(E x);<br />

creates an injective function m from I1 × I2 to the set of<br />

unused variables of type E, sets xdef to x and dom(M) to<br />

the empty set, and initializes M with m.<br />

4. Operations<br />

E& M(const I1 & i, const I2 & j)<br />

returns the variable M(i).<br />

bool M.defined(const I1& i, const I2 & j)<br />

returns true if i ∈ dom(M) and false otherwise.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!