Home  |  Delphi .net Home  |  System.Collections.Queue  |  Contains Method
Contains  
Method  
Returns true if the current Queue contains the given Value
Queue Class
System.Collections NameSpace
CF1.  Function Contains ( Value : Object; ) : Boolean;
CF : Methods with this mark are Compact Framework Compatible
Description
The Contains method searches the current Queue for an entry matching Value, returning true if found, otherwise false.
Microsoft MSDN Links
System.Collections
System.Collections.Queue
 
 
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
  Enumerator := MyQueue.GetEnumerator;
  while enumerator.MoveNext do
    Console.WriteLine(Enumerator.Current.ToString);

  Console.WriteLine;

  if MyQueue.Contains('Second')
  then Console.WriteLine('MyQueue contains ''Second''')
  else Console.WriteLine('MyQueue does not contain ''Second''');

  if MyQueue.Contains('Fourth')
  then Console.WriteLine('MyQueue contains ''Fourth''')
  else Console.WriteLine('MyQueue does not contain ''Fourth''');

  Console.Readline;
end.
Show full unit code
  First
  Second
  Third
  
  MyQueue contains 'Second'
  MyQueue does not contain 'Fourth'
 
 
Delphi Programming © Neil Moffatt All rights reserved.  |  Contact the author