tlx
SplayTree< Key, Compare, Duplicates, Allocator > Class Template Reference

#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 insert (const Key &k)
 insert key into tree if it does not exist, returns true if inserted. 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...
 
void clear ()
 free all nodes More...
 
bool exists (const Key &k)
 check if key exists More...
 
size_t size () const
 return number of items in tree More...
 
bool empty () const
 return true if tree is empty More...
 
Nodefind (const Key &k)
 find tree node containing key or return smallest key larger than k More...
 
bool check () const
 check the tree order 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

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

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.

Member Typedef Documentation

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 ( Allocator  alloc = Allocator())
inlineexplicit

Definition at line 233 of file splay_tree.hpp.

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

Definition at line 236 of file splay_tree.hpp.

~SplayTree ( )
inline

Definition at line 239 of file splay_tree.hpp.

Member Function Documentation

bool check ( ) const
inline

check the tree order

Definition at line 299 of file splay_tree.hpp.

void clear ( )
inline

free all nodes

Definition at line 273 of file splay_tree.hpp.

void delete_node ( Node n)
inlineprivate

delete node

Definition at line 326 of file splay_tree.hpp.

bool empty ( ) const
inline

return true if tree is empty

Definition at line 289 of file splay_tree.hpp.

bool erase ( const Key &  k)
inline

erase key from tree, return true if it existed.

Definition at line 260 of file splay_tree.hpp.

bool erase ( const Node n)
inline

erase node from tree, return true if it existed.

Definition at line 268 of file splay_tree.hpp.

bool exists ( const Key &  k)
inline

check if key exists

Definition at line 278 of file splay_tree.hpp.

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.

bool insert ( const Key &  k)
inline

insert key into tree if it does not exist, returns true if inserted.

Definition at line 244 of file splay_tree.hpp.

size_t size ( ) const
inline

return number of items in tree

Definition at line 284 of file splay_tree.hpp.

void traverse_preorder ( const Functor &  f) const
inline

traverse the whole tree in preorder (key order)s

Definition at line 305 of file splay_tree.hpp.

Member Data Documentation

Allocator alloc_
private

key allocator

Definition at line 317 of file splay_tree.hpp.

Compare cmp_
private

key comparator

Definition at line 315 of file splay_tree.hpp.

node_alloc_type node_allocator_
private

node allocator

Definition at line 323 of file splay_tree.hpp.

Node* root_
private

root tree node

Definition at line 311 of file splay_tree.hpp.

size_t size_
private

number of items in tree container

Definition at line 313 of file splay_tree.hpp.


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