using System; using System.Runtime.InteropServices; using System.Runtime.Serialization; namespace System.Collections.Generic { /// Represents a doubly linked list. /// Specifies the element type of the linked list. /// 1 // Token: 0x0200000B RID: 11 [ComVisible(false)] [Serializable] public class LinkedList : IEnumerable, ICollection, IDeserializationCallback, IEnumerable, ICollection, ISerializable { /// Initializes a new instance of the class that is empty. // Token: 0x0600000F RID: 15 RVA: 0x00002188 File Offset: 0x00000388 public LinkedList() { this.syncRoot = new object(); this.first = null; this.count = (this.version = 0U); } /// Initializes a new instance of the class that contains elements copied from the specified and has sufficient capacity to accommodate the number of elements copied. /// The whose elements are copied to the new . /// /// is null. // Token: 0x06000010 RID: 16 RVA: 0x000021C0 File Offset: 0x000003C0 public LinkedList(IEnumerable collection) : this() { foreach (T t in collection) { this.AddLast(t); } } /// Initializes a new instance of the class that is serializable with the specified and . /// A object containing the information required to serialize the . /// A object containing the source and destination of the serialized stream associated with the . // Token: 0x06000011 RID: 17 RVA: 0x00002228 File Offset: 0x00000428 protected LinkedList(SerializationInfo info, StreamingContext context) : this() { this.si = info; this.syncRoot = new object(); } // Token: 0x06000012 RID: 18 RVA: 0x00002244 File Offset: 0x00000444 void ICollection.Add(T value) { this.AddLast(value); } /// Copies the elements of the to an , starting at a particular index. /// The one-dimensional that is the destination of the elements copied from . The must have zero-based indexing. /// The zero-based index in at which copying begins. /// /// is null. /// /// is less than zero. /// /// is multidimensional.-or- does not have zero-based indexing.-or-The number of elements in the source is greater than the available space from to the end of the destination .-or-The type of the source cannot be cast automatically to the type of the destination . // Token: 0x06000013 RID: 19 RVA: 0x00002250 File Offset: 0x00000450 void ICollection.CopyTo(Array array, int index) { T[] array2 = array as T[]; if (array2 == null) { throw new ArgumentException("array"); } this.CopyTo(array2, index); } // Token: 0x06000014 RID: 20 RVA: 0x00002280 File Offset: 0x00000480 IEnumerator IEnumerable.GetEnumerator() { return this.GetEnumerator(); } /// Returns an enumerator that iterates through the linked list as a collection. /// An that can be used to iterate through the linked list as a collection. // Token: 0x06000015 RID: 21 RVA: 0x00002290 File Offset: 0x00000490 IEnumerator IEnumerable.GetEnumerator() { return this.GetEnumerator(); } // Token: 0x17000004 RID: 4 // (get) Token: 0x06000016 RID: 22 RVA: 0x000022A0 File Offset: 0x000004A0 bool ICollection.IsReadOnly { get { return false; } } /// Gets a value indicating whether access to the is synchronized (thread safe). /// true if access to the is synchronized (thread safe); otherwise, false. In the default implementation of , this property always returns false. // Token: 0x17000005 RID: 5 // (get) Token: 0x06000017 RID: 23 RVA: 0x000022A4 File Offset: 0x000004A4 bool ICollection.IsSynchronized { get { return false; } } /// Gets an object that can be used to synchronize access to the . /// An object that can be used to synchronize access to the . In the default implementation of , this property always returns the current instance. // Token: 0x17000006 RID: 6 // (get) Token: 0x06000018 RID: 24 RVA: 0x000022A8 File Offset: 0x000004A8 object ICollection.SyncRoot { get { return this.syncRoot; } } // Token: 0x06000019 RID: 25 RVA: 0x000022B0 File Offset: 0x000004B0 private void VerifyReferencedNode(LinkedListNode node) { if (node == null) { throw new ArgumentNullException("node"); } if (node.List != this) { throw new InvalidOperationException(); } } // Token: 0x0600001A RID: 26 RVA: 0x000022D8 File Offset: 0x000004D8 private static void VerifyBlankNode(LinkedListNode newNode) { if (newNode == null) { throw new ArgumentNullException("newNode"); } if (newNode.List != null) { throw new InvalidOperationException(); } } /// Adds a new node containing the specified value after the specified existing node in the . /// The new containing . /// The after which to insert a new containing . /// The value to add to the . /// /// is null. /// /// is not in the current . // Token: 0x0600001B RID: 27 RVA: 0x00002308 File Offset: 0x00000508 public LinkedListNode AddAfter(LinkedListNode node, T value) { this.VerifyReferencedNode(node); LinkedListNode linkedListNode = new LinkedListNode(this, value, node, node.forward); this.count += 1U; this.version += 1U; return linkedListNode; } /// Adds the specified new node after the specified existing node in the . /// The after which to insert . /// The new to add to the . /// /// is null.-or- is null. /// /// is not in the current .-or- belongs to another . // Token: 0x0600001C RID: 28 RVA: 0x00002348 File Offset: 0x00000548 public void AddAfter(LinkedListNode node, LinkedListNode newNode) { this.VerifyReferencedNode(node); LinkedList.VerifyBlankNode(newNode); newNode.InsertBetween(node, node.forward, this); this.count += 1U; this.version += 1U; } /// Adds a new node containing the specified value before the specified existing node in the . /// The new containing . /// The before which to insert a new containing . /// The value to add to the . /// /// is null. /// /// is not in the current . // Token: 0x0600001D RID: 29 RVA: 0x0000238C File Offset: 0x0000058C public LinkedListNode AddBefore(LinkedListNode node, T value) { this.VerifyReferencedNode(node); LinkedListNode linkedListNode = new LinkedListNode(this, value, node.back, node); this.count += 1U; this.version += 1U; if (node == this.first) { this.first = linkedListNode; } return linkedListNode; } /// Adds the specified new node before the specified existing node in the . /// The before which to insert . /// The new to add to the . /// /// is null.-or- is null. /// /// is not in the current .-or- belongs to another . // Token: 0x0600001E RID: 30 RVA: 0x000023E0 File Offset: 0x000005E0 public void AddBefore(LinkedListNode node, LinkedListNode newNode) { this.VerifyReferencedNode(node); LinkedList.VerifyBlankNode(newNode); newNode.InsertBetween(node.back, node, this); this.count += 1U; this.version += 1U; if (node == this.first) { this.first = newNode; } } /// Adds the specified new node at the start of the . /// The new to add at the start of the . /// /// is null. /// /// belongs to another . // Token: 0x0600001F RID: 31 RVA: 0x00002438 File Offset: 0x00000638 public void AddFirst(LinkedListNode node) { LinkedList.VerifyBlankNode(node); if (this.first == null) { node.SelfReference(this); } else { node.InsertBetween(this.first.back, this.first, this); } this.count += 1U; this.version += 1U; this.first = node; } /// Adds a new node containing the specified value at the start of the . /// The new containing . /// The value to add at the start of the . // Token: 0x06000020 RID: 32 RVA: 0x000024A0 File Offset: 0x000006A0 public LinkedListNode AddFirst(T value) { LinkedListNode linkedListNode; if (this.first == null) { linkedListNode = new LinkedListNode(this, value); } else { linkedListNode = new LinkedListNode(this, value, this.first.back, this.first); } this.count += 1U; this.version += 1U; this.first = linkedListNode; return linkedListNode; } /// Adds a new node containing the specified value at the end of the . /// The new containing . /// The value to add at the end of the . // Token: 0x06000021 RID: 33 RVA: 0x00002504 File Offset: 0x00000704 public LinkedListNode AddLast(T value) { LinkedListNode linkedListNode; if (this.first == null) { linkedListNode = new LinkedListNode(this, value); this.first = linkedListNode; } else { linkedListNode = new LinkedListNode(this, value, this.first.back, this.first); } this.count += 1U; this.version += 1U; return linkedListNode; } /// Adds the specified new node at the end of the . /// The new to add at the end of the . /// /// is null. /// /// belongs to another . // Token: 0x06000022 RID: 34 RVA: 0x00002568 File Offset: 0x00000768 public void AddLast(LinkedListNode node) { LinkedList.VerifyBlankNode(node); if (this.first == null) { node.SelfReference(this); this.first = node; } else { node.InsertBetween(this.first.back, this.first, this); } this.count += 1U; this.version += 1U; } /// Removes all nodes from the . // Token: 0x06000023 RID: 35 RVA: 0x000025D0 File Offset: 0x000007D0 public void Clear() { while (this.first != null) { this.RemoveLast(); } } /// Determines whether a value is in the . /// true if is found in the ; otherwise, false. /// The value to locate in the . The value can be null for reference types. // Token: 0x06000024 RID: 36 RVA: 0x000025E8 File Offset: 0x000007E8 public bool Contains(T value) { LinkedListNode forward = this.first; if (forward == null) { return false; } while (!value.Equals(forward.Value)) { forward = forward.forward; if (forward == this.first) { return false; } } return true; } /// Copies the entire to a compatible one-dimensional , starting at the specified index of the target array. /// The one-dimensional that is the destination of the elements copied from . The must have zero-based indexing. /// The zero-based index in at which copying begins. /// /// is null. /// /// is less than zero. /// The number of elements in the source is greater than the available space from to the end of the destination . // Token: 0x06000025 RID: 37 RVA: 0x00002638 File Offset: 0x00000838 public void CopyTo(T[] array, int index) { if (array == null) { throw new ArgumentNullException("array"); } if (index < array.GetLowerBound(0)) { throw new ArgumentOutOfRangeException("index"); } if (array.Rank != 1) { throw new ArgumentException("array", "Array is multidimensional"); } if ((long)(array.Length - index + array.GetLowerBound(0)) < (long)((ulong)this.count)) { throw new ArgumentException("number of items exceeds capacity"); } LinkedListNode forward = this.first; if (this.first == null) { return; } do { array[index] = forward.Value; index++; forward = forward.forward; } while (forward != this.first); } /// Finds the first node that contains the specified value. /// The first that contains the specified value, if found; otherwise, null. /// The value to locate in the . // Token: 0x06000026 RID: 38 RVA: 0x000026E8 File Offset: 0x000008E8 public LinkedListNode Find(T value) { LinkedListNode forward = this.first; if (forward == null) { return null; } while ((value != null || forward.Value != null) && (value == null || !value.Equals(forward.Value))) { forward = forward.forward; if (forward == this.first) { return null; } } return forward; } /// Finds the last node that contains the specified value. /// The last that contains the specified value, if found; otherwise, null. /// The value to locate in the . // Token: 0x06000027 RID: 39 RVA: 0x00002760 File Offset: 0x00000960 public LinkedListNode FindLast(T value) { LinkedListNode back = this.first; if (back == null) { return null; } for (;;) { back = back.back; if (value.Equals(back.Value)) { break; } if (back == this.first) { goto Block_3; } } return back; Block_3: return null; } /// Returns an enumerator that iterates through the . /// An for the . // Token: 0x06000028 RID: 40 RVA: 0x000027B0 File Offset: 0x000009B0 public LinkedList.Enumerator GetEnumerator() { return new LinkedList.Enumerator(this); } /// Implements the interface and returns the data needed to serialize the instance. /// A object that contains the information required to serialize the instance. /// A object that contains the source and destination of the serialized stream associated with the instance. /// /// is null. // Token: 0x06000029 RID: 41 RVA: 0x000027B8 File Offset: 0x000009B8 public virtual void GetObjectData(SerializationInfo info, StreamingContext context) { T[] array = new T[this.count]; this.CopyTo(array, 0); info.AddValue("DataArray", array, typeof(T[])); info.AddValue("version", this.version); } /// Implements the interface and raises the deserialization event when the deserialization is complete. /// The source of the deserialization event. /// The object associated with the current instance is invalid. // Token: 0x0600002A RID: 42 RVA: 0x00002804 File Offset: 0x00000A04 public virtual void OnDeserialization(object sender) { if (this.si != null) { T[] array = (T[])this.si.GetValue("DataArray", typeof(T[])); if (array != null) { foreach (T t in array) { this.AddLast(t); } } this.version = this.si.GetUInt32("version"); this.si = null; } } /// Removes the first occurrence of the specified value from the . /// true if the element containing is successfully removed; otherwise, false. This method also returns false if was not found in the original . /// The value to remove from the . // Token: 0x0600002B RID: 43 RVA: 0x00002888 File Offset: 0x00000A88 public bool Remove(T value) { LinkedListNode linkedListNode = this.Find(value); if (linkedListNode == null) { return false; } this.Remove(linkedListNode); return true; } /// Removes the specified node from the . /// The to remove from the . /// /// is null. /// /// is not in the current . // Token: 0x0600002C RID: 44 RVA: 0x000028B0 File Offset: 0x00000AB0 public void Remove(LinkedListNode node) { this.VerifyReferencedNode(node); this.count -= 1U; if (this.count == 0U) { this.first = null; } if (node == this.first) { this.first = this.first.forward; } this.version += 1U; node.Detach(); } /// Removes the node at the start of the . /// The is empty. // Token: 0x0600002D RID: 45 RVA: 0x00002918 File Offset: 0x00000B18 public void RemoveFirst() { if (this.first != null) { this.Remove(this.first); } } /// Removes the node at the end of the . /// The is empty. // Token: 0x0600002E RID: 46 RVA: 0x00002934 File Offset: 0x00000B34 public void RemoveLast() { if (this.first != null) { this.Remove(this.first.back); } } /// Gets the number of nodes actually contained in the . /// The number of nodes actually contained in the . // Token: 0x17000007 RID: 7 // (get) Token: 0x0600002F RID: 47 RVA: 0x00002954 File Offset: 0x00000B54 public int Count { get { return (int)this.count; } } /// Gets the first node of the . /// The first of the . // Token: 0x17000008 RID: 8 // (get) Token: 0x06000030 RID: 48 RVA: 0x0000295C File Offset: 0x00000B5C public LinkedListNode First { get { return this.first; } } /// Gets the last node of the . /// The last of the . // Token: 0x17000009 RID: 9 // (get) Token: 0x06000031 RID: 49 RVA: 0x00002964 File Offset: 0x00000B64 public LinkedListNode Last { get { return (this.first == null) ? null : this.first.back; } } // Token: 0x04000021 RID: 33 private const string DataArrayKey = "DataArray"; // Token: 0x04000022 RID: 34 private const string VersionKey = "version"; // Token: 0x04000023 RID: 35 private uint count; // Token: 0x04000024 RID: 36 private uint version; // Token: 0x04000025 RID: 37 private object syncRoot; // Token: 0x04000026 RID: 38 internal LinkedListNode first; // Token: 0x04000027 RID: 39 internal SerializationInfo si; /// Enumerates the elements of a . // Token: 0x0200000C RID: 12 [Serializable] public struct Enumerator : IEnumerator, IEnumerator, IDisposable { // Token: 0x06000032 RID: 50 RVA: 0x00002984 File Offset: 0x00000B84 internal Enumerator(LinkedList parent) { this.list = parent; this.current = null; this.index = -1; this.version = parent.version; } /// Gets the element at the current position of the enumerator. /// The element in the collection at the current position of the enumerator. /// The enumerator is positioned before the first element of the collection or after the last element. // Token: 0x1700000A RID: 10 // (get) Token: 0x06000033 RID: 51 RVA: 0x000029A8 File Offset: 0x00000BA8 object IEnumerator.Current { get { return this.Current; } } /// Sets the enumerator to its initial position, which is before the first element in the collection. This class cannot be inherited. /// The collection was modified after the enumerator was created. // Token: 0x06000034 RID: 52 RVA: 0x000029B8 File Offset: 0x00000BB8 void IEnumerator.Reset() { if (this.list == null) { throw new ObjectDisposedException(null); } if (this.version != this.list.version) { throw new InvalidOperationException("list modified"); } this.current = null; this.index = -1; } /// Gets the element at the current position of the enumerator. /// The element in the at the current position of the enumerator. // Token: 0x1700000B RID: 11 // (get) Token: 0x06000035 RID: 53 RVA: 0x00002A08 File Offset: 0x00000C08 public T Current { get { if (this.list == null) { throw new ObjectDisposedException(null); } if (this.current == null) { throw new InvalidOperationException(); } return this.current.Value; } } /// Advances the enumerator to the next element of the . /// true if the enumerator was successfully advanced to the next element; false if the enumerator has passed the end of the collection. /// The collection was modified after the enumerator was created. // Token: 0x06000036 RID: 54 RVA: 0x00002A44 File Offset: 0x00000C44 public bool MoveNext() { if (this.list == null) { throw new ObjectDisposedException(null); } if (this.version != this.list.version) { throw new InvalidOperationException("list modified"); } if (this.current == null) { this.current = this.list.first; } else { this.current = this.current.forward; if (this.current == this.list.first) { this.current = null; } } if (this.current == null) { this.index = -1; return false; } this.index++; return true; } /// Releases all resources used by the . // Token: 0x06000037 RID: 55 RVA: 0x00002AF8 File Offset: 0x00000CF8 public void Dispose() { if (this.list == null) { throw new ObjectDisposedException(null); } this.current = null; this.list = null; } // Token: 0x04000028 RID: 40 private const string VersionKey = "version"; // Token: 0x04000029 RID: 41 private const string IndexKey = "index"; // Token: 0x0400002A RID: 42 private const string ListKey = "list"; // Token: 0x0400002B RID: 43 private LinkedList list; // Token: 0x0400002C RID: 44 private LinkedListNode current; // Token: 0x0400002D RID: 45 private int index; // Token: 0x0400002E RID: 46 private uint version; } } }