Пример #1
0
        /// <summary>
        /// Add new given integer value to the front of the linked list
        /// </summary>
        /// <param name="value">Value to Add</param>
        public void PushFront(int value)
        {
            var insertNode = new IntNode {
                Value = value
            };

            if (_head != null)
            {
                insertNode.Next = _head;
            }

            _head = &insertNode;

            if (_tail == null)
            {
                _tail = &insertNode;
            }

            return;
        }
Пример #2
0
        /// <summary>
        /// Add new integer value to the end of the linked list
        /// </summary>
        /// <param name="value">Value to add</param>
        public void PushBack(int value)
        {
            var insertValue = new IntNode {
                Value = value
            };

            if (_head == null)
            {
                _head = &insertValue;
                _tail = &insertValue;
                return;
            }

            if (_head == _tail)
            {
                _head->Next = &insertValue;
                _tail       = &insertValue;
                return;
            }

            _tail->Next = &insertValue;
            _tail       = &insertValue;
            return;
        }