Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

NX: about delete record...

 
Barry Tsai
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi, all
I got a problem about deleting record. When I delete a record from file,
Should I actually delete it or just mark it as deleted one???
Best Regards,

Thx a lot.....
 
Tony Collins
Ranch Hand
Posts: 435
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I marked it as deleted, so it can be used again, plus deleting a record doesn't change the structure of the file.
 
Andrew Monkhouse
author and jackaroo
Marshal Commander
Pie
Posts: 11914
209
C++ Firefox Browser IntelliJ IDE Java Mac Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Barry
I agree with Tony's implementation.
I think just marking it as deleted (using the flag provided in the data file) is all you need do.
Regards, Andrew
 
Barry Tsai
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Tony Collins:
I marked it as deleted, so it can be used again, plus deleting a record doesn't change the structure of the file.

Ok,I mark it as deleted. That's means when I want to add a new record, I
should search file to judge whether have deleted record in the file.If yes,
I should insert into there , right??
 
Tony Collins
Ranch Hand
Posts: 435
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yeah that's right and if you haven't deleted a record you put the record at the end of the file. Therefore under this scheme a record always starts at the same position in a file.
Tony
 
Richard Jackson
Ranch Hand
Posts: 128
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,all
Tony's idea looks correct.
And in my assignment,there are states as below:
1 byte flag. 00 implies valid record, 0xFF implies deleted record

Please teach me the way to implement marking the deleted flag.
Thanks in advance.
Regards,
Richard.
 
Andrew Monkhouse
author and jackaroo
Marshal Commander
Pie
Posts: 11914
209
C++ Firefox Browser IntelliJ IDE Java Mac Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Richard,
Please look at this topic where this is being discussed.
Regards, Andrew
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic