コード例 #1
0
ファイル: Queue.cs プロジェクト: mangzee/Towel
 internal QueueLinked(QueueLinked <T> queue)
 {
     if (queue._head is not null)
     {
         _head = new Node(value: queue._head.Value);
         Node?a = queue._head.Next;
         Node?b = _head;
         while (a is not null)
         {
             b.Next = new Node(value: a.Value);
             b      = b.Next;
             a      = a.Next;
         }
         _tail  = b;
         _count = queue._count;
     }
 }
コード例 #2
0
ファイル: Queue.cs プロジェクト: GSKSan/Towel
        /// <summary>Creates a shallow clone of this data structure.</summary>
        /// <returns>A shallow clone of this data structure.</returns>
        public QueueLinked <T> Clone()
        {
            Node head          = new Node(this._head.Value);
            Node current       = this._head.Next;
            Node current_clone = head;

            while (current != null)
            {
                current_clone.Next = new Node(current.Value);
                current_clone      = current_clone.Next;
                current            = current.Next;
            }
            QueueLinked <T> clone = new QueueLinked <T>
            {
                _head  = head,
                _tail  = current_clone,
                _count = this._count
            };

            return(clone);
        }