[問題] HW 4

作者: DerekB98126 (修士)   2012-11-26 03:48:55
以下的function都會有 struct RID 的argument
deletRecord, exchangeRecord, nextRecord, getRecord, returnRecord
請問那些傳入的struct RID argument的slotNo會是正數還是負數?
同樣地,在 insertRecord, firstRecord, nextRecord 當中,都會有一個struct RID
by reference argument
請問那個slotNo我們應該傳正數還是負數?
如果是正數的話 我發現了以下這段code:
hfp_driver.C
line 351~362
//Deletion of empty page
Rid.pageNo=tmpPID; Rid.slotNo=-6; status = hfp.deleteRecord(Rid);
if (status == OK)
cout << "ERROR: empty space deletion.\n" << endl;
else
cout << "No record is deleted.\n"<<endl;
Rid.pageNo=tmpPID; Rid.slotNo=6; status = hfp.deleteRecord(Rid);
if (status == OK)
cout << "ERROR: improper deletion.\n" << endl;
else
cout << "No record is deleted. \n" <<endl;
當中可以看到如果傳入argument的slotNo是正數時,會做成 improper deletion.
而負數時是empty space deletion
我的理解是slotNo是負數才是正確的argument(因為是proper deletion)
但如果負數才是正確的argument
參考sample_output
insertRecord的struct RID argument by reference回傳的slotNo值應該是正數
Test 2: Insert and traversal of records
Inserted record, RID 7, 0
Inserted record, RID 7, 1
Inserted record, RID 7, 2
Inserted record, RID 7, 3
為什麼insertRecord回傳的slotNo值是正數呢?
還是應該想像成傳出時是正數 但傳入時是負數呢? (<
作者: DerekB98126 (修士)   2012-11-26 03:51:00
其實如果傳出傳入的slotNo都是正數的話,output才會和sample_output一樣
作者: peteranny (阿Tin)   2012-11-26 09:56:00
slotNo 是正數咦沒事,我沒看完你寫的,看完後我也不解了= =

Links booklink

Contact Us: admin [ a t ] ucptt.com