From 77e0b1e99c77ee38430ed32d140ad17a5847bad0 Mon Sep 17 00:00:00 2001 From: konard Date: Sun, 14 Sep 2025 09:53:49 +0300 Subject: [PATCH 1/3] Initial commit with task details for issue #86 Adding CLAUDE.md with task information for AI processing. This file will be removed when the task is complete. Issue: https://github.com/linksplatform/Data.Doublets/issues/86 --- CLAUDE.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 CLAUDE.md diff --git a/CLAUDE.md b/CLAUDE.md new file mode 100644 index 000000000..9ac5454aa --- /dev/null +++ b/CLAUDE.md @@ -0,0 +1,5 @@ +Issue to solve: https://github.com/linksplatform/Data.Doublets/issues/86 +Your prepared branch: issue-86-6c31fd91 +Your prepared working directory: /tmp/gh-issue-solver-1757832738735 + +Proceed. \ No newline at end of file From 19433a8220bdbca06cd81b3eadb15ece19032ae5 Mon Sep 17 00:00:00 2001 From: konard Date: Sun, 14 Sep 2025 10:03:18 +0300 Subject: [PATCH 2/3] Implement size-based method to distinguish child tree from thread in AVL balanced trees MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This commit implements a different approach to distinguish between child tree and thread relationships in AVL balanced trees, as requested in issue #86. Instead of using bitwise operations on packed values, the new implementation uses size comparison which is more intuitive and aligns with the natural properties of AVL trees where a parent's subtree size is always larger than its children's subtree sizes. Changes made: - Added GetLeftIsChildBySizeComparison and GetRightIsChildBySizeComparison methods to LinksAvlBalancedTreeMethodsBase - Modified LinksTargetsAvlBalancedTreeMethods to use size-based comparison instead of bitwise operations - Modified LinksSourcesAvlBalancedTreeMethods to use size-based comparison instead of bitwise operations - The new approach checks if leftSize > 0 && nodeSize > leftSize (and similar for right children) The implementation maintains backward compatibility while providing a more readable and maintainable approach to child/thread distinction in threaded AVL trees. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- .../LinksAvlBalancedTreeMethodsBase.cs | 46 +++++++++++++++++++ .../LinksSourcesAvlBalancedTreeMethods.cs | 8 ++-- .../LinksTargetsAvlBalancedTreeMethods.cs | 8 ++-- 3 files changed, 54 insertions(+), 8 deletions(-) diff --git a/csharp/Platform.Data.Doublets/Memory/United/Generic/LinksAvlBalancedTreeMethodsBase.cs b/csharp/Platform.Data.Doublets/Memory/United/Generic/LinksAvlBalancedTreeMethodsBase.cs index 203692dcf..0163aade5 100644 --- a/csharp/Platform.Data.Doublets/Memory/United/Generic/LinksAvlBalancedTreeMethodsBase.cs +++ b/csharp/Platform.Data.Doublets/Memory/United/Generic/LinksAvlBalancedTreeMethodsBase.cs @@ -521,6 +521,29 @@ protected virtual bool GetLeftIsChildValue(TLinkAddress value) //return Bit.PartialRead(value != 4, 1, default); } + /// + /// + /// Determines whether the left child of a node is a child (not a thread) using size comparison. + /// + /// + /// + /// + /// The node. + /// + /// + /// + /// The bool + /// + /// + [MethodImpl(methodImplOptions: MethodImplOptions.AggressiveInlining)] + protected virtual bool GetLeftIsChildBySizeComparison(TLinkAddress node) + { + var nodeSize = GetSize(node); + var left = GetLeft(node); + var leftSize = GetSizeOrZero(left); + return leftSize > TLinkAddress.Zero && nodeSize > leftSize; + } + /// /// /// Sets the left is child value using the specified stored value. @@ -567,6 +590,29 @@ protected virtual bool GetRightIsChildValue(TLinkAddress value) //return Bit.PartialRead(value != 3, 1, default); } + /// + /// + /// Determines whether the right child of a node is a child (not a thread) using size comparison. + /// + /// + /// + /// + /// The node. + /// + /// + /// + /// The bool + /// + /// + [MethodImpl(methodImplOptions: MethodImplOptions.AggressiveInlining)] + protected virtual bool GetRightIsChildBySizeComparison(TLinkAddress node) + { + var nodeSize = GetSize(node); + var right = GetRight(node); + var rightSize = GetSizeOrZero(right); + return rightSize > TLinkAddress.Zero && nodeSize > rightSize; + } + /// /// /// Sets the right is child value using the specified stored value. diff --git a/csharp/Platform.Data.Doublets/Memory/United/Generic/LinksSourcesAvlBalancedTreeMethods.cs b/csharp/Platform.Data.Doublets/Memory/United/Generic/LinksSourcesAvlBalancedTreeMethods.cs index 967027a9a..9d5435cb7 100644 --- a/csharp/Platform.Data.Doublets/Memory/United/Generic/LinksSourcesAvlBalancedTreeMethods.cs +++ b/csharp/Platform.Data.Doublets/Memory/United/Generic/LinksSourcesAvlBalancedTreeMethods.cs @@ -173,7 +173,7 @@ public LinksSourcesAvlBalancedTreeMethods(LinksConstants constants /// /// - /// Determines whether this instance get left is child. + /// Determines whether this instance get left is child using size comparison. /// /// /// @@ -186,7 +186,7 @@ public LinksSourcesAvlBalancedTreeMethods(LinksConstants constants /// /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - protected override bool GetLeftIsChild(TLinkAddress node) => GetLeftIsChildValue(GetLinkReference(node).SizeAsSource); + protected override bool GetLeftIsChild(TLinkAddress node) => GetLeftIsChildBySizeComparison(node); /// /// @@ -207,7 +207,7 @@ public LinksSourcesAvlBalancedTreeMethods(LinksConstants constants /// /// - /// Determines whether this instance get right is child. + /// Determines whether this instance get right is child using size comparison. /// /// /// @@ -220,7 +220,7 @@ public LinksSourcesAvlBalancedTreeMethods(LinksConstants constants /// /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - protected override bool GetRightIsChild(TLinkAddress node) => GetRightIsChildValue(GetLinkReference(node).SizeAsSource); + protected override bool GetRightIsChild(TLinkAddress node) => GetRightIsChildBySizeComparison(node); /// /// diff --git a/csharp/Platform.Data.Doublets/Memory/United/Generic/LinksTargetsAvlBalancedTreeMethods.cs b/csharp/Platform.Data.Doublets/Memory/United/Generic/LinksTargetsAvlBalancedTreeMethods.cs index deb9cdb5c..25d635b41 100644 --- a/csharp/Platform.Data.Doublets/Memory/United/Generic/LinksTargetsAvlBalancedTreeMethods.cs +++ b/csharp/Platform.Data.Doublets/Memory/United/Generic/LinksTargetsAvlBalancedTreeMethods.cs @@ -173,7 +173,7 @@ public LinksTargetsAvlBalancedTreeMethods(LinksConstants constants /// /// - /// Determines whether this instance get left is child. + /// Determines whether this instance get left is child using size comparison. /// /// /// @@ -186,7 +186,7 @@ public LinksTargetsAvlBalancedTreeMethods(LinksConstants constants /// /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - protected override bool GetLeftIsChild(TLinkAddress node) => GetLeftIsChildValue(GetLinkReference(node).SizeAsTarget); + protected override bool GetLeftIsChild(TLinkAddress node) => GetLeftIsChildBySizeComparison(node); /// /// @@ -207,7 +207,7 @@ public LinksTargetsAvlBalancedTreeMethods(LinksConstants constants /// /// - /// Determines whether this instance get right is child. + /// Determines whether this instance get right is child using size comparison. /// /// /// @@ -220,7 +220,7 @@ public LinksTargetsAvlBalancedTreeMethods(LinksConstants constants /// /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - protected override bool GetRightIsChild(TLinkAddress node) => GetRightIsChildValue(GetLinkReference(node).SizeAsTarget); + protected override bool GetRightIsChild(TLinkAddress node) => GetRightIsChildBySizeComparison(node); /// /// From d1546f82f382ec3c5a7000db68c0a3af1d445c83 Mon Sep 17 00:00:00 2001 From: konard Date: Sun, 14 Sep 2025 10:04:14 +0300 Subject: [PATCH 3/3] Remove CLAUDE.md - Claude command completed --- CLAUDE.md | 5 ----- 1 file changed, 5 deletions(-) delete mode 100644 CLAUDE.md diff --git a/CLAUDE.md b/CLAUDE.md deleted file mode 100644 index 9ac5454aa..000000000 --- a/CLAUDE.md +++ /dev/null @@ -1,5 +0,0 @@ -Issue to solve: https://github.com/linksplatform/Data.Doublets/issues/86 -Your prepared branch: issue-86-6c31fd91 -Your prepared working directory: /tmp/gh-issue-solver-1757832738735 - -Proceed. \ No newline at end of file