bst.h
Go to the documentation of this file.
1 /*
2  * This file is part of the alglib project.
3  *
4  * (c) Divyanshu Kakwani <divkakwani@gmail.com>
5  *
6  * For the full copyright and license information, please view the LICENSE file
7  * that was distributed with this source code.
8  */
9 
10 #pragma once
11 
12 // Forward declaration
13 template<typename> class BST;
14 
15 /*
16  * \brief A bst node
17  */
18 template<typename value_type>
19 struct BST_node {
20 
21  BST_node(const value_type& val, BST_node<value_type>* _parent = 0,
22  BST<value_type>* left_subtree = 0, BST<value_type>* right_subtree = 0) {
23 
24  data = val;
25  parent = _parent;
26  lt_subtree = left_subtree;
27  rt_subtree = right_subtree;
28  }
29 
31 
32  value_type data;
33 
36 
37 };
38 
39 template<typename value_type>
40 class BST {
41 
43 
44  explicit BST(const BST_node<value_type>& rt) { root = rt; }
45 
46  private:
47 
48  void insert(BST_node<value_type> node) {
49 
50  }
51 
52  public:
53 
54  typedef int PreIter;
55  typedef int PostIter;
56  typedef int InIter;
57 
58  // Changes to a tree
59  void insert(const value_type& val) {}
60  void remove(const value_type& val) {}
61 
62  // Inspection through iterators
63  PreIter prebegin() const {}
64  PreIter preend() const {}
65  InIter inbegin() const {}
66  InIter inend() const {}
67  PostIter postbegin() const {}
68  PostIter postend() const {}
69 
70 
72 
73 
74 };
75 
Definition: bst.h:13
PostIter postend() const
Definition: bst.h:68
PreIter preend() const
Definition: bst.h:64
int InIter
Definition: bst.h:56
BST_node(const value_type &val, BST_node< value_type > *_parent=0, BST< value_type > *left_subtree=0, BST< value_type > *right_subtree=0)
Definition: bst.h:21
int PostIter
Definition: bst.h:55
BST< value_type > * rt_subtree
Definition: bst.h:35
value_type data
Definition: bst.h:32
PostIter postbegin() const
Definition: bst.h:67
BST_node< value_type > * parent
Definition: bst.h:30
int PreIter
Definition: bst.h:54
InIter inend() const
Definition: bst.h:66
Definition: bst.h:19
void insert(const value_type &val)
Definition: bst.h:59
PreIter prebegin() const
Definition: bst.h:63
BST< value_type > * lt_subtree
Definition: bst.h:34
InIter inbegin() const
Definition: bst.h:65