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.

Input and Output<br />

void L.read(istream& I) reads a sequence of objects of type E from the input<br />

stream I using operator ≫ (istream&, E&).<br />

L is made a list of appropriate length and the sequence<br />

is stored in L.<br />

void<br />

void<br />

void<br />

L.read(istream& I, char delim)<br />

L.read(char delim = ’\n’)<br />

L.read(string prompt, char delim = ’\n’)<br />

as above but stops reading as soon as the first occurence<br />

of character delim is encountered.<br />

calls L.read(cin, delim) to read L from the standard<br />

input stream cin.<br />

As above, but first writes string prompt to cout.<br />

void L.print(ostream& O, char space = ’ ’)<br />

prints the contents of list L to the output tream O<br />

using operator ≪ (ostream&, const E&) to print<br />

each element. <strong>The</strong> elements are separated by character<br />

space.<br />

void<br />

L.print(char space = ’ ’) calls L.print(cout, space) to print L on the standard<br />

output stream cout.<br />

void L.print(string header, char space = ’ ’)<br />

Operators<br />

As above, but first outputs string header.<br />

list& L = const list& L1 <strong>The</strong> assignment operator makes L a copy of list<br />

L 1 . More precisely if L 1 is the sequence of items<br />

x 1 , x 2 , . . . , x n then L is made a sequence of items<br />

y 1 , y 2 , . . . , y n with L[y i ] = L 1 [x i ] for 1 ≤ i ≤ n.<br />

E& L[list item it] returns a reference to the contents of it.<br />

list item L[int i] an abbreviation for L.get item(i).<br />

list item L += const E& x same as L.append(x); returns the new item.<br />

ostream&<br />

istream&<br />

ostream& out ≪ const list& L<br />

same as L.print(out); returns out.<br />

istream& in ≫ list& L<br />

same as L.read(in)); returns in.

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

Saved successfully!

Ooh no, something went wrong!