@@ -17,7 +17,8 @@ bool SetListContainer::checkingOfExistence(int checking_value) {
1717}
1818// Добавление нового элемента в множество в начало списка
1919void SetListContainer::add (int adding_value) {
20- set.push_front (adding_value);
20+ if (!checkingOfExistence (adding_value))
21+ set.push_front (adding_value);
2122}
2223// Мощность множества
2324int SetListContainer::powerOfTheSet () {
@@ -70,11 +71,11 @@ bool SetListContainer::isEqual(SetListContainer a, SetListContainer b) {
7071SetListContainer SetListContainer::combiningSets (SetListContainer a, SetListContainer b) {
7172 if (a.emptySet () || b.emptySet ())
7273 return *new SetListContainer ();
73- a. set . sort () ;
74- b.set . sort ();
75- a. set . merge (b. set );
76- a. set . unique ( );
77- return a ;
74+ SetListContainer c = a ;
75+ for ( int iter: b.set )
76+ if (!c. checkingOfExistence (iter))
77+ c. add (iter );
78+ return c ;
7879}
7980// Пересечение множеств
8081SetListContainer SetListContainer::intersectionOfSets (SetListContainer a, SetListContainer b) {
@@ -99,3 +100,44 @@ SetListContainer SetListContainer::symmetricDifferenceOfSets(const SetListContai
99100 if (intersectionOfSets (a,b).emptySet ()) return combiningSets (a,b);
100101 return differenceOfSets (combiningSets (a,b), intersectionOfSets (a,b));
101102}
103+ /*
104+ // Проверка множеств на равенство
105+ bool SetListContainer::isEqual(SetListContainer a, SetListContainer b) {
106+ return a.set == b.set;
107+ }
108+ // Объединение множеств
109+ SetListContainer SetListContainer::combiningSets(SetListContainer a, SetListContainer b) {
110+ if (a.emptySet() || b.emptySet())
111+ return *new SetListContainer();
112+ a.set.sort();
113+ b.set.sort();
114+ a.set.merge(b.set);
115+ a.set.unique();
116+ return a;
117+ }
118+ // Пересечение множеств
119+ SetListContainer SetListContainer::intersectionOfSets(SetListContainer a, SetListContainer b) {
120+ if (a.emptySet() || b.emptySet())
121+ return *new SetListContainer();
122+ a.set.sort();
123+ b.set.sort();
124+ SetListContainer c = *new SetListContainer();
125+ set_intersection(a.set.begin(), a.set.end(), b.set.begin(), b.set.end(), inserter(c.set,c.set.begin()));
126+ return c;
127+ }
128+ // Разность множеств
129+ SetListContainer SetListContainer::differenceOfSets(SetListContainer a, SetListContainer b) {
130+ SetListContainer c = *new SetListContainer();
131+ a.set.sort();
132+ b.set.sort();
133+ set_difference(a.set.begin(), a.set.end(), b.set.begin(), b.set.end(), inserter(c.set,c.set.begin()));
134+ return c;
135+ }
136+ // Симметричная разность множеств
137+ SetListContainer SetListContainer::symmetricDifferenceOfSets(SetListContainer a, SetListContainer b) {
138+ SetListContainer c = *new SetListContainer();
139+ a.set.sort();
140+ b.set.sort();
141+ set_symmetric_difference(a.set.begin(), a.set.end(), b.set.begin(), b.set.end(), inserter(c.set,c.set.begin()));
142+ return c;
143+ }*/
0 commit comments