Re: Calling fire and forget methods.
Ryan Heath <[email protected]> Tue, 26 Feb 2008 13:48:13 +0100
| Newsgroups | gmane.comp.windows.devel.dotnet.clr |
|---|---|
| Message-ID | <[email protected]> |
Be careful, this [1] is written in gmail's c# editor too ;)
HTH
// Ryan
[1]
TreeNode parent = this;
bool added = false;
while ( !added)
{
if ( parent.item == null)
{
parent.item = item;
added = true;
}
else if ( item < parent.item)
{
if ( parent.lhs == null)
{
parent.lhs = new TreeNode();
}
parent = parent.lhs;
}
else
{
if ( parent.rhs == null)
{
parent.rhs = new TreeNode();
}
parent = parent.rhs;
}
}
On Tue, Feb 26, 2008 at 1: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