/// <summary> /// Returns an enumerator that iterates through the collection. /// </summary> /// <returns> /// A <see cref="T:System.Collections.Generic.IEnumerator`1"/> that can be used to iterate through the collection. /// </returns> /// <filterpriority>1</filterpriority> public IEnumerator <IJob <TKey> > GetEnumerator() { IEnumerator <IJob <TKey> > e1 = WorkQueue1.GetEnumerator(); IEnumerator <IJob <TKey> > e2 = WorkQueue1.GetEnumerator(); return(new PuzzleEnumerator <TKey>(WorkQueue1, WorkQueue2)); }
/// <summary> /// Determines whether the <see cref="T:System.Collections.Generic.ICollection`1"/> contains a specific value. /// </summary> /// <returns> /// true if <paramref name="item"/> is found in the <see cref="T:System.Collections.Generic.ICollection`1"/>; otherwise, false. /// </returns> /// <param name="item">The object to locate in the <see cref="T:System.Collections.Generic.ICollection`1"/>.</param> public bool Contains(IJob <TKey> job) { if (!WorkQueue1.Contains(job)) { if (!WorkQueue2.Contains(job)) { return(false); } } return(true); }
public void Add(IJob <TKey> job) { if (job.Priority == 1) { WorkQueue1.Enqueue(job); } else { WorkQueue2.Enqueue(job); } }
public IJob <TKey> Peek() { if (WorkQueue1.Count > 0) { return(WorkQueue1.Peek()); } else if (WorkQueue2.Count > 0) { return(WorkQueue2.Peek()); } return(null); }
public void RunActionCount(int actionCount) { int actionsProcessed = 0; bool continueProcessing = WorkQueue1.Count > 0; while (continueProcessing) { IJob <TKey> action = WorkQueue1.Dequeue(); ProcessAction(action); continueProcessing = WorkQueue1.Count > 0 || actionsProcessed == actionCount; } }
private void SolveUI() { while (Count > 0) { while (WorkQueue1.Count > 0) { IJob <TKey> jobCurrent = WorkQueue1.Dequeue(); ProcessAction(jobCurrent); } while (WorkQueue2.Count > 0) { IJob <TKey> jobCurrent = WorkQueue2.Dequeue(); ProcessAction(jobCurrent); } } }
public Keys <TKey> DoNextJob() { IJob <TKey> nextJob = null; Keys <TKey> keysChanged = new Keys <TKey>(); if (WorkQueue1.Count > 0) { nextJob = WorkQueue1.Dequeue(); } else if (WorkQueue2.Count > 0) { nextJob = WorkQueue2.Dequeue(); } if (nextJob != null) { keysChanged.UnionWith(nextJob.Process(this)); } return(keysChanged); }
/// <summary> /// Copies the elements of the <see cref="T:System.Collections.Generic.ICollection`1"/> to an <see cref="T:System.Array"/>, starting at a particular <see cref="T:System.Array"/> index. /// </summary> /// <param name="array">The one-dimensional <see cref="T:System.Array"/> that is the destination of the elements copied from <see cref="T:System.Collections.Generic.ICollection`1"/>. The <see cref="T:System.Array"/> must have zero-based indexing.</param><param name="arrayIndex">The zero-based index in <paramref name="array"/> at which copying begins.</param><exception cref="T:System.ArgumentNullException"><paramref name="array"/> is null.</exception><exception cref="T:System.ArgumentOutOfRangeException"><paramref name="arrayIndex"/> is less than 0.</exception><exception cref="T:System.ArgumentException"><paramref name="array"/> is multidimensional.-or-<paramref name="arrayIndex"/> is equal to or greater than the length of <paramref name="array"/>.-or-The number of elements in the source <see cref="T:System.Collections.Generic.ICollection`1"/> is greater than the available space from <paramref name="arrayIndex"/> to the end of the destination <paramref name="array"/>.-or-Type <paramref name="T"/> cannot be cast automatically to the type of the destination <paramref name="array"/>.</exception> public void CopyTo(IJob <TKey>[] array, int arrayIndex) { WorkQueue1.CopyTo(array, arrayIndex); WorkQueue2.CopyTo(array, arrayIndex + array.GetLength(0)); }
/// <summary> /// Removes all items from the <see cref="T:System.Collections.Generic.ICollection`1"/>. /// </summary> /// <exception cref="T:System.NotSupportedException">The <see cref="T:System.Collections.Generic.ICollection`1"/> is read-only. </exception> public void Clear() { WorkQueue1.Clear(); WorkQueue2.Clear(); }