|
|
| intrusive_avl_tree () ETL_NOEXCEPT |
| | Default constructor.
|
| template<typename TIterator, typename TBinaryCompare> |
| | intrusive_avl_tree (TIterator first, TIterator last, TBinaryCompare binary_comp, typename etl::enable_if<!etl::is_integral< TIterator >::value, int >::type=0) |
| | ~intrusive_avl_tree () |
| ETL_NODISCARD iterator | begin () ETL_NOEXCEPT |
| ETL_NODISCARD const_iterator | begin () const ETL_NOEXCEPT |
| ETL_NODISCARD const_iterator | cbegin () const ETL_NOEXCEPT |
| ETL_NODISCARD iterator | end () ETL_NOEXCEPT |
| ETL_NODISCARD const_iterator | end () const ETL_NOEXCEPT |
| ETL_NODISCARD const_iterator | cend () const ETL_NOEXCEPT |
| ETL_NODISCARD iterator | max () ETL_NOEXCEPT |
| ETL_NODISCARD const_iterator | max () const ETL_NOEXCEPT |
| ETL_NODISCARD iterator | min () ETL_NOEXCEPT |
| ETL_NODISCARD const_iterator | min () const ETL_NOEXCEPT |
| template<typename TCompare> |
| iterator | lower_bound (TCompare comp) |
|
template<typename TCompare> |
| const_iterator | lower_bound (TCompare comp) const |
| template<typename TCompare> |
| iterator | upper_bound (TCompare comp) |
|
template<typename TCompare> |
| const_iterator | upper_bound (TCompare comp) const |
| ETL_NODISCARD iterator | get_root () ETL_NOEXCEPT |
| ETL_NODISCARD const_iterator | get_root () const ETL_NOEXCEPT |
| template<typename TCompare> |
| iterator | find (TCompare comp) |
| template<typename TCompare> |
| const_iterator | find (TCompare comp) const |
| template<typename TCompare, typename TFactory> |
| etl::pair< iterator, bool > | find_or_insert (TCompare comp, TFactory factory) |
| iterator | erase (iterator position) |
| iterator | erase (const_iterator position) |
| template<typename Visitor> |
| void | visit_in_order (const bool is_reverse, Visitor visitor) |
| template<typename Visitor> |
| void | visit_in_order (const bool is_reverse, Visitor visitor) const |
| template<typename Visitor> |
| void | visit_post_order (const bool is_reverse, Visitor visitor) |
| template<typename Visitor> |
| void | visit_post_order (const bool is_reverse, Visitor visitor) const |
| template<typename Visitor> |
| void | visit_pre_order (const bool is_reverse, Visitor visitor) |
| template<typename Visitor> |
| void | visit_pre_order (const bool is_reverse, Visitor visitor) const |
| ETL_NODISCARD bool | empty () const ETL_NOEXCEPT |
| ETL_NODISCARD size_t | size () const ETL_NOEXCEPT |
| void | clear () ETL_NOEXCEPT |
| void | swap (intrusive_avl_tree_base &other) ETL_NOEXCEPT |
|
|
| intrusive_avl_tree_base () ETL_NOEXCEPT |
| | Default constructor.
|
| | ~intrusive_avl_tree_base () |
|
ETL_NODISCARD link_type * | get_root () ETL_NOEXCEPT |
|
ETL_NODISCARD link_type & | get_origin () ETL_NOEXCEPT |
|
void | assign_impl (TIterator first, TIterator last, TBinaryCompare binary_comp) |
|
etl::pair< TValue *, bool > | find_or_insert_impl (TCompare comp, TFactory factory) |
|
static ETL_NODISCARD bool | is_real_link (const link_type *link) ETL_NOEXCEPT |
|
static ETL_NODISCARD TLink * | begin_impl (TLink &origin) ETL_NOEXCEPT |
|
static ETL_NODISCARD TLink * | end_impl (TLink &origin) ETL_NOEXCEPT |
|
static ETL_NODISCARD TLink * | find_extremum_impl (TLink *curr, const bool is_max) ETL_NOEXCEPT |
|
static ETL_NODISCARD TLink * | next_in_order_impl (TLink *curr) ETL_NOEXCEPT |
|
static ETL_NODISCARD TLink * | prev_in_order_impl (TLink *curr) ETL_NOEXCEPT |
|
static void | visit_in_order_impl (TLink *curr, const bool is_reverse, Visitor visitor) |
|
static void | visit_post_order_impl (TLink *curr, const bool is_reverse, Visitor visitor) |
|
static void | visit_pre_order_impl (TLink *curr, const bool is_reverse, Visitor visitor) |
|
static ETL_NODISCARD int_fast8_t | get_balance_factor_impl (const link_type *const curr) ETL_NOEXCEPT |
|
static ETL_NODISCARD TLink * | get_parent_impl (TLink *const curr) ETL_NOEXCEPT |
|
static ETL_NODISCARD TLink * | get_child_impl (TLink *const curr, const bool is_right) ETL_NOEXCEPT |
|
static TValue * | find_impl (TLink *const root, TCompare comp) |
|
static TValue * | find_bound_impl (TLink *const root, TCompare comp) |
|
static void | erase_impl (link_type *const z_link) ETL_NOEXCEPT |
template<typename TValue, size_t ID_ = 0>
class etl::intrusive_avl_tree< TValue, ID_ >
An intrusive AVL tree. Stores elements derived from 'intrusive_avl_tree<ID>::link_type'.
NB! The tree itself is not the real owner (of memory) of its nodes. The node TValue type contains all the necessary means (via required inheritance from link_type) to be able to participate in the tree as a "linked" node - hence the "intrusive" term.
- Warning
- This tree cannot be used for concurrent access from multiple threads.
- Template Parameters
-
| TValue | The type of value that the tree holds. |
| ID_ | The link ID that the value is derived from. |
template<typename TValue, size_t ID_ = 0>
template<typename TIterator, typename TBinaryCompare>
Constructor from range of items. Complexity: O(N*log(N)). NB! All items in the range must be in the "unlinked" state initially; otherwise the "already linked" exception is thrown. On success, all inserted items (except possible duplicates; see the comparator description below) will be linked.
The binary comparator should accept two const value_type& arguments (aka lhs and rhs), and return integer result (aka lhs - rhs "subtraction" result):
- >0 if the lhs is "greater" than the rhs
- 0 if the lhs is "equal" to the rhs
- <0 if the lhs is "smaller" than the rhs
- if throws then exception is propagated Hints:
- if you want duplicates then always return either >0 or <0, even for equal arguments:
- <0 (e.g. -1) will prepend a duplicate item to the tree
- >0 (e.g. +1) will append a duplicate item to the tree
- if you want to avoid duplicates in the result tree then use 0 for "equal" arguments - in such case only the first item of duplicates in the range will be linked to the tree; the rest will be skipped (left unlinked)
- etl::compare<value_type>::cmp could be directly used as comparator (if value's less is defined) - its Less, Equal and Greater are convertible/compatible with expected result integers.
If asserts or exceptions are enabled, throws:
template<typename TValue, size_t ID_ = 0>
template<typename TCompare>
Finds an item using given unary comparator. Complexity: O(log(N)) assuming O(1) for the comparator.
The unary comparator should accept single const value_type& value argument, and return integer result:
- >0 (e.g. +1) if the find target is "greater" than the argument
- 0 if the target is found
- <0 (e.g. -1) if the target is "smaller" than the argument
- if throws then exception is propagated
Result iterator will be end() if there is no matching item.
template<typename TValue, size_t ID_ = 0>
template<typename TCompare>
Finds a constant item using given unary comparator. Complexity: O(log(N)) assuming O(1) for the comparator.
The unary comparator should accept single const value_type& value argument, and return integer result:
- >0 (e.g. +1) if the find target is "greater" than the argument
- 0 if the target is found
- <0 (e.g. -1) if the target is "smaller"
- if throws then exception is propagated
Result iterator will be end() if there is no matching item.
template<typename TValue, size_t ID_ = 0>
template<typename TCompare, typename TFactory>
Finds an existing item using given unary comparator, and if not found then invokes factory functor to insert a new item. The new item is inserted at the tree position where the search has stopped. Complexity: O(log(N)) assuming O(1) for the comparator and factory. Operation does NOT invalidate any already existing iterators, but depending on where the new item was linked to the tree the existing iterators may skip the recently linked item.
The unary comparator should accept single const value_type& value argument, and return integer result:
- >0 (e.g. +1) if the find target is "greater" than the argument
- 0 if the target is found
- <0 (e.g. -1) if the target is "smaller" than the argument
- if throws then exception is propagated Hint: If result tree should contain "duplicates" then return non-zero result even for "equal" items, like e.g.:
- +1 to append a new item after existing duplicates
- -1 to prepend a new item before existing duplicates
The factory functor should return address of a "new" value (castable to the link_type*). The returned value should not be already linked to any tree, otherwise throws intrusive_avl_tree_value_is_already_linked (if asserts or exceptions are enabled). If return address is nullptr then tree won't be modified, and final result iterator will be valueless. If factory throws then exception is propagated (without modifying the tree).
Result contains a pair of:
- iterator to found (or inserted) item (could be valueless, but never end()).
- boolean indicating whether tree was modified (due to successful insertion).
template<typename TValue, size_t ID_ = 0>
template<typename TCompare>
Returns an iterator pointing to the first item that compares as "not less". Complexity: O(log(N)) assuming O(1) for the comparator. The unary comparator should accept single const value_type& value argument, and return integer result:
- >0 (e.g. +1) if the find target is "greater" than the argument
- 0 if the target is found
- <0 (e.g. -1) if the target is "smaller" than the argument
- if throws then exception is propagated
Result iterator will be end() if no such item exists.
template<typename TValue, size_t ID_ = 0>
template<typename TCompare>
Returns an iterator pointing to the first item that compares as "greater". Complexity: O(log(N)) assuming O(1) for the comparator. The unary comparator should accept single const value_type& value argument, and return integer result:
- >0 (e.g. +1) if the find target is "greater" than the argument
- 0 if the target is found
- <0 (e.g. -1) if the target is "smaller" than the argument
- if throws then exception is propagated
Result iterator will be end() if no such item exists.