Home  |  Delphi .net Home  |  System.Collections.Queue  |  TrimToSize Method
  
TrimToSize  
Method  
Removes unused space in the current Queue
Queue Class
System.Collections NameSpace
CF1.  Procedure TrimToSize ;
CF : Methods with this mark are Compact Framework Compatible
Description
The capacity ofthe Queue is reduced to just hold the current Count of elements.
Notes
There is no Capacity property that can be used to inspect or set the Queue capacity. (Other collections, such as ArrayList do have).
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;

begin
  // Create our queue with default capacity of 16 items
  MyQueue := Queue.Create;

  // Fill it
  MyQueue.Enqueue('First');
  MyQueue.Enqueue('Second');
  MyQueue.Enqueue('Third');

  Console.WriteLine('MyQueue Count = {0}', MyQueue.Count.ToString);
  Console.WriteLine;

  // Trim to size
  MyQueue.TrimToSize;

  // The count is not affected
  // There is no 'Capacity' property that can be inspected
  Console.WriteLine('MyQueue Count = {0}', MyQueue.Count.ToString);

  Console.Readline;
end.
   MyQueue count = 3
  
   MyQueue count = 3
 
 
Delphi Programming Neil Moffatt 2002 - 2017. All rights reserved.  |  Contact the author