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


C# NTree.GetFirstByIndex方法代码示例

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


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

示例1: NTreeDeletesByIndexIndividualUnique

        public void NTreeDeletesByIndexIndividualUnique()
        {
            var objs = TestResourceFactory.GetMockClassAObjects(50).ToList();

            var seedIndex = new Seed32();
            var seedSegment = new Seed64();

            objs.ForEach(o => o.Id = seedIndex.Increment());

            using (var tree = new NTree<int, MockClassA, long>("Id", true))
            {
                foreach (var o in objs)
                    tree.AddOrUpdate(new Tuple<MockClassA, long>(o, seedSegment.Increment()));

                Assert.AreEqual(50, tree.Length);

                Assert.AreEqual(5, tree.GetFirstByIndex(5));
                Assert.AreEqual(5, tree.GetFirstBySegment(5));
                Assert.AreEqual(1, tree.GetByIndex(5).Count());

                Assert.AreEqual(1, tree.Delete(5).Length);

                Assert.AreEqual(50, tree.Length);

                Assert.AreEqual(0, tree.GetFirstByIndex(5));
            }
        }
开发者ID:thehexgod,项目名称:BESSY-DB,代码行数:27,代码来源:NTreeDeleteTests.cs

示例2: NTreeChecksAllWithLargeCount

        public void NTreeChecksAllWithLargeCount()
        {
            using (var tree = new NTree<int, MockClassA, long>("Id", true))
            {
                var objs = new List<MockClassA>();
                var seedIndex = new Seed32();
                var seedSegment = new Seed64();

                for (var i = 0; i < 5; i++)
                {
                    var additions = TestResourceFactory.GetMockClassAObjects(100000).ToList();

                    additions.ForEach(o => o.Id = seedIndex.Increment());

                    tree.AddOrUpdateRange(additions.Select(o => new Tuple<MockClassA, long>(o, seedSegment.Increment())).ToList());
                }

                Assert.AreEqual(500000, tree.Length);

                Assert.AreEqual(5, tree.GetFirstByIndex(5));
                Assert.AreEqual(5, tree.GetFirstBySegment(5));
                Assert.AreEqual(1, tree.GetByIndex(5).Count());

                tree.AddOrUpdate(new Tuple<MockClassA, long>(TestResourceFactory.CreateRandom().WithId(seedIndex.Increment()), seedSegment.Increment()));

                Assert.AreEqual(500001, tree.Length);

                tree.AddOrUpdateRange(
                    tree.AsEnumerable().First().Take(100)
                    .Select(s => new NTreeItem<int, long>(s.Item2.Index, s.Item2.Segment))
                    .ToList());

                Assert.AreEqual(500001, tree.Length);
            }
        }
开发者ID:thehexgod,项目名称:BESSY-DB,代码行数:35,代码来源:NTreeUniqueTests.cs

示例3: NTreeFetchesByIndexRange

        public void NTreeFetchesByIndexRange()
        {
            var objs = TestResourceFactory.GetMockClassAObjects(5000).ToList();

            var seedIndex = new Seed32();
            var seedSegment = new Seed64();

            objs.ForEach(o => o.Id = seedIndex.Increment());
            var toAdd = objs.Select(o => new Tuple<MockClassA, long>(o, seedSegment.Increment())).ToList();

            using (var tree = new NTree<int, MockClassA, long>("Id"))
            {
                var ids = tree.AddOrUpdateRange(toAdd);

                Assert.AreEqual(5000, tree.Length);

                Assert.AreEqual(5, tree.GetFirstByIndex(5));
                Assert.AreEqual(5, tree.GetFirstBySegment(5));
                Assert.AreEqual(1, tree.GetByIndex(5).Count());

                tree.AddOrUpdate(new Tuple<MockClassA, long>(TestResourceFactory.CreateRandom().WithId(seedIndex.Increment()), seedSegment.Increment()));

                Assert.AreEqual(5001, tree.Length);

                long[] loc;
                var range = tree.GetByIndexRangeInclusive(51, 250, out loc);

                Assert.AreEqual(200, range.Length);
            }
        }
开发者ID:thehexgod,项目名称:BESSY-DB,代码行数:30,代码来源:NTreeNonUniqueTests.cs

示例4: NTreePushesEntities

        public void NTreePushesEntities()
        {
            var objs = TestResourceFactory.GetMockClassAObjects(50).ToList();

            var seedIndex = new Seed32();
            var seedSegment = new Seed64();

            objs.ForEach(o => o.Id = seedIndex.Increment());
            var toAdd = objs.Select(o => new Tuple<MockClassA, long>(o, seedSegment.Increment())).ToList();

            using (var tree = new NTree<int, MockClassA, long>("Id", true))
            {
                var ids = tree.AddOrUpdateRange(toAdd);
                tree.AddOrUpdate(toAdd.First());

                Assert.AreEqual(50, tree.Length);

                Assert.AreEqual(5L, tree.GetFirstByIndex(5));
                Assert.AreEqual(5, tree.GetFirstBySegment(5));
                Assert.AreEqual(1, tree.GetByIndex(1).Count());
                Assert.AreEqual(5, tree.GetFirstBySegment(5));
            }
        }
开发者ID:thehexgod,项目名称:BESSY-DB,代码行数:23,代码来源:NTreeUniqueTests.cs

示例5: NTreePushesLotsOfDuplicateEntities

        public void NTreePushesLotsOfDuplicateEntities()
        {
            var objs = TestResourceFactory.GetMockClassAObjects(20480).ToList();

            var seedIndex = new Seed32();
            var seedSegment = new Seed64();

            objs.ForEach(o => o.Id = seedIndex.Increment());
            var toAdd = objs.Select(o => new Tuple<MockClassA, long>(o, seedSegment.Increment())).ToList();

            using (var tree = new NTree<int, MockClassA, long>("Id", true))
            {
                var ids = tree.AddOrUpdateRange(toAdd);

                Assert.AreEqual(20480, tree.Length);

                Assert.AreEqual(5, tree.GetFirstByIndex(5));
                Assert.AreEqual(5, tree.GetFirstBySegment(5));
                Assert.AreEqual(1, tree.GetByIndex(5).Count());

                tree.AddOrUpdate(new Tuple<MockClassA, long>(TestResourceFactory.CreateRandom().WithId(seedIndex.Increment()), seedSegment.Increment()));

                Assert.AreEqual(20481, tree.Length);

                tree.AddOrUpdateRange(toAdd.Skip(100).Take(100).ToList());

                Assert.AreEqual(20481, tree.Length);
            }
        }
开发者ID:thehexgod,项目名称:BESSY-DB,代码行数:29,代码来源:NTreeUniqueTests.cs

示例6: NTreeStreamsData

        public void NTreeStreamsData()
        {
            var objs = TestResourceFactory.GetMockClassAObjects(5000).ToList();

            var seedIndex = new Seed32();
            var seedSegment = new Seed64();

            objs.ForEach(o => o.Id = seedIndex.Increment());
            var toAdd = objs.Select(o => new Tuple<MockClassA, long>(o, seedSegment.Increment())).ToList();

            using (var tree = new NTree<int, MockClassA, long>("Id"))
            {
                var ids = tree.AddOrUpdateRange(toAdd);

                Assert.AreEqual(5000, tree.Length);

                Assert.AreEqual(5, tree.GetFirstByIndex(5));
                Assert.AreEqual(5, tree.GetFirstBySegment(5));
                Assert.AreEqual(1, tree.GetByIndex(5).Count());

                foreach (var p in tree.AsStreaming())
                {
                    if (p == null)
                        continue;

                    p.Dispose();
                }
            }
        }
开发者ID:thehexgod,项目名称:BESSY-DB,代码行数:29,代码来源:NTreeNonUniqueTests.cs

示例7: NTreeReturnsEmptyStreamOnWrongPage

        public void NTreeReturnsEmptyStreamOnWrongPage()
        {
            var objs = TestResourceFactory.GetMockClassAObjects(5000).ToList();

            var seedIndex = new Seed32();
            var seedSegment = new Seed64();

            objs.ForEach(o => o.Id = seedIndex.Increment());
            var toAdd = objs.Select(o => new Tuple<MockClassA, long>(o, seedSegment.Increment())).ToList();

            using (var tree = new NTree<int, MockClassA, long>("Id"))
            {
                var ids = tree.AddOrUpdateRange(toAdd);

                Assert.AreEqual(5000, tree.Length);

                Assert.AreEqual(5, tree.GetFirstByIndex(5));
                Assert.AreEqual(5, tree.GetFirstBySegment(5));
                Assert.AreEqual(1, tree.GetByIndex(5).Count());

                using (var p = tree.GetPageStream(8))
                {
                    Assert.AreEqual(0, p.Length);
                }
            }
        }
开发者ID:thehexgod,项目名称:BESSY-DB,代码行数:26,代码来源:NTreeNonUniqueTests.cs


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