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


C# ByteBuffer.Duplicate方法代碼示例

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


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

示例1: test


//.........這裏部分代碼省略.........
                    fail("equals not reflexive", xb, xb, x, x);
                }
                foreach (byte y in VALUES)
                {
                    ByteBuffer yb = Lucene.Net.Support.ByteBuffer.Wrap(new byte[] { y });
                    if (xb.CompareTo(yb) != -yb.CompareTo(xb))
                    {
                        fail("compareTo not anti-symmetric",
                             xb, yb, x, y);
                    }
                    if ((xb.CompareTo(yb) == 0) != xb.Equals(yb))
                    {
                        fail("compareTo inconsistent with equals",
                             xb, yb, x, y);
                    }
                    // from Byte.compare(x, y)
                    //return x - y;
                    if (xb.CompareTo(yb) != (x - y) /* Byte.Compare(x, y)*/)
                    {
                        fail("Incorrect results for ByteBuffer.compareTo",
                             xb, yb, x, y);
                    }
                    if (xb.equals(yb) != ((x == y) || ((x != x) && (y != y))))
                    {
                        fail("Incorrect results for ByteBuffer.equals",
                             xb, yb, x, y);
                    }
                }
            }

            // Sub, dup

            relPut(b);
            relGet(b.Duplicate());
            b.Position = (13);
            relGet(b.Duplicate(), 13);
            relGet(b.Duplicate().Slice(), 13);
            relGet(b.Slice(), 13);
            relGet(b.Slice().Duplicate(), 13);

            // Slice

            b.Position = (5);
            ByteBuffer sb = b.Slice();
            checkSlice(b, sb);
            b.Position = (0);
            ByteBuffer sb2 = sb.Slice();
            checkSlice(sb, sb2);

            if (!sb.Equals(sb2))
                fail("Sliced slices do not match", sb, sb2);
            if ((sb.HasArray) && (sb.ArrayOffset != sb2.ArrayOffset))
                fail("Array offsets do not match: "
                     + sb.ArrayOffset + " != " + sb2.ArrayOffset, sb, sb2);

            // Views

            b.Clear();
            b.Order = (ByteOrder.BIG_ENDIAN);
            testViews(level + 1, b, direct);

            for (int i = 1; i <= 9; i++)
            {
                b.Position = (i);
                Show(level + 1, b);
                testViews(level + 2, b, direct);
開發者ID:ChristopherHaws,項目名稱:lucenenet,代碼行數:67,代碼來源:TestByteBuffer.cs

示例2: callReset

        //6231529
        private static void callReset(ByteBuffer b)
        {
            b.Position = (0);
            b.Mark();

            b.Duplicate().Reset();
            // LUCENENET: AsReadOnlyBuffer() not implemented
            //b.AsReadOnlyBuffer().Reset();
        }
開發者ID:ChristopherHaws,項目名稱:lucenenet,代碼行數:10,代碼來源:TestByteBuffer.cs


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