public bool Remove(Patient element) { var currentNode = head; PatientListNode node = new PatientListNode(currentNode.data); if (element == null || count == 0) { return(false); } for (int x = 0; x <= count; x++) { if (!Equals(currentNode.data, element)) { node = currentNode; node.next = currentNode.next; } } //Element was not found in the list if (Equals(currentNode, null)) { return(false); } if (currentNode == head) { head = currentNode.next; count--; return(true); } return(false); }
public Patient[] All() { Patient[] patientArray = new Patient[count]; PatientListNode runner = head; int contador = 1; while (runner != null) { Console.WriteLine(); Console.WriteLine("Paciente #- " + contador); Console.WriteLine(); Console.WriteLine("Nombre: " + runner.data.Nombre); Console.WriteLine("Apellido: " + runner.data.Apellido); Console.Write("Disorders: "); for (int x = 0; x <= runner.data.Disorders.Count - 1; x++) { patientArray[x] = runner.data; } runner = runner.next; contador++; for (int z = 0; z <= patientArray.Length - 1; z++) { Console.WriteLine(patientArray[z]); } } return(patientArray); }
public bool Add(Patient element) { PatientListNode node = new PatientListNode(element); node.next = head; head = node; count++; return(true); }
public bool Contains(Patient element) { var currentNode = head; PatientListNode node = new PatientListNode(currentNode.data); if (element == null || count == 0) { return(false); } for (int x = 0; x <= count; x++) { if (currentNode.data.Apellido == element.Apellido && currentNode.data.Nombre == element.Nombre) { return(true); } } return(false); }
public PatientLinkedList() { head = null; count = 0; }
public PatientListNode(Patient element) { data = element; next = null; }