zoukankan      html  css  js  c++  java
  • 详测 Generics Collections TQueue (1): Enqueue、Dequeue、Peek

    unit Unit1;
    
    interface
    
    uses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs, StdCtrls;
    
    type
      TForm1 = class(TForm)
        Button1: TButton;
        procedure Button1Click(Sender: TObject);
      end;
    
    var
      Form1: TForm1;
    
    implementation
    
    {$R *.dfm}
    
    uses Generics.Collections;
    
    procedure TForm1.Button1Click(Sender: TObject);
    var
      Queue: TQueue<string>;
      s,str: string;
    begin
      Queue := TQueue<string>.Create();
    
      {入列}
      Queue.Enqueue('AAA');
      Queue.Enqueue('BBB');
      Queue.Enqueue('CCC');
      Queue.Enqueue('DDD');
    
      {查看}
      str := '';
      for s in Queue do str := str + s + ' ';
      ShowMessage(str); {AAA BBB CCC DDD}
    
      {出列, 并查看出列元素}
      ShowMessage(Queue.Dequeue); {AAA}
    
      str := '';
      for s in Queue do str := str + s + ' ';
      ShowMessage(str); {BBB CCC DDD}
    
      {查看下一个将要出列的是...}
      ShowMessage(Queue.Peek); {BBB}
    
      Queue.Free;
    end;
    
    end.
    
  • 相关阅读:
    HDU 4389 X mod f(x)
    SRM 400(1-250pt, 1-500pt)
    FZU 2113 Jason的特殊爱好
    POJ 3208 Apocalypse Someday
    HDU 4734 F(x)
    HDU 3555 Bomb
    HDU 2089 不要62
    poj2488(A Knight's Journey)
    poj3267(The Cow Lexicon)
    poj2513(Colored Sticks)
  • 原文地址:https://www.cnblogs.com/del/p/1580870.html
Copyright © 2011-2022 走看看