38 #include <type_traits>
47 static_assert( std::is_move_constructible<Tree>::value,
"Tree is not move constructible." );
48 static_assert( std::is_move_assignable<Tree>::value,
"Tree is not move assignable." );
56 for(
size_t i = 0; i < res.links_.size(); ++i ) {
59 for(
size_t i = 0; i < res.nodes_.size(); ++i ) {
66 auto const& res_data = *res.node_at(i).
data_ptr();
70 assert(
typeid( res_data ) ==
typeid( oth_data ));
75 for(
size_t i = 0; i < res.edges_.size(); ++i ) {
82 auto const& res_data = *res.edge_at(i).data_ptr();
86 assert(
typeid( res_data ) ==
typeid( oth_data ));
99 if( &other ==
this ) {
119 for(
size_t i = 0; i < links_.size(); ++i ) {
120 res.links_[i] = utils::make_unique< TreeLink >();
122 for(
size_t i = 0; i < nodes_.size(); ++i ) {
123 res.nodes_[i] = utils::make_unique< TreeNode >();
125 for(
size_t i = 0; i < edges_.size(); ++i ) {
126 res.edges_[i] = utils::make_unique< TreeEdge >();
130 for(
size_t i = 0; i < links_.size(); ++i ) {
131 auto const& cur_link =
link_at(i);
132 assert( cur_link.index() == i );
134 res.links_[i]->reset_index( i );
135 res.links_[i]->reset_next( res.links_[ cur_link.next().index() ].get() );
136 res.links_[i]->reset_outer( res.links_[ cur_link.outer().index() ].get() );
137 res.links_[i]->reset_node( res.nodes_[ cur_link.node().index() ].get() );
138 res.links_[i]->reset_edge( res.edges_[ cur_link.edge().index() ].get() );
140 for(
size_t i = 0; i < nodes_.size(); ++i ) {
141 auto const& cur_node =
node_at(i);
142 assert( cur_node.index() == i );
144 res.nodes_[i]->reset_index( i );
145 res.nodes_[i]->reset_primary_link( res.links_[ cur_node.link().index() ].get() );
147 for(
size_t i = 0; i < edges_.size(); ++i ) {
148 auto const& cur_edge =
edge_at(i);
149 assert( cur_edge.index() == i );
151 res.edges_[i]->reset_index( i );
152 res.edges_[i]->reset_primary_link( res.links_[ cur_edge.primary_link().index() ].get() );
153 res.edges_[i]->reset_secondary_link( res.links_[ cur_edge.secondary_link().index() ].get() );
157 res.root_link_ = res.links_[ root_link_->
index() ].get();
165 swap( root_link_, other.root_link_ );
167 swap( links_, other.links_ );
168 swap( nodes_, other.nodes_ );
169 swap( edges_, other.edges_ );
174 root_link_ =
nullptr;