STL Memory Versioning
Public Types | Public Member Functions | List of all members
vs::vs_tree< _Key, _Comp, _Strategy > Class Template Reference

A versioned AVL-tree with deep copy constructor in internal classes. More...

#include <vs_tree.h>

Public Types

typedef Versioned< _vs_tree< _Key, _Comp >, _Strategy > _Versioned
 
typedef _vs_tree< _Key, _Comp >::iterator iterator
 
typedef _vs_tree< _Key, _Comp >::size_type size_type
 

Public Member Functions

 vs_tree (const _Comp &__comp=_Comp())
 Creates a vs_tree with no elements. More...
 
 vs_tree (std::initializer_list< _Key > __l, const _Comp &__comp=_Comp())
 Builds a vs_tree from an initializer_list. More...
 
 vs_tree (const vs_tree &__vs_tree)
 vs_tree copy constructor More...
 
iterator begin () const
 begin constant iterator More...
 
iterator end () const
 end constant iterator More...
 
size_type size () const noexcept
 size of underlying tree More...
 
size_type height () const noexcept
 height of underlying tree More...
 
iterator find (const _Key &__x) const
 find element in tree More...
 
void push (const _Key &__x)
 Attempts to insert an element into the vs_tree. More...
 

Detailed Description

template<typename _Key, typename _Comp = std::less<_Key>, typename _Strategy = vs_tree_strategy<_Key, _Comp>>
class vs::vs_tree< _Key, _Comp, _Strategy >

A versioned AVL-tree with deep copy constructor in internal classes.

Parameters
_KeyType of key objects.
_CompComparison function object type, defaults to less<_Key>.
_StrategyCustom strategy class for different merge behaviour

Definition at line 453 of file vs_tree.h.

Member Typedef Documentation

◆ _Versioned

template<typename _Key , typename _Comp = std::less<_Key>, typename _Strategy = vs_tree_strategy<_Key, _Comp>>
typedef Versioned<_vs_tree<_Key, _Comp>, _Strategy> vs::vs_tree< _Key, _Comp, _Strategy >::_Versioned

Definition at line 462 of file vs_tree.h.

◆ iterator

template<typename _Key , typename _Comp = std::less<_Key>, typename _Strategy = vs_tree_strategy<_Key, _Comp>>
typedef _vs_tree<_Key, _Comp>::iterator vs::vs_tree< _Key, _Comp, _Strategy >::iterator

Definition at line 463 of file vs_tree.h.

◆ size_type

template<typename _Key , typename _Comp = std::less<_Key>, typename _Strategy = vs_tree_strategy<_Key, _Comp>>
typedef _vs_tree<_Key, _Comp>::size_type vs::vs_tree< _Key, _Comp, _Strategy >::size_type

Definition at line 464 of file vs_tree.h.

Constructor & Destructor Documentation

◆ vs_tree() [1/3]

template<typename _Key , typename _Comp = std::less<_Key>, typename _Strategy = vs_tree_strategy<_Key, _Comp>>
vs::vs_tree< _Key, _Comp, _Strategy >::vs_tree ( const _Comp &  __comp = _Comp())
inlineexplicit

Creates a vs_tree with no elements.

Parameters
__compComparator to use.

Definition at line 478 of file vs_tree.h.

479  : _v_t(_vs_tree<_Key, _Comp>()) { }

◆ vs_tree() [2/3]

template<typename _Key , typename _Comp = std::less<_Key>, typename _Strategy = vs_tree_strategy<_Key, _Comp>>
vs::vs_tree< _Key, _Comp, _Strategy >::vs_tree ( std::initializer_list< _Key >  __l,
const _Comp &  __comp = _Comp() 
)
inline

Builds a vs_tree from an initializer_list.

Parameters
__lAn initializer_list.
__compComparator to use.

Copy elements of the list to created vs_tree. Lots of copies in process, but only one version gets added.

Definition at line 489 of file vs_tree.h.

491  : _v_t(_vs_tree<_Key, _Comp>())
492  {
493  _v_t.Set(_v_t.Get(),
494  [&](_vs_tree<_Key, _Comp>& _tree){
495  for (auto& i: __l){
496  _tree.push(i);
497  }
498  return true;
499  });
500  }
const T & Get() const
Get the current value of the object in the current Revision.
Definition: versioned.h:186
bool Set(const T &v, const std::function< bool(T &)> &updater=nullptr)
Set new value of the object.
Definition: versioned.h:205

◆ vs_tree() [3/3]

template<typename _Key , typename _Comp = std::less<_Key>, typename _Strategy = vs_tree_strategy<_Key, _Comp>>
vs::vs_tree< _Key, _Comp, _Strategy >::vs_tree ( const vs_tree< _Key, _Comp, _Strategy > &  __vs_tree)
inline

vs_tree copy constructor

does not inherit versions history

Definition at line 507 of file vs_tree.h.

508  : _v_t(__vs_tree._v_t.Get()) { }

Member Function Documentation

◆ begin()

template<typename _Key , typename _Comp = std::less<_Key>, typename _Strategy = vs_tree_strategy<_Key, _Comp>>
iterator vs::vs_tree< _Key, _Comp, _Strategy >::begin ( ) const
inline

begin constant iterator

Returns an iterator that points to the first element in the vs_tree. Iteration is done in depth-first order.

Definition at line 524 of file vs_tree.h.

525  { return _v_t.Get().begin(); }

◆ end()

template<typename _Key , typename _Comp = std::less<_Key>, typename _Strategy = vs_tree_strategy<_Key, _Comp>>
iterator vs::vs_tree< _Key, _Comp, _Strategy >::end ( ) const
inline

end constant iterator

Returns an iterator that points one past the last element in the vs_tree. Iteration is done in depth-first order.

Definition at line 534 of file vs_tree.h.

535  { return _v_t.Get().end(); }

◆ find()

template<typename _Key , typename _Comp = std::less<_Key>, typename _Strategy = vs_tree_strategy<_Key, _Comp>>
iterator vs::vs_tree< _Key, _Comp, _Strategy >::find ( const _Key &  __x) const
inline

find element in tree

Definition at line 555 of file vs_tree.h.

556  { return _v_t.Get().find(__x); }

◆ height()

template<typename _Key , typename _Comp = std::less<_Key>, typename _Strategy = vs_tree_strategy<_Key, _Comp>>
size_type vs::vs_tree< _Key, _Comp, _Strategy >::height ( ) const
inlinenoexcept

height of underlying tree

Definition at line 548 of file vs_tree.h.

549  { return _v_t.Get().height(); }

◆ push()

template<typename _Key , typename _Comp = std::less<_Key>, typename _Strategy = vs_tree_strategy<_Key, _Comp>>
void vs::vs_tree< _Key, _Comp, _Strategy >::push ( const _Key &  __x)
inline

Attempts to insert an element into the vs_tree.

Parameters
__xElement to be inserted.

Definition at line 567 of file vs_tree.h.

568  {
569  _v_t.Set(_v_t.Get(), [&](_vs_tree<_Key, _Comp>& _tree){_tree.push(__x); return true;});
570  }

◆ size()

template<typename _Key , typename _Comp = std::less<_Key>, typename _Strategy = vs_tree_strategy<_Key, _Comp>>
size_type vs::vs_tree< _Key, _Comp, _Strategy >::size ( ) const
inlinenoexcept

size of underlying tree

Definition at line 541 of file vs_tree.h.

542  { return _v_t.Get().size(); }

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