GNU g++  v5.2.1
GNU Standard C++
__gnu_pbds::detail::PB_DS_RB_TREE_NAME< Key, Mapped, Cmp_Fn, Node_And_It_Traits, _Alloc > Class Template Reference

Red-Black tree. More...

#include <rb_tree_.hpp>

Inheritance diagram for __gnu_pbds::detail::PB_DS_RB_TREE_NAME< Key, Mapped, Cmp_Fn, Node_And_It_Traits, _Alloc >:
Collaboration diagram for __gnu_pbds::detail::PB_DS_RB_TREE_NAME< Key, Mapped, Cmp_Fn, Node_And_It_Traits, _Alloc >:

Public Types

typedef _Alloc allocator_type
 
typedef Cmp_Fn cmp_fn
 
typedef base_type::const_iterator const_iterator
 
typedef base_type::const_pointer const_pointer
 
typedef base_type::const_reference const_reference
 
typedef base_type::const_reverse_iterator const_reverse_iterator
 
typedef rb_tree_tag container_category
 
typedef _Alloc::difference_type difference_type
 
typedef base_type::iterator iterator
 
typedef base_type::key_const_pointer key_const_pointer
 
typedef base_type::key_const_reference key_const_reference
 
typedef base_type::key_pointer key_pointer
 
typedef base_type::key_reference key_reference
 
typedef base_type::key_type key_type
 
typedef base_type::mapped_const_pointer mapped_const_pointer
 
typedef base_type::mapped_const_reference mapped_const_reference
 
typedef base_type::mapped_pointer mapped_pointer
 
typedef base_type::mapped_reference mapped_reference
 
typedef base_type::mapped_type mapped_type
 
typedef base_type::node_update node_update
 
typedef base_type::const_iterator point_const_iterator
 
typedef base_type::point_iterator point_iterator
 
typedef base_type::pointer pointer
 
typedef base_type::reference reference
 
typedef base_type::reverse_iterator reverse_iterator
 
typedef _Alloc::size_type size_type
 
typedef base_type::value_type value_type
 

Public Member Functions

 PB_DS_RB_TREE_NAME ()
 
 PB_DS_RB_TREE_NAME (const Cmp_Fn &)
 
 PB_DS_RB_TREE_NAME (const Cmp_Fn &, const node_update &)
 
 PB_DS_RB_TREE_NAME (const PB_DS_RB_TREE_NAME< Key, Mapped, Cmp_Fn, Node_And_It_Traits, _Alloc > &)
 
template<typename It >
void copy_from_range (It, It)
 
bool erase (key_const_reference)
 
iterator erase (iterator)
 
reverse_iterator erase (reverse_iterator)
 
template<typename Pred >
size_type erase_if (Pred)
 
std::pair< point_iterator, bool > insert (const_reference)
 
void join (PB_DS_RB_TREE_NAME< Key, Mapped, Cmp_Fn, Node_And_It_Traits, _Alloc > &)
 
mapped_reference operator[] (key_const_reference r_key)
 
void split (key_const_reference, PB_DS_RB_TREE_NAME< Key, Mapped, Cmp_Fn, Node_And_It_Traits, _Alloc > &)
 
void swap (PB_DS_RB_TREE_NAME< Key, Mapped, Cmp_Fn, Node_And_It_Traits, _Alloc > &)
 

Private Types

typedef PB_DS_RB_TREE_BASE_NAME< Key, Mapped, Cmp_Fn, Node_And_It_Traits, _Alloc > base_type
 
typedef base_type::node_pointer node_pointer
 

Private Member Functions

size_type black_height (node_pointer)
 
void erase_node (node_pointer)
 
std::pair< node_pointer, node_pointerfind_join_pos_left (node_pointer, size_type, size_type)
 
std::pair< node_pointer, node_pointerfind_join_pos_right (node_pointer, size_type, size_type)
 
void initialize ()
 
void insert_fixup (node_pointer)
 
void join_imp (node_pointer, node_pointer)
 
void remove_fixup (node_pointer, node_pointer)
 
void remove_node (node_pointer)
 
void split_at_node (node_pointer, PB_DS_RB_TREE_NAME< Key, Mapped, Cmp_Fn, Node_And_It_Traits, _Alloc > &)
 
void split_imp (node_pointer, PB_DS_RB_TREE_NAME< Key, Mapped, Cmp_Fn, Node_And_It_Traits, _Alloc > &)
 
node_pointer split_min ()
 
std::pair< node_pointer, node_pointersplit_min_imp ()
 

Static Private Member Functions

static bool is_effectively_black (const node_pointer)
 

Detailed Description

template<typename Key, typename Mapped, typename Cmp_Fn, typename Node_And_It_Traits, typename _Alloc>
class __gnu_pbds::detail::PB_DS_RB_TREE_NAME< Key, Mapped, Cmp_Fn, Node_And_It_Traits, _Alloc >

Red-Black tree.

This implementation uses an idea from the SGI STL (using a header node which is needed for efficient iteration).

Member Typedef Documentation

template<typename Key , typename Mapped , typename Cmp_Fn , typename Node_And_It_Traits , typename _Alloc >
typedef _Alloc __gnu_pbds::detail::PB_DS_RB_TREE_NAME< Key, Mapped, Cmp_Fn, Node_And_It_Traits, _Alloc >::allocator_type
template<typename Key , typename Mapped , typename Cmp_Fn , typename Node_And_It_Traits , typename _Alloc >
typedef PB_DS_RB_TREE_BASE_NAME<Key, Mapped, Cmp_Fn, Node_And_It_Traits, _Alloc> __gnu_pbds::detail::PB_DS_RB_TREE_NAME< Key, Mapped, Cmp_Fn, Node_And_It_Traits, _Alloc >::base_type
private
template<typename Key , typename Mapped , typename Cmp_Fn , typename Node_And_It_Traits , typename _Alloc >
typedef Cmp_Fn __gnu_pbds::detail::PB_DS_RB_TREE_NAME< Key, Mapped, Cmp_Fn, Node_And_It_Traits, _Alloc >::cmp_fn
template<typename Key , typename Mapped , typename Cmp_Fn , typename Node_And_It_Traits , typename _Alloc >
typedef base_type::const_iterator __gnu_pbds::detail::PB_DS_RB_TREE_NAME< Key, Mapped, Cmp_Fn, Node_And_It_Traits, _Alloc >::const_iterator
template<typename Key , typename Mapped , typename Cmp_Fn , typename Node_And_It_Traits , typename _Alloc >
typedef base_type::const_pointer __gnu_pbds::detail::PB_DS_RB_TREE_NAME< Key, Mapped, Cmp_Fn, Node_And_It_Traits, _Alloc >::const_pointer
template<typename Key , typename Mapped , typename Cmp_Fn , typename Node_And_It_Traits , typename _Alloc >
typedef base_type::const_reference __gnu_pbds::detail::PB_DS_RB_TREE_NAME< Key, Mapped, Cmp_Fn, Node_And_It_Traits, _Alloc >::const_reference
template<typename Key , typename Mapped , typename Cmp_Fn , typename Node_And_It_Traits , typename _Alloc >
typedef base_type::const_reverse_iterator __gnu_pbds::detail::PB_DS_RB_TREE_NAME< Key, Mapped, Cmp_Fn, Node_And_It_Traits, _Alloc >::const_reverse_iterator
template<typename Key , typename Mapped , typename Cmp_Fn , typename Node_And_It_Traits , typename _Alloc >
typedef rb_tree_tag __gnu_pbds::detail::PB_DS_RB_TREE_NAME< Key, Mapped, Cmp_Fn, Node_And_It_Traits, _Alloc >::container_category
template<typename Key , typename Mapped , typename Cmp_Fn , typename Node_And_It_Traits , typename _Alloc >
typedef _Alloc::difference_type __gnu_pbds::detail::PB_DS_RB_TREE_NAME< Key, Mapped, Cmp_Fn, Node_And_It_Traits, _Alloc >::difference_type
template<typename Key , typename Mapped , typename Cmp_Fn , typename Node_And_It_Traits , typename _Alloc >
typedef base_type::iterator __gnu_pbds::detail::PB_DS_RB_TREE_NAME< Key, Mapped, Cmp_Fn, Node_And_It_Traits, _Alloc >::iterator
template<typename Key , typename Mapped , typename Cmp_Fn , typename Node_And_It_Traits , typename _Alloc >
typedef base_type::key_const_pointer __gnu_pbds::detail::PB_DS_RB_TREE_NAME< Key, Mapped, Cmp_Fn, Node_And_It_Traits, _Alloc >::key_const_pointer
template<typename Key , typename Mapped , typename Cmp_Fn , typename Node_And_It_Traits , typename _Alloc >
typedef base_type::key_const_reference __gnu_pbds::detail::PB_DS_RB_TREE_NAME< Key, Mapped, Cmp_Fn, Node_And_It_Traits, _Alloc >::key_const_reference
template<typename Key , typename Mapped , typename Cmp_Fn , typename Node_And_It_Traits , typename _Alloc >
typedef base_type::key_pointer __gnu_pbds::detail::PB_DS_RB_TREE_NAME< Key, Mapped, Cmp_Fn, Node_And_It_Traits, _Alloc >::key_pointer
template<typename Key , typename Mapped , typename Cmp_Fn , typename Node_And_It_Traits , typename _Alloc >
typedef base_type::key_reference __gnu_pbds::detail::PB_DS_RB_TREE_NAME< Key, Mapped, Cmp_Fn, Node_And_It_Traits, _Alloc >::key_reference
template<typename Key , typename Mapped , typename Cmp_Fn , typename Node_And_It_Traits , typename _Alloc >
typedef base_type::key_type __gnu_pbds::detail::PB_DS_RB_TREE_NAME< Key, Mapped, Cmp_Fn, Node_And_It_Traits, _Alloc >::key_type
template<typename Key , typename Mapped , typename Cmp_Fn , typename Node_And_It_Traits , typename _Alloc >
typedef base_type::mapped_const_pointer __gnu_pbds::detail::PB_DS_RB_TREE_NAME< Key, Mapped, Cmp_Fn, Node_And_It_Traits, _Alloc >::mapped_const_pointer
template<typename Key , typename Mapped , typename Cmp_Fn , typename Node_And_It_Traits , typename _Alloc >
typedef base_type::mapped_const_reference __gnu_pbds::detail::PB_DS_RB_TREE_NAME< Key, Mapped, Cmp_Fn, Node_And_It_Traits, _Alloc >::mapped_const_reference
template<typename Key , typename Mapped , typename Cmp_Fn , typename Node_And_It_Traits , typename _Alloc >
typedef base_type::mapped_pointer __gnu_pbds::detail::PB_DS_RB_TREE_NAME< Key, Mapped, Cmp_Fn, Node_And_It_Traits, _Alloc >::mapped_pointer
template<typename Key , typename Mapped , typename Cmp_Fn , typename Node_And_It_Traits , typename _Alloc >
typedef base_type::mapped_reference __gnu_pbds::detail::PB_DS_RB_TREE_NAME< Key, Mapped, Cmp_Fn, Node_And_It_Traits, _Alloc >::mapped_reference
template<typename Key , typename Mapped , typename Cmp_Fn , typename Node_And_It_Traits , typename _Alloc >
typedef base_type::mapped_type __gnu_pbds::detail::PB_DS_RB_TREE_NAME< Key, Mapped, Cmp_Fn, Node_And_It_Traits, _Alloc >::mapped_type
template<typename Key , typename Mapped , typename Cmp_Fn , typename Node_And_It_Traits , typename _Alloc >
typedef base_type::node_pointer __gnu_pbds::detail::PB_DS_RB_TREE_NAME< Key, Mapped, Cmp_Fn, Node_And_It_Traits, _Alloc >::node_pointer
private
template<typename Key , typename Mapped , typename Cmp_Fn , typename Node_And_It_Traits , typename _Alloc >
typedef base_type::node_update __gnu_pbds::detail::PB_DS_RB_TREE_NAME< Key, Mapped, Cmp_Fn, Node_And_It_Traits, _Alloc >::node_update
template<typename Key , typename Mapped , typename Cmp_Fn , typename Node_And_It_Traits , typename _Alloc >
typedef base_type::const_iterator __gnu_pbds::detail::PB_DS_RB_TREE_NAME< Key, Mapped, Cmp_Fn, Node_And_It_Traits, _Alloc >::point_const_iterator
template<typename Key , typename Mapped , typename Cmp_Fn , typename Node_And_It_Traits , typename _Alloc >
typedef base_type::point_iterator __gnu_pbds::detail::PB_DS_RB_TREE_NAME< Key, Mapped, Cmp_Fn, Node_And_It_Traits, _Alloc >::point_iterator
template<typename Key , typename Mapped , typename Cmp_Fn , typename Node_And_It_Traits , typename _Alloc >
typedef base_type::pointer __gnu_pbds::detail::PB_DS_RB_TREE_NAME< Key, Mapped, Cmp_Fn, Node_And_It_Traits, _Alloc >::pointer
template<typename Key , typename Mapped , typename Cmp_Fn , typename Node_And_It_Traits , typename _Alloc >
typedef base_type::reference __gnu_pbds::detail::PB_DS_RB_TREE_NAME< Key, Mapped, Cmp_Fn, Node_And_It_Traits, _Alloc >::reference
template<typename Key , typename Mapped , typename Cmp_Fn , typename Node_And_It_Traits , typename _Alloc >
typedef base_type::reverse_iterator __gnu_pbds::detail::PB_DS_RB_TREE_NAME< Key, Mapped, Cmp_Fn, Node_And_It_Traits, _Alloc >::reverse_iterator
template<typename Key , typename Mapped , typename Cmp_Fn , typename Node_And_It_Traits , typename _Alloc >
typedef _Alloc::size_type __gnu_pbds::detail::PB_DS_RB_TREE_NAME< Key, Mapped, Cmp_Fn, Node_And_It_Traits, _Alloc >::size_type
template<typename Key , typename Mapped , typename Cmp_Fn , typename Node_And_It_Traits , typename _Alloc >
typedef base_type::value_type __gnu_pbds::detail::PB_DS_RB_TREE_NAME< Key, Mapped, Cmp_Fn, Node_And_It_Traits, _Alloc >::value_type

Constructor & Destructor Documentation

template<typename Key , typename Mapped , typename Cmp_Fn , typename Node_And_It_Traits , typename _Alloc >
__gnu_pbds::detail::PB_DS_RB_TREE_NAME< Key, Mapped, Cmp_Fn, Node_And_It_Traits, _Alloc >::PB_DS_RB_TREE_NAME ( )
template<typename Key , typename Mapped , typename Cmp_Fn , typename Node_And_It_Traits , typename _Alloc >
__gnu_pbds::detail::PB_DS_RB_TREE_NAME< Key, Mapped, Cmp_Fn, Node_And_It_Traits, _Alloc >::PB_DS_RB_TREE_NAME ( const Cmp_Fn &  )
template<typename Key , typename Mapped , typename Cmp_Fn , typename Node_And_It_Traits , typename _Alloc >
__gnu_pbds::detail::PB_DS_RB_TREE_NAME< Key, Mapped, Cmp_Fn, Node_And_It_Traits, _Alloc >::PB_DS_RB_TREE_NAME ( const Cmp_Fn &  ,
const node_update  
)
template<typename Key , typename Mapped , typename Cmp_Fn , typename Node_And_It_Traits , typename _Alloc >
__gnu_pbds::detail::PB_DS_RB_TREE_NAME< Key, Mapped, Cmp_Fn, Node_And_It_Traits, _Alloc >::PB_DS_RB_TREE_NAME ( const PB_DS_RB_TREE_NAME< Key, Mapped, Cmp_Fn, Node_And_It_Traits, _Alloc > &  )

Member Function Documentation

template<typename Key , typename Mapped , typename Cmp_Fn , typename Node_And_It_Traits , typename _Alloc >
size_type __gnu_pbds::detail::PB_DS_RB_TREE_NAME< Key, Mapped, Cmp_Fn, Node_And_It_Traits, _Alloc >::black_height ( node_pointer  )
inlineprivate
template<typename Key , typename Mapped , typename Cmp_Fn , typename Node_And_It_Traits , typename _Alloc >
template<typename It >
void __gnu_pbds::detail::PB_DS_RB_TREE_NAME< Key, Mapped, Cmp_Fn, Node_And_It_Traits, _Alloc >::copy_from_range ( It  ,
It   
)
template<typename Key , typename Mapped , typename Cmp_Fn , typename Node_And_It_Traits , typename _Alloc >
bool __gnu_pbds::detail::PB_DS_RB_TREE_NAME< Key, Mapped, Cmp_Fn, Node_And_It_Traits, _Alloc >::erase ( key_const_reference  )
inline
template<typename Key , typename Mapped , typename Cmp_Fn , typename Node_And_It_Traits , typename _Alloc >
iterator __gnu_pbds::detail::PB_DS_RB_TREE_NAME< Key, Mapped, Cmp_Fn, Node_And_It_Traits, _Alloc >::erase ( iterator  )
inline
template<typename Key , typename Mapped , typename Cmp_Fn , typename Node_And_It_Traits , typename _Alloc >
reverse_iterator __gnu_pbds::detail::PB_DS_RB_TREE_NAME< Key, Mapped, Cmp_Fn, Node_And_It_Traits, _Alloc >::erase ( reverse_iterator  )
inline
template<typename Key , typename Mapped , typename Cmp_Fn , typename Node_And_It_Traits , typename _Alloc >
template<typename Pred >
size_type __gnu_pbds::detail::PB_DS_RB_TREE_NAME< Key, Mapped, Cmp_Fn, Node_And_It_Traits, _Alloc >::erase_if ( Pred  )
inline
template<typename Key , typename Mapped , typename Cmp_Fn , typename Node_And_It_Traits , typename _Alloc >
void __gnu_pbds::detail::PB_DS_RB_TREE_NAME< Key, Mapped, Cmp_Fn, Node_And_It_Traits, _Alloc >::erase_node ( node_pointer  )
private
template<typename Key , typename Mapped , typename Cmp_Fn , typename Node_And_It_Traits , typename _Alloc >
std::pair<node_pointer, node_pointer> __gnu_pbds::detail::PB_DS_RB_TREE_NAME< Key, Mapped, Cmp_Fn, Node_And_It_Traits, _Alloc >::find_join_pos_left ( node_pointer  ,
size_type  ,
size_type   
)
private
template<typename Key , typename Mapped , typename Cmp_Fn , typename Node_And_It_Traits , typename _Alloc >
std::pair<node_pointer, node_pointer> __gnu_pbds::detail::PB_DS_RB_TREE_NAME< Key, Mapped, Cmp_Fn, Node_And_It_Traits, _Alloc >::find_join_pos_right ( node_pointer  ,
size_type  ,
size_type   
)
private
template<typename Key , typename Mapped , typename Cmp_Fn , typename Node_And_It_Traits , typename _Alloc >
void __gnu_pbds::detail::PB_DS_RB_TREE_NAME< Key, Mapped, Cmp_Fn, Node_And_It_Traits, _Alloc >::initialize ( )
private
template<typename Key , typename Mapped , typename Cmp_Fn , typename Node_And_It_Traits , typename _Alloc >
std::pair<point_iterator, bool> __gnu_pbds::detail::PB_DS_RB_TREE_NAME< Key, Mapped, Cmp_Fn, Node_And_It_Traits, _Alloc >::insert ( const_reference  )
inline
template<typename Key , typename Mapped , typename Cmp_Fn , typename Node_And_It_Traits , typename _Alloc >
void __gnu_pbds::detail::PB_DS_RB_TREE_NAME< Key, Mapped, Cmp_Fn, Node_And_It_Traits, _Alloc >::insert_fixup ( node_pointer  )
private
template<typename Key , typename Mapped , typename Cmp_Fn , typename Node_And_It_Traits , typename _Alloc >
static bool __gnu_pbds::detail::PB_DS_RB_TREE_NAME< Key, Mapped, Cmp_Fn, Node_And_It_Traits, _Alloc >::is_effectively_black ( const node_pointer  )
inlinestaticprivate
template<typename Key , typename Mapped , typename Cmp_Fn , typename Node_And_It_Traits , typename _Alloc >
void __gnu_pbds::detail::PB_DS_RB_TREE_NAME< Key, Mapped, Cmp_Fn, Node_And_It_Traits, _Alloc >::join ( PB_DS_RB_TREE_NAME< Key, Mapped, Cmp_Fn, Node_And_It_Traits, _Alloc > &  )
template<typename Key , typename Mapped , typename Cmp_Fn , typename Node_And_It_Traits , typename _Alloc >
void __gnu_pbds::detail::PB_DS_RB_TREE_NAME< Key, Mapped, Cmp_Fn, Node_And_It_Traits, _Alloc >::join_imp ( node_pointer  ,
node_pointer   
)
private
template<typename Key , typename Mapped , typename Cmp_Fn , typename Node_And_It_Traits , typename _Alloc >
mapped_reference __gnu_pbds::detail::PB_DS_RB_TREE_NAME< Key, Mapped, Cmp_Fn, Node_And_It_Traits, _Alloc >::operator[] ( key_const_reference  r_key)
inline
template<typename Key , typename Mapped , typename Cmp_Fn , typename Node_And_It_Traits , typename _Alloc >
void __gnu_pbds::detail::PB_DS_RB_TREE_NAME< Key, Mapped, Cmp_Fn, Node_And_It_Traits, _Alloc >::remove_fixup ( node_pointer  ,
node_pointer   
)
private
template<typename Key , typename Mapped , typename Cmp_Fn , typename Node_And_It_Traits , typename _Alloc >
void __gnu_pbds::detail::PB_DS_RB_TREE_NAME< Key, Mapped, Cmp_Fn, Node_And_It_Traits, _Alloc >::remove_node ( node_pointer  )
private
template<typename Key , typename Mapped , typename Cmp_Fn , typename Node_And_It_Traits , typename _Alloc >
void __gnu_pbds::detail::PB_DS_RB_TREE_NAME< Key, Mapped, Cmp_Fn, Node_And_It_Traits, _Alloc >::split ( key_const_reference  ,
PB_DS_RB_TREE_NAME< Key, Mapped, Cmp_Fn, Node_And_It_Traits, _Alloc > &   
)
template<typename Key , typename Mapped , typename Cmp_Fn , typename Node_And_It_Traits , typename _Alloc >
void __gnu_pbds::detail::PB_DS_RB_TREE_NAME< Key, Mapped, Cmp_Fn, Node_And_It_Traits, _Alloc >::split_at_node ( node_pointer  ,
PB_DS_RB_TREE_NAME< Key, Mapped, Cmp_Fn, Node_And_It_Traits, _Alloc > &   
)
private
template<typename Key , typename Mapped , typename Cmp_Fn , typename Node_And_It_Traits , typename _Alloc >
void __gnu_pbds::detail::PB_DS_RB_TREE_NAME< Key, Mapped, Cmp_Fn, Node_And_It_Traits, _Alloc >::split_imp ( node_pointer  ,
PB_DS_RB_TREE_NAME< Key, Mapped, Cmp_Fn, Node_And_It_Traits, _Alloc > &   
)
private
template<typename Key , typename Mapped , typename Cmp_Fn , typename Node_And_It_Traits , typename _Alloc >
node_pointer __gnu_pbds::detail::PB_DS_RB_TREE_NAME< Key, Mapped, Cmp_Fn, Node_And_It_Traits, _Alloc >::split_min ( )
inlineprivate
template<typename Key , typename Mapped , typename Cmp_Fn , typename Node_And_It_Traits , typename _Alloc >
std::pair<node_pointer, node_pointer> __gnu_pbds::detail::PB_DS_RB_TREE_NAME< Key, Mapped, Cmp_Fn, Node_And_It_Traits, _Alloc >::split_min_imp ( )
private
template<typename Key , typename Mapped , typename Cmp_Fn , typename Node_And_It_Traits , typename _Alloc >
void __gnu_pbds::detail::PB_DS_RB_TREE_NAME< Key, Mapped, Cmp_Fn, Node_And_It_Traits, _Alloc >::swap ( PB_DS_RB_TREE_NAME< Key, Mapped, Cmp_Fn, Node_And_It_Traits, _Alloc > &  )

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