source: branches/kendall-score/yat/utility/ranking/NodeBase.h @ 4070

Last change on this file since 4070 was 4070, checked in by Peter, 20 months ago

refs #710; add erase functions

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 2.1 KB
Line 
1#ifndef theplu_yat_utility_detail_node_base
2#define theplu_yat_utility_detail_node_base
3
4// $Id: NodeBase.h 4070 2021-08-09 06:32:59Z peter $
5
6/*
7  Copyright (C) 2021 Peter Johansson
8
9  This file is part of the yat library, http://dev.thep.lu.se/yat
10
11  The yat library is free software; you can redistribute it and/or
12  modify it under the terms of the GNU General Public License as
13  published by the Free Software Foundation; either version 3 of the
14  License, or (at your option) any later version.
15
16  The yat library is distributed in the hope that it will be useful,
17  but WITHOUT ANY WARRANTY; without even the implied warranty of
18  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19  General Public License for more details.
20
21  You should have received a copy of the GNU General Public License
22  along with yat. If not, see <http://www.gnu.org/licenses/>.
23*/
24
25// This is a private file used by yat/utility/Ranking.h
26
27namespace theplu {
28namespace yat {
29namespace utility {
30
31  /// \cond IGNORE_DOXYGEN
32
33  // namespace for internal classes used in class Ranking
34  namespace ranking {
35
36    class NodeBase
37    {
38    public:
39      NodeBase(void);
40      virtual ~NodeBase(void);
41      NodeBase* parent_;
42      NodeBase* left_;
43      NodeBase* right_;
44
45      // return 0 for root, 1 for its children, etc
46      int generation(void) const;
47
48      // return true if head node
49      bool is_head_node(void) const;
50      // return true if having a parent and its left child is this
51      bool is_left_node(void) const;
52      // return true if having a parent and its right child is this
53      bool is_right_node(void) const;
54      // return true if having no parent
55      bool is_root_node(void) const;
56      // return traverse up in the tree following the left branch
57      // until a node has no left branch and we return that leaf node.
58      NodeBase* left_most(void);
59      const NodeBase* left_most(void) const;
60      // same as left_most but follow right branch
61      NodeBase* right_most(void);
62      const NodeBase* right_most(void) const;
63      // Only used to validate that the tree is valid, used in debug
64      // code and assertions.
65      bool validate(void) const;
66      bool recursive_validate(void) const;
67    };
68  } // end of namespace ranking
69
70  /// \endcond
71
72}}} // of namespace utility, yat, and theplu
73#endif
Note: See TracBrowser for help on using the repository browser.