<commit_before>using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BitMasks
{
    public struct BitMask : IEquatable<BitMask>
    {
        public static readonly BitMask None = new BitMask(bits: new int[0]);

        private const int MaskBytes = 4;
        private const int BitsPerByte = 8;

        private readonly byte[] _bytes;

        public BitMask(int[] bits)
        {
            _bytes = new byte[MaskBytes];

            for (int i = 0; i < bits.Length; ++i)
            {
                ref var bit = ref bits[i];

                int byteIndex = bit / BitsPerByte;
                int bitIndex = bit % BitsPerByte;
                byte mask = (byte) (1 << bitIndex);

                ref var targetByte = ref _bytes[byteIndex];

                targetByte |= mask;
            }
        }

        private BitMask(byte[] bytes)
        {
            _bytes = bytes;
        }

        public bool Equals(BitMask other)
        {
            for (int i = 0; i < MaskBytes; ++i)
            {
                if (_bytes[i] != other._bytes[i])
                    return false;
            }

            return true;
        }

        public override bool Equals(object obj)
        {
            if (obj is BitMask)
                return Equals((BitMask) obj);

            return base.Equals(obj);
        }

        public static bool operator ==(BitMask mask1, BitMask mask2)
        {
            return mask1.Equals(mask2);
        }

        public static bool operator !=(BitMask mask1, BitMask mask2)
        {
            return !mask1.Equals(mask2);
        }

        public static BitMask operator &(BitMask mask1, BitMask mask2)
        {
            var newBytes = new byte[MaskBytes];

            for (int i = 0; i < MaskBytes; ++i)
            {
                newBytes[i] = (byte) (mask1._bytes[i] & mask2._bytes[i]);
            }

            return new BitMask(bytes: newBytes);
        }

        public static BitMask operator |(BitMask mask1, BitMask mask2)
        {
            var newBytes = new byte[MaskBytes];

            for (int i = 0; i < MaskBytes; ++i)
            {
                newBytes[i] = (byte) (mask1._bytes[i] | mask2._bytes[i]);
            }

            return new BitMask(bytes: newBytes);
        }

        public static BitMask operator ~(BitMask mask)
        {
            var newBytes = new byte[MaskBytes];

            for (int i = 0; i < MaskBytes; ++i)
            {
                newBytes[i] = (byte) ~mask._bytes[i];
            }

            return new BitMask(bytes: newBytes);
        }

        public bool Has(BitMask mask)
        {
            for (int i = 0; i < MaskBytes; ++i)
            {
                if ((_bytes[i] & mask._bytes[i]) != mask._bytes[i])
                    return false;
            }

            return true;
        }
    }
}<commit_msg>feat: Use ints instead of bytes<commit_after>using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BitMasks
{
    public struct BitMask : IEquatable<BitMask>
    {
        public static readonly BitMask None = new BitMask(bits: new int[0]);

        private const int MaskInts = 1;
        private const int BitsPerInt = 8 * sizeof(int);

        private int[] _ints;

        public BitMask(int[] bits)
        {
            _ints = new int[MaskInts];

            for (int i = 0; i < bits.Length; ++i)
            {
                ref var bit = ref bits[i];

                int intIndex = bit / BitsPerInt;
                int bitIndex = bit % BitsPerInt;
                int mask = 1 << bitIndex;

                ref var targetInt = ref _ints[intIndex];

                targetInt |= mask;
            }
        }

        private static BitMask CreateWithInts(int[] ints)
        {
            var bitMask = new BitMask();
            bitMask._ints = ints;

            return bitMask;
        }

        public bool Equals(BitMask other)
        {
            for (int i = 0; i < MaskInts; ++i)
            {
                if (_ints[i] != other._ints[i])
                    return false;
            }

            return true;
        }

        public override bool Equals(object obj)
        {
            if (obj is BitMask)
                return Equals((BitMask) obj);

            return base.Equals(obj);
        }

        public static bool operator ==(BitMask mask1, BitMask mask2)
        {
            return mask1.Equals(mask2);
        }

        public static bool operator !=(BitMask mask1, BitMask mask2)
        {
            return !mask1.Equals(mask2);
        }

        public static BitMask operator &(BitMask mask1, BitMask mask2)
        {
            var newInts = new int[MaskInts];

            for (int i = 0; i < MaskInts; ++i)
            {
                newInts[i] = mask1._ints[i] & mask2._ints[i];
            }

            return CreateWithInts(newInts);
        }

        public static BitMask operator |(BitMask mask1, BitMask mask2)
        {
            var newInts = new int[MaskInts];

            for (int i = 0; i < MaskInts; ++i)
            {
                newInts[i] = mask1._ints[i] | mask2._ints[i];
            }

            return CreateWithInts(newInts);
        }

        public static BitMask operator ~(BitMask mask)
        {
            var newInts = new int[MaskInts];

            for (int i = 0; i < MaskInts; ++i)
            {
                newInts[i] = ~mask._ints[i];
            }

            return CreateWithInts(newInts);
        }

        public bool Has(BitMask mask)
        {
            for (int i = 0; i < MaskInts; ++i)
            {
                if ((_ints[i] & mask._ints[i]) != mask._ints[i])
                    return false;
            }

            return true;
        }
    }
}
{'fraction_non_alphanumeric': 0.09857482185273159, 'fraction_numerical': 0.008822531387852052, 'mean_word_length': 1.3300395256916997, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 5, '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': '91625', 'n_tokens_mistral': 1749, 'n_tokens_neox': 1643, 'n_words': 465}