BitVector32.CreateMask 메서드

정의

비트 플래그로 설정된 BitVector32에서 개별 비트를 검색하는 데 사용할 수 있는 일련의 마스크를 만듭니다.

오버로드

CreateMask()

비트 플래그로 설정된 BitVector32에서 개별 비트를 검색하는 데 사용할 수 있는 일련의 마스크 중의 첫 번째 마스크를 만듭니다.

CreateMask(Int32)

비트 플래그로 설정된 BitVector32에서 개별 비트를 검색하는 데 사용할 수 있는 일련의 마스크 중에서 지정된 마스크 다음에 마스크를 추가로 만듭니다.

예제

다음 코드 예제에서는 마스크를 만들고 사용하는 방법을 보여 줍니다.

#using <system.dll>

using namespace System;
using namespace System::Collections::Specialized;
int main()
{
   // Creates and initializes a BitVector32 with all bit flags set to FALSE.
   BitVector32 myBV;

   // 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 );

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

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

/*
This code produces the following output.

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

*/
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

반환

Int32

BitVector32에서 첫 번째 비트 플래그를 격리하는 마스크입니다.

설명

계열의 첫 번째 마스크와 CreateMask(int) 모든 후속 마스크를 만드는 데 사용합니다CreateMask().

동일한 비트 플래그를 참조하기 위해 여러 마스크를 만들 수 있습니다.

결과 마스크는 .에서 BitVector32하나의 비트 플래그만 격리합니다. 비트 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

이전 비트 플래그를 나타내는 마스크입니다.

반환

Int32

BitVector32에서 previous가 가리키는 마스크 다음의 비트 플래그를 격리하는 마스크입니다.

예외

previousBitVector32의 마지막 비트 플래그를 나타내는 경우

설명

계열의 첫 번째 마스크와 CreateMask(int) 모든 후속 마스크를 만드는 데 사용합니다CreateMask().

동일한 비트 플래그를 참조하기 위해 여러 마스크를 만들 수 있습니다.

결과 마스크는 .에서 BitVector32하나의 비트 플래그만 격리합니다. 비트 OR 연산을 사용하여 마스크를 결합하여 에 있는 여러 비트 플래그를 격리하는 마스크를 BitVector32만들 수 있습니다.

섹션으로 설정된 마스크를 BitVector32 사용하면 예기치 않은 결과가 발생할 수 있습니다.

이 방법은 O(1) 작업에 설명 합니다.

적용 대상