Queue.Peek : Queue « System.Collections « VB.Net by API






Queue.Peek

  

Imports System
Imports System.Collections

Public Class MainClass
    
    Shared Sub Main()
             Dim intQueue As New Queue(  )

             Dim i As Integer
             For i = 0 To 4
                 intQueue.Enqueue((i * 5))
             Next i

             Console.WriteLine("intQueue values:")
             DisplayValues(intQueue)

             Console.WriteLine("(Dequeue) {0}", intQueue.Dequeue(  ))

             Console.WriteLine("intQueue values:")
             DisplayValues(intQueue)

             Console.WriteLine("(Dequeue) {0}", intQueue.Dequeue(  ))

             Console.WriteLine("intQueue values:")
             DisplayValues(intQueue)

             Console.WriteLine("(Peek)   {0}", intQueue.Peek(  ))

             Console.WriteLine("intQueue values:")
             DisplayValues(intQueue)
   End Sub

   Public Shared Sub DisplayValues(ByVal myCollection As IEnumerable)
       Dim myEnumerator As IEnumerator = myCollection.GetEnumerator(  )
       While myEnumerator.MoveNext(  )
           Console.WriteLine("{0} ", myEnumerator.Current)
       End While
       Console.WriteLine(  )
   End Sub

End Class

   
    
  








Related examples in the same category

1.Queue.Count
2.Queue.Dequeue
3.Queue.ToArray