charset.h
Type | |
Defines the abstract type used to represent sets of characters | |
Functions | |
Creates an empty set capable of holding characters. | |
Frees the storage associated with a character set. | |
Returns the number of elements in the set. | |
Returns true if the set has no elements. | |
Removes all characters from the set. | |
Creates a copy of the set. | |
Returns true if the character ch is a member of the set. | |
Adds the character ch to the set. | |
Adds the characters in str to the set. | |
Removes an element from the set. | |
Returns true if s1 and s2 are equal, which means that they contain the same elements. | |
Returns true if s1 is a subset of s2 . | |
Returns a new set consisting of all elements in either s1 or s2 . | |
Returns a new set consisting of all elements in both s1 and s2 . | |
Returns a new set consisting of all elements in s1 that are not elements of s2 . |
typedef struct CharSetCDT *CharSet;
CharSet newCharSet();
Usage:
set = newCharSet();
void freeCharSet(CharSet set);
Usage:
freeCharSet(set);
int size(CharSet set);
Usage:
n = size(set);
bool isEmpty(CharSet set);
true
if the set has no elements.
Usage:
if (isEmpty(set)) . . .
void clear(CharSet set);
Usage:
clear(set);
CharSet clone(CharSet set);
clone
function copies
only the first level of the structure and does not copy the individual
elements.
Usage:
newset = clone(set);
bool contains(CharSet set, char ch);
true
if the character ch
is a member
of the set.
Usage:
if (contains(set, ch)) . . .
void add(CharSet set, char ch);
ch
to the set.
Usage:
add(set, ch);
void addString(CharSet set, string str);
str
to the set.
Usage:
addString(set, str);
void remove(CharSet set, char ch);
Usage:
remove(set, ch);
bool equals(CharSet s1, CharSet s2);
true
if s1
and s2
are equal, which means that they contain the same elements.
Usage:
if (equals(s1, s2)) . . .
bool isSubset(CharSet s1, CharSet s2);
true
if s1
is a subset of s2
.
Usage:
if (isSubset(s1, s2)) . . .
CharSet union(CharSet s1, CharSet s2);
s1
or s2
.
Usage:
set = union(s1, s2);
CharSet intersection(CharSet s1, CharSet s2);
s1
and s2
.
Usage:
set = intersection(s1, s2);
CharSet setDifference(CharSet s1, CharSet s2);
s1
that
are not elements of s2
.
Usage:
set = setDifference(s1, s2);