9 #ifndef CPPCOMMON_CONTAINERS_BINTREE_AVL_H
10 #define CPPCOMMON_CONTAINERS_BINTREE_AVL_H
98 template <
typename T,
typename TCompare = std::less<T>>
132 template <
class InputIterator>
133 BinTreeAVL(InputIterator first, InputIterator last,
const TCompare&
compare = TCompare()) noexcept;
142 explicit operator
bool() const noexcept {
return !
empty(); }
145 bool empty() const noexcept {
return _root ==
nullptr; }
148 size_t size() const noexcept {
return _size; }
151 T*
root() noexcept {
return _root; }
152 const T*
root() const noexcept {
return _root; }
155 const T*
lowest() const noexcept;
158 const T*
highest() const noexcept;
161 bool compare(const T& item1, const T& item2) const noexcept {
return _compare(item1, item2); }
211 T*
erase(const T& item) noexcept;
220 void clear() noexcept;
224 template <typename U, typename UCompare>
232 const T* InternalLowest() const noexcept;
233 const T* InternalHighest() const noexcept;
234 const T* InternalFind(const T& item) const noexcept;
235 const T* InternalLowerBound(const T& item) const noexcept;
236 const T* InternalUpperBound(const T& item) const noexcept;
238 static
void RotateLeft(T* node);
239 static
void RotateRight(T* node);
240 static
void RotateLeftLeft(T* node);
241 static
void RotateRightRight(T* node);
242 static
void Unlink(T* node);
243 static
void Swap(T*& node1, T*& node2);
248 #include "bintree_avl.inl"
Intrusive non balanced binary tree container definition.
Intrusive balanced AVL binary tree container.
ptrdiff_t difference_type
T * lowest() noexcept
Get the lowest binary tree item.
BinTreeConstReverseIterator< BinTreeAVL< T, TCompare >, T > const_reverse_iterator
T * root() noexcept
Get the root binary tree item.
BinTreeIterator< BinTreeAVL< T, TCompare >, T > iterator
T * erase(const T &item) noexcept
Erase the given item from the binary tree.
const T * root() const noexcept
void clear() noexcept
Clear the binary tree.
const_reverse_iterator crbegin() const noexcept
BinTreeConstIterator< BinTreeAVL< T, TCompare >, T > const_iterator
reverse_iterator rend() noexcept
Get the reverse end binary tree iterator.
bool empty() const noexcept
Is the binary tree empty?
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 crend() const noexcept
const_iterator cend() const noexcept
size_t size() const noexcept
Get the binary tree size.
void swap(BinTreeAVL &bintree) noexcept
Swap two instances.
reverse_iterator rbegin() noexcept
Get the reverse begin binary tree iterator.
BinTreeReverseIterator< BinTreeAVL< T, TCompare >, T > reverse_iterator
const value_type * const_pointer
std::pair< iterator, bool > insert(T &item) noexcept
Insert a new item into the binary tree.
iterator end() noexcept
Get the end binary tree iterator.
T * highest() noexcept
Get the highest binary tree item.
bool compare(const T &item1, const T &item2) const noexcept
Compare two items: if the first item is less than the second one?
const_iterator cbegin() const noexcept
BinTreeAVL(const TCompare &compare=TCompare()) noexcept
iterator find(const T &item) noexcept
Find the iterator which points to the first equal item in the binary tree or return end iterator.
const value_type & const_reference
iterator begin() noexcept
Get the begin binary tree 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 ...
Intrusive binary tree constant iterator.
Intrusive binary tree constant reverse iterator.
Intrusive binary tree iterator.
Intrusive binary tree reverse iterator.
C++ Common project definitions.
signed char balance
Balance level (-1, 0, 1)
T * left
Pointer to the left child binary tree node.
T * right
Pointer to the right child binary tree node.
T * parent
Pointer to the parent binary tree node.