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.

6.11 Dynamic Integer Sets ( d int set )<br />

1. Definition<br />

An instance S of the data type d int set is a subset of the integers.<br />

#include < <strong>LEDA</strong>/core/d int set.h ><br />

2. Creation<br />

d int set S; creates an instance S of type d int set initializes it to the empty<br />

set.<br />

3. Operations<br />

int S.min( ) returns the smallest element in S.<br />

Precondition: S is not empty.<br />

int S.max( ) returns the largest element in S.<br />

Precondition: S is not empty.<br />

void S.insert(int x) adds x to S. As the sets range is expanding<br />

dynamically during insertion for the range<br />

[S.min( ), S.max( )] inserting the extrema early<br />

saves repeated reallocation time.<br />

void S.del(int x) deletes x from S.<br />

bool S.member(int x) returns true if x in S, false otherwise.<br />

int S.choose( ) returns a random element of S.<br />

Precondition: S is not empty.<br />

bool S.empty( ) returns true if S is empty, false otherwise.<br />

int S.size( ) returns the size of S.<br />

void S.clear( ) makes S the empty set.<br />

d int set S.join(const d int set& T ) returns S ∪ T .<br />

d int set S.intersect(const d int set& T )<br />

returns S ∩ T .<br />

d int set S.diff(const d int set& T ) returns S − T .<br />

d int set S.symdiff(const d int set& T )<br />

returns the symmectric difference of S and T .<br />

d int set S + const d int set& T returns the union S.join(T ).

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

Saved successfully!

Ooh no, something went wrong!