9 #ifndef CPPCOMMON_CONTAINERS_BINTREE_AA_H
10 #define CPPCOMMON_CONTAINERS_BINTREE_AA_H
58 template <
typename T,
typename TCompare = std::less<T>>
92 template <
class InputIterator>
93 BinTreeAA(InputIterator first, InputIterator last,
const TCompare&
compare = TCompare()) noexcept;
102 explicit operator
bool() const noexcept {
return !
empty(); }
105 bool empty() const noexcept {
return _root ==
nullptr; }
108 size_t size() const noexcept {
return _size; }
111 T*
root() noexcept {
return _root; }
112 const T*
root() const noexcept {
return _root; }
115 const T*
lowest() const noexcept;
118 const T*
highest() const noexcept;
121 bool compare(const T& item1, const T& item2) const noexcept {
return _compare(item1, item2); }
171 T*
erase(const T& item) noexcept;
180 void clear() noexcept;
184 template <typename U, typename UCompare>
192 const T* InternalLowest() const noexcept;
193 const T* InternalHighest() const noexcept;
194 const T* InternalFind(const T& item) const noexcept;
195 const T* InternalLowerBound(const T& item) const noexcept;
196 const T* InternalUpperBound(const T& item) const noexcept;
219 #include "bintree_aa.inl"
Intrusive non balanced binary tree container definition.
Intrusive balanced A.Andersson binary tree container.
void clear() noexcept
Clear the binary tree.
const_reverse_iterator crend() const noexcept
void swap(BinTreeAA &bintree) noexcept
Swap two instances.
bool empty() const noexcept
Is the binary tree empty?
iterator begin() noexcept
Get the begin binary tree iterator.
BinTreeIterator< BinTreeAA< T, TCompare >, T > 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 ...
const value_type * const_pointer
size_t size() const noexcept
Get the binary tree size.
bool compare(const T &item1, const T &item2) const noexcept
Compare two items: if the first item is less than the second one?
BinTreeConstReverseIterator< BinTreeAA< T, TCompare >, T > const_reverse_iterator
BinTreeReverseIterator< BinTreeAA< T, TCompare >, T > reverse_iterator
BinTreeAA(const TCompare &compare=TCompare()) noexcept
BinTreeConstIterator< BinTreeAA< T, TCompare >, T > const_iterator
ptrdiff_t difference_type
reverse_iterator rend() noexcept
Get the reverse end binary tree iterator.
const_reverse_iterator crbegin() const noexcept
const T * root() const noexcept
iterator end() noexcept
Get the end binary tree iterator.
const_iterator cbegin() const noexcept
T * lowest() noexcept
Get the lowest binary tree item.
const_iterator cend() const noexcept
T * highest() noexcept
Get the highest binary tree item.
const value_type & const_reference
iterator find(const T &item) noexcept
Find the iterator which points to the first equal item in the binary tree or return end iterator.
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...
T * erase(const T &item) noexcept
Erase the given item from the binary tree.
T * root() noexcept
Get the root binary tree item.
std::pair< iterator, bool > insert(T &item) noexcept
Insert a new item into the binary tree.
reverse_iterator rbegin() noexcept
Get the reverse begin binary tree iterator.
Intrusive binary tree constant iterator.
Intrusive binary tree constant reverse iterator.
Intrusive binary tree iterator.
Intrusive binary tree reverse iterator.
C++ Common project definitions.
A.Andersson 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.
size_t level
Balance level.