Created
December 30, 2016 19:56
-
-
Save GER-NaN/0fcbb6b7f42454c249f25ba1994cd366 to your computer and use it in GitHub Desktop.
List of Node
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
https://msdn.microsoft.com/en-us/library/ms379572(v=vs.80).aspx | |
An Extensive Examination of Data Structures Using C# 2.0 | |
Visual Studio 2005 | |
Scott Mitchell | |
4GuysFromRolla.com | |
Update January 2005 | |
*/ | |
public class NodeList<T> : Collection<Node<T>> | |
{ | |
public NodeList() : base() { } | |
public NodeList(int initialSize) | |
{ | |
// Add the specified number of items | |
for (int i = 0; i < initialSize; i++) | |
base.Items.Add(default(Node<T>)); | |
} | |
public Node<T> FindByValue(T value) | |
{ | |
// search the list for the value | |
foreach (Node<T> node in Items) | |
if (node.Value.Equals(value)) | |
return node; | |
// if we reached here, we didn't find a matching node | |
return null; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment