tags:

views:

746

answers:

2

If I have a type defined as a set of an enumerated type, it's easy to create an empty set with [], but how do I create a full set?

EDIT: Yeah, the obvious solution is to use a for loop. That's also a really bad solution if there's another way. Does anyone know of a way that'll work in constant time?

+5  A: 

Per Barry's suggestion:

FillChar(VarSet, SizeOf(VarSet), $FF);
Jim McKeeth
+5  A: 

Low() and High() are "compiler magic" functions that can be evaluated at compile time. This allows their use in constant declarations like the following:

var
  MySet : TBorderIcons;
  MySet2 : TBorderIcons;
const
  AllIcons : TBorderIcons = [Low(TBorderIcon)..High(TBorderIcon)];
begin
  MySet := [Low(TBorderIcon)..High(TBorderIcon)];
  MySet2 := AllIcons;
end;
Gerry
Dude! That was GOOD! ;) Thank you!
F.D.Castel
I'm even deleting my own answer, after that ;)
F.D.Castel