From Eric Sokolosky, insertChild().

This commit is contained in:
Robert Osfield
2003-07-10 13:11:25 +00:00
parent c5c7a1b2ba
commit 9c5f84e99e
2 changed files with 20 additions and 1 deletions

View File

@@ -65,6 +65,11 @@ void Group::traverse(NodeVisitor& nv)
bool Group::addChild( Node *child )
{
return Group::insertChild( _children.size(), child );
}
bool Group::insertChild( unsigned int index, Node *child )
{
if (!child) return false;
@@ -79,7 +84,14 @@ bool Group::addChild( Node *child )
if (child)
{
// note ref_ptr<> automatically handles incrementing child's reference count.
_children.push_back(child);
if (index >= _children.size())
{
_children.push_back(child);
}
else
{
_children.insert(_children.begin()+index, child);
}
// register as parent of child.
child->addParent(this);