BitVector32.CreateSection 메서드

정의

small 정수가 포함되어 있는 일련의 섹션을 만듭니다.

오버로드

CreateSection(Int16)

small 정수가 들어 있는 일련의 섹션에 첫 번째 BitVector32.Section을 만듭니다.

CreateSection(Int16, BitVector32+Section)

small 정수가 들어 있는 일련의 섹션에서 지정된 BitVector32.Section 다음에 새 BitVector32.Section을 만듭니다.

예제

다음 코드 예제에서는 섹션의 컬렉션으로 사용 BitVector32 합니다.

#using <system.dll>

using namespace System;
using namespace System::Collections::Specialized;

int main()
{
   // Creates and initializes a BitVector32.
   BitVector32 myBV(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 );
   myBV[ mySect1 ] = 5;
   Console::WriteLine( "\tmySect1 = 5:\t {0}", myBV );
   myBV[ mySect2 ] = 3;
   Console::WriteLine( "\tmySect2 = 3:\t {0}", myBV );
   myBV[ mySect3 ] = 1;
   Console::WriteLine( "\tmySect3 = 1:\t {0}", myBV );
   myBV[ mySect4 ] = 9;
   Console::WriteLine( "\tmySect4 = 9:\t {0}", myBV );

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

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

*/
Imports System.Collections.Specialized

Public Class SamplesBitVector32
   
   Public Shared Sub Main()
      
      ' Creates and initializes a BitVector32.
      Dim myBV As 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.
      Dim mySect1 As BitVector32.Section = BitVector32.CreateSection(6)
      Dim mySect2 As BitVector32.Section = BitVector32.CreateSection(3, mySect1)
      Dim mySect3 As BitVector32.Section = BitVector32.CreateSection(1, mySect2)
      Dim mySect4 As BitVector32.Section = BitVector32.CreateSection(15, mySect3)
      
      ' Displays the values of the sections.
      Console.WriteLine("Initial values:")
      Console.WriteLine(ControlChars.Tab + "mySect1: {0}", myBV(mySect1))
      Console.WriteLine(ControlChars.Tab + "mySect2: {0}", myBV(mySect2))
      Console.WriteLine(ControlChars.Tab + "mySect3: {0}", myBV(mySect3))
      Console.WriteLine(ControlChars.Tab + "mySect4: {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(ControlChars.Tab + "Initial:    " + ControlChars.Tab + "{0}", myBV.ToString())
      myBV(mySect1) = 5
      Console.WriteLine(ControlChars.Tab + "mySect1 = 5:" + ControlChars.Tab + "{0}", myBV.ToString())
      myBV(mySect2) = 3
      Console.WriteLine(ControlChars.Tab + "mySect2 = 3:" + ControlChars.Tab + "{0}", myBV.ToString())
      myBV(mySect3) = 1
      Console.WriteLine(ControlChars.Tab + "mySect3 = 1:" + ControlChars.Tab + "{0}", myBV.ToString())
      myBV(mySect4) = 9
      Console.WriteLine(ControlChars.Tab + "mySect4 = 9:" + ControlChars.Tab + "{0}", myBV.ToString())
      
      ' Displays the values of the sections.
      Console.WriteLine("New values:")
      Console.WriteLine(ControlChars.Tab + "mySect1: {0}", myBV(mySect1))
      Console.WriteLine(ControlChars.Tab + "mySect2: {0}", myBV(mySect2))
      Console.WriteLine(ControlChars.Tab + "mySect3: {0}", myBV(mySect3))
      Console.WriteLine(ControlChars.Tab + "mySect4: {0}", myBV(mySect4))

   End Sub

End Class


' 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)

Source:
BitVector32.cs
Source:
BitVector32.cs
Source:
BitVector32.cs

small 정수가 들어 있는 일련의 섹션에 첫 번째 BitVector32.Section을 만듭니다.

public:
 static System::Collections::Specialized::BitVector32::Section CreateSection(short maxValue);
public static System.Collections.Specialized.BitVector32.Section CreateSection (short maxValue);
static member CreateSection : int16 -> System.Collections.Specialized.BitVector32.Section
Public Shared Function CreateSection (maxValue As Short) As BitVector32.Section

매개 변수

maxValue
Int16

BitVector32.Section의 최대값을 지정하는 16비트의 부호 있는 정수입니다.

반환

0부터 maxValue 범위의 숫자를 보유할 수 있는 BitVector32.Section입니다.

예외

maxValue가 1보다 작습니다.

설명

BitVector32.Section 은 의 BitVector32 창이며 에 지정된 최대값을 포함할 수 있는 가장 적은 수의 연속 비트로 구성됩니다CreateSection. 예를 들어 최대값이 1인 섹션은 1비트만 구성되는 반면, 최대값이 5인 섹션은 3비트로 구성됩니다. 최대값이 1인 을 BitVector32.Section 만들어 부울로 사용할 수 있으므로 같은 BitVector32에 정수와 부울을 저장할 수 있습니다.

섹션이 BitVector32에 이미 있는 경우 해당 섹션에 계속 액세스할 수 있지만 섹션이 겹치면 예기치 않은 결과가 발생할 수 있습니다.

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

적용 대상

CreateSection(Int16, BitVector32+Section)

Source:
BitVector32.cs
Source:
BitVector32.cs
Source:
BitVector32.cs

small 정수가 들어 있는 일련의 섹션에서 지정된 BitVector32.Section 다음에 새 BitVector32.Section을 만듭니다.

public:
 static System::Collections::Specialized::BitVector32::Section CreateSection(short maxValue, System::Collections::Specialized::BitVector32::Section previous);
public static System.Collections.Specialized.BitVector32.Section CreateSection (short maxValue, System.Collections.Specialized.BitVector32.Section previous);
static member CreateSection : int16 * System.Collections.Specialized.BitVector32.Section -> System.Collections.Specialized.BitVector32.Section
Public Shared Function CreateSection (maxValue As Short, previous As BitVector32.Section) As BitVector32.Section

매개 변수

maxValue
Int16

BitVector32.Section의 최대값을 지정하는 16비트의 부호 있는 정수입니다.

previous
BitVector32.Section

BitVector32.Section에서 이전의 BitVector32입니다.

반환

0부터 maxValue 범위의 숫자를 보유할 수 있는 BitVector32.Section입니다.

예외

maxValue가 1보다 작습니다.

previousBitVector32의 마지막 비트가 포함되는 경우

또는

maxValueprevious 다음에 나오는 비트 수가 나타낼 수 있는 최대값보다 큰 경우

설명

BitVector32.Section 은 의 BitVector32 창이며 에 지정된 최대값을 포함할 수 있는 가장 적은 수의 연속 비트로 구성됩니다CreateSection. 예를 들어 최대값이 1인 섹션은 1비트만 구성되는 반면, 최대값이 5인 섹션은 3비트로 구성됩니다. 최대값이 1인 을 BitVector32.Section 만들어 부울로 사용할 수 있으므로 같은 BitVector32에 정수와 부울을 저장할 수 있습니다.

에 섹션이 previousBitVector32이미 있는 경우 해당 섹션에 계속 액세스할 수 있지만 섹션이 겹치면 예기치 않은 결과가 발생할 수 있습니다.

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

적용 대상