map is bst
This commit is contained in:
50
headers/map_node.hpp
Normal file
50
headers/map_node.hpp
Normal file
@@ -0,0 +1,50 @@
|
||||
|
||||
#ifndef MAP_NODE_HPP
|
||||
# define MAP_NODE_HPP
|
||||
|
||||
# include <cstddef> // NULL
|
||||
|
||||
namespace ft {
|
||||
|
||||
template < typename ValueType >
|
||||
struct node
|
||||
{
|
||||
ValueType value;
|
||||
node *up;
|
||||
node *left;
|
||||
node *right;
|
||||
short height;
|
||||
|
||||
node(const ValueType& val) : value(val), up(NULL), left(NULL), right(NULL), height(1) {}
|
||||
|
||||
node* min()
|
||||
{
|
||||
node* n = this;
|
||||
|
||||
while (n->left)
|
||||
n = n->left;
|
||||
return n;
|
||||
}
|
||||
|
||||
node* max()
|
||||
{
|
||||
node* n = this;
|
||||
|
||||
while (n->right)
|
||||
n = n->right;
|
||||
return n;
|
||||
}
|
||||
};
|
||||
|
||||
template < typename ValueType >
|
||||
struct node_sentinel
|
||||
{
|
||||
node<ValueType> *child;
|
||||
|
||||
node_sentinel() : child(NULL) {}
|
||||
};
|
||||
|
||||
} // namespace ft
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user