Re: Calling fire and forget methods.
Stoyan Damov <[email protected]> Tue, 26 Feb 2008 14:47:39 +0200
| Newsgroups | gmane.comp.windows.devel.dotnet.clr |
|---|---|
| Message-ID | <[email protected]> |
Sure -
current item = root item
while (item being added less than current item)
{
current item = current item.left child
}
while (item being added bigger than current item)
{
current item = current item.right child
}
current item.add(item)
That helps?
Cheers
On Tue, Feb 26, 2008 at 2:36 PM, Davy J <[email protected]> wrote:
> Hi all.
> I've got a Binary tree implementation that I need a little help with.
> my problem is the recursive lhs.Add(item) and rhs.Add(item) call, is there
> any way I could refactor this to remove the stack dependancy?
>
> the application is written in Net.2.0 , so no fancy linq replys please :)
>
> Cheers
>
> Dave.
>
> the psudeo code for the Add function. (written in gmail's c# editor)
>
> public void Add(T item)
> {
> if (this.item == null)
> {
> this.item = item;
> return;
> }
> if (item < this.item)
> {
> if (lhs == null)
> {
> lhs = new TreeNode<T>();
> }
> lhs.Add(item);
> }
> else
> {
> if (rhs == null)
> {
> rhs = new TreeNode<T>();
> }
> rhs.Add(item);
> }
> }
>
> ===================================
> This list is hosted by DevelopMentor(R) http://www.develop.com
>
> View archives and manage your subscription(s) at http://discuss.develop.com
>
===================================
This list is hosted by DevelopMentor® http://www.develop.com
View archives and manage your subscription(s) at http://discuss.develop.com