<?xml version="1.0" encoding="utf-8"?>
<feed
    xmlns="http://www.w3.org/2005/Atom"
    xmlns:at="http://www.sixapart.com/ns/at"
    xmlns:icbm="http://postneo.com/icbm"
    xmlns:rvw="http://purl.org/NET/RVW/0.2/"
    xml:lang="en">
    <title>Life, Opportunity, and Development</title>
    <link rel="self" type="application/atom+xml" title="Life, Opportunity, and Development (Atom)" href="http://cyberkruz.vox.com/library/posts/tags/tutorial/page/1/atom.xml" />
    <link rel="alternate" type="text/html" title="Life, Opportunity, and Development" href="http://cyberkruz.vox.com/library/posts/tags/tutorial/page/1/"/> 
    <link rel="service.post" type="application/atom+xml" title="Life, Opportunity, and Development" href="http://www.vox.com/services/atom/svc=post/collection_id=6a00c2251f2742604a00c2251f2743604a" /> 
    <link rel="service.subscribe" type="application/atom+xml" title="Life, Opportunity, and Development" href="http://cyberkruz.vox.com/library/posts/tags/tutorial/atom.xml" />   
    <link rel="last" type="application/atom+xml" title="Life, Opportunity, and Development" href="http://cyberkruz.vox.com/library/posts/tags/tutorial/page/1/atom.xml" />  
    <category term="tutorial" scheme="http://cyberkruz.vox.com/tags/tutorial/?_c=feed-atom-full" label="tutorial" /> 
    <generator uri="http://www.vox.com/">Vox</generator>
    <updated>2008-02-13T18:50:43Z</updated> 
    <author>
        <name>Matthew Kruskamp</name>
        <uri>http://cyberkruz.vox.com/?_c=feed-atom-full</uri>
    </author> 
    <id>tag:vox.com,2006:6p00c2251f2742604a/tags/tutorial/</id> 
    <subtitle>[witty comment]</subtitle>  
    
    <entry>
        <title>J2EE Custom Simple Tags Part 1</title>   
        <link rel="alternate" type="text/html" title="J2EE Custom Simple Tags Part 1" href="http://cyberkruz.vox.com/library/post/j2ee-custom-simple-tags-part-1.html?_c=feed-atom-full" />  
        <link rel="service.post" type="application/atom+xml" title="J2EE Custom Simple Tags Part 1" href="http://cyberkruz.vox.com/library/post/j2ee-custom-simple-tags-part-1.html?_c=feed-atom-full#comments" /> 
        <link rel="service.edit" type="application/atom+xml" title="J2EE Custom Simple Tags Part 1" href="http://www.vox.com/atom/svc=post/asset_id=6a00c2251f2742604a00d09e6a7647be2b" />          <id>tag:vox.com,2007-05-09:asset-6a00c2251f2742604a00d09e6a7647be2b</id>
        <published>2007-05-09T19:05:22Z</published>
        <updated>2008-02-13T18:50:43Z</updated>
    
        <author>
            <name>Matthew Kruskamp</name>
            <uri>http://cyberkruz.vox.com/?_c=feed-atom-full</uri>
        </author>
    
        
        <content type="html" xml:base="http://cyberkruz.vox.com/?_c=feed-atom-full">
            <![CDATA[
                <div xmlns="http://www.w3.org/1999/xhtml" xmlns:at="http://www.sixapart.com/ns/at">
        <p>Note: This article assumes you have done some Java web development in the past, and you are capable of compiling and executing web applications with J2EE.</p><p><strong>Overview</strong><br />J2EE has done some amazing things in progressing the creation of custom tags. Now it is fairly easy to integrate any custom HTML tag within your application further separating the view from designers. This article will show you how to implement a custom HTML tag that calculates the square of a number by simply placing &lt;math:square num=&quot;12&quot; /&gt; into your web application. Hopefully, you can feel the power with this simple feature.</p><p><strong>Creating the class</strong><br />Every custom tag extends SimpleTagSupport. This is a class implemented by the J2EE spec which allows a class to output information to a jsp. So, lets get right to coding. Create a class in your web application that extends javax.servlet.jsp.tagext.SimpleTagSupport. If you are compiling by hand, the class file must go in the package structure under /WEB-INF/classes/ i.e. /WEB-INF/classes/com/cyberkruz/test/NewMath.class<br />l<br /><blockquote>

<div style="background: white none repeat scroll 0% 50%; font-family: Courier New; font-size: 9pt; color: black; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;">
<p style="margin: 0px;"><span style="color: blue;">package</span> com.cyberkruz.test;</p>
<p style="margin: 0px;">&#160;</p>
<p style="margin: 0px;"><span style="color: blue;">import</span> java.io.*;</p>
<p style="margin: 0px;"><span style="color: blue;">import</span> javax.servlet.jsp.*;</p>
<p style="margin: 0px;"><span style="color: blue;">import</span> javax.servlet.jsp.tagext.SimpleTagSupport;</p>
<p style="margin: 0px;">&#160;</p>

<p style="margin: 0px;"><span style="color: blue;">public</span> <span style="color: blue;">class</span> NewMath <span style="color: blue;">extends</span> SimpleTagSupport {</p>
<p style="margin: 0px;">&#160;</p>
<p style="margin: 0px;">&#160;&#160;&#160; <span style="color: blue;">private</span> <span style="color: teal;">Integer</span> num;</p>
<p style="margin: 0px;">&#160;</p>
<p style="margin: 0px;">&#160;&#160;&#160; <span style="color: green;">/**</span></p>
<p style="margin: 0px;"><span style="color: green;">&#160;&#160;&#160;  * Method overridden which is called</span></p>
<p style="margin: 0px;"><span style="color: green;">&#160;&#160;&#160;  * by the jsp.</span></p>
<p style="margin: 0px;"><span style="color: green;">&#160;&#160;&#160;  */</span></p>

<p style="margin: 0px;">&#160;&#160;&#160; <span style="color: blue;">public</span> <span style="color: blue;">void</span> doTag() <span style="color: blue;">throws</span> JspException, <span style="color: teal;">IOException</span> {</p>
<p style="margin: 0px;">&#160;&#160;&#160; &#160;&#160;&#160; <span style="color: green;">// Gets the jsp context and prints the</span></p>
<p style="margin: 0px;">&#160;&#160;&#160; &#160;&#160;&#160; <span style="color: green;">// number squared.</span></p>
<p style="margin: 0px;">&#160;&#160;&#160; &#160;&#160;&#160; <span style="color: blue;">this</span>.getJspContext().getOut().print(<span style="color: blue;">this</span>.num * <span style="color: blue;">this</span>.num);</p>
<p style="margin: 0px;">&#160;&#160;&#160; }</p>
<p style="margin: 0px;">&#160;</p>
<p style="margin: 0px;">&#160;&#160;&#160; <span style="color: green;">/**</span></p>
<p style="margin: 0px;"><span style="color: green;">&#160;&#160;&#160;  * Sets a number that our custom</span></p>
<p style="margin: 0px;"><span style="color: green;">&#160;&#160;&#160;  * tag squares.</span></p>
<p style="margin: 0px;"><span style="color: green;">&#160;&#160;&#160;  * @param num The number to which</span></p>
<p style="margin: 0px;"><span style="color: green;">&#160;&#160;&#160;  * we want to square.</span></p>
<p style="margin: 0px;"><span style="color: green;">&#160;&#160;&#160;  */</span></p>

<p style="margin: 0px;">&#160;&#160;&#160; <span style="color: blue;">public</span> <span style="color: blue;">void</span> setNum(<span style="color: teal;">Integer</span> num) {</p>
<p style="margin: 0px;">&#160;&#160;&#160; &#160;&#160;&#160; <span style="color: blue;">this</span>.num = num;</p>
<p style="margin: 0px;">&#160;&#160;&#160; }</p>
<p style="margin: 0px;">}</p>
</div>

</blockquote>Every attribute in your custom tag must have a Java Bean mutator property to go with it. This is handled with reflection to send the parameter to your class.</p><p><strong>Configuring the application to use the class<br /></strong>Now, all we have to do is let our application know that the new tag is there. To do so, we can set up a TLD file which looks much like the document descriptor for configuring servlets. So lets do it! Create a new file called MyTags.tld and place it in the /WEB-INF directory. Then type the following:</p><blockquote>

<div style="background: white none repeat scroll 0% 50%; font-family: Courier New; font-size: 9pt; color: black; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;">
<p style="margin: 0px;"><span style="color: blue;">&lt;?</span><span style="color: maroon;">xml</span><span style="color: blue;"> </span><span style="color: red;">version</span><span style="color: blue;">=</span>&quot;<span style="color: blue;">1.0</span>&quot;<span style="color: blue;"> </span><span style="color: red;">encoding</span><span style="color: blue;">=</span>&quot;<span style="color: blue;">iso-8859-1</span>&quot;<span style="color: blue;"> ?&gt;</span></p>
<p style="margin: 0px;"><span style="color: blue;">&lt;</span><span style="color: maroon;">taglib</span><span style="color: blue;"> </span><span style="color: red;">xmlns</span><span style="color: blue;">=</span>&quot;<span style="color: blue;">http://java.sun.com/xml/ns/j2ee</span>&quot;<span style="color: blue;"> </span></p>
<p style="margin: 0px;"><span style="color: blue;">&#160;&#160;&#160; &#160;&#160;&#160; </span><span style="color: red;">xmlns:xsi</span><span style="color: blue;">=</span>&quot;<span style="color: blue;">http://www.w3c.org/2001/XMLSchema-instance</span>&quot;<span style="color: blue;"> </span></p>
<p style="margin: 0px;"><span style="color: blue;">&#160;&#160;&#160; &#160;&#160;&#160; </span><span style="color: red;">xsi:schemaLocation</span><span style="color: blue;">=</span>&quot;<span style="color: blue;">http://java.sun.com/xml/ns/j2ee/web-jsptaglibrary_2_0.xsd</span>&quot;<span style="color: blue;"> </span></p>
<p style="margin: 0px;"><span style="color: blue;">&#160;&#160;&#160; &#160;&#160;&#160; </span><span style="color: red;">version</span><span style="color: blue;">=</span>&quot;<span style="color: blue;">2.0</span>&quot;<span style="color: blue;">&gt;</span></p>
<p style="margin: 0px;"><span style="color: blue;">&#160; &lt;</span><span style="color: maroon;">tlib-version</span><span style="color: blue;">&gt;</span>1.2<span style="color: blue;">&lt;/</span><span style="color: maroon;">tlib-version</span><span style="color: blue;">&gt;</span></p>
<p style="margin: 0px;"><span style="color: blue;">&#160; &lt;</span><span style="color: maroon;">uri</span><span style="color: blue;">&gt;</span>myTags<span style="color: blue;">&lt;/</span><span style="color: maroon;">uri</span><span style="color: blue;">&gt;</span></p>
<p style="margin: 0px;"><span style="color: blue;">&#160; &lt;</span><span style="color: maroon;">tag</span><span style="color: blue;">&gt;</span></p>
<p style="margin: 0px;"><span style="color: blue;">&#160;&#160;&#160; &lt;</span><span style="color: maroon;">description</span><span style="color: blue;">&gt;</span>Custom tags<span style="color: blue;">&lt;/</span><span style="color: maroon;">description</span><span style="color: blue;">&gt;</span></p>
<p style="margin: 0px;"><span style="color: blue;">&#160;&#160;&#160; &lt;</span><span style="color: maroon;">name</span><span style="color: blue;">&gt;</span>Square<span style="color: blue;">&lt;/</span><span style="color: maroon;">name</span><span style="color: blue;">&gt;</span></p>
<p style="margin: 0px;"><span style="color: blue;">&#160;&#160;&#160; &lt;</span><span style="color: maroon;">tag-class</span><span style="color: blue;">&gt;</span>com.cyberkruz.test.NewMath<span style="color: blue;">&lt;/</span><span style="color: maroon;">tag-class</span><span style="color: blue;">&gt;</span></p>
<p style="margin: 0px;"><span style="color: blue;">&#160;&#160;&#160; &lt;</span><span style="color: maroon;">body-content</span><span style="color: blue;">&gt;</span>scriptless<span style="color: blue;">&lt;/</span><span style="color: maroon;">body-content</span><span style="color: blue;">&gt;</span></p>
<p style="margin: 0px;"><span style="color: blue;">&#160;&#160;&#160; &lt;</span><span style="color: maroon;">attribute</span><span style="color: blue;">&gt;</span></p>
<p style="margin: 0px;"><span style="color: blue;">&#160;&#160;&#160; &#160; &lt;</span><span style="color: maroon;">name</span><span style="color: blue;">&gt;</span>num<span style="color: blue;">&lt;/</span><span style="color: maroon;">name</span><span style="color: blue;">&gt;</span></p>
<p style="margin: 0px;"><span style="color: blue;">&#160;&#160;&#160; &#160; &lt;</span><span style="color: maroon;">required</span><span style="color: blue;">&gt;</span>true<span style="color: blue;">&lt;/</span><span style="color: maroon;">required</span><span style="color: blue;">&gt;</span></p>
<p style="margin: 0px;"><span style="color: blue;">&#160;&#160;&#160; &#160; &lt;</span><span style="color: maroon;">rtexprvalue</span><span style="color: blue;">&gt;</span>true<span style="color: blue;">&lt;/</span><span style="color: maroon;">rtexprvalue</span><span style="color: blue;">&gt;</span></p>
<p style="margin: 0px;"><span style="color: blue;">&#160;&#160;&#160; &lt;/</span><span style="color: maroon;">attribute</span><span style="color: blue;">&gt;</span></p>
<p style="margin: 0px;"><span style="color: blue;">&#160; &lt;/</span><span style="color: maroon;">tag</span><span style="color: blue;">&gt;</span></p>
<p style="margin: 0px;"><span style="color: blue;">&lt;/</span><span style="color: maroon;">taglib</span><span style="color: blue;">&gt;</span></p>
</div>

</blockquote><p><br />This file configures our web application to use our new custom tag. Multiple tags can be placed and mapped with this single file. The taglib directive just specifies the schemas for this particular file and version. The uri specifies what location these tags are being mapped to. Under the tag element, the description and name should be pretty straight forward. The tag-class element points this tag to the class that we wrote previously. the body-content is stating that we don&#39;t want inline scripting for this element. Now the attribute tag is fairly interesting. While optional, it maps the num variable to our setter in the class we specified. Then, it says we must have it there (required element) and it can be specified at run time (rtexprvalue).</p><p>Now all we have to do is use it!</p><p><strong>Place our new tag in a jsp<br /></strong>Allowing our jsp to use the custom tag is the easiest part. It only requires a single declaration.</p><blockquote>

<div style="background: white none repeat scroll 0% 50%; font-family: Courier New; font-size: 9pt; color: black; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;">
<p style="margin: 0px;"><span style="color: blue;">&lt;</span>%<span style="color: maroon;">@</span><span style="color: blue;"> </span><span style="color: red;">taglib</span><span style="color: blue;"></span><span style="color: blue;"> </span><span style="color: red;">prefix</span><span style="color: blue;">=</span>&quot;<span style="color: blue;">math</span>&quot;<span style="color: blue;"> </span><span style="color: red;">uri</span><span style="color: blue;">=</span>&quot;<span style="color: blue;">myTags</span>&quot;<span style="color: blue;"> </span>%<span style="color: blue;">&gt;</span></p>
</div>

</blockquote><p>The taglib keyword tells the jsp what we are trying to do. The prefix is what we want to put before the tags when we call them, and the uri points to the uri specified in the tld file. This is going to load every tag that is configured in that tld file that we made previously. </p><p>Now, let&#39;s put it in a jsp. Create a jsp file called SimpleTest.jsp and place it in your web application. Place the following in your jsp:</p><blockquote>

<div style="background: white none repeat scroll 0% 50%; font-family: Courier New; font-size: 9pt; color: black; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;">
<p style="margin: 0px;"><span style="color: blue;">&lt;</span>%<span style="color: maroon;">@page</span><span style="color: blue;"> </span><span style="color: red;">language</span><span style="color: blue;">=</span>&quot;<span style="color: blue;">java</span>&quot;<span style="color: blue;"> </span></p>
<p style="margin: 0px;"><span style="color: red;">contentType</span><span style="color: blue;">=</span>&quot;<span style="color: blue;">text/html; charset=ISO-8859-1</span>&quot;</p>
<p style="margin: 0px;"><span style="color: red;">pageEncoding</span><span style="color: blue;">=</span>&quot;<span style="color: blue;">ISO-8859-1</span>&quot;%<span style="color: blue;">&gt;</span></p>
<p style="margin: 0px;"><span style="color: blue;">&lt;</span>%<span style="color: maroon;">@</span><span style="color: blue;"> </span><span style="color: red;">taglib</span><span style="color: blue;">=</span>&quot;&quot;<span style="color: blue;"> </span><span style="color: red;">prefix</span><span style="color: blue;">=</span>&quot;<span style="color: blue;">math</span>&quot;<span style="color: blue;"> </span><span style="color: red;">uri</span><span style="color: blue;">=</span>&quot;<span style="color: blue;">myTags</span>&quot;<span style="color: blue;"> </span>%<span style="color: blue;">&gt;</span></p>
<p style="margin: 0px;">&#160;</p>
<p style="margin: 0px;"><span style="color: blue;">&lt;</span><span style="color: maroon;">html</span><span style="color: blue;">&gt;</span></p>
<p style="margin: 0px;"><span style="color: blue;">&#160; &lt;</span><span style="color: maroon;">head</span><span style="color: blue;">&gt;</span></p>
<p style="margin: 0px;"><span style="color: blue;">&#160;&#160;&#160; &lt;</span><span style="color: maroon;">title</span><span style="color: blue;">&gt;</span>SimpleTest<span style="color: blue;">&lt;/</span><span style="color: maroon;">title</span><span style="color: blue;">&gt;</span></p>
<p style="margin: 0px;"><span style="color: blue;">&#160;&#160;&#160; &lt;</span><span style="color: maroon;">meta</span><span style="color: blue;"> </span><span style="color: red;">http-equiv</span><span style="color: blue;">=</span>&quot;<span style="color: blue;">Content-Type</span>&quot;<span style="color: blue;"> </span><span style="color: red;">content</span><span style="color: blue;">=</span>&quot;<span style="color: blue;">text/html; charset=ISO-8859-1</span>&quot;<span style="color: blue;">&gt;</span></p>
<p style="margin: 0px;"><span style="color: blue;">&#160;&#160;&#160; &lt;/</span><span style="color: maroon;">head</span><span style="color: blue;">&gt;</span></p>
<p style="margin: 0px;"><span style="color: blue;">&#160; &lt;</span><span style="color: maroon;">body</span><span style="color: blue;">&gt;</span></p>
<p style="margin: 0px;">&#160;&#160;&#160; 10 squared is: <span style="color: blue;">&lt;</span><span style="color: maroon;">math:Square</span><span style="color: blue;"> </span><span style="color: red;">num</span><span style="color: blue;">=</span>&quot;<span style="color: blue;">10</span>&quot;<span style="color: blue;"> /&gt;</span>.</p>
<p style="margin: 0px;"><span style="color: blue;">&#160; &lt;/</span><span style="color: maroon;">body</span><span style="color: blue;">&gt;</span></p>
<p style="margin: 0px;"><span style="color: blue;">&lt;/</span><span style="color: maroon;">html</span><span style="color: blue;">&gt;</span></p>
</div>

</blockquote><p>Run it on your web server and... YAY! This is a base introduction to what you can do with custom simple tags. More information about how to use these is below. Enjoy!</p><p><strong>More information<br /><a href="http://java.sun.com/j2ee/1.4/docs/tutorial/doc/JSPTags7.html">http://java.sun.com/j2ee/1.4/docs/tutorial/doc/JSPTags7.html</a><br /></strong> </p>   <p style="clear:both;"> 
    <a href="http://cyberkruz.vox.com/library/post/j2ee-custom-simple-tags-part-1.html?_c=feed-atom-full#comments">Read and post comments</a>   |   
    <a href="http://www.vox.com/share/6a00c2251f2742604a00d09e6a7647be2b?_c=feed-atom-full">Send to a friend</a> 
</p>

                </div>
            ]]>
        </content> 
    <category term="java" scheme="http://cyberkruz.vox.com/tags/java/" label="java" /> 
    <category term="html" scheme="http://cyberkruz.vox.com/tags/html/" label="html" /> 
    <category term="tutorial" scheme="http://cyberkruz.vox.com/tags/tutorial/" label="tutorial" /> 
    <category term="j2ee" scheme="http://cyberkruz.vox.com/tags/j2ee/" label="j2ee" /> 
    <category term="jsp" scheme="http://cyberkruz.vox.com/tags/jsp/" label="jsp" /> 
    <category term="simple tags" scheme="http://cyberkruz.vox.com/tags/simple+tags/" label="simple tags" /> 
    </entry> 
    
    <entry>
        <title>C# tutorial: Linked List</title>   
        <link rel="alternate" type="text/html" title="C# tutorial: Linked List" href="http://cyberkruz.vox.com/library/post/c-tutorial-linked-list.html?_c=feed-atom-full" />  
        <link rel="service.post" type="application/atom+xml" title="C# tutorial: Linked List" href="http://cyberkruz.vox.com/library/post/c-tutorial-linked-list.html?_c=feed-atom-full#comments" /> 
        <link rel="service.edit" type="application/atom+xml" title="C# tutorial: Linked List" href="http://www.vox.com/atom/svc=post/asset_id=6a00c2251f2742604a00d09e593c97be2b" />              <id>tag:vox.com,2007-03-02:asset-6a00c2251f2742604a00d09e593c97be2b</id>
        <published>2007-03-02T22:38:26Z</published>
        <updated>2007-04-21T01:27:41Z</updated>
    
        <author>
            <name>Matthew Kruskamp</name>
            <uri>http://cyberkruz.vox.com/?_c=feed-atom-full</uri>
        </author>
    
        
        <content type="html" xml:base="http://cyberkruz.vox.com/?_c=feed-atom-full">
            <![CDATA[
                <div xmlns="http://www.w3.org/1999/xhtml" xmlns:at="http://www.sixapart.com/ns/at">
        <p>For archive purposes, I am posing a custom, generic, sortable, event-driven, doubly-linked list. In the future I will run some tests on it to see if it beats the current linked list implementation provided by the .NET framework. For those unsure of what a linked list is, here is a small tutorial on it.</p><p><strong><span style="font-size: 1.25em;"><span style="font-size: 0.8em;">Collections</span></span></strong><br />When programming a computer, it is very common to store many items of the same type. Some different types of storing methods include array&#39;s, lists, and linked lists. The array is probably the most common for those attempting to store items. When an array of items is specified, the computer goes into memory and searches for a place to allocate the array. If it cannot allocate the entire array, it will keep searching. until it can.</p>
    

    

    

    

    

    

    

    

    
    
    
<div at:enclosure="asset" at:xid="6a00c2251f2742604a00d41422c43a6a47" at:format="medium" at:align="center"
    class="enclosure enclosure-center enclosure-medium photo-enclosure" 
     style="text-align: center;">
<div class="enclosure-inner"
    
        style="padding: 9px; border: 1px solid; width: px; margin: 10px auto;"
    >
    <div class="enclosure-list">
        <div class="enclosure-item photo-asset last">
    
            <div class="enclosure-image">
        
                <a href="http://cyberkruz.vox.com/library/photo/6a00c2251f2742604a00d41422c43a6a47.html"><img src="http://a2.vox.com/6a00c2251f2742604a00d41422c43a6a47-200pi" alt="ArrayStorage" title="ArrayStorage" /></a>
        
            </div>
            <div class="enclosure-meta">
                <div class="enclosure-asset-name"><a href="http://cyberkruz.vox.com/library/photo/6a00c2251f2742604a00d41422c43a6a47.html" title="ArrayStorage">ArrayStorage</a></div>
            </div>
    
        </div>
    </div>
</div>
</div><!-- end enclosure -->








<p><br /><em>Note: I put 5 spaces in the array definition. This is because of a manifest placed in the array, however, the inter workings of memory is beyond the scope of this article.</em></p><p>Now the problem with the array rises when someone runs out of room in their array. If they have an array that is 5 items large, and they want to hold a 6th, they must now re-define an entirely new array that can hold the new information. This requires the computer to go through and find another spot in memory that is big enough, place the new array in there, and then copy the elements from the original array to the new array. This problem is where a linked list comes in handy.<br /><strong><br />The Linked List</strong><br />When a linked list is used, every item is stored in a chain of items. The linked list works by housing the references to the next (and previous in doubly linked lists) items in the chain. To do this, it is common to house your value inside a node. That node contains a reference in memory to the next node. Thus, you can define nodes anywhere you want in memory as long as you link to it making it easy to add and remove any amount of elements in the chain. The code would look something like this if you are trying to store integers:</p>
<blockquote><p style="margin-bottom: 0in;">    <span lang=""><span style="font-size: small"><span style="color: #0000ff">public</span><span style="color: #000000">
</span><span style="color: #0000ff">class</span><span style="color: #000000">
</span><span style="color: #008080">LinkedList</span></span></span></p><p lang="" style="margin-bottom: 0in;"><span style="color: #000000">    <span style="font-size: small">{</span></span></p><p style="margin-bottom: 0in;"><span style="color: #000000">        </span><span lang="">&#160;&#160;&#160; <span style="font-size: small"><span style="color: #008080">Node</span><span style="color: #000000">
firstNode;</span></span></span></p><p lang="" style="margin-bottom: 0in;"><br />
</p><p style="margin-bottom: 0in;"><span style="color: #000000">        </span>&#160;&#160;&#160; <span lang=""><span style="font-size: small"><span style="color: #0000ff">public</span><span style="color: #000000">
</span><span style="color: #0000ff">class</span><span style="color: #000000"> </span><span style="color: #008080">Node</span></span></span></p><p lang="" style="margin-bottom: 0in;"><span style="color: #000000">        &#160;&#160;&#160; <span style="font-size: small">{</span></span></p><p style="margin-bottom: 0in;"><span style="color: #000000">            </span><span lang=""><span style="font-size: small">&#160;&#160;&#160; &#160;&#160;&#160; <span style="color: #008080">Node</span><span style="color: #000000">
previous;</span></span></span></p><p style="margin-bottom: 0in;"><span style="color: #000000">            </span><span lang=""><span style="font-size: small">&#160;&#160;&#160; &#160;&#160;&#160; <span style="color: #008080">Node</span><span style="color: #000000">
next;</span></span></span></p><p style="margin-bottom: 0in;">&#160;&#160;&#160; &#160;&#160;&#160; <span lang=""><span style="font-size: small"><span style="color: #0000ff">int</span><span style="color: #000000">
value;</span></span></span></p><p lang="" style="margin-bottom: 0in;"><span style="color: #000000">        &#160;&#160;&#160; <span style="font-size: small">}</span></span></p><p lang="" style="margin-bottom: 0in;"><span style="color: #000000">    <span style="font-size: small">}</span></span></p></blockquote>











    

    

    

    

    

    

    

    

    
    
    
<div at:enclosure="asset" at:xid="6a00c2251f2742604a00d09e58fa35be2b" at:format="medium" at:align="center"
    class="enclosure enclosure-center enclosure-medium photo-enclosure" 
     style="text-align: center;">
<div class="enclosure-inner"
    
        style="padding: 9px; border: 1px solid; width: px; margin: 10px auto;"
    >
    <div class="enclosure-list">
        <div class="enclosure-item photo-asset last">
    
            <div class="enclosure-image">
        
                <a href="http://cyberkruz.vox.com/library/photo/6a00c2251f2742604a00d09e58fa35be2b.html"><img src="http://a5.vox.com/6a00c2251f2742604a00d09e58fa35be2b-200pi" alt="LinkedListStorage" title="LinkedListStorage" /></a>
        
            </div>
            <div class="enclosure-meta">
                <div class="enclosure-asset-name"><a href="http://cyberkruz.vox.com/library/photo/6a00c2251f2742604a00d09e58fa35be2b.html" title="LinkedListStorage">LinkedListStorage</a></div>
            </div>
    
        </div>
    </div>
</div>
</div><!-- end enclosure -->








<p><strong>Problems</strong><br />With anything in computer science, there are downfalls to using Linked Lists. In order to get to an element in the linked list, you must traverse the entire list until you get to that element. This can be time consuming if there are a lot of nodes. Another problem is if you lose a reference to one of the nodes, you break the entire list. However, in a lot of circumstances, it is very useful to be able to add and remove items on the fly just by changing references.</p><p><strong>Source</strong><br />Here is an example doubly linked list example that I wrote. Thank <a href="http://dusda.vox.com/" class="enclosure-inline-user" at:enclosure="inline-user" at:user-xid="6p00c2251efa85549d" at:screen-name="dusda" at:delegate="people-connect" at:user-pic="http://up5.vox.com/6a00c2251efa85549d00c2251efce7604a-75si" >dusda</a> for the event driven idea. It is a doubly linked list that will convert to an array if needed. It supports any data type, and automatically sorts if specified. There is even support for getting an item by it&#39;s location (index). I hope you all find it useful.</p>

<p><br />

<div style="background: white none repeat scroll 0% 50%; font-family: Courier New; font-size: 8pt; color: black; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;">

<div style="background: white none repeat scroll 0% 50%; font-family: Courier New; font-size: 8pt; color: black; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;">

<div style="background: white none repeat scroll 0%; font-family: Courier New; font-size: 8pt; color: black; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;">
<p style="margin: 0px;"><span style="color: blue;">using</span> System;</p>
<p style="margin: 0px;">&#160;</p>
<p style="margin: 0px;"><span style="color: blue;">namespace</span> Systepic.Collections</p>
<p style="margin: 0px;">{</p>
<p style="margin: 0px;">&#160;&#160;  <span style="color: gray;">///</span><span style="color: green;"> </span><span style="color: gray;">&lt;summary&gt;</span></p>
<p style="margin: 0px;">&#160;&#160;  <span style="color: gray;">///</span><span style="color: green;"> Event Handler designed to be thrown</span></p>
<p style="margin: 0px;">&#160;&#160;  <span style="color: gray;">///</span><span style="color: green;"> when a collection&#39;s list items change.</span></p>
<p style="margin: 0px;">&#160;&#160;  <span style="color: gray;">///</span><span style="color: green;"> </span><span style="color: gray;">&lt;/summary&gt;</span></p>
<p style="margin: 0px;">&#160;&#160;  <span style="color: gray;">///</span><span style="color: green;"> </span><span style="color: gray;">&lt;param name=&quot;sender&quot;&gt;</span><span style="color: green;">The list that</span></p>
<p style="margin: 0px;">&#160;&#160;  <span style="color: gray;">///</span><span style="color: green;"> fired the event.</span><span style="color: gray;">&lt;/param&gt;</span></p>
<p style="margin: 0px;">&#160;&#160;  <span style="color: gray;">///</span><span style="color: green;"> </span><span style="color: gray;">&lt;param name=&quot;e&quot;&gt;</span><span style="color: green;">Information about</span></p>
<p style="margin: 0px;">&#160;&#160;  <span style="color: gray;">///</span><span style="color: green;"> what the event did.</span><span style="color: gray;">&lt;/param&gt;</span></p>
<p style="margin: 0px;">&#160;&#160;  <span style="color: blue;">public</span> <span style="color: blue;">delegate</span> <span style="color: blue;">void</span> CollectionEventHandler(</p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160; <span style="color: teal;">Object</span> sender, CollectionEventArgs e);</p>
<p style="margin: 0px;">&#160;</p>
<p style="margin: 0px;">&#160;&#160;  <span style="color: gray;">///</span><span style="color: green;"> </span><span style="color: gray;">&lt;summary&gt;</span></p>
<p style="margin: 0px;">&#160;&#160;  <span style="color: gray;">///</span><span style="color: green;"> Class inheriting from EventArgs designed</span></p>
<p style="margin: 0px;">&#160;&#160;  <span style="color: gray;">///</span><span style="color: green;"> to hold information about the state change</span></p>
<p style="margin: 0px;">&#160;&#160;  <span style="color: gray;">///</span><span style="color: green;"> of a collection.</span></p>
<p style="margin: 0px;">&#160;&#160;  <span style="color: gray;">///</span><span style="color: green;"> </span><span style="color: gray;">&lt;/summary&gt;</span></p>
<p style="margin: 0px;">&#160;&#160;  <span style="color: blue;">public</span> <span style="color: blue;">class</span> CollectionEventArgs : <span style="color: teal;">EventArgs</span></p>
<p style="margin: 0px;">&#160;&#160;  {</p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160; <span style="color: blue;">public</span> CollectionEventArgs():<span style="color: blue;">base</span>(){}</p>
<p style="margin: 0px;">&#160;&#160;  }</p>
<p style="margin: 0px;">&#160;</p>
<p style="margin: 0px;">&#160;&#160;  <span style="color: gray;">///</span><span style="color: green;"> </span><span style="color: gray;">&lt;summary&gt;</span></p>
<p style="margin: 0px;">&#160;&#160;  <span style="color: gray;">///</span><span style="color: green;"> A generic sortable linked list.</span></p>
<p style="margin: 0px;">&#160;&#160;  <span style="color: gray;">///</span><span style="color: green;"> </span><span style="color: gray;">&lt;/summary&gt;</span></p>
<p style="margin: 0px;">&#160;&#160;  <span style="color: gray;">///</span><span style="color: green;"> </span><span style="color: gray;">&lt;typeparam name=&quot;T&quot;&gt;</span><span style="color: green;">The type</span></p>
<p style="margin: 0px;">&#160;&#160;  <span style="color: gray;">///</span><span style="color: green;"> that the linked list is. The type</span></p>
<p style="margin: 0px;">&#160;&#160;  <span style="color: gray;">///</span><span style="color: green;"> should be a valuetype or a string</span></p>
<p style="margin: 0px;">&#160;&#160;  <span style="color: gray;">///</span><span style="color: green;"> in order to be sorted.</span><span style="color: gray;">&lt;/typeparam&gt;</span></p>
<p style="margin: 0px;">&#160;&#160;  <span style="color: blue;">public</span> <span style="color: blue;">class</span> LinkedList&lt;T&gt;</p>
<p style="margin: 0px;">&#160;&#160;  {</p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160; <span style="color: gray;">///</span><span style="color: green;"> </span><span style="color: gray;">&lt;summary&gt;</span></p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160; <span style="color: gray;">///</span><span style="color: green;"> An event fired whenever the collection</span></p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160; <span style="color: gray;">///</span><span style="color: green;"> contents change.</span></p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160; <span style="color: gray;">///</span><span style="color: green;"> </span><span style="color: gray;">&lt;/summary&gt;</span></p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160; <span style="color: blue;">public</span> <span style="color: blue;">event</span> CollectionEventHandler ListChanged;</p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160; <span style="color: gray;">///</span><span style="color: green;"> </span><span style="color: gray;">&lt;summary&gt;</span><span style="color: green;"> </span></p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160; <span style="color: gray;">///</span><span style="color: green;"> The initial node to iterate in the list.</span></p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160; <span style="color: gray;">///</span><span style="color: green;"> </span><span style="color: gray;">&lt;/summary&gt;</span></p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160; <span style="color: blue;">private</span> Node&lt;T&gt; firstNode;</p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160; <span style="color: gray;">///</span><span style="color: green;"> </span><span style="color: gray;">&lt;summary&gt;</span></p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160; <span style="color: gray;">///</span><span style="color: green;"> The number of items in the linked list.</span></p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160; <span style="color: gray;">///</span><span style="color: green;"> </span><span style="color: gray;">&lt;/summary&gt;</span></p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160; <span style="color: blue;">private</span> <span style="color: blue;">int</span> count;</p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160; <span style="color: gray;">///</span><span style="color: green;"> </span><span style="color: gray;">&lt;summary&gt;</span></p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160; <span style="color: gray;">///</span><span style="color: green;"> Whether or not it is a sorted list.</span></p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160; <span style="color: gray;">///</span><span style="color: green;"> </span><span style="color: gray;">&lt;/summary&gt;</span></p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160; <span style="color: blue;">private</span> <span style="color: blue;">bool</span> sorted;</p>
<p style="margin: 0px;">&#160;</p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160; <span style="color: gray;">///</span><span style="color: green;"> </span><span style="color: gray;">&lt;summary&gt;</span></p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160; <span style="color: gray;">///</span><span style="color: green;"> Create a new unsorted</span></p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160; <span style="color: gray;">///</span><span style="color: green;"> linked list.</span></p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160; <span style="color: gray;">///</span><span style="color: green;"> </span><span style="color: gray;">&lt;/summary&gt;</span></p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160; <span style="color: blue;">public</span> LinkedList() : <span style="color: blue;">this</span>(<span style="color: blue;">false</span>) { }</p>
<p style="margin: 0px;">&#160;</p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160; <span style="color: gray;">///</span><span style="color: green;"> </span><span style="color: gray;">&lt;summary&gt;</span></p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160; <span style="color: gray;">///</span><span style="color: green;"> Create a new linked list that</span></p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160; <span style="color: gray;">///</span><span style="color: green;"> can be a sorted linked list.</span></p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160; <span style="color: gray;">///</span><span style="color: green;"> </span><span style="color: gray;">&lt;/summary&gt;</span></p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160; <span style="color: gray;">///</span><span style="color: green;"> </span><span style="color: gray;">&lt;param name=&quot;sorted&quot;&gt;</span><span style="color: green;">Whether or not</span></p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160; <span style="color: gray;">///</span><span style="color: green;"> the linked list should be sorted.</span><span style="color: gray;">&lt;/param&gt;</span></p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160; <span style="color: blue;">public</span> LinkedList(<span style="color: blue;">bool</span> sorted)</p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160; {</p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; <span style="color: blue;">this</span>.count = 0;</p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; <span style="color: blue;">this</span>.sorted = sorted;</p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160; }</p>
<p style="margin: 0px;">&#160;</p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160; <span style="color: gray;">///</span><span style="color: green;"> </span><span style="color: gray;">&lt;summary&gt;</span></p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160; <span style="color: gray;">///</span><span style="color: green;"> Adds an item to the end of the current </span></p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160; <span style="color: gray;">///</span><span style="color: green;"> linked list. If the linked list is a </span></p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160; <span style="color: gray;">///</span><span style="color: green;"> sorted list, the list is re-sorted.</span></p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160; <span style="color: gray;">///</span><span style="color: green;"> </span><span style="color: gray;">&lt;/summary&gt;</span></p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160; <span style="color: gray;">///</span><span style="color: green;"> </span><span style="color: gray;">&lt;param name=&quot;item&quot;&gt;</span><span style="color: green;">The item that should </span></p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160; <span style="color: gray;">///</span><span style="color: green;"> be added to the linked list.</span><span style="color: gray;">&lt;/param&gt;</span></p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160; <span style="color: gray;">///</span><span style="color: green;"> </span><span style="color: gray;">&lt;returns&gt;</span><span style="color: green;">Whether or not the item was </span></p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160; <span style="color: gray;">///</span><span style="color: green;"> added successfully.</span><span style="color: gray;">&lt;/returns&gt;</span></p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160; <span style="color: blue;">public</span> <span style="color: blue;">bool</span> Add(T item)</p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160; {</p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; <span style="color: green;">// Add if there is none</span></p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; <span style="color: blue;">if</span> (<span style="color: blue;">this</span>.count == 0)</p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160;  <span style="color: blue;">this</span>.firstNode = <span style="color: blue;">new</span> Node&lt;T&gt;(item);</p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; <span style="color: blue;">else</span></p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; {</p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160;  Node&lt;T&gt; temp = <span style="color: blue;">this</span>.firstNode;</p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160;  <span style="color: blue;">for</span> (<span style="color: blue;">int</span> x = 1; x &lt; <span style="color: blue;">this</span>.count; ++x)</p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160; temp = temp.Next;</p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160;  <span style="color: green;">// Add a new item to the list</span></p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160;  temp.Next = <span style="color: blue;">new</span> Node&lt;T&gt;(</p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160; item, temp, <span style="color: blue;">null</span>);</p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; }</p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; <span style="color: green;">// increment the counter.</span></p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; ++count;</p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; <span style="color: blue;">if</span> (<span style="color: blue;">this</span>.sorted) <span style="color: blue;">this</span>.Sort();</p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; <span style="color: green;">// fire the event</span></p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; <span style="color: blue;">if</span> (<span style="color: blue;">this</span>.ListChanged != <span style="color: blue;">null</span>)</p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160;  <span style="color: blue;">this</span>.ListChanged(<span style="color: blue;">this</span>,</p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160; <span style="color: blue;">new</span> CollectionEventArgs());</p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; <span style="color: green;">// Call the insertAt method.</span></p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; <span style="color: blue;">return</span> <span style="color: blue;">true</span>;</p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160; }</p>
<p style="margin: 0px;">&#160;</p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160; <span style="color: gray;">///</span><span style="color: green;"> </span><span style="color: gray;">&lt;summary&gt;</span></p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160; <span style="color: gray;">///</span><span style="color: green;"> Insert an item at a specified index in</span></p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160; <span style="color: gray;">///</span><span style="color: green;"> the linked list. If the linked list is</span></p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160; <span style="color: gray;">///</span><span style="color: green;"> a sorted list, the list is re-sorted.</span></p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160; <span style="color: gray;">///</span><span style="color: green;"> </span><span style="color: gray;">&lt;/summary&gt;</span></p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160; <span style="color: gray;">///</span><span style="color: green;"> </span><span style="color: gray;">&lt;param name=&quot;item&quot;&gt;</span><span style="color: green;">The item to add to the</span></p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160; <span style="color: gray;">///</span><span style="color: green;"> linked list.</span><span style="color: gray;">&lt;/param&gt;</span></p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160; <span style="color: gray;">///</span><span style="color: green;"> </span><span style="color: gray;">&lt;param name=&quot;index&quot;&gt;</span><span style="color: green;">The 0 based index of where</span></p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160; <span style="color: gray;">///</span><span style="color: green;"> it should be added at.</span><span style="color: gray;">&lt;/param&gt;</span></p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160; <span style="color: gray;">///</span><span style="color: green;"> </span><span style="color: gray;">&lt;returns&gt;</span><span style="color: green;">Whether or not the item was added</span></p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160; <span style="color: gray;">///</span><span style="color: green;"> successfully.</span><span style="color: gray;">&lt;/returns&gt;</span></p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160; <span style="color: blue;">public</span> <span style="color: blue;">bool</span> InsertAt(T item, <span style="color: blue;">int</span> index)</p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160; {</p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; <span style="color: green;">// make sure the index is valid</span></p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; <span style="color: blue;">if</span> (index &lt; 0)</p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160;  <span style="color: blue;">throw</span> <span style="color: blue;">new</span> <span style="color: teal;">IndexOutOfRangeException</span>();</p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; <span style="color: blue;">if</span> (index &gt;= <span style="color: blue;">this</span>.count)</p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160;  <span style="color: blue;">throw</span> <span style="color: blue;">new</span> <span style="color: teal;">IndexOutOfRangeException</span>();</p>
<p style="margin: 0px;">&#160;</p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; <span style="color: green;">// make sure there is an actual place to insert</span></p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; <span style="color: blue;">if</span> (count == 0)</p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160;  <span style="color: blue;">return</span> <span style="color: blue;">false</span>;</p>
<p style="margin: 0px;">&#160;</p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; <span style="color: green;">// Create temp node to store info</span></p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; Node&lt;T&gt; tempNode = <span style="color: blue;">new</span> Node&lt;T&gt;(item);</p>
<p style="margin: 0px;">&#160;</p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; <span style="color: green;">// Create a temporary for iteration</span></p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; Node&lt;T&gt; temp = <span style="color: blue;">this</span>.firstNode;</p>
<p style="margin: 0px;">&#160;</p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; <span style="color: green;">// get to the specified index</span></p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; <span style="color: blue;">for</span> (<span style="color: blue;">int</span> x = 1; x &lt;= index; ++x)</p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160;  temp = temp.Next;</p>
<p style="margin: 0px;">&#160;</p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; <span style="color: green;">// get the current reference.</span></p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; <span style="color: blue;">if</span> (index &gt; 0)</p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; {</p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160;  Node&lt;T&gt; prev = temp.Previous;</p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160;  prev.Next = tempNode;</p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160;  tempNode.Previous = prev;</p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; }</p>
<p style="margin: 0px;">&#160;</p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; <span style="color: green;">// set the references</span></p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; tempNode.Next = temp;</p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; temp.Previous = tempNode;</p>
<p style="margin: 0px;">&#160;</p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; <span style="color: blue;">if</span> (index == 0)</p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160;  <span style="color: blue;">this</span>.firstNode = tempNode;</p>
<p style="margin: 0px;">&#160;</p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; <span style="color: green;">// update the list information</span></p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; ++count;</p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; <span style="color: blue;">if</span>(<span style="color: blue;">this</span>.sorted) <span style="color: blue;">this</span>.Sort();</p>
<p style="margin: 0px;">&#160;</p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; <span style="color: green;">// fire event</span></p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; <span style="color: blue;">if</span> (<span style="color: blue;">this</span>.ListChanged != <span style="color: blue;">null</span>)</p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160;  <span style="color: blue;">this</span>.ListChanged(<span style="color: blue;">this</span>, </p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160; <span style="color: blue;">new</span> CollectionEventArgs());</p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; <span style="color: blue;">return</span> <span style="color: blue;">true</span>;</p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160; }</p>
<p style="margin: 0px;">&#160;</p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160; <span style="color: gray;">///</span><span style="color: green;"> </span><span style="color: gray;">&lt;summary&gt;</span></p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160; <span style="color: gray;">///</span><span style="color: green;"> Find a particular item and remove</span></p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160; <span style="color: gray;">///</span><span style="color: green;"> it from the linked list.</span></p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160; <span style="color: gray;">///</span><span style="color: green;"> </span><span style="color: gray;">&lt;/summary&gt;</span></p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160; <span style="color: gray;">///</span><span style="color: green;"> </span><span style="color: gray;">&lt;param name=&quot;item&quot;&gt;</span><span style="color: green;">The item to find</span></p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160; <span style="color: gray;">///</span><span style="color: green;"> in the list.</span><span style="color: gray;">&lt;/param&gt;</span></p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160; <span style="color: gray;">///</span><span style="color: green;"> </span><span style="color: gray;">&lt;returns&gt;</span><span style="color: green;">Whether or not the item</span></p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160; <span style="color: gray;">///</span><span style="color: green;"> was removed successfully.</span><span style="color: gray;">&lt;/returns&gt;</span></p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160; <span style="color: blue;">public</span> <span style="color: blue;">bool</span> Remove(T item)</p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160; {</p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; <span style="color: green;">// make sure we can remove</span></p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; <span style="color: blue;">if</span> (count &lt; 1)</p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160;  <span style="color: blue;">return</span> <span style="color: blue;">false</span>;</p>
<p style="margin: 0px;">&#160;</p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; Node&lt;T&gt; temp = <span style="color: blue;">this</span>.firstNode;</p>
<p style="margin: 0px;">&#160;</p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; <span style="color: green;">// Iterate and find item</span></p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; <span style="color: blue;">for</span> (<span style="color: blue;">int</span> x = 1; x &lt;= <span style="color: blue;">this</span>.count; ++x)</p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; {</p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160;  <span style="color: blue;">if</span> ((item <span style="color: blue;">as</span> <span style="color: blue;">object</span>) == (temp.Value <span style="color: blue;">as</span> <span style="color: blue;">object</span>))</p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160;  {</p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160; <span style="color: green;">// Change the references</span></p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160; <span style="color: blue;">if</span> (temp.HasNext &amp;&amp; temp.HasPrevious)</p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160; {</p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; temp.Previous.Next = temp.Next;</p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; temp.Next.Previous = temp.Previous;</p>
<p style="margin: 0px;">&#160;</p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160; }</p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160; <span style="color: blue;">else</span> <span style="color: blue;">if</span> (temp.HasNext)</p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; temp.Next.Previous = <span style="color: blue;">null</span>;</p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160; <span style="color: blue;">else</span> <span style="color: blue;">if</span> (temp.HasPrevious)</p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; temp.Previous.Next = <span style="color: blue;">null</span>;</p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160; <span style="color: blue;">else</span></p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; temp = <span style="color: blue;">null</span>;</p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160; <span style="color: green;">// Reset the first Node if we</span></p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160; <span style="color: green;">// removed it.</span></p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160; <span style="color: blue;">if</span> (x == 1 &amp;&amp; temp != <span style="color: blue;">null</span>)</p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; <span style="color: blue;">this</span>.firstNode = temp.Next;</p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160; <span style="color: green;">// Handle the counter</span></p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160; --count;</p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160;  }</p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160;  <span style="color: blue;">if</span> (temp != <span style="color: blue;">null</span> &amp;&amp; temp.HasNext)</p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160; temp = temp.Next;</p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; }</p>
<p style="margin: 0px;">&#160;</p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; <span style="color: green;">// Resort the algorithm if it is </span></p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; <span style="color: green;">// a sorted algorithm</span></p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; <span style="color: blue;">if</span> (<span style="color: blue;">this</span>.sorted) <span style="color: blue;">this</span>.Sort();</p>
<p style="margin: 0px;">&#160;</p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; <span style="color: green;">// fire event</span></p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; <span style="color: blue;">if</span> (<span style="color: blue;">this</span>.ListChanged != <span style="color: blue;">null</span>)</p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160;  <span style="color: blue;">this</span>.ListChanged(<span style="color: blue;">this</span>,</p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160; <span style="color: blue;">new</span> CollectionEventArgs());</p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; <span style="color: blue;">return</span> <span style="color: blue;">true</span>;</p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160; }</p>
<p style="margin: 0px;">&#160;</p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160; <span style="color: gray;">///</span><span style="color: green;"> </span><span style="color: gray;">&lt;summary&gt;</span></p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160; <span style="color: gray;">///</span><span style="color: green;"> Sorts a list using insertion sort. Although</span></p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160; <span style="color: gray;">///</span><span style="color: green;"> this algorithm is considered slow, since the</span></p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160; <span style="color: gray;">///</span><span style="color: green;"> list is always almost sorted, the time to sort</span></p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160; <span style="color: gray;">///</span><span style="color: green;"> the list is really fast whereas most high speed</span></p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160; <span style="color: gray;">///</span><span style="color: green;"> algorithms will not beat this in this particular</span></p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160; <span style="color: gray;">///</span><span style="color: green;"> instance because they handle near-sorted </span></p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160; <span style="color: gray;">///</span><span style="color: green;"> algorithms the same as unsorted.</span></p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160; <span style="color: gray;">///</span><span style="color: green;"> </span><span style="color: gray;">&lt;/summary&gt;</span></p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160; <span style="color: gray;">///</span><span style="color: green;"> </span><span style="color: gray;">&lt;returns&gt;</span><span style="color: green;">Whether or not the</span></p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160; <span style="color: gray;">///</span><span style="color: green;"> list was sorted successfully.</span><span style="color: gray;">&lt;/returns&gt;</span></p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160; <span style="color: blue;">public</span> <span style="color: blue;">bool</span> Sort()</p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160; {</p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; <span style="color: blue;">if</span> (<span style="color: blue;">this</span>.firstNode.Value <span style="color: blue;">is</span> <span style="color: teal;">IComparable</span>)</p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; {</p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160;  <span style="color: green;">// check index out of range</span></p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160;  <span style="color: blue;">if</span> (<span style="color: blue;">this</span>.firstNode.Next == <span style="color: blue;">null</span>)</p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160; <span style="color: blue;">return</span> <span style="color: blue;">true</span>;</p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160;  <span style="color: green;">// get the base comparison</span></p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160;  Node&lt;T&gt; baseNode = <span style="color: blue;">this</span>.firstNode.Next;</p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160;  <span style="color: green;">// traverse the nodes</span></p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160;  <span style="color: blue;">for</span> (<span style="color: blue;">int</span> x = 2; x &lt;= <span style="color: blue;">this</span>.count; ++x)</p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160;  {</p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160; <span style="color: blue;">if</span> ((baseNode.Previous.Value <span style="color: blue;">as</span> </p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; <span style="color: teal;">IComparable</span>).CompareTo(</p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; baseNode.Value) == 1)</p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160; {</p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; Node&lt;T&gt; comp = <span style="color: blue;">this</span>.firstNode;</p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; <span style="color: blue;">bool</span> found = <span style="color: blue;">false</span>;</p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; <span style="color: blue;">for</span> (<span style="color: blue;">int</span> y = 1; y &lt; x &amp;&amp; found != <span style="color: blue;">true</span>; ++y)</p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; {</p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160;  <span style="color: blue;">if</span> ((baseNode.Value <span style="color: blue;">as</span> </p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160; <span style="color: teal;">IComparable</span>).CompareTo(comp.Value) != 1)</p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160;  {</p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160; <span style="color: green;">// We need to change the references</span></p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160; <span style="color: green;">// to all of the nodes to re-order them.</span></p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160; <span style="color: blue;">if</span> (baseNode.HasNext)</p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160; {</p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; baseNode.Next.Previous = </p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160;  baseNode.Previous;</p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; baseNode.Previous.Next = </p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160;  baseNode.Next;</p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160; } </p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160; <span style="color: blue;">else</span></p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; baseNode.Previous.Next = <span style="color: blue;">null</span>;</p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160; baseNode.Next = comp;</p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160; <span style="color: blue;">if</span> (comp.HasPrevious)</p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160; {</p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; comp.Previous.Next = </p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160;  baseNode;</p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; baseNode.Previous = </p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160;  comp.Previous;</p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160; }</p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160; <span style="color: blue;">else</span></p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; baseNode.Previous = <span style="color: blue;">null</span>;</p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160; comp.Previous = baseNode;</p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160; <span style="color: green;">// the references are set... make </span></p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160; <span style="color: green;">// sure the first node gets reset</span></p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160; <span style="color: green;">// if needed.</span></p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160; <span style="color: blue;">if</span> (y == 1)</p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; <span style="color: blue;">this</span>.firstNode = baseNode;</p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160; found = <span style="color: blue;">true</span>;</p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160;  }</p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160;  <span style="color: green;">// Set the next node</span></p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160;  <span style="color: blue;">if</span> (comp.HasNext)</p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160; comp = comp.Next;</p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; }</p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160; }</p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160; <span style="color: green;">// Set the next node</span></p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160; <span style="color: blue;">if</span> (baseNode.HasNext)</p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; baseNode = baseNode.Next;</p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160;  }</p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160;  <span style="color: blue;">return</span> <span style="color: blue;">true</span>;</p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; }</p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; <span style="color: blue;">else</span></p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160;  <span style="color: blue;">return</span> <span style="color: blue;">false</span>;</p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160; }</p>
<p style="margin: 0px;">&#160;</p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160; <span style="color: gray;">///</span><span style="color: green;"> </span><span style="color: gray;">&lt;summary&gt;</span></p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160; <span style="color: gray;">///</span><span style="color: green;"> Clears all of the items in the</span></p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160; <span style="color: gray;">///</span><span style="color: green;"> list by removing the reference </span></p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160; <span style="color: gray;">///</span><span style="color: green;"> to the first node. The remaining</span></p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160; <span style="color: gray;">///</span><span style="color: green;"> nodes no longer have references to</span></p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160; <span style="color: gray;">///</span><span style="color: green;"> the application and will be collected</span></p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160; <span style="color: gray;">///</span><span style="color: green;"> by the GC.</span></p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160; <span style="color: gray;">///</span><span style="color: green;"> </span><span style="color: gray;">&lt;/summary&gt;</span></p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160; <span style="color: blue;">public</span> <span style="color: blue;">void</span> Clear()</p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160; {</p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; <span style="color: green;">// kill the reference</span></p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; <span style="color: blue;">this</span>.firstNode = <span style="color: blue;">null</span>;</p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; <span style="color: green;">// reset the count</span></p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; <span style="color: blue;">this</span>.count = 0;</p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; <span style="color: green;">// let everyone know.</span></p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; <span style="color: blue;">if</span> (<span style="color: blue;">this</span>.ListChanged != <span style="color: blue;">null</span>)</p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160;  <span style="color: blue;">this</span>.ListChanged(<span style="color: blue;">this</span>, </p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160; <span style="color: blue;">new</span> CollectionEventArgs());</p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160; }</p>
<p style="margin: 0px;">&#160;</p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160; <span style="color: gray;">///</span><span style="color: green;"> </span><span style="color: gray;">&lt;summary&gt;</span></p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160; <span style="color: gray;">///</span><span style="color: green;"> Converts the linked list to</span></p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160; <span style="color: gray;">///</span><span style="color: green;"> an array.</span></p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160; <span style="color: gray;">///</span><span style="color: green;"> </span><span style="color: gray;">&lt;/summary&gt;</span></p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160; <span style="color: gray;">///</span><span style="color: green;"> </span><span style="color: gray;">&lt;returns&gt;</span><span style="color: green;">An array of the items</span></p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160; <span style="color: gray;">///</span><span style="color: green;"> in the linked list ordered by</span></p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160; <span style="color: gray;">///</span><span style="color: green;"> their location in the list top</span></p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160; <span style="color: gray;">///</span><span style="color: green;"> down.</span><span style="color: gray;">&lt;/returns&gt;</span></p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160; <span style="color: blue;">public</span> T[] ToArray()</p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160; {</p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; <span style="color: blue;">if</span> (<span style="color: blue;">this</span>.count &lt; 1)</p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160;  <span style="color: blue;">return</span> <span style="color: blue;">default</span>(T[]);</p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; T[] newArray = <span style="color: blue;">new</span> T[<span style="color: blue;">this</span>.count];</p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; <span style="color: green;">// create a temp node</span></p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; Node&lt;T&gt; temp = <span style="color: blue;">this</span>.firstNode;</p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; newArray[0] = temp.Value;</p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; <span style="color: green;">// iterate and get the node</span></p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; <span style="color: blue;">for</span> (<span style="color: blue;">int</span> x = 1; x &lt; <span style="color: blue;">this</span>.count; ++x)</p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; {</p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160;  temp = temp.Next;</p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160;  newArray[x] = temp.Value;</p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; }</p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; <span style="color: blue;">return</span> newArray;</p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160; }</p>
<p style="margin: 0px;">&#160;</p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160; <span style="color: gray;">///</span><span style="color: green;"> </span><span style="color: gray;">&lt;summary&gt;</span></p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160; <span style="color: gray;">///</span><span style="color: green;"> Allows the use of this linked list</span></p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160; <span style="color: gray;">///</span><span style="color: green;"> like it is an array. Get an item</span></p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160; <span style="color: gray;">///</span><span style="color: green;"> in the linked list by it&#39;s location</span></p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160; <span style="color: gray;">///</span><span style="color: green;"> in the list.</span></p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160; <span style="color: gray;">///</span><span style="color: green;"> </span><span style="color: gray;">&lt;/summary&gt;</span></p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160; <span style="color: gray;">///</span><span style="color: green;"> </span><span style="color: gray;">&lt;param name=&quot;index&quot;&gt;</span><span style="color: green;">The 0 based location</span></p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160; <span style="color: gray;">///</span><span style="color: green;"> of the item to get in the list.</span><span style="color: gray;">&lt;/param&gt;</span></p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160; <span style="color: gray;">///</span><span style="color: green;"> </span><span style="color: gray;">&lt;returns&gt;</span><span style="color: green;">The item at the specified</span></p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160; <span style="color: gray;">///</span><span style="color: green;"> location.</span><span style="color: gray;">&lt;/returns&gt;</span></p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160; <span style="color: blue;">public</span> T <span style="color: blue;">this</span>[<span style="color: blue;">int</span> index]</p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160; {</p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; <span style="color: blue;">get</span></p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; {</p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160;  <span style="color: green;">// make sure we can do it before traversal.</span></p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160;  <span style="color: blue;">if</span> (index + 1 &gt; count)</p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160; <span style="color: blue;">throw</span> <span style="color: blue;">new</span> <span style="color: teal;">IndexOutOfRangeException</span>();</p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160;  <span style="color: green;">// create a temp node</span></p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160;  Node&lt;T&gt; temp = <span style="color: blue;">this</span>.firstNode;</p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160;  <span style="color: green;">// iterate and get the node</span></p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160;  <span style="color: blue;">for</span> (<span style="color: blue;">int</span> x = 1; x &lt;= index; ++x)</p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160; temp = temp.Next;</p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160;  <span style="color: green;">// return the node value</span></p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160;  <span style="color: blue;">return</span> temp.Value;</p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; }</p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; <span style="color: blue;">set</span></p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; {</p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160;  <span style="color: green;">// make sure we can do it before traversal.</span></p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160;  <span style="color: blue;">if</span>(index + 1 &gt; count)</p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160; <span style="color: blue;">throw</span> <span style="color: blue;">new</span> <span style="color: teal;">IndexOutOfRangeException</span>();</p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160;  <span style="color: green;">// create a temp node</span></p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160;  Node&lt;T&gt; temp = <span style="color: blue;">this</span>.firstNode;</p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160;  <span style="color: green;">// iterate and get the node</span></p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160;  <span style="color: blue;">for</span> (<span style="color: blue;">int</span> x = 0; x &lt; index; ++x)</p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160; temp = temp.Next;</p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160;  <span style="color: green;">// set the node to value</span></p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160;  temp.Value = <span style="color: blue;">value</span>;</p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; }</p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160; }</p>
<p style="margin: 0px;">&#160;</p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160; <span style="color: gray;">///</span><span style="color: green;"> </span><span style="color: gray;">&lt;summary&gt;</span></p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160; <span style="color: gray;">///</span><span style="color: green;"> How many nodes are contained in the</span></p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160; <span style="color: gray;">///</span><span style="color: green;"> Linked List.</span></p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160; <span style="color: gray;">///</span><span style="color: green;"> </span><span style="color: gray;">&lt;/summary&gt;</span></p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160; <span style="color: blue;">public</span> <span style="color: blue;">int</span> Length</p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160; {</p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; <span style="color: blue;">get</span> { <span style="color: blue;">return</span> <span style="color: blue;">this</span>.count; }</p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160; }</p>
<p style="margin: 0px;">&#160;</p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160; <span style="color: gray;">///</span><span style="color: green;"> </span><span style="color: gray;">&lt;summary&gt;</span></p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160; <span style="color: gray;">///</span><span style="color: green;"> Whether or not this list sorts</span></p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160; <span style="color: gray;">///</span><span style="color: green;"> automatically.</span></p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160; <span style="color: gray;">///</span><span style="color: green;"> </span><span style="color: gray;">&lt;/summary&gt;</span></p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160; <span style="color: blue;">public</span> <span style="color: blue;">bool</span> IsSorted</p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160; {</p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; <span style="color: blue;">get</span> { <span style="color: blue;">return</span> <span style="color: blue;">this</span>.sorted; }</p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; <span style="color: blue;">set</span> { <span style="color: blue;">this</span>.sorted = <span style="color: blue;">value</span>; }</p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160; }</p>
<p style="margin: 0px;">&#160;</p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160; <span style="color: gray;">///</span><span style="color: green;"> </span><span style="color: gray;">&lt;summary&gt;</span></p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160; <span style="color: gray;">///</span><span style="color: green;"> Generic node with pre and post references</span></p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160; <span style="color: gray;">///</span><span style="color: green;"> for use in a linked list.</span></p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160; <span style="color: gray;">///</span><span style="color: green;"> </span><span style="color: gray;">&lt;/summary&gt;</span></p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160; <span style="color: gray;">///</span><span style="color: green;"> </span><span style="color: gray;">&lt;typeparam name=&quot;U&quot;&gt;</span><span style="color: green;">The type of</span></p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160; <span style="color: gray;">///</span><span style="color: green;"> information contained within the node.</span><span style="color: gray;">&lt;/typeparam&gt;</span></p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160; <span style="color: blue;">private</span> <span style="color: blue;">class</span> Node&lt;U&gt;</p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160; {</p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; <span style="color: gray;">///</span><span style="color: green;"> </span><span style="color: gray;">&lt;summary&gt;</span></p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; <span style="color: gray;">///</span><span style="color: green;"> The node reference to the node</span></p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; <span style="color: gray;">///</span><span style="color: green;"> before this node reference.</span></p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; <span style="color: gray;">///</span><span style="color: green;"> </span><span style="color: gray;">&lt;/summary&gt;</span></p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; Node&lt;U&gt; pre;</p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; <span style="color: gray;">///</span><span style="color: green;"> </span><span style="color: gray;">&lt;summary&gt;</span></p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; <span style="color: gray;">///</span><span style="color: green;"> The node reference to the node after</span></p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; <span style="color: gray;">///</span><span style="color: green;"> this node reference.</span></p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; <span style="color: gray;">///</span><span style="color: green;"> </span><span style="color: gray;">&lt;/summary&gt;</span></p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; Node&lt;U&gt; post;</p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; <span style="color: gray;">///</span><span style="color: green;"> </span><span style="color: gray;">&lt;summary&gt;</span></p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; <span style="color: gray;">///</span><span style="color: green;"> The generic information stored within</span></p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; <span style="color: gray;">///</span><span style="color: green;"> the node.</span></p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; <span style="color: gray;">///</span><span style="color: green;"> </span><span style="color: gray;">&lt;/summary&gt;</span></p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; U assignment;</p>
<p style="margin: 0px;">&#160;</p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; <span style="color: gray;">///</span><span style="color: green;"> </span><span style="color: gray;">&lt;summary&gt;</span></p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; <span style="color: gray;">///</span><span style="color: green;"> Create a new node with references</span></p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; <span style="color: gray;">///</span><span style="color: green;"> to both sides of the node.</span></p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; <span style="color: gray;">///</span><span style="color: green;"> </span><span style="color: gray;">&lt;/summary&gt;</span></p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; <span style="color: gray;">///</span><span style="color: green;"> </span><span style="color: gray;">&lt;param name=&quot;info&quot;&gt;</span><span style="color: green;">What the node actually</span></p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; <span style="color: gray;">///</span><span style="color: green;"> contains.</span><span style="color: gray;">&lt;/param&gt;</span></p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; <span style="color: gray;">///</span><span style="color: green;"> </span><span style="color: gray;">&lt;param name=&quot;previous&quot;&gt;</span><span style="color: green;">The node before this</span></p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; <span style="color: gray;">///</span><span style="color: green;"> node.</span><span style="color: gray;">&lt;/param&gt;</span></p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; <span style="color: gray;">///</span><span style="color: green;"> </span><span style="color: gray;">&lt;param name=&quot;next&quot;&gt;</span><span style="color: green;">The node after this</span></p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; <span style="color: gray;">///</span><span style="color: green;"> node.</span><span style="color: gray;">&lt;/param&gt;</span></p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; <span style="color: blue;">public</span> Node(U info, Node&lt;U&gt; previous, Node&lt;U&gt; next)</p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; {</p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160;  <span style="color: blue;">this</span>.assignment = info;</p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160;  <span style="color: blue;">this</span>.pre = previous;</p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160;  <span style="color: blue;">this</span>.post = next;</p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; }</p>
<p style="margin: 0px;">&#160;</p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; <span style="color: gray;">///</span><span style="color: green;"> </span><span style="color: gray;">&lt;summary&gt;</span></p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; <span style="color: gray;">///</span><span style="color: green;"> Create a new node with no references</span></p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; <span style="color: gray;">///</span><span style="color: green;"> to nodes.</span></p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; <span style="color: gray;">///</span><span style="color: green;"> </span><span style="color: gray;">&lt;/summary&gt;</span></p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; <span style="color: gray;">///</span><span style="color: green;"> </span><span style="color: gray;">&lt;param name=&quot;info&quot;&gt;</span><span style="color: green;">The information</span></p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; <span style="color: gray;">///</span><span style="color: green;"> that the node actually contains.</span><span style="color: gray;">&lt;/param&gt;</span></p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; <span style="color: blue;">public</span> Node(U info) : <span style="color: blue;">this</span>(info, <span style="color: blue;">null</span>, <span style="color: blue;">null</span>) { }</p>
<p style="margin: 0px;">&#160;</p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; <span style="color: gray;">///</span><span style="color: green;"> </span><span style="color: gray;">&lt;summary&gt;</span></p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; <span style="color: gray;">///</span><span style="color: green;"> The node before this node in the chain.</span></p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; <span style="color: gray;">///</span><span style="color: green;"> </span><span style="color: gray;">&lt;/summary&gt;</span></p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; <span style="color: blue;">public</span> Node&lt;U&gt; Previous</p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; {</p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160;  <span style="color: blue;">get</span> { <span style="color: blue;">return</span> <span style="color: blue;">this</span>.pre; }</p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160;  <span style="color: blue;">set</span> { <span style="color: blue;">this</span>.pre = <span style="color: blue;">value</span>; }</p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; }</p>
<p style="margin: 0px;">&#160;</p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; <span style="color: gray;">///</span><span style="color: green;"> </span><span style="color: gray;">&lt;summary&gt;</span></p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; <span style="color: gray;">///</span><span style="color: green;"> The node after this node in the chain.</span></p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; <span style="color: gray;">///</span><span style="color: green;"> </span><span style="color: gray;">&lt;/summary&gt;</span></p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; <span style="color: blue;">public</span> Node&lt;U&gt; Next</p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; {</p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160;  <span style="color: blue;">get</span> { <span style="color: blue;">return</span> <span style="color: blue;">this</span>.post; }</p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160;  <span style="color: blue;">set</span> { <span style="color: blue;">this</span>.post = <span style="color: blue;">value</span>; }</p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; }</p>
<p style="margin: 0px;">&#160;</p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; <span style="color: gray;">///</span><span style="color: green;"> </span><span style="color: gray;">&lt;summary&gt;</span></p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; <span style="color: gray;">///</span><span style="color: green;"> Whether or not the node has a node</span></p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; <span style="color: gray;">///</span><span style="color: green;"> reference to the previous node.</span></p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; <span style="color: gray;">///</span><span style="color: green;"> </span><span style="color: gray;">&lt;/summary&gt;</span></p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; <span style="color: blue;">public</span> <span style="color: blue;">bool</span> HasPrevious</p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; {</p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160;  <span style="color: blue;">get</span> { <span style="color: blue;">return</span> (<span style="color: blue;">this</span>.pre == <span style="color: blue;">null</span>) ? <span style="color: blue;">false</span> : <span style="color: blue;">true</span>; }</p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; }</p>
<p style="margin: 0px;">&#160;</p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; <span style="color: gray;">///</span><span style="color: green;"> </span><span style="color: gray;">&lt;summary&gt;</span></p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; <span style="color: gray;">///</span><span style="color: green;"> Whether or not the node has a node</span></p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; <span style="color: gray;">///</span><span style="color: green;"> reference to the next node.</span></p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; <span style="color: gray;">///</span><span style="color: green;"> </span><span style="color: gray;">&lt;/summary&gt;</span></p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; <span style="color: blue;">public</span> <span style="color: blue;">bool</span> HasNext</p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; {</p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160;  <span style="color: blue;">get</span> { <span style="color: blue;">return</span> (<span style="color: blue;">this</span>.post == <span style="color: blue;">null</span>) ? <span style="color: blue;">false</span> : <span style="color: blue;">true</span>; }</p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; }</p>
<p style="margin: 0px;">&#160;</p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; <span style="color: gray;">///</span><span style="color: green;"> </span><span style="color: gray;">&lt;summary&gt;</span></p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; <span style="color: gray;">///</span><span style="color: green;"> The actual value stored in this node.</span></p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; <span style="color: gray;">///</span><span style="color: green;"> </span><span style="color: gray;">&lt;/summary&gt;</span></p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; <span style="color: blue;">public</span> U Value</p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; {</p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160;  <span style="color: blue;">get</span> { <span style="color: blue;">return</span> <span style="color: blue;">this</span>.assignment; }</p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160;  <span style="color: blue;">set</span> { <span style="color: blue;">this</span>.assignment = <span style="color: blue;">value</span>; }</p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; }</p>
<p style="margin: 0px;">&#160;&#160; &#160;&#160; &#160; }</p>
<p style="margin: 0px;">&#160;&#160;  }</p>
<p style="margin: 0px;">}</p>
</div>

</div>

</div>

</p>   <p style="clear:both;"> 
    <a href="http://cyberkruz.vox.com/library/post/c-tutorial-linked-list.html?_c=feed-atom-full#comments">Read and post comments</a>   |   
    <a href="http://www.vox.com/share/6a00c2251f2742604a00d09e593c97be2b?_c=feed-atom-full">Send to a friend</a> 
</p>

                </div>
            ]]>
        </content> 
    <category term="c#" scheme="http://cyberkruz.vox.com/tags/c%23/" label="c#" /> 
    <category term="tutorial" scheme="http://cyberkruz.vox.com/tags/tutorial/" label="tutorial" /> 
    <category term=".net" scheme="http://cyberkruz.vox.com/tags/.net/" label=".net" /> 
    <category term="linked list" scheme="http://cyberkruz.vox.com/tags/linked+list/" label="linked list" /> 
    <category term="doubly-linked list" scheme="http://cyberkruz.vox.com/tags/doubly-linked+list/" label="doubly-linked list" /> 
    </entry> 
    
    <entry>
        <title>Wireless speed optimization tutorial</title>   
        <link rel="alternate" type="text/html" title="Wireless speed optimization tutorial" href="http://cyberkruz.vox.com/library/post/wireless-speed-optimization-tutorial.html?_c=feed-atom-full" />  
        <link rel="service.post" type="application/atom+xml" title="Wireless speed optimization tutorial" href="http://cyberkruz.vox.com/library/post/wireless-speed-optimization-tutorial.html?_c=feed-atom-full#comments" /> 
        <link rel="service.edit" type="application/atom+xml" title="Wireless speed optimization tutorial" href="http://www.vox.com/atom/svc=post/asset_id=6a00c2251f2742604a00cdf7ea28d7094f" />              <id>tag:vox.com,2006-12-04:asset-6a00c2251f2742604a00cdf7ea28d7094f</id>
        <published>2006-12-04T11:45:30Z</published>
        <updated>2006-12-05T22:42:19Z</updated>
    
        <author>
            <name>Matthew Kruskamp</name>
            <uri>http://cyberkruz.vox.com/?_c=feed-atom-full</uri>
        </author>
    
        
        <content type="html" xml:base="http://cyberkruz.vox.com/?_c=feed-atom-full">
            <![CDATA[
                <div xmlns="http://www.w3.org/1999/xhtml" xmlns:at="http://www.sixapart.com/ns/at">
        <p>This small tutorial is really just a personal reference, but to those who find it useful I&#39;m glad. I&#39;m currently running a T60p, and the wireless when we upgraded the internet was still slow. With a few optimizations however, one can get the full speed and usage of their network card.</p><blockquote><p>First, go to <a href="http://www.dslreports.com/tweaks">http://www.dslreports.com/tweaks</a>.<br />Click on start.<br />If start doesn&#39;t come up, you might need the JRE plugin for your browser. If so, then download and install 
it.<br />Click on Results once it has finished.<br />Fill out the connectivity form for tweak suggestions.<br /></p></blockquote><p><br />If you are like me, you got a suggestion for optimization.</p><blockquote><p>Under Notes and Recommendations, look for &quot;choose RWIN between some number and 
some number.&quot;<br />
Download DRTCP.<br />When you open the application, under Tcp Receive Window, put in the second number 
listed on choose RWIN between some number and some number.<br />Make sure that you have the right network adapter selected.<br />Save the settings.<br />Restart your computer.<br /></p></blockquote><p>Here are my before and afters. The difference is kind of amazing. Thank you <a href="http://vancottt.vox.com/" class="enclosure-inline-user" at:enclosure="inline-user" at:user-xid="6p00c22520a5be8e1d" at:screen-name="vancottt" at:delegate="people-connect" at:user-pic="http://up6.vox.com/6a00c22520a5be8e1d00c2251fbbea549d-75si" >vancottt</a> for this information. Have fun.<br />    
    
    
    
<div at:enclosure="asset" at:xid="6a00c2251f2742604a00cdf7ea28cc094f 6a00c2251f2742604a00cd9701c0754cd5" at:format="strip-horizontal" at:align="center" class="enclosure enclosure-center enclosure-strip enclosure-strip-horizontal"  style="text-align: center;">
<div class="enclosure-inner" style=" margin: 5px; border: 1px solid; text-align: center;"><a href="http://cyberkruz.vox.com/library/photo/6a00c2251f2742604a00cdf7ea28cc094f.html" class="enclosure-strip-link" title="Speedtest1"><img src="http://a4.vox.com/6a00c2251f2742604a00cdf7ea28cc094f-120pi" alt="Speedtest1" class="enclosure-strip-image" style="margin: 5px; border: 0;" /></a><a href="http://cyberkruz.vox.com/library/photo/6a00c2251f2742604a00cd9701c0754cd5.html" class="enclosure-strip-link" title="Speedtest2"><img src="http://a5.vox.com/6a00c2251f2742604a00cd9701c0754cd5-120pi" alt="Speedtest2" class="enclosure-strip-image" style="margin: 5px; border: 0;" /></a></div>
</div> <!-- end enclosure -->
 
 
 
 
 </p>   <p style="clear:both;"> 
    <a href="http://cyberkruz.vox.com/library/post/wireless-speed-optimization-tutorial.html?_c=feed-atom-full#comments">Read and post comments</a>   |   
    <a href="http://www.vox.com/share/6a00c2251f2742604a00cdf7ea28d7094f?_c=feed-atom-full">Send to a friend</a> 
</p>

                </div>
            ]]>
        </content> 
    <category term="wireless" scheme="http://cyberkruz.vox.com/tags/wireless/" label="wireless" /> 
    <category term="optimization" scheme="http://cyberkruz.vox.com/tags/optimization/" label="optimization" /> 
    <category term="tutorial" scheme="http://cyberkruz.vox.com/tags/tutorial/" label="tutorial" /> 
    </entry> 
    
    <entry>
        <title>Installing Ubuntu on T60 with XGL and Beryl</title>   
        <link rel="alternate" type="text/html" title="Installing Ubuntu on T60 with XGL and Beryl" href="http://cyberkruz.vox.com/library/post/installing-ubuntu-on-t60-with-xgl-and-beryl.html?_c=feed-atom-full" />  
        <link rel="service.post" type="application/atom+xml" title="Installing Ubuntu on T60 with XGL and Beryl" href="http://cyberkruz.vox.com/library/post/installing-ubuntu-on-t60-with-xgl-and-beryl.html?_c=feed-atom-full#comments" /> 
        <link rel="service.edit" type="application/atom+xml" title="Installing Ubuntu on T60 with XGL and Beryl" href="http://www.vox.com/atom/svc=post/asset_id=6a00c2251f2742604a00ccff86f0d8985d" />              <id>tag:vox.com,2006-11-03:asset-6a00c2251f2742604a00ccff86f0d8985d</id>
        <published>2006-11-03T10:16:54Z</published>
        <updated>2007-01-05T15:01:40Z</updated>
    
        <author>
            <name>Matthew Kruskamp</name>
            <uri>http://cyberkruz.vox.com/?_c=feed-atom-full</uri>
        </author>
    
        
        <content type="html" xml:base="http://cyberkruz.vox.com/?_c=feed-atom-full">
            <![CDATA[
                <div xmlns="http://www.w3.org/1999/xhtml" xmlns:at="http://www.sixapart.com/ns/at">
        <p><span style="font-size: 1.25em;">Introduction</span><br />I decided for my reference and by requests of various people, that I would write a full installation tutorial for Ubuntu with all of the cool features of XGL and Beryl on the T60. The cool thing about Ubuntu is it installs and configures a lot of your drivers for you (including wireless) so it is fairly painless to get everything up and running. I wrote this tutorial dual-booting Windows XP with my T60p (2007-93U).</p><p><span style="font-size: 1.25em;">Getting the live cd</span><br />Snag the latest desktop download iso from <a href="http://www.ubuntu.com/products/GetUbuntu/download?action=show&amp;redirect=download">here.</a> Burn it off and boot her up. When everything boots up and you are in UBUNTU, double click the installer. Follow the instructions for partitoning and the keyboard and everything. I will post pictures soon. Then sit back and watch it install. After it is done installing, reboot and pull the cd out.</p><p>This is how my partitions are set up.</p>       
<div at:enclosure="asset" at:xid="6a00c2251f2742604a00ccff870832985d 6a00c2251f2742604a00cd97834855f9cc" at:format="strip-horizontal" at:align="center" class="enclosure enclosure-center enclosure-strip enclosure-strip-horizontal"  style="text-align: center;">
<div class="enclosure-inner" style=" margin: 5px; border: 1px solid; text-align: center;"><a href="http://cyberkruz.vox.com/library/photo/6a00c2251f2742604a00ccff870832985d.html" class="enclosure-strip-link" title="Parts1"><img src="http://a2.vox.com/6a00c2251f2742604a00ccff870832985d-120pi" alt="Parts1" class="enclosure-strip-image" style="margin: 5px; border: 0;" /></a><a href="http://cyberkruz.vox.com/library/photo/6a00c2251f2742604a00cd97834855f9cc.html" class="enclosure-strip-link" title="Parts2"><img src="http://a5.vox.com/6a00c2251f2742604a00cd97834855f9cc-120pi" alt="Parts2" class="enclosure-strip-image" style="margin: 5px; border: 0;" /></a></div>
</div> <!-- end enclosure -->
 
<p></p><p>Holy moly, the majority of our stuff is installed aready. Network support for the T60 hardware is fully functional for both the wired and wireless connection. That definatly makes things easy. You are going to want to be online for this so go configure your networking. It is in:</p><p>System-&gt;Administraton-&gt;Networking</p><p>Once you set up your network settings, you can test them by opening up a browser and trying to navigate to a site.</p><p><span style="font-size: 1.25em;">Video</span><br />Now that we can access the internet, we need to get the video drivers installed so we can use XGL. In order to do that, we need to change our package manager to have the restricted packages. So open up a terminal (Applications-&gt;Accessories-&gt;Terminal) and type the following:</p><blockquote><p>sudo nano /etc/apt/sources.list<br /></p></blockquote><p><br />I went and uncommented every line that started with deb in order to get all of the packages we could use. Also, if you are on a broadband connection, I usually delete the top cdrom line as well. Once this is done, type ctrl-x-y and hit enter to get back to the terminal. Now we must update our packages and it is a good idea to upgrade any packages we have installed and may be out of date so type into the terminal:</p><blockquote><p>sudo aptitude update<br />sudo aptitude upgrade<br />sudo aptitude install linux-restricted-modules<br />sudo aptitude install xorg-driver-fglrx<br />sudo depmod -a<br /></p></blockquote><p><br />There we go, now we have video driver support installed. But we have to set up our xserver to reflect our new found drivers.</p><blockquote><p>sudo aticonfig --initial<br />sudo aticonfig --overlay-type=Xv<br /></p></blockquote><p><br />And now, I like to go into my configuration and give myself a higher resolution to run at:</p><blockquote><p>sudo cp /etc/X11/xorg.conf /etc/X11/xorg.conf.bak<br />sudo nano /etc/X11/xorg.conf<br /></p></blockquote><p><br />Scroll down to where it says Section &quot;Screen&quot; and look for a section called SubSection &quot;Display with a Depth of 24. Under Modes, I like a higher resolution so add 1600x1200 like shown below:</p><blockquote><p>SubSection &quot;Display&quot;<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; Depth&#160;&#160;&#160;&#160; 24<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; Modes&#160;&#160;&#160; &quot;1600x1200&quot; &quot;1024x768&quot; &quot;800x600&quot; &quot;640x480&quot;<br />EndSubSection<br /></p></blockquote><p><br />Now scroll all the way to the bottom and add the following to the bottom of the configuration file.</p><blockquote><p>Section &quot;Extensions&quot;<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; Option&#160; &quot;Composite&quot; &quot;0&quot;<br />EndSection<br /></p></blockquote><p><br />Just for those wondering why this is done, the fglrx drivers at the time of this writing don&#39;t have support for composite extensions. Now press ctrl-x-y and press alt+backspace to restart the x-server. You should see a higher resolution x-server, and when you log in, things should be smoother. Just to verify, open up a terminal (Applications-&gt;Accessories-&gt;Terminal) and type:</p><blockquote><p>glxinfo |grep direct<br /></p></blockquote><p><br />If the response is:</p><blockquote><p>direct rendering: Yes<br /></p></blockquote><p><br />Congratulations you have working video drivers! </p><p><span style="font-size: 1.25em;">XGL and Beryl</span><br />Well that was fairly boring, now on to XGL. Using your terminal, open up your sources.list again by typing:</p><blockquote><p>sudo nano /etc/apt/sources.list<br /></p></blockquote><p><br />Scroll to the bottom and add this line:</p><blockquote><p>deb http://ubuntu.beryl-project.org/ edgy main-edgy<br /></p></blockquote><p><br />ctrl-x-y to save and exit and now we can get the key. The key? Well the packages are digitally signed with a key for validation and we need to add that key. So type this in command to get the key:</p><blockquote><p>sudo wget http://ubuntu.beryl-project.org/quinn.key.asc --quiet -O - | sudo apt-key add -<br /></p></blockquote><p><br />And it should come back with the response: OK. Now we can install XGL and beryl with our package manager. So type:</p><blockquote><p>sudo apt-get update<br />sudo apt-get install beryl beryl-core beryl-plugins beryl-plugins-data beryl-settings beryl-manager emerald emerald-themes xserver-xgl<br /></p></blockquote><p><br />We have everything we need installed, now we just have to configure it. We are going to create a custom session for XGL. So type the following into your terminal:</p><blockquote><p>sudo nano /usr/share/xsessions/xgl.desktop<br /></p></blockquote><p><br />When it opens, add this too it:</p><blockquote><p>[Desktop Entry]<br />Encoding=UTF-8<br />Name=Xgl<br />Exec=/usr/bin/startxgl.sh<br />Icon=<br />Type=Application<br /></p></blockquote><p><br />ctrl-x-y to save and close the file and then type:</p><blockquote><p>sudo nano /usr/bin/startxgl.sh<br /></p></blockquote><p><br />When it opens, add this to it:</p><blockquote><p>#!/bin/sh<br />Xgl -fullscreen :1 -ac -accel glx:pbuffer -accel xv:pbuffer &amp;<br />sleep 4&#160; <br />export DISPLAY=:1 <br />exec gnome-session<br /></p></blockquote><p><br />ctrl-x-y to save and close. We need to be able to execute the scripts we just wrote so type:</p><blockquote><p>sudo chmod a+x /usr/bin/startxgl.sh<br /></p></blockquote><p><br />If you are wondering exactly what we just did with this text editing, we created a desktop entry for our xserver session manager (The first edit). This entry points to our script that executes gnome with xgl (Second edit). Now we just type ctrl-alt-backspace to kill the xserver again. At the login screen, click sessions and select XGL. Now login as normal.</p><p>Well things changed, but it looks a little worse then before. Don&#39;t worry, we will get to that. We need to test beryl first. Open up a terminal again (Applications-&gt;Accessories-&gt;Terminal) and type:</p><blockquote><p>beryl-manager<br /></p></blockquote><p><br />Holy wow again. a logo should pop up and all your borders dissapear, and then ... your windows are all wavy when you move them. Pretty cool. Now we have to finish it all up. First thing we have to do is make beryl start on your startup so click System-&gt;Preferences-&gt;Sessions. Click on the startup tab and click Add. Type beryl-manager under the startup command and press ok. This will make beryl-manager load on the start. However, we also want to make it look a little better so press add again and type gnome-settings-daemon and press ok. Now press ctrl+alt+backspace to restart xserver again and login again.</p><p>Wow, super cool huh? The little red ruby is where you do all your configuration. Have fun!</p><p>Another little issue I have is accidentally hitting shift-backspace. If you find this is annoying as well, I have another post about it below.</p><p>Note: When using OpenGL games and other programs of the sort, it is better to run them using regular gnome and not XGL. You can do this just by switching the session when you login.</p><p>For more information the <a href="http://wiki.cchtml.com/index.php/Main_Page">ATI Wiki</a> and the <a href="http://wiki.beryl-project.org/index.php">Beryl Project Wiki</a> are both really good resources.</p><p><br /><span style="font-size: 1.25em;"><br /></span> <div><br /></div></p>   <p style="clear:both;"> 
    <a href="http://cyberkruz.vox.com/library/post/installing-ubuntu-on-t60-with-xgl-and-beryl.html?_c=feed-atom-full#comments">Read and post comments</a>   |   
    <a href="http://www.vox.com/share/6a00c2251f2742604a00ccff86f0d8985d?_c=feed-atom-full">Send to a friend</a> 
</p>

                </div>
            ]]>
        </content> 
    <category term="ubuntu" scheme="http://cyberkruz.vox.com/tags/ubuntu/" label="ubuntu" /> 
    <category term="tutorial" scheme="http://cyberkruz.vox.com/tags/tutorial/" label="tutorial" /> 
    <category term="xgl" scheme="http://cyberkruz.vox.com/tags/xgl/" label="xgl" /> 
    <category term="installation" scheme="http://cyberkruz.vox.com/tags/installation/" label="installation" /> 
    <category term="beryl" scheme="http://cyberkruz.vox.com/tags/beryl/" label="beryl" /> 
    <category term="t60p" scheme="http://cyberkruz.vox.com/tags/t60p/" label="t60p" /> 
    <category term="t60" scheme="http://cyberkruz.vox.com/tags/t60/" label="t60" /> 
    <category term="firegl" scheme="http://cyberkruz.vox.com/tags/firegl/" label="firegl" /> 
    </entry> 
    
    <entry>
        <title>ASP.NET Membership and Roles tutorial</title>   
        <link rel="alternate" type="text/html" title="ASP.NET Membership and Roles tutorial" href="http://cyberkruz.vox.com/library/post/aspnet-membership-and-roles-tutorial.html?_c=feed-atom-full" />  
        <link rel="service.post" type="application/atom+xml" title="ASP.NET Membership and Roles tutorial" href="http://cyberkruz.vox.com/library/post/aspnet-membership-and-roles-tutorial.html?_c=feed-atom-full#comments" /> 
        <link rel="service.edit" type="application/atom+xml" title="ASP.NET Membership and Roles tutorial" href="http://www.vox.com/atom/svc=post/asset_id=6a00c2251f2742604a00c22529471a8e1d" />          <id>tag:vox.com,2006-09-27:asset-6a00c2251f2742604a00c22529471a8e1d</id>
        <published>2006-09-27T05:04:28Z</published>
        <updated>2006-09-27T05:08:08Z</updated>
    
        <author>
            <name>Matthew Kruskamp</name>
            <uri>http://cyberkruz.vox.com/?_c=feed-atom-full</uri>
        </author>
    
        
        <content type="html" xml:base="http://cyberkruz.vox.com/?_c=feed-atom-full">
            <![CDATA[
                <div xmlns="http://www.w3.org/1999/xhtml" xmlns:at="http://www.sixapart.com/ns/at">
        <p><strong><span style="font-size: 1.25em;">Overview</span></strong><br />
I was originally going to just post the information needed for my
reference, but I decided that I had to reference many things all the
time, so I will just post a tutorial. For those people using ASP.NET
often on a large amount of projects have no doubt-ably come across
ASP.NET 2.0&#39;s custom roles and membership tools. These tools allow you
to use a lot of prefabricated tools written by the Microsoft developers
in order to perform menial tasks like authentication and role
assignment. The problem is that this system is so flexible, it is hard
to get a lot of documentation about using all of the features, and
searchers are usually pointed to specific information. This tutorial is
going to be short and sweet and demonstrate what I feel would be the
most common and useful usage for the membership and role system.
</p><p>
Our task: A custom authentication system implementing users and roles.<br />
Our technologies: ASP.NET 2.0 written in C# (Visual Studio) using a SqlServer 2005 database.
</p>
<p><span style="font-size: 1.25em;"><strong>Setting up the database</strong></span><br />
Origonally, I was under the assumtion that unless I wrote my own custom
membership and role classes, I would be required to use the ASPNETDB on
SqlExpress (I later found out that a lot of people were under the same
assumption). Well I have no intention of writing unnessissary code, and
I found out that there is a tool that will set up a remote database
according to the specifications of Microsoft&#39;s default membership and
role providers. so...
</p>
<ul>
  <li><em>Run the Visual Studio Command Prompt</em></li>
  <li><em>Type aspnet_regsql and press enter</em></li>
  <li><em>Go through the wizard provided to set up your database</em></li>
</ul><p>
This will set up your database with all of the stored procedures and tables required. Very fast eh? Onward...
</p>
<p><strong><span style="font-size: 1.25em;">Setting up the website
</p>
</span></strong>
<ul>
  <li><em>Create a new ASP.NET website or open up the existing site.</em></li>
  <li><em>Create a new or open up your web.config files</em></li>
</ul>
<p><em><br />
</em>Use the following in your web.config under the &lt;configuration&gt; section
</p><p><span style="font-size: 1.25em;">
&#160;&#160;&#160; </span><span style="font-size: 1em;">&lt;connectionStrings&gt;<br />

&#160;&#160;&#160; &#160;&#160;&#160; &lt;add name=&quot;TestConnection&quot; <br />

&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; connectionString=&quot;your connection string here&quot;/&gt;<br />

&#160;&#160;&#160; &lt;/connectionStrings&gt;</span>
</p><p>
This section is the connection string for your SqlServer2005 server
that you previously configured. It will be used by our membership and
roles declarations below. Add the following too your web.config file
under the &lt;system.web&gt; section
</p><p>
&#160;&#160;&#160; &#160;&#160;&#160;<span style="font-size: 1.25em;"> </span><span style="font-size: 1em;">&lt;roleManager enabled=&quot;true&quot; defaultProvider=&quot;MyTestRoleProvider&quot;&gt;<br />

&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &lt;providers&gt;<br />

&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &lt;clear /&gt;<br />

&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160;
&#160;&#160;&#160; &lt;add connectionStringName=&quot;TestConnection&quot;
<br />
&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160;
&#160;&#160;&#160; &#160;&#160;&#160; applicationName=&quot;/ApplicationName&quot;<br />

&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160;
&#160;&#160;&#160; &#160;&#160;&#160;&#160; name=&quot;MyTestRoleProvider&quot;
type=&quot;System.Web.Security.SqlRoleProvider&quot; /&gt;<br />

&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &lt;/providers&gt;<br />

&#160;&#160;&#160; &#160;&#160;&#160; &lt;/roleManager&gt;
</p><p>

&#160;&#160;&#160; &#160;&#160;&#160; &lt;membership defaultProvider=&quot;MyTestMembershipProvider&quot; <br />

&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160;
&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160;
&#160;&#160;&#160; userIsOnlineTimeWindow=&quot;20&quot; <br />

&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160;
&#160;&#160;&#160; &#160;&#160;&#160; &#16