SinglyLinkedListCollection(Of T)

C#

using System;
using Dsa.DataStructures;

namespace Dsa.Examples {

    class Program {

        static void Main() {
            SinglyLinkedList<int> sll = new SinglyLinkedList<int>();
            sll.AddLast(20);
            sll.AddLast(30);
            sll.AddLast(40);
            sll.AddFirst(10);
            foreach (int i in sll) {
                Console.WriteLine(i);
            }
        }

    }

}


C++/CLI

#include "stdafx.h"

using namespace System;
using namespace Dsa::DataStructures;

int main() {
	SinglyLinkedList<String ^> ^sll = gcnew SinglyLinkedList<String ^>();
	sll->AddLast("Granville");
	sll->AddLast("John");
	sll->AddLast("Rachel");
	sll->AddFirst("Monica");
	for each (String ^s in sll) {
		Console::WriteLine(s);
	}
    return 0;
}


C# LINQ

using System;
using System.Collections.Generic;
using System.Linq;
using Dsa.DataStructures;

namespace Dsa.Examples {

    class Program {

        static void Main() {
            SinglyLinkedList<int> sll = new SinglyLinkedList<int>();
            sll.AddLast(20);
            sll.AddLast(30);
            sll.AddLast(40);
            sll.AddFirst(10);
            IEnumerable<int> expr = sll.Where(x => x > 20);
            foreach (int i in expr) {
                Console.WriteLine(i);
            }
        }

    }

}

Last edited Sep 1, 2007 at 5:01 PM by gbarnett, version 1

Comments

No comments yet.