BitVector32.CreateMask Método

Definição

Cria uma série de máscaras que podem ser usadas para recuperar bits individuais em um BitVector32, configuradas como sinalizadoras de bit.Creates a series of masks that can be used to retrieve individual bits in a BitVector32 that is set up as bit flags.

Sobrecargas

CreateMask()

Cria a primeira máscara em uma série de máscaras que podem ser usadas para recuperar bits individuais em um BitVector32 configurado como sinalizador de bit.Creates the first mask in a series of masks that can be used to retrieve individual bits in a BitVector32 that is set up as bit flags.

CreateMask(Int32)

Cria uma máscara adicional após a máscara especificada em uma série de máscaras que podem ser usadas para recuperar bits individuais em um BitVector32 que está configurado como sinalizadores de bit.Creates an additional mask following the specified mask in a series of masks that can be used to retrieve individual bits in a BitVector32 that is set up as bit flags.

CreateMask()

Cria a primeira máscara em uma série de máscaras que podem ser usadas para recuperar bits individuais em um BitVector32 configurado como sinalizador de bit.Creates the first mask in a series of masks that can be used to retrieve individual bits in a BitVector32 that is set up as bit flags.

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

Retornos

Uma máscara que isola o primeiro sinalizador de bit no BitVector32.A mask that isolates the first bit flag in the BitVector32.

Exemplos

O exemplo de código a seguir mostra como criar e usar máscaras.The following code example shows how to create and use masks.

#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}

Comentários

Use CreateMask() para criar a primeira máscara em uma série e CreateMask(int) para todas as máscaras subsequentes.Use CreateMask() to create the first mask in a series and CreateMask(int) for all subsequent masks.

Várias máscaras podem ser criadas para fazer referência ao mesmo sinalizador de bit.Multiple masks can be created to refer to the same bit flag.

A máscara resultante isola apenas um sinalizador de bit no BitVector32.The resulting mask isolates only one bit flag in the BitVector32. Você pode combinar máscaras usando a operação OR bit a bit para criar uma máscara que Isole os BitVector32sinalizadores de vários bits no.You can combine masks using the bitwise OR operation to create a mask that isolates multiple bit flags in the BitVector32.

Usar uma máscara em uma BitVector32 que é configurada como seções pode causar resultados inesperados.Using a mask on a BitVector32 that is set up as sections might cause unexpected results.

Este método é uma operação O(1).This method is an O(1) operation.

CreateMask(Int32)

Cria uma máscara adicional após a máscara especificada em uma série de máscaras que podem ser usadas para recuperar bits individuais em um BitVector32 que está configurado como sinalizadores de bit.Creates an additional mask following the specified mask in a series of masks that can be used to retrieve individual bits in a BitVector32 that is set up as bit flags.

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

Parâmetros

previous
Int32

A máscara que indica o sinalizador de bit anterior.The mask that indicates the previous bit flag.

Retornos

Uma máscara que isola o sinalizador de bit que segue aquele para o qual previous aponta em BitVector32.A mask that isolates the bit flag following the one that previous points to in BitVector32.

Exceções

previous indica o último sinalizador de bit no BitVector32.previous indicates the last bit flag in the BitVector32.

Exemplos

O exemplo de código a seguir mostra como criar e usar máscaras.The following code example shows how to create and use masks.

#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}

Comentários

Use CreateMask() para criar a primeira máscara em uma série e CreateMask(int) para todas as máscaras subsequentes.Use CreateMask() to create the first mask in a series and CreateMask(int) for all subsequent masks.

Várias máscaras podem ser criadas para fazer referência ao mesmo sinalizador de bit.Multiple masks can be created to refer to the same bit flag.

A máscara resultante isola apenas um sinalizador de bit no BitVector32.The resulting mask isolates only one bit flag in the BitVector32. Você pode combinar máscaras usando a operação OR bit a bit para criar uma máscara que Isole os BitVector32sinalizadores de vários bits no.You can combine masks using the bitwise OR operation to create a mask that isolates multiple bit flags in the BitVector32.

Usar uma máscara em uma BitVector32 que é configurada como seções pode causar resultados inesperados.Using a mask on a BitVector32 that is set up as sections might cause unexpected results.

Este método é uma operação O(1).This method is an O(1) operation.

Aplica-se a