<commit_before>using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using WpfMath.Boxes;

namespace WpfMath.Atoms
{
    // Atom representing horizontal row of other atoms, separated by glue.
    internal class RowAtom : Atom, IRow
    {
        // Set of atom types that make previous atom of BinaryOperator type change to Ordinary type.
        private static BitArray binaryOperatorChangeSet;

        // Set of atom types that may need kern, or together with previous atom, be replaced by ligature.
        private static BitArray ligatureKernChangeSet;

        static RowAtom()
        {
            binaryOperatorChangeSet = new BitArray(16);
            binaryOperatorChangeSet.Set((int)TexAtomType.BinaryOperator, true);
            binaryOperatorChangeSet.Set((int)TexAtomType.BigOperator, true);
            binaryOperatorChangeSet.Set((int)TexAtomType.Relation, true);
            binaryOperatorChangeSet.Set((int)TexAtomType.Opening, true);
            binaryOperatorChangeSet.Set((int)TexAtomType.Punctuation, true);

            ligatureKernChangeSet = new BitArray(16);
            ligatureKernChangeSet.Set((int)TexAtomType.Ordinary, true);
            ligatureKernChangeSet.Set((int)TexAtomType.BigOperator, true);
            ligatureKernChangeSet.Set((int)TexAtomType.BinaryOperator, true);
            ligatureKernChangeSet.Set((int)TexAtomType.Relation, true);
            ligatureKernChangeSet.Set((int)TexAtomType.Opening, true);
            ligatureKernChangeSet.Set((int)TexAtomType.Closing, true);
            ligatureKernChangeSet.Set((int)TexAtomType.Punctuation, true);
        }

        public RowAtom(SourceSpan source, Atom baseAtom)
            : this(
                source,
                baseAtom is RowAtom
                    ? (IEnumerable<Atom>) ((RowAtom) baseAtom).Elements
                    : new[] { baseAtom })
        {
        }

        public RowAtom(SourceSpan source)
            : base(source)
        {
            this.Elements = new List<Atom>().AsReadOnly();
        }

        private RowAtom(SourceSpan source, DummyAtom previousAtom, ReadOnlyCollection<Atom> elements)
            : base(source)
        {
            this.PreviousAtom = previousAtom;
            this.Elements = elements;
        }

        internal RowAtom(SourceSpan source, IEnumerable<Atom> elements)
            : base(source) =>
            this.Elements = elements.Where(x => x != null ).ToList().AsReadOnly();

        public DummyAtom PreviousAtom { get; }

        public ReadOnlyCollection<Atom> Elements { get; }

        public Atom WithPreviousAtom(DummyAtom previousAtom) =>
            new RowAtom(this.Source, previousAtom, this.Elements);
<commit_msg>Fix the code style, add a TODO (#203)<commit_after>using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using WpfMath.Boxes;

namespace WpfMath.Atoms
{
    // Atom representing horizontal row of other atoms, separated by glue.
    internal class RowAtom : Atom, IRow
    {
        // Set of atom types that make previous atom of BinaryOperator type change to Ordinary type.
        private static BitArray binaryOperatorChangeSet;

        // Set of atom types that may need kern, or together with previous atom, be replaced by ligature.
        private static BitArray ligatureKernChangeSet;

        static RowAtom()
        {
            binaryOperatorChangeSet = new BitArray(16);
            binaryOperatorChangeSet.Set((int)TexAtomType.BinaryOperator, true);
            binaryOperatorChangeSet.Set((int)TexAtomType.BigOperator, true);
            binaryOperatorChangeSet.Set((int)TexAtomType.Relation, true);
            binaryOperatorChangeSet.Set((int)TexAtomType.Opening, true);
            binaryOperatorChangeSet.Set((int)TexAtomType.Punctuation, true);

            ligatureKernChangeSet = new BitArray(16);
            ligatureKernChangeSet.Set((int)TexAtomType.Ordinary, true);
            ligatureKernChangeSet.Set((int)TexAtomType.BigOperator, true);
            ligatureKernChangeSet.Set((int)TexAtomType.BinaryOperator, true);
            ligatureKernChangeSet.Set((int)TexAtomType.Relation, true);
            ligatureKernChangeSet.Set((int)TexAtomType.Opening, true);
            ligatureKernChangeSet.Set((int)TexAtomType.Closing, true);
            ligatureKernChangeSet.Set((int)TexAtomType.Punctuation, true);
        }

        public RowAtom(SourceSpan source, Atom baseAtom)
            : this(
                source,
                baseAtom is RowAtom
                    ? (IEnumerable<Atom>) ((RowAtom) baseAtom).Elements
                    : new[] { baseAtom })
        {
        }

        public RowAtom(SourceSpan source)
            : base(source)
        {
            this.Elements = new List<Atom>().AsReadOnly();
        }

        private RowAtom(SourceSpan source, DummyAtom previousAtom, ReadOnlyCollection<Atom> elements)
            : base(source)
        {
            this.PreviousAtom = previousAtom;
            this.Elements = elements;
        }

        internal RowAtom(SourceSpan source, IEnumerable<Atom> elements)
            : base(source) =>
            this.Elements = elements.Where(x => x != null).ToList().AsReadOnly();
            // TODO[F]: Fix this with C# 8 migration: there shouldn't be nullable atoms in this collection

        public DummyAtom PreviousAtom { get; }

        public ReadOnlyCollection<Atom> Elements { get; }

        public Atom WithPreviousAtom(DummyAtom previousAtom) =>
            new RowAtom(this.Source, previousAtom, this.Elements);

{'fraction_non_alphanumeric': 0.08869257950530035, 'fraction_numerical': 0.0021201413427561835, 'mean_word_length': 2.5492163009404387, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 19, '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': '5690675', 'n_tokens_mistral': 1593, 'n_tokens_neox': 1550, 'n_words': 341}