示例#1
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;
}
示例#2
0
Bool testlist::Parent::insertBeforeChild(const Child & child, const Child & next) const  {
    if(!child.isExists() ||
        !next.isExists() ||
        next.getParent() != *this ||
        child.getParent().isValid())
        return false;
    Child prev = next.getPrevParentChild();
    next.setPrevParentChild(child);
    child.setNextParentChild(next);
    child.setPrevParentChild(prev);
    if(prev.isValid())
        prev.setNextParentChild(child);
    else
        setFirstChild(child);
    child.setParent(*this);
    setNumChilds(getNumChilds() + 1);
    child.setupParentHandler();
    return true;
}