Пример #1
0
        public void HeadPrevIsTailAndTailNextIsHead(int first, int last)
        {
            var list = new CircularlyLinkedList <int>();

            list.AddFirst(first);
            list.AddLast(last);
            Assert.Equal(list.Find(last), list.Find(first).Prev);
            Assert.Equal(list.Find(first), list.Find(last).Next);
        }
Пример #2
0
        public void AddingAndRemovingIncrementsAndDecrementsTheCount()
        {
            var list = new CircularlyLinkedList <int>();

            list.AddFirst(1);
            list.AddAfter(list.Find(1), 3);
            list.AddBefore(list.Find(3), 2);
            list.AddLast(4);
            Assert.Equal(4, list.Count);
            list.RemoveFirst();
            list.RemoveLast();
            list.Remove(3);
            Assert.Equal(1, list.Count);
        }
Пример #3
0
        public void ListOnlyHasTwoTermsNextValueIsEqualToPrevious()
        {
            var list = new CircularlyLinkedList <int>();

            list.AddFirst(1);
            list.AddLast(2);
            Assert.Equal(list.Find(2), list.Head.Prev);
        }
Пример #4
0
        public void LastItemNextIsHead()
        {
            var list = new CircularlyLinkedList <int>();

            list.AddFirst(1);
            list.AddLast(2);
            list.AddAfter(list.Find(2), 3);
            Assert.Equal(1, list.Tail.Next.Value);
            //Assert.Equal(3, list.Head.Prev.Value);
        }
Пример #5
0
        public void RemovingValueSetsPreviousValuesNextToTheRemovedValuesNext()
        {
            var list = new CircularlyLinkedList <int>();

            list.AddFirst(1);
            list.AddLast(3);
            list.AddLast(5);
            list.AddLast(7);
            list.Remove(5);
            Assert.Equal(7, list.Find(3).Next.Value);
        }