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); }
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; } }
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; }
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); }
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); } }
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; } }
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--; }
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; } }
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; } }
internal void Invalidate() { this.next = null; this.prev = null; }
public void AddAfter(NCLinkedListNode <T> node, NCLinkedListNode <T> newNode) { this.ValidateNode(node); this.ValidateNewNode(newNode); this.InternalInsertNodeBefore(node.Next, newNode); }
void IEnumerator.Reset() { this.current = default(T); this.node = this.list.head; this.index = 0; }