Beispiel #1
0
        public virtual LinkedList Clone(bool attemptDeepCopy)
        {
            LinkedList listClone;

            if (attemptDeepCopy)
            {
                listClone = new LinkedList();

                object currentObject;

                for (Node node = headerNode.NextNode; node != headerNode; node = node.NextNode)
                {
                    currentObject = node.CurrentNode;

                    if (currentObject == null)
                        listClone.Add(null);
                    else if (currentObject is ICloneable)
                        listClone.Add(((ICloneable)currentObject).Clone());
                    else
                        throw new SystemException("The object of type [" + currentObject.GetType() +
                            "] in the list is not an ICloneable, cannot attempt a deep copy.");
                }
            }
            else
                listClone = (LinkedList)this.Clone();

            return listClone;
        }
Beispiel #2
0
 public LinkedListEnumerator(LinkedList linkedList)
 {
     this.linkedList = linkedList;
     validModificationCount = linkedList.modifications;
     currentNode = linkedList.headerNode;
 }
Beispiel #3
0
        public virtual object Clone()
        {
            LinkedList listClone = new LinkedList();

            for (Node node = headerNode.NextNode; node != headerNode; node = node.NextNode)
                listClone.Add(node.CurrentNode);

            return listClone;
        }