Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "UnionSet.h"
- UnionSet::UnionSet(IntSet *set1, IntSet *set2) {
- s1 = set1;
- s2 = set2;
- count = s1->GetCount() + s2->GetCount();
- }
- void UnionSet::Add(int elem) {
- if (Contains(elem)) return;
- s2->Add(elem);
- count++;
- }
- IntSet* UnionSet::Union(IntSet *other) {
- return new UnionSet(this, other);
- }
- void UnionSet::Rewind() {
- s1->Rewind();
- s2->Rewind();
- iterator = 0;
- }
- bool UnionSet::IsEnd() {
- return s2->IsEnd();
- }
- int UnionSet::Current() {
- if (s1->IsEnd()) return s2->Current();
- return s1->Current();
- }
- void UnionSet::MoveNext() {
- if (s1->IsEnd()) s2->MoveNext();
- else s1->MoveNext();
- iterator++;
- }
Advertisement
Add Comment
Please, Sign In to add comment