CTR Pia  4.11.3
Game Communication Engine
common_TreeMapBase.h
1 /*---------------------------------------------------------------------------*
2  Project: Pia
3  File: common_TreeMapBase.h
4 
5  Copyright Nintendo. All rights reserved.
6 
7  These coded instructions, statements, and computer programs contain
8  proprietary information of Nintendo of America Inc. and/or Nintendo
9  Company Ltd., and are protected by Federal copyright law. They may
10  not be disclosed to third parties or copied or duplicated in any form,
11  in whole or in part, without the prior written consent of Nintendo.
12  *---------------------------------------------------------------------------*/
13 
14 
15 #pragma once
16 
17 #include <pia/common/common_definitions.h>
18 #include <pia/common/common_TreeMapNodeBase.h>
19 
20 namespace nn
21 {
22 namespace pia
23 {
24 namespace common
25 {
26 
27 /*!
28 @cond PRIVATE
29 @brief This is the default class for treemaps.
30 */
31 class TreeMapBase : public common::RootObject
32 {
33  typedef TreeMapNodeBase Node;
34 
35 protected:
36  TreeMapBase()
37  : m_pRoot(NULL)
38  {
39  }
40 
41 
42 public:
43 /*!
44 @brief Determines whether the object is empty.
45 @return Returns <tt>true</tt> if the object is empty.
46 */
47  bool IsEmpty() const
48  {
49  return m_pRoot == NULL;
50  }
51 
52 
53 /*!
54 @brief Counts the number of elements.
55 @return Returns the number of elements.
56 */
57  u32 Count() const;
58 
59 
60 protected:
61  bool IsIncludeNodeBase(const Node* cpNode) const;
62 
63  void ClearNodeBase();
64 
65  Node* FrontNodeBase() const;
66  Node* BackNodeBase() const;
67 
68  void InsertNodeRoot(Node* pNode);
69  void InsertNodeLeft(Node* pNode, Node* pUp);
70  void InsertNodeRight(Node* pNode, Node* pUp);
71  void ReplaceNode(Node* pNode, Node* pOld);
72 
73  void EraseNodeBase(Node* pNode);
74 
75  Node* RotateRight(Node* pNode);
76  Node* RotateLeft(Node* pNode);
77 
78 protected:
79  Node* GetRootBase() const
80  {
81  return m_pRoot;
82  }
83 
84 private:
85  // Copying is prohibited.
86  TreeMapBase(const TreeMapBase& rhs);
87  TreeMapBase& operator=(const TreeMapBase& rhs);
88 
89  u32 CountImpl(const Node* cpNode) const;
90 
91  void ClearNodeBaseImpl(Node* pNode);
92 
93  void UpdateBalanceInsert(Node* pNode);
94 
95 private:
96  Node* m_pRoot;
97 };
98 //! @endcond
99 }
100 }
101 } // end of namespace nn::pia::common
Definition: assert.h:115