0

I want to know how I can edit any element of a queue in Visual Basic. Can you tell me if there's any method or any way to get to get an element and modify it? I want to modify the first element of a queue but I have no idea.

On the line COLAESPERA. Peek-1 I need to subtract the first element of the queue.

Public Sub RR()
    If COLAESPERA.Count = 0 Then
    Else
        For i = 1 To quamtun
            ***COLAESPERA.Peek-1***
            If COLAESPERA.Peek = 0 Then
                COLAESPERA.Dequeue()
                RR()
            Else
                If i = quamtun Then
                    COLAESPERA.Enqueue(COLAESPERA.Dequeue)
                    RR()
                End If
            End If
        Next
    End If
End Sub
Blackwood
  • 4,504
  • 16
  • 32
  • 41
  • This is not a code writing or tutorial site. You need to do your own research and post a programming question when you get stuck. Please read [ask] and take the [tour] – Ňɏssa Pøngjǣrdenlarp Oct 06 '17 at 23:14
  • If you need random access to the items in a collection then a `Queue` is not the right collection to use. It's worth noting that `Queue(Of T)` implements `ICollection(Of T)` but not `IList(Of T)`, specifically because it's not meant to be accessed randomly. That said, it does implement `IEnumerable(Of T)`, so you can call the `ElementAt` extension method. I'm not sure how a `Queue(Of T)` behaves when enumerated though, which any extension method of `IEnumerable(Of T)` must do. It might dequeue each item as it goes. – jmcilhinney Oct 07 '17 at 04:30
  • It's also worth noting that the objects in the queue are still the same objects that you added in the first place, so you can still access them via the same reference you used to add them in the first place. That may or may not be feasible in your specific case. – jmcilhinney Oct 07 '17 at 04:31

0 Answers0