<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<div class="moz-cite-prefix">Am 11.03.2013 14:43, schrieb Jonas
Maebe:<br>
</div>
<blockquote
cite="mid:3C8162F9-BBA1-4E92-8123-3C7CB063229F@elis.ugent.be"
type="cite"><br>
<div>
<div>On 11 Mar 2013, at 14:32, Daniel Gaspary wrote:</div>
<br class="Apple-interchange-newline">
<blockquote type="cite"><span class="Apple-style-span"
style="border-collapse: separate; color: rgb(0, 0, 0);
font-family: Monaco; font-style: normal; font-variant:
normal; font-weight: normal; letter-spacing: normal;
line-height: normal; orphans: 2; text-align: -webkit-auto;
text-indent: 0px; text-transform: none; white-space: normal;
widows: 2; word-spacing: 0px;
-webkit-border-horizontal-spacing: 0px;
-webkit-border-vertical-spacing: 0px;
-webkit-text-decorations-in-effect: none;
-webkit-text-size-adjust: auto; -webkit-text-stroke-width:
0px; font-size: medium; "><span class="Apple-style-span"
style="font-family: monospace; ">In my case the enum has
near 600 elements.<br>
<br>
TMyEnum = (me1, me2...);<br>
<br>
The set though would never be used to contain more than
256.<br>
<br>
TMySet = set of TMyEnum;<br>
<br>
Is it not viable to modify the compiler to compile the
code and raise<br>
an exception if I try to add more than 256 elements to the
set ?<br>
</span></span></blockquote>
</div>
<br>
<div>A set is basically a bitpacked array of boolean. Element X is
set to true if you add X to the set, and to false if you remove
it again. That means that if you have a set with 600 possible
values, you need at least 600 bits, regardless of how many
elements are inside it.</div>
<div><br>
</div>
<div>The above also shows an alternative to sets in that case: you
can use a bitpacked array[TMyEnum] of boolean instead. Of
course, then you can't use the regular set operators.</div>
</blockquote>
If the array is a named one (e.g. "TMyArraySet = bitpacked
array[TMyEnum] of Boolean") then operator overloading could be
used...<br>
<br>
Regards,<br>
Sven<br>
</body>
</html>