Repository navigation
Conversation
return bal
…, когда первое дз бует замерджено этот hw1 я удалю и залью нормальный
yurii-litvinov
left a comment
There was a problem hiding this comment.
Комментарии к коммитам не очень. См. https://mukhutdinov.com/conventional-commits.html
| #include <stdbool.h> | ||
| #include <stddef.h> | ||
|
|
||
| typedef struct Node Node; |
There was a problem hiding this comment.
Внешнему миру вовсе незачем знать, что в словаре есть какие-то узлы, это объявление стоит спрятать в .c и подправить функции интерфейса модуля, чтобы они его не показывали.
|
|
||
| typedef struct Node Node; | ||
| typedef struct AVL { | ||
| Node* root; |
There was a problem hiding this comment.
И уж тем более внешнему миру не нужно знать про устройство дерева. И я бы сказал, что внешнему миру не нужно знать, что это вообще дерево, и переименовал бы эту структуру в Dictionary или что-то такое.
| Node* insertAVL(char* code, char* name, Node* node, bool* err); | ||
| const char* contains(Node* node, char* code); | ||
| void freeAVL(AVL* tree); | ||
| int saveAVLtoFILE(char* filename, AVL* tree); |
| Node* root; | ||
| } AVL; | ||
|
|
||
| void split(char* s, char* code, char* name, size_t len, char separator); |
There was a problem hiding this comment.
split вроде как к дереву не относится
| } AVL; | ||
|
|
||
| void split(char* s, char* code, char* name, size_t len, char separator); | ||
| AVL* readFileToAVL(char* filename); |
There was a problem hiding this comment.
К каждой функции из заголовочного файла нужен комментарий
| } | ||
| Node* deleteAVL(Node* node, char* code, bool* err) |
There was a problem hiding this comment.
| } | |
| Node* deleteAVL(Node* node, char* code, bool* err) | |
| } | |
| Node* deleteAVL(Node* node, char* code, bool* err) |
| free(node->code); | ||
| free(node->name); | ||
| free(node); |
There was a problem hiding this comment.
Сделали бы функцию, которая это делает
| #include <stdlib.h> | ||
| #include <string.h> | ||
|
|
||
| void test_empty_tree() |
There was a problem hiding this comment.
Выше был camelCase, тут snake_case, нехорошо
| AVL* tree = malloc(sizeof(AVL)); | ||
| tree->root = NULL; |
There was a problem hiding this comment.
Тестироваться должно внешнее поведение, тест не должен лезть во внутреннее представление абстрактного типа данных. И тогда и определение AVL в хедере будет не нужно.
| int main() | ||
| { | ||
| char userCom[100]; | ||
| char com[100]; |
|
|
||
| static Node* rotateLeft(Node* a) | ||
| { | ||
| Node* b = a->right; |
There was a problem hiding this comment.
Как-то не поправлено, и ниже с большими вращениями вообще жесть в этом плане
| free(node->code); | ||
| free(node->name); | ||
| free(node); |
| Node* root; | ||
| } AVL; | ||
|
|
||
| void split(char* s, char* code, char* name, size_t len, char separator); |
| { | ||
| printf("Тест 1: Пустое дерево... "); | ||
|
|
||
| AVL* tree = readFileToAVL("nonexistent.txt"); |
There was a problem hiding this comment.
Не уверен, что это скомпилируется. В CI тесты даже не пытаются собираться, кстати
Пустые CMakeLists.txt нужны чтобы проходил clang-tidy, при мердже они будут удалены