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.

6.9 Sets ( set )<br />

1. Definition<br />

An instance S of the parameterized data type set is a collection of elements of the<br />

linearly ordered type E, called the element type of S. <strong>The</strong> size of S is the number of<br />

elements in S, a set of size zero is called the empty set.<br />

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

2. Creation<br />

set S;<br />

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

set.<br />

3. Operations<br />

void S.insert(const E& x) adds x to S.<br />

void S.del(const E& x) deletes x from S.<br />

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

const E& S.choose( ) returns an element of S.<br />

Precondition: S is not empty.<br />

set S.join(const set& T )<br />

returns S ∪ T .<br />

set S.diff(const set& T )<br />

returns S − T .<br />

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

returns S ∩ T .<br />

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

set S + const set& T<br />

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

returns S.join(T ).<br />

set S − const set& T<br />

returns S.diff (T ).<br />

set S & const set& T<br />

returns S.intersect(T ).

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

Saved successfully!

Ooh no, something went wrong!