This week's book giveaway is in the Agile and Other Processes forum.
We're giving away four copies of The Little Book of Impediments (e-book only) and have Tom Perry on-line!
See this thread for details.
Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

records/linked list/deletion

 
Laura Williamson
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
QUESTION ONE

-- IF WE STORE THE RECORDS IN A LINKED LIST....
-- THE INDEX FOR A LINKEDLIST IS AN INT
-- WHICH WOULD IMPLY THAT THE GREATEST NO OF ELEMENTS A LINKEDLIST CAN HOLD IS 2^31.
-- THE FACT THAT DATA RECORDS ARE ASSIGNED LONGS, NOT INTS, IMPLIES THAT THE SYSTEM MIGHT
NEED TO DEAL WITH RECORD NUMBERS > INTEGER.MAX_VALUE (i.e. longer than a linked list)
-- LINKED LIST WOULDN'T COPE WITH THIS. - as far as I know...

--> COULD IMPLEMENT MULTIPLE LINKED LISTS TO DEAL WITH THIS
R1 (holds records 1 - 2^31)
R2 (holds records 2 ^ 31 + 1 ---- ... )

etc.

BUT if record numbers are getting up towards LONG.MAX_VALUE you'd need a lot of linked lists!

Is this overkill, or do we need to code for this?

In summary - do we need to code for a system where record numbers might exceed INTEGER.MAX_VALUE?

If so, is a suitable suggestion multiple linked lists? I think not...

QUESTION TWO

do i have to nullify all the values in a delete record - or is it enough just to set the first
VALID byte to 0xFF

0xFF = 255 which will overflow one byte. So how can I set the valid byte to this anyway>?
Can set to a max of 127>?

All advice appreciated

Thanks
 
Philippe Maquet
Bartender
Posts: 1872
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Laura,
1) You don't need to care about having to deal with more than Integer.MAX_VALUE records in memory. You'll never have enough memory anyway to load them all... BTW, what's the purpose of that LinkedList? Are you sure it's the best collection to meet your needs?
2)
do i have to nullify all the values in a delete record - or is it enough just to set the first
VALID byte to 0xFF

Setting the "deleted" flag only is enough.
So how can I set the valid byte to this anyway?

Just cast the 0xFF to a byte: (byte) 0XFF
Regards,
Phil.
 
Laura Williamson
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ok thanks
was thinking of changing linked list -
you think ArrayList is better? or hashMap or HashTable?
 
Philippe Maquet
Bartender
Posts: 1872
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Laura,
I guess you're implementing a records cache. If you want a List (array-like access, by index) ArrayList is a better choice than LinkedList (because you'll access it by index and LinkedList is (potentially much) slower in that area). A HashMap can be used too (in it, you may even store recNos as Long keys BTW). And I'd avoid Hashtable which is one of the old-fashioned collections (as Vector).
Regards,
Phil.
 
Laura Williamson
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ok thanks very much. will go for arrayList or hashMap
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic