zoukankan      html  css  js  c++  java
  • delphi集合的用法

    unit Unit4;
     
    interface
     
    uses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs, StdCtrls;
     
    type
      TEnum = (One, Two, Three, Four, Five, Six, Seven, Eight, Nine, Ten);
      TSetEnum = set of TEnum;
      TForm4 = class(TForm)
        GroupBox1: TGroupBox;
        GroupBox2: TGroupBox;
        Button3: TButton;
        Button4: TButton;
        Button5: TButton;
        Button6: TButton;
        Button7: TButton;
        Button8: TButton;
        Button9: TButton;
    procedure Button3Click(Sender: TObject); procedure Button5Click(Sender: TObject); procedure Button6Click(Sender: TObject); procedure Button7Click(Sender: TObject); procedure Button4Click(Sender: TObject); procedure Button8Click(Sender: TObject); procedure Button9Click(Sender: TObject); private SetEnum, SetEnum1, SetEnum2: TSetEnum ; { Private declarations } public { Public declarations } end; var Form4: TForm4; implementation {$R *.dfm} //初始化 procedure TForm4.Button3Click(Sender: TObject); begin SetEnum := [one, Two]; SetEnum1 := [Three, Nine, Ten] end; //集合减少 procedure TForm4.Button5Click(Sender: TObject); begin SetEnum := SetEnum - [Two]; end; //集合增加 procedure TForm4.Button6Click(Sender: TObject); begin SetEnum := SetEnum + [Three]; end; //集合减少 procedure TForm4.Button7Click(Sender: TObject); begin Exclude(SetEnum, One); end; //集合增加 procedure TForm4.Button4Click(Sender: TObject); begin Include(SetEnum, Four); Include(SetEnum, Ten); end; //执行校验 procedure TForm4.Button8Click(Sender: TObject); begin if One in SetEnum then begin ShowMessage('Exclude函数执行失败'); end else if Two in SetEnum then begin ShowMessage('SetEnum - [Two]执行失败'); end else if not (Three in SetEnum) then begin ShowMessage('SetEnum + [Three]执行失败'); end else if not (Four in SetEnum) then begin ShowMessage('Include函数执行失败'); end else if not (ten in SetEnum) then begin ShowMessage('Include函数执行失败'); end else begin ShowMessage('执行成功!'); end; end; //取得集合的交集 procedure TForm4.Button9Click(Sender: TObject); begin SetEnum2 := SetEnum1 * SetEnum; if Three in SetEnum2 then begin ShowMessage('交集成功执行成功'); end; end; end.
  • 相关阅读:
    get started with laravel
    redis消息队列
    javascript模板引擎Mustache
    YIi 权限管理和基于角色的访问控制
    Yii CDbCriteria
    C++ 推断进程是否存在
    IE浏览器开启对JavaScript脚本的支持
    最小公约数(欧几里得算法&&stein算法)
    Nyoj 43 24 Point game 【DFS】
    【蓝桥杯】PREV-5 错误票据
  • 原文地址:https://www.cnblogs.com/hejoy91/p/3154274.html
Copyright © 2011-2022 走看看