Esempio n. 1
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;
}
Esempio n. 2
0
Bool testhash::Parent::insertAfterTableListChild(const Child & child, const Child & prev) const  {
    if( !child.isExists() || !prev.isExists())
        return false;
    Child next = prev.getNextParentTableListChild();
    prev.setNextParentTableListChild(child);
    child.setPrevParentTableListChild(prev);
    child.setNextParentTableListChild(next);
    if(next.isValid())
        next.setPrevParentTableListChild(child);
    else
        setLastTableListChild(child);
    setNumTableListChilds(getNumTableListChilds() + 1);
    child.setupTableListParentHandler();
    return true;
}
Esempio n. 3
0
Bool testhash::Parent::removeChild(Sym key) const  {
    if(getChildTableLen() == 0)
        return false;
    StdUInt hash_value = getChildHash(key);
    Child first_table_child = getiChildTable(hash_value);
    if(!first_table_child.isValid())
        return false;
    for (Child it = first_table_child; it.isValid(); it = it.getNextParentTableListChild())
    {
        if (getChildHash(it.getParentKey()) != hash_value)
            break;
        if (it.getParentKey() == key)
            return removeChild(it);
    }
    return false;
}
Esempio n. 4
0
Void testhash::Parent::cascadeRemoveTableListChild() const  {
    Child prev;
    for ( Child current = getFirstTableListChild(); current.isValid(); current = current.getNextParentTableListChild())
    {
        if (prev.isValid())
        {
            prev.removeTableListParentHandler();
            prev.destroy();
        }
        prev = current;
    }
    if (prev.isValid())
    {
        prev.removeTableListParentHandler();
        prev.destroy();
    }
}
Esempio n. 5
0
testhash::Child testhash::Parent::popFrontTableListChild() const  {
    Child result = getFirstTableListChild();
    if(result.isValid())
    {
        result.removeTableListParentHandler();
        Child next = result.getNextParentTableListChild();
        result.setNextParentTableListChild(Child());
        result.setPrevParentTableListChild(Child());
        setFirstTableListChild(next);
        if(!next.isValid())
            setLastTableListChild(Child());
        else
            next.setPrevParentTableListChild(Child());
        setNumTableListChilds(getNumTableListChilds() - 1);
    }
    return result;
}
Esempio n. 6
0
Bool testhash::Parent::removeTableListChild(const Child & child) const  {
    if( !child.isExists())
        return false;
    child.removeTableListParentHandler();
    Child next = child.getNextParentTableListChild(), prev = child.getPrevParentTableListChild();
    if(next.isValid())
        next.setPrevParentTableListChild(prev);
    else if (getLastTableListChild() == child)
        setLastTableListChild(prev);
    else
        return false;
    if(prev.isValid())
        prev.setNextParentTableListChild(next);
    else if (getFirstTableListChild() == child)
        setFirstTableListChild(next);
    else
        return false;
    child.setNextParentTableListChild(Child());
    child.setPrevParentTableListChild(Child());
    setNumTableListChilds(getNumTableListChilds() - 1);
    return true;
}