This is an automated email from the ASF dual-hosted git repository.
tabish pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/qpid-proton-dotnet.git
The following commit(s) were added to refs/heads/main by this push:
new 212b734 PROTON-2576 Ensure tracking map is updated correctly on remove
212b734 is described below
commit 212b734af10e1dc2770ba92407b3693fefdc9abd
Author: Timothy Bish <[email protected]>
AuthorDate: Mon Jul 11 12:05:53 2022 -0400
PROTON-2576 Ensure tracking map is updated correctly on remove
Fix issue of tracking map improperly joining elements after an inner
remove from the tree.
---
src/Proton/Utilities/SplayedDictionary.cs | 3 +++
.../Utilities/SplayedDictionaryTest.cs | 24 ++++++++++++++++++++++
2 files changed, 27 insertions(+)
diff --git a/src/Proton/Utilities/SplayedDictionary.cs
b/src/Proton/Utilities/SplayedDictionary.cs
index 0490530..273f39b 100644
--- a/src/Proton/Utilities/SplayedDictionary.cs
+++ b/src/Proton/Utilities/SplayedDictionary.cs
@@ -993,6 +993,9 @@ namespace Apache.Qpid.Proton.Utilities
{
replacement = Splay(node.left, node.Key);
replacement.right = node.right;
+ if (replacement.right != null) {
+ replacement.right.parent = replacement;
+ }
}
if (replacement != null)
diff --git a/test/Proton.Tests/Utilities/SplayedDictionaryTest.cs
b/test/Proton.Tests/Utilities/SplayedDictionaryTest.cs
index aad33fe..4ad982e 100644
--- a/test/Proton.Tests/Utilities/SplayedDictionaryTest.cs
+++ b/test/Proton.Tests/Utilities/SplayedDictionaryTest.cs
@@ -1115,6 +1115,30 @@ namespace Apache.Qpid.Proton.Utilities
}
}
+ [Test]
+ public void TestRemoveFromNonRootLocations()
+ {
+ SplayedDictionary<uint, string> testMap = new();
+
+ for (uint i = 0; i < 9; i++)
+ {
+ uint x = i;
+ testMap.Add(x, i.ToString());
+ }
+
+ Assert.IsTrue(testMap.Contains(3u));
+
+ Assert.IsTrue(testMap.RemoveValue("3"));
+ Assert.IsTrue(testMap.RemoveValue("7"));
+ Assert.IsTrue(testMap.RemoveValue("1"));
+ Assert.IsTrue(testMap.RemoveValue("0"));
+ Assert.IsTrue(testMap.RemoveValue("8"));
+ Assert.IsTrue(testMap.RemoveValue("5"));
+ Assert.IsTrue(testMap.RemoveValue("6"));
+ Assert.IsTrue(testMap.RemoveValue("2"));
+ Assert.IsTrue(testMap.RemoveValue("4"));
+ }
+
protected void DumpRandomDataSet(int iterations, bool bounded)
{
uint[] dataSet = new uint[iterations];
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]