public void RemoveLastMethod_RemovesTheOnlyItemInTheList()
            {
                SimpleLinkedList <string> linkedList = new SimpleLinkedList <string>();

                linkedList.AddLast("asdf");

                linkedList.RemoveLast();

                Assert.Null(linkedList.Find("asdf"));
            }
            public void RemoveMethod_RemovesTheOnlyItemFromList()
            {
                SimpleLinkedList <string> linkedList = new SimpleLinkedList <string>();

                linkedList.AddFirst("asdf");

                linkedList.Remove("asdf");

                Assert.Null(linkedList.Find("asdf"));
            }
            public void FindMethod_ReturnsNullIfItemIsNotFound()
            {
                SimpleLinkedList <string> linkedList = new SimpleLinkedList <string>();

                linkedList.AddFirst("asdf");
                linkedList.AddFirst("qwer");

                LinkedListNode <string> node = linkedList.Find("zzzzzzzzzzzz");

                Assert.Null(node);
            }
            public void RemoveMethod_RemovesCorrectItemFromListWithMultipleItems()
            {
                SimpleLinkedList <string> linkedList = new SimpleLinkedList <string>();

                linkedList.AddFirst("asdf");
                linkedList.AddFirst("middle");
                linkedList.AddFirst("qwer");

                linkedList.Remove("middle");

                Assert.Null(linkedList.Find("middle"));
            }
            public void FindMethod_ReturnsCorrectNode()
            {
                SimpleLinkedList <string> linkedList = new SimpleLinkedList <string>();

                linkedList.AddFirst("asdf");
                linkedList.AddFirst("qwer");

                LinkedListNode <string> node = linkedList.Find("asdf");

                Assert.NotNull(node);
                Assert.Equal("asdf", node.Item);
            }
Exemple #6
0
        public Patient FindPatientByName(string first, string last)
        {
            Patient pat = null;

            int index = Patient.genPatientId(first, last) % this.size;
            SimpleLinkedList <Patient> pList = list[index];

            if (pList != null)
            {
                pat = pList.Find(new Patient(first, last, 0));
            }

            return(pat);
        }
        public void CheckListImplementation()
        {
            var        myList  = new SimpleLinkedList <int>();
            List <int> netList = new List <int>();

            myList.AddFirst(1);
            foreach (var i in myList)
            {
                netList.Add(i);
            }
            LinkedList <int> nwtList = new LinkedList <int>();

            Assert.Equal(1, netList[0]);

            myList.AddFirst(0);
            Assert.Equal(0, myList.Head.Value);
            Assert.Equal(1, myList.Last.Value);

            SimpleLinkedList <int> my3 = new SimpleLinkedList <int>(new[] { 1, 2, 3 });

            var node2 = my3.Find(2);

            my3.Remove(node2);

            netList.Clear();
            foreach (var i in my3)
            {
                netList.Add(i);
            }

            Assert.Equal(1, netList[0]);
            Assert.Equal(3, netList[1]);

            my3.Remove(my3.Head);

            netList.Clear();
            foreach (var i in my3)
            {
                netList.Add(i);
            }
            Assert.Equal(3, netList[0]);
        }
            public void RemoveMethod_RemovesTheOnlyItemFromList()
            {
                SimpleLinkedList<string> linkedList = new SimpleLinkedList<string>();
                linkedList.AddFirst("asdf");

                linkedList.Remove("asdf");

                Assert.Null(linkedList.Find("asdf"));
            }
            public void RemoveMethod_RemovesCorrectItemFromListWithMultipleItems()
            {
                SimpleLinkedList<string> linkedList = new SimpleLinkedList<string>();
                linkedList.AddFirst("asdf");
                linkedList.AddFirst("middle");
                linkedList.AddFirst("qwer");

                linkedList.Remove("middle");

                Assert.Null(linkedList.Find("middle"));
            }
            public void RemoveLastMethod_RemovesTheOnlyItemInTheList()
            {
                SimpleLinkedList<string> linkedList = new SimpleLinkedList<string>();
                linkedList.AddLast("asdf");

                linkedList.RemoveLast();

                Assert.Null(linkedList.Find("asdf"));
            }
            public void FindMethod_ReturnsNullIfItemIsNotFound()
            {
                SimpleLinkedList<string> linkedList = new SimpleLinkedList<string>();
                linkedList.AddFirst("asdf");
                linkedList.AddFirst("qwer");

                LinkedListNode<string> node = linkedList.Find("zzzzzzzzzzzz");

                Assert.Null(node);
            }
            public void FindMethod_ReturnsCorrectNode()
            {
                SimpleLinkedList<string> linkedList = new SimpleLinkedList<string>();
                linkedList.AddFirst("asdf");
                linkedList.AddFirst("qwer");

                LinkedListNode<string> node = linkedList.Find("asdf");

                Assert.NotNull(node);
                Assert.Equal("asdf", node.Item);
            }