/ src / setup / src / strbst.h
strbst.h
 1  /* FinnOS - Beowulf cluster linux distro.
 2   * If you find this software useful, please consider supporting future development.
 3   * Donate what you believe this software is worth at: https://SammTech.net/donate
 4   * Copyright (c) 2025 Samm and FinnOS Contributors.
 5   * Licensed under the GNU General Public License, version 2 (GPLv2).
 6   * See LICENSE.txt for details.
 7   */
 8  
 9  #ifndef STRING_BINARY_SEARCH_TREE_H
10  #define STRING_BINARY_SEARCH_TREE_H
11  
12  #include <stdlib.h>
13  #include <string.h>
14  
15  #define MAX_BST_STR_SIZE 255
16  
17  typedef struct {
18      char* str;
19      void* eq; /* -> equal child */
20  } UnsortedStrBstNode;
21  
22  typedef struct str_bst_node_tds {
23      char* str;
24      struct str_bst_node_tds* lchild; /* left child */
25      struct str_bst_node_tds* rchild; /* right child */
26      void* echild; /* equal child */
27  } StrBstNode;
28  
29  StrBstNode* search_strbst(StrBstNode* bst, char* str);
30  StrBstNode* insert_to_strbst(StrBstNode* bst, UnsortedStrBstNode* unsort_node);
31  StrBstNode* insert_multiple_to_strbst(StrBstNode* bst, UnsortedStrBstNode* unsort_nodes, size_t unsort_size);
32  void destroy_strbst(StrBstNode* bst);
33  
34  #endif