1. Home
  2. Computing & Technology
  3. Delphi Programming
Delphi for .NET FCL Examples Reference
Queue namespace
System.Collections
Declaration
Queue = class(System.Object, ICollection, IEnumerable, ICloneable);
Description
Represents a first-in, first-out collection of objects.
Example
program System_Collections_Queue;
{$APPTYPE CONSOLE}
{$AUTOBOX ON}

uses
  System.Collections;

type
  SamplesQueue = class
  public
    class procedure Main;
  private
    class procedure PrintValues(myCollection: IEnumerable);
  end;

{ SamplesQueue }

class procedure SamplesQueue.Main;
var
  myQ: Queue;
begin
  // Creates and initializes a new Queue.
  myQ := Queue.Create;
  myQ.Enqueue('Hello');
  myQ.Enqueue('World');
  myQ.Dequeue;
  myQ.Enqueue('Delphi for .NET');
  myQ.Enqueue('World');
  myQ.Enqueue('!');

  Console.WriteLine('myQ');
  Console.WriteLine(''#9'Count:    {0}', myQ.Count);
  Console.Write(''#9'Values:');

  PrintValues(myQ);
end;

class procedure SamplesQueue.PrintValues
                (myCollection: IEnumerable);
var
  myEnumerator: System.Collections.IEnumerator;
begin
  myEnumerator := myCollection.GetEnumerator;
  while myEnumerator.MoveNext do
  begin
    Console.Write(''#9'{0}', 
                  myEnumerator.Current);
  end;
  Console.WriteLine;
end;

//test program
begin
  SamplesQueue.Main;
end.
Example output
myQ
 Count:    4
 Values:   World Delphi for .NET World !

Looking for Delphi for .NET examples? Look no further, Delphi for .NET FCL Examples Reference is what you are looking for!

Explore Delphi Programming
About.com Special Features

Stay connected and entertained with reviews on tips on the latest HDTVs, cellphones and more. More >

Easy ways to connect two computers for networking purposes. More >

  1. Home
  2. Computing & Technology
  3. Delphi Programming

©2009 About.com, a part of The New York Times Company.

All rights reserved.