Thrill  0.1
SplayTree< Key, Compare, Duplicates, Allocator > Class Template Reference

Detailed Description

template<typename Key, typename Compare = std::less<Key>, bool Duplicates = false, typename Allocator = std::allocator<Key>>
class tlx::SplayTree< Key, Compare, Duplicates, Allocator >

Definition at line 223 of file splay_tree.hpp.

+ Collaboration diagram for SplayTree< Key, Compare, Duplicates, Allocator >:

#include <splay_tree.hpp>

Classes

struct  Node
 splay tree node, also seen as public iterator More...
 

Public Member Functions

 SplayTree (Allocator alloc=Allocator())
 
 SplayTree (Compare cmp, Allocator alloc=Allocator())
 
 ~SplayTree ()
 
bool check () const
 check the tree order More...
 
void clear ()
 free all nodes More...
 
bool empty () const
 return true if tree is empty More...
 
bool erase (const Key &k)
 erase key from tree, return true if it existed. More...
 
bool erase (const Node *n)
 erase node from tree, return true if it existed. More...
 
bool exists (const Key &k)
 check if key exists More...
 
Nodefind (const Key &k)
 find tree node containing key or return smallest key larger than k More...
 
bool insert (const Key &k)
 insert key into tree if it does not exist, returns true if inserted. More...
 
size_t size () const
 return number of items in tree More...
 
template<typename Functor >
void traverse_preorder (const Functor &f) const
 traverse the whole tree in preorder (key order)s More...
 

Private Types

typedef Allocator::template rebind< Node >::other node_alloc_type
 node allocator More...
 

Private Member Functions

void delete_node (Node *n)
 delete node More...
 

Private Attributes

Allocator alloc_
 key allocator More...
 
Compare cmp_
 key comparator More...
 
node_alloc_type node_allocator_
 node allocator More...
 
Noderoot_ = nullptr
 root tree node More...
 
size_t size_ = 0
 number of items in tree container More...
 

Member Typedef Documentation

◆ node_alloc_type

typedef Allocator::template rebind<Node>::other node_alloc_type
private

node allocator

Definition at line 320 of file splay_tree.hpp.

Constructor & Destructor Documentation

◆ SplayTree() [1/2]

SplayTree ( Allocator  alloc = Allocator())
inlineexplicit

Definition at line 233 of file splay_tree.hpp.

◆ SplayTree() [2/2]

SplayTree ( Compare  cmp,
Allocator  alloc = Allocator() 
)
inlineexplicit

Definition at line 236 of file splay_tree.hpp.

◆ ~SplayTree()

~SplayTree ( )
inline

Member Function Documentation

◆ check()

bool check ( ) const
inline

◆ clear()

◆ delete_node()

void delete_node ( Node n)
inlineprivate

◆ empty()

bool empty ( ) const
inline

return true if tree is empty

Definition at line 289 of file splay_tree.hpp.

References SplayTree< Key, Compare, Duplicates, Allocator >::size_.

◆ erase() [1/2]

◆ erase() [2/2]

bool erase ( const Node n)
inline

erase node from tree, return true if it existed.

Definition at line 268 of file splay_tree.hpp.

References SplayTree< Key, Compare, Duplicates, Allocator >::erase(), and SplayTree< Key, Compare, Duplicates, Allocator >::Node::key.

◆ exists()

◆ find()

Node* find ( const Key &  k)
inline

find tree node containing key or return smallest key larger than k

Definition at line 294 of file splay_tree.hpp.

References SplayTree< Key, Compare, Duplicates, Allocator >::cmp_, SplayTree< Key, Compare, Duplicates, Allocator >::root_, and tlx::splay().

◆ insert()

◆ size()

size_t size ( ) const
inline

return number of items in tree

Definition at line 284 of file splay_tree.hpp.

References SplayTree< Key, Compare, Duplicates, Allocator >::size_.

◆ traverse_preorder()

void traverse_preorder ( const Functor &  f) const
inline

Member Data Documentation

◆ alloc_

Allocator alloc_
private

key allocator

Definition at line 317 of file splay_tree.hpp.

◆ cmp_

◆ node_allocator_

node_alloc_type node_allocator_
private

node allocator

Definition at line 323 of file splay_tree.hpp.

Referenced by SplayTree< Key, Compare, Duplicates, Allocator >::insert().

◆ root_

◆ size_


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