delphi - 如何获取 Delphi 集类型变量的互补值?

标签 delphi set delphi-2007

从一个集合类型变量开始,如 TAnchors :

  TAnchorKind = (akLeft, akTop, akRight, akBottom);
  TAnchors = set of TAnchorKind;

我试图获得互补的值(value)。
var
  Tmp : TAnchors;
begin
  Tmp := [akLeft];
   ...
end;

我期望得到 TAnchors 的所有值不在 Tmp 中多变的。

例如,从 [akLeft] 开始, 我希望得到 [akTop, akRight, akBottom] .

我试过使用 not运算符,但它似乎不适用于 Sets types .

最佳答案

集合运算符列于 documentation . not运算符未在此处列出,这就是它不能用于集合的原因。但是,您正在寻找差异运算符 - .取包含所有成员的集合与您的集合之间的差异:

[Low(TAnchorKind)..High(TAnchorKind)] - Anchors

关于delphi - 如何获取 Delphi 集类型变量的互补值?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55118380/

相关文章:

python - 如何更改具有多个值(元组)的字典的特定值而不出现 TypeError

delphi - 哪个是与 delphi 2007 一起使用的当前正确的 indy 和 openssl 版本

delphi - 谁将 TCP 窗口大小设置为 0,Indy 还是 Windows?

Delphi TTrayIcon BalloonFlags 自定义图标

Windows 性能分析器缺少 ImageId 事件

delphi - 如何调试Delphi项目?

python - 排序和唯一与集合

delphi - Delphi 2009 和旧式对象类型的问题

python - 如何使用生成器表达式创建多个集合的并集?

delphi - 为什么 Delphi 中的 FillChar 将货币变量视为常量?