9 #ifndef CPPCOMMON_CONTAINERS_BINTREE_RB_H
10 #define CPPCOMMON_CONTAINERS_BINTREE_RB_H
200 template <
typename T,
typename TCompare = std::less<T>>
234 template <
class InputIterator>
235 BinTreeRB(InputIterator first, InputIterator last,
const TCompare&
compare = TCompare()) noexcept;
244 explicit operator
bool() const noexcept {
return !
empty(); }
247 bool empty() const noexcept {
return _root ==
nullptr; }
250 size_t size() const noexcept {
return _size; }
253 T*
root() noexcept {
return _root; }
254 const T*
root() const noexcept {
return _root; }
257 const T*
lowest() const noexcept;
260 const T*
highest() const noexcept;
263 bool compare(const T& item1, const T& item2) const noexcept {
return _compare(item1, item2); }
313 T*
erase(const T& item) noexcept;
322 void clear() noexcept;
326 template <typename U, typename UCompare>
334 const T* InternalLowest() const noexcept;
335 const T* InternalHighest() const noexcept;
336 const T* InternalFind(const T& item) const noexcept;
337 const T* InternalLowerBound(const T& item) const noexcept;
338 const T* InternalUpperBound(const T& item) const noexcept;
340 void RotateLeft(T* node);
341 void RotateRight(T* node);
342 void Unlink(T* node, T* parent);
343 static
void Swap(T*& node1, T*& node2);
348 #include "bintree_rb.inl"
Intrusive non balanced binary tree container definition.
Intrusive binary tree constant iterator.
Intrusive binary tree constant reverse iterator.
Intrusive binary tree iterator.
Intrusive balanced Red-Black binary tree container.
BinTreeIterator< BinTreeRB< T, TCompare >, T > iterator
BinTreeReverseIterator< BinTreeRB< T, TCompare >, T > reverse_iterator
bool compare(const T &item1, const T &item2) const noexcept
Compare two items: if the first item is less than the second one?
T * highest() noexcept
Get the highest binary tree item.
size_t size() const noexcept
Get the binary tree size.
const value_type * const_pointer
BinTreeConstReverseIterator< BinTreeRB< T, TCompare >, T > const_reverse_iterator
const_iterator cend() const noexcept
const_reverse_iterator crbegin() const noexcept
ptrdiff_t difference_type
BinTreeRB(const TCompare &compare=TCompare()) noexcept
iterator begin() noexcept
Get the begin binary tree iterator.
reverse_iterator rbegin() noexcept
Get the reverse begin binary tree iterator.
T * erase(const T &item) noexcept
Erase the given item from the binary tree.
void clear() noexcept
Clear the binary tree.
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 ...
BinTreeConstIterator< BinTreeRB< 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 end() noexcept
Get the end binary tree iterator.
T * root() noexcept
Get the root binary tree item.
const T * root() const noexcept
T * lowest() noexcept
Get the lowest binary tree item.
void swap(BinTreeRB &bintree) noexcept
Swap two instances.
const_reverse_iterator crend() const noexcept
std::pair< iterator, bool > insert(T &item) noexcept
Insert a new item into the binary tree.
const value_type & const_reference
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_iterator cbegin() const 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.
Intrusive binary tree reverse iterator.
C++ Common project definitions.
Red-Black binary tree node.
T * right
Pointer to the right child binary tree node.
T * left
Pointer to the left child binary tree node.
T * parent
Pointer to the parent binary tree node.