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


C# RangeCollection.Remove方法代码示例

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


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

示例1: RemoveTest

        public void RemoveTest()
        {
            RangeCollection c = new RangeCollection();
            c.Add(new AddressRange(0,100));
            c.Remove(new AddressRange(50, 50));
            Assert.AreEqual(2, c.Ranges.Count, "#1");
            Assert.AreEqual(new AddressRange(0, 49), c.Ranges[0], "#2");
            Assert.AreEqual(new AddressRange(51, 100), c.Ranges[1], "#3");

            c.Remove(new AddressRange(50, 55));
            Assert.AreEqual(2, c.Ranges.Count, "#4");
            Assert.AreEqual(new AddressRange(0, 49), c.Ranges[0], "#5");
            Assert.AreEqual(new AddressRange(56, 100), c.Ranges[1], "#6");

            c.Remove(new AddressRange(45, 60));
            Assert.AreEqual(2, c.Ranges.Count, "#7");
            Assert.AreEqual(new AddressRange(0, 44), c.Ranges[0], "#8");
            Assert.AreEqual(new AddressRange(61, 100), c.Ranges[1], "#9");

            c.Remove(new AddressRange(45, 60));
            Assert.AreEqual(2, c.Ranges.Count, "#10");
            Assert.AreEqual(new AddressRange(0, 44), c.Ranges[0], "#11");
            Assert.AreEqual(new AddressRange(61, 100), c.Ranges[1], "#12");

            c.Remove(new AddressRange(-100, 5));
            Assert.AreEqual(2, c.Ranges.Count, "#1");
            Assert.AreEqual(new AddressRange(6, 44), c.Ranges[0], "#1");
            Assert.AreEqual(new AddressRange(61, 100), c.Ranges[1], "#1");

            c.Remove(new AddressRange(6, 15));
            Assert.AreEqual(2, c.Ranges.Count, "#1");
            Assert.AreEqual(new AddressRange(16, 44), c.Ranges[0], "#1");
            Assert.AreEqual(new AddressRange(61, 100), c.Ranges[1], "#1");

            c.Remove(new AddressRange(70, 80));
            Assert.AreEqual(3, c.Ranges.Count, "#1");
            Assert.AreEqual(new AddressRange(16, 44), c.Ranges[0], "#1");
            Assert.AreEqual(new AddressRange(61,69), c.Ranges[1], "#1");
            Assert.AreEqual(new AddressRange(81, 100), c.Ranges[2], "#1");
        }
开发者ID:JacklEventreur,项目名称:monotorrent,代码行数:40,代码来源:RangeCollectionTests.cs

示例2: RemoveSingles

        public void RemoveSingles ()
        {
            RangeCollection range = new RangeCollection ();
            int [] indexes = new int [] { 0, 2, 4, 6, 8, 10, 12, 14 };
            foreach (int index in indexes) {
                range.Add (index);
            }

            foreach (int index in indexes) {
                Assert.AreEqual (true, range.Remove (index));
            }
        }
开发者ID:rubenv,项目名称:tripod,代码行数:12,代码来源:RangeCollectionTests.cs

示例3: IndexesCacheGeneration

        public void IndexesCacheGeneration ()
        {
            RangeCollection range = new RangeCollection ();
            int [] index_cache = range.Indexes;

            Assert.AreSame (index_cache, range.Indexes);

            range.Add (0);
            range.Add (5);

            if (index_cache == range.Indexes) {
                Assert.Fail ("Indexes Cache not regenerated after change");
            }

            index_cache = range.Indexes;
            range.Remove (0);
            range.Add (3);

            if (index_cache == range.Indexes) {
                Assert.Fail ("Indexes Cache not regenerated after change");
            }
        }
开发者ID:rubenv,项目名称:tripod,代码行数:22,代码来源:RangeCollectionTests.cs

示例4: RemoveTest

        public void RemoveTest()
        {
            var c = new RangeCollection();
            c.Add(new AddressRange(0, 100));
            c.Remove(new AddressRange(50, 50));
            Assert.Equal(2, c.Ranges.Count);
            Assert.Equal(new AddressRange(0, 49), c.Ranges[0]);
            Assert.Equal(new AddressRange(51, 100), c.Ranges[1]);

            c.Remove(new AddressRange(50, 55));
            Assert.Equal(2, c.Ranges.Count);
            Assert.Equal(new AddressRange(0, 49), c.Ranges[0]);
            Assert.Equal(new AddressRange(56, 100), c.Ranges[1]);

            c.Remove(new AddressRange(45, 60));
            Assert.Equal(2, c.Ranges.Count);
            Assert.Equal(new AddressRange(0, 44), c.Ranges[0]);
            Assert.Equal(new AddressRange(61, 100), c.Ranges[1]);

            c.Remove(new AddressRange(45, 60));
            Assert.Equal(2, c.Ranges.Count);
            Assert.Equal(new AddressRange(0, 44), c.Ranges[0]);
            Assert.Equal(new AddressRange(61, 100), c.Ranges[1]);

            c.Remove(new AddressRange(-100, 5));
            Assert.Equal(2, c.Ranges.Count);
            Assert.Equal(new AddressRange(6, 44), c.Ranges[0]);
            Assert.Equal(new AddressRange(61, 100), c.Ranges[1]);

            c.Remove(new AddressRange(6, 15));
            Assert.Equal(2, c.Ranges.Count);
            Assert.Equal(new AddressRange(16, 44), c.Ranges[0]);
            Assert.Equal(new AddressRange(61, 100), c.Ranges[1]);

            c.Remove(new AddressRange(70, 80));
            Assert.Equal(3, c.Ranges.Count);
            Assert.Equal(new AddressRange(16, 44), c.Ranges[0]);
            Assert.Equal(new AddressRange(61, 69), c.Ranges[1]);
            Assert.Equal(new AddressRange(81, 100), c.Ranges[2]);
        }
开发者ID:claudiuslollarius,项目名称:monotorrent,代码行数:40,代码来源:RangeCollectionTests.cs


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