本文整理汇总了C++中Page::EmptyItOut方法的典型用法代码示例。如果您正苦于以下问题:C++ Page::EmptyItOut方法的具体用法?C++ Page::EmptyItOut怎么用?C++ Page::EmptyItOut使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Page
的用法示例。
在下文中一共展示了Page::EmptyItOut方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Add
void HeapFile::Add (Record& addme){
Page tempPage;
cout << "File length: " << f.GetLength() << endl;
if(0 != f.GetLength()){
f.GetPage(&tempPage, f.GetLength() - 2); //get the last page in the file
if(0 == tempPage.Append(&addme)){// the last page is full, add record to a new page and insert into the end of file
tempPage.EmptyItOut();
tempPage.Append(&addme);
f.AddPage(&tempPage, f.GetLength() - 1);
}else{// the last page is not full, add record into the last page.
f.AddPage(&tempPage, f.GetLength() - 2);
}
}else{ // This file is a new file with no page.
if(1 == tempPage.Append(&addme)) f.AddPage(&tempPage, 0);
else cout << "A new page is full. Can't insert record!" << endl;
}
}
示例2: Load
void HeapFile::Load (Schema& myschema, char* loadpath){
FILE *table = fopen(loadpath, "r");
if( 0 == table) exit(-1);
Page tempPage;
Record tempRecord;
int recordCounter = 0;
int pageCounter = 0;
while(1 == tempRecord.SuckNextRecord(&myschema, table)){
assert(pageCounter >= 0);
assert(recordCounter >= 0);
recordCounter++;
if(recordCounter % 10000 == 0)
cout << "The toal number of record: " << recordCounter << endl;
//insert record into page until page is full and insert page into file
if(0 == tempPage.Append(&tempRecord)){ // tempPage is full
f.AddPage(&tempPage, pageCounter);
tempPage.EmptyItOut();
tempPage.Append(&tempRecord);
pageCounter++;
}
}
f.AddPage(&tempPage,pageCounter);// insert the last page into the file
cout<< "Read " << recordCounter << endl;
}