Exemple #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();
    }
}
Exemple #2
0
Bool testhash::Parent::removeChild(const Child & child) const  {
    if(!child.isExists() || child.getParent() != *this )
        return false;
    StdUInt hash_value = getChildHash(child.getParentKey());
    Child next = child.getNextParentTableListChild();
    Child prev = child.getPrevParentTableListChild();
    if (prev.isValid()) //! Previous exists
    {
        if (getChildHash(prev.getParentKey()) != hash_value) //! Previous has different hash
        {
            if (next.isValid()) //! And next exists
            {
                if (getChildHash(next.getParentKey()) != hash_value) //! But next has different hash
                    setiChildTable(hash_value, Child());
                else  //! Next has the same hash
                    setiChildTable(hash_value, next);
            }
            else  //! Next is absent
            {
                setiChildTable(hash_value, Child());
                setChildTableMax(getChildHash(prev.getParentKey()));
            }
        }
    }
    else  //! Previous absent
    {
        if (next.isValid()) //! Next exists
        {
            if (getChildHash(next.getParentKey()) != hash_value) //! Next has different hash
            {
                setiChildTable(hash_value, Child());
                setChildTableMin(getChildHash(next.getParentKey()));
            }
            else //! Next has the same hash
                setiChildTable(hash_value, next);
        }
        else //! Next is absent
        {
            setiChildTable(hash_value, Child());
            setChildTableMax(0);
            setChildTableMin(0);
        }
    }
    removeTableListChild(child);
    child.setParent(Parent());
    child.removeParentHandler();
    setNumChilds(getNumChilds() - 1);
    return true;
}
Exemple #3
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;
}
Exemple #4
0
testlist::Child testlist::Parent::popBackChild() const  {
    Child result = getLastChild();
    if(result.isValid())
    {
        result.removeParentHandler();
        Child prev = result.getPrevParentChild();
        result.setPrevParentChild(Child());
        result.setNextParentChild(Child());
        setLastChild(prev);
        if(!prev.isValid())
            setFirstChild(Child());
        else
            prev.setNextParentChild(Child());
        setNumChilds(getNumChilds() - 1);
        result.setParent(Parent());
    }
    return result;
}
Exemple #5
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;
}