Skip to content

Deque#1

Open
Annarrchy wants to merge 6 commits into
mainfrom
Deque
Open

Deque#1
Annarrchy wants to merge 6 commits into
mainfrom
Deque

Conversation

@Annarrchy

Copy link
Copy Markdown
Owner

No description provided.

@Annarrchy Annarrchy requested a review from FlyLikeSoarin June 18, 2022 14:53
Comment thread deque.h Outdated
@@ -0,0 +1,381 @@
#include <iostream>

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Нужно добавить обработку исключений

Comment thread deque.h Outdated

public:
Iterat(type** iter, uint64_t index) : iterat(iter), ind(index) {};
Iterat& operator++() {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

выражается через +=

Comment thread deque.h Outdated
return *this;
};

Iterat& operator--() {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

выражается через -=

Comment thread deque.h Outdated
}
}

explicit Deque(int n, const type& value = type()) : siz(static_cast<size_t>(n)) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

n раз push_back

Comment thread deque.h Outdated
init->curr = block_capacity - 1;
}
}
new(arr[init->amount] + init->curr) type(value);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Кажется у тебя тут все элементы массива (блоки) уже аллоцированы

Comment thread deque.h Outdated
siz += 1;
}
void erase(Iterat<false> it) {
for (auto i = it; i < end() - 1; ++i) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Если вдруг случится исключение - дек не менялся

Comment thread deque.h Outdated
siz -= 1;
}
void insert(Iterat<false> it, const type& val) {
push_back(val);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Если вдруг случится исключение - дек не менялся

Comment thread deque.h
Comment thread deque.h Outdated
Comment thread deque.h Outdated
Comment thread deque.h Outdated
Comment thread deque.h Outdated
Comment thread deque.h Outdated
Comment thread deque.h Outdated
Comment thread deque.h Outdated
}
}
new(arr[fin->amount] + fin->curr) type(value);
arr[fin->block_number][fin->curr] = type(value);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Если операция кидает исключение - то нужно вернуть блок назад. Иначе у тебя в конце несуществующий элемент.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

arr[fin->block_number][fin->curr] = value;;

Comment thread deque.h Outdated
Comment thread deque.h
Comment thread deque.h Outdated
Comment thread deque.h
Comment thread deque.h Outdated
Comment thread deque.h
Comment thread deque.h Outdated
arr[0] = reinterpret_cast<type*>(new uint64_t[s]);
}
catch (...) {
delete arr[0];

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

delete[]

Comment thread deque.h
while (i >= 0) {
delete[] arr[i];
--i;
}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

throw;

Comment thread deque.h Outdated
};
}
catch (...) {
fin->~block();

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Не нужно

Comment thread deque.h Outdated

};

block* init;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Сделать полями класса.

Comment thread deque.h
if (siz != 0) {
if (init->last != init->curr) {
init->curr -= 1;
Deque<type> copy = *this;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Тут так нельзя.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants