コード例 #1
0
        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);
        }
コード例 #2
0
        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);
        }
コード例 #3
0
        public bool Add(Patient element)
        {
            PatientListNode node = new PatientListNode(element);

            node.next = head;
            head      = node;
            count++;

            return(true);
        }
コード例 #4
0
        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);
        }
コード例 #5
0
 public PatientLinkedList()
 {
     head  = null;
     count = 0;
 }
コード例 #6
0
 public PatientListNode(Patient element)
 {
     data = element;
     next = null;
 }