CLRX  1
An unofficial OpenCL extensions designed for Radeon GPUs
Classes | Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Attributes | List of all members
CLRX::DTree< K, T, Comp, KeyOfVal, AT > Class Template Reference

main D-Tree container of the unique ordered elements (D-Tree is kind of the B-Tree) More...

#include <DTree.h>

Inheritance diagram for CLRX::DTree< K, T, Comp, KeyOfVal, AT >:

Classes

struct  ConstIter
 iterator that allow only to read element More...
 
struct  Iter
 iterator which allow to modify underlying element More...
 
struct  IterBase
 main iterator class More...
 
struct  Node0
 
struct  Node1
 Node1 - main node that holds Node0's or Node1's. More...
 
struct  NodeBase
 
struct  NodeV
 

Public Types

enum  : cxbyte { NODE0 = 0, NODE1, NODE2, NODEV }
 node type More...
 
typedef ConstIter const_iterator
 
typedef Iter iterator
 
typedef T value_type
 
typedef K key_type
 

Public Member Functions

 DTree (const Comp &comp=Comp(), const KeyOfVal &kofval=KeyOfVal())
 default constructor
 
template<typename Iter >
 DTree (Iter first, Iter last, const Comp &comp=Comp(), const KeyOfVal &kofval=KeyOfVal())
 constructor with range assignment
 
 DTree (std::initializer_list< value_type > init, const Comp &comp=Comp(), const KeyOfVal &kofval=KeyOfVal())
 constructor with initializer list
 
 DTree (const DTree &dt)
 copy construcror
 
 DTree (DTree &&dt) noexcept
 move constructor
 
 ~DTree ()
 destructor
 
DTreeoperator= (const DTree &dt)
 copy assignment
 
DTreeoperator= (DTree &&dt) noexcept
 move assignment
 
DTreeoperator= (std::initializer_list< value_type > init)
 assignment of initilizer list
 
bool empty () const
 return true if empty
 
size_t size () const
 return size
 
void clear ()
 clear (remove all elements)
 
iterator find (const key_type &key)
 find element or return end iterator
 
const_iterator find (const key_type &key) const
 find element or return end iterator
 
iterator begin ()
 return iterator to first element
 
const_iterator cbegin () const
 return iterator to first element
 
const_iterator begin () const
 return iterator to first element
 
iterator end ()
 return iterator after last element
 
const_iterator end () const
 return iterator after last element
 
const_iterator cend () const
 return iterator after last element
 
iterator lower_bound (const key_type &key)
 first element that not less than key
 
const_iterator lower_bound (const key_type &key) const
 first element that not less than key
 
iterator upper_bound (const key_type &key)
 first element that greater than key
 
const_iterator upper_bound (const key_type &key) const
 first element that greater than key
 
std::pair< iterator, bool > insert (const value_type &value)
 insert new element
 
void insert (std::initializer_list< value_type > ilist)
 insert new elements from initializer list
 
template<typename Iter >
void insert (Iter first, Iter last)
 
iterator erase (const_iterator it)
 remove element in postion pointed by iterator
 
size_t erase (const key_type &key)
 remove element by key
 
void replace (iterator iter, const value_type &value)
 replace element with checking range
 
bool operator== (const DTree &dt) const
 lexicograhical equal to
 
bool operator!= (const DTree &dt) const
 lexicograhical not equal
 
bool operator< (const DTree &dt) const
 lexicograhical less
 
bool operator<= (const DTree &dt) const
 lexicograhical less or equal
 
bool operator> (const DTree &dt) const
 lexicograhical greater
 
bool operator>= (const DTree &dt) const
 lexicograhical greater or equal
 

Static Public Member Functions

static size_t maxTotalSize (cxuint level)
 
static size_t normalTotalSize (cxuint level)
 
static size_t minTotalSize (cxuint level)
 

Static Public Attributes

static const cxuint maxNode1Size = 8
 
static const cxuint maxNode1Shift = 3
 
static const cxuint normalNode1Shift = 2
 
static const cxuint maxNode1Depth = (sizeof(size_t)*8)>>1
 
static const cxuint maxNode0Capacity = 63
 
static const cxuint normalNode0Capacity = maxNode0Capacity>>1
 
static const cxuint minNode0Capacity = 20
 
static const cxuint freePlacesShift = 1
 
static const cxuint minFreePlacesShift = 3
 
static const cxuint maxNode0Size
 
static const cxuint normalNode0Size
 
static const cxuint minNode0Size = maxNode0Size / 3
 
static const int parentEntrySize = sizeof(void*) <= 8 ? 8 : sizeof(void*)
 
static const int parentEntryIndex = -int(parentEntrySize / sizeof(void*))
 
static const size_t MaxNode01Size
 
static const size_t NodeVElemsNum
 

Protected Attributes

union {
   Node0   n0
 
   Node1   n1
 
   NodeV   nv
 
}; 
 

Detailed Description

template<typename K, typename T = K, typename Comp = std::less<K>, typename KeyOfVal = Identity<K>, typename AT = T>
class CLRX::DTree< K, T, Comp, KeyOfVal, AT >

main D-Tree container of the unique ordered elements (D-Tree is kind of the B-Tree)

The DTree is container very similar to the B+Tree (B-Tree that holds values in leafs). This container holds unique values in sorted order (from smallest to greatest). Arrays of values is held in Node0 nodes which can hold 18-56 elements. Array of values holds empty spaces to improve insertion (shorter moving of the elements). Second type of Node is Node1 that holds Node0's or Node1's. It can hold 2-8 children. DTree have static depth for all leafs (from every leaf is this same step number to root).

About invalidation: every insertion or removal can invalidate pointers, references and iterators to over 200 neighbors of the inserted/removed element. Best way is assumption any insert/erase can invalidate any reference, pointer or iterator.

Member Enumeration Documentation

template<typename K, typename T = K, typename Comp = std::less<K>, typename KeyOfVal = Identity<K>, typename AT = T>
anonymous enum : cxbyte

node type

Enumerator
NODE0 

Node0.

NODE1 

Node1 that holds Node0's.

NODE2 

Node1 that holds Node1's.

NODEV 

NodeV - holds short array with elements its space.

Member Data Documentation

template<typename K, typename T = K, typename Comp = std::less<K>, typename KeyOfVal = Identity<K>, typename AT = T>
const cxuint CLRX::DTree< K, T, Comp, KeyOfVal, AT >::maxNode0Size
static
Initial value:
= ((maxNode0Capacity*1000 /
((1<<minFreePlacesShift)+1))*(1<<minFreePlacesShift)) / 1000
template<typename K, typename T = K, typename Comp = std::less<K>, typename KeyOfVal = Identity<K>, typename AT = T>
const cxuint CLRX::DTree< K, T, Comp, KeyOfVal, AT >::normalNode0Size
static
Initial value:
= ((normalNode0Capacity*1000 /
((1<<minFreePlacesShift)+1))*(1<<minFreePlacesShift)) / 1000
template<typename K, typename T = K, typename Comp = std::less<K>, typename KeyOfVal = Identity<K>, typename AT = T>
const size_t CLRX::DTree< K, T, Comp, KeyOfVal, AT >::MaxNode01Size
static
Initial value:
= sizeof(Node0) < sizeof(Node1) ?
sizeof(Node1) : sizeof(Node0)
template<typename K, typename T = K, typename Comp = std::less<K>, typename KeyOfVal = Identity<K>, typename AT = T>
const size_t CLRX::DTree< K, T, Comp, KeyOfVal, AT >::NodeVElemsNum
static
Initial value:
= (MaxNode01Size -
(2 < alignof(T) ? alignof(T) : 2)) / sizeof(T)

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