Skip to content

bdz_2 #5

Open
Shrimp-proger wants to merge 1 commit intoSergeyBalabaev:mainfrom
Shrimp-proger:main
Open

bdz_2 #5
Shrimp-proger wants to merge 1 commit intoSergeyBalabaev:mainfrom
Shrimp-proger:main

Conversation

@Shrimp-proger
Copy link

Реализация контейнера мап с использованием красночерных деревьев для типа данных инт

@okuroshi okuroshi self-requested a review May 23, 2025 09:19
Copy link
Collaborator

@okuroshi okuroshi left a comment

Choose a reason for hiding this comment

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

Добавь больше тестов на крайние случае. Какой стайл код использовался ?

map_erase(my_map, 10);
map_destroy(my_map);
return 0;
} No newline at end of file
Copy link
Collaborator

Choose a reason for hiding this comment

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

Потерял \n

#include "map_lib.h"

Node* createNIL() {
Node* nil = (Node*)malloc(sizeof(Node));
Copy link
Collaborator

Choose a reason for hiding this comment

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

Нет проверки корректного результата выполнения malloc

Copy link
Collaborator

Choose a reason for hiding this comment

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

Требуется ли каст к Node, является ли это избыточным или нет ? Уточни в доке

}

Map* map_create() {
Map* map = (Map*)malloc(sizeof(Map));
Copy link
Collaborator

Choose a reason for hiding this comment

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

Нет проверки корректного результата выполнения malloc

Copy link
Collaborator

Choose a reason for hiding this comment

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

Требуется ли каст к Map, является ли это избыточным или нет ? Уточни в доке

}

void map_insert(Map* map, int key, void* value) {
Node* z = (Node*)malloc(sizeof(Node));
Copy link
Collaborator

Choose a reason for hiding this comment

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

Нет проверки корректного результата выполнения malloc

Copy link
Collaborator

Choose a reason for hiding this comment

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

Требуется ли каст к Node, является ли это избыточным или нет ? Уточни в доке

else
y->right = z;

insert_fixup(map, z);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Существует ли кейс в котором z, кроме как z->parent = y больше не заполниться ничем и из-за этого в insert_fixup в строке z->parent->parent->left будет segfault ?

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