当前位置: 首页>>代码示例>>C#>>正文


C# BitArray.Get方法代码示例

本文整理汇总了C#中BitArray.Get方法的典型用法代码示例。如果您正苦于以下问题:C# BitArray.Get方法的具体用法?C# BitArray.Get怎么用?C# BitArray.Get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在BitArray的用法示例。


在下文中一共展示了BitArray.Get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Get_InvalidIndex_ThrowsArgumentOutOfRangeException

        public static void Get_InvalidIndex_ThrowsArgumentOutOfRangeException()
        {
            BitArray bitArray = new BitArray(4);
            Assert.Throws<ArgumentOutOfRangeException>("index", () => bitArray.Get(-1));
            Assert.Throws<ArgumentOutOfRangeException>("index", () => bitArray.Get(bitArray.Length));

            Assert.Throws<ArgumentOutOfRangeException>("index", () => bitArray[-1]);
            Assert.Throws<ArgumentOutOfRangeException>("index", () => bitArray[bitArray.Length]);
        }
开发者ID:SGuyGe,项目名称:corefx,代码行数:9,代码来源:BitArray_GetSetTests.cs

示例2: StringPiece

    public StringPiece(string vf, string kor, AudioClip vFile, string pp,BitArray sceneFlag)
    {
        voiceFile = vf;
        korean = kor;
        voice = vFile;
        purpose = pp;
        LoadingTag = sceneFlag;

        serializeBitArray[0] = LoadingTag.Get(0);
        serializeBitArray[1] = LoadingTag.Get(1);
    }
开发者ID:KimTaeYool,项目名称:copy-of-puzzleD,代码行数:11,代码来源:StringPiece.cs

示例3: SetAll

        public static void SetAll(int size, bool defaultValue)
        {
            BitArray bitArray = new BitArray(6, defaultValue);
            bitArray.SetAll(!defaultValue);
            for (int i = 0; i < bitArray.Length; i++)
            {
                Assert.Equal(!defaultValue, bitArray[i]);
                Assert.Equal(!defaultValue, bitArray.Get(i));
            }

            bitArray.SetAll(defaultValue);
            for (int i = 0; i < bitArray.Length; i++)
            {
                Assert.Equal(defaultValue, bitArray[i]);
                Assert.Equal(defaultValue, bitArray.Get(i));
            }
        }
开发者ID:SGuyGe,项目名称:corefx,代码行数:17,代码来源:BitArray_GetSetTests.cs

示例4: UpdateScreen

 public void UpdateScreen(BitArray pixels)
 {
     Color[] colors = new Color[pixels.Count];
     for(int i=0; i<pixels.Count; i++)
     {
         colors[i] = pixels.Get(i) == true ? Color.white : Color.black;
     }
     texture.SetPixels(colors);
     texture.Apply();
 }
开发者ID:jarkkopa,项目名称:Chip8Unity,代码行数:10,代码来源:DisplayTexture.cs

示例5: Get_Set

 public static void Get_Set(bool[] newValues)
 {
     BitArray bitArray = new BitArray(newValues.Length, false);
     for (int i = 0; i < newValues.Length; i++)
     {
         bitArray.Set(i, newValues[i]);
         Assert.Equal(newValues[i], bitArray[i]);
         Assert.Equal(newValues[i], bitArray.Get(i));
     }
 }
开发者ID:SGuyGe,项目名称:corefx,代码行数:10,代码来源:BitArray_GetSetTests.cs

示例6: Ctor_BitArray

 public static void Ctor_BitArray(BitArray bits)
 {
     BitArray bitArray = new BitArray(bits);
     Assert.Equal(bits.Length, bitArray.Length);
     for (int i = 0; i < bitArray.Length; i++)
     {
         Assert.Equal(bits[i], bitArray[i]);
         Assert.Equal(bits[i], bitArray.Get(i));
     }
     ICollection collection = bitArray;
     Assert.Equal(bits.Length, collection.Count);
     Assert.False(collection.IsSynchronized);
 }
开发者ID:SGuyGe,项目名称:corefx,代码行数:13,代码来源:BitArray_CtorTests.cs

示例7: Ctor_Int_Bool

 public static void Ctor_Int_Bool(int length, bool defaultValue)
 {
     BitArray bitArray = new BitArray(length, defaultValue);
     Assert.Equal(length, bitArray.Length);
     for (int i = 0; i < bitArray.Length; i++)
     {
         Assert.Equal(defaultValue, bitArray[i]);
         Assert.Equal(defaultValue, bitArray.Get(i));
     }
     ICollection collection = bitArray;
     Assert.Equal(length, collection.Count);
     Assert.False(collection.IsSynchronized);
 }
开发者ID:ESgarbi,项目名称:corefx,代码行数:13,代码来源:BitArray_CtorTests.cs

示例8: Main

    public static void Main()
    {
        Euler.run(() => {
          long total = 0;

          primes = Euler.sieve(100000000);
          for (int p = 2; p < primes.Count; p++) {
        if (primes.Get(p) && isPrimeGenerator(p-1)) {
          total += p-1;
        }
          }

          return total;
        });
    }
开发者ID:jbcrail,项目名称:project-euler,代码行数:15,代码来源:p357.cs

示例9: ConvertToByte

	protected byte ConvertToByte(BitArray bits)
	{
    		if (bits.Count != 8)
    		{
    	    		throw new ArgumentException("illegal number of bits");
    		}

    		byte b = 0;
    		if (bits.Get(7)) b++;
    		if (bits.Get(6)) b += 2;
    		if (bits.Get(5)) b += 4;
    		if (bits.Get(4)) b += 8;
    		if (bits.Get(3)) b += 16;
    		if (bits.Get(2)) b += 32;
    		if (bits.Get(1)) b += 64;
    		if (bits.Get(0)) b += 128;
    		return b;
	}
开发者ID:thedanieldude1,项目名称:DanielCode,代码行数:18,代码来源:64bitCollection.cs

示例10: Equal

    // returns true if the two bitboards are equivalent, false otherwise
    public static bool Equal(BitArray b1, BitArray b2)
    {
        if (b1.Length != b2.Length)
        {
          return false;
        }

        for (int i = 0; i < b1.Length && i < b2.Length; i++)
        {
          if (b1.Get(i) != b2.Get(i))
          {
        return false;
          }
        }

        return true;
    }
开发者ID:austingantner,项目名称:MegaMinerAI12-Mars,代码行数:18,代码来源:BitBoard.cs

示例11: runTest

 public virtual bool runTest()
 {
     System.Console.Error.WriteLine( "BitArray- Co1557SetAll runTest started." );
     int iCountErrors = 0;
     int iCountTestcases = 0;
     int i2 = -2;
     bool b2 = false;
     BitArray ba2 = null;
     BitArray ba4 = null;
     i2 = 6;
     ba2 = new BitArray( i2 ,false );
     ++iCountTestcases;
     if ( ba2.Get( 0 ) )
     {
         ++iCountErrors;
         System.Console.Error.WriteLine( "Co1557SetAll Error E_545wi!" );
     }
     ++iCountTestcases;
     if ( ba2.Get( (i2 - 1) ) )
     {
         ++iCountErrors;
         System.Console.Error.WriteLine( "Co1557SetAll Error E_319hf!" );
     }
     ba2.SetAll( true );
     ++iCountTestcases;
     if ( ! ba2.Get( 0 ) )
     {
         ++iCountErrors;
         System.Console.Error.WriteLine( "Co1557SetAll Error E_446hf!" );
     }
     ++iCountTestcases;
     if ( ! ba2.Get( (i2 - 1) ) )
     {
         ++iCountErrors;
         System.Console.Error.WriteLine( "Co1557SetAll Error E_667aa!" );
     }
     i2 = 6;
     ba2 = new BitArray( i2 ,true );
     ++iCountTestcases;
     if ( ! ba2.Get( 0 ) )
     {
         ++iCountErrors;
         System.Console.Error.WriteLine( "Co1557SetAll Error E_965dd!" );
     }
     ++iCountTestcases;
     if ( ! ba2.Get( (i2 - 1) ) )
     {
         ++iCountErrors;
         System.Console.Error.WriteLine( "Co1557SetAll Error E_443sw!" );
     }
     ba2.SetAll( true );
     ++iCountTestcases;
     if ( ! ba2.Get( 0 ) )
     {
         ++iCountErrors;
         System.Console.Error.WriteLine( "Co1557SetAll Error E_979uy!" );
     }
     ++iCountTestcases;
     if ( ! ba2.Get( (i2 - 1) ) )
     {
         ++iCountErrors;
         System.Console.Error.WriteLine( "Co1557SetAll Error E_118ju!" );
     }
     i2 = 6;
     ba2 = new BitArray( i2 ,false );
     ++iCountTestcases;
     if ( ba2.Get( 0 ) )
     {
         ++iCountErrors;
         System.Console.Error.WriteLine( "Co1557SetAll Error E_747tr!" );
     }
     ++iCountTestcases;
     if ( ba2.Get( (i2 - 1) ) )
     {
         ++iCountErrors;
         System.Console.Error.WriteLine( "Co1557SetAll Error E_235vc!" );
     }
     ba2.SetAll( false );
     ++iCountTestcases;
     if ( ba2.Get( 0 ) )
     {
         ++iCountErrors;
         System.Console.Error.WriteLine( "Co1557SetAll Error E_005gh!" );
     }
     ++iCountTestcases;
     if ( ba2.Get( (i2 - 1) ) )
     {
         ++iCountErrors;
         System.Console.Error.WriteLine( "Co1557SetAll Error E_739wn!" );
     }
     i2 = 0x1000F;
     ba2 = new BitArray( i2 ,true );
     ++iCountTestcases;
     if ( ! ba2.Get( 0 ) )
     {
         ++iCountErrors;
         System.Console.Error.WriteLine( "Co1557SetAll Error E_945wx!" );
     }
     ++iCountTestcases;
     if ( ! ba2.Get( (i2 - 1) ) )
//.........这里部分代码省略.........
开发者ID:gbarnett,项目名称:shared-source-cli-2.0,代码行数:101,代码来源:co1557setall.cs

示例12: pager_playback_one_page

 private RC pager_playback_one_page(ref long pOffset, BitArray pDone, int isMainJrnl, int isSavepnt)
 {
     Debug.Assert((isMainJrnl & ~1) == 0);       // isMainJrnl is 0 or 1
     Debug.Assert((isSavepnt & ~1) == 0);        // isSavepnt is 0 or 1
     Debug.Assert(isMainJrnl != 0 || pDone != null);     // pDone always used on sub-journals
     Debug.Assert(isSavepnt != 0 || pDone == null);      // pDone never used on non-savepoint
     var aData = this.pTmpSpace;
     Debug.Assert(aData != null);         // Temp storage must have already been allocated
     Debug.Assert(!pagerUseWal() || (0 == isMainJrnl && isSavepnt != 0));
     // Either the state is greater than PAGER_WRITER_CACHEMOD (a transaction or savepoint rollback done at the request of the caller) or this is
     // a hot-journal rollback. If it is a hot-journal rollback, the pager is in state OPEN and holds an EXCLUSIVE lock. Hot-journal rollback
     // only reads from the main journal, not the sub-journal.
     Debug.Assert(this.eState >= PAGER.WRITER_CACHEMOD || (this.eState == PAGER.OPEN && this.eLock == VFSLOCK.EXCLUSIVE));
     Debug.Assert(this.eState >= PAGER.WRITER_CACHEMOD || isMainJrnl != 0);
     // Read the page number and page data from the journal or sub-journal file. Return an error code to the caller if an IO error occurs.
     var jfd = (isMainJrnl != 0 ? this.jfd : this.sjfd); // The file descriptor for the journal file
     Pgno pgno = 0;  // The page number of a page in journal
     var rc = jfd.ReadByte(pOffset, ref pgno);
     if (rc != RC.OK)
         return rc;
     rc = jfd.Read(aData, this.pageSize, pOffset + 4);
     if (rc != RC.OK)
         return rc;
     pOffset += this.pageSize + 4 + isMainJrnl * 4;
     // Sanity checking on the page.  This is more important that I originally thought.  If a power failure occurs while the journal is being written,
     // it could cause invalid data to be written into the journal.  We need to detect this invalid data (with high probability) and ignore it.
     if (pgno == 0 || pgno == PAGER_MJ_PGNO(this))
     {
         Debug.Assert(0 == isSavepnt);
         return RC.DONE;
     }
     if (pgno > this.dbSize || pDone.Get(pgno) != 0)
         return RC.OK;
     uint cksum = 0;         // Checksum used for sanity checking
     if (isMainJrnl != 0)
     {
         rc = jfd.ReadByte((pOffset) - 4, ref cksum);
         if (rc != RC.OK)
             return rc;
         if (0 == isSavepnt && pager_cksum(aData) != cksum)
             return RC.DONE;
     }
     // If this page has already been played by before during the current rollback, then don't bother to play it back again.
     if (pDone != null && (rc = pDone.Set(pgno)) != RC.OK)
         return rc;
     // When playing back page 1, restore the nReserve setting
     if (pgno == 1 && this.nReserve != aData[20])
     {
         this.nReserve = (aData)[20];
         pagerReportSize();
     }
     var pPg = (pagerUseWal() ? null : pager_lookup(pgno)); // An existing page in the cache
     Debug.Assert(pPg != null ||
     #if SQLITE_OMIT_MEMORYDB
     0==MEMDB
     #else
      this.memDb == 0
     #endif
     );
     Debug.Assert(this.eState != PAGER.OPEN || pPg == null);
     PAGERTRACE("PLAYBACK {0} page {1} hash({2,08:x}) {3}", PAGERID(this), pgno, pager_datahash(this.pageSize, aData), isMainJrnl != 0 ? "main-journal" : "sub-journal");
     bool isSynced; // True if journal page is synced
     if (isMainJrnl != 0)
         isSynced = this.noSync || (pOffset <= this.journalHdr);
     else
         isSynced = (pPg == null || 0 == (pPg.Flags & PgHdr.PGHDR.NEED_SYNC));
     if (this.fd.IsOpen && (this.eState >= PAGER.WRITER_DBMOD || this.eState == PAGER.OPEN) && isSynced)
     {
         long ofst = (pgno - 1) * this.pageSize;
         Debug.Assert(!pagerUseWal());
         rc = this.fd.Write(aData, this.pageSize, ofst);
         if (pgno > this.dbFileSize)
             this.dbFileSize = pgno;
         if (this.pBackup != null)
         {
             if (CODEC1(this, aData, pgno, codec_ctx.DECRYPT))
                 rc = RC.NOMEM;
             this.pBackup.sqlite3BackupUpdate(pgno, aData);
             if (CODEC2(this, aData, pgno, codec_ctx.ENCRYPT_READ_CTX, ref aData))
                 rc = RC.NOMEM;
         }
     }
     else if (0 == isMainJrnl && pPg == null)
     {
         // If this is a rollback of a savepoint and data was not written to the database and the page is not in-memory, there is a potential
         // problem. When the page is next fetched by the b-tree layer, it will be read from the database file, which may or may not be
         // current.
         // There are a couple of different ways this can happen. All are quite obscure. When running in synchronous mode, this can only happen
         // if the page is on the free-list at the start of the transaction, then populated, then moved using sqlite3PagerMovepage().
         // The solution is to add an in-memory page to the cache containing the data just read from the sub-journal. Mark the page as dirty
         // and if the pager requires a journal-sync, then mark the page as requiring a journal-sync before it is written.
         Debug.Assert(isSavepnt != 0);
         Debug.Assert(this.doNotSpill == 0);
         this.doNotSpill++;
         rc = this.Get(pgno, ref pPg, 1);
         Debug.Assert(this.doNotSpill == 1);
         this.doNotSpill--;
         if (rc != RC.OK)
             return rc;
         pPg.Flags &= ~PgHdr.PGHDR.NEED_READ;
//.........这里部分代码省略.........
开发者ID:JiujiangZhu,项目名称:feaserver,代码行数:101,代码来源:Pager+Pager.cs

示例13: BitArrayToString

    // Returns a string in the form "{0, 2, 4}" containing the indices of "true"
    // bits in the given BitArray.
    string BitArrayToString(BitArray b)
    {
        StringBuilder sb = new StringBuilder();
        sb.Append("{");
        bool started = false;
        for (int i = 0; i < b.Length; ++i) {
            if (b.Get(i)) {
                if (started) {
                    sb.Append(", ");
                }
                else {
                    started = true;
                }

                sb.Append(i);
            }
        }
        sb.Append("}");
        return sb.ToString();
    }
开发者ID:KBrizzle,项目名称:ScoreDrop,代码行数:22,代码来源:EnumerateSubsets.cs

示例14: ShiftRight

 // returns the bit array shifted a specified number of bits to the right
 public static BitArray ShiftRight(BitArray bitboard, int shift)
 {
     BitArray shiftedBitBoard = new BitArray(bitboard.Length, false);
     for (int i = 0; (i + shift) < bitboard.Length; i++)
     {
       shiftedBitBoard.Set((i + shift), bitboard.Get(i));
     }
     return shiftedBitBoard;
 }
开发者ID:austingantner,项目名称:MegaMinerAI12-Mars,代码行数:10,代码来源:BitBoard.cs

示例15: Ctor_ByteArray

 public static void Ctor_ByteArray(byte[] bytes, bool[] expected)
 {
     BitArray bitArray = new BitArray(bytes);
     Assert.Equal(expected.Length, bitArray.Length);
     for (int i = 0; i < bitArray.Length; i++)
     {
         Assert.Equal(expected[i], bitArray[i]);
         Assert.Equal(expected[i], bitArray.Get(i));
     }
     ICollection collection = bitArray;
     Assert.Equal(expected.Length, collection.Count);
     Assert.False(collection.IsSynchronized);
 }
开发者ID:ESgarbi,项目名称:corefx,代码行数:13,代码来源:BitArray_CtorTests.cs


注:本文中的BitArray.Get方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。