<commit_before>﻿namespace TAUtil.Gdi.Palette
{
    using System.Collections;
    using System.Collections.Generic;
    using System.Drawing;

    public class ArrayPalette : IPalette
    {
        private readonly Color[] palette;

        private readonly Dictionary<Color, int> reversePalette;

        public ArrayPalette(int size)
        {
            this.palette = new Color[size];
            this.reversePalette = new Dictionary<Color, int>();
        }

        public int Count
        {
            get
            {
                return this.palette.Length;
            }
        }

        public Color this[int index]
        {
            get
            {
                return this.palette[index];
            }

            set
            {
                this.palette[index] = value;
                this.reversePalette[value] = index;
            }
        }

        public int LookUp(Color color)
        {
            return this.reversePalette[color];
        }

        public int GetNearest(Color color)
        {
            int winIndex = -1;
            int winDistance = int.MaxValue;
            for (var i = 0; i < this.Count; i++)
            {
                var dist = DistanceSquared(this[i], color);
                if (dist == 0)
                {
                    return i;
                }

                if (dist < winDistance)
                {
                    winIndex = i;
                    winDistance = dist;
                }
            }

            return winIndex;
        }

        public IEnumerator<Color> GetEnumerator()
        {
            foreach (var c in this.palette)
            {
                yield return c;
            }
        }

        IEnumerator IEnumerable.GetEnumerator()
        {
            return this.GetEnumerator();
        }

        public static int DistanceSquared(Color c1, Color c2)
        {
            int dr = c2.R - c1.R;
            int dg = c2.G - c1.G;
            int db = c2.B - c1.B;
            return (dr * dr) + (dg * dg) + (db * db);
        }
    }
}<commit_msg>Switch ArrayPalette.DistanceSquared to private<commit_after>﻿namespace TAUtil.Gdi.Palette
{
    using System.Collections;
    using System.Collections.Generic;
    using System.Drawing;

    public class ArrayPalette : IPalette
    {
        private readonly Color[] palette;

        private readonly Dictionary<Color, int> reversePalette;

        public ArrayPalette(int size)
        {
            this.palette = new Color[size];
            this.reversePalette = new Dictionary<Color, int>();
        }

        public int Count
        {
            get
            {
                return this.palette.Length;
            }
        }

        public Color this[int index]
        {
            get
            {
                return this.palette[index];
            }

            set
            {
                this.palette[index] = value;
                this.reversePalette[value] = index;
            }
        }

        public int LookUp(Color color)
        {
            return this.reversePalette[color];
        }

        public int GetNearest(Color color)
        {
            int winIndex = -1;
            int winDistance = int.MaxValue;
            for (var i = 0; i < this.Count; i++)
            {
                var dist = DistanceSquared(this[i], color);
                if (dist == 0)
                {
                    return i;
                }

                if (dist < winDistance)
                {
                    winIndex = i;
                    winDistance = dist;
                }
            }

            return winIndex;
        }

        public IEnumerator<Color> GetEnumerator()
        {
            foreach (var c in this.palette)
            {
                yield return c;
            }
        }

        IEnumerator IEnumerable.GetEnumerator()
        {
            return this.GetEnumerator();
        }

        private static int DistanceSquared(Color c1, Color c2)
        {
            int dr = c2.R - c1.R;
            int dg = c2.G - c1.G;
            int db = c2.B - c1.B;
            return (dr * dr) + (dg * dg) + (db * db);
        }
    }
}
{'fraction_non_alphanumeric': 0.08428300094966762, 'fraction_numerical': 0.0052231718898385565, 'mean_word_length': 1.046138902379796, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5917070', 'n_tokens_mistral': 1167, 'n_tokens_neox': 1100, 'n_words': 265}