node: swap_children and swap_children_at functions

This commit is contained in:
BlackMATov
2020-04-22 10:25:02 +07:00
parent db99cd71d3
commit 3f8bb69955
6 changed files with 137 additions and 22 deletions

View File

@@ -108,6 +108,17 @@ namespace e2d
bool remove_child(
const node_iptr& child) noexcept;
node_iptr remove_child_at(
std::size_t index) noexcept;
bool swap_children(
const node_iptr& child_l,
const node_iptr& child_r) noexcept;
bool swap_children_at(
std::size_t child_l,
std::size_t child_r) noexcept;
bool send_backward() noexcept;
bool bring_to_back() noexcept;
@@ -131,8 +142,6 @@ namespace e2d
std::pair<std::size_t, bool> child_index(
const const_node_iptr& child) const noexcept;
node_iptr remove_child_at(std::size_t index) noexcept;
protected:
node() = default;
node(gobject owner);

View File

@@ -273,6 +273,8 @@ namespace e2d
static iterator iterator_to(T& v) noexcept;
static const_iterator iterator_to(const T& v) noexcept;
static void iterator_swap(iterator l, iterator r) noexcept;
private:
using node_t = intrusive_list_hook<Tag>;
using node_ptr = typename node_t::node_ptr;
@@ -496,4 +498,10 @@ namespace e2d
E2D_ASSERT(node.is_linked());
return const_iterator(&node);
}
template < typename T, typename Tag >
void intrusive_list<T,Tag>::iterator_swap(iterator l, iterator r) noexcept {
E2D_ASSERT(l.node()->is_linked() && r.node()->is_linked());
intrusive_list_hook<Tag>::swap_nodes(l.node(), r.node());
}
}