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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to implement a Stack 5

Status
Not open for further replies.

camjon

Technical User
Apr 2, 2008
17
US
I want to know if anyone knows how to implement a stack in vba
 
Use a Global array.

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
How are ya camjon . . .

Outside of Access own stack, I find it hard to see the need for your own.

[blue]Could you explain in more detail how you intend to use it?[/blue] [surprise] . . . Its possible we can relieve you of any stack at all . . .

Calvin.gif
See Ya! . . . . . .

Be sure to see thread181-473997
Also faq181-2886
 
TheAceMan1,

I can find a massive use for a stack straight away. An Undo stack for Command pattern.

As you do commands, you push them onto the stack. Popping them off gives you Undo ability.

C
 
Craig0201 . . .

I've just never had the need. Could turn out to be quite a task for you . . . particularly undoing previously run code! Good Luck with this . . .

Calvin.gif
See Ya! . . . . . .

Be sure to see thread181-473997
Also faq181-2886
 
Just realised.....I never answered the question. Curteosy of our friends at Microsoft.....

Declare this as a Class Module called Stack

Code:
Option Compare Database
Option Explicit

Private siTop As StackItem

Property Get StackTop() As Variant
    If StackEmpty Then
        StackTop = Null
    Else
        StackTop = siTop.Value
    End If
End Property

Property Get StackEmpty() As Boolean
    ' Is the stack empty?  It can
    ' only be empty if siTop is Nothing.
    StackEmpty = (siTop Is Nothing)
End Property

Public Function Pop() As Variant
    If Not StackEmpty Then
        ' Get the value from the current top stack element.
        ' Then, get a reference to the new stack top.
        Pop = siTop.Value
        Set siTop = siTop.NextItem
    End If
End Function

Public Sub Push(ByVal varText As Variant)
    ' Add a new item to the top of the stack.

    Dim siNewTop As New StackItem

    siNewTop.Value = varText
    Set siNewTop.NextItem = siTop
    Set siTop = siNewTop
End Sub

And declare this as a Class Module called StackItem

Code:
Option Compare Database

' Keep track of the next stack item,
' and the value of this item.
Public Value As Variant
Public NextItem As StackItem

You can test using this in a standard module....

Code:
Dim stkTest As New Stack
Sub TestStacks()
    ' Push some items, and then pop them.
    stkTest.Push "Hello"
    stkTest.Push "There"
    stkTest.Push "How"
    stkTest.Push "Are"
    stkTest.Push "You"
    Do While Not stkTest.StackEmpty
        Debug.Print stkTest.Pop()
    Loop
    ' Now, call a bunch of procedures.
    ' For each procedure, push the proc name
    ' at the beginning, and pop it on the way out.
    Debug.Print
    Debug.Print "Testing Procs:"
    stkTest.Push "Main"
    Debug.Print stkTest.StackTop
    Call A
    Debug.Print stkTest.Pop
End Sub
Sub A()
    stkTest.Push "A"
    Debug.Print stkTest.StackTop
    Call B
    Debug.Print stkTest.Pop
End Sub
Sub B()
    stkTest.Push "B"
    Debug.Print stkTest.StackTop
    Call C
    Debug.Print stkTest.Pop
End Sub
Sub C()
    stkTest.Push "C"
    Debug.Print stkTest.StackTop
    ' You'd probably do something in here...
    Debug.Print stkTest.Pop
End Sub

Basically, as you push onto the stack, a StackItem is created which knows what the previous StackItem pushed on is. Hence you create the chain.

Hope this helps.

C
 
Thank you for the excellent post Craig0201, that was some very valuable information. I have just one more question, I am doing this in VBA 2003 and I am getting the error "user-defined type not defined" how do you define the user types.

Thanks
 
Have you created the Stack and StackList as Class Modules? And have you named the class modules as Stack and StackItem?

C
 
For most of us Access programmers we are concerned about working with objects (often controls). This code will add more utility to Craigs post. Also this gives the option of a FIFO or FILO queue

Code:
Option Compare Database
Option Explicit

Private mStack As New Collection
Private mStackType As Long
Public Enum theStackType
  FILO = 1
  FIFO = 2
End Enum

Public Function Push(theObject As Object, objName As String) As Object
   On Error GoTo errlabel
   If mStack.count = 0 Then
     mStack.Add Item:=theObject, Key:=objName
   ElseIf mStackType = FIFO Then
     mStack.Add Item:=theObject, Key:=objName, After:=mStack.count
   Else
     mStack.Add Item:=theObject, Key:=objName, Before:=1
   End If
   Set Push = theObject
   Exit Function
errlabel:
   MsgBox Err.Number & " " & Err.Description
End Function
Public Property Get count() As Integer
   count = mStack.count
End Property
Public Property Get Item(ByVal index As Variant) As Object
   Set Item = mStack(index)
End Property
Public Sub Remove(index As Variant)
   mStack.Remove (index)
End Sub

Private Sub Class_Initialize()
  mStackType = FILO
End Sub

Private Sub Class_Terminate()
 Set mStack = Nothing
End Sub
Public Sub Clear()
    Set mStack = New Collection
End Sub

Public Function Pop() As Object
  If Me.count > 0 Then
    Set Pop = mStack.Item(1)
    Me.Remove (1)
  Else
    MsgBox "Collection Empty"
  End If
End Function
Public Property Get StackType() As theStackType
  StackType = mStackType
End Property

Public Property Let StackType(ByVal theStackType As Long)
  mStackType = theStackType
End Property
Public Property Get StackTypeName() As String
  If mStackType = FIFO Then
    StackTypeName = "FIFO"
  Else
    StackTypeName = "FILO"
  End If
End Property
Public Property Get LastObjectName() As String
  LastObjectName = mStack.Item(mStack.count).Name
End Property
Public Property Get FirstObjectName() As String
  FirstObjectName = mStack.Item(1).Name
End Property

Test using some controls on a form
Code:
Public Sub testStack()
  Dim ctl As Access.Control
  Dim counter As Integer
  DoCmd.OpenForm "form1"
  Set myStack = New Stack
  'myStack.StackType = FILO
  myStack.StackType = FIFO
  Debug.Print myStack.StackTypeName
 For Each ctl In Forms("form1").Controls
    Debug.Print "Pushing " & ctl.Name
    myStack.Push ctl, ctl.Name
  Next ctl
    Debug.Print "Final StacK" & vbCrLf
  For counter = 1 To myStack.count
    Debug.Print "Stack Order " & myStack.Item(counter).Name
  Next counter
  Debug.Print "Popping" & vbCrLf
  For counter = 1 To myStack.count
    Debug.Print "Pop " & myStack.Pop.Name & " Remaining " & myStack.count
  Next counter
  
End Sub

Output demonstrating First in First Out FIFO or First in Last Out FILO
Code:
FILO

Pushing Check0
Pushing Label1
Pushing Option2
Pushing Label3
Pushing Text4
Pushing Label5

Final StacK
Stack Order Label5
Stack Order Text4
Stack Order Label3
Stack Order Option2
Stack Order Label1
Stack Order Check0

Popping
Pop Label5 Remaining 5
Pop Text4 Remaining 4
Pop Label3 Remaining 3
Pop Option2 Remaining 2
Pop Label1 Remaining 1
Pop Check0 Remaining 0

************************************
FIFO

Pushing Check0
Pushing Label1
Pushing Option2
Pushing Label3
Pushing Text4
Pushing Label5

Final StacK
Stack Order Check0
Stack Order Label1
Stack Order Option2
Stack Order Label3
Stack Order Text4
Stack Order Label5

Popping
Pop Check0 Remaining 5
Pop Label1 Remaining 4
Pop Option2 Remaining 3
Pop Label3 Remaining 2
Pop Text4 Remaining 1
Pop Label5 Remaining 0
 
A FIFO stack......that's a queue!

Personally, I wouldn't mix the two as they are different structures. In pure OO terms, you might inherit from a common DataStructure class or more likely, implement the same interface. Under no terms, though would I mix a queue and a stack in the same class. It confuses the code.

I would do as follows if you wish to have a queue.

Create an interface class module for DataStructure such that stack and queue are polymorphic.

Code for DataStructure
Code:
Option Compare Database

Property Get Peek() As Variant
    

End Property

Property Get IsEmpty() As Boolean
    
    
End Property

Public Function Pop() As Variant
    
    
End Function

Public Sub Push(dsi As Variant)
    
End Sub

Class module for a stack
Code:
Option Compare Database
Option Explicit

Implements DataStructure

Private dsiTop As DataStructureItem

Property Get DataStructure_IsEmpty() As Boolean
    ' Is the stack empty?  It can
    ' only be empty if siTop is Nothing.
    DataStructure_IsEmpty = (dsiTop Is Nothing)

End Property

Public Function DataStructure_Pop() As Variant
    
    If Not DataStructure_IsEmpty Then
        ' Get the value from the current top stack element.
        ' Then, get a reference to the new stack top.
        DataStructure_Pop = dsiTop.Value
        Set dsiTop = dsiTop.RelatedItem
    End If

End Function

Public Sub DataStructure_Push(dsi As Variant)
    ' Add a new item to the top of the stack.

    Dim dsiNewTop As New DataStructureItem

    dsiNewTop.Value = dsi
    Set dsiNewTop.RelatedItem = dsiTop
    Set dsiTop = dsiNewTop

End Sub

Private Property Get DataStructure_Peek() As Variant

    If DataStructure_IsEmpty Then
        DataStructure_Peek = Null
    Else
        DataStructure_Peek = dsiTop.Value
    End If

End Property

Class module for a queue
Code:
Option Explicit

Implements DataStructure

Private dsiFirst As DataStructureItem
Private dsiLast As New DataStructureItem

Property Get DataStructure_Peek() As Variant
    
    If DataStructure_IsEmpty Then
        DataStructure_Peek = Null
    Else
        DataStructure_Peek = dsiFirst.Value
    End If

End Property

Property Get DataStructure_IsEmpty() As Boolean
    
    ' Is the stack empty?  It can
    ' only be empty if siTop is Nothing.
    DataStructure_IsEmpty = (dsiFirst Is Nothing)

End Property

Public Function DataStructure_Pop() As Variant
    
    If Not DataStructure_IsEmpty Then
        ' Get the value from the current top stack element.
        ' Then, get a reference to the new stack top.
        DataStructure_Pop = dsiFirst.Value
        Set dsiFirst = dsiFirst.RelatedItem
    End If

End Function

Public Sub DataStructure_Push(dsi As Variant)
    ' Add a new item to the top of the stack.

    Dim dsiNewItem As New DataStructureItem
    
    Dim emptyQueue As Boolean
    
    emptyQueue = DataStructure_IsEmpty

    dsiNewItem.Value = dsi
    Set dsiLast.RelatedItem = dsiNewItem
    Set dsiLast = dsiNewItem
    
    If emptyQueue = True Then
        Set dsiFirst = dsiNewItem
    End If

End Sub

Class module for a DataStructureItem
Code:
Option Compare Database
Option Explicit
' Keep track of the next stack item,
' and the value of this item.
Public Value As Variant
Public RelatedItem As DataStructureItem

And this to test

Code:
Option Compare Database
Option Explicit

Dim testObject As DataStructure

Sub TestDataStructures(ByRef struct As DataStructure)
    ' Push some items, and then pop them.
    
    Set testObject = struct
    testObject.Push "Hello"
    testObject.Push "There"
    testObject.Push "How"
    testObject.Push "Are"
    testObject.Push "You"
    
    Do While Not testObject.IsEmpty
        Debug.Print testObject.Pop()
    Loop

End Sub

Sub TestQueue()
    
    Dim q As New DataStructure
    
    Set q = New Queue
    
    Debug.Print "Testing queue"
    TestDataStructures q
    Debug.Print

End Sub

Sub TestStack()
    
    Dim s As New Stack
    
    Set s = New Stack
    
    Debug.Print "Testing stack"
    TestDataStructures s
    Debug.Print

End Sub

Sub TestMaster()

    TestQueue
    TestStack

End Sub

Which when running TestMaster returns.....

Testing queue
Hello
There
How
Are
You

Testing stack
You
Are
How
There
Hello

Note that the classes Queue and Stack are polymorphic to a common interface. They are therefore interchangable. Note how I declare "testObject As DataStructure". I can then set it to a queue or stack as I require. This gives me the advantages of your FIFO and LIFO but with clarity as to how this is achieved and a defined structure.

Craig



 
Thanks, good point. A stack is a queue but not all queues are stacks. So I will do a global find and replace and just call it a queue class.

so now

Class Queue
Code:
Option Compare Database
Option Explicit

Private mQueue As New Collection
Private mQueueType As Long
Public Enum theQueueType
  FILO_STACK = 1
  FIFO = 2
End Enum

Public Function Push(theObject As Object, objName As String) As Object
   On Error GoTo errlabel
   If mQueue.count = 0 Then
     mQueue.Add Item:=theObject, Key:=objName
   ElseIf mQueueType = FIFO Then
     mQueue.Add Item:=theObject, Key:=objName, After:=mQueue.count
   Else
     mQueue.Add Item:=theObject, Key:=objName, Before:=1
   End If
   Set Push = theObject
   Exit Function
errlabel:
   MsgBox Err.Number & " " & Err.Description
End Function
Public Property Get count() As Integer
   count = mQueue.count
End Property
Public Property Get Item(ByVal index As Variant) As Object
   Set Item = mQueue(index)
End Property
Public Sub Remove(index As Variant)
   mQueue.Remove (index)
End Sub

Private Sub Class_Initialize()
  mQueueType = FILO_STACK
End Sub

Private Sub Class_Terminate()
 Set mQueue = Nothing
End Sub
Public Sub Clear()
    Set mQueue = New Collection
End Sub

Public Function Pop() As Object
  If Me.count > 0 Then
    Set Pop = mQueue.Item(1)
    Me.Remove (1)
  Else
    MsgBox "Collection Empty"
  End If
End Function
Public Property Get QueueType() As theQueueType
  QueueType = mQueueType
End Property

Public Property Let QueueType(ByVal theQueueType As Long)
  mQueueType = theQueueType
End Property
Public Property Get QueueTypeName() As String
  If mQueueType = FIFO Then
    QueueTypeName = "FIFO"
  Else
    QueueTypeName = "FILO (STACK)"
  End If
End Property
Public Property Get LastObjectName() As String
  LastObjectName = mQueue.Item(mQueue.count).Name
End Property
Public Property Get FirstObjectName() As String
  FirstObjectName = mQueue.Item(1).Name
End Property
 
A stack isn't a queue either. They are both cases of ordered lists. Hence why I treated as above, using the nearest I can to inheritance.

I fundamentally disagree with using a flag for different functionality. Whilst it is possible to code it that way, it breaks the ideas of OO programming.

C
 
Thanks. I think I am starting to get it. So if I want two "pseudo" ordered lists using a collection of objects build two seperate classes . How about this

ObjQueue_FIFO
Code:
Option Compare Database
Option Explicit

Private mQueue As New Collection
Public Function Push(theObject As Object, objName As String) As Object
   On Error GoTo errlabel
   mQueue.Add Item:=theObject, Key:=objName
   Set Push = theObject
   Exit Function
errlabel:
   MsgBox Err.Number & " " & Err.Description
End Function
Public Property Get count() As Integer
   count = mQueue.count
End Property
Public Property Get Item(ByVal index As Variant) As Object
   Set Item = mQueue(index)
End Property
Public Sub Remove(index As Variant)
   mQueue.Remove (index)
End Sub
Private Sub Class_Terminate()
 Set mQueue = Nothing
End Sub
Public Sub Clear()
    Set mQueue = New Collection
End Sub
Public Function Pop() As Object
  If Me.count > 0 Then
    Set Pop = mQueue.Item(1)
    Me.Remove (1)
  Else
    MsgBox "Collection Empty"
  End If
End Function
Public Property Get LastObjectName() As String
  If Me.count > 0 Then
    LastObjectName = mQueue.Item(mQueue.count).Name
  Else
    MsgBox "Queue Empty"
  End If
End Property
Public Property Get FirstObjectName() As String
   If Me.count > 0 Then
    FirstObjectName = mQueue.Item(1).Name
  Else
    MsgBox "Queue Empty"
  End If
End Property

Public Property Get LastObject() As Object
  If Me.count > 0 Then
    Set LastObject = mQueue.Item(mQueue.count)
  Else
    MsgBox "Queue Empty"
  End If
End Property

Public Property Get FirstObject() As Object
  If Me.count > 0 Then
    Set FirstObject = mQueue.Item(1)
  Else
    MsgBox "Queue Empty"
  End If
End Property

ObjStack_LIFO
Code:
Option Compare Database
Option Explicit

Private mStack As New Collection
Public Function Push(theObject As Object, objName As String) As Object
   On Error GoTo errlabel
   If mStack.count = 0 Then
     mStack.Add Item:=theObject, Key:=objName
   Else
     mStack.Add Item:=theObject, Key:=objName, before:=1
   End If
   Set Push = theObject
   Exit Function
errlabel:
   MsgBox Err.Number & " " & Err.Description
End Function
Public Property Get count() As Integer
   count = mStack.count
End Property
Public Property Get Item(ByVal index As Variant) As Object
   Set Item = mStack(index)
End Property
Public Sub Remove(index As Variant)
   mStack.Remove (index)
End Sub
Private Sub Class_Terminate()
 Set mStack = Nothing
End Sub
Public Sub Clear()
    Set mStack = New Collection
End Sub
Public Function Pop() As Object
  If Me.count > 0 Then
    Set Pop = mStack.Item(1)
    Me.Remove (1)
  Else
    MsgBox "Collection Empty"
  End If
End Function
Public Property Get LastObjectName() As String
  If Me.count > 0 Then
    LastObjectName = mStack.Item(mStack.count).Name
  Else
    MsgBox "Stack Empty"
  End If
End Property
Public Property Get FirstObjectName() As String
   If Me.count > 0 Then
    FirstObjectName = mStack.Item(1).Name
  Else
    MsgBox "Stack Empty"
  End If
End Property

Public Property Get LastObject() As Object
  If Me.count > 0 Then
    Set LastObject = mStack.Item(mStack.count)
  Else
    MsgBox "Stack Empty"
  End If
End Property

Public Property Get FirstObject() As Object
  If Me.count > 0 Then
    Set FirstObject = mStack.Item(1)
  Else
    MsgBox "Stack Empty"
  End If
End Property

So if I want to take this idea farther.
1)I can build a data structure class and put all common properties and procedures in there?
2)Then have my classes implement the data structure class?
3)Dimension a variable as a DataStructure but instantiate it as either a Stack or Queue?

I did not know I could use implements in VBA. Or is this VB?

If a property/procedure is common such as:

Property Get DataStructure_IsEmpty() As Boolean
' Is the stack empty? It can
' only be empty if siTop is Nothing.
DataStructure_IsEmpty = (dsiTop Is Nothing)
End Property

can the code actually go in the DataStructure class instead of repeated in each class?
 
Ok.....let's deal with these one by one.....

1)I can build a data structure class and put all common properties and procedures in there?

Unfortunately not. You're talking about inheritance here which VBA does not support. The nearest you can get is polymorphism.

2)Then have my classes implement the data structure class?

Your classes should implement DataStructure (which on second thoughts, I have renamed OrderedList).

3)Dimension a variable as a DataStructure but instantiate it as either a Stack or Queue?

Yes. This is good programming technique. It's called 'programming to an interface'. Which basically means, I can instantiate any object into that variable as long as it conforms to the interface. I then have code which I can adapt and reuse rather more easily.

You can use the keyword Implements in VBA, same as in VB6. It provides for polymorphism, which basically means that Stack and Queue have the same interface (external calls to them are identical).


In the case of
"If a property/procedure is common such as:

Property Get DataStructure_IsEmpty() As Boolean
' Is the stack empty? It can
' only be empty if siTop is Nothing.
DataStructure_IsEmpty = (dsiTop Is Nothing)
End Property

can the code actually go in the DataStructure class instead of repeated in each class?"

Unfortunately not. This is inheritance. In a true OO language, this is exactly what you would do. My code above is as near as you can get to it.

Some comments on your code more generally......

1) Stacks and queues don't generally have Remove, Item and other 'collection' methods. They just have Peek (what's going to come off without removing), Pop (what's come off) and Push (what's going in). There is nothing wrong in principle in using a collection as the 'holder' but the user of the class should be isolated from it. Otherwise, why wouldn't they just instantiate a collection?

2) You have methods in the class displaying Msgbox. The class should be returning Nothing at this point and the caller should be handling it. Why should the Stack/Queue know what to do to the user? The caller is what asked for the item knowing it may be empty so should be able to handle a Nothing return.

Does that all help?

C
 
Further.....

When you're pushing, you're aking the user to supply a key. There is no concept of a key in a stack or a queue. And it doesn't return anything. There is no need.

If I was to use a collection, I would......

Code Queue like this

Code:
Option Compare Database
Option Explicit

Implements DataStructure

Private coll As New Collection

Private Sub Class_Terminate()
   
   Set coll = Nothing

End Sub


Public Function DataStructure_Push(theObject As Object)

   coll.Add Item:=theObject

End Function

Public Function DataStructure_Count() As Integer
   
   DataStructure_Count = coll.Count

End Function

Public Function DataStructure_Pop() As Object

  If coll.Count > 0 Then
    Set DataStructure_Pop = coll.Item(1)
    coll.Remove (1)
  Else
    DataStructure_Pop = Nothing
  End If

End Function

Public Function DataStructure_Peek() As Object

  If coll.Count > 0 Then
    Set DataStructure_Peek = coll.Item(1)
  Else
    DataStructure_Peek = Nothing
  End If

End Function

Property Get DataStructure_IsEmpty() As Boolean
   
   DataStructure_IsEmpty = False

   If coll.Count = 0 Then
      DataStructure_IsEmpty = True
   End If

End Property

And code Stack like this...

Code:
Option Compare Database
Option Explicit

Implements DataStructure

Private coll As New Collection

Private Sub Class_Terminate()

   Set coll = Nothing

End Sub


Public Function DataStructure_Push(theObject As Object)

   coll.Add Item:=theObject

End Function

Public Function DataStructure_Count() As Integer
   
   DataStructure_Count = coll.Count

End Function

Public Function DataStructure_Pop() As Object

  If coll.Count > 0 Then
    Set DataStructure_Pop = coll.Item(coll.Count)
    coll.Remove (coll.Count)
  Else
    DataStructure_Pop = Nothing
  End If

End Function

Public Function DataStructure_Peek() As Object

  If coll.Count > 0 Then
    Set DataStructure_Peek = coll.Item(coll.Count)
  Else
    DataStructure_Peek = Nothing
  End If

End Function

Property Get DataStructure_IsEmpty() As Boolean
   
   DataStructure_IsEmpty = False

   If coll.Count = 0 Then
      DataStructure_IsEmpty = True
   End If

End Property

And adapting DataStructure to.....
Code:
Option Compare Database
Option Explicit

Property Get Peek() As Variant
    

End Property

Property Get IsEmpty() As Boolean
    
    
End Property

Public Function Pop() As Variant
    
    
End Function

Public Sub Push(dsi As Variant)
    
End Sub

Public Function Count() As Integer

End Function

You would need to do quite a bit of playing with this to make all the bits align correctly.

There is also one disadvantage of using a collection.....it doesn't have the flexibility of Variant in accepting value based objects such as strings or integers unless you box them.

C
 
Thanks. I think I got it. I Learned a lot.
 
You've already got a load of stars, Craig0201, but have another from me. I thought I was a pretty good vba guy, but you've shown me some new techniques I didn't realise were possible.

Many thanks.

Ben

----------------------------------------------
Ben O'Hara
David W. Fenton said:
We could be confused in exactly the same way, but confusion might be like Nulls, and not comparable.
 
somewhere in the dim recesses of ?memory? I recall "Stacks and Queues" as being taught as a subject referred to as linked lists, with the implication that they were 'single linked list' and thus somewhat easier to easier for many programmers to use, but that the dual linked lists were in fact more robust albeit a bit more complex.

The generic description of a stack is usually the concept of the plates in the cafeteria. You 'push' new (clean plates) onto the stack and 'pop' them off as necessary. Then most recently added one is always the next one to pop off.

The queue is often described as the 'chow line'. Every one (item) is added to the end of the existing line and the leader in the line is the next one to get 'fed' (or used).

These structures have strictly ordered methods of adding to and subtracting members. Both are often referred to by their acronym initials, 'Stack' is a 'LIFO' (last in First out) while the queue is a FIFO (First in First Out). These options are, of course, dictated by the simple fact that the mechanism only keeps track of the one 'neighbor'. The dual linked list actually functions in either direction, since every internal member (e.g. all members EXCEPT the 'head' and 'tail') keep track of of both of their neighbors (usually referred to as predecessor and successor). Since both these relationships are known, one can inspect the list for a specific member without destroying the lists and extract a member, by reattaching the predecessor and successor elements.

Apparently this is -at best- of academic interest in today's world, but I thought I would mention it.



MichaelRed


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top