예제 #1
0
        public void TestLinkedListUpperBoundary()
        {
            var linkedList = new LinkedList.LinkedList();

            linkedList.AddLast(20);
            linkedList.AddLast(21);
            linkedList.AddLast(22);

            var actual = linkedList.ElementFromTailAt(3).Value;
        }
예제 #2
0
        public void GetFirstElementFromTail()
        {
            var linkedList = new LinkedList.LinkedList();

            linkedList.AddLast(20);
            linkedList.AddLast(21);
            linkedList.AddLast(22);

            var actual   = linkedList.ElementFromTailAt(0).Value;
            var expected = 22;

            Assert.AreEqual(expected, actual);
        }
예제 #3
0
        public void Enqueue(int val)
        {
            if (_linkedList.Count == 0)
            {
                _linkedList.AddLast(val);
            }
            else
            {
                LinkedListNode current = _linkedList.Head;
                while (current != null && current.Value.CompareTo(val) < 0)
                {
                    current = current.Next;
                }

                if (current == null)
                {
                    _linkedList.AddLast(val);
                }
                else
                {
                    _linkedList.AddBefore(val, current.Value);
                }
            }
        }
예제 #4
0
 public void Enqueue(int val)
 {
     _linkedList.AddLast(val);
 }