public static void IEnumerable_Testing <TQueue>() where TQueue : IQueue <int>, new() { { // enqueue only int[] values = { 0, 1, 2, 3, 4, 5, }; IQueue <int> queue = new TQueue(); values.Stepper(i => queue.Enqueue(i)); #pragma warning disable CA1829 // Use Length/Count property instead of Count() when available Assert.IsTrue(System.Linq.Enumerable.Count(queue) == values.Length); #pragma warning restore CA1829 // Use Length/Count property instead of Count() when available ISet <int> set = SetHashLinked.New <int>(); values.Stepper(i => set.Add(i)); foreach (int i in queue) { Assert.IsTrue(set.Contains(i)); set.Remove(i); } Assert.IsTrue(set.Count == 0); } { // enqueue + dequeue int[] values = { 0, 1, 2, 3, 4, 5, }; int[] expectedValues = { 2, 3, 4, 5, }; IQueue <int> queue = new TQueue(); values.Stepper(i => queue.Enqueue(i)); queue.Dequeue(); queue.Dequeue(); #pragma warning disable CA1829 // Use Length/Count property instead of Count() when available Assert.IsTrue(System.Linq.Enumerable.Count(queue) == expectedValues.Length); #pragma warning restore CA1829 // Use Length/Count property instead of Count() when available ISet <int> set = SetHashLinked.New <int>(); expectedValues.Stepper(i => set.Add(i)); foreach (int i in queue) { Assert.IsTrue(set.Contains(i)); set.Remove(i); } Assert.IsTrue(set.Count == 0); } { // enqueue + dequeue int[] values = { 0, 1, 2, 3, 4, 5, }; IQueue <int> queue = new TQueue(); values.Stepper(i => queue.Enqueue(i)); values.Stepper(i => { queue.Dequeue(); queue.Enqueue(i); }); #pragma warning disable CA1829 // Use Length/Count property instead of Count() when available Assert.IsTrue(System.Linq.Enumerable.Count(queue) == values.Length); #pragma warning restore CA1829 // Use Length/Count property instead of Count() when available ISet <int> set = SetHashLinked.New <int>(); values.Stepper(i => set.Add(i)); foreach (int i in queue) { Assert.IsTrue(set.Contains(i)); set.Remove(i); } Assert.IsTrue(set.Count == 0); } }
public static void Stepper_Testing <TQueue>() where TQueue : IQueue <int>, new() { { // enqueue only int[] values = { 0, 1, 2, 3, 4, 5, }; IQueue <int> queue = new TQueue(); values.Stepper(i => queue.Enqueue(i)); Assert.IsTrue(queue.Count == values.Length); ISet <int> set = SetHashLinked.New <int>(); values.Stepper(i => set.Add(i)); queue.Stepper(i => { Assert.IsTrue(set.Contains(i)); set.Remove(i); }); Assert.IsTrue(set.Count == 0); } { // enqueue + dequeue int[] values = { 0, 1, 2, 3, 4, 5, }; int[] expectedValues = { 2, 3, 4, 5, }; IQueue <int> queue = new TQueue(); values.Stepper(i => queue.Enqueue(i)); queue.Dequeue(); queue.Dequeue(); Assert.IsTrue(queue.Count == expectedValues.Length); ISet <int> set = SetHashLinked.New <int>(); expectedValues.Stepper(i => set.Add(i)); queue.Stepper(i => { Assert.IsTrue(set.Contains(i)); set.Remove(i); }); Assert.IsTrue(set.Count == 0); } { // enqueue + dequeue int[] values = { 0, 1, 2, 3, 4, 5, }; IQueue <int> queue = new TQueue(); values.Stepper(i => queue.Enqueue(i)); values.Stepper(i => { queue.Dequeue(); queue.Enqueue(i); }); Assert.IsTrue(queue.Count == values.Length); ISet <int> set = SetHashLinked.New <int>(); values.Stepper(i => set.Add(i)); queue.Stepper(i => { Assert.IsTrue(set.Contains(i)); set.Remove(i); }); Assert.IsTrue(set.Count == 0); } }
public void EnqueueDequeueForeachTest1() { queueInt3.Enqueue(3); queueInt3.Enqueue(2); queueInt3.Dequeque(); int i = -1; int[] expected = new[] { 2, 3, 4, 5, 6, 7, 3, 2 }; foreach (var item in queueInt3) { Assert.AreEqual(expected[++i], item); } }
public void EnqueueDequeueForeachTest2() { queueCust4.Enqueue(p1); queueCust4.Enqueue(p1); queueCust4.Enqueue(p1); queueCust4.Dequeque(); int i = -1; Person[] expected = new[] { p2, p3, p1, p1, p1 }; foreach (var item in queueCust4) { Assert.AreEqual(expected[++i], item); } }
public void AddChunkToDecorationQueue(Chunk chunk) { if (!chunk.IsOnTheBorder && !m_DecorationQueue.Contains(chunk)) { m_DecorationQueue.Enqueue(chunk); } }
private static void EnqueueChunks(List <Chunk> chunks, TQueue <Chunk> queue) { foreach (Chunk chunk in chunks) { queue.Enqueue(chunk); } }
/// <summary> /// 输入数据行 /// </summary> public void InputLine(string line) { if (string.IsNullOrWhiteSpace(line)) { return; } source.Enqueue(line); }
public void AddGameObjectCreationData(GameObjectCreationData gameObjectCreationData) { m_GameObjectCreationQueue.Enqueue(gameObjectCreationData); }
/// <summary> /// Add a new item to the begining of the list. /// </summary> /// <param name="item">The item to add.</param> public void AddItem(string item) { items.Enqueue(item); DataBind(); }
private static void EnqueueChunks(List<Chunk> chunks, TQueue<Chunk> queue) { foreach (Chunk chunk in chunks) { queue.Enqueue(chunk); } }
/// <summary> /// Excecute the passed in action on the main /// thread. /// </summary> /// <param name="action">The action to call on the main thread.</param> public void ExecuteOnMain(Action action) { actionQueue.Enqueue(action); }
public void AddBatchOfChunks(List <Chunk> chunks, BatchType batchType) { m_ChunkBatches.Enqueue(new ChunkBatch(chunks, batchType)); }
public void AddChunkToLightingQueue(Chunk originalChunk) { m_LightingQueue.Enqueue(originalChunk); }
public void AddChunkToTerrainQueue(Chunk chunk) { m_TerrainQueue.Enqueue(chunk); }