Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Linked List

Status
Not open for further replies.

tabaki

Programmer
Nov 14, 2001
19
BE
Does anybody know how to create a linked list in VB? I know how to create a linked list in C but not in VB. Can anybody help me?
 
I wrote a class for this over a year ago. It's slow and kludgy, but it worked. I made it doubly linked (head and tail and each node has a previous and next link). I wrote an LLNode class that has
Private mNext as Object
Private mExt as Extent 'I'm keeping a list of extents
Private mPrev as Object

The linked list class has
Private mCount as Long
Private Head as LLNode
Private Tail as LLNode

I'm sure I could rewrite it faster and cleaner. It's the same logic as writing in in C, but no pointers, or rather ALL pointers. I'm sure you could use AddressOf to make your own pointers to address locations to speed it up.

You're welcome to a copy of the class if you want it.
scarfhead
 
I'm very interested in your version, would you pleas give a copy of it to me...

thanks TABAKI
 
tabaki -

The critical difference between a linked list in C/C++ and VB, is that in the C versions, you're storing a memory address of the other node(s). In VB, you'll be storing a object reference to the other node(s).

So you'd declare a class module called LLNode that contained member variables for your payload (the data needed by your program), as well as member variable(s) of type LLNode to point to the next node or nodes.

It's perfectly OK to have self-referential types in this case (a member variable of the same type as the surrounding class), as the VB runtime will have no problem resolving the class type.

Chip H.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top