Home  |  Delphi .net Home  |  System.Collections.Queue  |  EnQueue Method
  
EnQueue  
Method  
Add an item to the end of the current Queue
Queue Class
System.Collections NameSpace
CF1.  Procedure EnQueue ( Value : Object ) ;
CF : Methods with this mark are Compact Framework Compatible
Description
A new item is added to the end of the queue. It will be the last to be removed if the queue is now processed.
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('Removing 2 queue items');
  MyQueue.DeQueue;
  MyQueue.DeQueue;

  // Add 2 more items
  Console.WriteLine('Adding 2 new queue items');
  MyQueue.EnQueue('New item 1');
  MyQueue.EnQueue('New item 2');

  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
  
   Removing 2 queue items
   Adding 2 new queue items
  
   Queue now contains :
  
   Third
   New item 1
   New item 2
 
 
Delphi Programming Neil Moffatt 2002 - 2017. All rights reserved.  |  Contact the author