Ejemplo n.º 1
0
    public static void Main(string[] args)
    {
        Link link = new Link();

        link.AddLast("one");
        Console.WriteLine(link.Head.Name == "one");
        Console.WriteLine(link.Tail.Name == "one");
        Console.WriteLine(link.Head.Prev == null);
        Console.WriteLine(link.Head.Next == null);
        link.AddLast("two");
        Console.WriteLine(link.Head.Name == "one");
        Console.WriteLine(link.Tail.Name == "two");
        Console.WriteLine(link.Head.Prev.Name == "two");
        Console.WriteLine(link.Head.Next.Name == "two");
        Console.WriteLine(link.Tail.Prev.Name == "one");
        Console.WriteLine(link.Tail.Next.Name == "one");
        link.AddFirst("zero");
        Console.WriteLine(link.Head.Name == "zero");
        Console.WriteLine(link.Tail.Name == "two");
        Console.WriteLine(link.Head.Prev.Name == "two");
        Console.WriteLine(link.Head.Next.Name == "one");
        Console.WriteLine(link.Tail.Prev.Name == "one");
        Console.WriteLine(link.Tail.Next.Name == "zero");
        link.AddLast("three");
        Console.WriteLine(link.Head.Name == "zero");
        Console.WriteLine(link.Tail.Name == "three");
        Console.WriteLine(link.Head.Prev.Name == "three");
        Console.WriteLine(link.Head.Next.Name == "one");
        Console.WriteLine(link.Tail.Prev.Name == "two");
        Console.WriteLine(link.Tail.Next.Name == "zero");
        // Check Current
        Console.WriteLine(link.Head.Next.Name == "one");
        Console.WriteLine(link.Tail.Next.Name == "zero");
        Console.WriteLine(link.Head.Prev.Prev.Name == "two");
        Console.WriteLine(link.Head.Next.Next.Name == "two");
        Console.WriteLine(link.Tail.Prev.Prev.Name == "one");
        Console.WriteLine(link.Tail.Next.Next.Name == "one");
        Console.WriteLine(link.Head.Next.Next.Next.Name == "three");
        link.RemoveFirst();
        Console.WriteLine(link.Head.Name == "one");
        Console.WriteLine(link.Tail.Name == "three");
        Console.WriteLine(link.Head.Prev.Name == "three");
        Console.WriteLine(link.Head.Next.Name == "two");
        Console.WriteLine(link.Tail.Prev.Name == "two");
        Console.WriteLine(link.Tail.Next.Name == "one");
        link.AddFirst("zero");
        link.RemoveLast();
        Console.WriteLine(link.Head.Name == "zero");
        Console.WriteLine(link.Tail.Name == "two");
        Console.WriteLine(link.Head.Prev.Name == "two");
        Console.WriteLine(link.Head.Next.Name == "one");
        Console.WriteLine(link.Tail.Prev.Name == "one");
        Console.WriteLine(link.Tail.Next.Name == "zero");
        Console.WriteLine(link.Tail.Next.Next.Name == "one");
        Console.WriteLine(link.Head.Prev.Prev.Name == "one");

        Console.WriteLine("Count : " + link.Count());
    } // emm