Prakticke aspekty vývoje softwaru: Projekt 1 – Testování  1.0
Projekt zaměřený na osvojení praktik testování včetně technik test driven development, black box testing a white box testing.
red_black_tree_lib.h
1 //======== Copyright (c) 2018, FIT VUT Brno, All rights reserved. ============//
2 //
3 // Purpose: Red-Black Self balancing Tree private interface
4 //
5 // $NoKeywords: $ivs_project_1 $red_black_tree_lib.h
6 // $Authors: Filip Vaverka <ivaverka@fit.vutbr.cz>
7 // David Grochol <igrochol@fit.vutbr.cz>
8 // $Date: $2018-02-08
9 //============================================================================//
18 #include <stdlib.h>
19 
20 #pragma once
21 
22 #ifndef RED_BLACK_TREE_LIB_H_
23 #define RED_BLACK_TREE_LIB_H_
24 
25 #ifdef __cplusplus
26 extern "C" {
27 #endif // __cplusplus
28 
33 enum Color_t {
34  RED = 0,
35  BLACK
36 };
37 
42 typedef struct Node_t {
43  struct Node_t *pParent;
44  struct Node_t *pLeft;
45  struct Node_t *pRight;
46  int color;
47 
48  int key;
49 } Node_t;
50 
51 void BTCreate(Node_t **ppRoot);
52 void BTDestroy(Node_t **ppRoot);
53 
54 int BTInsertNode(Node_t **ppRoot, int key, Node_t **ppOutNode);
55 void BTInsertNodeMany(Node_t **ppRoot, size_t count, const int *pKeys,
56  Node_t **ppOutNodes, int *pOutStates);
57 int BTDeleteNode(Node_t **ppRoot, int key);
58 Node_t *BTFindNode(Node_t *pRoot, int key);
59 void BTGetLeafNodes(Node_t *pRoot, size_t *pOutNodesCount, Node_t **ppOutNodes);
60 void BTGetAllNodes(Node_t *pRoot, size_t *pOutNodesCount, Node_t **ppOutNodes);
61 void BTGetNonLeafNodes(Node_t *pRoot, size_t *pOutNodesCount, Node_t **ppOutNodes);
62 
63 #ifdef __cplusplus
64 }
65 #endif // __cplusplus
66 
67 #endif // RED_BLACK_TREE_LIB_H_
Node_t
The Node_t struct Struktura uzlu stromu.
Definition: red_black_tree_lib.h:42
Node_t::pParent
struct Node_t * pParent
Ukazatel na rodice uzlu, nebo NULL v pripade korene.
Definition: red_black_tree_lib.h:43
Node_t::color
int color
Barva uzlu (Color_t), tj. RED nebo BLACK.
Definition: red_black_tree_lib.h:46
Node_t::pRight
struct Node_t * pRight
Ukazatel na praveho potomka uzlu, nebo NULL pro listovy uzel.
Definition: red_black_tree_lib.h:45
Node_t::pLeft
struct Node_t * pLeft
Ukazatel na leveho potomka uzlu, nebo NULL pro listovy uzel.
Definition: red_black_tree_lib.h:44
Node_t::key
int key
Hodnota/klic tohoto uzlu.
Definition: red_black_tree_lib.h:48