9 #ifndef CPPCOMMON_CONTAINERS_BINTREE_SPLAY_H
10 #define CPPCOMMON_CONTAINERS_BINTREE_SPLAY_H
196 template <
typename T,
typename TCompare = std::less<T>>
229 template <
class InputIterator>
230 BinTreeSplay(InputIterator first, InputIterator last,
const TCompare&
compare = TCompare()) noexcept;
239 explicit operator
bool() const noexcept {
return !
empty(); }
242 bool empty() const noexcept {
return _root ==
nullptr; }
245 size_t size() const noexcept {
return _size; }
248 T*
root() noexcept {
return _root; }
249 const T*
root() const noexcept {
return _root; }
252 const T*
lowest() const noexcept;
255 const T*
highest() const noexcept;
258 bool compare(const T& item1, const T& item2) const noexcept {
return _compare(item1, item2); }
308 T*
erase(const T& item) noexcept;
317 void clear() noexcept;
321 template <typename U, typename UCompare>
329 const T* InternalLowest() const noexcept;
330 const T* InternalHighest() const noexcept;
331 const T* InternalFind(const T& item) const noexcept;
332 const T* InternalLowerBound(const T& item) const noexcept;
333 const T* InternalUpperBound(const T& item) const noexcept;
335 void Splay(T* x) const;
336 void Zig(T* x) const;
337 void ZigZig(T* x) const;
338 void ZigZag(T* x) const;
343 #include "bintree_splay.inl"
Intrusive non balanced binary tree container definition.
Intrusive binary tree constant iterator.
Intrusive binary tree constant reverse iterator.
Intrusive binary tree iterator.
Intrusive binary tree reverse iterator.
Intrusive balanced Splay binary tree container.
reverse_iterator rend() noexcept
Get the reverse end binary tree iterator.
const T * root() const noexcept
BinTreeSplay(const TCompare &compare=TCompare()) noexcept
const_iterator cbegin() const noexcept
iterator end() noexcept
Get the end binary tree iterator.
const value_type * const_pointer
size_t size() const noexcept
Get the binary tree size.
bool empty() const noexcept
Is the binary tree empty?
BinTreeConstReverseIterator< BinTreeSplay< T, TCompare >, T > const_reverse_iterator
iterator upper_bound(const T &item) noexcept
Find the iterator which points to the first item that greater than the given item in the binary tree ...
iterator lower_bound(const T &item) noexcept
Find the iterator which points to the first item that not less than the given item in the binary tree...
const_reverse_iterator crbegin() const noexcept
void clear() noexcept
Clear the binary tree.
T * highest() noexcept
Get the highest binary tree item.
T * root() noexcept
Get the root binary tree item.
ptrdiff_t difference_type
iterator find(const T &item) noexcept
Find the iterator which points to the first equal item in the binary tree or return end iterator.
BinTreeConstIterator< BinTreeSplay< T, TCompare >, T > const_iterator
const_iterator cend() const noexcept
std::pair< iterator, bool > insert(T &item) noexcept
Insert a new item into the binary tree.
BinTreeReverseIterator< BinTreeSplay< T, TCompare >, T > reverse_iterator
reverse_iterator rbegin() noexcept
Get the reverse begin binary tree iterator.
T * lowest() noexcept
Get the lowest binary tree item.
iterator begin() noexcept
Get the begin binary tree iterator.
const_reverse_iterator crend() const noexcept
T * erase(const T &item) noexcept
Erase the given item from the binary tree.
const value_type & const_reference
void swap(BinTreeSplay &bintree) noexcept
Swap two instances.
bool compare(const T &item1, const T &item2) const noexcept
Compare two items: if the first item is less than the second one?
BinTreeIterator< BinTreeSplay< T, TCompare >, T > iterator
C++ Common project definitions.
T * parent
Pointer to the parent binary tree node.
T * right
Pointer to the right child binary tree node.
T * left
Pointer to the left child binary tree node.