Home  |  Delphi .net Home  |  System.Collections.Queue  |  DeQueue Method
  
DeQueue  
Method  
Remove the item from the beginning of the current Queue
Queue Class
System.Collections NameSpace
CF1.  Function DeQueue : Object;
CF : Methods with this mark are Compact Framework Compatible
Description
The oldest item in the current queue is removed and returned. The Count is decremented.
Microsoft MSDN Links
System.Collections
System.Collections.Queue
 Author links

 Buy Website Traffic at
 Buywebsitetrafficexperts.com

 Buy Proxies at
 Buyproxies.io
 
 
 
A simple example
program Project1;
{$APPTYPE CONSOLE}

uses
  System.Collections;

var
  MyQueue    : System.Collections.Queue;
  Enumerator : IEnumerator;

begin
  // Create our queue
  MyQueue := Queue.Create;

  // Add entries to the queue
  MyQueue.EnQueue('First');
  MyQueue.EnQueue('Second');
  MyQueue.Enqueue('Third');

  // Display the queue
  Console.WriteLine('Queue contains :');
  Console.WriteLine;
  Enumerator := MyQueue.GetEnumerator;
  while enumerator.MoveNext do
    Console.WriteLine(Enumerator.Current.ToString);

  Console.WriteLine;

  // Get 2 items from the queue
  Console.WriteLine('1st item from the queue : ' +
                    MyQueue.DeQueue.ToString);

  Console.WriteLine('2nd item from the queue : ' +
                    MyQueue.DeQueue.ToString);

  Console.WriteLine;

  // Display the queue again
  Console.WriteLine('Queue now contains :');
  Console.WriteLine;
  Enumerator := MyQueue.GetEnumerator;
  while enumerator.MoveNext do
    Console.WriteLine(Enumerator.Current.ToString);

  Console.Readline;
end.
   Queue contains :
  
   First
   Second
   Third
  
   1st item from the queue : First
   2nd item from the queue : Second
  
   Queue now contains :
  
   Third
 
 
Delphi Programming Neil Moffatt 2002 - 2017. All rights reserved.  |  Contact the author