示例#1
0
testlist::Child testlist::Child::popFreeChild()  {
    Child result = getFirstFreeChild();
    if(result.isValid())
    {
        result.removeFreeChildHandler();
        setFirstFreeChild(result.getNextChildFreeChild());
        result.setNextChildFreeChild(Child());
        setNumFreeChilds(getNumFreeChilds() - 1);
    }
    return result;
}
示例#2
0
Bool testlist::Child::removeFreeChild(const Child & child)  {
    if( !child.isExists() )
        return false;
    Child prev;
    Child current;
    for(current = getFirstFreeChild(); current.isValid() && current != child; current = current.getNextChildFreeChild())
        prev = current;
    if(!current.isValid())
    {
        return false; //! data corrupted
    }
    current.removeFreeChildHandler();
    if(prev.isValid())
        prev.setNextChildFreeChild(current.getNextChildFreeChild());
    else
        setFirstFreeChild(current.getNextChildFreeChild());
    current.setNextChildFreeChild(Child());
    setNumFreeChilds(getNumFreeChilds() - 1);
    return true;
}