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


C# SparseArray.SetValue方法代码示例

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


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

示例1: CorrectKeysWithInsertsWithSpaces

        public void CorrectKeysWithInsertsWithSpaces()
        {
            var array = new SparseArray<string>();

            for (int i = 0; i < 1000; i++)
            {
                if (i % 2 == 0)
                    array.SetValue(i, i.ToString());
            }

            int offset = 0;
            foreach (int key in array.GetKeys())
            {
                Assert.AreEqual(offset, key);
                offset += 2;
            }

            // Verify that we didn't switch to chunks even though we have
            // sparsely set items.

            Assert.AreEqual("Values=1280", array.ToString());
        }
开发者ID:pvginkel,项目名称:Jint2,代码行数:22,代码来源:Fixture.cs

示例2: InsertAtHighIndex

        public void InsertAtHighIndex()
        {
            var array = new SparseArray<string>();
            int offset = 1000000;

            // Insert some items.

            for (int i = 0; i < 1000; i++)
            {
                array.SetValue(offset + i, i.ToString());
            }

            // Verify that we can get them back.

            for (int i = 0; i < 1000; i++)
            {
                Assert.AreEqual(i.ToString(), array.GetValue(offset + i));
            }

            // Verify that we've switched to chunks.

            Assert.AreEqual("Chunks=33, ChunkCapacity=37", array.ToString());
        }
开发者ID:pvginkel,项目名称:Jint2,代码行数:23,代码来源:Fixture.cs

示例3: InsertWithSpaces

        public void InsertWithSpaces()
        {
            var array = new SparseArray<string>();

            for (int i = 0; i < 1000; i++)
            {
                if (i % 2 == 0)
                    array.SetValue(i, i.ToString());
            }

            for (int i = 0; i < 1000; i++)
            {
                if (i % 2 == 0)
                {
                    Assert.AreEqual(i.ToString(), array.GetValue(i));
                }
                else
                {
                    Assert.IsNull(array.GetValue(i));
                }
            }

            // Verify that we didn't switch to chunks even though we have
            // sparsely set items.

            Assert.AreEqual("Values=1280", array.ToString());
        }
开发者ID:pvginkel,项目名称:Jint2,代码行数:27,代码来源:Fixture.cs

示例4: VerifyKeysInOrderFromReverseInserts

        public void VerifyKeysInOrderFromReverseInserts()
        {
            var array = new SparseArray<string>();

            for (int i = 1000; i > 0; i--)
            {
                array.SetValue(i, "");
            }

            int offset = 1;

            foreach (int key in array.GetKeys())
            {
                Assert.AreEqual(offset++, key);
            }

            // Verify the allocations.

            Assert.AreEqual("Chunks=32, ChunkCapacity=37", array.ToString());
        }
开发者ID:pvginkel,项目名称:Jint2,代码行数:20,代码来源:Fixture.cs

示例5: VerifyKeysInOrderFromRandomInserts

        public void VerifyKeysInOrderFromRandomInserts()
        {
            var array = new SparseArray<string>();
            var random = new Random();

            for (int i = 0; i < 1000; i++)
            {
                array.SetValue(random.Next(), "");
            }

            int lastKey = int.MinValue;

            foreach (int key in array.GetKeys())
            {
                Assert.Greater(key, lastKey);
                lastKey = key;
            }
        }
开发者ID:pvginkel,项目名称:Jint2,代码行数:18,代码来源:Fixture.cs

示例6: SimpleInserts

        public void SimpleInserts()
        {
            var array = new SparseArray<string>();

            // Insert some items.

            for (int i = 0; i < 1000; i++)
            {
                array.SetValue(i, i.ToString());
            }

            // Verify that we can get them back.

            for (int i = 0; i < 1000; i++)
            {
                Assert.AreEqual(i.ToString(), array.GetValue(i));
            }

            // Verify that we didn't switch to chunks.

            Assert.AreEqual("Values=1280", array.ToString());
        }
开发者ID:pvginkel,项目名称:Jint2,代码行数:22,代码来源:Fixture.cs


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