修复clear的bug
This commit is contained in:
@@ -171,7 +171,10 @@ namespace TinySTL{
|
|||||||
deque(const deque& x);
|
deque(const deque& x);
|
||||||
|
|
||||||
~deque(){
|
~deque(){
|
||||||
clear();
|
for (int i = 0; i != mapSize_; ++i)
|
||||||
|
if (!map_[i])
|
||||||
|
dataAllocator::deallocate(map_[i], getBuckSize());
|
||||||
|
delete[] map_;
|
||||||
}
|
}
|
||||||
|
|
||||||
deque& operator= (const deque& x);
|
deque& operator= (const deque& x);
|
||||||
@@ -202,8 +205,10 @@ namespace TinySTL{
|
|||||||
void clear(){
|
void clear(){
|
||||||
for (int i = 0; i != mapSize_; ++i)
|
for (int i = 0; i != mapSize_; ++i)
|
||||||
if (!map_[i])
|
if (!map_[i])
|
||||||
dataAllocator::deallocate(map_[i], getBuckSize());
|
dataAllocator::destroy(map_[i], map_[i] + getBuckSize());
|
||||||
delete[] map_;
|
mapSize_ = 0;
|
||||||
|
beg_.mapIndex_ = end_.mapIndex_ = mapSize_ / 2;
|
||||||
|
beg_.cur_ = end_.cur_ = map_[mapSize_ / 2];
|
||||||
}
|
}
|
||||||
private:
|
private:
|
||||||
T *getANewBuck(){
|
T *getANewBuck(){
|
||||||
|
|||||||
Reference in New Issue
Block a user