當前位置: 首頁>>代碼示例>>C#>>正文


C# ByteBuffer.Clear方法代碼示例

本文整理匯總了C#中System.ByteBuffer.Clear方法的典型用法代碼示例。如果您正苦於以下問題:C# ByteBuffer.Clear方法的具體用法?C# ByteBuffer.Clear怎麽用?C# ByteBuffer.Clear使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在System.ByteBuffer的用法示例。


在下文中一共展示了ByteBuffer.Clear方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: relPut

 private static void relPut(ByteBuffer b)
 {
     int n = b.Capacity;
     b.Clear();
     for (int i = 0; i < n; i++)
         b.Put((byte)Ic(i));
     b.Flip();
 }
開發者ID:ChristopherHaws,項目名稱:lucenenet,代碼行數:8,代碼來源:TestByteBuffer.cs

示例2: absPut

 private static void absPut(ByteBuffer b)
 {
     int n = b.Capacity;
     b.Clear();
     for (int i = 0; i < n; i++)
         b.Put(i, (byte)Ic(i));
     b.Limit = (n);
     b.Position = (0);
 }
開發者ID:ChristopherHaws,項目名稱:lucenenet,代碼行數:9,代碼來源:TestByteBuffer.cs

示例3: bulkPutArray

 private static void bulkPutArray(ByteBuffer b)
 {
     int n = b.Capacity;
     b.Clear();
     byte[] a = new byte[n + 7];
     for (int i = 0; i < n; i++)
         a[i + 7] = (byte)Ic(i);
     b.Put(a, 7, n);
     b.Flip();
 }
開發者ID:ChristopherHaws,項目名稱:lucenenet,代碼行數:10,代碼來源:TestByteBuffer.cs

示例4: bulkPutBuffer

 private static void bulkPutBuffer(ByteBuffer b)
 {
     int n = b.Capacity;
     b.Clear();
     ByteBuffer c = ByteBuffer.Allocate(n + 7);
     c.Position = (7);
     for (int i = 0; i < n; i++)
         c.Put((byte)Ic(i));
     c.Flip();
     c.Position = (7);
     b.Put(c);
     b.Flip();
 }
開發者ID:ChristopherHaws,項目名稱:lucenenet,代碼行數:13,代碼來源:TestByteBuffer.cs

示例5: test

        public static void test(int level, ByteBuffer b, bool direct)
        {
            Show(level, b);

            if (direct != b.IsDirect)
                fail("Wrong direction", b);

            // Gets and puts

            relPut(b);
            relGet(b);
            absGet(b);
            bulkGet(b);

            absPut(b);
            relGet(b);
            absGet(b);
            bulkGet(b);

            bulkPutArray(b);
            relGet(b);

            bulkPutBuffer(b);
            relGet(b);


            // Compact

            relPut(b);
            b.Position = (13);
            b.Compact();
            b.Flip();
            relGet(b, 13);

            // Exceptions

            relPut(b);
            b.Limit = (b.Capacity / 2);
            b.Position = (b.Limit);

            tryCatch(b, typeof(BufferUnderflowException), () =>
            {
                b.Get();
            });

            tryCatch(b, typeof(BufferOverflowException), () =>
            {
                b.Put((byte)42);
            });

            // The index must be non-negative and lesss than the buffer's limit.
            tryCatch(b, typeof(IndexOutOfRangeException), () =>
            {
                b.Get(b.Limit);
            });
            tryCatch(b, typeof(IndexOutOfRangeException), () =>
            {
                b.Get(-1);
            });

            tryCatch(b, typeof(IndexOutOfRangeException), () =>
            {
                b.Put(b.Limit, (byte)42);
            });

            tryCatch(b, typeof(InvalidMarkException), () =>
            {
                b.Position = (0);
                b.Mark();
                b.Compact();
                b.Reset();
            });

            // Values

            b.Clear();
            b.Put((byte)0);
            b.Put(unchecked((byte)-1));
            b.Put((byte)1);
            b.Put(unchecked((byte)sbyte.MaxValue));
            b.Put(unchecked((byte)sbyte.MinValue));

            byte v;
            b.Flip();
            ck(b, b.Get(), 0);
            ck(b, b.Get(), unchecked((byte)-1));
            ck(b, b.Get(), 1);
            ck(b, b.Get(), unchecked((byte)sbyte.MaxValue));
            ck(b, b.Get(), unchecked((byte)sbyte.MinValue));


            // Comparison
            b.Rewind();
            ByteBuffer b2 = Lucene.Net.Support.ByteBuffer.Allocate(b.Capacity);
            b2.Put(b);
            b2.Flip();
            b.Position = (2);
            b2.Position = (2);
            if (!b.Equals(b2))
            {
//.........這裏部分代碼省略.........
開發者ID:ChristopherHaws,項目名稱:lucenenet,代碼行數:101,代碼來源:TestByteBuffer.cs


注:本文中的System.ByteBuffer.Clear方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。