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.10 Integer Sets ( int set )<br />

1. Definition<br />

An instance S of the data type int set is a subset of a fixed interval [a..b] of the integers,<br />

called the range of S.<br />

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

2. Creation<br />

int set S(int a, int b);<br />

creates an instance S of type int set for elements from [a..b] and<br />

initializes it to the empty set.<br />

int set S(int n); creates an instance S of type int set for elements from [0..n − 1]<br />

and initializes it to the empty set.<br />

3. Operations<br />

void S.insert(int x) adds x to S.<br />

Precondition: a ≤ x ≤ b.<br />

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

Precondition: a ≤ x ≤ b.<br />

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

Precondition: a ≤ x ≤ b.<br />

int S.min( ) returns the minimal integer in the range of of S.<br />

int S.max( ) returns the maximal integer in the range of of S.<br />

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

In any binary operation below, S and T must have the same range:<br />

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

replaces S by S ∪ T and returns it.<br />

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

replaces S by S ∩ T and returns it.<br />

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

replaces S by S \ T and returns it.<br />

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

replaces S by (S \ T ) ∪ (T \ S) and returns it.<br />

int set& S.complement( )<br />

replaces S by [a..b] \ S and returns it.

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

Saved successfully!

Ooh no, something went wrong!