Thread: List of data?
View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
GS[_5_] GS[_5_] is offline
external usenet poster
 
Posts: 226
Default List of data?

Robert Crandal explained :
I know I didnt answer the question about a "linked list". I
thought it would be better if I just forget about linked lists
because it is an abstract data type that is often implemented
in the C/C++ programming language.

Basically, a "linked list" is a set of data structures or "nodes"
that is in sequence; ie, the list has a beginning (i.e "head") and
and an end (i.e "tail"). Each node contains data, in addition
to a "next" pointer which points to the next node in the list.

Below is a text/graphical depiction of a linked list with
6 nodes. H is the head node, T is the tail node, and all
the other nodes are marked as N. Each node has an
arrow or pointer which points to the next node.

[H]--[N]--[N]--[N]--[N]--[T]

The nice thing about linked lists is that you can make them
dynamically grow or shink, by adding or deleting nodes.
So, a linked list is ALMOST like an array. The main difference
is that an array size is usually fixed, but a linked list can
dynamically grow and new nodes can be inserted anywhere
in the middle of the list.

Is this really your first experience with linked lists??


Well, I don't have any experience with linked lists. I'm afraid my
programming experience is limited to VB/VBA, HTML, and some vbScript.
I've read about this while exploring Delphi as a possible candidate for
my next gen dev language. I think it's a great concept, though.

I get a similar effect using a one dim array with [delimited] string
elements. Since arrays don't dynamically resize when deleting the
contents of an element, the Filter() function trims out any empty
elements and returns a newly sized array. For example, if myArray has
10 elements (0 T0 9) and I empty elements 2 and 6, the Filter()
function resizes the array to 8 elements (0 To 7). (What happens is
elements 3-5 shift one position, elements 7-10 shift 2 positions)

This makes for a very flexible structure where, for example, each
element of my one dim array can hold an array (thus making it an array
of arrays) if I choose. Usually, I store delimited strings that I parse
into a temp array when I want to use the data. I find this approach a
bit faster and easier to manage size-wise.

So, for example, if you stored your data in a text file where each
'record' of data was on a separate line then you could quickly dump the
file contents into a 'dynamic' array using Split() and specifying
vbCrLf as the delimiter. (Conversely, writing back is a simple matter
of using Join() and specifying vbCrLf as the delimiter) I like to store
field names (headings) in the first row so element 1 of myArray is the
first record and UBound(myArray) is the number of records. It also
makes it easier to dump the data onto a spreadsheet. (..subject to
worksheet row limit)

--
Garry

Free usenet access at http://www.eternal-september.org
ClassicVB Users Regroup! comp.lang.basic.visual.misc