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

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Chapter 6<br />

Basic Data Types<br />

6.1 One Dimensional Arrays ( array )<br />

1. Definition<br />

An instance A of the parameterized data type array is a mapping from an interval<br />

I = [a..b] of integers, the index set of A, to the set of variables of data type E, the<br />

element type of A. A(i) is called the element at position i. <strong>The</strong> array access operator<br />

(A[i]) checks its precondition (a ≤ i ≤ b). <strong>The</strong> check can be turned off by compiling with<br />

the flag -D<strong>LEDA</strong>_CHECKING_OFF.<br />

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

2. Types<br />

array:: item<br />

array:: value type<br />

the item type.<br />

the value type.<br />

3. Creation<br />

array A(int a, int b);<br />

creates an instance A of type array with index set [a..b].<br />

array A(int n);<br />

creates an instance A of type array with index set [0..n − 1].<br />

array A;<br />

creates an instance A of type array with empty index set.<br />

Special Constructors<br />

array A(int low, const E& x, const E& y);<br />

creates an instance A of type array with index set [low, low + 1]<br />

initialized to [x, y].<br />

117

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

Saved successfully!

Ooh no, something went wrong!