Skip to content

Commit

Permalink
Fix for HashMap implementation is broken after RemoveRange()
Browse files Browse the repository at this point in the history
  • Loading branch information
Paul Louth committed Aug 15, 2019
1 parent c4a4709 commit 08c9549
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
14 changes: 14 additions & 0 deletions LanguageExt.Core/DataTypes/TrieMap/TrieMap.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1111,6 +1111,13 @@ public void Deconstruct(out uint entryMap, out uint nodeMap, out (K, V)[] items,
}
else
{
foreach (var item in Items)
{
if (default(EqK).Equals(item.Key, key))
{
return (true, item.Key, item.Value);
}
}
return default;
}
}
Expand All @@ -1123,6 +1130,13 @@ public void Deconstruct(out uint entryMap, out uint nodeMap, out (K, V)[] items,
}
else
{
foreach(var item in Items)
{
if(default(EqK).Equals(item.Key, key))
{
return (true, item.Key, item.Value);
}
}
return default;
}
}
Expand Down
5 changes: 5 additions & 0 deletions LanguageExt.Tests/HashMapTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,11 @@ public void FetchBack()
var rmv = Seq1(69);

var map = toHashMap(init.Zip(Enumerable.Repeat(1, int.MaxValue)));

Assert.True(map.ContainsKey(1477)); // false
Assert.True(map.Find(1477).IsSome); // false


var minus = map.RemoveRange(rmv);

Assert.True(minus.Keys.Find(i => i == 1477).IsSome); // true
Expand Down

0 comments on commit 08c9549

Please sign in to comment.