[Test] public void Basics() { RawList <int> intList = new RawList <int>(); intList.Add(10); intList.AddRange(new int[] { 17, 42, 94 }); Assert.AreEqual(4, intList.Count); Assert.IsTrue(intList.Contains(42)); Assert.AreEqual(2, intList.IndexOf(42)); CollectionAssert.AreEqual(new int[] { 10, 17, 42, 94 }, intList); CollectionAssert.AreEqual(new int[] { 10, 17, 42, 94 }, intList.Data.Take(4)); intList.ShrinkToFit(); Assert.AreEqual(intList.Count, intList.Capacity); intList.Remove(42); Assert.AreEqual(3, intList.Count); Assert.IsTrue(!intList.Contains(42)); Assert.AreEqual(-1, intList.IndexOf(42)); CollectionAssert.AreEqual(new int[] { 10, 17, 94 }, intList); CollectionAssert.AreEqual(new int[] { 10, 17, 94 }, intList.Data.Take(3)); intList.Insert(1, 100); CollectionAssert.AreEqual(new int[] { 10, 100, 17, 94 }, intList); CollectionAssert.AreEqual(new int[] { 10, 100, 17, 94 }, intList.Data.Take(4)); intList.InsertRange(2, new int[] { 150, 200, 250, 300 }); CollectionAssert.AreEqual(new int[] { 10, 100, 150, 200, 250, 300, 17, 94 }, intList); CollectionAssert.AreEqual(new int[] { 10, 100, 150, 200, 250, 300, 17, 94 }, intList.Data.Take(8)); intList.Clear(); Assert.AreEqual(0, intList.Count); Assert.IsTrue(!intList.Contains(94)); }
[Test] public void Basics() { RawList<int> intList = new RawList<int>(); intList.Add(10); intList.AddRange(new int[] { 17, 42, 94 }); Assert.AreEqual(4, intList.Count); Assert.IsTrue(intList.Contains(42)); Assert.AreEqual(2, intList.IndexOf(42)); CollectionAssert.AreEqual(new int[] { 10, 17, 42, 94 }, intList); CollectionAssert.AreEqual(new int[] { 10, 17, 42, 94 }, intList.Data.Take(4)); intList.ShrinkToFit(); Assert.AreEqual(intList.Count, intList.Capacity); intList.Remove(42); Assert.AreEqual(3, intList.Count); Assert.IsTrue(!intList.Contains(42)); Assert.AreEqual(-1, intList.IndexOf(42)); CollectionAssert.AreEqual(new int[] { 10, 17, 94 }, intList); CollectionAssert.AreEqual(new int[] { 10, 17, 94 }, intList.Data.Take(3)); intList.Insert(1, 100); CollectionAssert.AreEqual(new int[] { 10, 100, 17, 94 }, intList); CollectionAssert.AreEqual(new int[] { 10, 100, 17, 94 }, intList.Data.Take(4)); intList.InsertRange(2, new int[] { 150, 200, 250, 300 }); CollectionAssert.AreEqual(new int[] { 10, 100, 150, 200, 250, 300, 17, 94 }, intList); CollectionAssert.AreEqual(new int[] { 10, 100, 150, 200, 250, 300, 17, 94 }, intList.Data.Take(8)); intList.Clear(); Assert.AreEqual(0, intList.Count); Assert.IsTrue(!intList.Contains(94)); }
[Test] public void RemoveAll() { // Remove nothing { RawList <int> list = new RawList <int>(Enumerable.Range(0, 10)); list.RemoveAll(i => false); CollectionAssert.AreEqual(Enumerable.Range(0, 10), list); } // Remove everything { RawList <int> list = new RawList <int>(Enumerable.Range(0, 10)); list.RemoveAll(i => true); CollectionAssert.AreEqual(new int[0], list); } // Remove all even numbers { RawList <int> list = new RawList <int>(Enumerable.Range(0, 10)); list.RemoveAll(i => i % 2 == 0); CollectionAssert.AreEqual(new int[] { 1, 3, 5, 7, 9 }, list); } // Remove numbers that are in a second list with no regularity { RawList <int> list = new RawList <int>(Enumerable.Range(0, 10)); RawList <int> removeList = new RawList <int>(new int[] { 1, 2, 4, 5, 6, 9 }); list.RemoveAll(i => removeList.Contains(i)); CollectionAssert.AreEqual(new int[] { 0, 3, 7, 8 }, list); } }
internal void EnqueueForStreaming(NativeAudioSource source) { if (streamWorkerQueue.Contains(source)) { return; } streamWorkerQueue.Add(source); streamWorkerQueueEvent.Set(); }
/// <summary> /// Adds entities associated with the solver item to the involved entities list. /// Ensure that sortInvolvedEntities() is called at the end of the function. /// This allows the non-batched multithreading system to lock properly. /// </summary> protected internal override void CollectInvolvedEntities(RawList <Entity> outputInvolvedEntities) { outputInvolvedEntities.Add(Body); foreach (Wheel wheel in Wheels) { if (wheel.supportingEntity != null && !outputInvolvedEntities.Contains(wheel.supportingEntity)) { outputInvolvedEntities.Add(wheel.supportingEntity); } } }
/// <summary> /// Collects the entities which are affected by the solver group and updates the internal listing. /// </summary> protected internal override void CollectInvolvedEntities(RawList <Entity> outputInvolvedEntities) { foreach (SolverUpdateable item in solverUpdateables) { for (int i = 0; i < item.involvedEntities.Count; i++) { if (!outputInvolvedEntities.Contains(item.involvedEntities.Elements[i])) { outputInvolvedEntities.Add(item.involvedEntities.Elements[i]); } } } }
/// <summary> /// Collects the entities which are affected by the solver group and updates the internal listing. /// </summary> protected internal override void CollectInvolvedEntities(RawList<Entity> outputInvolvedEntities) { foreach (EntitySolverUpdateable item in solverUpdateables) { for (int i = 0; i < item.involvedEntities.count; i++) { if (!outputInvolvedEntities.Contains(item.involvedEntities.Elements[i])) { outputInvolvedEntities.Add(item.involvedEntities.Elements[i]); } } } }
/// <summary> /// Adds entities associated with the solver item to the involved entities list. /// Ensure that sortInvolvedEntities() is called at the end of the function. /// This allows the non-batched multithreading system to lock properly. /// </summary> protected internal override void CollectInvolvedEntities(RawList<Entity> outputInvolvedEntities) { outputInvolvedEntities.Add(Body); foreach (Wheel wheel in Wheels) { if (wheel.supportingEntity != null && !outputInvolvedEntities.Contains(wheel.supportingEntity)) outputInvolvedEntities.Add(wheel.supportingEntity); } }