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.

3. Creation<br />

timer<br />

t(const string& name, bool report on destruction = true);<br />

creates an instance t with the given name. If report on destruction<br />

is true, then the timer reports upon its destruction how long it has<br />

been running in total. <strong>The</strong> initial state of the timer is stopped.<br />

timer t; creates an unnamed instance t and sets the report on destruction<br />

flag to false. <strong>The</strong> initial state of the timer is stopped.<br />

4. Operations<br />

void t.reset( ) sets the internal counter and the total elapsed time to<br />

zero.<br />

void t.start( ) increments the internal counter.<br />

void t.stop( ) decrements the internal counter. (If the counter is<br />

already zero, nothing happens.)<br />

void t.restart( ) short-hand for t.reset( ) + t.start( ).<br />

void t.halt( ) sets the counter to zero, which forces the timer into<br />

the state stopped no matter how many start operations<br />

have been executed before.<br />

bool t.is running( ) returns if t is currently in the state running.<br />

float t.elapsed time( ) returns how long (in seconds) t has been in the state<br />

running (since the last reset).<br />

void<br />

t.set name(const string& name)<br />

sets the name of t.<br />

string t.get name( ) returns the name of t.<br />

void<br />

t.report on desctruction(bool do report = true)<br />

sets the flag report on destruction to do report.<br />

bool t.will report on desctruction( )<br />

5. Example<br />

returns whether t will issue a report upon its destruction.<br />

We give an example demonstrating the use of the class measure. Note that the function<br />

below has several return statements, so it would be tedious to stop the timer “by hand”.<br />

#include

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

Saved successfully!

Ooh no, something went wrong!