Hi guys, in the interface the delete method signature is
// Deletes a record, making the record number and associated disk // storage available for reuse. public void delete(int recNo) throws RecordNotFoundException;
and the data file has a flag for every record that indicates if the record is deleted or active, but based on the method's comment, every call to this method will delete the record from the file, meaning that the file will only have active records.
And for the create method: // Creates a new record in the database (possibly reusing a // deleted entry). Inserts the given data, and returns the record // number of the new record. public int create(String  data) throws DuplicateKeyException;
Then my question is, do I really need remove the record from the file? It does not make sense to me, to have a flag when all records are valid, am I missing something here?
the thing that confused me was // making the record number and associated disk storage available for reuse
specially the "associated disk storage available" comment, first I was thinking mark the record using the flag value and remove it from the system, but here it seems that is requesting to remove it from the file too, but I could be wrong.
Like I said, if you mark the record as deleted in your file, then the associated disk storage becomes available for reuse by your program, but not the operating system. If you actually delete the record from the file, the disk storage becomes available to the operating system, but not to your program.
What I think, is to mark the record deleted on memory (using the flag value for it) and write the flag byte on disk and when a new record needs to be created you can find the first deleted record from the collection and overwrite it on memory and permament storage.