Exemplo n.º 1
0
Void testlist::Parent::cascadeRemoveChild() const  {
    Child prev;
    for ( Child current = getFirstChild(); current.isValid(); current = current.getNextParentChild())
    {
        if (prev.isValid())
        {
            prev.removeParentHandler();
            prev.setParent(Parent());
            prev.destroy();
        }
        prev = current;
    }
    if (prev.isValid())
    {
        prev.removeParentHandler();
        prev.destroy();
    }
}
Exemplo n.º 2
0
testlist::Child testlist::Parent::popFrontChild() const  {
    Child result = getFirstChild();
    if(result.isValid())
    {
        result.removeParentHandler();
        Child next = result.getNextParentChild();
        result.setNextParentChild(Child());
        result.setPrevParentChild(Child());
        setFirstChild(next);
        if(!next.isValid())
            setLastChild(Child());
        else
            next.setPrevParentChild(Child());
        setNumChilds(getNumChilds() - 1);
        result.setParent(Parent());
    }
    return result;
}
Exemplo n.º 3
0
Bool testlist::Parent::insertAfterChild(const Child & child, const Child & prev) const  {
    if(!child.isExists() ||
        !prev.isExists() ||
        prev.getParent() != *this ||
        child.getParent().isValid())
        return false;
    Child next = prev.getNextParentChild();
    prev.setNextParentChild(child);
    child.setPrevParentChild(prev);
    child.setNextParentChild(next);
    if(next.isValid())
        next.setPrevParentChild(child);
    else
        setLastChild(child);
    child.setParent(*this);
    setNumChilds(getNumChilds() + 1);
    child.setupParentHandler();
    return true;
}
Exemplo n.º 4
0
Bool testlist::Parent::removeChild(const Child & child) const  {
    if( !child.isExists() || child.getParent() != *this)
        return false;
    child.removeParentHandler();
    Child next = child.getNextParentChild(), prev = child.getPrevParentChild();
    if(next.isValid())
        next.setPrevParentChild(prev);
    else if (getLastChild() == child)
        setLastChild(prev);
    else
        return false;
    if(prev.isValid())
        prev.setNextParentChild(next);
    else if (getFirstChild() == child)
        setFirstChild(next);
    else
        return false;
    child.setNextParentChild(Child());
    child.setPrevParentChild(Child());
    child.setParent(Parent());
    setNumChilds(getNumChilds() - 1);
    return true;
}