16#include <l4/cxx/std_alloc> 
   17#include <l4/cxx/std_ops> 
   18#include <l4/cxx/type_traits> 
   33template< 
typename Node, 
typename Key, 
typename Node_op >
 
   34class Avl_set_iter : 
public __Bst_iter_b<Node, Node_op>
 
   38  typedef __Bst_iter_b<Node, Node_op> Base;
 
   41  typedef typename Type_traits<Key>::Non_const_type Non_const_key;
 
   44  typedef Avl_set_iter<Node, Non_const_key, Node_op> Non_const_iter;
 
   52  Avl_set_iter() = 
default;
 
   58  Avl_set_iter(Node 
const *t) : Base(t) {}
 
   64  Avl_set_iter(Base 
const &o) : Base(o) {}
 
   67  Avl_set_iter(Non_const_iter 
const &o)
 
   71  Avl_set_iter &operator = (Non_const_iter 
const &o)
 
   72  { Base::operator = (o); 
return *
this; }
 
   78  Key &operator * ()
 const { 
return const_cast<Node*
>(_n)->item; }
 
   83  Key *operator -> ()
 const { 
return &
const_cast<Node*
>(_n)->item; }
 
   87  Avl_set_iter &operator ++ () { inc(); 
return *
this; }
 
   91  Avl_set_iter operator ++ (
int)
 
   92  { Avl_set_iter tmp = *
this; inc(); 
return tmp; }
 
   97template<
typename KEY_TYPE>
 
  100  typedef KEY_TYPE Key_type;
 
  101  template<
typename NODE>
 
  102  static Key_type 
const &key_of(NODE 
const *n)
 
 
  119template< 
typename ITEM_TYPE, 
class COMPARE,
 
  120          template<
typename A> 
class ALLOC,
 
  124  friend struct ::Avl_set_tester;
 
  163    template<
typename ...ARGS>
 
  164    _Node(ARGS &&...args) : 
Avl_tree_node(), item(cxx::forward<ARGS>(args)...)
 
  176    friend class Base_avl_set<ITEM_TYPE, COMPARE, ALLOC, GET_KEY>;
 
  178    explicit Node(_Node 
const *n) : _n(n) {}
 
  204    operator Item_type const * () { 
return _n ? &_n->item : 0; }
 
 
  222  typedef typename Type_traits<Item_type>::Param_type Item_param_type;
 
  225  typedef Avl_set_iter<_Node, Item_type, Fwd> 
Iterator;
 
  244  : _tree(), _alloc(alloc)
 
 
  284  template<
typename... Args>
 
  297    _Node *n = _tree.remove(item);
 
 
  325  { 
return Node(_tree.find_node(item)); }
 
 
  336  { 
return Node(_tree.lower_bound_node(key)); }
 
 
  386  { 
return _tree.
find(item); }
 
  389  bool rec_dump(
bool print)
 
  391    return _tree.rec_dump(print);
 
 
  401template< 
typename Item, 
class Compare, 
template<
typename A> 
class Alloc, 
typename KEY_TYPE>
 
  403  : _tree(), _alloc(o._alloc)
 
 
  410template< 
typename Item, 
class Compare, 
template< 
typename A > 
class Alloc, 
typename KEY_TYPE>
 
  414  _Node *n = _alloc.alloc();
 
  418  new (n, 
Nothrow()) _Node(item);
 
 
  430template< 
typename Item, 
class Compare, 
template< 
typename A > 
class Alloc, 
typename KEY_TYPE>
 
  431template<
typename... Args>
 
  433Base_avl_set<Item,Compare,Alloc,KEY_TYPE>::emplace(Args&&... args)
 
  435  _Node *n = _alloc.alloc();
 
  437    return cxx::pair(end(), -E_nomem);
 
  439  new (n, 
Nothrow()) _Node(cxx::forward<Args>(args)...);
 
  447  return cxx::pair(Iterator(
typename Tree::Iterator(err.
first, err.
first)), err.
second ? 0 : -E_exist);
 
  463template< 
typename ITEM_TYPE, 
class COMPARE = Lt_functor<ITEM_TYPE>,
 
  467                            Bits::Avl_set_get_key<ITEM_TYPE> >
 
  476  Avl_set(Node_allocator 
const &alloc)
 
 
Avl_tree_node()=default
Create an uninitialized node, this is what you should do.
 
Pair< Node *, bool > insert(Node *new_node)
Insert a new node into this AVL tree.
 
bool valid() const
Validity check.
 
Item_type const * operator->()
Dereferenced member access.
 
Node()
Default construction for NIL pointer.
 
Item_type const & operator*()
Dereference the pointer.
 
Internal: AVL set with internally managed nodes.
 
Avl_set_iter< _Node, Item_type, Fwd > Iterator
 
Node find_node(Key_type const &item) const
Lookup a node equal to item.
 
Avl_set_iter< _Node, Item_type, Rev > Rev_iterator
 
Const_rev_iterator rbegin() const
Get the constant backward iterator for the last element in the set.
 
Iterator end()
Get the end marker for the mutable forward iterator.
 
Rev_iterator rbegin()
Get the mutable backward iterator for the last element of the set.
 
Bits::Avl_map_get_key< KEY_TYPE >::Key_type Key_type
 
Local_item_type Item_type
 
int remove(Key_type const &item)
Remove an item from the set.
 
Base_avl_set(Node_allocator const &alloc=Node_allocator())
Create a AVL-tree based set.
 
Const_iterator end() const
Get the end marker for the constant forward iterator.
 
Const_rev_iterator rend() const
Get the end marker for the constant backward iterator.
 
Const_iterator begin() const
Get the constant forward iterator for the first element in the set.
 
ALLOC< _Node > Node_allocator
 
Rev_iterator rend()
Get the end marker for the mutable backward iterator.
 
Iterator begin()
Get the mutable forward iterator for the first element of the set.
 
Avl_set_iter< _Node, Const_item_type, Rev > Const_rev_iterator
 
Bits::Avl_map_get_key< KEY_TYPE > Get_key
 
cxx::Pair< Iterator, int > insert(Item_type const &item)
Insert an item into the set.
 
Type_traits< Item_type >::Const_type Const_item_type
 
int erase(Key_type const &item)
Erase the item with the given key.
 
Base_avl_set(Base_avl_set const &o)
Create a copy of an AVL-tree based set.
 
Avl_set_iter< _Node, Const_item_type, Fwd > Const_iterator
 
Node lower_bound_node(Key_type const &key) const
Find the first node greater or equal to key.
 
Node * lower_bound_node(Key_param_type key) const
Find the first node with a key not less than the given key.
 
Rev Rev_iter_ops
Helper for building reverse iterators for different wrapper classes.
 
Const_iterator find(Key_param_type key) const
find the node with the given key.
 
void remove_all(FUNC &&callback)
Clear the tree.
 
Fwd Fwd_iter_ops
Helper for building forward iterators for different wrapper classes.
 
Standard allocator based on operator new () .
 
Helper type to distinguish the  operator new  version that does not throw exceptions.
 
Internal helpers for the cxx package.
 
Internal, key-getter for Avl_set nodes.
 
Second second
Second value.