/* This file contains the declaration of class Set.

-------------------------------------------------------*/

#ifndef SET
#define SET

#include "Boolean.h"

class Set
{
public:
   enum {MaxElements = 256};        // U = {0, 1, ..., 255}

   /* This function constructs a Set as the empty set.

      Precondition:  a Set has been defined with no arguments.
      Postcondition: that Set is initialized as an empty set.
   --------------------------------------------------------------------*/

   Set(void);


   /* This function constructs a Set from a list of Set elements.

   --------------------------------------------------------------------*/

   Set(unsigned Num, ...);


   /* This function returns the union of two Set objects.

      Receive: S1 and S2, two Set objects
      Return:  The union of S1 and S2
   ----------------------------------------------------------*/

   friend Set operator+(const Set& S1, const Set& S2);


   /* This function returns the insersection of two Set objects.

      Receive: S1 and S2, two Set objects
      Return: the intersection of S1 and S2
   ----------------------------------------------------------*/

   friend Set operator*(const Set& S1, const Set& S2);


   /* This function returns the difference of two Set objects.

      Receive: S1 and S2, two Set objects.
      Return: the difference of S1 and S2.
   ----------------------------------------------------------*/

   friend Set operator-(const Set& S1, const Set& S2);


   /* This function performs the set membership operation.

      Receive: Elem, an element.
      Return:  True, iff Elem is a member of the Set containing this
                 function.
   -------------------------------------------------------------------*/

   Boolean Contains(unsigned Elem) const;


   /* This function inserts an element into a Set.

      Receive: Elem, a set element
      Return:  The Set containing this function, with Elem as a member
   ------------------------------------------------------------------*/

   Boolean Insert(unsigned Elem);


   /* This function removes an element from a Set.

      Receive: Elem, a set element
      Return:  The Set containing this function, without Elem as a member
   ------------------------------------------------------------------*/

   Boolean Delete(unsigned Elem);


   /* This function provides stream output for a Set.

   ------------------------------------------------------------------*/

   friend ostream& operator<<(ostream& Out, const Set& S)


private:
   enum { BitsPerEntry = 32,        // number of bits in a long
          ArrayLength =             // # array elements needed
            MaxElements/BitsPerEntry};

   long
      Array[ArrayLength];           // container for the bits

};

#endif

