< Summary

Class:GDX.Collections.BitArray32
Assembly:GDX
File(s):./Packages/com.dotbunny.gdx/GDX/Collections/BitArray32.cs
Covered lines:0
Uncovered lines:13
Coverable lines:13
Total lines:63
Line coverage:0% (0 of 13)
Covered branches:0
Total branches:0
Covered methods:0
Total methods:3
Method coverage:0% (0 of 3)

Coverage History

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
BitArray32(...)0%2100%

File(s)

./Packages/com.dotbunny.gdx/GDX/Collections/BitArray32.cs

#LineLine coverage
 1// Copyright (c) 2020-2024 dotBunny Inc.
 2// dotBunny licenses this file to you under the BSL-1.0 license.
 3// See the LICENSE file in the project root for more information.
 4
 5using System;
 6using System.Runtime.CompilerServices;
 7
 8namespace GDX.Collections
 9{
 10    /// <summary>
 11    ///     A 32-bit array.
 12    /// </summary>
 13    /// <example>
 14    ///     Useful for packing a bunch of data with known indices tightly.
 15    ///     <code>
 16    ///         if(myBitArray32[1])
 17    ///         {
 18    ///             BeAwesome();
 19    ///         }
 20    ///     </code>
 21    /// </example>
 22    [Serializable]
 23    public struct BitArray32
 24    {
 25        /// <summary>
 26        ///     First reserved <see cref="uint" /> memory block (32-bits).
 27        /// </summary>
 28        /// <remarks>Indices 0-31</remarks>
 29        public uint Bits0;
 30
 31        /// <summary>
 32        ///     Create a new <see cref="BitArray32" /> based on provided <paramref name="bits0" />.
 33        /// </summary>
 34        /// <param name="bits0">An existing value to be used to create the backing data for a <see cref="BitArray32" /><
 35        public BitArray32(uint bits0)
 036        {
 037            Bits0 = bits0;
 038        }
 39
 40        /// <summary>
 41        ///     Access bit in array.
 42        /// </summary>
 43        /// <param name="index">Target bit index.</param>
 44        public bool this[byte index]
 45        {
 46            [MethodImpl(MethodImplOptions.AggressiveInlining)]
 047            get => (Bits0 & (uint)(1 << index)) != 0;
 48
 49            [MethodImpl(MethodImplOptions.AggressiveInlining)]
 50            set
 051            {
 052                if (value)
 053                {
 054                    Bits0 |= (uint)1 << index;
 055                }
 56                else
 057                {
 058                    Bits0 &= ~((uint)1 << index);
 059                }
 060            }
 61        }
 62    }
 63}