예제 #1
0
파일: testlist.cpp 프로젝트: ivandzen/HSDB
Bool testlist::Child::insertAfterFreeChild(const Child & child, const Child & prev)  {
    if(!prev.isExists() || !child.isExists())
        return false;
    Child nxt = prev.getNextChildFreeChild();
    child.setNextChildFreeChild(nxt);
    prev.setNextChildFreeChild(child);
    setNumFreeChilds(getNumFreeChilds() - 1);
    child.setupFreeChildHandler();
    return true;
}
예제 #2
0
파일: testhash.cpp 프로젝트: ivandzen/HSDB
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;
}
예제 #3
0
파일: testhash.cpp 프로젝트: ivandzen/HSDB
Bool testhash::Parent::insertBeforeTableListChild(const Child & child, const Child & next) const  {
    if(!child.isExists() || !next.isExists())
        return false;
    Child prev = next.getPrevParentTableListChild();
    next.setPrevParentTableListChild(child);
    child.setNextParentTableListChild(next);
    child.setPrevParentTableListChild(prev);
    if(prev.isValid())
        prev.setNextParentTableListChild(child);
    else
        setFirstTableListChild(child);
    setNumTableListChilds(getNumTableListChilds() + 1);
    child.setupTableListParentHandler();
    return true;
}
예제 #4
0
파일: testlist.cpp 프로젝트: ivandzen/HSDB
Bool testlist::Child::pushFreeChild(const Child & child)  {
    if( !child.isExists())
        return false;
    child.setNextChildFreeChild(getFirstFreeChild());
    setFirstFreeChild(child);
    setNumFreeChilds(getNumFreeChilds() + 1);
    child.setupFreeChildHandler();
    return true;
}
예제 #5
0
파일: testlist.cpp 프로젝트: ivandzen/HSDB
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;
}
예제 #6
0
파일: testlist.cpp 프로젝트: ivandzen/HSDB
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;
}
예제 #7
0
파일: testhash.cpp 프로젝트: ivandzen/HSDB
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;
}
예제 #8
0
파일: testhash.cpp 프로젝트: ivandzen/HSDB
Bool testhash::Parent::pushFrontTableListChild(const Child & child) const  {
    if(!child.isExists())
        return false;
    Child first_child = getFirstTableListChild();
    child.setNextParentTableListChild(first_child);
    if(first_child.isValid())
        first_child.setPrevParentTableListChild(child);
    else
        setLastTableListChild(child);
    child.setPrevParentTableListChild(Child());
    setFirstTableListChild(child);
    setNumTableListChilds(getNumTableListChilds() + 1);
    child.setupTableListParentHandler();
    return true;
}
예제 #9
0
파일: testlist.cpp 프로젝트: ivandzen/HSDB
Bool testlist::Parent::pushBackChild(const Child & child) const  {
    if(!child.isExists() || child.getParent().isValid())
        return false;
    Child last_child = getLastChild();
    child.setPrevParentChild(last_child);
    if(last_child.isValid())
        last_child.setNextParentChild(child);
    else
        setFirstChild(child);
    child.setNextParentChild(Child());
    setLastChild(child);
    setNumChilds(getNumChilds() + 1);
    child.setParent(*this);
    child.setupParentHandler();
    return true;
}
예제 #10
0
파일: testhash.cpp 프로젝트: ivandzen/HSDB
Bool testhash::Parent::insertChild(const Child & child, Sym key, Bool replace) const  {
    if(!child.isExists() || child.getParent().isValid() || (!replace && hasKeyChild(key)))
        return false;
    if (getChildTableLen() == 0)
    {
        resizeChildTable(getChildTableSize());
        for (StdUInt i = 0; i < getChildTableSize(); i++)
            setiChildTable(i, Child());
    }
    StdUInt hash_value = getChildHash(key);
    Child first_table_child = getiChildTable(hash_value);
    if (first_table_child.isValid())
        insertBeforeTableListChild(child, first_table_child);
    else
    {
        if (hash_value < getChildTableMin())
        {
            pushFrontTableListChild(child);
            setChildTableMin(hash_value);
        }
        else if (hash_value > getChildTableMax())
        {
            pushBackTableListChild(child);
            setChildTableMax(hash_value);
        }
        else
        {
            StdUInt next_busy;
            for (next_busy = hash_value + 1; next_busy <= getChildTableMax(); next_busy++)
            {
                Child next_table_child = getiChildTable(next_busy);
                if (next_table_child.isValid())
                {
                    insertBeforeTableListChild(child, next_table_child);
                    break;
                }
            }
        }
    }
    setiChildTable(hash_value, child);
    setNumChilds(getNumChilds() + 1);
    child.setParentKey(key);
    child.setParent(*this);
    child.setupParentHandler();
    return true;
}
예제 #11
0
파일: testlist.cpp 프로젝트: ivandzen/HSDB
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;
}
예제 #12
0
파일: testhash.cpp 프로젝트: ivandzen/HSDB
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;
}
예제 #13
0
파일: testlist.cpp 프로젝트: ivandzen/HSDB
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;
}