// * operator (INTERSECTION) set set::operator*(const set &s) // Postcondition: returns the intersection // of the active set with the set 's'. { set c; if(s.cardinality() < 1) return c; // self intersection if(this == &s) { c = *this; return c; } int i=0; for(i=0; i<s.entry_count; ++i) if(search(s.data[i])) c.insert(s.data[i]); for(i=0; i<s.child_count; ++i) c += *this*s.subset[i]; return c; }
// == operator (EQUALITY) bool set::operator==(const set &s) // Postcondition: checks to see if // set 's' equals the current set. { // self comparison if(this == &s) return true; if(s.cardinality() != cardinality()) return false; set tmp = *this; tmp.insertAll(s); if(tmp.cardinality() == cardinality()) return true; return false; }
// - operator (COMPLIMENT) set set::operator-(const set &s) // Postcondition: returns the // compliment of active set - 's' { set c; if(cardinality() < 1 || this == &s) return c; c = *this; // self assignment if(s.cardinality() < 1) return c; // Remove all intersecting parts c.removeAll(c*s); return c; }