1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
|
function SizeOfSetShai(PSet: pointer; SizeOfSet: Byte = 32): Integer;
const
CountBitByHalfByte: array[0..15] of Integer = (0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4);
type
PHashSet = ^THashSet;
THashSet = array [0..31] of Byte;
var
i, vHS: Byte;
pHS: PHashSet;
begin
Result := 0;
pHS := PSet;
for i := 0 to SizeOfSet-1 do
begin
vHS := pHS^[i] and $0F;
if vHS > 0 then
Inc(Result, CountBitByHalfByte[vHS]);
vHS := pHS^[i] shr 4;
if vHS > 0 then
begin
Inc(Result, CountBitByHalfByte[vHS]);
end;
end;
end; |
Partager