// -*- C++ -*-
-// Copyright (C) 2005, 2006, 2009 Free Software Foundation, Inc.
+// Copyright (C) 2005, 2006, 2009, 2011 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// warranty.
/**
- * @file node.hpp
+ * @file rb_tree_map_/node.hpp
* Contains an implementation for rb_tree_.
*/
#ifndef PB_DS_RB_TREE_NODE_HPP
#define PB_DS_RB_TREE_NODE_HPP
-#include <ext/pb_ds/detail/basic_tree_policy/null_node_metadata.hpp>
+#include <ext/pb_ds/detail/branch_policy/null_node_metadata.hpp>
namespace __gnu_pbds
{
namespace detail
{
- template<typename Value_Type, class Metadata, class Allocator>
+ /// Node for Red-Black trees.
+ template<typename Value_Type, class Metadata, typename _Alloc>
struct rb_tree_node_
{
public:
- typedef Value_Type value_type;
- typedef Metadata metadata_type;
+ typedef Value_Type value_type;
+ typedef Metadata metadata_type;
typedef
- typename Allocator::template rebind<
+ typename _Alloc::template rebind<
rb_tree_node_<
Value_Type,
Metadata,
- Allocator> >::other::pointer
+ _Alloc> >::other::pointer
node_pointer;
typedef
- typename Allocator::template rebind<
+ typename _Alloc::template rebind<
metadata_type>::other::reference
metadata_reference;
typedef
- typename Allocator::template rebind<
+ typename _Alloc::template rebind<
metadata_type>::other::const_reference
- const_metadata_reference;
+ metadata_const_reference;
- inline bool
+ bool
special() const
{ return m_red; }
- inline const_metadata_reference
+ metadata_const_reference
get_metadata() const
{ return m_metadata; }
- inline metadata_reference
+ metadata_reference
get_metadata()
{ return m_metadata; }
}
#endif
- node_pointer m_p_left;
- node_pointer m_p_right;
- node_pointer m_p_parent;
- value_type m_value;
- bool m_red;
- metadata_type m_metadata;
+ node_pointer m_p_left;
+ node_pointer m_p_right;
+ node_pointer m_p_parent;
+ value_type m_value;
+ bool m_red;
+ metadata_type m_metadata;
};
- template<typename Value_Type, class Allocator>
- struct rb_tree_node_<Value_Type, null_node_metadata, Allocator>
+ template<typename Value_Type, typename _Alloc>
+ struct rb_tree_node_<Value_Type, null_type, _Alloc>
{
public:
- typedef Value_Type value_type;
- typedef null_node_metadata metadata_type;
+ typedef Value_Type value_type;
+ typedef null_type metadata_type;
typedef
- typename Allocator::template rebind<
+ typename _Alloc::template rebind<
rb_tree_node_<
Value_Type,
- null_node_metadata,
- Allocator> >::other::pointer
+ null_type,
+ _Alloc> >::other::pointer
node_pointer;
- inline bool
+ bool
special() const
{ return m_red; }
{ std::cout << PB_DS_V2F(m_value) <<(m_red? " <r> " : " <b> "); }
#endif
- node_pointer m_p_left;
- node_pointer m_p_right;
- node_pointer m_p_parent;
- value_type m_value;
- bool m_red;
+ node_pointer m_p_left;
+ node_pointer m_p_right;
+ node_pointer m_p_parent;
+ value_type m_value;
+ bool m_red;
};
} // namespace detail
} // namespace __gnu_pbds