// File: Set_ADT.h // Definitions for ADT that implements set of objects #ifndef SET_ADT_H #define SET_ADT_H #include #include "SortSearch.h" using namespace std; // Need these for this one...these are forward declarations... // Need this one to make the class' name known, because the one we actually // have to do, for the << operator, refers to the class' name template class SetADT; // And here's the one of the template function template ostream &operator<<(ostream &,SetADT); template class SetADT { public: // Initialize Set to Empty SetADT(); // Add Item to Set // Pre: None // Post: If Elt already in set, size of set unchanged, otherwise // set has cardinality increase by 1 // Returns: 0=> Elt already in Set 1=> Elt added to Set int addElt(eltType); // Remove Item From Set // Pre: None // Post: If Elt not in set, size of set unchanged, otherwise // set has cardinality decrease by 1 // Returns: 0=> Elt not in Set 1=> Elt Removed From Set int removeElt(eltType); // Return # Elts in Set // Pre: None // Post: Set Unchanged // Returns: Cardinality of Set int cardinality() const; // Determine if an element is a member of the set // Pre: None // Post: Set Unchanged. Result dependent on argument membership // Returns: 0=> Elt not in Set 1=> Elt in Set int operator >(eltType); // Return Union of 2 Sets // Pre: None // Post: Returns union of argument SetADTs with no repitition of elements SetADT operator+(SetADT); // Return Intersection of 2 Sets // Pre: None // Post: Returns intersect of argument SetADTs SetADT operator *(SetADT); // Return Set Difference - Elts that are in 1st Set but not 2nd // Pre: None // Post: Returns difference of argument SetADTs SetADT operator -(SetADT); // Print the set // Pre:None // Post:None friend ostream &operator<< <> (ostream &,SetADT); private: eltType *ListOfElts; int Elts; }; #endif