473,473 Members | 2,031 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

how is TreeNodeCollection.Find implemented?

Hi,

If you look at TreeNodeCollection.Find Method, you'll see:

Finds the tree nodes with specified key, optionally searching subnodes.

public TreeNode[] Find (
string key,
bool searchAllChildren
)

My question is - how is the find impelmented? is there a hash that
holds the keys or does the Find method really go over each node and
search for the key?

Thanks
Engel

Mar 29 '06 #1
2 6257

en**********@gmail.com wrote:
Hi,

If you look at TreeNodeCollection.Find Method, you'll see:

Finds the tree nodes with specified key, optionally searching subnodes.

public TreeNode[] Find (
string key,
bool searchAllChildren
)

My question is - how is the find impelmented?
For all such questions, you can discover the answer yourself using Lutz
Roeder's Reflector (google result 1 for 'reflector'), which is
basically a .NET disassembler: point it at System.Windows.Forms.dll
and...
is there a hash that
holds the keys or does the Find method really go over each node and
search for the key?


public TreeNode[] Find(string key, bool searchAllChildren)
{
ArrayList list1 = this.FindInternal(key, searchAllChildren, this,
new ArrayList());
TreeNode[] nodeArray1 = new TreeNode[list1.Count];
list1.CopyTo(nodeArray1, 0);
return nodeArray1;
}

private ArrayList FindInternal(string key, bool searchAllChildren,
TreeNodeCollection treeNodeCollectionToLookIn, ArrayList
foundTreeNodes)
{
if ((treeNodeCollectionToLookIn == null) || (foundTreeNodes ==
null))
{
return null;
}
for (int num1 = 0; num1 < treeNodeCollectionToLookIn.Count;
num1++)
{
if ((treeNodeCollectionToLookIn[num1] != null) &&
WindowsFormsUtils.SafeCompareStrings(treeNodeColle ctionToLookIn[num1].Name,
key, true))
{
foundTreeNodes.Add(treeNodeCollectionToLookIn[num1]);
}
}
if (searchAllChildren)
{
for (int num2 = 0; num2 < treeNodeCollectionToLookIn.Count;
num2++)
{
if (((treeNodeCollectionToLookIn[num2] != null) &&
(treeNodeCollectionToLookIn[num2].Nodes != null)) &&
(treeNodeCollectionToLookIn[num2].Nodes.Count > 0))
{
foundTreeNodes = this.FindInternal(key,
searchAllChildren, treeNodeCollectionToLookIn[num2].Nodes,
foundTreeNodes);
}
}
}
return foundTreeNodes;
}

--
Larry Lard
Replies to group please

Mar 29 '06 #2
Thanks!

Mar 29 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Greg Baker | last post by:
I don't know what standard protocol is in this newsgroup. Am I allowed to post code and ask for help? I hope so.. :) Here's my problem: I am trying problem 127 of the valladolid online...
14
by: Stegano | last post by:
I am learning C Programming after working with Java for 5 years. I want to know where can I find the source files for C language itself. For example strcat is a function, which concatenates two...
0
by: | last post by:
I have derived new classes for the TreeNode and TreeView classes that Microsoft provides. Since the TreeNodeCollection class is sealed I created my own class that implements the IList interface....
4
by: Chuck Bowling | last post by:
I have a serialized TreeNodeCollection that I want to initialize a TreeView with. Is there a simple assignment I can use for this or do I have to iterate thru the collection and add individual...
2
by: Dmitriy Kolesnik | last post by:
Hello, All! I have next problem: I need to override TreeNodeCollection method Add(), but I know that I can't inherited from TreeNodeCollection. How I can resolve this problem? Help me please...
0
by: Patrick.O.Ige | last post by:
I have this code below. All its suppose to do is to EXPAND / COLLAPSE ALL of my treeview. But when i use ASP.NET WEbmatrix it all works fine .. But with VS.NET is says TreeNodeCollection not...
6
by: bobueland | last post by:
The module string has a function called translate. I tried to find the source code for that function. In: C:\Python24\Lib there is one file called string.py I open it and it says
3
by: escristian | last post by:
Hello. I am trying to use a specific IComparer object to sort the nodes of my TreeView. Now if it was an Array I could simply call Sort() and pass it my IComparer object. But with the...
5
by: Larry__Weiss | last post by:
Can a C# program find out what language an assembly (or components thereof) is written in? - Larry
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.