Example #1
0
        /// <summary>
        /// Time complexity: O(1).
        /// </summary>
        public void Union(CircularLinkedList <T> newList)
        {
            ReferenceNode.Previous.Next = newList.ReferenceNode;
            ReferenceNode.Previous      = newList.ReferenceNode.Previous;

            newList.ReferenceNode.Previous.Next = ReferenceNode;
            newList.ReferenceNode.Previous      = ReferenceNode.Previous;
        }
Example #2
0
        /// <summary>
        /// O(1) time complexity
        /// </summary>
        /// <param name="newList"></param>
        internal void Union(CircularLinkedList <T> newList)
        {
            ReferenceNode.Prev.Next = newList.ReferenceNode;
            ReferenceNode.Prev      = newList.ReferenceNode.Prev;

            newList.ReferenceNode.Prev.Next = ReferenceNode;
            newList.ReferenceNode.Prev      = ReferenceNode.Prev;
        }