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


C# ConcurrentDictionary.Remove方法代码示例

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


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

示例1: TestDuplicateRemove

        public void TestDuplicateRemove()
        {
            var dict = new ConcurrentDictionary<int, string>();

            dict.Add(3, string.Empty);

            dict.Remove(3);
            dict.Remove(3);
        }
开发者ID:hanson-huang,项目名称:Encore,代码行数:9,代码来源:ConcurrentDictionaryExtensionsTest.cs

示例2: TestLockFreeDictionary

        public void TestLockFreeDictionary()
        {
            IDictionary<int, Guid> dict = new ConcurrentDictionary<int, Guid>();

            KeyValuePair<int, Guid> test = new KeyValuePair<int, Guid>(-64, Guid.NewGuid());

            dict.Add(42, Guid.NewGuid());
            dict.Add(22, Guid.NewGuid());
            dict.Add(test);
            dict.Add(55, Guid.NewGuid());

            Assert.IsTrue(dict.ContainsKey(-64));
            Assert.IsTrue(dict.Contains(test));
            Assert.IsFalse(dict.Contains(new KeyValuePair<int, Guid>(-64, new Guid())));

            dict[-64] = Guid.NewGuid();
            Assert.IsFalse(dict.Contains(test));

            Guid newID = Guid.NewGuid();
            dict[12] = newID;
            Guid id = dict[12];

            Assert.IsTrue(newID == id);

            Assert.IsTrue(dict.Count == 5);

            dict.Remove(-64);
            Assert.IsTrue(dict.Count == 4);

        }
开发者ID:mbmccormick,项目名称:Ximura,代码行数:30,代码来源:Test_Collections_Dictionary.cs

示例3: Remove_WithKeyValuePairThrowsNotImplementedException

        public void Remove_WithKeyValuePairThrowsNotImplementedException()
        {
            // Arrange
            ConcurrentDictionary<int, int> dictionary = new ConcurrentDictionary<int, int>();

            // Act/Assert
            Assert.Throws<NotImplementedException>(() => dictionary.Remove(new KeyValuePair<int, int>(0, 0)));
        }
开发者ID:huangw-t,项目名称:aspnetwebstack,代码行数:8,代码来源:ConcurrentDictionaryTests.cs

示例4: Remove_ThrowsNotImplementedException

        public void Remove_ThrowsNotImplementedException()
        {
            // Arrange
            ConcurrentDictionary<int, int> dictionary = new ConcurrentDictionary<int, int>();

            // Act/Assert
            Assert.Throws<NotImplementedException>(() => dictionary.Remove(0));
        }
开发者ID:huangw-t,项目名称:aspnetwebstack,代码行数:8,代码来源:ConcurrentDictionaryTests.cs

示例5: LoadChannels

 private void LoadChannels(ConcurrentDictionary<ulong, UserEventCallback> dict)
 {
     foreach (var pair in dict)
     {
         try
         {
             pair.Value.Channel = _client.GetServer(pair.Key).GetChannel(pair.Value.ChannelId);
         }
         catch (NullReferenceException)
         {
             Logger.FormattedWrite("AnnounceLoad",
                 $"Failed loading channel {pair.Value.ChannelId} for server {pair.Key}. Removing",
                 ConsoleColor.Yellow);
             dict.Remove(pair.Key);
         }
     }
 }
开发者ID:SSStormy,项目名称:Stormbot,代码行数:17,代码来源:AnnouncementModule.cs


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