Skip to content

Commit

Permalink
Implemented a fix for issue #35
Browse files Browse the repository at this point in the history
  • Loading branch information
stewienj committed Dec 19, 2024
1 parent 7e9aefe commit c8cf693
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions Swordfish.NET.CollectionsV3/ImmutableDictionaryListPair.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ public ImmutableDictionaryListPair<TKey, TValue> AddRange(IEnumerable<KeyValuePa
// Create the list of nodes for the internal list
var nodes = pairs.SelectWithPreviousResult(
firstItem => new ObservableDictionaryNode<TKey, TValue>(firstItem, endNode),
(previousNode, pair) => new ObservableDictionaryNode<TKey, TValue>(pair, previousNode));
(previousNode, pair) => new ObservableDictionaryNode<TKey, TValue>(pair, previousNode))
.ToList();

// create the key/value pairs for the internal dictionary
var dictionaryEntries = nodes.Select(node => KeyValuePair.Create(node.Key, node));
Expand Down Expand Up @@ -151,7 +152,9 @@ public ImmutableDictionaryListPair<TKey, TValue> RemoveRange(IList<TKey> keys)
var nodesToRemove = keys.Where(key => Dictionary.ContainsKey(key)).Select(key => Dictionary[key]);
if (nodesToRemove.Any())
{
return new ImmutableDictionaryListPair<TKey, TValue>(Dictionary.RemoveRange(keys), List.RemoveRange(nodesToRemove));
var newDictionary = Dictionary.RemoveRange(keys);
var newList = List.RemoveRange(nodesToRemove);
return new ImmutableDictionaryListPair<TKey, TValue>(newDictionary, newList);
}

else
Expand Down

0 comments on commit c8cf693

Please sign in to comment.