Simple Dynamic Structures

Linear structures are the simplest class of dynamic data structures. Each element of structures of this type contains some information and a pointer to the next element. The diagram in Figure 6.1 shows a simple data structure in which each element of the structure contains a piece of data and a reference to the next item in the structure. (This structure is normally called a linked list because it contains a list of items, linked together.)

Figure 6.1: The simplest type of dynamic data structure

What differentiates one instance of this kind of data structure from another? It’s just the arbitrary rules about how you can add or delete nodes. For example, stacks and queues are both types of linear linked data structures, but a stack can accept new items only at its “top,” and a queue can accept new items only at its “bottom.” With a stack, you can retrieve items only from the same place you added them, but with a queue, you retrieve them from the other end of the structure. This chapter discusses creating both of these simple data structures with VBA class modules.

If you need to be able to traverse your structure in both directions, you can, of course, include links in both directions. Although we won’t handle this additional step in this chapter, it takes very little extra work to provide links in both directions. You’ll find this extra pointer very useful when you must traverse a list in either direction.

© 1997 by SYBEX Inc. All rights reserved.