Sayfayı Yazdır | Pencereyi Kapat

basit bir linked list örneği

Nereden Yazdırıldığı: Datakent
Kategori: Diğer bölümler
Forum Adı: C# & ASP.NET
Forum Tanımlaması: C# ve ASP.NET ile ilgili soru / sorun ve paylaşım bölümü
URL: http://forum.datakent.com/forum_posts.asp?TID=2375
Tarih: 29.Mart.2024 Saat 17:33


Konu: basit bir linked list örneği
Mesajı Yazan: aziz.alkurt
Konu: basit bir linked list örneği
Mesaj Tarihi: 17.Haziran.2012 Saat 18:21
    class LL
    {
        public int Key { get; set; }
        public string Value { get; set; }
        public LL next { get; set; }
        public LL(int Key, string Value)
        {
            this.Key = Key;
            this.Value = Value;
        }
        public void insertNode(LL list,LL newNode)
        {
            LL endNode = list;
            while (endNode.next != null)
                endNode = endNode.next;
            endNode.next = newNode;
        }
    }
    class Program
    {
        static void Main(string[] args)
        {
            LL list = new LL(1, "A");  
            list.insertNode(list, new LL(2, "B"));
            list.insertNode(list, new LL(3, "C"));
            list.insertNode(list, new LL(4, "D"));
            while (list != null)
            {
                Console.WriteLine("Key=" + list.Key + " Value " + list.Value);
                list = list.next;
            }
            Console.ReadKey();
        }
    }

Nerede kullanılır? Dinamik olan her nesnede kullanılır. Bu kadar basit değil, doubly linked list, circular linked list gibi çeşitli tipleri vardır.



Cevaplar:
Mesajı Yazan: bayramucuncu
Mesaj Tarihi: 26.Agustos.2012 Saat 20:02
Teşekkürler Aziz.

-------------
http://www.bayramucuncu.com - Test Driven Development



Sayfayı Yazdır | Pencereyi Kapat