< Summary

Class:GDX.Collections.BitArray64
Assembly:GDX
File(s):./Packages/com.dotbunny.gdx/GDX/Collections/BitArray64.cs
Covered lines:0
Uncovered lines:8
Coverable lines:8
Total lines:57
Line coverage:0% (0 of 8)
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
BitArray64(...)0%2100%

File(s)

./Packages/com.dotbunny.gdx/GDX/Collections/BitArray64.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 64-bit array.
 12    /// </summary>
 13    /// <example>
 14    ///     Useful for packing a bunch of data with known indices tightly.
 15    ///     <code>
 16    ///         if(myBitArray64[1])
 17    ///         {
 18    ///             BeAwesome();
 19    ///         }
 20    ///     </code>
 21    /// </example>
 22    [Serializable]
 23    public struct BitArray64
 24    {
 25        /// <summary>
 26        ///     First reserved <see cref="long" /> memory block (64-bits).
 27        /// </summary>
 28        /// <remarks>Indices 0-63</remarks>
 29        public long Bits0;
 30
 31        /// <summary>
 32        ///     Create a new <see cref="BitArray64" /> 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="BitArray64" /><
 35        public BitArray64(long 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 & (1 << index)) != 0;
 48
 49            [MethodImpl(MethodImplOptions.AggressiveInlining)]
 50            set
 051            {
 052                long negativeValue = value ? -1 : 0;
 053                Bits0 ^= (negativeValue ^ Bits0) & (1L << index);
 054            }
 55        }
 56    }
 57}