next up previous contents index
Next: Timer ( timer ) Up: Simple Data Types and Previous: Socket Streambuffer ( socket_streambuf   Contents   Index


Some Useful Functions ( misc )

The following functions and macros are defined in < LEDA/core/misc.htex2html_wrap_inline> .

int read_int(string s) prints s and reads an integer from cin.

double read_real(string s) prints s and reads a real number from cin.

string read_string(string s) prints s and reads a line from cin.

char read_char(string s) prints s and reads a character from cin.

int Yes(string s) returns (read_char(s) == `y').

bool get_environment(string var)
    returns true if variable var is defined in the current environment and false otherwise.

bool get_environment(string var, string& val)
    if variable var is defined in the current environment its value is assigned to val and the result is true. Otherwise, the result is false.

float used_time() returns the currently used cpu time in seconds. (The class timer in Section timer provides a nicer interface for time measurements.)

float used_time(float& T) returns the cpu time used by the program from time T up to this moment and assigns the current time to T.

float elapsed_time() returns the current daytime time in seconds.

float elapsed_time(float& T) returns the elapsed time since time T and assigns the current elapsed time to T.

float real_time() same as elapased$\_$time().

float real_time(float& T) same as elapased$\_$time(T).

void print_statistics() prints a summary of the currently used memory, which is used by LEDA's internal memory manager. This only reports on memory usage of LEDA's internal types and user-defined types that implement the LEDA_MEMORY macro (see Section [*]).

bool is_space(char c) returns true is c is a white space character.

void sleep(double sec) suspends execution for sec seconds.

void wait(double sec) suspends execution for sec seconds.

double truncate(double x, int k = 10)
    returns a double whose mantissa is truncated after k - 1 bits after the binary point, i.e, if x $\not=$ 0 then the binary representation of the mantissa of the result has the form d.dddddddd, where the number of d's is equal to k. There is a corresponding function for integers; it has no effect.

template <class T>
const T& min(const T& a, const T& b)
    returns the minimum of a and b.

template <class T>
const T& max(const T& a, const T& b)
    returns the maximum of a and b.

template <class T>
void swap(T& a, T& b) swaps values of a and b.


next up previous contents index
Next: Timer ( timer ) Up: Simple Data Types and Previous: Socket Streambuffer ( socket_streambuf   Contents   Index