Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using DoubleLinkedListExample;
- namespace DLList
- {
- public class DLListTest
- {
- static void Main(string[] args)
- {
- DoubleLinkedList<int> dll = new DoubleLinkedList<int>();
- dll.Add(new Node<int>(1));
- dll.Add(new Node<int>(2));
- dll.Add(new Node<int>(3));
- dll.Add(new Node<int>(4));
- dll.Add(new Node<int>(5));
- dll.AddToHead(new Node<int>(0));
- dll.AddToHead(new Node<int>(-1));
- Console.WriteLine("The 2nd element is {0}",dll[0]);
- Console.WriteLine("All the elements are: (reversed)");
- for (int i = dll.Size-1; i >=0; i--)
- {
- Console.WriteLine("{0} element: {1}",i+1,dll[i]);
- }
- dll.InsertAt(new Node<int>(100), 3);
- Console.WriteLine("After inserting element 100 at position 3, we have:");
- for (int i = 0; i < dll.Size; i++)
- {
- Console.WriteLine("{0} element: {1}", i + 1, dll[i]);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement