Beispiel #1
0
        public void NativeArraySharedValuesSameValues()
        {
            int count  = 1024 + 1023;
            var source = new NativeArray <int>(count, Allocator.Temp);

            for (int i = 0; i < count; i++)
            {
                source[i] = count - (i / 2);
            }
            var sharedValues          = new NativeArraySharedValues <int>(source, Allocator.Temp);
            var sharedValuesJobHandle = sharedValues.Schedule(default(JobHandle));

            sharedValuesJobHandle.Complete();

            for (int i = 0; i < count; i++)
            {
                var sharedValueIndices = sharedValues.GetSharedValueIndicesBySourceIndex(i);
                var sourceValue        = source[i];
                Assert.GreaterOrEqual(sharedValueIndices.Length, 1);
                for (int j = 0; j < sharedValueIndices.Length; j++)
                {
                    var otherIndex = sharedValueIndices[j];
                    var otherValue = source[otherIndex];
                    Assert.AreEqual(sourceValue, otherValue);
                }
            }
            sharedValues.Dispose();
            source.Dispose();
        }
        public void NativeArraySharedValuesSameValues([Values(1, 3, 1024, 1024 + 1023)] int count)
        {
            PrepareReverseHalf(count);

            for (int i = 0; i < Source.Length; i++)
            {
                var sharedValueIndices = SharedValues.GetSharedValueIndicesBySourceIndex(i);
                var sourceValue        = Source[i];
                Assert.GreaterOrEqual(sharedValueIndices.Length, 1);
                for (int j = 0; j < sharedValueIndices.Length; j++)
                {
                    var otherIndex = sharedValueIndices[j];
                    var otherValue = Source[otherIndex];
                    Assert.AreEqual(sourceValue, otherValue);
                }
            }
        }