[futurebasic] Re: Linked Lists

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : September 1998 : Group Archive : Group : All Groups

From: Mark Goodes <wave@...>
Date: Mon, 28 Sep 1998 21:29:10 -0400
>I would appreciate a simple example of a
>situation where a Linked List is of particular value.

OK... the Mac Toolbox bases its window records on linked lists.  The data
for any window is stored in a window record.  Each window record has a
field called nextWindow&, which points to the window behind it.  The window
record does not exist until a window is created.

The advantage is flexibility:  the user can create as many windows as
memory allows, and a window record will be created every time.  No worries
about having to dim arrays or resize handles.  Also, no memory is wasted.
A window record doesn't exist until a window is created; it is destroyed
immediately when the window is closed.  There is no need to reserve memory
space just in case more records are required.

I used linked lists in a WDEF I was working on last summer.  Each window
that I drew had a separate record in addition to the regular window record
to store information that was private to my WDEF.  First I made sure the
code worked for three windows using linked lists.  Then I tested it by
opening and closing more and more windows.  There were no problems; it
worked like a charm.

____________________
wave(Toronto, Canada)
Genius is 50% inspiration, 50% perspiration, and 50% having the right tools.