wasSharp

Subversion Repositories:
Compare Path: Rev
With Path: Rev
?path1? @ 44  →  ?path2? @ 45
/Collections/Utilities/CollectionExtensions.cs
@@ -7,6 +7,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using wasSharp.Collections.Specialized;
 
namespace wasSharp.Collections.Utilities
@@ -33,36 +34,6 @@
.OrderBy(kvp => kvp.Key));
}
 
public static void UnionWith<TKey, TValue>(this IDictionary<TKey, TValue> target,
IDictionary<TKey, TValue> source)
{
var LockObject = new object();
source.AsParallel().ForAll(o =>
{
bool hasElement;
lock (LockObject)
{
hasElement = target.ContainsKey(o.Key);
}
switch (hasElement)
{
case true:
lock (LockObject)
{
target[o.Key] = o.Value;
}
break;
 
default:
lock (LockObject)
{
target.Add(o.Key, o.Value);
}
break;
}
});
}
 
public static void AddOrReplace<TKey, TValue>(this IDictionary<TKey, TValue> dictionary, TKey key, TValue value)
{
switch (dictionary.ContainsKey(key))