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.

13.14 Constant Accessors ( constant da )<br />

1. Definition<br />

An instance ca of class constant da is bound to a specific value of type T, and the<br />

function get(ca, it) simply returns this value for each iterator.<br />

#include < <strong>LEDA</strong>/graph/graph iterator.h ><br />

2. Creation<br />

constant da ca(T t);<br />

introduces a variable ca of this class bound to the given value t.<br />

3. Operations<br />

T<br />

get(const constant da& ca, const Iter& it)<br />

returns the value to which ca is bound.<br />

4. Example<br />

With the template function of sect. 13.13 we can write a function that counts the number<br />

of nodes in a graph:<br />

int count_all(graph G) {<br />

constant_da Color(red);<br />

return count_red_t(G,Color); }<br />

13.15 Node Member Accessors ( node member da )<br />

1. Definition<br />

An instance da of class node member da manages the access to a node parameter<br />

that is organized as a member of a struct type, which is the first template argument of a<br />

parameterized graph GRAPH. <strong>The</strong> parameter is of type T and the struct of type<br />

Str.<br />

Classes edge member da is defined completely analogously.<br />

#include < <strong>LEDA</strong>/graph/graph iterator.h >

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

Saved successfully!

Ooh no, something went wrong!