docs.unity3d.com
    目次を表示する/隠す

    Struct UnsafeBitArray.ReadOnly

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

    Namespace: Unity.Collections.LowLevel.Unsafe
    Syntax
    public struct ReadOnly

    Fields

    Length

    The number of bits.

    Declaration
    public int Length
    Field Value
    Type Description
    Int32

    The number of bits.

    Ptr

    Pointer to the data.

    Declaration
    [NativeDisableUnsafePtrRestriction]
    public ulong *Ptr
    Field Value
    Type Description
    UInt64*

    Pointer to the data.

    Methods

    CountBits(Int32, Int32)

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

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

    Index of the bit at which to start searching.

    Int32 numBits

    Number of bits to test. Defaults to 1.

    Returns
    Type Description
    Int32

    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(Int32, Int32)

    Returns the index of the first occurrence in this array of N contiguous 0 bits.

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

    Index of the bit at which to start searching.

    Int32 numBits

    Number of contiguous 0 bits to look for.

    Returns
    Type Description
    Int32

    The index of the first occurrence in this array of numBits contiguous 0 bits. Range is pos up to (but not including) the length of this array. Returns -1 if no occurrence is found.

    Remarks

    The search is linear.

    Find(Int32, Int32, Int32)

    Returns the index of the first occurrence in this array of a given number of contiguous 0 bits.

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

    Index of the bit at which to start searching.

    Int32 count

    Number of indexes to consider as the return value.

    Int32 numBits

    Number of contiguous 0 bits to look for.

    Returns
    Type Description
    Int32

    The index of the first occurrence in this array of numBits contiguous 0 bits. Range is pos up to (but not including) pos + count. Returns -1 if no occurrence is found.

    Remarks

    The search is linear.

    GetBits(Int32, Int32)

    Returns a ulong which has bits copied from this array.

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

    Index of the first bit to get.

    Int32 numBits

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

    Returns
    Type Description
    UInt64

    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(Int32)

    Returns true if the bit at an index is 1.

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

    Index of the bit to test.

    Returns
    Type Description
    Boolean

    True if the bit at the index is 1.

    Exceptions
    Type Condition
    ArgumentException

    Thrown if pos is out of bounds.

    トップに戻る
    Copyright © 2023 Unity Technologies — 商標と利用規約
    • 法律関連
    • プライバシーポリシー
    • クッキー
    • 私の個人情報を販売または共有しない
    • Your Privacy Choices (Cookie Settings)