⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 gdsl_rbtree.h

📁 一个通用的C语言实现的数据结构
💻 H
📖 第 1 页 / 共 2 页
字号:
 * found, it is removed from T and then returned. * * @note Complexity: O( log ( |T| ) ) * @pre T must be a valid gdsl_rbtree_t * @param T The red-black tree to modify * @param VALUE The value used to find the element to remove * @return the first founded element equal to VALUE in T in case is found. * @return NULL in case no element equal to VALUE is found in T. * @see gdsl_rbtree_insert() * @see gdsl_rbtree_delete() */extern gdsl_element_tgdsl_rbtree_remove (gdsl_rbtree_t T,		    void* VALUE		    );/** * @brief Delete an element from a red-black tree. * * Remove from the red-black tree the first founded element E equal to  * VALUE, by using T's COMP_F function passed to gdsl_rbtree_alloc(). If E is  * found, it is removed from T and E is deallocated using T's FREE_F function  * passed to gdsl_rbtree_alloc(), then T is returned. * * @note Complexity: O( log( |T| ) ) * @pre T must be a valid gdsl_rbtree_t * @param T The red-black tree to remove an element from * @param VALUE The value used to find the element to remove * @return the modified red-black tree after removal of E if E was found. * @return NULL if no element equal to VALUE was found. * @see gdsl_rbtree_insert() * @see gdsl_rbtree_remove() */extern gdsl_rbtree_tgdsl_rbtree_delete (gdsl_rbtree_t T,		    void* VALUE		    );/******************************************************************************//* Search functions of red-black trees                                        *//******************************************************************************//** * @brief Search for a particular element into a red-black tree. * * Search the first element E equal to VALUE in the red-black tree T, by  * using COMP_F function to find it. If COMP_F == NULL, then the COMP_F function * passed to gdsl_rbtree_alloc() is used. * * @note Complexity: O( log( |T| ) ) * @pre T must be a valid gdsl_rbtree_t * @param T The red-black tree to use. * @param COMP_F The comparison function to use to compare T's element with * VALUE to find the element E (or NULL to use the default T's COMP_F) * @param VALUE The value that must be used by COMP_F to find the element E * @return the first founded element E equal to VALUE. * @return NULL if VALUE is not found in T. * @see gdsl_rbtree_insert() * @see gdsl_rbtree_remove() * @see gdsl_rbtree_delete() */extern gdsl_element_tgdsl_rbtree_search (const gdsl_rbtree_t T,		    gdsl_compare_func_t COMP_F,		    void* VALUE		    );/******************************************************************************//* Parse functions of red-black trees                                         *//******************************************************************************//** * @brief Parse a red-black tree in prefixed order. * * Parse all nodes of the red-black tree T in prefixed order. The MAP_F  * function is called on the element contained in each node with the USER_DATA * argument. If MAP_F returns GDSL_MAP_STOP, then gdsl_rbtree_map_prefix() stops * and returns its last examinated element. * * @note Complexity: O( |T| ) * @pre T must be a valid gdsl_rbtree_t & MAP_F != NULL * @param T The red-black tree to map. * @param MAP_F The map function. * @param USER_DATA User's datas passed to MAP_F * @return the first element for which MAP_F returns GDSL_MAP_STOP. * @return NULL when the parsing is done. * @see gdsl_rbtree_map_infix() * @see gdsl_rbtree_map_postfix() */extern gdsl_element_tgdsl_rbtree_map_prefix (const gdsl_rbtree_t T,			gdsl_map_func_t MAP_F,			void* USER_DATA			);/** * @brief Parse a red-black tree in infixed order. * * Parse all nodes of the red-black tree T in infixed order. The MAP_F  * function is called on the element contained in each node with the USER_DATA * argument. If MAP_F returns GDSL_MAP_STOP, then gdsl_rbtree_map_infix() stops * and returns its last examinated element. * * @note Complexity: O( |T| ) * @pre T must be a valid gdsl_rbtree_t & MAP_F != NULL * @param T The red-black tree to map. * @param MAP_F The map function. * @param USER_DATA User's datas passed to MAP_F * @return the first element for which MAP_F returns GDSL_MAP_STOP. * @return NULL when the parsing is done. * @see gdsl_rbtree_map_prefix() * @see gdsl_rbtree_map_postfix() */extern gdsl_element_tgdsl_rbtree_map_infix (const gdsl_rbtree_t T,		       gdsl_map_func_t MAP_F,		       void* USER_DATA		       );/** * @brief Parse a red-black tree in postfixed order. * * Parse all nodes of the red-black tree T in postfixed order. The MAP_F  * function is called on the element contained in each node with the USER_DATA * argument. If MAP_F returns GDSL_MAP_STOP, then gdsl_rbtree_map_postfix()  * stops and returns its last examinated element. * * @note Complexity: O( |T| ) * @pre T must be a valid gdsl_rbtree_t & MAP_F != NULL * @param T The red-black tree to map. * @param MAP_F The map function. * @param USER_DATA User's datas passed to MAP_F * @return the first element for which MAP_F returns GDSL_MAP_STOP. * @return NULL when the parsing is done. * @see gdsl_rbtree_map_prefix() * @see gdsl_rbtree_map_infix() */extern gdsl_element_tgdsl_rbtree_map_postfix (const gdsl_rbtree_t T,			 gdsl_map_func_t MAP_F,			 void* USER_DATA			 );/******************************************************************************//* Input/output functions of red-black trees                                  *//******************************************************************************//** * @brief Write the element of each node of a red-black tree to a file. * * Write the nodes elements of the red-black tree T to OUTPUT_FILE, using * WRITE_F function. * Additionnal USER_DATA argument could be passed to WRITE_F. * * @note Complexity: O( |T| ) * @pre T must be a valid gdsl_rbtree_t & WRITE_F != NULL & OUTPUT_FILE != NULL * @param T The red-black tree to write. * @param WRITE_F The write function. * @param OUTPUT_FILE The file where to write T's elements. * @param USER_DATA User's datas passed to WRITE_F. * @see gdsl_rbtree_write_xml() * @see gdsl_rbtree_dump() */extern voidgdsl_rbtree_write (const gdsl_rbtree_t T,		   gdsl_write_func_t WRITE_F,		   FILE* OUTPUT_FILE,		   void* USER_DATA		   );/** * @brief Write the content of a red-black tree to a file into XML. * * Write the nodes elements of the red-black tree T to OUTPUT_FILE, into * XML language. * If WRITE_F != NULL, then use WRITE_F to write T's nodes elements to  * OUTPUT_FILE. * Additionnal USER_DATA argument could be passed to WRITE_F. * * @note Complexity: O( |T| ) * @pre T must be a valid gdsl_rbtree_t & OUTPUT_FILE != NULL * @param T The red-black tree to write. * @param WRITE_F The write function. * @param OUTPUT_FILE The file where to write T's elements. * @param USER_DATA User's datas passed to WRITE_F. * @see gdsl_rbtree_write() * @see gdsl_rbtree_dump() */extern voidgdsl_rbtree_write_xml (const gdsl_rbtree_t T,		       gdsl_write_func_t WRITE_F,		       FILE* OUTPUT_FILE,		       void* USER_DATA		       );/** * @brief Dump the internal structure of a red-black tree to a file. * * Dump the structure of the red-black tree T to OUTPUT_FILE. If  * WRITE_F != NULL, then use WRITE_F to write T's nodes elements to  * OUTPUT_FILE. * Additionnal USER_DATA argument could be passed to WRITE_F. * * @note Complexity: O( |T| ) * @pre T must be a valid gdsl_rbtree_t & OUTPUT_FILE != NULL * @param T The red-black tree to write. * @param WRITE_F The write function. * @param OUTPUT_FILE The file where to write T's elements. * @param USER_DATA User's datas passed to WRITE_F. * @see gdsl_rbtree_write() * @see gdsl_rbtree_write_xml() */extern voidgdsl_rbtree_dump (const gdsl_rbtree_t T,		  gdsl_write_func_t WRITE_F,		  FILE* OUTPUT_FILE,		  void* USER_DATA		  );/* * @} */#ifdef __cplusplus}#endif /* __cplusplus */#endif /* _GDSL_RBTREE_H_ *//** EMACS ** * Local variables: * mode: c * c-basic-offset: 4 * End: */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -