little add
This commit is contained in:
parent
560e1e985c
commit
3d078ae677
@ -126,13 +126,8 @@ class map
|
||||
|
||||
~map()
|
||||
{
|
||||
// if (_size && _root && _root != _end)
|
||||
// this->clear();
|
||||
//if (_size)
|
||||
//{
|
||||
this->destructTree(_root);
|
||||
this->destructNode(_end);
|
||||
//}
|
||||
this->destructTree(_root);
|
||||
this->destructNode(_end);
|
||||
}
|
||||
|
||||
map& operator=(const map& x)
|
||||
@ -141,11 +136,7 @@ class map
|
||||
_comp = (x._comp);
|
||||
_alloc = (x._alloc);
|
||||
_node_alloc = (x._node_alloc);
|
||||
//destructNode(_end);
|
||||
//_end = x._end;
|
||||
_size = 0;
|
||||
//_end = _node_alloc.allocate(1);
|
||||
//_node_alloc.construct(_end, node());
|
||||
_root = _end;
|
||||
insert(x.begin(), x.end());
|
||||
return (*this);
|
||||
@ -333,17 +324,6 @@ class map
|
||||
|
||||
void swap (map& x)
|
||||
{
|
||||
//map tmp;
|
||||
|
||||
// key_compare _comp;
|
||||
// allocator_type _alloc;
|
||||
// node_allocator_type _node_alloc;
|
||||
|
||||
// NodePtr _root;
|
||||
// NodePtr _end;
|
||||
// size_type _size;
|
||||
|
||||
// //destructNode(tmp._end);
|
||||
key_compare tmp_comp = _comp;
|
||||
allocator_type tmp_alloc = _alloc;
|
||||
node_allocator_type tmp_node_alloc = _node_alloc;
|
||||
@ -358,22 +338,17 @@ class map
|
||||
_size = x._size;
|
||||
_end = x._end;
|
||||
|
||||
//x = tmp;
|
||||
x._comp = tmp_comp;
|
||||
x._alloc = tmp_alloc;
|
||||
x._node_alloc = tmp_node_alloc;
|
||||
x._root = tmp_root;
|
||||
x._size = tmp_size;
|
||||
x._end = tmp_end;
|
||||
|
||||
//tmp._end = 0;
|
||||
//tmp._size = 0;
|
||||
}
|
||||
|
||||
void clear()
|
||||
{
|
||||
this->destructTree(_root);
|
||||
// this->destructNode(_end);
|
||||
_size = 0;
|
||||
_root = _end;
|
||||
}
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
/* By: apommier <apommier@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2022/11/29 12:55:23 by apommier #+# #+# */
|
||||
/* Updated: 2022/11/29 14:45:23 by apommier ### ########.fr */
|
||||
/* Updated: 2022/11/29 15:06:00 by apommier ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -53,6 +53,10 @@ void vector_tester()
|
||||
std::cout << "----assign val----" << std::endl;
|
||||
ctnr.assign(10, 1);
|
||||
printSize(ctnr);
|
||||
|
||||
std::cout << "----copy constructor----" << std::endl;
|
||||
ft::vector<int> ctnr_copy(ctnr);
|
||||
printSize(ctnr_copy);
|
||||
|
||||
std::cout << "----range constructor----" << std::endl;
|
||||
ft::vector<int> ctnr2(ctnr.begin(), ctnr.end());
|
||||
@ -156,7 +160,7 @@ void real_vector_tester()
|
||||
std::vector<int> ctnr3;
|
||||
ctnr3.assign(ctnr.begin(), ctnr.end());
|
||||
printSize_real(ctnr3);
|
||||
////////////
|
||||
|
||||
std::cout << "----insert at position + assign constrcutor----" << std::endl;
|
||||
std::vector<int> ctnr4(5, 5);
|
||||
printSize_real(ctnr4);
|
||||
@ -230,4 +234,6 @@ void real_vector_tester()
|
||||
|
||||
std::cout << "----relationnal ope----\n";
|
||||
cmp(ctnr, ctnr4);
|
||||
|
||||
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user