示例#1
0
        public NCLinkedListNode <T> AddFirst(T value)
        {
            NCLinkedListNode <T> newNode = new NCLinkedListNode <T>(value);

            if (this.head == null)
            {
                this.InternalInsertNodeToEmptyList(newNode);
                return(newNode);
            }
            this.InternalInsertNodeBefore(this.head, newNode);
            this.head = newNode;
            return(newNode);
        }
示例#2
0
 public void AddFirst(NCLinkedListNode <T> node)
 {
     this.ValidateNewNode(node);
     if (this.head == null)
     {
         this.InternalInsertNodeToEmptyList(node);
     }
     else
     {
         this.InternalInsertNodeBefore(this.head, node);
         this.head = node;
     }
 }
示例#3
0
        public void Clear()
        {
            NCLinkedListNode <T> head = this.head;

            while (head != null)
            {
                NCLinkedListNode <T> node2 = head;
                head = head.Next;
                node2.Invalidate();
            }
            this.head  = null;
            this.count = 0;
        }
示例#4
0
 public bool MoveNext()
 {
     if (this.node == null)
     {
         this.index = this.list.Count + 1;
         return(false);
     }
     this.index++;
     this.current = this.node.item;
     this.node    = this.node.next;
     if (this.node == this.list.head)
     {
         this.node = null;
     }
     return(true);
 }
示例#5
0
        public void AddRangeInList(System.Collections.ICollection keys)
        {
            if (keys == null)
            {
                throw new ArgumentNullException("keys cannot be null.");
            }
            IEnumerator          _enum = keys.GetEnumerator();
            object               obj;
            NCLinkedListNode <T> node;

            while (_enum.MoveNext())
            {
                node = new NCLinkedListNode <T>((T)_enum.Current);
                this.AddLast(node);
            }
        }
示例#6
0
        public void AppendLinkedList(NCLinkedList <T> secondList)
        {
            if (this.head == null)
            {
                this.head  = secondList.head;
                this.count = this.count + secondList.count;
            }
            else
            {
                secondList.head.prev.next = this.head;
                this.head.prev.next       = secondList.head;

                this.head.prev = secondList.head.prev;
                this.count     = this.count + secondList.count;
            }
        }
示例#7
0
 internal void InternalRemoveNode(NCLinkedListNode <T> node)
 {
     if (node.next == node)
     {
         this.head = null;
     }
     else
     {
         node.next.prev = node.prev;
         node.prev.next = node.next;
         if (this.head == node)
         {
             this.head = node.next;
         }
     }
     node.Invalidate();
     this.count--;
 }
示例#8
0
 void IDeserializationCallback.OnDeserialization(object sender)
 {
     if (this.list == null)
     {
         if (this.siInfo == null)
         {
             throw new SerializationException("Serialization invalid on deserialize");
         }
         this.list    = (NCLinkedList <T>) this.siInfo.GetValue("LinkedList", typeof(NCLinkedList <T>));
         this.current = (T)this.siInfo.GetValue("Current", typeof(T));
         this.index   = this.siInfo.GetInt32("Index");
         if (this.list.siInfo != null)
         {
             this.list.OnDeserialization(sender);
         }
         if (this.index == (this.list.Count + 1))
         {
             this.node = null;
         }
         else
         {
             this.node = this.list.First;
             if ((this.node != null) && (this.index != 0))
             {
                 for (int i = 0; i < this.index; i++)
                 {
                     this.node = this.node.next;
                 }
                 if (this.node == this.list.First)
                 {
                     this.node = null;
                 }
             }
         }
         this.siInfo = null;
     }
 }
示例#9
0
 public virtual void OnDeserialization(object sender)
 {
     if (this.siInfo != null)
     {
         int num = this.siInfo.GetInt32("Version");
         if (this.siInfo.GetInt32("Count") != 0)
         {
             T[] localArray = (T[])this.siInfo.GetValue("Data", typeof(T[]));
             if (localArray == null)
             {
                 throw new SerializationException("Missing values");
             }
             for (int i = 0; i < localArray.Length; i++)
             {
                 this.AddLast(localArray[i]);
             }
         }
         else
         {
             this.head = null;
         }
         this.siInfo = null;
     }
 }
示例#10
0
 internal void Invalidate()
 {
     this.next = null;
     this.prev = null;
 }
示例#11
0
 public void AddAfter(NCLinkedListNode <T> node, NCLinkedListNode <T> newNode)
 {
     this.ValidateNode(node);
     this.ValidateNewNode(newNode);
     this.InternalInsertNodeBefore(node.Next, newNode);
 }
示例#12
0
 void IEnumerator.Reset()
 {
     this.current = default(T);
     this.node    = this.list.head;
     this.index   = 0;
 }