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


C# KeyValuePair.Skip方法代码示例

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


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

示例1: CopyToTest

 public void CopyToTest()
 {
     for (int y = 1900; y < 2123; y++) {
         var values = CreateZmanim(y);
         var array = new KeyValuePair<DateTime, ZmanimInfo>[values.Length + 33];
         new YearlyZmanimDictionary(y, values).CopyTo(array, 33);
         Assert.IsTrue(array.Skip(33).Select(kvp => kvp.Value).SequenceEqual(values));
         Assert.IsTrue(array.Skip(33).All(kvp => kvp.Key == kvp.Value.Date));
     }
 }
开发者ID:ShomreiTorah,项目名称:Libraries,代码行数:10,代码来源:YearlyZmanimDictionaryTest.cs

示例2: CopyToTest

        public void CopyToTest()
        {
            var dict = new ShieldedDict<int, object>(
                Enumerable.Range(1, 1000).Select(i =>
                    new KeyValuePair<int, object>(i, new object())).ToArray());
            Assert.AreEqual(1000, dict.Count);

            var array = new KeyValuePair<int, object>[1100];
            // this works out of transaction (and consequently, so do ToArray and ToList), by opening
            // a transaction itself. that could not be done when you do a foreach.
            ((ICollection<KeyValuePair<int, object>>)dict).CopyTo(array, 100);
            var keys = new HashSet<int>();
            foreach (var kvp in array.Skip(100))
            {
                Assert.IsTrue(dict.ContainsKey(kvp.Key));
                Assert.IsTrue(keys.Add(kvp.Key));
                Assert.AreEqual(dict[kvp.Key], kvp.Value);
            }
        }
开发者ID:wizardbeard,项目名称:Shielded,代码行数:19,代码来源:DictionaryTests.cs

示例3: CopyToTest

        public void CopyToTest()
        {
            var tree = new ShieldedTree<int, object>();
            ParallelEnumerable.Range(1, 1000).ForAll(
                i => Shield.InTransaction(() => tree.Add(i, new object())));
            Assert.AreEqual(1000, tree.Count);

            var array = new KeyValuePair<int, object>[1100];
            ((ICollection<KeyValuePair<int, object>>)tree).CopyTo(array, 100);
            var expected = 1;
            foreach (var kvp in array.Skip(100))
            {
                Assert.IsTrue(tree.ContainsKey(kvp.Key));
                Assert.AreEqual(expected, kvp.Key);
                Assert.AreEqual(tree[kvp.Key], kvp.Value);
                expected++;
            }
        }
开发者ID:jbakic,项目名称:Shielded,代码行数:18,代码来源:TreeTests.cs

示例4: CopyTo_IndexNonZero_ValuesCopied

        public void CopyTo_IndexNonZero_ValuesCopied()
        {
            Trie<string, char, int> trie = new Trie<string, char, int>();

            trie.Add("key1", 5);
            trie.Add("key2", 6);

            KeyValuePair<string, int>[] vals = new KeyValuePair<string, int>[4];
            trie.CopyTo(vals, 2);

            Assert.AreEqual(0, vals[0].Value);
            Assert.AreEqual(0, vals[1].Value);
            Assert.IsTrue(vals.Skip(2).Any(k => k.Key == "key1" && k.Value == 5));
            Assert.IsTrue(vals.Skip(2).Any(k => k.Key == "key2" && k.Value == 6));
        }
开发者ID:flashcurd,项目名称:Shared.Utilities,代码行数:15,代码来源:TrieTests.cs


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