diff options
Diffstat (limited to 'src/Ryujinx.Cpu/Jit/HostTracked/AddressIntrusiveRedBlackTree.cs')
| -rw-r--r-- | src/Ryujinx.Cpu/Jit/HostTracked/AddressIntrusiveRedBlackTree.cs | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/src/Ryujinx.Cpu/Jit/HostTracked/AddressIntrusiveRedBlackTree.cs b/src/Ryujinx.Cpu/Jit/HostTracked/AddressIntrusiveRedBlackTree.cs new file mode 100644 index 00000000..0e244330 --- /dev/null +++ b/src/Ryujinx.Cpu/Jit/HostTracked/AddressIntrusiveRedBlackTree.cs @@ -0,0 +1,35 @@ +using Ryujinx.Common.Collections; +using System; + +namespace Ryujinx.Cpu.Jit.HostTracked +{ + internal class AddressIntrusiveRedBlackTree<T> : IntrusiveRedBlackTree<T> where T : IntrusiveRedBlackTreeNode<T>, IComparable<T>, IComparable<ulong> + { + /// <summary> + /// Retrieve the node that is considered equal to the specified address by the comparator. + /// </summary> + /// <param name="address">Address to compare with</param> + /// <returns>Node that is equal to <paramref name="address"/></returns> + public T GetNode(ulong address) + { + T node = Root; + while (node != null) + { + int cmp = node.CompareTo(address); + if (cmp < 0) + { + node = node.Left; + } + else if (cmp > 0) + { + node = node.Right; + } + else + { + return node; + } + } + return null; + } + } +} |
