Lista dinâmica duplamente encadeada – C#

Autor: Emerson Shigueo Sugimoto 08/03/2014

Criei este projeto para resolver um problema que envolvia LinquedList (C#), que por definição é uma lista duplamente ligada. O objetivo do projeto é o desenvolvimento de uma biblioteca de objetos genéricos armazenados em uma lista duplamente ligada com inserção ordenada.

Exemplo de Entrada:

LinkedList lqDt = new LinkedList();
UtilLinquedList.AddLinkedList(ref lqDt, new LQData(DateTime.Now));
UtilLinquedList.AddLinkedList(ref lqDt, new LQData(DateTime.Now.AddDays(-1)));
UtilLinquedList.AddLinkedList(ref lqDt, new LQData(DateTime.Now.AddDays(-4)));
UtilLinquedList.AddLinkedList(ref lqDt, new LQData(DateTime.Now.AddDays(10)));

txt1.Text = UtilLinquedList.Print(lqDt) + Environment.NewLine + Environment.NewLine;

LinkedList lqInt = new LinkedList();
UtilLinquedList.AddLinkedList(ref lqInt, new LQInt(3));
UtilLinquedList.AddLinkedList(ref lqInt, new LQInt(20));
UtilLinquedList.AddLinkedList(ref lqInt, new LQInt(14));
UtilLinquedList.AddLinkedList(ref lqInt, new LQInt(-7));
UtilLinquedList.AddLinkedList(ref lqInt, new LQInt(1));
UtilLinquedList.AddLinkedList(ref lqInt, new LQInt(3));

txt1.Text += UtilLinquedList.Print(lqInt) + Environment.NewLine + Environment.NewLine;

LinkedList lqPessoa = new LinkedList();
UtilLinquedList.AddLinkedList(ref lqPessoa, new LQPessoa(new Pessoa() { Nome = "Emerson", Idade = 10 }));
UtilLinquedList.AddLinkedList(ref lqPessoa, new LQPessoa(new Pessoa() { Nome = "Maria", Idade = 7 }));
UtilLinquedList.AddLinkedList(ref lqPessoa, new LQPessoa(new Pessoa() { Nome = "Alana", Idade = 20 }));
UtilLinquedList.AddLinkedList(ref lqPessoa, new LQPessoa(new Pessoa() { Nome = "Denise", Idade = 20 }));
UtilLinquedList.AddLinkedList(ref lqPessoa, new LQPessoa(new Pessoa() { Nome = "Kurtis", Idade = 15 }));
UtilLinquedList.AddLinkedList(ref lqPessoa, new LQPessoa(new Pessoa() { Nome = "Paula", Idade = 9 }));
UtilLinquedList.AddLinkedList(ref lqPessoa, new LQPessoa(new Pessoa() { Nome = "Gogh", Idade = 7 }));
UtilLinquedList.AddLinkedList(ref lqPessoa, new LQPessoa(new Pessoa() { Nome = "Four", Idade = 4 }));

txt1.Text += UtilLinquedList.Print(lqPessoa) + Environment.NewLine + Environment.NewLine;

Exemplo de saída do sistema:

SaidaDoubleLinquedList
Continuar lendo Lista dinâmica duplamente encadeada – C#