Everything must be redefined, but implementation can make use of the list data structure.
class Set {
public:
void add(int);
int includes(int);
void remove(int);
int firstElement();
private:
List data;
};
void Set::add (int x)
{
if (! data.includes(x))
data.add(x);
}
int includes (int x)
{
return data.includes(x);
}
void remove (int x)
{
data.remove(x);
}
int firstElement ()
{
return data.firstElement();
}