[futurebasic] Re: [FB] More fun with linked lists!

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : February 2000 : Group Archive : Group : All Groups

From: Sean <mclaugh@...>
Date: Wed, 23 Feb 2000 11:17:26 +0000
I like your idea, jonathan. A couple suggestions:

Fill the empty spaces from the top-down. Start by filling whatever
trans# 000 tells you to. Put this slot's "next" field in the trans# 000
field. That is quicker than going all the way to the bottom of the
table. However, as you would say, "as tedd would say, 'linked lists are
fast to treat!'", so mabye it isn't worth it. :-)

Further, what about when you delete more than one field in a row? The
position of the first one would go in trans# 000, but the second one
would be lost forever! No, don't just "just look for the first free row
as I did in the beginning"! Instead, link the second deleted field to
the beginning or the end of the first deleted field. This way, you'll
_never_ have to go searching for empty space. The only time you won't be
able to find space in the "empty space linked list" is when there is no
empty space. This means you need to expand your storage space.

Ok, here we have one chain of empty fields. Trans# 000 says to find it
at field 005. Now lets say we had complaints with the "zyx", and want to
remove it.

Trans#    Item     Next
000       -----    005
001       abc      002
002       def      004
003       zyx      000
004       ghi      000
005       -----    006
006       -----    000

Now its gone, and the chain of empty fields includes it. It was pushed
into the beginning of the chain. It could just as easily be put at the
end, but this is slightly quicker (see my very first comment).

Trans#    Item     Next
000       -----    003
001       abc      002
002       def      004
003       -----    005
004       ghi      000
005       -----    006
006       -----    000

It just keeps getting more fun, huh?

Regards,
Sean