コード例 #1
0
        //遅いしメモリの大量消費
        private int Count14ConcurrentDictionaryBoolean_32bpp(byte[] pixels)
        {
            var cd = new System.Collections.Concurrent.ConcurrentDictionary <uint, bool>();

            Parallel.For(0, pixels.Length / 4, i =>
            {
                cd.GetOrAdd((uint)(pixels[i * 4] | (pixels[i * 4 + 1] << 8) | (pixels[i * 4 + 2] << 16) | (pixels[i * 4 + 3] << 24)), true);
            });
            return(cd.Distinct().ToArray().Length);
        }