Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.

ID: 14018, Counting number of elements in a set

by Robert Lee Email:

Download Details
FTP  download also available 0 bytes
CDN Login Required to Download. (You will be redirected to the login page if you click on the Download Link)
To download this, you must have registered:
A free membership

For Delphi, Version 1.0  to 1.0 23 downloads
Copyright: No significant restrictions

Size: 0 bytes
Updated on Thu, 11 Nov 1999 00:00:00 GMT
Originally uploaded on Thu, 11 Nov 1999 00:00:00 GMT
This routine will count the number of elements contained within a set. Alternatively it can be used to count the number of bits set in a structure of any length. -----------------------
function card(var tar; size: integer): integer;
// Returns the number of bits set in the Size bytes starting from Tar.
const // nibble table
  Ca: array[0..15] of integer=( 0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4);
    ab: TbyteArray absolute tar;
    j: integer;
  for j := 0 to size - 1 do begin
    inc(result, Ca[ab[j] and $F] + Ca[ab[j] shr 4]);
  mySet: TsomeSetType;
  myCount := card(mySet, sizeof(mySet));

   Latest Comments  View All Add New

Move mouse over comment to see the full text

Could not retrieve comments. Please try again later.

Server Response from: ETNACDC03