コード例 #1
0
 public void RemoveFromListWithOnlyHead()
 {
     linkedList = new LinkedListAdt <int>();
     linkedList.AddToStart(1);
     startCount = linkedList.Count;
     linkedList.RemoveFromEnd();
 }
コード例 #2
0
            public void ShouldNotBeEmptyWithValues()
            {
                var linkedList = new LinkedListAdt <int>();

                linkedList.AddToStart(1);
                linkedList.Empty().Should().BeFalse();
            }
コード例 #3
0
                public void ShouldReturnException()
                {
                    var    linkedList = new LinkedListAdt <int>();
                    Action act        = () => linkedList.RemoveFromEnd();

                    act.Should().Throw <InvalidOperationException>();
                }
コード例 #4
0
            public void ClearLinkedList()
            {
                linkedList = new LinkedListAdt <int>();
                linkedList.AddToStart(2);
                linkedList.AddToEnd(1);
                linkedList.AddToEnd(3);

                linkedList.Clear();
            }
コード例 #5
0
                public void AddWithValuesAndTail()
                {
                    linkedList = new LinkedListAdt <int>();
                    linkedList.AddToStart(1);
                    linkedList.AddToEnd(oldTailValue);
                    oldTail = linkedList.Tail;

                    linkedList.AddToEnd(addedValue);
                }
コード例 #6
0
            public void SetUp()
            {
                linkedList = new LinkedListAdt <int>();
                linkedList.AddToStart(1);
                linkedList.AddToEnd(2);
                linkedList.AddToEnd(3);

                linkedList.Reverse();
            }
コード例 #7
0
            public void ShouldReturnNull()
            {
                var linkedList = new LinkedListAdt <int>();

                linkedList.AddToStart(1);
                linkedList.AddToStart(2);
                linkedList.AddToStart(3);

                linkedList.SearchValue(100).Should().BeNull();
            }
コード例 #8
0
                public void RemoveFromListWithHeadAndTail()
                {
                    linkedList = new LinkedListAdt <int>();
                    linkedList.AddToStart(1);
                    linkedList.AddToEnd(tailValue);
                    startCount = linkedList.Count;
                    oldTail    = linkedList.Tail;

                    linkedList.RemoveFromStart();
                }
コード例 #9
0
            public void RemoveFromMiddle()
            {
                linkedList = new LinkedListAdt <int>();
                linkedList.AddToStart(1);
                linkedList.AddToEnd(2);
                linkedList.AddToEnd(3);

                startCount  = linkedList.Count;
                removedNode = linkedList.Head.Next;

                linkedList.Remove(removedNode);
            }
コード例 #10
0
            public void EnumerateLinkedList()
            {
                resultList = new List <int>();
                valueList  = new List <int>();
                valueList.AddRange(new int[] { 1, 2, 3, 4 });

                var linkedList = new LinkedListAdt <int>();

                foreach (var value in valueList)
                {
                    linkedList.AddToEnd(value);
                }

                foreach (var value in linkedList)
                {
                    resultList.Add(value);
                }
            }
コード例 #11
0
        public static LinkedListAdt <T> Reverse <T>(this LinkedListAdt <T> linkedList)
        {
            var current = linkedList.Head;

            while (current != null)
            {
                var temp = current.Next;

                current.Next     = current.Previous;
                current.Previous = temp;

                if (current == null)
                {
                    linkedList.Head = current;
                }
                current = temp;
            }

            return(null);
        }
コード例 #12
0
 public void AddInList()
 {
     linkedList = new LinkedListAdt <int>();
     linkedList.AddToStart(oldHead);
     linkedList.AddToStart(newHead);
 }
コード例 #13
0
 public void AddWithEmptyList()
 {
     linkedList = new LinkedListAdt <int>();
     linkedList.AddToStart(1);
 }
コード例 #14
0
            public void ShouldStartWithCountZero()
            {
                var linkedList = new LinkedListAdt <int>();

                linkedList.Count.Should().Be(0);
            }
コード例 #15
0
 public void AddToListWithHead()
 {
     linkedList = new LinkedListAdt <int>();
     linkedList.AddToStart(headValue);
     linkedList.AddToEnd(valueAdded);
 }
コード例 #16
0
 public void AddToEndWithoutValues()
 {
     linkedList = new LinkedListAdt <int>();
     linkedList.AddToEnd(valueAdded);
 }