docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Struct NativeBitArray.ReadOnly

    A read-only alias for the value of a UnsafeBitArray. Does not have its own allocated storage.

    Namespace: Unity.Collections
    Assembly: Unity.Collections.dll
    Syntax
    [NativeContainer]
    [NativeContainerIsReadOnly]
    public struct NativeBitArray.ReadOnly

    Properties

    Length

    Returns the number of bits.

    Declaration
    public readonly int Length { get; }
    Property Value
    Type Description
    int

    The number of bits.

    Methods

    CountBits(int, int)

    Returns the number of bits in a range that are 1.

    Declaration
    public readonly int CountBits(int pos, int numBits = 1)
    Parameters
    Type Name Description
    int pos

    Index of the bit at which to start searching.

    int numBits

    Number of bits to test. Defaults to 1.

    Returns
    Type Description
    int

    The number of bits in a range of bits that are 1.

    Exceptions
    Type Condition
    ArgumentException

    Thrown if pos is out of bounds or numBits is less than 1.

    Find(int, int)

    Finds the first length-N contiguous sequence of 0 bits in this bit array.

    Declaration
    public readonly int Find(int pos, int numBits)
    Parameters
    Type Name Description
    int pos

    Index at which to start searching.

    int numBits

    Number of contiguous 0 bits to look for.

    Returns
    Type Description
    int

    The index in this array where the sequence is found. The index will be greater than or equal to pos. Returns -1 if no occurrence is found.

    Find(int, int, int)

    Finds the first length-N contiguous sequence of 0 bits in this bit array. Searches only a subsection.

    Declaration
    public readonly int Find(int pos, int count, int numBits)
    Parameters
    Type Name Description
    int pos

    Index at which to start searching.

    int count

    Number of bits to search.

    int numBits

    Number of contiguous 0 bits to look for.

    Returns
    Type Description
    int

    The index in this array where the sequence is found. The index will be greater than or equal to pos but less than pos + count. Returns -1 if no occurrence is found.

    GetBits(int, int)

    Returns a ulong which has bits copied from this array.

    Declaration
    public readonly ulong GetBits(int pos, int numBits = 1)
    Parameters
    Type Name Description
    int pos

    Index of the first bit to get.

    int numBits

    Number of bits to get (must be between 1 and 64).

    Returns
    Type Description
    ulong

    A ulong which has bits copied from this array.

    Remarks

    The source bits in this array run from index pos up to (but not including) pos + numBits. No exception is thrown if pos + numBits exceeds the length.

    The first source bit is copied to the lowest bit of the ulong; the second source bit is copied to the second-lowest bit of the ulong; and so forth. Any remaining bits in the ulong will be 0.

    Exceptions
    Type Condition
    ArgumentException

    Thrown if pos is out of bounds or if numBits is not between 1 and 64.

    IsSet(int)

    Returns true if the bit at an index is 1.

    Declaration
    public readonly bool IsSet(int pos)
    Parameters
    Type Name Description
    int pos

    Index of the bit to test.

    Returns
    Type Description
    bool

    True if the bit at the index is 1.

    Exceptions
    Type Condition
    ArgumentException

    Thrown if pos is out of bounds.

    In This Article
    Back to top
    Copyright © 2024 Unity Technologies — Trademarks and terms of use
    • Legal
    • Privacy Policy
    • Cookie Policy
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)