Conversation
| @@ -0,0 +1,381 @@ | |||
| #include <iostream> | |||
There was a problem hiding this comment.
Нужно добавить обработку исключений
|
|
||
| public: | ||
| Iterat(type** iter, uint64_t index) : iterat(iter), ind(index) {}; | ||
| Iterat& operator++() { |
There was a problem hiding this comment.
выражается через +=
| return *this; | ||
| }; | ||
|
|
||
| Iterat& operator--() { |
There was a problem hiding this comment.
выражается через -=
| } | ||
| } | ||
|
|
||
| explicit Deque(int n, const type& value = type()) : siz(static_cast<size_t>(n)) { |
| init->curr = block_capacity - 1; | ||
| } | ||
| } | ||
| new(arr[init->amount] + init->curr) type(value); |
There was a problem hiding this comment.
Кажется у тебя тут все элементы массива (блоки) уже аллоцированы
| siz += 1; | ||
| } | ||
| void erase(Iterat<false> it) { | ||
| for (auto i = it; i < end() - 1; ++i) { |
There was a problem hiding this comment.
Если вдруг случится исключение - дек не менялся
| siz -= 1; | ||
| } | ||
| void insert(Iterat<false> it, const type& val) { | ||
| push_back(val); |
There was a problem hiding this comment.
Если вдруг случится исключение - дек не менялся
| } | ||
| } | ||
| new(arr[fin->amount] + fin->curr) type(value); | ||
| arr[fin->block_number][fin->curr] = type(value); |
There was a problem hiding this comment.
Если операция кидает исключение - то нужно вернуть блок назад. Иначе у тебя в конце несуществующий элемент.
There was a problem hiding this comment.
arr[fin->block_number][fin->curr] = value;;
| arr[0] = reinterpret_cast<type*>(new uint64_t[s]); | ||
| } | ||
| catch (...) { | ||
| delete arr[0]; |
| while (i >= 0) { | ||
| delete[] arr[i]; | ||
| --i; | ||
| } |
| }; | ||
| } | ||
| catch (...) { | ||
| fin->~block(); |
|
|
||
| }; | ||
|
|
||
| block* init; |
There was a problem hiding this comment.
Сделать полями класса.
| if (siz != 0) { | ||
| if (init->last != init->curr) { | ||
| init->curr -= 1; | ||
| Deque<type> copy = *this; |
No description provided.