Repository navigation
Conversation
Adapt the Lab3 C vector to store typed values. Use new[]/delete[] and element assignment instead of realloc. Add independent copying, assignment and swap.
Dovgalyuk
requested changes
Oct 22, 2026
| if (this == &a) return *this; | ||
| std::unique_ptr<Data[]> new_data(new Data[a.count]()); | ||
| for (size_t i = 0; i < a.count; i++) | ||
| new_data[i] = a.data[i]; |
Owner
There was a problem hiding this comment.
Копирование реализовано дважды.
| if (size == count) return; | ||
| if (size > count) { | ||
| if (size <= capacity) { | ||
| for (size_t i = count; i < size; i++) data[i] = Data(); |
Owner
There was a problem hiding this comment.
Емкость же выделена со значениями по умолчанию.
| } | ||
| private: | ||
| struct Edge { | ||
| bool exists = false; |
Owner
There was a problem hiding this comment.
Не логичнее хранить указатель на метку, чтобы не выделять лишнюю память?
| using namespace std; | ||
|
|
||
| bool find_path( | ||
| const Graph<string, long long> &residual, |
Dovgalyuk
requested changes
Oct 23, 2026
| const FlowGraph &residual, | ||
| size_t current, | ||
| size_t sink, | ||
| Vector<bool> &visited, |
Owner
There was a problem hiding this comment.
Здесь тоже не хватает typedef.
| edges.set(from * size() + to, Edge()); | ||
| } | ||
|
|
||
| Vector<VertexLabel> get_vertices() const{ |
Dovgalyuk
reviewed
Oct 27, 2026
|
|
||
| parent.set(next, current); | ||
|
|
||
| if (find_path(residual, next, sink, visited, parent)) |
Owner
There was a problem hiding this comment.
Поиск в глубину не лучший вариант, в больших графах может быть переполнение стека. Нужен либо собственный стек, либо поиск в ширину.
realize bfs with queue based on vector because every vertex can be in queue maximum once, so fixed sized vector will be enough
Contributor
Author
|
а еще удалил папку lab1C так как мешалась :) |
Dovgalyuk
reviewed
Oct 29, 2026
| typedef Graph<string, long long> FlowGraph; | ||
| typedef Vector<bool> Visited; | ||
| typedef Vector<size_t> Parents; | ||
| typedef Vector<size_t> VertexQueue; |
Owner
There was a problem hiding this comment.
Очередь же уже была реализована.
Надоело притворяться англичанином, нагуглил как подключить С библиотеку к CPP оказывается уже всё было, просто не было раньше необходимости Вектор был переписан чтобы хранить не только Data (который инт/указатель), а и строки и числа, в целом наверное можно было бы его тоже использовать из предыдущей, но тогда бы пришлось изгаляться с указателями на объекты. воооот
Owner
|
Принято.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.