示例#1
0
        internal InstantiateCommandBufferUntyped(Allocator allocator, FixedList64 <ComponentType> componentTypesWithData, int disposeSentinalStackDepth)
        {
            int            dataPayloadSize = 0;
            FixedListInt64 typesSizes      = new FixedListInt64();
            FixedListInt64 typesWithData   = new FixedListInt64();

            for (int i = 0; i < componentTypesWithData.Length; i++)
            {
                var size = TypeManager.GetTypeInfo(componentTypesWithData[i].TypeIndex).ElementSize;
                dataPayloadSize += size;
                typesSizes.Add(size);
                typesWithData.Add(componentTypesWithData[i].TypeIndex);
            }
            CheckComponentTypesValid(BuildComponentTypesFromFixedList(typesWithData));
            m_prefabSortkeyBlockList = (UnsafeParallelBlockList *)UnsafeUtility.Malloc(UnsafeUtility.SizeOf <UnsafeParallelBlockList>(),
                                                                                       UnsafeUtility.AlignOf <UnsafeParallelBlockList>(),
                                                                                       allocator);
            m_componentDataBlockList = (UnsafeParallelBlockList *)UnsafeUtility.Malloc(UnsafeUtility.SizeOf <UnsafeParallelBlockList>(),
                                                                                       UnsafeUtility.AlignOf <UnsafeParallelBlockList>(),
                                                                                       allocator);
            m_state = (State *)UnsafeUtility.Malloc(UnsafeUtility.SizeOf <State>(), UnsafeUtility.AlignOf <State>(), allocator);
            *m_prefabSortkeyBlockList = new UnsafeParallelBlockList(UnsafeUtility.SizeOf <PrefabSortkey>(), 256, allocator);
            *m_componentDataBlockList = new UnsafeParallelBlockList(dataPayloadSize, 256, allocator);
            *m_state = new State
            {
                typesWithData = typesWithData,
                tagsToAdd     = default,
 /// <summary>
 /// Modifies this container to contain values from both containers.
 /// </summary>
 /// <typeparam name="T">Source type of elements</typeparam>
 /// <param name="container">Container to modify.</param>
 /// <param name="other">The container to compare to this container.</param>
 public static void UnionWith <T>(this UnsafeHashSet <T> container, FixedList64 <T> other)
     where T : unmanaged, IEquatable <T>
 {
     foreach (var item in other)
     {
         container.Add(item);
     }
 }
示例#3
0
 /// <summary>
 /// Modifies this container to remove all values that are present in the other container.
 /// </summary>
 /// <typeparam name="T">Source type of elements</typeparam>
 /// <param name="container">Container to modify.</param>
 /// <param name="other">The container to compare to this container.</param>
 public static void ExceptWith <T>(this NativeHashSet <T> container, FixedList64 <T> other)
     where T : unmanaged, IEquatable <T>
 {
     foreach (var item in other)
     {
         container.Remove(item);
     }
 }
    public void FixedList64intGenericHasExpectedCapacity()
    {
        var list             = new FixedList64 <int>();
        var expectedCapacity = list.Capacity;

        for (int i = 0; i < expectedCapacity; ++i)
        {
            list.Add((int)i);
        }
        Assert.Throws <IndexOutOfRangeException> (() => { list.Add((int)expectedCapacity); });
    }
    public void FixedList64intGenericSort()
    {
        var list = new FixedList64 <int>();

        for (var i = 0; i < 5; ++i)
        {
            list.Add((int)(4 - i));
        }
        list.Sort();
        for (var i = 0; i < 5; ++i)
        {
            Assert.AreEqual(i, list[i]);
        }
    }
    public void FixedList64intGenericRemoveRange()
    {
        var list = new FixedList64 <int>();

        list.Add(0);
        list.Add(3);
        list.Add(3);
        list.Add(1);
        list.Add(2);
        list.RemoveRange(1, 2);
        for (var i = 0; i < 3; ++i)
        {
            Assert.AreEqual(i, list[i]);
        }
    }
    public void FixedList64intGenericInsertRange()
    {
        var list = new FixedList64 <int>();

        list.Add(0);
        list.Add(3);
        list.Add(4);
        list.InsertRange(1, 2);
        list[1] = 1;
        list[2] = 2;
        for (var i = 0; i < 5; ++i)
        {
            Assert.AreEqual(i, list[i]);
        }
    }
        /// <summary>
        /// Modifies this container to keep only values that are present in both containers.
        /// </summary>
        /// <typeparam name="T">Source type of elements</typeparam>
        /// <param name="container">Container to modify.</param>
        /// <param name="other">The container to compare to this container.</param>
        public static void IntersectWith <T>(this UnsafeHashSet <T> container, FixedList64 <T> other)
            where T : unmanaged, IEquatable <T>
        {
            var result = new UnsafeList <T>(container.Count(), Allocator.Temp);

            foreach (var item in other)
            {
                if (container.Contains(item))
                {
                    result.Add(item);
                }
            }

            container.Clear();
            container.UnionWith(result);

            result.Dispose();
        }
    public void FixedList64intGenericHasExpectedLayout()
    {
        var actual = new FixedList64 <int>();

        for (var i = 0; i < 15; ++i)
        {
            actual.Add((int)i);
        }
        unsafe
        {
            var e = stackalloc byte[64];
            e[0] = (byte)((15 >> 0) & 0xFF);
            e[1] = (byte)((15 >> 8) & 0xFF);
            for (var i = 0; i < 15; ++i)
            {
                var s = (int)i;
                UnsafeUtility.MemCpy(e + 2 + FixedList.PaddingBytes <int>() + sizeof(int) * i, &s, sizeof(int));
            }
            Assert.AreEqual(0, UnsafeUtility.MemCmp(e, &actual.length, 64));
        }
    }
示例#10
0
 public InstantiateCommandBufferUntyped(Allocator allocator, FixedList64 <ComponentType> typesWithData) : this(allocator, typesWithData, 1)
 {
 }