﻿<?xml version="1.0" encoding="utf-8"?><rss version="2.0"><channel><title>Ayende @ Rahien</title><link>http://ayende.com</link><description>Ayende @ Rahien</description><copyright>Copyright (C) Ayende Rahien  2004 - 2021 (c) 2026</copyright><ttl>60</ttl><item><title>Wesner Moise commented on Find the bug: A broken tree</title><description>Code Review:
  
You should really design the function to return the same object if no node has been deleted.... rather than offering an out removed parameter.
</description><link>http://ayende.com/4703/find-the-bug-a-broken-tree#comment12</link><guid>http://ayende.com/4703/find-the-bug-a-broken-tree#comment12</guid><pubDate>Wed, 01 Dec 2010 10:01:32 GMT</pubDate></item><item><title>Frank Quednau commented on Find the bug: A broken tree</title><description>Remember vaguely that out and ref can give you some nastiness especially passing it around forward and sideways...
</description><link>http://ayende.com/4703/find-the-bug-a-broken-tree#comment11</link><guid>http://ayende.com/4703/find-the-bug-a-broken-tree#comment11</guid><pubDate>Thu, 25 Nov 2010 17:08:50 GMT</pubDate></item><item><title>nickd commented on Find the bug: A broken tree</title><description>In the complex case the  value out parameter is set to the child replacing the node. Like I just noticed Patrick said,
</description><link>http://ayende.com/4703/find-the-bug-a-broken-tree#comment10</link><guid>http://ayende.com/4703/find-the-bug-a-broken-tree#comment10</guid><pubDate>Thu, 25 Nov 2010 15:34:37 GMT</pubDate></item><item><title>Nick commented on Find the bug: A broken tree</title><description>int compare = comparer.Compare(key, theKey);
  
  
I cannot see a declaration of the variable "theKey".
</description><link>http://ayende.com/4703/find-the-bug-a-broken-tree#comment9</link><guid>http://ayende.com/4703/find-the-bug-a-broken-tree#comment9</guid><pubDate>Thu, 25 Nov 2010 14:58:39 GMT</pubDate></item><item><title>Patrick Huizinga commented on Find the bug: A broken tree</title><description>When the matching node has two children, you can trust 
__result
 (to be true). However 
__value
 will in this case have the value of replacing node.
</description><link>http://ayende.com/4703/find-the-bug-a-broken-tree#comment8</link><guid>http://ayende.com/4703/find-the-bug-a-broken-tree#comment8</guid><pubDate>Thu, 25 Nov 2010 14:29:31 GMT</pubDate></item><item><title>Chaviv commented on Find the bug: A broken tree</title><description>Not wearing my code glasses. My bad. I read the code wrong. It would have been easier to read it as:
  
  
Check if both are not empty
  
Left not empty
  
Right not empty
  
else (both empty)
</description><link>http://ayende.com/4703/find-the-bug-a-broken-tree#comment7</link><guid>http://ayende.com/4703/find-the-bug-a-broken-tree#comment7</guid><pubDate>Thu, 25 Nov 2010 10:45:11 GMT</pubDate></item><item><title>Ayende Rahien commented on Find the bug: A broken tree</title><description>Omer,
  
BINGO!
</description><link>http://ayende.com/4703/find-the-bug-a-broken-tree#comment6</link><guid>http://ayende.com/4703/find-the-bug-a-broken-tree#comment6</guid><pubDate>Thu, 25 Nov 2010 10:30:20 GMT</pubDate></item><item><title>Ayende Rahien commented on Find the bug: A broken tree</title><description>Chaviv,
  
How come?
  
If both Right &amp; Left are not empty, it is hit.
</description><link>http://ayende.com/4703/find-the-bug-a-broken-tree#comment5</link><guid>http://ayende.com/4703/find-the-bug-a-broken-tree#comment5</guid><pubDate>Thu, 25 Nov 2010 10:29:41 GMT</pubDate></item><item><title>configurator commented on Find the bug: A broken tree</title><description>Chaviv: Which if would match the case of having two children, then?
</description><link>http://ayende.com/4703/find-the-bug-a-broken-tree#comment4</link><guid>http://ayende.com/4703/find-the-bug-a-broken-tree#comment4</guid><pubDate>Thu, 25 Nov 2010 10:29:04 GMT</pubDate></item><item><title>Omer Mor commented on Find the bug: A broken tree</title><description>If we have a match (compare == 0) we set removed to be true (which is right), but later, if both right &amp; left are not empty, we overwrite this value with the result of removing from the right side.
  
So you can't trust the "removed" result in this scenario.
</description><link>http://ayende.com/4703/find-the-bug-a-broken-tree#comment3</link><guid>http://ayende.com/4703/find-the-bug-a-broken-tree#comment3</guid><pubDate>Thu, 25 Nov 2010 10:28:59 GMT</pubDate></item><item><title>Chaviv commented on Find the bug: A broken tree</title><description>The else case is never hit.
  
  
else
  
        {
  
            // We have two children. Remove the next-highest node and replace
  
            // this node with it.
  
            IBinarySearchTree
&lt;tkey,&gt;
 successor = Right;
  
            while (!successor.Left.IsEmpty)
  
                successor = successor.Left;
  
            result = new AVLTree
&lt;tkey,&gt;
(comparer, deepCopyKey, deepCopyValue, successor.Key, 
  
                successor.Value, Left, Right.TryRemove(successor.Key, out removed, out value));
  
        }
</description><link>http://ayende.com/4703/find-the-bug-a-broken-tree#comment2</link><guid>http://ayende.com/4703/find-the-bug-a-broken-tree#comment2</guid><pubDate>Thu, 25 Nov 2010 10:27:51 GMT</pubDate></item><item><title>configurator commented on Find the bug: A broken tree</title><description>There's a picture of a tree all over it... Is that it?
</description><link>http://ayende.com/4703/find-the-bug-a-broken-tree#comment1</link><guid>http://ayende.com/4703/find-the-bug-a-broken-tree#comment1</guid><pubDate>Thu, 25 Nov 2010 10:16:31 GMT</pubDate></item></channel></rss>