本文整理汇总了C++中BlockInfo::GetNext方法的典型用法代码示例。如果您正苦于以下问题:C++ BlockInfo::GetNext方法的具体用法?C++ BlockInfo::GetNext怎么用?C++ BlockInfo::GetNext使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BlockInfo
的用法示例。
在下文中一共展示了BlockInfo::GetNext方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: AddBlockInfo
void FileHandle::AddBlockInfo(BlockInfo* block)
{
BlockInfo *bp = block->GetFile()->GetFirstBlock();
if (bp == NULL) block->GetFile()->SetFirstBlock(block);
else
{
while (bp->GetNext() != NULL)
bp = bp->GetNext();
bp->SetNext(block);
}
block->GetFile()->IncreaseRecordAmount();
block->GetFile()->IncreaseRecordLength();
}
示例2: GetBlockInfo
BlockInfo* FileHandle::GetBlockInfo(FileInfo* file, int block_pos)
{
BlockInfo* bp = file->GetFirstBlock();
while (bp != NULL)
{
if (bp->get_block_num() == block_pos)
return bp;
bp = bp->GetNext();
}
return NULL;
}
示例3:
BlockHandle::~BlockHandle()
{
BlockInfo* b = first_block_;
//释放所有块
while (block_count_ > 0)
{
BlockInfo* bn = b->GetNext();
delete b;
b = bn;
block_count_--;
}
}
示例4: IncreaseAge
void FileHandle::IncreaseAge()
{
FileInfo* fp = first_file_;
while (fp != NULL)
{
BlockInfo* bp = fp->GetFirstBlock();
while (bp != NULL)
{
bp->IncreaseAge();
bp = bp->GetNext();
}
fp = fp->GetNext();
}
}
示例5: LRUAlgorithm
//LRU算法返回该表所包含的所有文件中最老的块的指针(最近最少使用的块)
BlockInfo* FileHandle::LRUAlgorithm()
{
FileInfo* fp = first_file_;
//最老的块的前一块
BlockInfo* oldestbefore = NULL;
//最老的块
BlockInfo* oldest = fp->GetFirstBlock();
//找到最老的块
while (fp != NULL)
{
BlockInfo* bpbefore = NULL;
BlockInfo* bp = fp->GetFirstBlock();
while (bp != NULL)
{
if (bp->get_age() > oldest->get_age())
{
oldestbefore = bpbefore;
oldest = bp;
}
bpbefore = bp;
bp = bp->GetNext();
}
fp = fp->GetNext();
}
//如果最老的块被修改过,则把它的内容写回文件
if (oldest->get_dirty())
oldest->WriteInfo(path_);
//如果最老的块的前一位置是空块,则说明第一块就是最老的块。这时因为要移除oldest,所有该文件第一块就变成了oldest->next
if (oldestbefore == NULL) oldest->GetFile()->SetFirstBlock(oldest->GetNext());
else oldestbefore->SetNext(oldest->GetNext());
//将最老的块年龄重置为0
oldest->ResetAge();
//oldest的next置为null
oldest->SetNext(NULL);
//返回最老的块的指针
return oldest;
}
示例6:
FileHandle::~FileHandle()
{
WriteToDisk();
FileInfo* fp = first_file_;
while (fp != NULL)
{
FileInfo* fpn = fp->GetNext();
BlockInfo* bp = fp->GetFirstBlock();
while (bp != NULL)
{
BlockInfo* bpn = bp->GetNext();
delete bp;
bp = bpn;
}
delete fp;
fp = fpn;
}
}
示例7: WriteToDisk
void FileHandle::WriteToDisk()
{
FileInfo* fp = first_file_;
while (fp != NULL)
{
BlockInfo* bp = fp->GetFirstBlock();
while (bp != NULL)
{
//如果该块被修改过,则写到文件中
if (bp->get_dirty())
{
bp->WriteInfo(path_);
bp->set_dirty(false);
}
bp = bp->GetNext();
}
fp = fp->GetNext();
}
}