本文整理汇总了C++中HDB::setLastRootOffset方法的典型用法代码示例。如果您正苦于以下问题:C++ HDB::setLastRootOffset方法的具体用法?C++ HDB::setLastRootOffset怎么用?C++ HDB::setLastRootOffset使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HDB
的用法示例。
在下文中一共展示了HDB::setLastRootOffset方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
bool
HDBNode::remove(HDBHandle& hdl)
{
// If node hasn't been written yet, don't do anything.
if (m_pdata->m_offset <= 0)
{
return false;
}
File file = hdl.getFile();
HDB* pdb = hdl.getHDB();
HDBBlock fblk;
// Remove all children
Int32 coffset = m_pdata->m_blk.lastChild;
Int32 toffset;
while (coffset > 0)
{
HDB::readBlock(fblk, file, coffset);
toffset = coffset; // Save offset for deletion class
coffset = fblk.prevSib; // Save offset for next read
// Remove node and all of its children. This call will modify fblk.
removeBlock(hdl, fblk, toffset);
}
// Set pointer on next sibling if it exists
if (m_pdata->m_blk.nextSib > 0)
{
HDB::readBlock(fblk, file, m_pdata->m_blk.nextSib);
fblk.prevSib = m_pdata->m_blk.prevSib;
HDB::writeBlock(fblk, file, m_pdata->m_blk.nextSib);
}
// Set pointer on prev sibling if it exists
if (m_pdata->m_blk.prevSib > 0)
{
HDB::readBlock(fblk, file, m_pdata->m_blk.prevSib);
fblk.nextSib = m_pdata->m_blk.nextSib;
HDB::writeBlock(fblk, file, m_pdata->m_blk.prevSib);
}
// If it has a parent, insure parent doesn't contain it's offset
if (m_pdata->m_blk.parent > 0)
{
// Read parent block
HDB::readBlock(fblk, file, m_pdata->m_blk.parent);
bool changed = false;
// If this was the first child in the list, then update the
// first child pointer in the parent block
if (fblk.firstChild == m_pdata->m_offset)
{
changed = true;
fblk.firstChild = m_pdata->m_blk.nextSib;
}
// If this was the last child in the list, then update the
// last child pointer in the parent block
if (fblk.lastChild == m_pdata->m_offset)
{
changed = true;
fblk.lastChild = m_pdata->m_blk.prevSib;
}
// If any offsets changed in the parent block, then update the parent
if (changed)
{
HDB::writeBlock(fblk, file, m_pdata->m_blk.parent);
}
}
else
{
// Must be a root node
if (pdb->getFirstRootOffSet() == m_pdata->m_offset)
{
pdb->setFirstRootOffSet(file, m_pdata->m_blk.nextSib);
}
if (pdb->getLastRootOffset() == m_pdata->m_offset)
{
pdb->setLastRootOffset(file, m_pdata->m_blk.prevSib);
}
}
// Add block to free list
pdb->addBlockToFreeList(file, m_pdata->m_blk, m_pdata->m_offset);
// Remove the index entry for this node
hdl.removeIndexEntry(m_pdata->m_key.c_str());
m_pdata->m_offset = -1;
m_pdata->m_blk.isFree = true;
m_pdata->m_blk.parent = -1;
m_pdata->m_blk.firstChild = -1;
m_pdata->m_blk.lastChild = -1;
m_pdata->m_blk.prevSib = -1;
m_pdata->m_blk.nextSib = -1;
m_pdata->m_blk.size = 0;
hdl.registerWrite();
return true;
}