From 13e729a8bf2fc72d167fda378fd934ff8ae7409f Mon Sep 17 00:00:00 2001 From: Jan Travnicek <Jan.Travnicek@fit.cvut.cz> Date: Tue, 19 Jul 2016 13:56:33 +0200 Subject: [PATCH] add another insert type to VararyNode --- alib2std/src/extensions/tree.hpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/alib2std/src/extensions/tree.hpp b/alib2std/src/extensions/tree.hpp index 68ae7d77db..e165ef6774 100644 --- a/alib2std/src/extensions/tree.hpp +++ b/alib2std/src/extensions/tree.hpp @@ -372,6 +372,14 @@ public: ( * it )->parent = static_cast < Cast * > ( this ); } + typename std::vector < Data >::iterator insert ( typename std::vector < Data >::iterator it, Data d ) { + it = children.insert ( it, std::move ( d ) ); + + ( * std::prev ( it ) ) -> parent = static_cast < Cast * > ( this ); + + return it; + } + template < class InputIterator > typename std::vector < Data >::iterator insert ( typename std::vector < Data >::iterator it, InputIterator first, InputIterator last ) { size_t off = it - children.begin ( ); @@ -453,6 +461,10 @@ public: const_cast < VararyNode < Data, ConstData, Cast > & > ( node ).setChild ( std::move ( child ), it ); } + typename std::vector < Data >::iterator insert ( const VararyNode < Data, ConstData, Cast > & node, typename std::vector < Data >::iterator it, Data child ) { + const_cast < VararyNode < Data, ConstData, Cast > & > ( node ).insert ( it, std::move ( child ) ); + } + template < class InputIterator > typename std::vector < Data >::iterator insert ( const VararyNode < Data, ConstData, Cast > & node, typename std::vector < Data >::iterator it, InputIterator first, InputIterator last ) { const_cast < VararyNode < Data, ConstData, Cast > & > ( node ).insert ( it, first, last ); -- GitLab