BitVector32.CreateMask メソッド

定義

ビット フラグとして設定されている BitVector32 内の個々のビットを取得するために使用できる一連のマスクを作成します。

オーバーロード

名前 説明
CreateMask()

ビット フラグとして設定されている BitVector32 内の個々のビットを取得するために使用できる一連のマスクに最初のマスクを作成します。

CreateMask(Int32)

指定したマスクの後に追加のマスクを作成します。一連のマスクを使用して、ビット フラグとして設定されている BitVector32 内の個々のビットを取得できます。

次のコード例は、マスクを作成して使用する方法を示しています。

using System;
using System.Collections.Specialized;

public class SamplesBitVector32  {

   public static void Main()  {

      // Creates and initializes a BitVector32 with all bit flags set to FALSE.
      BitVector32 myBV = new BitVector32( 0 );

      // Creates masks to isolate each of the first five bit flags.
      int myBit1 = BitVector32.CreateMask();
      int myBit2 = BitVector32.CreateMask( myBit1 );
      int myBit3 = BitVector32.CreateMask( myBit2 );
      int myBit4 = BitVector32.CreateMask( myBit3 );
      int myBit5 = BitVector32.CreateMask( myBit4 );
      Console.WriteLine( "Initial:               \t{0}", myBV.ToString() );

      // Sets the third bit to TRUE.
      myBV[myBit3] = true;
      Console.WriteLine( "myBit3 = TRUE          \t{0}", myBV.ToString() );

      // Combines two masks to access multiple bits at a time.
      myBV[myBit4 + myBit5] = true;
      Console.WriteLine( "myBit4 + myBit5 = TRUE \t{0}", myBV.ToString() );
      myBV[myBit1 | myBit2] = true;
      Console.WriteLine( "myBit1 | myBit2 = TRUE \t{0}", myBV.ToString() );
   }
}

/*
This code produces the following output.

Initial:                BitVector32{00000000000000000000000000000000}
myBit3 = TRUE           BitVector32{00000000000000000000000000000100}
myBit4 + myBit5 = TRUE  BitVector32{00000000000000000000000000011100}
myBit1 | myBit2 = TRUE  BitVector32{00000000000000000000000000011111}

*/
Imports System.Collections.Specialized


Public Class SamplesBitVector32

   Public Shared Sub Main()

      ' Creates and initializes a BitVector32 with all bit flags set to FALSE.
      Dim myBV As New BitVector32(0)
      
      ' Creates masks to isolate each of the first five bit flags.
      Dim myBit1 As Integer = BitVector32.CreateMask()
      Dim myBit2 As Integer = BitVector32.CreateMask(myBit1)
      Dim myBit3 As Integer = BitVector32.CreateMask(myBit2)
      Dim myBit4 As Integer = BitVector32.CreateMask(myBit3)
      Dim myBit5 As Integer = BitVector32.CreateMask(myBit4)
      Console.WriteLine("Initial:               " + ControlChars.Tab + "{0}", myBV.ToString())
      
      ' Sets the third bit to TRUE.
      myBV(myBit3) = True
      Console.WriteLine("myBit3 = TRUE          " + ControlChars.Tab + "{0}", myBV.ToString())
      
      ' Combines two masks to access multiple bits at a time.
      myBV((myBit4 + myBit5)) = True
      Console.WriteLine("myBit4 + myBit5 = TRUE " + ControlChars.Tab + "{0}", myBV.ToString())
      myBV((myBit1 Or myBit2)) = True
      Console.WriteLine("myBit1 | myBit2 = TRUE " + ControlChars.Tab + "{0}", myBV.ToString())

   End Sub

End Class


' This code produces the following output.
'
' Initial:                BitVector32{00000000000000000000000000000000}
' myBit3 = TRUE           BitVector32{00000000000000000000000000000100}
' myBit4 + myBit5 = TRUE  BitVector32{00000000000000000000000000011100}
' myBit1 | myBit2 = TRUE  BitVector32{00000000000000000000000000011111}

CreateMask()

ビット フラグとして設定されている BitVector32 内の個々のビットを取得するために使用できる一連のマスクに最初のマスクを作成します。

public:
 static int CreateMask();
public static int CreateMask();
static member CreateMask : unit -> int
Public Shared Function CreateMask () As Integer

返品

BitVector32の最初のビット フラグを分離するマスク。

注釈

CreateMask()を使用して系列の最初のマスクを作成し、後続のすべてのマスクにCreateMask(int)します。

同じビット フラグを参照する複数のマスクを作成できます。

結果のマスクは、 BitVector32内の 1 つのビット フラグのみを分離します。 ビットごとの OR 演算を使用してマスクを組み合わせて、 BitVector32内の複数のビット フラグを分離するマスクを作成できます。

セクションとして設定されている BitVector32 でマスクを使用すると、予期しない結果が発生する可能性があります。

このメソッドは O(1) 操作です。

適用対象

CreateMask(Int32)

指定したマスクの後に追加のマスクを作成します。一連のマスクを使用して、ビット フラグとして設定されている BitVector32 内の個々のビットを取得できます。

public:
 static int CreateMask(int previous);
public static int CreateMask(int previous);
static member CreateMask : int -> int
Public Shared Function CreateMask (previous As Integer) As Integer

パラメーター

previous
Int32

前のビット フラグを示すマスク。

返品

previousBitVector32内を指すビット フラグに続くビット フラグを分離するマスク。

例外

previous は、 BitVector32の最後のビット フラグを示します。

注釈

CreateMask()を使用して系列の最初のマスクを作成し、後続のすべてのマスクにCreateMask(int)します。

同じビット フラグを参照する複数のマスクを作成できます。

結果のマスクは、 BitVector32内の 1 つのビット フラグのみを分離します。 ビットごとの OR 演算を使用してマスクを組み合わせて、 BitVector32内の複数のビット フラグを分離するマスクを作成できます。

セクションとして設定されている BitVector32 でマスクを使用すると、予期しない結果が発生する可能性があります。

このメソッドは O(1) 操作です。

適用対象