Skip to content

Commit ece52bb

Browse files
committed
Add a Create() method for HashKernelReturnValue.
1 parent 2839828 commit ece52bb

File tree

1 file changed

+17
-9
lines changed

1 file changed

+17
-9
lines changed

ProbabilisticDataStructures/ProbabilisticDataStructures.cs

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -44,16 +44,15 @@ public static uint OptimalK(double fpRate)
4444
/// <param name="data">The data bytes to hash.</param>
4545
/// <param name="algorithm">The hashing algorithm to use.</param>
4646
/// <returns>A HashKernel</returns>
47-
public static HashKernel HashKernel(byte[] data, HashAlgorithm algorithm)
47+
public static HashKernelReturnValue HashKernel(byte[] data, HashAlgorithm algorithm)
4848
{
4949
var hash = new Hash(algorithm);
5050
hash.ComputeHash(data);
5151
var sum = hash.Sum();
52-
return new HashKernel
53-
{
54-
LowerBaseHash = ToBigEndianUInt32(sum.Skip(4).Take(4).ToArray()),
55-
UpperBaseHash = ToBigEndianUInt32(sum.Take(4).ToArray())
56-
};
52+
return HashKernelReturnValue.Create(
53+
ToBigEndianUInt32(sum.Skip(4).Take(4).ToArray()),
54+
ToBigEndianUInt32(sum.Take(4).ToArray())
55+
);
5756
}
5857

5958
public static uint ToBigEndianUInt32(byte[] bytes)
@@ -66,9 +65,18 @@ public static uint ToBigEndianUInt32(byte[] bytes)
6665
}
6766
}
6867

69-
public struct HashKernel
68+
public struct HashKernelReturnValue
7069
{
71-
public uint UpperBaseHash;
72-
public uint LowerBaseHash;
70+
public uint UpperBaseHash { get; private set; }
71+
public uint LowerBaseHash { get; private set; }
72+
73+
public static HashKernelReturnValue Create(uint lowerBaseHash, uint upperBaseHash)
74+
{
75+
return new HashKernelReturnValue
76+
{
77+
UpperBaseHash = upperBaseHash,
78+
LowerBaseHash = lowerBaseHash
79+
};
80+
}
7381
}
7482
}

0 commit comments

Comments
 (0)