BitVector32.CreateSection Metodo

Definizione

Crea una serie di sezioni che contengono Small Integer.

Overload

CreateSection(Int16)

Crea la prima sezione BitVector32.Section di una serie di sezioni che contengono Small Integer.

CreateSection(Int16, BitVector32+Section)

Crea una nuova sezione BitVector32.Section, successiva a quella specificata BitVector32.Section in una serie di sezioni che contengono Small Integer.

Esempio

Nell'esempio di codice seguente viene utilizzato un BitVector32 oggetto come raccolta di sezioni.

C#
using System;
using System.Collections.Specialized;

public class SamplesBitVector32  {

   public static void Main()  {

      // Creates and initializes a BitVector32.
      BitVector32 myBV = new BitVector32( 0 );

      // Creates four sections in the BitVector32 with maximum values 6, 3, 1, and 15.
      // mySect3, which uses exactly one bit, can also be used as a bit flag.
      BitVector32.Section mySect1 = BitVector32.CreateSection( 6 );
      BitVector32.Section mySect2 = BitVector32.CreateSection( 3, mySect1 );
      BitVector32.Section mySect3 = BitVector32.CreateSection( 1, mySect2 );
      BitVector32.Section mySect4 = BitVector32.CreateSection( 15, mySect3 );

      // Displays the values of the sections.
      Console.WriteLine( "Initial values:" );
      Console.WriteLine( "\tmySect1: {0}", myBV[mySect1] );
      Console.WriteLine( "\tmySect2: {0}", myBV[mySect2] );
      Console.WriteLine( "\tmySect3: {0}", myBV[mySect3] );
      Console.WriteLine( "\tmySect4: {0}", myBV[mySect4] );

      // Sets each section to a new value and displays the value of the BitVector32 at each step.
      Console.WriteLine( "Changing the values of each section:" );
      Console.WriteLine( "\tInitial:    \t{0}", myBV.ToString() );
      myBV[mySect1] = 5;
      Console.WriteLine( "\tmySect1 = 5:\t{0}", myBV.ToString() );
      myBV[mySect2] = 3;
      Console.WriteLine( "\tmySect2 = 3:\t{0}", myBV.ToString() );
      myBV[mySect3] = 1;
      Console.WriteLine( "\tmySect3 = 1:\t{0}", myBV.ToString() );
      myBV[mySect4] = 9;
      Console.WriteLine( "\tmySect4 = 9:\t{0}", myBV.ToString() );

      // Displays the values of the sections.
      Console.WriteLine( "New values:" );
      Console.WriteLine( "\tmySect1: {0}", myBV[mySect1] );
      Console.WriteLine( "\tmySect2: {0}", myBV[mySect2] );
      Console.WriteLine( "\tmySect3: {0}", myBV[mySect3] );
      Console.WriteLine( "\tmySect4: {0}", myBV[mySect4] );
   }
}

/*
This code produces the following output.

Initial values:
        mySect1: 0
        mySect2: 0
        mySect3: 0
        mySect4: 0
Changing the values of each section:
        Initial:        BitVector32{00000000000000000000000000000000}
        mySect1 = 5:    BitVector32{00000000000000000000000000000101}
        mySect2 = 3:    BitVector32{00000000000000000000000000011101}
        mySect3 = 1:    BitVector32{00000000000000000000000000111101}
        mySect4 = 9:    BitVector32{00000000000000000000001001111101}
New values:
        mySect1: 5
        mySect2: 3
        mySect3: 1
        mySect4: 9

*/

CreateSection(Int16)

Origine:
BitVector32.cs
Origine:
BitVector32.cs
Origine:
BitVector32.cs

Crea la prima sezione BitVector32.Section di una serie di sezioni che contengono Small Integer.

C#
public static System.Collections.Specialized.BitVector32.Section CreateSection (short maxValue);

Parametri

maxValue
Int16

Intero con segno a 16 bit che specifica il valore massimo della nuova struttura BitVector32.Section.

Restituisce

Sezione BitVector32.Section che può contenere un numero compreso tra zero e maxValue.

Eccezioni

maxValue è minore di 1.

Commenti

Un BitVector32.Section oggetto è una finestra nell'oggetto BitVector32 e è costituito dal numero più piccolo di bit consecutivi che possono contenere il valore massimo specificato in CreateSection. Ad esempio, una sezione con un valore massimo di 1 è composta da un solo bit, mentre una sezione con un valore massimo di 5 è composta da tre bit. È possibile creare un BitVector32.Section oggetto con un valore massimo pari a 1 per fungere da valore booleano, consentendo così di archiviare numeri interi e booleani nello stesso BitVector32.

Se le BitVector32sezioni esistono già in , tali sezioni sono ancora accessibili. Tuttavia, le sezioni sovrapposte potrebbero causare risultati imprevisti.

Questo metodo è un'operazione O(1).

Si applica a

.NET 9 e altre versioni
Prodotto Versioni
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0, 2.1
UWP 10.0

CreateSection(Int16, BitVector32+Section)

Origine:
BitVector32.cs
Origine:
BitVector32.cs
Origine:
BitVector32.cs

Crea una nuova sezione BitVector32.Section, successiva a quella specificata BitVector32.Section in una serie di sezioni che contengono Small Integer.

C#
public static System.Collections.Specialized.BitVector32.Section CreateSection (short maxValue, System.Collections.Specialized.BitVector32.Section previous);

Parametri

maxValue
Int16

Intero con segno a 16 bit che specifica il valore massimo della nuova struttura BitVector32.Section.

previous
BitVector32.Section

Sezione BitVector32.Section precedente nella struttura BitVector32.

Restituisce

Sezione BitVector32.Section che può contenere un numero compreso tra zero e maxValue.

Eccezioni

maxValue è minore di 1.

previous include il bit finale della struttura BitVector32.

-oppure-

maxValue è maggiore del valore massimo che può essere rappresentato dal numero di bit dopo previous.

Commenti

Un BitVector32.Section oggetto è una finestra nell'oggetto BitVector32 e è costituito dal numero più piccolo di bit consecutivi che possono contenere il valore massimo specificato in CreateSection. Ad esempio, una sezione con un valore massimo di 1 è composta da un solo bit, mentre una sezione con un valore massimo di 5 è composta da tre bit. È possibile creare un BitVector32.Section oggetto con un valore massimo pari a 1 per fungere da valore booleano, consentendo così di archiviare numeri interi e booleani nello stesso BitVector32.

Se le BitVector32sezioni esistono già dopo previous in , tali sezioni sono ancora accessibili. Tuttavia, le sezioni sovrapposte potrebbero causare risultati imprevisti.

Questo metodo è un'operazione O(1).

Si applica a

.NET 9 e altre versioni
Prodotto Versioni
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0, 2.1
UWP 10.0