All pastes #1673033 Raw Edit

AnarkiNet

public text v1 · immutable
#1673033 ·published 2009-11-16 04:43 UTC
rendered paste body
internal static class __HashCode
{
    private static readonly int[] seeds = new int[] { 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67 };
 
    internal static int Calculate(params object[] fields)
    {
        int seed = seeds[fields.Length % seeds.Length];
        int prefix = seeds[(seed + 2) % seeds.Length];

        int result = seed;

        unchecked
        {
            for (int i = 0; i < fields.Length; i++)
                if (fields[i] != null)
                    result += prefix + (result ^ fields[i].GetHashCode());
        }

        return result;
    }
}