Advertisement
TodorMitev

DoubleLinkedList<T> Test Class

Jun 21st, 2012
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.20 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using DoubleLinkedListExample;
  6.  
  7. namespace DLList
  8. {
  9.     public class DLListTest
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             DoubleLinkedList<int> dll = new DoubleLinkedList<int>();
  14.             dll.Add(new Node<int>(1));
  15.             dll.Add(new Node<int>(2));
  16.             dll.Add(new Node<int>(3));
  17.             dll.Add(new Node<int>(4));
  18.             dll.Add(new Node<int>(5));
  19.            
  20.             dll.AddToHead(new Node<int>(0));
  21.             dll.AddToHead(new Node<int>(-1));
  22.            
  23.             Console.WriteLine("The 2nd element is {0}",dll[0]);
  24.             Console.WriteLine("All the elements are: (reversed)");
  25.            
  26.             for (int i = dll.Size-1; i >=0; i--)
  27.             {
  28.                 Console.WriteLine("{0} element: {1}",i+1,dll[i]);
  29.             }
  30.  
  31.             dll.InsertAt(new Node<int>(100), 3);
  32.             Console.WriteLine("After inserting element 100 at position 3, we have:");
  33.             for (int i = 0; i < dll.Size; i++)
  34.             {
  35.                 Console.WriteLine("{0} element: {1}", i + 1, dll[i]);
  36.             }
  37.         }
  38.     }
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement