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.

4.15 Some Useful Functions ( misc )<br />

<strong>The</strong> following functions and macros are defined in .<br />

int read int(string s) prints s and reads an integer from cin.<br />

double read real(string s) prints s and reads a real number from cin.<br />

string read string(string s) prints s and reads a line from cin.<br />

char read char(string s) prints s and reads a character from cin.<br />

int Yes(string s) returns (read char(s) == ‘y’).<br />

bool<br />

bool<br />

get environment(string var)<br />

get environment(string var, string& val)<br />

returns true if variable var is defined in the current<br />

environment and false otherwise.<br />

if variable var is defined in the current environment<br />

its value is assigned to val and the result is true. Otherwise,<br />

the result is false.<br />

float used time( ) returns the currently used cpu time in seconds. (<strong>The</strong><br />

class timer in Section 4.16 provides a nicer interface<br />

for time measurements.)<br />

float used time(float& T ) returns the cpu time used by the program from time<br />

T up to this moment and assigns the current time to<br />

T .<br />

void print statistics( ) prints a summary of the currently used memory,<br />

which is used by <strong>LEDA</strong>’s internal memory manager.<br />

This only reports on memory usage of <strong>LEDA</strong>’s internal<br />

types and user-defined types that implement the<br />

<strong>LEDA</strong> MEMORY macro (see Section 4.9).<br />

bool is space(char c) returns true is c is a white space character.<br />

void wait(double sec) suspends execution for sec seconds.<br />

double truncate(double x, int k = 10)<br />

returns a double whose mantissa is truncated after<br />

k − 1 bits after the binary point, i.e, if x ≠ 0 then<br />

the binary representation of the mantissa of the result<br />

has the form d.dddddddd, where the number of d’s<br />

is equal to k. <strong>The</strong>re is a corresponding function for<br />

integers; it has no effect.

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

Saved successfully!

Ooh no, something went wrong!