Queue Class represents a first-in, first-out collection of objects. : Queue « Data Structure « VB.Net






Queue Class represents a first-in, first-out collection of objects.

 

Imports System
Imports System.Collections

Public Class SamplesQueue
    Public Shared Sub Main()
        Dim myQ As New Queue()
        myQ.Enqueue("A")
        myQ.Enqueue("B")
        myQ.Enqueue("C")

        Console.WriteLine("    Count:    {0}", myQ.Count)
        PrintValues(myQ)
    End Sub 'Main

    Public Shared Sub PrintValues(myCollection As IEnumerable)
        Dim obj As [Object]
        For Each obj In  myCollection
            Console.Write("    {0}", obj)
        Next obj
        Console.WriteLine()
    End Sub 'PrintValues

End Class 'SamplesQueue

   
  








Related examples in the same category

1.Queue Demo: enqueue, dequeue and peekQueue Demo: enqueue, dequeue and peek
2.Queue Item CountQueue Item Count
3.Simple Demo for Queue: Enqueue, Dequeue and PeekSimple Demo for Queue: Enqueue, Dequeue and Peek
4.Creates a queue of strings with default capacity and uses the Enqueue method to queue five strings.
5.The elements of the queue are enumerated, which does not change the state of the queue.
6.The Dequeue method is used to dequeue the first string.
7.The Peek method is used to look at the next item in the queue
8.The ToArray method is used to create an array and copy the queue elements to it
9.the array is passed to the Queue<(Of <(T>)>) constructor that takes IEnumerable<(Of <(T>)>)
10.CopyTo method is used to copy the array elements beginning at the middle of the array.
11.Create a second copy of the queue containing three null elements at the beginning.