//delete Word tweeted by delUser void delTweetWord(User* delUser) { wordList* delWord = delUser->wordFirst; while (delWord) { delWord->word->userCount = delWord->word->userCount - delWord->count; UserList* list = delWord->word->first; if (list->user == delUser) { delWord->word->first = list->next; free(list); } else { UserList* pre = list; list = list->next; while (list) { if (list->user == delUser) { pre->next = list->next; free(list); break; } pre = pre->next; list = list->next; } } if (delWord->word->userCount == 0) { deleteWord(&words, delWord->word); } delWord = delWord->next; } }
void clearTrie(void){ if(root != NULL) clearNode(root); root = NULL; for(int i = 0;i < numberOfWords;i++){ endOfWord[i] = NULL; deleteWord(&words[i]); } numberOfNodes = 0; }
//dodaje ostatni dodany do bazy wyraz void addLastWord(void){ Word *last = &words[numberOfWords - 1]; if(findTree(root, last->text, last->size, true)) ignore(); if(checkBadLine()){ numberOfWords--; deleteWord(&words[numberOfWords]); return; } if(root == NULL) root = makeLeaf(NULL, 0, NO_END_OF_WORD, NULL); addWordToNode(root, last->text, last->size, numberOfWords - 1); nodes(); assert(endOfWord[numberOfWords - 1] != NULL); printf("word number: %d\n", numberOfWords - 1); }