correct map insert to use _comp, add tests iterators in swap, and add correction screenshot
This commit is contained in:
BIN
correction.png
Normal file
BIN
correction.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 836 KiB |
@@ -152,9 +152,9 @@ MP_TPL pair<typename MP::iterator, bool> MP::
|
|||||||
if (value.first == n->value.first)
|
if (value.first == n->value.first)
|
||||||
return ft::make_pair(iterator(n, _sentinel), false);
|
return ft::make_pair(iterator(n, _sentinel), false);
|
||||||
n = next;
|
n = next;
|
||||||
if (value.first < n->value.first)
|
if (_comp(value.first, n->value.first))
|
||||||
next = n->left;
|
next = n->left;
|
||||||
else if (value.first > n->value.first)
|
else if (_comp(n->value.first, value.first))
|
||||||
next = n->right;
|
next = n->right;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -168,9 +168,9 @@ MP_TPL pair<typename MP::iterator, bool> MP::
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (value.first < n->value.first)
|
if (_comp(value.first, n->value.first))
|
||||||
n->left = next;
|
n->left = next;
|
||||||
else if (value.first > n->value.first)
|
else if (_comp(n->value.first, value.first))
|
||||||
n->right = next;
|
n->right = next;
|
||||||
}
|
}
|
||||||
next->up = n;
|
next->up = n;
|
||||||
|
|||||||
@@ -639,8 +639,19 @@ TEST_V(tests_vector_swap)
|
|||||||
ft::vector<T> foo (3,VAL(100)); // three ints with a value of 100
|
ft::vector<T> foo (3,VAL(100)); // three ints with a value of 100
|
||||||
ft::vector<T> bar (5,VAL(200)); // five ints with a value of 200
|
ft::vector<T> bar (5,VAL(200)); // five ints with a value of 200
|
||||||
|
|
||||||
|
typename ft::vector<T>::iterator it1 = foo.begin();
|
||||||
|
typename ft::vector<T>::iterator it2 = bar.begin();
|
||||||
|
|
||||||
|
std::cout << "it1:" << *it1 << " - it2:" << *it2 << "\n";
|
||||||
|
std::cout << "foo.begin():" << *(foo.begin()) << " - bar.begin():" << *(bar.begin()) << "\n";
|
||||||
|
|
||||||
foo.swap(bar);
|
foo.swap(bar);
|
||||||
|
|
||||||
|
std::cout << "swap\n";
|
||||||
|
|
||||||
|
std::cout << "it1:" << *it1 << " - it2:" << *it2 << "\n";
|
||||||
|
std::cout << "foo.begin():" << *(foo.begin()) << " - bar.begin():" << *(bar.begin()) << "\n";
|
||||||
|
|
||||||
PRINT(foo)
|
PRINT(foo)
|
||||||
|
|
||||||
PRINT(bar)
|
PRINT(bar)
|
||||||
|
|||||||
Reference in New Issue
Block a user