using System; using System.Diagnostics; using System.Runtime.InteropServices; namespace System.Collections { /// Represents a first-in, first-out collection of objects. /// 1 // Token: 0x02000137 RID: 311 [DebuggerDisplay("Count={Count}")] [ComVisible(true)] [DebuggerTypeProxy(typeof(CollectionDebuggerView))] [Serializable] public class Queue : IEnumerable, ICloneable, ICollection { /// Initializes a new instance of the class that is empty, has the default initial capacity, and uses the default growth factor. // Token: 0x06000FF1 RID: 4081 RVA: 0x00042160 File Offset: 0x00040360 public Queue() : this(32, 2f) { } /// Initializes a new instance of the class that is empty, has the specified initial capacity, and uses the default growth factor. /// The initial number of elements that the can contain. /// /// is less than zero. // Token: 0x06000FF2 RID: 4082 RVA: 0x00042170 File Offset: 0x00040370 public Queue(int capacity) : this(capacity, 2f) { } /// Initializes a new instance of the class that contains elements copied from the specified collection, has the same initial capacity as the number of elements copied, and uses the default growth factor. /// The to copy elements from. /// /// is null. // Token: 0x06000FF3 RID: 4083 RVA: 0x00042180 File Offset: 0x00040380 public Queue(ICollection col) : this((col != null) ? col.Count : 32) { if (col == null) { throw new ArgumentNullException("col"); } foreach (object obj in col) { this.Enqueue(obj); } } /// Initializes a new instance of the class that is empty, has the specified initial capacity, and uses the specified growth factor. /// The initial number of elements that the can contain. /// The factor by which the capacity of the is expanded. /// /// is less than zero.-or- is less than 1.0 or greater than 10.0. // Token: 0x06000FF4 RID: 4084 RVA: 0x00042210 File Offset: 0x00040410 public Queue(int capacity, float growFactor) { if (capacity < 0) { throw new ArgumentOutOfRangeException("capacity", "Needs a non-negative number"); } if (growFactor < 1f || growFactor > 10f) { throw new ArgumentOutOfRangeException("growFactor", "Queue growth factor must be between 1.0 and 10.0, inclusive"); } this._array = new object[capacity]; this._growFactor = (int)(growFactor * 100f); } /// Gets the number of elements contained in the . /// The number of elements contained in the . /// 2 // Token: 0x17000295 RID: 661 // (get) Token: 0x06000FF5 RID: 4085 RVA: 0x0004227C File Offset: 0x0004047C public virtual int Count { get { return this._size; } } /// Gets a value indicating whether access to the is synchronized (thread safe). /// true if access to the is synchronized (thread safe); otherwise, false. The default is false. /// 2 // Token: 0x17000296 RID: 662 // (get) Token: 0x06000FF6 RID: 4086 RVA: 0x00042284 File Offset: 0x00040484 public virtual bool 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 . /// 2 // Token: 0x17000297 RID: 663 // (get) Token: 0x06000FF7 RID: 4087 RVA: 0x00042288 File Offset: 0x00040488 public virtual object SyncRoot { get { return this; } } /// Copies the elements to an existing one-dimensional , starting at the specified array 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- The number of elements in the source is greater than the available space from to the end of the destination . /// The type of the source cannot be cast automatically to the type of the destination . /// 2 // Token: 0x06000FF8 RID: 4088 RVA: 0x0004228C File Offset: 0x0004048C public virtual void CopyTo(Array array, int index) { if (array == null) { throw new ArgumentNullException("array"); } if (index < 0) { throw new ArgumentOutOfRangeException("index"); } if (array.Rank > 1 || (index != 0 && index >= array.Length) || this._size > array.Length - index) { throw new ArgumentException(); } int num = this._array.Length; int num2 = num - this._head; Array.Copy(this._array, this._head, array, index, Math.Min(this._size, num2)); if (this._size > num2) { Array.Copy(this._array, 0, array, index + num2, this._size - num2); } } /// Returns an enumerator that iterates through the . /// An for the . /// 2 // Token: 0x06000FF9 RID: 4089 RVA: 0x00042348 File Offset: 0x00040548 public virtual IEnumerator GetEnumerator() { return new Queue.QueueEnumerator(this); } /// Creates a shallow copy of the . /// A shallow copy of the . /// 2 // Token: 0x06000FFA RID: 4090 RVA: 0x00042350 File Offset: 0x00040550 public virtual object Clone() { Queue queue = new Queue(this._array.Length); queue._growFactor = this._growFactor; Array.Copy(this._array, 0, queue._array, 0, this._array.Length); queue._head = this._head; queue._size = this._size; queue._tail = this._tail; return queue; } /// Removes all objects from the . /// 2 // Token: 0x06000FFB RID: 4091 RVA: 0x000423B8 File Offset: 0x000405B8 public virtual void Clear() { this._version++; this._head = 0; this._size = 0; this._tail = 0; for (int i = this._array.Length - 1; i >= 0; i--) { this._array[i] = null; } } /// Determines whether an element is in the . /// true if is found in the ; otherwise, false. /// The to locate in the . The value can be null. /// 2 // Token: 0x06000FFC RID: 4092 RVA: 0x0004240C File Offset: 0x0004060C public virtual bool Contains(object obj) { int num = this._head + this._size; if (obj == null) { for (int i = this._head; i < num; i++) { if (this._array[i % this._array.Length] == null) { return true; } } } else { for (int j = this._head; j < num; j++) { if (obj.Equals(this._array[j % this._array.Length])) { return true; } } } return false; } /// Removes and returns the object at the beginning of the . /// The object that is removed from the beginning of the . /// The is empty. /// 2 // Token: 0x06000FFD RID: 4093 RVA: 0x00042498 File Offset: 0x00040698 public virtual object Dequeue() { this._version++; if (this._size < 1) { throw new InvalidOperationException(); } object obj = this._array[this._head]; this._array[this._head] = null; this._head = (this._head + 1) % this._array.Length; this._size--; return obj; } /// Adds an object to the end of the . /// The object to add to the . The value can be null. /// 2 // Token: 0x06000FFE RID: 4094 RVA: 0x00042508 File Offset: 0x00040708 public virtual void Enqueue(object obj) { this._version++; if (this._size == this._array.Length) { this.grow(); } this._array[this._tail] = obj; this._tail = (this._tail + 1) % this._array.Length; this._size++; } /// Returns the object at the beginning of the without removing it. /// The object at the beginning of the . /// The is empty. /// 2 // Token: 0x06000FFF RID: 4095 RVA: 0x00042570 File Offset: 0x00040770 public virtual object Peek() { if (this._size < 1) { throw new InvalidOperationException(); } return this._array[this._head]; } /// Returns a wrapper that is synchronized (thread safe). /// A wrapper that is synchronized (thread safe). /// The to synchronize. /// /// is null. /// 2 // Token: 0x06001000 RID: 4096 RVA: 0x00042594 File Offset: 0x00040794 public static Queue Synchronized(Queue queue) { if (queue == null) { throw new ArgumentNullException("queue"); } return new Queue.SyncQueue(queue); } /// Copies the elements to a new array. /// A new array containing elements copied from the . /// 2 // Token: 0x06001001 RID: 4097 RVA: 0x000425B0 File Offset: 0x000407B0 public virtual object[] ToArray() { object[] array = new object[this._size]; this.CopyTo(array, 0); return array; } /// Sets the capacity to the actual number of elements in the . /// The is read-only. /// 2 // Token: 0x06001002 RID: 4098 RVA: 0x000425D4 File Offset: 0x000407D4 public virtual void TrimToSize() { this._version++; object[] array = new object[this._size]; this.CopyTo(array, 0); this._array = array; this._head = 0; this._tail = 0; } // Token: 0x06001003 RID: 4099 RVA: 0x00042618 File Offset: 0x00040818 private void grow() { int num = this._array.Length * this._growFactor / 100; if (num < this._array.Length + 1) { num = this._array.Length + 1; } object[] array = new object[num]; this.CopyTo(array, 0); this._array = array; this._head = 0; this._tail = this._head + this._size; } // Token: 0x040003DF RID: 991 private object[] _array; // Token: 0x040003E0 RID: 992 private int _head; // Token: 0x040003E1 RID: 993 private int _size; // Token: 0x040003E2 RID: 994 private int _tail; // Token: 0x040003E3 RID: 995 private int _growFactor; // Token: 0x040003E4 RID: 996 private int _version; // Token: 0x02000138 RID: 312 private class SyncQueue : Queue { // Token: 0x06001004 RID: 4100 RVA: 0x00042684 File Offset: 0x00040884 internal SyncQueue(Queue queue) { this.queue = queue; } // Token: 0x17000298 RID: 664 // (get) Token: 0x06001005 RID: 4101 RVA: 0x00042694 File Offset: 0x00040894 public override int Count { get { Queue queue = this.queue; int count; lock (queue) { count = this.queue.Count; } return count; } } // Token: 0x17000299 RID: 665 // (get) Token: 0x06001006 RID: 4102 RVA: 0x000426E8 File Offset: 0x000408E8 public override bool IsSynchronized { get { return true; } } // Token: 0x1700029A RID: 666 // (get) Token: 0x06001007 RID: 4103 RVA: 0x000426EC File Offset: 0x000408EC public override object SyncRoot { get { return this.queue.SyncRoot; } } // Token: 0x06001008 RID: 4104 RVA: 0x000426FC File Offset: 0x000408FC public override void CopyTo(Array array, int index) { Queue queue = this.queue; lock (queue) { this.queue.CopyTo(array, index); } } // Token: 0x06001009 RID: 4105 RVA: 0x0004274C File Offset: 0x0004094C public override IEnumerator GetEnumerator() { Queue queue = this.queue; IEnumerator enumerator; lock (queue) { enumerator = this.queue.GetEnumerator(); } return enumerator; } // Token: 0x0600100A RID: 4106 RVA: 0x000427A0 File Offset: 0x000409A0 public override object Clone() { Queue queue = this.queue; object obj; lock (queue) { obj = new Queue.SyncQueue((Queue)this.queue.Clone()); } return obj; } // Token: 0x0600100B RID: 4107 RVA: 0x00042800 File Offset: 0x00040A00 public override void Clear() { Queue queue = this.queue; lock (queue) { this.queue.Clear(); } } // Token: 0x0600100C RID: 4108 RVA: 0x00042850 File Offset: 0x00040A50 public override void TrimToSize() { Queue queue = this.queue; lock (queue) { this.queue.TrimToSize(); } } // Token: 0x0600100D RID: 4109 RVA: 0x000428A0 File Offset: 0x00040AA0 public override bool Contains(object obj) { Queue queue = this.queue; bool flag; lock (queue) { flag = this.queue.Contains(obj); } return flag; } // Token: 0x0600100E RID: 4110 RVA: 0x000428F8 File Offset: 0x00040AF8 public override object Dequeue() { Queue queue = this.queue; object obj; lock (queue) { obj = this.queue.Dequeue(); } return obj; } // Token: 0x0600100F RID: 4111 RVA: 0x0004294C File Offset: 0x00040B4C public override void Enqueue(object obj) { Queue queue = this.queue; lock (queue) { this.queue.Enqueue(obj); } } // Token: 0x06001010 RID: 4112 RVA: 0x0004299C File Offset: 0x00040B9C public override object Peek() { Queue queue = this.queue; object obj; lock (queue) { obj = this.queue.Peek(); } return obj; } // Token: 0x06001011 RID: 4113 RVA: 0x000429F0 File Offset: 0x00040BF0 public override object[] ToArray() { Queue queue = this.queue; object[] array; lock (queue) { array = this.queue.ToArray(); } return array; } // Token: 0x040003E5 RID: 997 private Queue queue; } // Token: 0x02000139 RID: 313 [Serializable] private class QueueEnumerator : IEnumerator, ICloneable { // Token: 0x06001012 RID: 4114 RVA: 0x00042A44 File Offset: 0x00040C44 internal QueueEnumerator(Queue q) { this.queue = q; this._version = q._version; this.current = -1; } // Token: 0x06001013 RID: 4115 RVA: 0x00042A74 File Offset: 0x00040C74 public object Clone() { return new Queue.QueueEnumerator(this.queue) { _version = this._version, current = this.current }; } // Token: 0x1700029B RID: 667 // (get) Token: 0x06001014 RID: 4116 RVA: 0x00042AA8 File Offset: 0x00040CA8 public virtual object Current { get { if (this._version != this.queue._version || this.current < 0 || this.current >= this.queue._size) { throw new InvalidOperationException(); } return this.queue._array[(this.queue._head + this.current) % this.queue._array.Length]; } } // Token: 0x06001015 RID: 4117 RVA: 0x00042B20 File Offset: 0x00040D20 public virtual bool MoveNext() { if (this._version != this.queue._version) { throw new InvalidOperationException(); } if (this.current >= this.queue._size - 1) { this.current = int.MaxValue; return false; } this.current++; return true; } // Token: 0x06001016 RID: 4118 RVA: 0x00042B80 File Offset: 0x00040D80 public virtual void Reset() { if (this._version != this.queue._version) { throw new InvalidOperationException(); } this.current = -1; } // Token: 0x040003E6 RID: 998 private Queue queue; // Token: 0x040003E7 RID: 999 private int _version; // Token: 0x040003E8 RID: 1000 private int current; } } }