From 89fec72cdd0ad61626ef3d3de58efac6be68506a Mon Sep 17 00:00:00 2001 From: narnaud Date: Mon, 5 Dec 2022 00:56:07 +0100 Subject: [PATCH] save 5-12-22 --- .../ft_container.hpp.AE6A49ED28E963FF.idx | Bin 0 -> 186 bytes .../index/iterator.hpp.B6BE3296FFA2AF9F.idx | Bin 0 -> 6854 bytes .../index/tester.cpp.133FD4700F7AEE0A.idx | Bin 0 -> 374 bytes .../index/vector.hpp.8C3201A34AC2A736.idx | Bin 0 -> 5526 bytes includes/vector.hpp | 52 +++++++++++++----- 5 files changed, 38 insertions(+), 14 deletions(-) create mode 100644 .cache/clangd/index/ft_container.hpp.AE6A49ED28E963FF.idx create mode 100644 .cache/clangd/index/iterator.hpp.B6BE3296FFA2AF9F.idx create mode 100644 .cache/clangd/index/tester.cpp.133FD4700F7AEE0A.idx create mode 100644 .cache/clangd/index/vector.hpp.8C3201A34AC2A736.idx diff --git a/.cache/clangd/index/ft_container.hpp.AE6A49ED28E963FF.idx b/.cache/clangd/index/ft_container.hpp.AE6A49ED28E963FF.idx new file mode 100644 index 0000000000000000000000000000000000000000..73e1a8cf60a0716217bf60e9e2a26d9b266355a1 GIT binary patch literal 186 zcmWIYbaUIpz`)>~;#rZKT9U{DWD5duaY<2T7?3^>#1(Uvo-yQWP~c$=@JlIAf1fDz zqebn4kj|X@Cl7{RH{Ua1X_ES)B;F-9Q_>ePb6>4$wo0{MymGS!Tjwz=;dRsVmVW>6 zQSf-e_W0vYHEq%^3w*nZD|3^81~U|;rWHfzoJ0^^T$Eg_3}P^Y2nb+;F&G#ae??6W N)HgrH$i&RV007buI1K;* literal 0 HcmV?d00001 diff --git a/.cache/clangd/index/iterator.hpp.B6BE3296FFA2AF9F.idx b/.cache/clangd/index/iterator.hpp.B6BE3296FFA2AF9F.idx new file mode 100644 index 0000000000000000000000000000000000000000..0924e83fd5c17b8f590f9bb683af2f0b16abeb1a GIT binary patch literal 6854 zcmY*e3s_V~vOax;8JKBiIta}091sRj28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&!#?%8~^|S literal 0 HcmV?d00001 diff --git a/.cache/clangd/index/vector.hpp.8C3201A34AC2A736.idx b/.cache/clangd/index/vector.hpp.8C3201A34AC2A736.idx new file mode 100644 index 0000000000000000000000000000000000000000..d84791128f49558045819a425ca4f21539acf8a4 GIT binary patch literal 5526 zcmY*d3s{s@8vZ%pFf;#Q=ARj04lpx-1BeV)89+gji-BVx1T7>&5OQe~<1!*@H=ndE zw{$JBl-7(#%@(z6b!#mb*IQ-9s%veQW~TO3N*A?@`c%8;|M8uFmgnJnIPZ6E|M|Z2 ze(#~mQ&O@jOc07&Jd5VHF1R~L5Cjwd^)Bf7{nP+KSVjb4(VsU|?Voipo&LCWRLI%A z)4nZ3cW6RaapIM#z9(j^d1sawxc~Jv*$s~^wN&-*{qp3|8?xi=R4t@a^zy z%ig-su1odl>quwe`K5*5-P4(W&oa}>^3r3?pJ~7Ef9XU@D zQgi8xC5v~|-5VG^_<3?r`Or|eD{}ql#IHYY+@w#n25#$)>&4CXlV>EN z!`h`%sTuC5giFTTr=*{k$V9l?XqyG@xGVRYhYzkfEs+Gc>z(xz;m#7@eX#GLgLwuL z#Mib`t64E{=N%bIea+srNg{UcF18mZDF*IoHI~AH#RnFPf{D9LF4Hu{z+I@BKD51d z<4TEyW9=TXNAkJThac^UO$-zTCm*eM=_e@$?h;MK=A-G~MMy-%=vrrOBHT0XOW1Mp zXx-Zq34?pKb9MsUo(Rp)xs|(%MInVxZgE-Mih;ZG(5}fDXEVx0VFGtk7j-KJ?%Tg! zet5+tc1$7;Ox`JWn&7T|_LXaGeYr!T;Nqhtmz1X%xa;YhLg#_!^8F%KB9-_e)=>Sy zjayd#?OBP$WAX*T3w+1YSg`enx7zle7)z#1lBs2~!Q@Rvj+hx&v$jb@kI@xUMJU{J zt(jZq=%02-B!qA6-r#$wV&HCZPqkb~Ik!p_jNC1{#B9aD-M(#8?V*ZWKb6RMOg>YZ z$>8o-tNZ1}?WL7tTXTpG6O#?xUBlOUzij@;YEdxo$&D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^j{G%W4@g)H2UO zSt7-IM6s(LZS6GRS7kQHrjBDIen2%y&rv% zF1;UpvF;e$V9I((j~-%zw@f_|YRgN!dSpFiUXwS%uNCW^h!#p7{|@IQNMn4#d)q;G%k%BFdj0zxBP$s zj0?nJ`QZW>1(*|-{9pl$2Mg~lKU4riHE>vdpa4eQ=CJ%Q0o>Etakngly*+ciPWg`r Y*^K?LJ-@CxlX*wk0b-31tUv|ffB%8900000 literal 0 HcmV?d00001 diff --git a/includes/vector.hpp b/includes/vector.hpp index a472722..471e3bf 100644 --- a/includes/vector.hpp +++ b/includes/vector.hpp @@ -1,6 +1,7 @@ #pragma once #include "iterator.hpp" #include +#include namespace ft { @@ -62,7 +63,18 @@ public: _alloc.deallocate(_begin, _capacity); } - vector &operator=(const vector &other); + vector &operator=(const vector &other) { + clear(); + _alloc.deallocate(_begin, _capacity); + _alloc = other._alloc; + _capacity = other._capacity; + _size = other._size; + _begin = _alloc.allocate(_capacity); + for (size_type i = 0; i < _size; i++) + _alloc.construct(_begin + i, *(other._begin + i)); + return (*this); + } + void assign(size_type count, const T &value); template < class It > void assign(It first, It last); allocator_type get_allocator(void) const { return _alloc; } @@ -97,11 +109,24 @@ public: ft::rev_iterator< cst_iterator > rend(void) const; // CAPACITY: - bool empty(void) const; - size_type size(void) const; - size_type max_size(void) const; - void reserve(size_type new_cap); - size_type capacity(void) const; + bool empty(void) const { return _size == 0; } + size_type size(void) const { return _size; } + size_type max_size(void) const { return _alloc.max_size(); } + void reserve(size_type new_cap) { + if (new_cap > max_size()) + throw(std::length_error("vector::reserve: new_cap > max_size")); + Allocator new_alloc; + pointer new_begin; + new_begin = new_alloc.allocate(new_cap); + for (size_type i = 0; i < _size; i++) + new_alloc.construct(new_begin + i, *(_begin + i)); + clear(); + _alloc.deallocate(_begin, _capacity); + _alloc = new_alloc; + _begin = new_begin; + _capacity = new_cap; + } + size_type capacity(void) const { return _capacity; } // MODIFIERS: void clear(void) { @@ -112,14 +137,13 @@ public: iterator insert(cst_iterator pos, const T &value); iterator insert(cst_iterator pos, size_type count, const T &value); template < class It > iterator insert(cst_iterator pos, It first, It last); - iterator erase(iterator pos); - iterator erase(iterator first, iterator last); - void push_back(const T& value); - void pop_back(void); - void resize(size_type count); - void resize(size_type count, T value = T()); - void swap( vector& other); - + iterator erase(iterator pos); + iterator erase(iterator first, iterator last); + void push_back(const T &value); + void pop_back(void); + void resize(size_type count); + void resize(size_type count, T value = T()); + void swap(vector &other); }; } // namespace ft