TPIE

2362a60
tpie::btree_node< S > Class Template Reference

Type that is useful for navigating a btree. More...

#include <tpie/btree/base.h>

Public Types

typedef S state_type
 
typedef S::key_type key_type
 Type of the key of a value. More...
 
typedef S::augment_type augment_type
 Type of the augment of a set of nodes/values. More...
 
typedef S::value_type value_type
 Type of values. More...
 
typedef S::store_type store_type
 

Public Member Functions

bool has_parent () const
 Check if this node has a parent. More...
 
void parent ()
 Move to the parent node. More...
 
void child (size_t i)
 Move to the ith child. More...
 
btree_node get_parent () const
 Return the parent node. More...
 
btree_node get_child (size_t i) const
 Return the ith child node. More...
 
bool is_leaf () const
 Return true if this is a leaf node. More...
 
const augment_typeget_augmentation (size_t i) const
 Return the augmented data of the ith child. More...
 
key_type min_key (size_t i) const
 Return the minimal key of the i'th child. More...
 
const value_typevalue (size_t i) const
 Return the i'th value. More...
 
size_t count () const
 Return the number of children or values. More...
 
size_t index () const
 Return the index of this node in its parent. More...
 

Friends

template<typename , typename >
class bbits::tree_state
 
template<typename , typename >
class bbits::tree
 
template<typename , typename >
class bbits::builder
 
template<typename >
class btree_iterator
 

Detailed Description

template<typename S>
class tpie::btree_node< S >

Type that is useful for navigating a btree.

S is the type of the store used

Definition at line 178 of file base.h.

Member Typedef Documentation

template<typename S >
typedef S::augment_type tpie::btree_node< S >::augment_type

Type of the augment of a set of nodes/values.

Definition at line 50 of file node.h.

template<typename S >
typedef S::key_type tpie::btree_node< S >::key_type

Type of the key of a value.

Definition at line 45 of file node.h.

template<typename S >
typedef S::value_type tpie::btree_node< S >::value_type

Type of values.

Definition at line 55 of file node.h.

Member Function Documentation

template<typename S >
void tpie::btree_node< S >::child ( size_t  i)
inline

Move to the ith child.

Requires !is_leaf() and i < count()

Definition at line 89 of file node.h.

References tpie::btree_node< S >::count(), and tp_assert.

89  {
90  tp_assert(!m_is_leaf, "Is leaf");
91  tp_assert(i < count(), "Invalid i");
92  if (m_path.size() + 1 == m_state->store().height()) {
93  m_is_leaf = true;
94  m_leaf = m_state->store().get_child_leaf(m_path.back(), i);
95  } else
96  m_path.push_back(m_state->store().get_child_internal(m_path.back(), i));
97  }
#define tp_assert(condition, message)
Definition: tpie_assert.h:48
size_t count() const
Return the number of children or values.
Definition: node.h:160
template<typename S >
size_t tpie::btree_node< S >::count ( ) const
inline

Return the number of children or values.

Definition at line 160 of file node.h.

Referenced by tpie::btree_node< S >::child().

160  {
161  if (m_is_leaf)
162  return m_state->store().count(m_leaf);
163  else
164  return m_state->store().count(m_path.back());
165  }
template<typename S >
const augment_type& tpie::btree_node< S >::get_augmentation ( size_t  i) const
inline

Return the augmented data of the ith child.

Requires !is_leaf()

Definition at line 133 of file node.h.

133  {
134  return state_type::user_augment(m_state->store().augment(m_path.back(), i));
135  }
template<typename S >
btree_node tpie::btree_node< S >::get_child ( size_t  i) const
inline

Return the ith child node.

Requires !is_leaf() and i < count()

Definition at line 115 of file node.h.

115  {
116  btree_node n=*this;
117  n.child(i);
118  return n;
119  }
template<typename S >
btree_node tpie::btree_node< S >::get_parent ( ) const
inline

Return the parent node.

Requires hasParent()

Definition at line 104 of file node.h.

104  {
105  btree_node n=*this;
106  n.parent();
107  return n;
108  }
template<typename S >
bool tpie::btree_node< S >::has_parent ( ) const
inline

Check if this node has a parent.

True iff this is not the root

Definition at line 65 of file node.h.

65  {
66  if (m_is_leaf)
67  return !m_path.empty();
68  else
69  return m_path.size() > 1;
70  }
template<typename S >
size_t tpie::btree_node< S >::index ( ) const
inline

Return the index of this node in its parent.

Requires has_parent()

Definition at line 172 of file node.h.

172  {
173  if (m_is_leaf)
174  return m_state->store().index(m_leaf, m_path.back());
175  return m_state->store().index(m_path.back(), m_path[m_path.size()-2]);
176  }
template<typename S >
bool tpie::btree_node< S >::is_leaf ( ) const
inline

Return true if this is a leaf node.

Definition at line 124 of file node.h.

124  {
125  return m_is_leaf;
126  }
template<typename S >
key_type tpie::btree_node< S >::min_key ( size_t  i) const
inline

Return the minimal key of the i'th child.

Definition at line 140 of file node.h.

140  {
141  if (m_is_leaf)
142  return m_state->min_key(m_leaf, i);
143  else
144  return m_state->min_key(m_path.back(), i);
145  }
template<typename S >
void tpie::btree_node< S >::parent ( )
inline

Move to the parent node.

Requires hasParent()

Definition at line 77 of file node.h.

77  {
78  if (m_is_leaf)
79  m_is_leaf = false;
80  else
81  m_path.pop_back();
82  }
template<typename S >
const value_type& tpie::btree_node< S >::value ( size_t  i) const
inline

Return the i'th value.

Requires is_leaf()

Definition at line 152 of file node.h.

References tp_assert.

152  {
153  tp_assert(m_is_leaf, "Not leaf");
154  return m_state->store().get(m_leaf, i);
155  }
#define tp_assert(condition, message)
Definition: tpie_assert.h:48

The documentation for this class was generated from the following files: