Search Unity

Question Generic type parameter for IEnumerable not supported?

Discussion in 'Burst' started by FaithlessOne, May 15, 2023.

  1. FaithlessOne

    FaithlessOne

    Joined:
    Jun 19, 2017
    Posts:
    315
    Hello,

    I tried to provide IEnumerable as a generic type parameter for a method, but that does not work. Is this not supported by Burst or is there a way to get it work?

    Thats the code:
    Code (CSharp):
    1. public interface INativeSwappingStructList<TElement> : IDisposable where TElement : unmanaged
    2. {
    3.   void AddRange<TEnumerable>(int swapIndex, TEnumerable addedElements) where TEnumerable : unmanaged, IEnumerable<TElement>;
    4. }  
    5.  
    6. [BurstCompile]
    7. public struct NativeSwappingStructListCore<TElement> : INativeSwappingStructList<TElement> where TElement : unmanaged
    8. {
    9.   [BurstCompile]
    10.   public void AddRange<TEnumerable>(int swapIndex, TEnumerable addedElements) where TEnumerable : unmanaged, IEnumerable<TElement>
    11.   {
    12.     foreach (var element in addedElements)
    13.     {
    14.     }
    15.   }
    16. }
    17.  
    18. private struct MyStruct : IEquatable<MyStruct>
    19. {
    20.   public int X;
    21.   public float F;
    22.   // ...
    23. }
    24.  
    25. // Called within other burst compiled code:
    26. NativeArray<MyStruct> array = new(2, Allocator.Temp);
    27. array[0] = new();
    28. array[1] = new();
    29.  
    30. NativeSwappingStructListCore<MyStruct> list = new(/* ... */);
    31. list.AddRange(0, array);
    Thats the error:
    NativeArray itself supports IEnumerable<T>:
    Code (CSharp):
    1. public struct NativeArray<T> : IDisposable, IEnumerable<T>, IEnumerable, IEquatable<NativeArray<T>>
    2.     where T : struct
     
  2. CodeSmile

    CodeSmile

    Joined:
    Apr 10, 2014
    Posts:
    5,880
    First thing to check: does it compile without Burst?Does it also work correctly?

    I read somewhere that Burst does not support scheduling generic jobs from generic methods. Maybe that has something to do with it.
    I would simplify this test to see where the issue is coming from. Like making AddRange a static method in a non generic class.
     
  3. tim_jones

    tim_jones

    Unity Technologies

    Joined:
    May 2, 2019
    Posts:
    287
    Thanks @FaithlessOne - we'll take a look and see whether this should be supported (in which case it's a bug) or not.
     
  4. FaithlessOne

    FaithlessOne

    Joined:
    Jun 19, 2017
    Posts:
    315
    Yes, thats fine C# code. In this case I want to circumvent the not allowed managed type restriction of Burst. The use of IEnumerable<TElement> instead of TEnumerable would clearly not work, because IEnumerable (interfaces in general) is a managed type. Also this technique of using generic types for interfaces avoids boxing of structs in plain C#, so its also having its purpose.

    Thanks for looking into that issue.
     
  5. Miro_Brodlova

    Miro_Brodlova

    Unity Technologies

    Joined:
    Apr 28, 2023
    Posts:
    23
    Hi @FaithlessOne,

    First I just want to say thank you for bringing this to our attention. You were the first to report this problem but I believe more will encounter this in the future. People like you really help Burst and Unity become better!

    We've looked into the error you got and you have caught an edge case we discovered we don't support. My colleague @tim_jones put together this example to show more clearly what's happening and explained it like this:

    In the example
    method M
    is what you are trying to do. We can't support it because it ends up calling an interface method (
    IEnumerator.MoveNext()
    ) without a concrete constrained type.
    Method N
    is what we support. Roslyn ends up calling
    S_Enumerator.MoveNext
    (a method on a struct type, which Burst is fine with), instead of
    IEnumerator<int>
    .

    So as it stands right now you need to have a concrete collection type as the parameter (and need to find another way to do that code). We'll be adding documentation to alert future users of this edge case. We're also adding a new error message for this particular case - hopefully helping others too.

    Thank you again, and feel free to ask any follow up questions!
     
    Sylmerria and FaithlessOne like this.
  6. FaithlessOne

    FaithlessOne

    Joined:
    Jun 19, 2017
    Posts:
    315
    Thanks for looking into my issue and stating a workaround. This is indeed interessting that the IL-Code of Roslyn still does virtual calls for members of IEnumerable supplied as generic type parameter. So I will stick to your stated workaround to be Burst compatible.
     
    Miro_Brodlova likes this.
  7. Miro_Brodlova

    Miro_Brodlova

    Unity Technologies

    Joined:
    Apr 28, 2023
    Posts:
    23
    Hi @FaithlessOne,

    First I just want to thank you for bringing this to our attention. I believe you are just one of the people who will encounter this. People like you really help burst and Unity tools become better.
    Yes, we also thought that was interesting and didn't expect it at first.
    Good luck with your project and hope you find a well-working workaround for now! :)
     
    FaithlessOne likes this.
  8. Deleted User

    Deleted User

    Guest

    Wanted to point out another alternative that may work. Instead of
    foreach
    , you can use

    Code (CSharp):
    1. var enumerator = enumerable.GetEnumerator();
    2. while (enumerator.MoveNext())
    3. {
    4.   var item = enumerator.Current;
    5. }
     
  9. Miro_Brodlova

    Miro_Brodlova

    Unity Technologies

    Joined:
    Apr 28, 2023
    Posts:
    23
    Hi,

    Just wanted to give a heads up that this will throw the same error! But it was very good to consider other iteration-formats and an interesting idea, thank you for bringing it up. Just to be sure I just now gave
    for
    ,
    foreach
    and
    while
    a try, using them to iterate through a generic collection parameter, and all of them will (as it stands now) fail in Burst.
     
    Last edited: Jun 21, 2023
  10. alexchisholm343

    alexchisholm343

    Joined:
    Feb 7, 2021
    Posts:
    14
    Doesn't the underlying burst compiled Unity ECS library make use of generics in lots of places? I figured burst not being able to compile a generic enumerable would have been caught a long time ago
     
  11. Miro_Brodlova

    Miro_Brodlova

    Unity Technologies

    Joined:
    Apr 28, 2023
    Posts:
    23
    Good question!

    Burst does support compiling and iterating through generic collections (which like you say is a common occurrence in most code bases). In Burst for example you can iterate through a NativeList<T> or your own custom-made generic enumerable (like Method N does over custom IEnumarble S in this example from the comment above). If this was what wasn't working that should've indeed been caught a long time ago.

    What Burst does not support is an edge case @FaithlessOne helped us discovered. What doesn't work is wrapping the generic collection in a generic method (that doesn't know the concrete type of the collection) and then iterating through that non-concrete collection inside that method.

    Like in this case (same as Method M in the example above):
    Code (CSharp):
    1.  
    2. // A method that iterates over a generic IEnumerable<T>
    3. // where the concrete type of the collection isn't known.
    4. // This will not work in Burst it's not supported at this time.
    5. public void IterateThroughCollection<T>(T enumerable) where T : IEnumerable<T>
    6.     {
    7.         foreach (var item in enumerable)
    8.         {
    9.         }
    10.     }
    11.  
    This is a more 'niche' use of generic collections and is probably less commonly done - which is why we didn't discover it until now.

    Hope that helps answer your question @alexchisholm343 ! :)
     
    Last edited: Dec 7, 2023
    alexchisholm343 likes this.
  12. FaithlessOne

    FaithlessOne

    Joined:
    Jun 19, 2017
    Posts:
    315
    Only to share my solution. I implemented my own iterator struct to enable the funcitonality of IEnumerable<T> within Burst-compiled code. The iterator works on NativeArray, NativeList, NativeSlice, UnsafeList and the FixedLists, but can easily be extended for more types. It is has to be used with a bit of caution, because it directly iterates on the data of that native containers to avoid making additional copies. It had to be ensured the data is accessible. Especially fixed list can be used on stack memory, so the iterator may refer to memory no more tied to the fixed list. The iterator struct is a ref struct for semantic reasons to ensure it only exists for on the stack and not on the heap which would be more dangerous.

    Code of using the iterator looks like this:
    Code (CSharp):
    1. NativeArray<int> nativeArray = new(5, Allocator.Temp);
    2. nativeArray[0] = 0;
    3. nativeArray[1] = 1;
    4. nativeArray[2] = 2;
    5. nativeArray[3] = 3;
    6. nativeArray[4] = 4;
    7.  
    8. // Write access iterator
    9. var iterator = new NativeIterator<int>(nativeArray);
    10. // Read access iterator
    11. var iterator = new NativeIterator<int>(nativeArray, true);
    12.  
    13. // The iterator can supplied by reference, readonly reference or by value, in this case by reference is used
    14. MyMethod(ref iterator);
    15.  
    16. public void MyMethod(ref NativeIterator<int> iterator)
    17. {
    18.   for (var value = iterator.First(); iterator.HasNext; value = iterator.Next())
    19.   {
    20.     // ...
    21.   }
    22.  
    23.   // Alternative using references to the original data
    24.   for (ref var valueRef = ref iterator.FirstRef(); iterator.HasNext; valueRef = ref iterator.NextRef())
    25.   {
    26.     // ...
    27.   }
    28.  
    29.   // Alternative using readonly references to the original data
    30.   for (ref readonly var valueRefRO = ref iterator.FirstRefRO(); iterator.HasNext; valueRefRO = ref iterator.NextRefRO())
    31.   {
    32.     // ...
    33.   }
    34. }
    Thats the implemented NativeIterator<T>. It also includes an advanced feature for filtering indices, so that only certain values of the underlying native container are returned.
    Code (CSharp):
    1. /// <summary>
    2. /// A iterator for iteration native containers used in <see cref="Unity.Collections" />.
    3. /// CAUTION: This iterator is quite unsafe because it NEVER holds the data itself, only referrers to the data, so
    4. /// you must ensure that the data is still accessible in the memory when iterating.
    5. /// This is especially important when using fixed lists, but may also an issue on native containers.
    6. /// </summary>
    7. [DebuggerStepThrough]
    8. [NoReorder]
    9. public unsafe ref struct NativeIterator<TElement> where TElement : unmanaged
    10. {
    11.   [Flags]
    12.   private enum FilterOptions : int
    13.   {
    14.     None = 0,
    15.     IncludeIndices = 1 << 0,
    16.     IncludeIndicesUnordered = 1 << 1,
    17.   }
    18.  
    19.   [Flags]
    20.   private enum Flags : int
    21.   {
    22.     None = 0,
    23.  
    24.     /// <summary>
    25.     /// Iterator can only be used with <see cref="First" /> and <see cref="Next" />
    26.     /// and not using the ref calls <see cref="FirstRef" /> and <see cref="NextRef" />.
    27.     /// </summary>
    28.     IsReadOnly = 1 << 0,
    29.  
    30.     /// <summary>
    31.     /// Set when repeatable enumeration possible.
    32.     /// </summary>
    33.     IsRepeatable = 1 << 1,
    34.  
    35.     /// <summary>
    36.     /// Default flags used.
    37.     /// </summary>
    38.     Default = Flags.IsRepeatable,
    39.   }
    40.  
    41.   private int _elementCount;
    42.   private int _index;
    43.   private readonly void* _nativePtr;
    44.   private TElement* _dataPtr;
    45.   private readonly NativeTypeCode _nativeTypeCode;
    46.   private readonly Flags _flags; // Integer for faster access (padded, avoid additional padding)
    47.   private UnsafeList<int>* _filteringIncludedIndicesPtr;
    48.   private int _filteringIncludedIndicesIndex;
    49.   private FilterOptions _filterOptions;
    50.  
    51.   /// <summary>
    52.   /// Gets a value indicating whether the iterator can run multiple times using the
    53.   /// <see cref="First" />, <see cref="FirstRef" /> or <see cref="FirstRefRO" />.
    54.   /// When false these methods can only be called once.
    55.   /// </summary>
    56.   public bool IsRepeatable
    57.   {
    58.     [MethodImpl(MethodImplOptions.AggressiveInlining)]
    59.     get => (this._flags & Flags.IsRepeatable) != 0;
    60.   }
    61.  
    62.   /// <summary>
    63.   /// Gets a value indicating whether the iterator is readonly.
    64.   /// In this case the methods <see cref="First" />, <see cref="FirstRefRO" /> and <see cref="Next" />,
    65.   /// <see cref="NextRefRO" />
    66.   /// have to be used and the <see cref="FirstRef" /> and <see cref="NextRef" /> will throw exceptions.
    67.   /// </summary>
    68.   public bool IsReadOnly
    69.   {
    70.     [MethodImpl(MethodImplOptions.AggressiveInlining)]
    71.     get => (this._flags & Flags.IsReadOnly) != 0;
    72.   }
    73.  
    74.   // private TElement* GetFixedBuffer()
    75.   // {
    76.   //   // Unfortunately the Buffer pointer of the fixed lists is internal, so only using the logic inside
    77.   //   // for determining the buffer to first element
    78.   //   // Native Pointer => Pointer to the struct
    79.   //   // SizeOf<ushort> => Item length
    80.   //   // math.max       => padding of the data (the SizeOf<ushort> is padded to four bytes)
    81.   //   return (TElement*)((byte*)this._nativePointer + UnsafeUtility.SizeOf<ushort>() + math.max(0, math.min(6, (1 << math.tzcnt(UnsafeUtility.SizeOf<TElement>())) - 2)));
    82.   // }
    83.  
    84.   /// <summary>
    85.   /// Initializes a new instance of the <see cref="NativeIterator{TElement}" />
    86.   /// struct.
    87.   /// </summary>
    88.   public NativeIterator(void* fixedListPtr, bool isReadOnly = false)
    89.   {
    90.     this._flags = Flags.Default | (isReadOnly ? Flags.IsReadOnly : Flags.None);
    91.     this._nativeTypeCode = NativeTypeCode.FixedListUnknownSize;
    92.  
    93.     this._nativePtr = fixedListPtr;
    94.  
    95.     this._index = 0;
    96.     this._elementCount = 0;
    97.     this._dataPtr = (TElement*)0;
    98.  
    99.     this._filterOptions = FilterOptions.None;
    100.     this._filteringIncludedIndicesPtr = (UnsafeList<int>*)0;
    101.     this._filteringIncludedIndicesIndex = 0;
    102.   }
    103.  
    104.   /// <summary>
    105.   /// Initializes a new instance of the <see cref="NativeIterator{TElement}" />
    106.   /// struct.
    107.   /// </summary>
    108.   public NativeIterator(in FixedList32Bytes<TElement> fixedList, bool isReadOnly = false)
    109.   {
    110.     this._flags = Flags.Default | (isReadOnly ? Flags.IsReadOnly : Flags.None);
    111.     this._nativeTypeCode = NativeTypeCode.FixedList32;
    112.  
    113.     fixed (FixedList32Bytes<TElement>* tempPointer = &fixedList)
    114.     {
    115.       this._nativePtr = tempPointer;
    116.     }
    117.  
    118.     this._index = 0;
    119.     this._elementCount = 0;
    120.     this._dataPtr = (TElement*)0;
    121.  
    122.     this._filterOptions = FilterOptions.None;
    123.     this._filteringIncludedIndicesPtr = (UnsafeList<int>*)0;
    124.     this._filteringIncludedIndicesIndex = 0;
    125.   }
    126.  
    127.   /// <summary>
    128.   /// Initializes a new instance of the <see cref="NativeIterator{TElement}" />
    129.   /// struct.
    130.   /// </summary>
    131.   public NativeIterator(in FixedList64Bytes<TElement> fixedList, bool isReadOnly = false)
    132.   {
    133.     this._flags = Flags.Default | (isReadOnly ? Flags.IsReadOnly : Flags.None);
    134.     this._nativeTypeCode = NativeTypeCode.FixedList64;
    135.  
    136.     fixed (FixedList64Bytes<TElement>* tempPointer = &fixedList)
    137.     {
    138.       this._nativePtr = tempPointer;
    139.     }
    140.  
    141.     this._index = 0;
    142.     this._elementCount = 0;
    143.     this._dataPtr = (TElement*)0;
    144.  
    145.     this._filterOptions = FilterOptions.None;
    146.     this._filteringIncludedIndicesPtr = (UnsafeList<int>*)0;
    147.     this._filteringIncludedIndicesIndex = 0;
    148.   }
    149.  
    150.   /// <summary>
    151.   /// Initializes a new instance of the <see cref="NativeIterator{TElement}" />
    152.   /// struct.
    153.   /// </summary>
    154.   public NativeIterator(in FixedList128Bytes<TElement> fixedList, bool isReadOnly = false)
    155.   {
    156.     this._flags = Flags.Default | (isReadOnly ? Flags.IsReadOnly : Flags.None);
    157.     this._nativeTypeCode = NativeTypeCode.FixedList128;
    158.  
    159.     fixed (FixedList128Bytes<TElement>* tempPointer = &fixedList)
    160.     {
    161.       this._nativePtr = tempPointer;
    162.     }
    163.  
    164.     this._index = 0;
    165.     this._elementCount = 0;
    166.     this._dataPtr = (TElement*)0;
    167.  
    168.     this._filterOptions = FilterOptions.None;
    169.     this._filteringIncludedIndicesPtr = (UnsafeList<int>*)0;
    170.     this._filteringIncludedIndicesIndex = 0;
    171.   }
    172.  
    173.   /// <summary>
    174.   /// Initializes a new instance of the <see cref="NativeIterator{TElement}" />
    175.   /// struct.
    176.   /// </summary>
    177.   public NativeIterator(in FixedList512Bytes<TElement> fixedList, bool isReadOnly = false)
    178.   {
    179.     this._flags = Flags.Default | (isReadOnly ? Flags.IsReadOnly : Flags.None);
    180.     this._nativeTypeCode = NativeTypeCode.FixedList512;
    181.  
    182.     fixed (FixedList512Bytes<TElement>* tempPointer = &fixedList)
    183.     {
    184.       this._nativePtr = tempPointer;
    185.     }
    186.  
    187.     this._index = 0;
    188.     this._elementCount = 0;
    189.     this._dataPtr = (TElement*)0;
    190.  
    191.     this._filterOptions = FilterOptions.None;
    192.     this._filteringIncludedIndicesPtr = (UnsafeList<int>*)0;
    193.     this._filteringIncludedIndicesIndex = 0;
    194.   }
    195.  
    196.   /// <summary>
    197.   /// Initializes a new instance of the <see cref="NativeIterator{TElement}" />
    198.   /// struct.
    199.   /// </summary>
    200.   public NativeIterator(in FixedList4096Bytes<TElement> fixedList, bool isReadOnly = false)
    201.   {
    202.     this._flags = Flags.Default | (isReadOnly ? Flags.IsReadOnly : Flags.None);
    203.     this._nativeTypeCode = NativeTypeCode.FixedList4096;
    204.  
    205.     fixed (FixedList4096Bytes<TElement>* tempPointer = &fixedList)
    206.     {
    207.       this._nativePtr = tempPointer;
    208.     }
    209.  
    210.     this._index = 0;
    211.     this._elementCount = 0;
    212.     this._dataPtr = (TElement*)0;
    213.  
    214.     this._filterOptions = FilterOptions.None;
    215.     this._filteringIncludedIndicesPtr = (UnsafeList<int>*)0;
    216.     this._filteringIncludedIndicesIndex = 0;
    217.   }
    218.  
    219.   /// <summary>
    220.   /// Initializes a new instance of the <see cref="NativeIterator{TElement}" />
    221.   /// struct.
    222.   /// </summary>
    223.   public NativeIterator(in NativeArray<TElement> nativeArray, bool isReadOnly = false)
    224.   {
    225.     this._flags = Flags.Default | (isReadOnly ? Flags.IsReadOnly : Flags.None);
    226.     this._nativeTypeCode = NativeTypeCode.NativeArray;
    227.  
    228.     fixed (NativeArray<TElement>* tempPointer = &nativeArray)
    229.     {
    230.       this._nativePtr = tempPointer;
    231.     }
    232.  
    233.     this._index = 0;
    234.     this._elementCount = 0;
    235.     this._dataPtr = (TElement*)0;
    236.  
    237.     this._filterOptions = FilterOptions.None;
    238.     this._filteringIncludedIndicesPtr = (UnsafeList<int>*)0;
    239.     this._filteringIncludedIndicesIndex = 0;
    240.   }
    241.  
    242.   /// <summary>
    243.   /// Initializes a new instance of the <see cref="NativeIterator{TElement}" />
    244.   /// struct.
    245.   /// </summary>
    246.   public NativeIterator(in NativeList<TElement> nativeList, bool isReadOnly = false)
    247.   {
    248.     this._flags = Flags.Default | (isReadOnly ? Flags.IsReadOnly : Flags.None);
    249.     this._nativeTypeCode = NativeTypeCode.NativeList;
    250.  
    251.     fixed (NativeList<TElement>* tempPointer = &nativeList)
    252.     {
    253.       this._nativePtr = tempPointer;
    254.     }
    255.  
    256.     this._index = 0;
    257.     this._elementCount = 0;
    258.     this._dataPtr = (TElement*)0;
    259.  
    260.     this._filterOptions = FilterOptions.None;
    261.     this._filteringIncludedIndicesPtr = (UnsafeList<int>*)0;
    262.     this._filteringIncludedIndicesIndex = 0;
    263.   }
    264.  
    265.   /// <summary>
    266.   /// Initializes a new instance of the <see cref="NativeIterator{TElement}" />
    267.   /// struct.
    268.   /// </summary>
    269.   public NativeIterator(in UnsafeList<TElement> unsafeList, bool isReadOnly = false)
    270.   {
    271.     this._flags = Flags.Default | (isReadOnly ? Flags.IsReadOnly : Flags.None);
    272.     this._nativeTypeCode = NativeTypeCode.UnsafeList;
    273.  
    274.     fixed (UnsafeList<TElement>* tempPointer = &unsafeList)
    275.     {
    276.       this._nativePtr = tempPointer;
    277.     }
    278.  
    279.     this._index = 0;
    280.     this._elementCount = 0;
    281.     this._dataPtr = (TElement*)0;
    282.  
    283.     this._filterOptions = FilterOptions.None;
    284.     this._filteringIncludedIndicesPtr = (UnsafeList<int>*)0;
    285.     this._filteringIncludedIndicesIndex = 0;
    286.   }
    287.  
    288.   /// <summary>
    289.   /// Initializes a new instance of the <see cref="NativeIterator{TElement}" />
    290.   /// struct.
    291.   /// </summary>
    292.   public NativeIterator(in NativeSlice<TElement> nativeList, bool isReadOnly = false)
    293.   {
    294.     this._flags = Flags.Default | (isReadOnly ? Flags.IsReadOnly : Flags.None);
    295.     this._nativeTypeCode = NativeTypeCode.NativeSlice;
    296.  
    297.     fixed (NativeSlice<TElement>* tempPointer = &nativeList)
    298.     {
    299.       this._nativePtr = tempPointer;
    300.     }
    301.  
    302.     this._index = 0;
    303.     this._elementCount = 0;
    304.     this._dataPtr = (TElement*)0;
    305.  
    306.     this._filterOptions = FilterOptions.None;
    307.     this._filteringIncludedIndicesPtr = (UnsafeList<int>*)0;
    308.     this._filteringIncludedIndicesIndex = 0;
    309.   }
    310.  
    311.   private readonly ref NativeArray<TElement> _nativeArray
    312.   {
    313.     [MethodImpl(MethodImplOptions.AggressiveInlining)]
    314.     get => ref *(NativeArray<TElement>*)this._nativePtr;
    315.   }
    316.  
    317.   private readonly ref FixedList32Bytes<TElement> _fixedList32
    318.   {
    319.     [MethodImpl(MethodImplOptions.AggressiveInlining)]
    320.     get => ref *(FixedList32Bytes<TElement>*)this._nativePtr;
    321.   }
    322.  
    323.   private readonly ref NativeList<TElement> _nativeList
    324.   {
    325.     [MethodImpl(MethodImplOptions.AggressiveInlining)]
    326.     get => ref *(NativeList<TElement>*)this._nativePtr;
    327.   }
    328.  
    329.   private readonly ref UnsafeList<TElement> _unsafeList
    330.   {
    331.     [MethodImpl(MethodImplOptions.AggressiveInlining)]
    332.     get => ref *(UnsafeList<TElement>*)this._nativePtr;
    333.   }
    334.  
    335.   private readonly ref NativeSlice<TElement> _nativeSlice
    336.   {
    337.     [MethodImpl(MethodImplOptions.AggressiveInlining)]
    338.     get => ref *(NativeSlice<TElement>*)this._nativePtr;
    339.   }
    340.  
    341.   /// <summary>
    342.   /// Gets a value indicating whether a next node is available.
    343.   /// </summary>
    344.   public bool HasNext => this._index < this._elementCount;
    345.  
    346.   /// <summary>
    347.   /// Fetches the next node.
    348.   /// </summary>
    349.   private void FetchNextNode()
    350.   {
    351.     this._index++;
    352.  
    353.     if (this._filterOptions != FilterOptions.None)
    354.     {
    355.       if ((this._filterOptions & FilterOptions.IncludeIndices) != 0)
    356.       {
    357.         while (this._index < this._elementCount && this._index == this._filteringIncludedIndicesPtr->ElementAt(this._filteringIncludedIndicesIndex))
    358.         {
    359.           this._index++;
    360.           this._filteringIncludedIndicesIndex++;
    361.         }
    362.       }
    363.     }
    364.   }
    365.  
    366.   /// <summary>
    367.   /// Gets or sets the indices which the iterator should include in the iteration.
    368.   /// </summary>
    369.   /// <param name="includedIndices">The indices to include. The list has to be sorted ascending.</param>
    370.   public void FilterIndices(in UnsafeList<int> includedIndices)
    371.   {
    372.     fixed (UnsafeList<int>* includedIndicesPtr = &includedIndices)
    373.     {
    374.       this._filteringIncludedIndicesPtr = includedIndicesPtr;
    375.     }
    376.  
    377.     this._filterOptions = FilterOptions.IncludeIndices;
    378.   }
    379.  
    380.   /// <summary>
    381.   /// Disables all filter.
    382.   /// </summary>
    383.   public void ResetFilter()
    384.   {
    385.     this._filteringIncludedIndicesPtr = (UnsafeList<int>*)0;
    386.     this._filterOptions = FilterOptions.None;
    387.   }
    388.  
    389.   /// <summary>
    390.   /// Gets the first element of the iteration by reference.
    391.   /// Ensure that the reference is caught by reference otherwise this causes
    392.   /// <see cref="NullReferenceException" /> errors.
    393.   /// </summary>
    394.   [MustUseReturnValue("Return value has to used by reference")]
    395.   public ref TElement FirstRef()
    396.   {
    397.     this.CheckReadOnly();
    398.  
    399.     this._index = -1;
    400.     this.InitIteration();
    401.     this.FetchNextNode();
    402.  
    403.     if (this.HasNext)
    404.     {
    405.       return ref this.ReturnCurrentElementByRef();
    406.     }
    407.     else
    408.     {
    409.       // Burst handles managed pointers being 0 differently than C# does, but in this case it does not cause any trouble
    410.       return ref UnsafeUtility.AsRef<TElement>((void*)0);;
    411.     }
    412.   }
    413.  
    414.   /// <summary>
    415.   /// Gets the first element of the iteration by readonly reference.
    416.   /// Ensure that the reference is caught by reference otherwise this causes
    417.   /// <see cref="NullReferenceException" /> errors.
    418.   /// </summary>
    419.   [MustUseReturnValue("Return value has to used by reference")]
    420.   public ref readonly TElement FirstRefRO()
    421.   {
    422.     this._index = -1;
    423.     this.InitIteration();
    424.     this.FetchNextNode();
    425.  
    426.     if (this.HasNext)
    427.     {
    428.       return ref this.ReturnCurrentElementByRef();
    429.     }
    430.     else
    431.     {
    432.       // Burst handles managed pointers being 0 differently than C# does, but in this case it does not cause any trouble
    433.       return ref UnsafeUtility.AsRef<TElement>((void*)0);;
    434.     }
    435.   }
    436.  
    437.   /// <summary>
    438.   /// Gets the first element of the iteration by value.
    439.   /// Ensure that the reference is caught by reference otherwise this causes
    440.   /// <see cref="NullReferenceException" /> errors.
    441.   /// </summary>
    442.   [MustUseReturnValue("Return value has to used")]
    443.   public TElement First()
    444.   {
    445.     this._index = -1;
    446.     this.InitIteration();
    447.     this.FetchNextNode();
    448.  
    449.     if (this.HasNext)
    450.     {
    451.       return this.ReturnCurrentElementByRef();
    452.     }
    453.     else
    454.     {
    455.       return default;
    456.     }
    457.   }
    458.  
    459.   /// <summary>
    460.   /// Returns the current iterator as copy but usable as reference.
    461.   /// This is just syntactic sugar to make the iterator supplied as reference in one line instead of two.
    462.   /// </summary>
    463.   /// <param name="iterator">The resulting iterator. This is the equally same as the returned iterator.</param>
    464.   /// <returns>
    465.   /// The iterator by ref which is copy of the current iterator. This is the equally same as
    466.   /// <paramref name="iterator" />.
    467.   /// </returns>
    468.   /// <example>
    469.   /// <code>
    470.   /// void Test(in NativeIterator&lt;TElement&gt; iterator)
    471.   /// {
    472.   ///   var copiedIterator = iterator;
    473.   ///   this.OtherMethod(ref copiedIterator);
    474.   ///   // But instead this can be used:
    475.   ///   this.OtherMethod(ref iterator.Ref(out _));
    476.   /// }
    477.   /// </code>
    478.   /// </example>
    479.   public readonly ref NativeIterator<TElement> Ref(out NativeIterator<TElement> iterator)
    480.   {
    481.     iterator = this;
    482.     return ref iterator;
    483.   }
    484.  
    485.   /// <summary>
    486.   /// Creates a clone/copy of the current iterator.
    487.   /// </summary>
    488.   /// <returns>Copy of the iterator.</returns>
    489.   public readonly NativeIterator<TElement> Clone()
    490.   {
    491.     return this;
    492.   }
    493.  
    494.   /// <summary>
    495.   /// Tries getting the count of elements for the iterator.
    496.   /// Only usable when the underlying enumerable supports returning the count without enumerating.
    497.   /// </summary>
    498.   /// <param name="length">The resulting count when return value is true.</param>
    499.   /// <returns>True when the count could be determined.</returns>
    500.   public readonly bool TryGetLength(out int length)
    501.   {
    502.     // No length when having a filter active
    503.     if (this._filterOptions != FilterOptions.None)
    504.     {
    505.       length = default;
    506.       return false;
    507.     }
    508.  
    509.     if (this._nativeTypeCode == NativeTypeCode.NativeArray)
    510.     {
    511.       length = this._nativeArray.Length;
    512.       return true;
    513.     }
    514.     else if (this._nativeTypeCode == NativeTypeCode.NativeList)
    515.     {
    516.       length = this._nativeList.Length;
    517.       return true;
    518.     }
    519.     else if (this._nativeTypeCode == NativeTypeCode.UnsafeList)
    520.     {
    521.       length = this._unsafeList.Length;
    522.       return true;
    523.     }
    524.     else if (this._nativeTypeCode == NativeTypeCode.NativeSlice)
    525.     {
    526.       length = this._nativeSlice.Length;
    527.       return true;
    528.     }
    529.     else if (this._nativeTypeCode is >= NativeTypeCode.FixedList32 and <= NativeTypeCode.FixedListUnknownSize)
    530.     {
    531.       // Item length are the first two bytes
    532.       length = *(ushort*)this._nativePtr;
    533.       return true;
    534.     }
    535.     else
    536.     {
    537.       this.ThrowUnsupportedContainer();
    538.       length = default;
    539.       return false;
    540.     }
    541.   }
    542.  
    543.   private readonly void ThrowUnsupportedContainer()
    544.   {
    545.     var message = $"Unsupported native container";
    546.     Log.Error(message);
    547.     throw new System.Data.DataException(message);
    548.   }
    549.  
    550.   private void InitIteration()
    551.   {
    552.     if (this._nativeTypeCode == NativeTypeCode.NativeArray)
    553.     {
    554.       var nativeArray = this._nativeArray;
    555.       this._elementCount = nativeArray.Length;
    556.  
    557.       if (this._elementCount > 0)
    558.       {
    559.         this._dataPtr = (TElement*)nativeArray.GetUnsafePtr();
    560.       }
    561.     }
    562.     else if (this._nativeTypeCode == NativeTypeCode.NativeList)
    563.     {
    564.       var nativeList = this._nativeList;
    565.       this._elementCount = nativeList.Length;
    566.  
    567.       if (this._elementCount > 0)
    568.       {
    569.         this._dataPtr = (TElement*)nativeList.GetUnsafePtr();
    570.       }
    571.     }
    572.     else if (this._nativeTypeCode == NativeTypeCode.UnsafeList)
    573.     {
    574.       var unsafeList = this._unsafeList;
    575.       this._elementCount = unsafeList.Length;
    576.  
    577.       if (this._elementCount > 0)
    578.       {
    579.         this._dataPtr = (TElement*)unsafeList.Ptr;
    580.       }
    581.     }
    582.     else if (this._nativeTypeCode == NativeTypeCode.NativeSlice)
    583.     {
    584.       var nativeSlice = this._nativeSlice;
    585.       this._elementCount = nativeSlice.Length;
    586.  
    587.       if (this._elementCount > 0)
    588.       {
    589.         this._dataPtr = (TElement*)nativeSlice.GetUnsafePtr();
    590.       }
    591.     }
    592.     else if (this._nativeTypeCode is >= NativeTypeCode.FixedList32 and <= NativeTypeCode.FixedListUnknownSize)
    593.     {
    594.       // Item length are the first two bytes
    595.       this._elementCount = *(ushort*)this._nativePtr;
    596.  
    597.       if (this._elementCount > 0)
    598.       {
    599.         this._dataPtr = NativeIterator.GetFixedListBufferPointer<TElement>(this._nativePtr);
    600.       }
    601.     }
    602.     else
    603.     {
    604.       this.ThrowUnsupportedContainer();
    605.     }
    606.   }
    607.  
    608.   /// <summary>
    609.   /// Gets the next element of the iteration by readonly reference.
    610.   /// </summary>
    611.   [MustUseReturnValue("Return value has to used by reference")]
    612.   public ref readonly TElement NextRefRO()
    613.   {
    614.     this.FetchNextNode();
    615.  
    616.     if (this.HasNext)
    617.     {
    618.       return ref this.ReturnCurrentElementByRef();
    619.     }
    620.     else
    621.     {
    622.       // Burst handles managed pointers being 0 differently than C# does, but in this case it does not cause any trouble
    623.       return ref UnsafeUtility.AsRef<TElement>((void*)0);;
    624.     }
    625.   }
    626.  
    627.   /// <summary>
    628.   /// Gets the next element of the iteration by reference.
    629.   /// </summary>
    630.   [MustUseReturnValue("Return value has to used by reference")]
    631.   public ref TElement NextRef()
    632.   {
    633.     this.CheckReadOnly();
    634.     this.FetchNextNode();
    635.  
    636.     if (this.HasNext)
    637.     {
    638.       return ref this.ReturnCurrentElementByRef();
    639.     }
    640.     else
    641.     {
    642.       // Burst handles managed pointers being 0 differently than C# does, but in this case it does not cause any trouble
    643.       return ref UnsafeUtility.AsRef<TElement>((void*)0);;
    644.     }
    645.   }
    646.  
    647.   private readonly void CheckReadOnly()
    648.   {
    649.     if ((this._flags & Flags.IsReadOnly) != 0)
    650.     {
    651.       var message = "Iteration is read-only. Ref returning is not allowed";
    652.       Log.Error(message);
    653.       throw new System.Data.DataException(message);
    654.     }
    655.   }
    656.  
    657.   /// <summary>
    658.   /// Gets the next element of the iteration by value.
    659.   /// </summary>
    660.   [MustUseReturnValue("Return value has to used")]
    661.   public TElement Next()
    662.   {
    663.     this.FetchNextNode();
    664.  
    665.     if (this.HasNext)
    666.     {
    667.       return this.ReturnCurrentElementByRef();
    668.     }
    669.     else
    670.     {
    671.       return default;
    672.     }
    673.   }
    674.  
    675.   private ref TElement ReturnCurrentElementByRef()
    676.   {
    677.     //if (!this._nativeArraySpan.IsEmpty || !this._nativeListSpan.IsEmpty)
    678.     if (this._nativeTypeCode is NativeTypeCode.NativeArray or NativeTypeCode.NativeList or NativeTypeCode.UnsafeList or NativeTypeCode.NativeSlice
    679.         || this._nativeTypeCode is >= NativeTypeCode.FixedList32 and <= NativeTypeCode.FixedListUnknownSize)
    680.     {
    681.       // Burst handles managed pointers being 0 differently than C# does, but in this case it does not cause any trouble
    682.       return ref UnsafeUtility.AsRef<TElement>(this._dataPtr + this._index);
    683.     }
    684.     else
    685.     {
    686.       this.ThrowUnsupportedContainer();
    687.       return ref UnsafeUtility.AsRef<TElement>((void*)0);;
    688.     }
    689.   }
    690. }
    691.  
    692. /// <summary>
    693. /// Code for a native type.
    694. /// </summary>
    695. public enum NativeTypeCode
    696. {
    697.   /// <summary>
    698.   /// No type specified.
    699.   /// </summary>
    700.   Unspecified = 0,
    701.  
    702.   /// <summary>
    703.   /// <see cref="NativeArray{T}" />.
    704.   /// </summary>
    705.   NativeArray = 1,
    706.  
    707.   /// <summary>
    708.   /// <see cref="NativeList{T}" />.
    709.   /// </summary>
    710.   NativeList = 2,
    711.  
    712.   /// <summary>
    713.   /// <see cref="UnsafeList{T}" />.
    714.   /// </summary>
    715.   UnsafeList = 3,
    716.  
    717.   /// <summary>
    718.   /// <see cref="NativeSlice{T}" />.
    719.   /// </summary>
    720.   NativeSlice = 5,
    721.  
    722.   /// <summary>
    723.   /// <see cref="FixedList32Bytes{T}" />.
    724.   /// </summary>
    725.   FixedList32 = 6,
    726.  
    727.   /// <summary>
    728.   /// <see cref="FixedList64Bytes{T}" />.
    729.   /// </summary>
    730.   FixedList64 = 7,
    731.  
    732.   /// <summary>
    733.   /// <see cref="FixedList128Bytes{T}" />.
    734.   /// </summary>
    735.   FixedList128 = 8,
    736.  
    737.   /// <summary>
    738.   /// <see cref="FixedList512Bytes{T}" />.
    739.   /// </summary>
    740.   FixedList512 = 9,
    741.  
    742.   /// <summary>
    743.   /// <see cref="FixedList4096Bytes{T}" />.
    744.   /// </summary>
    745.   FixedList4096 = 10,
    746.  
    747.   /// <summary>
    748.   /// Any fixed list.
    749.   /// </summary>
    750.   FixedListUnknownSize = 11,
    751. }
    752.  
    Here are some additional utility methods:
    Code (CSharp):
    1. /// <summary>
    2. /// Static calls regarding <see cref="NativeIterator{TElement}"/>.
    3. /// </summary>
    4. [DebuggerStepThrough]
    5. public static class NativeIterator
    6. {
    7.   public const int FixedListPreliminaryBytes = 4;
    8.  
    9.   /// <summary>
    10.   /// Gets the pointer to the buffer of a fixed list using the pointer to the fixed list itself.
    11.   /// </summary>
    12.   /// <param name="fixedListPointer">Pointer to the fixed list.</param>
    13.   /// <typeparam name="T">The type of the fixed list.</typeparam>
    14.   /// <returns>The pointer to the fixed list buffer.</returns>
    15.   public static unsafe T* GetFixedListBufferPointer<T>(void* fixedListPointer)
    16.     where T : unmanaged
    17.   {
    18.     // Unfortunately the Buffer pointer of the fixed lists is internal, so only using the logic inside
    19.     // for determining the buffer to first element
    20.     // Native Pointer => Pointer to the struct
    21.     // SizeOf<ushort> => Item length
    22.     // math.max       => padding of the data (the SizeOf<ushort> is padded to four bytes)
    23.     return (T*)((byte*)fixedListPointer + UnsafeUtility.SizeOf<ushort>() + math.max(0, math.min(6, (1 << math.tzcnt(UnsafeUtility.SizeOf<T>())) - 2)));
    24.   }
    25.  
    26.   /// <summary>
    27.   /// Creates an iterator using the specified element based on an <see cref="NativeArray{T}" />.
    28.   /// </summary>
    29.   /// <param name="t1">Element.</param>
    30.   /// <param name="nativeArray">The reference to the allocated array.</param>
    31.   /// <param name="allocator">The allocator for the array.</param>
    32.   /// <typeparam name="TElement">The type of the element.</typeparam>
    33.   /// <returns>Iterator for the specified elements.</returns>
    34.   public static NativeIterator<TElement> CreateArray<TElement>(in TElement t1, out NativeArray<TElement> nativeArray, Allocator allocator = Allocator.Temp)
    35.     where TElement : unmanaged
    36.   {
    37.     nativeArray = new NativeArray<TElement>(1, allocator);
    38.     nativeArray[0] = t1;
    39.  
    40.     return new NativeIterator<TElement>(nativeArray);
    41.   }
    42.  
    43.   /// <summary>
    44.   /// Creates an iterator using the specified element based on an <see cref="NativeArray{T}" />.
    45.   /// </summary>
    46.   /// <param name="t1">Element.</param>
    47.   /// <param name="t2">Element.</param>
    48.   /// <param name="nativeArray">The reference to the allocated array.</param>
    49.   /// <param name="allocator">The allocator for the array.</param>
    50.   /// <typeparam name="TElement">The type of the element.</typeparam>
    51.   /// <returns>Iterator for the specified elements.</returns>
    52.   public static NativeIterator<TElement> CreateArray<TElement>(in TElement t1, in TElement t2, out NativeArray<TElement> nativeArray, Allocator allocator = Allocator.Temp)
    53.     where TElement : unmanaged
    54.   {
    55.     nativeArray = new NativeArray<TElement>(2, allocator);
    56.     nativeArray[0] = t1;
    57.     nativeArray[1] = t2;
    58.  
    59.     return new NativeIterator<TElement>(nativeArray);
    60.   }
    61.  
    62.   /// <summary>
    63.   /// Creates an iterator using the specified element based on an <see cref="NativeArray{T}" />.
    64.   /// </summary>
    65.   /// <param name="t1">Element.</param>
    66.   /// <param name="t2">Element.</param>
    67.   /// <param name="t3">Element.</param>
    68.   /// <param name="t4">Element.</param>
    69.   /// <param name="t5">Element.</param>
    70.   /// <param name="nativeArray">The reference to the allocated array.</param>
    71.   /// <param name="allocator">The allocator for the array.</param>
    72.   /// <typeparam name="TElement">The type of the element.</typeparam>
    73.   /// <returns>Iterator for the specified elements.</returns>
    74.   public static NativeIterator<TElement> CreateArray<TElement>(
    75.     in TElement t1, in TElement t2, in TElement t3, out NativeArray<TElement> nativeArray, Allocator allocator = Allocator.Temp)
    76.     where TElement : unmanaged
    77.   {
    78.     nativeArray = new NativeArray<TElement>(3, allocator);
    79.     nativeArray[0] = t1;
    80.     nativeArray[1] = t2;
    81.     nativeArray[2] = t3;
    82.  
    83.     return new NativeIterator<TElement>(nativeArray);
    84.   }
    85.  
    86.   /// <summary>
    87.   /// Creates an iterator using the specified element based on an <see cref="NativeArray{T}" />.
    88.   /// </summary>
    89.   /// <param name="t1">Element.</param>
    90.   /// <param name="t2">Element.</param>
    91.   /// <param name="t3">Element.</param>
    92.   /// <param name="t4">Element.</param>
    93.   /// <param name="nativeArray">The reference to the allocated array.</param>
    94.   /// <param name="allocator">The allocator for the array.</param>
    95.   /// <typeparam name="TElement">The type of the element.</typeparam>
    96.   /// <returns>Iterator for the specified elements.</returns>
    97.   public static NativeIterator<TElement> CreateArray<TElement>(
    98.     in TElement t1, in TElement t2, in TElement t3, in TElement t4, out NativeArray<TElement> nativeArray, Allocator allocator = Allocator.Temp)
    99.     where TElement : unmanaged
    100.   {
    101.     nativeArray = new NativeArray<TElement>(4, allocator);
    102.     nativeArray[0] = t1;
    103.     nativeArray[1] = t2;
    104.     nativeArray[2] = t3;
    105.     nativeArray[3] = t4;
    106.  
    107.     return new NativeIterator<TElement>(nativeArray);
    108.   }
    109.  
    110.   /// <summary>
    111.   /// Creates an iterator using the specified element based on an <see cref="NativeArray{T}" />.
    112.   /// </summary>
    113.   /// <param name="t1">Element.</param>
    114.   /// <param name="t2">Element.</param>
    115.   /// <param name="t3">Element.</param>
    116.   /// <param name="t4">Element.</param>
    117.   /// <param name="t5">Element.</param>
    118.   /// <param name="nativeArray">The reference to the allocated array.</param>
    119.   /// <param name="allocator">The allocator for the array.</param>
    120.   /// <typeparam name="TElement">The type of the element.</typeparam>
    121.   /// <returns>Iterator for the specified elements.</returns>
    122.   public static NativeIterator<TElement> CreateArray<TElement>(
    123.     in TElement t1, in TElement t2, in TElement t3, in TElement t4, in TElement t5, out NativeArray<TElement> nativeArray, Allocator allocator = Allocator.Temp)
    124.     where TElement : unmanaged
    125.   {
    126.     nativeArray = new NativeArray<TElement>(5, allocator);
    127.     nativeArray[0] = t1;
    128.     nativeArray[1] = t2;
    129.     nativeArray[2] = t3;
    130.     nativeArray[3] = t4;
    131.     nativeArray[4] = t5;
    132.  
    133.     return new NativeIterator<TElement>(nativeArray);
    134.   }
    135.  
    136.   /// <summary>
    137.   /// Creates an iterator using the specified element based on an <see cref="NativeArray{T}" />.
    138.   /// </summary>
    139.   /// <param name="t1">Element.</param>
    140.   /// <param name="t2">Element.</param>
    141.   /// <param name="t3">Element.</param>
    142.   /// <param name="t4">Element.</param>
    143.   /// <param name="t5">Element.</param>
    144.   /// <param name="t6">Element.</param>
    145.   /// <param name="nativeArray">The reference to the allocated array.</param>
    146.   /// <param name="allocator">The allocator for the array.</param>
    147.   /// <typeparam name="TElement">The type of the element.</typeparam>
    148.   /// <returns>Iterator for the specified elements.</returns>
    149.   public static NativeIterator<TElement> CreateArray<TElement>(
    150.     in TElement t1, in TElement t2, in TElement t3, in TElement t4, in TElement t5, in TElement t6, out NativeArray<TElement> nativeArray, Allocator allocator = Allocator.Temp)
    151.     where TElement : unmanaged
    152.   {
    153.     nativeArray = new NativeArray<TElement>(6, allocator);
    154.     nativeArray[0] = t1;
    155.     nativeArray[1] = t2;
    156.     nativeArray[2] = t3;
    157.     nativeArray[3] = t4;
    158.     nativeArray[4] = t5;
    159.     nativeArray[5] = t6;
    160.  
    161.     return new NativeIterator<TElement>(nativeArray);
    162.   }
    163.  
    164.   /// <summary>
    165.   /// Creates an iterator using the specified element based on an <see cref="NativeArray{T}" />.
    166.   /// </summary>
    167.   /// <param name="t1">Element.</param>
    168.   /// <param name="t2">Element.</param>
    169.   /// <param name="t3">Element.</param>
    170.   /// <param name="t4">Element.</param>
    171.   /// <param name="t5">Element.</param>
    172.   /// <param name="t6">Element.</param>
    173.   /// <param name="t7">Element.</param>
    174.   /// <param name="nativeArray">The reference to the allocated array.</param>
    175.   /// <param name="allocator">The allocator for the array.</param>
    176.   /// <typeparam name="TElement">The type of the element.</typeparam>
    177.   /// <returns>Iterator for the specified elements.</returns>
    178.   public static NativeIterator<TElement> CreateArray<TElement>(
    179.     in TElement t1, in TElement t2, in TElement t3, in TElement t4, in TElement t5, in TElement t6, in TElement t7, out NativeArray<TElement> nativeArray,
    180.     Allocator allocator = Allocator.Temp)
    181.     where TElement : unmanaged
    182.   {
    183.     nativeArray = new NativeArray<TElement>(7, allocator);
    184.     nativeArray[0] = t1;
    185.     nativeArray[1] = t2;
    186.     nativeArray[2] = t3;
    187.     nativeArray[3] = t4;
    188.     nativeArray[4] = t5;
    189.     nativeArray[5] = t6;
    190.     nativeArray[6] = t7;
    191.  
    192.     return new NativeIterator<TElement>(nativeArray);
    193.   }
    194.  
    195.   /// <summary>
    196.   /// Creates an iterator using the specified element based on an <see cref="NativeArray{T}" />.
    197.   /// </summary>
    198.   /// <param name="t1">Element.</param>
    199.   /// <param name="t2">Element.</param>
    200.   /// <param name="t3">Element.</param>
    201.   /// <param name="t4">Element.</param>
    202.   /// <param name="t5">Element.</param>
    203.   /// <param name="t6">Element.</param>
    204.   /// <param name="t7">Element.</param>
    205.   /// <param name="t8">Element.</param>
    206.   /// <param name="nativeArray">The reference to the allocated array.</param>
    207.   /// <param name="allocator">The allocator for the array.</param>
    208.   /// <typeparam name="TElement">The type of the element.</typeparam>
    209.   /// <returns>Iterator for the specified elements.</returns>
    210.   public static NativeIterator<TElement> CreateArray<TElement>(
    211.     in TElement t1, in TElement t2, in TElement t3, in TElement t4, in TElement t5, in TElement t6, in TElement t7, in TElement t8, out NativeArray<TElement> nativeArray,
    212.     Allocator allocator = Allocator.Temp)
    213.     where TElement : unmanaged
    214.   {
    215.     nativeArray = new NativeArray<TElement>(8, allocator);
    216.     nativeArray[0] = t1;
    217.     nativeArray[1] = t2;
    218.     nativeArray[2] = t3;
    219.     nativeArray[3] = t4;
    220.     nativeArray[4] = t5;
    221.     nativeArray[5] = t6;
    222.     nativeArray[6] = t7;
    223.     nativeArray[7] = t8;
    224.  
    225.     return new NativeIterator<TElement>(nativeArray);
    226.   }
    227.  
    228.   /// <summary>
    229.   /// Creates an iterator using the specified element based on an <see cref="FixedList32Bytes{T}" />.
    230.   /// </summary>
    231.   /// <param name="fixedList">The reference to the allocated array.</param>
    232.   /// <typeparam name="TElement">The type of the element.</typeparam>
    233.   /// <returns>Iterator for the specified elements.</returns>
    234.   public static NativeIterator<TElement> CreateFixed128<TElement>(out FixedList128Bytes<TElement> fixedList)
    235.     where TElement : unmanaged
    236.   {
    237.     fixedList = new FixedList128Bytes<TElement>();
    238.     return new NativeIterator<TElement>(fixedList);
    239.   }
    240.  
    241.   /// <summary>
    242.   /// Creates an iterator using the specified element based on an <see cref="FixedList128Bytes{T}" />.
    243.   /// </summary>
    244.   /// <param name="t1">Element.</param>
    245.   /// <param name="fixedList">The reference to the allocated array.</param>
    246.   /// <typeparam name="TElement">The type of the element.</typeparam>
    247.   /// <returns>Iterator for the specified elements.</returns>
    248.   public static NativeIterator<TElement> CreateFixed128<TElement>(in TElement t1, out FixedList128Bytes<TElement> fixedList)
    249.     where TElement : unmanaged
    250.   {
    251.     var requiredByteLength = UnsafeUtility.SizeOf<TElement>();
    252.  
    253.     if (requiredByteLength <= 128 - NativeIterator.FixedListPreliminaryBytes)
    254.     {
    255.       fixedList = new FixedList128Bytes<TElement> { t1 };
    256.  
    257.       return new NativeIterator<TElement>(fixedList);
    258.     }
    259.     else
    260.     {
    261.       var message = $"Size of fixed list is 128 (-{NativeIterator.FixedListPreliminaryBytes}) bytes but required is {requiredByteLength} bytes";
    262.       Log.Error(message);
    263.       throw new System.Data.DataException(message);
    264.     }
    265.   }
    266.  
    267.   /// <summary>
    268.   /// Creates an iterator using the specified element based on an <see cref="FixedList128Bytes{T}" />.
    269.   /// </summary>
    270.   /// <param name="t1">Element.</param>
    271.   /// <param name="t2">Element.</param>
    272.   /// <param name="fixedList">The reference to the allocated array.</param>
    273.   /// <typeparam name="TElement">The type of the element.</typeparam>
    274.   /// <returns>Iterator for the specified elements.</returns>
    275.   public static NativeIterator<TElement> CreateFixed128<TElement>(in TElement t1, in TElement t2, out FixedList128Bytes<TElement> fixedList)
    276.     where TElement : unmanaged
    277.   {
    278.     var requiredByteLength = 2 * UnsafeUtility.SizeOf<TElement>();
    279.  
    280.     if (requiredByteLength <= 128 - NativeIterator.FixedListPreliminaryBytes)
    281.     {
    282.       fixedList = new FixedList128Bytes<TElement> { t1, t2 };
    283.  
    284.       return new NativeIterator<TElement>(fixedList);
    285.     }
    286.     else
    287.     {
    288.       var message = $"Size of fixed list is 128 (-{NativeIterator.FixedListPreliminaryBytes}) bytes but required is {requiredByteLength} bytes";
    289.       Log.Error(message);
    290.       throw new System.Data.DataException(message);
    291.     }
    292.   }
    293.  
    294.   /// <summary>
    295.   /// Creates an iterator using the specified element based on an <see cref="FixedList128Bytes{T}" />.
    296.   /// </summary>
    297.   /// <param name="t1">Element.</param>
    298.   /// <param name="t2">Element.</param>
    299.   /// <param name="t3">Element.</param>
    300.   /// <param name="fixedList">The reference to the allocated array.</param>
    301.   /// <typeparam name="TElement">The type of the element.</typeparam>
    302.   /// <returns>Iterator for the specified elements.</returns>
    303.   public static NativeIterator<TElement> CreateFixed128<TElement>(in TElement t1, in TElement t2, in TElement t3, out FixedList128Bytes<TElement> fixedList)
    304.     where TElement : unmanaged
    305.   {
    306.     var requiredByteLength = 3 * UnsafeUtility.SizeOf<TElement>();
    307.  
    308.     if (requiredByteLength <= 128 - NativeIterator.FixedListPreliminaryBytes)
    309.     {
    310.       fixedList = new FixedList128Bytes<TElement> { t1, t2, t3 };
    311.  
    312.       return new NativeIterator<TElement>(fixedList);
    313.     }
    314.     else
    315.     {
    316.       var message = $"Size of fixed list is 128 (-{NativeIterator.FixedListPreliminaryBytes}) bytes but required is {requiredByteLength} bytes";
    317.       Log.Error(message);
    318.       throw new System.Data.DataException(message);
    319.     }
    320.   }
    321.  
    322.   /// <summary>
    323.   /// Creates an iterator using the specified element based on an <see cref="FixedList128Bytes{T}" />.
    324.   /// </summary>
    325.   /// <param name="t1">Element.</param>
    326.   /// <param name="t2">Element.</param>
    327.   /// <param name="t3">Element.</param>
    328.   /// <param name="t4">Element.</param>
    329.   /// <param name="fixedList">The reference to the allocated array.</param>
    330.   /// <typeparam name="TElement">The type of the element.</typeparam>
    331.   /// <returns>Iterator for the specified elements.</returns>
    332.   public static NativeIterator<TElement> CreateFixed128<TElement>(in TElement t1, in TElement t2, in TElement t3, in TElement t4, out FixedList128Bytes<TElement> fixedList)
    333.     where TElement : unmanaged
    334.   {
    335.     var requiredByteLength = 4 * UnsafeUtility.SizeOf<TElement>();
    336.  
    337.     if (requiredByteLength <= 128 - NativeIterator.FixedListPreliminaryBytes)
    338.     {
    339.       fixedList = new FixedList128Bytes<TElement> { t1, t2, t3, t4 };
    340.  
    341.       return new NativeIterator<TElement>(fixedList);
    342.     }
    343.     else
    344.     {
    345.       var message = $"Size of fixed list is 128 (-{NativeIterator.FixedListPreliminaryBytes}) bytes but required is {requiredByteLength} bytes";
    346.       Log.Error(message);
    347.       throw new System.Data.DataException(message);
    348.     }
    349.   }
    350.  
    351.   /// <summary>
    352.   /// Creates an iterator using the specified element based on an <see cref="FixedList128Bytes{T}" />.
    353.   /// </summary>
    354.   /// <param name="t1">Element.</param>
    355.   /// <param name="t2">Element.</param>
    356.   /// <param name="t3">Element.</param>
    357.   /// <param name="t4">Element.</param>
    358.   /// <param name="t5">Element.</param>
    359.   /// <param name="fixedList">The reference to the allocated array.</param>
    360.   /// <typeparam name="TElement">The type of the element.</typeparam>
    361.   /// <returns>Iterator for the specified elements.</returns>
    362.   public static NativeIterator<TElement> CreateFixed128<TElement>(
    363.     in TElement t1, in TElement t2, in TElement t3, in TElement t4, in TElement t5, out FixedList128Bytes<TElement> fixedList)
    364.     where TElement : unmanaged
    365.   {
    366.     var requiredByteLength = 5 * UnsafeUtility.SizeOf<TElement>();
    367.  
    368.     if (requiredByteLength <= 128 - NativeIterator.FixedListPreliminaryBytes)
    369.     {
    370.       fixedList = new FixedList128Bytes<TElement> { t1, t2, t3, t4, t5 };
    371.  
    372.       return new NativeIterator<TElement>(fixedList);
    373.     }
    374.     else
    375.     {
    376.       var message = $"Size of fixed list is 128 (-{NativeIterator.FixedListPreliminaryBytes}) bytes but required is {requiredByteLength} bytes";
    377.       Log.Error(message);
    378.       throw new System.Data.DataException(message);
    379.     }
    380.   }
    381.  
    382.   /// <summary>
    383.   /// Creates an iterator using the specified element based on an <see cref="FixedList128Bytes{T}" />.
    384.   /// </summary>
    385.   /// <param name="t1">Element.</param>
    386.   /// <param name="t2">Element.</param>
    387.   /// <param name="t3">Element.</param>
    388.   /// <param name="t4">Element.</param>
    389.   /// <param name="t5">Element.</param>
    390.   /// <param name="t6">Element.</param>
    391.   /// <param name="fixedList">The reference to the allocated array.</param>
    392.   /// <typeparam name="TElement">The type of the element.</typeparam>
    393.   /// <returns>Iterator for the specified elements.</returns>
    394.   public static NativeIterator<TElement> CreateFixed128<TElement>(
    395.     in TElement t1, in TElement t2, in TElement t3, in TElement t4, in TElement t5, in TElement t6, out FixedList128Bytes<TElement> fixedList)
    396.     where TElement : unmanaged
    397.   {
    398.     var requiredByteLength = 6 * UnsafeUtility.SizeOf<TElement>();
    399.  
    400.     if (requiredByteLength <= 128 - NativeIterator.FixedListPreliminaryBytes)
    401.     {
    402.       fixedList = new FixedList128Bytes<TElement> { t1, t2, t3, t4, t5, t6 };
    403.  
    404.       return new NativeIterator<TElement>(fixedList);
    405.     }
    406.     else
    407.     {
    408.       var message = $"Size of fixed list is 128 (-{NativeIterator.FixedListPreliminaryBytes}) bytes but required is {requiredByteLength} bytes";
    409.       Log.Error(message);
    410.       throw new System.Data.DataException(message);
    411.     }
    412.   }
    413.  
    414.   /// <summary>
    415.   /// Creates an iterator using the specified element based on an <see cref="FixedList128Bytes{T}" />.
    416.   /// </summary>
    417.   /// <param name="t1">Element.</param>
    418.   /// <param name="t2">Element.</param>
    419.   /// <param name="t3">Element.</param>
    420.   /// <param name="t4">Element.</param>
    421.   /// <param name="t5">Element.</param>
    422.   /// <param name="t6">Element.</param>
    423.   /// <param name="t7">Element.</param>
    424.   /// <param name="fixedList">The reference to the allocated array.</param>
    425.   /// <typeparam name="TElement">The type of the element.</typeparam>
    426.   /// <returns>Iterator for the specified elements.</returns>
    427.   public static NativeIterator<TElement> CreateFixed128<TElement>(
    428.     in TElement t1, in TElement t2, in TElement t3, in TElement t4, in TElement t5, in TElement t6, in TElement t7, out FixedList128Bytes<TElement> fixedList)
    429.     where TElement : unmanaged
    430.   {
    431.     var requiredByteLength = 7 * UnsafeUtility.SizeOf<TElement>();
    432.  
    433.     if (requiredByteLength <= 128 - NativeIterator.FixedListPreliminaryBytes)
    434.     {
    435.       fixedList = new FixedList128Bytes<TElement> { t1, t2, t3, t4, t5, t6, t7 };
    436.  
    437.       return new NativeIterator<TElement>(fixedList);
    438.     }
    439.     else
    440.     {
    441.       var message = $"Size of fixed list is 128 (-{NativeIterator.FixedListPreliminaryBytes}) bytes but required is {requiredByteLength} bytes";
    442.       Log.Error(message);
    443.       throw new System.Data.DataException(message);
    444.     }
    445.   }
    446.  
    447.   /// <summary>
    448.   /// Creates an iterator using the specified element based on an <see cref="FixedList128Bytes{T}" />.
    449.   /// </summary>
    450.   /// <param name="t1">Element.</param>
    451.   /// <param name="t2">Element.</param>
    452.   /// <param name="t3">Element.</param>
    453.   /// <param name="t4">Element.</param>
    454.   /// <param name="t5">Element.</param>
    455.   /// <param name="t6">Element.</param>
    456.   /// <param name="t7">Element.</param>
    457.   /// <param name="t8">Element.</param>
    458.   /// <param name="fixedList">The reference to the allocated array.</param>
    459.   /// <typeparam name="TElement">The type of the element.</typeparam>
    460.   /// <returns>Iterator for the specified elements.</returns>
    461.   public static NativeIterator<TElement> CreateFixed128<TElement>(
    462.     in TElement t1, in TElement t2, in TElement t3, in TElement t4, in TElement t5, in TElement t6, in TElement t7, in TElement t8, out FixedList128Bytes<TElement> fixedList)
    463.     where TElement : unmanaged
    464.   {
    465.     var requiredByteLength = 8 * UnsafeUtility.SizeOf<TElement>();
    466.  
    467.     if (requiredByteLength <= 128 - NativeIterator.FixedListPreliminaryBytes)
    468.     {
    469.       fixedList = new FixedList128Bytes<TElement> { t1, t2, t3, t4, t5, t6, t7, t8 };
    470.  
    471.       return new NativeIterator<TElement>(fixedList);
    472.     }
    473.     else
    474.     {
    475.       var message = $"Size of fixed list is 128 (-{NativeIterator.FixedListPreliminaryBytes}) bytes but required is {requiredByteLength} bytes";
    476.       Log.Error(message);
    477.       throw new System.Data.DataException(message);
    478.     }
    479.   }
    480.  
    481.   /// <summary>
    482.   /// Creates an iterator using the specified element based on an <see cref="FixedList32Bytes{T}" />.
    483.   /// </summary>
    484.   /// <param name="fixedList">The reference to the allocated array.</param>
    485.   /// <typeparam name="TElement">The type of the element.</typeparam>
    486.   /// <returns>Iterator for the specified elements.</returns>
    487.   public static NativeIterator<TElement> CreateFixed32<TElement>(out FixedList32Bytes<TElement> fixedList)
    488.     where TElement : unmanaged
    489.   {
    490.     fixedList = new FixedList32Bytes<TElement>();
    491.     return new NativeIterator<TElement>(fixedList);
    492.   }
    493.  
    494.   /// <summary>
    495.   /// Creates an iterator using the specified element based on an <see cref="FixedList32Bytes{T}" />.
    496.   /// </summary>
    497.   /// <param name="t1">Element.</param>
    498.   /// <param name="fixedList">The reference to the allocated array.</param>
    499.   /// <typeparam name="TElement">The type of the element.</typeparam>
    500.   /// <returns>Iterator for the specified elements.</returns>
    501.   public static NativeIterator<TElement> CreateFixed32<TElement>(in TElement t1, out FixedList32Bytes<TElement> fixedList)
    502.     where TElement : unmanaged
    503.   {
    504.     var requiredByteLength = UnsafeUtility.SizeOf<TElement>();
    505.  
    506.     if (requiredByteLength <= 32 - NativeIterator.FixedListPreliminaryBytes)
    507.     {
    508.       fixedList = new FixedList32Bytes<TElement> { t1 };
    509.  
    510.       return new NativeIterator<TElement>(fixedList);
    511.     }
    512.     else
    513.     {
    514.       var message = $"Size of fixed list is 32 (-{NativeIterator.FixedListPreliminaryBytes}) bytes but required is {requiredByteLength} bytes";
    515.       Log.Error(message);
    516.       throw new System.Data.DataException(message);
    517.     }
    518.   }
    519.  
    520.   /// <summary>
    521.   /// Creates an iterator using the specified element based on an <see cref="FixedList32Bytes{T}" />.
    522.   /// </summary>
    523.   /// <param name="t1">Element.</param>
    524.   /// <param name="t2">Element.</param>
    525.   /// <param name="fixedList">The reference to the allocated array.</param>
    526.   /// <typeparam name="TElement">The type of the element.</typeparam>
    527.   /// <returns>Iterator for the specified elements.</returns>
    528.   public static NativeIterator<TElement> CreateFixed32<TElement>(in TElement t1, in TElement t2, out FixedList32Bytes<TElement> fixedList)
    529.     where TElement : unmanaged
    530.   {
    531.     var requiredByteLength = 2 * UnsafeUtility.SizeOf<TElement>();
    532.  
    533.     if (requiredByteLength <= 32 - NativeIterator.FixedListPreliminaryBytes)
    534.     {
    535.       fixedList = new FixedList32Bytes<TElement> { t1, t2 };
    536.  
    537.       return new NativeIterator<TElement>(fixedList);
    538.     }
    539.     else
    540.     {
    541.       var message = $"Size of fixed list is 32 (-{NativeIterator.FixedListPreliminaryBytes}) bytes but required is {requiredByteLength} bytes";
    542.       Log.Error(message);
    543.       throw new System.Data.DataException(message);
    544.     }
    545.   }
    546.  
    547.   /// <summary>
    548.   /// Creates an iterator using the specified element based on an <see cref="FixedList32Bytes{T}" />.
    549.   /// </summary>
    550.   /// <param name="t1">Element.</param>
    551.   /// <param name="t2">Element.</param>
    552.   /// <param name="t3">Element.</param>
    553.   /// <param name="fixedList">The reference to the allocated array.</param>
    554.   /// <typeparam name="TElement">The type of the element.</typeparam>
    555.   /// <returns>Iterator for the specified elements.</returns>
    556.   public static NativeIterator<TElement> CreateFixed32<TElement>(in TElement t1, in TElement t2, in TElement t3, out FixedList32Bytes<TElement> fixedList)
    557.     where TElement : unmanaged
    558.   {
    559.     var requiredByteLength = 3 * UnsafeUtility.SizeOf<TElement>();
    560.  
    561.     if (requiredByteLength <= 32 - NativeIterator.FixedListPreliminaryBytes)
    562.     {
    563.       fixedList = new FixedList32Bytes<TElement> { t1, t2, t3 };
    564.  
    565.       return new NativeIterator<TElement>(fixedList);
    566.     }
    567.     else
    568.     {
    569.       var message = $"Size of fixed list is 32 (-{NativeIterator.FixedListPreliminaryBytes}) bytes but required is {requiredByteLength} bytes";
    570.       Log.Error(message);
    571.       throw new System.Data.DataException(message);
    572.     }
    573.   }
    574.  
    575.   /// <summary>
    576.   /// Creates an iterator using the specified element based on an <see cref="FixedList32Bytes{T}" />.
    577.   /// </summary>
    578.   /// <param name="t1">Element.</param>
    579.   /// <param name="t2">Element.</param>
    580.   /// <param name="t3">Element.</param>
    581.   /// <param name="t4">Element.</param>
    582.   /// <param name="fixedList">The reference to the allocated array.</param>
    583.   /// <typeparam name="TElement">The type of the element.</typeparam>
    584.   /// <returns>Iterator for the specified elements.</returns>
    585.   public static NativeIterator<TElement> CreateFixed32<TElement>(in TElement t1, in TElement t2, in TElement t3, in TElement t4, out FixedList32Bytes<TElement> fixedList)
    586.     where TElement : unmanaged
    587.   {
    588.     var requiredByteLength = 4 * UnsafeUtility.SizeOf<TElement>();
    589.  
    590.     if (requiredByteLength <= 32 - NativeIterator.FixedListPreliminaryBytes)
    591.     {
    592.       fixedList = new FixedList32Bytes<TElement> { t1, t2, t3, t4 };
    593.  
    594.       return new NativeIterator<TElement>(fixedList);
    595.     }
    596.     else
    597.     {
    598.       var message = $"Size of fixed list is 32 (-{NativeIterator.FixedListPreliminaryBytes}) bytes but required is {requiredByteLength} bytes";
    599.       Log.Error(message);
    600.       throw new System.Data.DataException(message);
    601.     }
    602.   }
    603.  
    604.   /// <summary>
    605.   /// Creates an iterator using the specified element based on an <see cref="FixedList32Bytes{T}" />.
    606.   /// </summary>
    607.   /// <param name="t1">Element.</param>
    608.   /// <param name="t2">Element.</param>
    609.   /// <param name="t3">Element.</param>
    610.   /// <param name="t4">Element.</param>
    611.   /// <param name="t5">Element.</param>
    612.   /// <param name="fixedList">The reference to the allocated array.</param>
    613.   /// <typeparam name="TElement">The type of the element.</typeparam>
    614.   /// <returns>Iterator for the specified elements.</returns>
    615.   public static NativeIterator<TElement> CreateFixed32<TElement>(
    616.     in TElement t1, in TElement t2, in TElement t3, in TElement t4, in TElement t5, out FixedList32Bytes<TElement> fixedList)
    617.     where TElement : unmanaged
    618.   {
    619.     var requiredByteLength = 5 * UnsafeUtility.SizeOf<TElement>();
    620.  
    621.     if (requiredByteLength <= 32 - NativeIterator.FixedListPreliminaryBytes)
    622.     {
    623.       fixedList = new FixedList32Bytes<TElement> { t1, t2, t3, t4, t5 };
    624.  
    625.       return new NativeIterator<TElement>(fixedList);
    626.     }
    627.     else
    628.     {
    629.       var message = $"Size of fixed list is 32 (-{NativeIterator.FixedListPreliminaryBytes}) bytes but required is {requiredByteLength} bytes";
    630.       Log.Error(message);
    631.       throw new System.Data.DataException(message);
    632.     }
    633.   }
    634.  
    635.   /// <summary>
    636.   /// Creates an iterator using the specified element based on an <see cref="FixedList32Bytes{T}" />.
    637.   /// </summary>
    638.   /// <param name="t1">Element.</param>
    639.   /// <param name="t2">Element.</param>
    640.   /// <param name="t3">Element.</param>
    641.   /// <param name="t4">Element.</param>
    642.   /// <param name="t5">Element.</param>
    643.   /// <param name="t6">Element.</param>
    644.   /// <param name="fixedList">The reference to the allocated array.</param>
    645.   /// <typeparam name="TElement">The type of the element.</typeparam>
    646.   /// <returns>Iterator for the specified elements.</returns>
    647.   public static NativeIterator<TElement> CreateFixed32<TElement>(
    648.     in TElement t1, in TElement t2, in TElement t3, in TElement t4, in TElement t5, in TElement t6, out FixedList32Bytes<TElement> fixedList)
    649.     where TElement : unmanaged
    650.   {
    651.     var requiredByteLength = 6 * UnsafeUtility.SizeOf<TElement>();
    652.  
    653.     if (requiredByteLength <= 32 - NativeIterator.FixedListPreliminaryBytes)
    654.     {
    655.       fixedList = new FixedList32Bytes<TElement> { t1, t2, t3, t4, t5, t6 };
    656.  
    657.       return new NativeIterator<TElement>(fixedList);
    658.     }
    659.     else
    660.     {
    661.       var message = $"Size of fixed list is 32 (-{NativeIterator.FixedListPreliminaryBytes}) bytes but required is {requiredByteLength} bytes";
    662.       Log.Error(message);
    663.       throw new System.Data.DataException(message);
    664.     }
    665.   }
    666.  
    667.   /// <summary>
    668.   /// Creates an iterator using the specified element based on an <see cref="FixedList32Bytes{T}" />.
    669.   /// </summary>
    670.   /// <param name="t1">Element.</param>
    671.   /// <param name="t2">Element.</param>
    672.   /// <param name="t3">Element.</param>
    673.   /// <param name="t4">Element.</param>
    674.   /// <param name="t5">Element.</param>
    675.   /// <param name="t6">Element.</param>
    676.   /// <param name="t7">Element.</param>
    677.   /// <param name="fixedList">The reference to the allocated array.</param>
    678.   /// <typeparam name="TElement">The type of the element.</typeparam>
    679.   /// <returns>Iterator for the specified elements.</returns>
    680.   public static NativeIterator<TElement> CreateFixed32<TElement>(
    681.     in TElement t1, in TElement t2, in TElement t3, in TElement t4, in TElement t5, in TElement t6, in TElement t7, out FixedList32Bytes<TElement> fixedList)
    682.     where TElement : unmanaged
    683.   {
    684.     var requiredByteLength = 7 * UnsafeUtility.SizeOf<TElement>();
    685.  
    686.     if (requiredByteLength <= 32 - NativeIterator.FixedListPreliminaryBytes)
    687.     {
    688.       fixedList = new FixedList32Bytes<TElement> { t1, t2, t3, t4, t5, t6, t7 };
    689.  
    690.       return new NativeIterator<TElement>(fixedList);
    691.     }
    692.     else
    693.     {
    694.       var message = $"Size of fixed list is 32 (-{NativeIterator.FixedListPreliminaryBytes}) bytes but required is {requiredByteLength} bytes";
    695.       Log.Error(message);
    696.       throw new System.Data.DataException(message);
    697.     }
    698.   }
    699.  
    700.   /// <summary>
    701.   /// Creates an iterator using the specified element based on an <see cref="FixedList32Bytes{T}" />.
    702.   /// </summary>
    703.   /// <param name="t1">Element.</param>
    704.   /// <param name="t2">Element.</param>
    705.   /// <param name="t3">Element.</param>
    706.   /// <param name="t4">Element.</param>
    707.   /// <param name="t5">Element.</param>
    708.   /// <param name="t6">Element.</param>
    709.   /// <param name="t7">Element.</param>
    710.   /// <param name="t8">Element.</param>
    711.   /// <param name="fixedList">The reference to the allocated array.</param>
    712.   /// <typeparam name="TElement">The type of the element.</typeparam>
    713.   /// <returns>Iterator for the specified elements.</returns>
    714.   public static NativeIterator<TElement> CreateFixed32<TElement>(
    715.     in TElement t1, in TElement t2, in TElement t3, in TElement t4, in TElement t5, in TElement t6, in TElement t7, in TElement t8, out FixedList32Bytes<TElement> fixedList)
    716.     where TElement : unmanaged
    717.   {
    718.     var requiredByteLength = 8 * UnsafeUtility.SizeOf<TElement>();
    719.  
    720.     if (requiredByteLength <= 32 - NativeIterator.FixedListPreliminaryBytes)
    721.     {
    722.       fixedList = new FixedList32Bytes<TElement> { t1, t2, t3, t4, t5, t6, t7, t8 };
    723.  
    724.       return new NativeIterator<TElement>(fixedList);
    725.     }
    726.     else
    727.     {
    728.       var message = $"Size of fixed list is 32 (-{NativeIterator.FixedListPreliminaryBytes}) bytes but required is {requiredByteLength} bytes";
    729.       Log.Error(message);
    730.       throw new System.Data.DataException(message);
    731.     }
    732.   }
    733.  
    734.   /// <summary>
    735.   /// Creates an iterator using the specified element based on an <see cref="FixedList512Bytes{T}" />.
    736.   /// </summary>
    737.   /// <param name="fixedList">The reference to the allocated array.</param>
    738.   /// <typeparam name="TElement">The type of the element.</typeparam>
    739.   /// <returns>Iterator for the specified elements.</returns>
    740.   public static NativeIterator<TElement> CreateFixed4096<TElement>(out FixedList4096Bytes<TElement> fixedList)
    741.     where TElement : unmanaged
    742.   {
    743.     fixedList = new FixedList4096Bytes<TElement>();
    744.     return new NativeIterator<TElement>(fixedList);
    745.   }
    746.  
    747.   /// <summary>
    748.   /// Creates an iterator using the specified element based on an <see cref="FixedList4096Bytes{T}" />.
    749.   /// </summary>
    750.   /// <param name="t1">Element.</param>
    751.   /// <param name="fixedList">The reference to the allocated array.</param>
    752.   /// <typeparam name="TElement">The type of the element.</typeparam>
    753.   /// <returns>Iterator for the specified elements.</returns>
    754.   public static NativeIterator<TElement> CreateFixed4096<TElement>(in TElement t1, out FixedList4096Bytes<TElement> fixedList)
    755.     where TElement : unmanaged
    756.   {
    757.     var requiredByteLength = UnsafeUtility.SizeOf<TElement>();
    758.  
    759.     if (requiredByteLength <= 4096 - NativeIterator.FixedListPreliminaryBytes)
    760.     {
    761.       fixedList = new FixedList4096Bytes<TElement> { t1 };
    762.  
    763.       return new NativeIterator<TElement>(fixedList);
    764.     }
    765.     else
    766.     {
    767.       var message = $"Size of fixed list is 4096 (-{NativeIterator.FixedListPreliminaryBytes}) bytes but required is {requiredByteLength} bytes";
    768.       Log.Error(message);
    769.       throw new System.Data.DataException(message);
    770.     }
    771.   }
    772.  
    773.   /// <summary>
    774.   /// Creates an iterator using the specified element based on an <see cref="FixedList4096Bytes{T}" />.
    775.   /// </summary>
    776.   /// <param name="t1">Element.</param>
    777.   /// <param name="t2">Element.</param>
    778.   /// <param name="fixedList">The reference to the allocated array.</param>
    779.   /// <typeparam name="TElement">The type of the element.</typeparam>
    780.   /// <returns>Iterator for the specified elements.</returns>
    781.   public static NativeIterator<TElement> CreateFixed4096<TElement>(in TElement t1, in TElement t2, out FixedList4096Bytes<TElement> fixedList)
    782.     where TElement : unmanaged
    783.   {
    784.     var requiredByteLength = 2 * UnsafeUtility.SizeOf<TElement>();
    785.  
    786.     if (requiredByteLength <= 4096 - NativeIterator.FixedListPreliminaryBytes)
    787.     {
    788.       fixedList = new FixedList4096Bytes<TElement> { t1, t2 };
    789.  
    790.       return new NativeIterator<TElement>(fixedList);
    791.     }
    792.     else
    793.     {
    794.       var message = $"Size of fixed list is 4096 (-{NativeIterator.FixedListPreliminaryBytes}) bytes but required is {requiredByteLength} bytes";
    795.       Log.Error(message);
    796.       throw new System.Data.DataException(message);
    797.     }
    798.   }
    799.  
    800.   /// <summary>
    801.   /// Creates an iterator using the specified element based on an <see cref="FixedList4096Bytes{T}" />.
    802.   /// </summary>
    803.   /// <param name="t1">Element.</param>
    804.   /// <param name="t2">Element.</param>
    805.   /// <param name="t3">Element.</param>
    806.   /// <param name="fixedList">The reference to the allocated array.</param>
    807.   /// <typeparam name="TElement">The type of the element.</typeparam>
    808.   /// <returns>Iterator for the specified elements.</returns>
    809.   public static NativeIterator<TElement> CreateFixed4096<TElement>(in TElement t1, in TElement t2, in TElement t3, out FixedList4096Bytes<TElement> fixedList)
    810.     where TElement : unmanaged
    811.   {
    812.     var requiredByteLength = 3 * UnsafeUtility.SizeOf<TElement>();
    813.  
    814.     if (requiredByteLength <= 4096 - NativeIterator.FixedListPreliminaryBytes)
    815.     {
    816.       fixedList = new FixedList4096Bytes<TElement> { t1, t2, t3 };
    817.  
    818.       return new NativeIterator<TElement>(fixedList);
    819.     }
    820.     else
    821.     {
    822.       var message = $"Size of fixed list is 4096 (-{NativeIterator.FixedListPreliminaryBytes}) bytes but required is {requiredByteLength} bytes";
    823.       Log.Error(message);
    824.       throw new System.Data.DataException(message);
    825.     }
    826.   }
    827.  
    828.   /// <summary>
    829.   /// Creates an iterator using the specified element based on an <see cref="FixedList4096Bytes{T}" />.
    830.   /// </summary>
    831.   /// <param name="t1">Element.</param>
    832.   /// <param name="t2">Element.</param>
    833.   /// <param name="t3">Element.</param>
    834.   /// <param name="t4">Element.</param>
    835.   /// <param name="fixedList">The reference to the allocated array.</param>
    836.   /// <typeparam name="TElement">The type of the element.</typeparam>
    837.   /// <returns>Iterator for the specified elements.</returns>
    838.   public static NativeIterator<TElement> CreateFixed4096<TElement>(in TElement t1, in TElement t2, in TElement t3, in TElement t4, out FixedList4096Bytes<TElement> fixedList)
    839.     where TElement : unmanaged
    840.   {
    841.     var requiredByteLength = 4 * UnsafeUtility.SizeOf<TElement>();
    842.  
    843.     if (requiredByteLength <= 4096 - NativeIterator.FixedListPreliminaryBytes)
    844.     {
    845.       fixedList = new FixedList4096Bytes<TElement> { t1, t2, t3, t4 };
    846.  
    847.       return new NativeIterator<TElement>(fixedList);
    848.     }
    849.     else
    850.     {
    851.       var message = $"Size of fixed list is 4096 (-{NativeIterator.FixedListPreliminaryBytes}) bytes but required is {requiredByteLength} bytes";
    852.       Log.Error(message);
    853.       throw new System.Data.DataException(message);
    854.     }
    855.   }
    856.  
    857.   /// <summary>
    858.   /// Creates an iterator using the specified element based on an <see cref="FixedList4096Bytes{T}" />.
    859.   /// </summary>
    860.   /// <param name="t1">Element.</param>
    861.   /// <param name="t2">Element.</param>
    862.   /// <param name="t3">Element.</param>
    863.   /// <param name="t4">Element.</param>
    864.   /// <param name="t5">Element.</param>
    865.   /// <param name="fixedList">The reference to the allocated array.</param>
    866.   /// <typeparam name="TElement">The type of the element.</typeparam>
    867.   /// <returns>Iterator for the specified elements.</returns>
    868.   public static NativeIterator<TElement> CreateFixed4096<TElement>(
    869.     in TElement t1, in TElement t2, in TElement t3, in TElement t4, in TElement t5, out FixedList4096Bytes<TElement> fixedList)
    870.     where TElement : unmanaged
    871.   {
    872.     var requiredByteLength = 5 * UnsafeUtility.SizeOf<TElement>();
    873.  
    874.     if (requiredByteLength <= 4096 - NativeIterator.FixedListPreliminaryBytes)
    875.     {
    876.       fixedList = new FixedList4096Bytes<TElement> { t1, t2, t3, t4, t5 };
    877.  
    878.       return new NativeIterator<TElement>(fixedList);
    879.     }
    880.     else
    881.     {
    882.       var message = $"Size of fixed list is 4096 (-{NativeIterator.FixedListPreliminaryBytes}) bytes but required is {requiredByteLength} bytes";
    883.       Log.Error(message);
    884.       throw new System.Data.DataException(message);
    885.     }
    886.   }
    887.  
    888.   /// <summary>
    889.   /// Creates an iterator using the specified element based on an <see cref="FixedList4096Bytes{T}" />.
    890.   /// </summary>
    891.   /// <param name="t1">Element.</param>
    892.   /// <param name="t2">Element.</param>
    893.   /// <param name="t3">Element.</param>
    894.   /// <param name="t4">Element.</param>
    895.   /// <param name="t5">Element.</param>
    896.   /// <param name="t6">Element.</param>
    897.   /// <param name="fixedList">The reference to the allocated array.</param>
    898.   /// <typeparam name="TElement">The type of the element.</typeparam>
    899.   /// <returns>Iterator for the specified elements.</returns>
    900.   public static NativeIterator<TElement> CreateFixed4096<TElement>(
    901.     in TElement t1, in TElement t2, in TElement t3, in TElement t4, in TElement t5, in TElement t6, out FixedList4096Bytes<TElement> fixedList)
    902.     where TElement : unmanaged
    903.   {
    904.     var requiredByteLength = 6 * UnsafeUtility.SizeOf<TElement>();
    905.  
    906.     if (requiredByteLength <= 4096 - NativeIterator.FixedListPreliminaryBytes)
    907.     {
    908.       fixedList = new FixedList4096Bytes<TElement> { t1, t2, t3, t4, t5, t6 };
    909.  
    910.       return new NativeIterator<TElement>(fixedList);
    911.     }
    912.     else
    913.     {
    914.       var message = $"Size of fixed list is 4096 (-{NativeIterator.FixedListPreliminaryBytes}) bytes but required is {requiredByteLength} bytes";
    915.       Log.Error(message);
    916.       throw new System.Data.DataException(message);
    917.     }
    918.   }
    919.  
    920.   /// <summary>
    921.   /// Creates an iterator using the specified element based on an <see cref="FixedList4096Bytes{T}" />.
    922.   /// </summary>
    923.   /// <param name="t1">Element.</param>
    924.   /// <param name="t2">Element.</param>
    925.   /// <param name="t3">Element.</param>
    926.   /// <param name="t4">Element.</param>
    927.   /// <param name="t5">Element.</param>
    928.   /// <param name="t6">Element.</param>
    929.   /// <param name="t7">Element.</param>
    930.   /// <param name="fixedList">The reference to the allocated array.</param>
    931.   /// <typeparam name="TElement">The type of the element.</typeparam>
    932.   /// <returns>Iterator for the specified elements.</returns>
    933.   public static NativeIterator<TElement> CreateFixed4096<TElement>(
    934.     in TElement t1, in TElement t2, in TElement t3, in TElement t4, in TElement t5, in TElement t6, in TElement t7, out FixedList4096Bytes<TElement> fixedList)
    935.     where TElement : unmanaged
    936.   {
    937.     var requiredByteLength = 7 * UnsafeUtility.SizeOf<TElement>();
    938.  
    939.     if (requiredByteLength <= 4096 - NativeIterator.FixedListPreliminaryBytes)
    940.     {
    941.       fixedList = new FixedList4096Bytes<TElement> { t1, t2, t3, t4, t5, t6, t7 };
    942.  
    943.       return new NativeIterator<TElement>(fixedList);
    944.     }
    945.     else
    946.     {
    947.       var message = $"Size of fixed list is 4096 (-{NativeIterator.FixedListPreliminaryBytes}) bytes but required is {requiredByteLength} bytes";
    948.       Log.Error(message);
    949.       throw new System.Data.DataException(message);
    950.     }
    951.   }
    952.  
    953.   /// <summary>
    954.   /// Creates an iterator using the specified element based on an <see cref="FixedList4096Bytes{T}" />.
    955.   /// </summary>
    956.   /// <param name="t1">Element.</param>
    957.   /// <param name="t2">Element.</param>
    958.   /// <param name="t3">Element.</param>
    959.   /// <param name="t4">Element.</param>
    960.   /// <param name="t5">Element.</param>
    961.   /// <param name="t6">Element.</param>
    962.   /// <param name="t7">Element.</param>
    963.   /// <param name="t8">Element.</param>
    964.   /// <param name="fixedList">The reference to the allocated array.</param>
    965.   /// <typeparam name="TElement">The type of the element.</typeparam>
    966.   /// <returns>Iterator for the specified elements.</returns>
    967.   public static NativeIterator<TElement> CreateFixed4096<TElement>(
    968.     in TElement t1, in TElement t2, in TElement t3, in TElement t4, in TElement t5, in TElement t6, in TElement t7, in TElement t8, out FixedList4096Bytes<TElement> fixedList)
    969.     where TElement : unmanaged
    970.   {
    971.     var requiredByteLength = 8 * UnsafeUtility.SizeOf<TElement>();
    972.  
    973.     if (requiredByteLength <= 4096 - NativeIterator.FixedListPreliminaryBytes)
    974.     {
    975.       fixedList = new FixedList4096Bytes<TElement> { t1, t2, t3, t4, t5, t6, t7, t8 };
    976.  
    977.       return new NativeIterator<TElement>(fixedList);
    978.     }
    979.     else
    980.     {
    981.       var message = $"Size of fixed list is 4096 (-{NativeIterator.FixedListPreliminaryBytes}) bytes but required is {requiredByteLength} bytes";
    982.       Log.Error(message);
    983.       throw new System.Data.DataException(message);
    984.     }
    985.   }
    986.  
    987.   /// <summary>
    988.   /// Creates an iterator using the specified element based on an <see cref="FixedList512Bytes{T}" />.
    989.   /// </summary>
    990.   /// <param name="fixedList">The reference to the allocated array.</param>
    991.   /// <typeparam name="TElement">The type of the element.</typeparam>
    992.   /// <returns>Iterator for the specified elements.</returns>
    993.   public static NativeIterator<TElement> CreateFixed512<TElement>(out FixedList512Bytes<TElement> fixedList)
    994.     where TElement : unmanaged
    995.   {
    996.     fixedList = new FixedList512Bytes<TElement>();
    997.     return new NativeIterator<TElement>(fixedList);
    998.   }
    999.  
    1000.   /// <summary>
    1001.   /// Creates an iterator using the specified element based on an <see cref="FixedList512Bytes{T}" />.
    1002.   /// </summary>
    1003.   /// <param name="t1">Element.</param>
    1004.   /// <param name="fixedList">The reference to the allocated array.</param>
    1005.   /// <typeparam name="TElement">The type of the element.</typeparam>
    1006.   /// <returns>Iterator for the specified elements.</returns>
    1007.   public static NativeIterator<TElement> CreateFixed512<TElement>(in TElement t1, out FixedList512Bytes<TElement> fixedList)
    1008.     where TElement : unmanaged
    1009.   {
    1010.     var requiredByteLength = UnsafeUtility.SizeOf<TElement>();
    1011.  
    1012.     if (requiredByteLength <= 512 - NativeIterator.FixedListPreliminaryBytes)
    1013.     {
    1014.       fixedList = new FixedList512Bytes<TElement> { t1 };
    1015.  
    1016.       return new NativeIterator<TElement>(fixedList);
    1017.     }
    1018.     else
    1019.     {
    1020.       var message = $"Size of fixed list is 512 (-{NativeIterator.FixedListPreliminaryBytes}) bytes but required is {requiredByteLength} bytes";
    1021.       Log.Error(message);
    1022.       throw new System.Data.DataException(message);
    1023.     }
    1024.   }
    1025.  
    1026.   /// <summary>
    1027.   /// Creates an iterator using the specified element based on an <see cref="FixedList512Bytes{T}" />.
    1028.   /// </summary>
    1029.   /// <param name="t1">Element.</param>
    1030.   /// <param name="t2">Element.</param>
    1031.   /// <param name="fixedList">The reference to the allocated array.</param>
    1032.   /// <typeparam name="TElement">The type of the element.</typeparam>
    1033.   /// <returns>Iterator for the specified elements.</returns>
    1034.   public static NativeIterator<TElement> CreateFixed512<TElement>(in TElement t1, in TElement t2, out FixedList512Bytes<TElement> fixedList)
    1035.     where TElement : unmanaged
    1036.   {
    1037.     var requiredByteLength = 2 * UnsafeUtility.SizeOf<TElement>();
    1038.  
    1039.     if (requiredByteLength <= 512 - NativeIterator.FixedListPreliminaryBytes)
    1040.     {
    1041.       fixedList = new FixedList512Bytes<TElement> { t1, t2 };
    1042.  
    1043.       return new NativeIterator<TElement>(fixedList);
    1044.     }
    1045.     else
    1046.     {
    1047.       var message = $"Size of fixed list is 512 (-{NativeIterator.FixedListPreliminaryBytes}) bytes but required is {requiredByteLength} bytes";
    1048.       Log.Error(message);
    1049.       throw new System.Data.DataException(message);
    1050.     }
    1051.   }
    1052.  
    1053.   /// <summary>
    1054.   /// Creates an iterator using the specified element based on an <see cref="FixedList512Bytes{T}" />.
    1055.   /// </summary>
    1056.   /// <param name="t1">Element.</param>
    1057.   /// <param name="t2">Element.</param>
    1058.   /// <param name="t3">Element.</param>
    1059.   /// <param name="fixedList">The reference to the allocated array.</param>
    1060.   /// <typeparam name="TElement">The type of the element.</typeparam>
    1061.   /// <returns>Iterator for the specified elements.</returns>
    1062.   public static NativeIterator<TElement> CreateFixed512<TElement>(in TElement t1, in TElement t2, in TElement t3, out FixedList512Bytes<TElement> fixedList)
    1063.     where TElement : unmanaged
    1064.   {
    1065.     var requiredByteLength = 3 * UnsafeUtility.SizeOf<TElement>();
    1066.  
    1067.     if (requiredByteLength <= 512 - NativeIterator.FixedListPreliminaryBytes)
    1068.     {
    1069.       fixedList = new FixedList512Bytes<TElement> { t1, t2, t3 };
    1070.  
    1071.       return new NativeIterator<TElement>(fixedList);
    1072.     }
    1073.     else
    1074.     {
    1075.       var message = $"Size of fixed list is 512 (-{NativeIterator.FixedListPreliminaryBytes}) bytes but required is {requiredByteLength} bytes";
    1076.       Log.Error(message);
    1077.       throw new System.Data.DataException(message);
    1078.     }
    1079.   }
    1080.  
    1081.   /// <summary>
    1082.   /// Creates an iterator using the specified element based on an <see cref="FixedList512Bytes{T}" />.
    1083.   /// </summary>
    1084.   /// <param name="t1">Element.</param>
    1085.   /// <param name="t2">Element.</param>
    1086.   /// <param name="t3">Element.</param>
    1087.   /// <param name="t4">Element.</param>
    1088.   /// <param name="fixedList">The reference to the allocated array.</param>
    1089.   /// <typeparam name="TElement">The type of the element.</typeparam>
    1090.   /// <returns>Iterator for the specified elements.</returns>
    1091.   public static NativeIterator<TElement> CreateFixed512<TElement>(in TElement t1, in TElement t2, in TElement t3, in TElement t4, out FixedList512Bytes<TElement> fixedList)
    1092.     where TElement : unmanaged
    1093.   {
    1094.     var requiredByteLength = 4 * UnsafeUtility.SizeOf<TElement>();
    1095.  
    1096.     if (requiredByteLength <= 512 - NativeIterator.FixedListPreliminaryBytes)
    1097.     {
    1098.       fixedList = new FixedList512Bytes<TElement> { t1, t2, t3, t4 };
    1099.  
    1100.       return new NativeIterator<TElement>(fixedList);
    1101.     }
    1102.     else
    1103.     {
    1104.       var message = $"Size of fixed list is 512 (-{NativeIterator.FixedListPreliminaryBytes}) bytes but required is {requiredByteLength} bytes";
    1105.       Log.Error(message);
    1106.       throw new System.Data.DataException(message);
    1107.     }
    1108.   }
    1109.  
    1110.   /// <summary>
    1111.   /// Creates an iterator using the specified element based on an <see cref="FixedList512Bytes{T}" />.
    1112.   /// </summary>
    1113.   /// <param name="t1">Element.</param>
    1114.   /// <param name="t2">Element.</param>
    1115.   /// <param name="t3">Element.</param>
    1116.   /// <param name="t4">Element.</param>
    1117.   /// <param name="t5">Element.</param>
    1118.   /// <param name="fixedList">The reference to the allocated array.</param>
    1119.   /// <typeparam name="TElement">The type of the element.</typeparam>
    1120.   /// <returns>Iterator for the specified elements.</returns>
    1121.   public static NativeIterator<TElement> CreateFixed512<TElement>(
    1122.     in TElement t1, in TElement t2, in TElement t3, in TElement t4, in TElement t5, out FixedList512Bytes<TElement> fixedList)
    1123.     where TElement : unmanaged
    1124.   {
    1125.     var requiredByteLength = 5 * UnsafeUtility.SizeOf<TElement>();
    1126.  
    1127.     if (requiredByteLength <= 512 - NativeIterator.FixedListPreliminaryBytes)
    1128.     {
    1129.       fixedList = new FixedList512Bytes<TElement> { t1, t2, t3, t4, t5 };
    1130.  
    1131.       return new NativeIterator<TElement>(fixedList);
    1132.     }
    1133.     else
    1134.     {
    1135.       var message = $"Size of fixed list is 512 (-{NativeIterator.FixedListPreliminaryBytes}) bytes but required is {requiredByteLength} bytes";
    1136.       Log.Error(message);
    1137.       throw new System.Data.DataException(message);
    1138.     }
    1139.   }
    1140.  
    1141.   /// <summary>
    1142.   /// Creates an iterator using the specified element based on an <see cref="FixedList512Bytes{T}" />.
    1143.   /// </summary>
    1144.   /// <param name="t1">Element.</param>
    1145.   /// <param name="t2">Element.</param>
    1146.   /// <param name="t3">Element.</param>
    1147.   /// <param name="t4">Element.</param>
    1148.   /// <param name="t5">Element.</param>
    1149.   /// <param name="t6">Element.</param>
    1150.   /// <param name="fixedList">The reference to the allocated array.</param>
    1151.   /// <typeparam name="TElement">The type of the element.</typeparam>
    1152.   /// <returns>Iterator for the specified elements.</returns>
    1153.   public static NativeIterator<TElement> CreateFixed512<TElement>(
    1154.     in TElement t1, in TElement t2, in TElement t3, in TElement t4, in TElement t5, in TElement t6, out FixedList512Bytes<TElement> fixedList)
    1155.     where TElement : unmanaged
    1156.   {
    1157.     var requiredByteLength = 6 * UnsafeUtility.SizeOf<TElement>();
    1158.  
    1159.     if (requiredByteLength <= 512 - NativeIterator.FixedListPreliminaryBytes)
    1160.     {
    1161.       fixedList = new FixedList512Bytes<TElement> { t1, t2, t3, t4, t5, t6 };
    1162.  
    1163.       return new NativeIterator<TElement>(fixedList);
    1164.     }
    1165.     else
    1166.     {
    1167.       var message = $"Size of fixed list is 512 (-{NativeIterator.FixedListPreliminaryBytes}) bytes but required is {requiredByteLength} bytes";
    1168.       Log.Error(message);
    1169.       throw new System.Data.DataException(message);
    1170.     }
    1171.   }
    1172.  
    1173.   /// <summary>
    1174.   /// Creates an iterator using the specified element based on an <see cref="FixedList512Bytes{T}" />.
    1175.   /// </summary>
    1176.   /// <param name="t1">Element.</param>
    1177.   /// <param name="t2">Element.</param>
    1178.   /// <param name="t3">Element.</param>
    1179.   /// <param name="t4">Element.</param>
    1180.   /// <param name="t5">Element.</param>
    1181.   /// <param name="t6">Element.</param>
    1182.   /// <param name="t7">Element.</param>
    1183.   /// <param name="fixedList">The reference to the allocated array.</param>
    1184.   /// <typeparam name="TElement">The type of the element.</typeparam>
    1185.   /// <returns>Iterator for the specified elements.</returns>
    1186.   public static NativeIterator<TElement> CreateFixed512<TElement>(
    1187.     in TElement t1, in TElement t2, in TElement t3, in TElement t4, in TElement t5, in TElement t6, in TElement t7, out FixedList512Bytes<TElement> fixedList)
    1188.     where TElement : unmanaged
    1189.   {
    1190.     var requiredByteLength = 7 * UnsafeUtility.SizeOf<TElement>();
    1191.  
    1192.     if (requiredByteLength <= 512 - NativeIterator.FixedListPreliminaryBytes)
    1193.     {
    1194.       fixedList = new FixedList512Bytes<TElement> { t1, t2, t3, t4, t5, t6, t7 };
    1195.  
    1196.       return new NativeIterator<TElement>(fixedList);
    1197.     }
    1198.     else
    1199.     {
    1200.       var message = $"Size of fixed list is 512 (-{NativeIterator.FixedListPreliminaryBytes}) bytes but required is {requiredByteLength} bytes";
    1201.       Log.Error(message);
    1202.       throw new System.Data.DataException(message);
    1203.     }
    1204.   }
    1205.  
    1206.   /// <summary>
    1207.   /// Creates an iterator using the specified element based on an <see cref="FixedList512Bytes{T}" />.
    1208.   /// </summary>
    1209.   /// <param name="t1">Element.</param>
    1210.   /// <param name="t2">Element.</param>
    1211.   /// <param name="t3">Element.</param>
    1212.   /// <param name="t4">Element.</param>
    1213.   /// <param name="t5">Element.</param>
    1214.   /// <param name="t6">Element.</param>
    1215.   /// <param name="t7">Element.</param>
    1216.   /// <param name="t8">Element.</param>
    1217.   /// <param name="fixedList">The reference to the allocated array.</param>
    1218.   /// <typeparam name="TElement">The type of the element.</typeparam>
    1219.   /// <returns>Iterator for the specified elements.</returns>
    1220.   public static NativeIterator<TElement> CreateFixed512<TElement>(
    1221.     in TElement t1, in TElement t2, in TElement t3, in TElement t4, in TElement t5, in TElement t6, in TElement t7, in TElement t8, out FixedList512Bytes<TElement> fixedList)
    1222.     where TElement : unmanaged
    1223.   {
    1224.     var requiredByteLength = 8 * UnsafeUtility.SizeOf<TElement>();
    1225.  
    1226.     if (requiredByteLength <= 512 - NativeIterator.FixedListPreliminaryBytes)
    1227.     {
    1228.       fixedList = new FixedList512Bytes<TElement> { t1, t2, t3, t4, t5, t6, t7, t8 };
    1229.  
    1230.       return new NativeIterator<TElement>(fixedList);
    1231.     }
    1232.     else
    1233.     {
    1234.       var message = $"Size of fixed list is 512 (-{NativeIterator.FixedListPreliminaryBytes}) bytes but required is {requiredByteLength} bytes";
    1235.       Log.Error(message);
    1236.       throw new System.Data.DataException(message);
    1237.     }
    1238.   }
    1239.  
    1240.   /// <summary>
    1241.   /// Creates an iterator using the specified element based on an <see cref="FixedList32Bytes{T}" />.
    1242.   /// </summary>
    1243.   /// <param name="fixedList">The reference to the allocated array.</param>
    1244.   /// <typeparam name="TElement">The type of the element.</typeparam>
    1245.   /// <returns>Iterator for the specified elements.</returns>
    1246.   public static NativeIterator<TElement> CreateFixed64<TElement>(out FixedList64Bytes<TElement> fixedList)
    1247.     where TElement : unmanaged
    1248.   {
    1249.     fixedList = new FixedList64Bytes<TElement>();
    1250.     return new NativeIterator<TElement>(fixedList);
    1251.   }
    1252.  
    1253.   /// <summary>
    1254.   /// Creates an iterator using the specified element based on an <see cref="FixedList64Bytes{T}" />.
    1255.   /// </summary>
    1256.   /// <param name="t1">Element.</param>
    1257.   /// <param name="fixedList">The reference to the allocated array.</param>
    1258.   /// <typeparam name="TElement">The type of the element.</typeparam>
    1259.   /// <returns>Iterator for the specified elements.</returns>
    1260.   public static NativeIterator<TElement> CreateFixed64<TElement>(in TElement t1, out FixedList64Bytes<TElement> fixedList)
    1261.     where TElement : unmanaged
    1262.   {
    1263.     var requiredByteLength = UnsafeUtility.SizeOf<TElement>();
    1264.  
    1265.     if (requiredByteLength <= 64 - NativeIterator.FixedListPreliminaryBytes)
    1266.     {
    1267.       fixedList = new FixedList64Bytes<TElement> { t1 };
    1268.  
    1269.       return new NativeIterator<TElement>(fixedList);
    1270.     }
    1271.     else
    1272.     {
    1273.       var message = $"Size of fixed list is 64 (-{NativeIterator.FixedListPreliminaryBytes}) bytes but required is {requiredByteLength} bytes";
    1274.       Log.Error(message);
    1275.       throw new System.Data.DataException(message);
    1276.     }
    1277.   }
    1278.  
    1279.   /// <summary>
    1280.   /// Creates an iterator using the specified element based on an <see cref="FixedList64Bytes{T}" />.
    1281.   /// </summary>
    1282.   /// <param name="t1">Element.</param>
    1283.   /// <param name="t2">Element.</param>
    1284.   /// <param name="fixedList">The reference to the allocated array.</param>
    1285.   /// <typeparam name="TElement">The type of the element.</typeparam>
    1286.   /// <returns>Iterator for the specified elements.</returns>
    1287.   public static NativeIterator<TElement> CreateFixed64<TElement>(in TElement t1, in TElement t2, out FixedList64Bytes<TElement> fixedList)
    1288.     where TElement : unmanaged
    1289.   {
    1290.     var requiredByteLength = 2 * UnsafeUtility.SizeOf<TElement>();
    1291.  
    1292.     if (requiredByteLength <= 64 - NativeIterator.FixedListPreliminaryBytes)
    1293.     {
    1294.       fixedList = new FixedList64Bytes<TElement> { t1, t2 };
    1295.  
    1296.       return new NativeIterator<TElement>(fixedList);
    1297.     }
    1298.     else
    1299.     {
    1300.       var message = $"Size of fixed list is 64 (-{NativeIterator.FixedListPreliminaryBytes}) bytes but required is {requiredByteLength} bytes";
    1301.       Log.Error(message);
    1302.       throw new System.Data.DataException(message);
    1303.     }
    1304.   }
    1305.  
    1306.   /// <summary>
    1307.   /// Creates an iterator using the specified element based on an <see cref="FixedList64Bytes{T}" />.
    1308.   /// </summary>
    1309.   /// <param name="t1">Element.</param>
    1310.   /// <param name="t2">Element.</param>
    1311.   /// <param name="t3">Element.</param>
    1312.   /// <param name="fixedList">The reference to the allocated array.</param>
    1313.   /// <typeparam name="TElement">The type of the element.</typeparam>
    1314.   /// <returns>Iterator for the specified elements.</returns>
    1315.   public static NativeIterator<TElement> CreateFixed64<TElement>(in TElement t1, in TElement t2, in TElement t3, out FixedList64Bytes<TElement> fixedList)
    1316.     where TElement : unmanaged
    1317.   {
    1318.     var requiredByteLength = 3 * UnsafeUtility.SizeOf<TElement>();
    1319.  
    1320.     if (requiredByteLength <= 64 - NativeIterator.FixedListPreliminaryBytes)
    1321.     {
    1322.       fixedList = new FixedList64Bytes<TElement> { t1, t2, t3 };
    1323.  
    1324.       return new NativeIterator<TElement>(fixedList);
    1325.     }
    1326.     else
    1327.     {
    1328.       var message = $"Size of fixed list is 64 (-{NativeIterator.FixedListPreliminaryBytes}) bytes but required is {requiredByteLength} bytes";
    1329.       Log.Error(message);
    1330.       throw new System.Data.DataException(message);
    1331.     }
    1332.   }
    1333.  
    1334.   /// <summary>
    1335.   /// Creates an iterator using the specified element based on an <see cref="FixedList64Bytes{T}" />.
    1336.   /// </summary>
    1337.   /// <param name="t1">Element.</param>
    1338.   /// <param name="t2">Element.</param>
    1339.   /// <param name="t3">Element.</param>
    1340.   /// <param name="t4">Element.</param>
    1341.   /// <param name="fixedList">The reference to the allocated array.</param>
    1342.   /// <typeparam name="TElement">The type of the element.</typeparam>
    1343.   /// <returns>Iterator for the specified elements.</returns>
    1344.   public static NativeIterator<TElement> CreateFixed64<TElement>(in TElement t1, in TElement t2, in TElement t3, in TElement t4, out FixedList64Bytes<TElement> fixedList)
    1345.     where TElement : unmanaged
    1346.   {
    1347.     var requiredByteLength = 4 * UnsafeUtility.SizeOf<TElement>();
    1348.  
    1349.     if (requiredByteLength <= 64 - NativeIterator.FixedListPreliminaryBytes)
    1350.     {
    1351.       fixedList = new FixedList64Bytes<TElement> { t1, t2, t3, t4 };
    1352.  
    1353.       return new NativeIterator<TElement>(fixedList);
    1354.     }
    1355.     else
    1356.     {
    1357.       var message = $"Size of fixed list is 64 (-{NativeIterator.FixedListPreliminaryBytes}) bytes but required is {requiredByteLength} bytes";
    1358.       Log.Error(message);
    1359.       throw new System.Data.DataException(message);
    1360.     }
    1361.   }
    1362.  
    1363.   /// <summary>
    1364.   /// Creates an iterator using the specified element based on an <see cref="FixedList64Bytes{T}" />.
    1365.   /// </summary>
    1366.   /// <param name="t1">Element.</param>
    1367.   /// <param name="t2">Element.</param>
    1368.   /// <param name="t3">Element.</param>
    1369.   /// <param name="t4">Element.</param>
    1370.   /// <param name="t5">Element.</param>
    1371.   /// <param name="fixedList">The reference to the allocated array.</param>
    1372.   /// <typeparam name="TElement">The type of the element.</typeparam>
    1373.   /// <returns>Iterator for the specified elements.</returns>
    1374.   public static NativeIterator<TElement> CreateFixed64<TElement>(
    1375.     in TElement t1, in TElement t2, in TElement t3, in TElement t4, in TElement t5, out FixedList64Bytes<TElement> fixedList)
    1376.     where TElement : unmanaged
    1377.   {
    1378.     var requiredByteLength = 5 * UnsafeUtility.SizeOf<TElement>();
    1379.  
    1380.     if (requiredByteLength <= 64 - NativeIterator.FixedListPreliminaryBytes)
    1381.     {
    1382.       fixedList = new FixedList64Bytes<TElement> { t1, t2, t3, t4, t5 };
    1383.  
    1384.       return new NativeIterator<TElement>(fixedList);
    1385.     }
    1386.     else
    1387.     {
    1388.       var message = $"Size of fixed list is 64 (-{NativeIterator.FixedListPreliminaryBytes}) bytes but required is {requiredByteLength} bytes";
    1389.       Log.Error(message);
    1390.       throw new System.Data.DataException(message);
    1391.     }
    1392.   }
    1393.  
    1394.   /// <summary>
    1395.   /// Creates an iterator using the specified element based on an <see cref="FixedList64Bytes{T}" />.
    1396.   /// </summary>
    1397.   /// <param name="t1">Element.</param>
    1398.   /// <param name="t2">Element.</param>
    1399.   /// <param name="t3">Element.</param>
    1400.   /// <param name="t4">Element.</param>
    1401.   /// <param name="t5">Element.</param>
    1402.   /// <param name="t6">Element.</param>
    1403.   /// <param name="fixedList">The reference to the allocated array.</param>
    1404.   /// <typeparam name="TElement">The type of the element.</typeparam>
    1405.   /// <returns>Iterator for the specified elements.</returns>
    1406.   public static NativeIterator<TElement> CreateFixed64<TElement>(
    1407.     in TElement t1, in TElement t2, in TElement t3, in TElement t4, in TElement t5, in TElement t6, out FixedList64Bytes<TElement> fixedList)
    1408.     where TElement : unmanaged
    1409.   {
    1410.     var requiredByteLength = 6 * UnsafeUtility.SizeOf<TElement>();
    1411.  
    1412.     if (requiredByteLength <= 64 - NativeIterator.FixedListPreliminaryBytes)
    1413.     {
    1414.       fixedList = new FixedList64Bytes<TElement> { t1, t2, t3, t4, t5, t6 };
    1415.  
    1416.       return new NativeIterator<TElement>(fixedList);
    1417.     }
    1418.     else
    1419.     {
    1420.       var message = $"Size of fixed list is 64 (-{NativeIterator.FixedListPreliminaryBytes}) bytes but required is {requiredByteLength} bytes";
    1421.       Log.Error(message);
    1422.       throw new System.Data.DataException(message);
    1423.     }
    1424.   }
    1425.  
    1426.   /// <summary>
    1427.   /// Creates an iterator using the specified element based on an <see cref="FixedList64Bytes{T}" />.
    1428.   /// </summary>
    1429.   /// <param name="t1">Element.</param>
    1430.   /// <param name="t2">Element.</param>
    1431.   /// <param name="t3">Element.</param>
    1432.   /// <param name="t4">Element.</param>
    1433.   /// <param name="t5">Element.</param>
    1434.   /// <param name="t6">Element.</param>
    1435.   /// <param name="t7">Element.</param>
    1436.   /// <param name="fixedList">The reference to the allocated array.</param>
    1437.   /// <typeparam name="TElement">The type of the element.</typeparam>
    1438.   /// <returns>Iterator for the specified elements.</returns>
    1439.   public static NativeIterator<TElement> CreateFixed64<TElement>(
    1440.     in TElement t1, in TElement t2, in TElement t3, in TElement t4, in TElement t5, in TElement t6, in TElement t7, out FixedList64Bytes<TElement> fixedList)
    1441.     where TElement : unmanaged
    1442.   {
    1443.     var requiredByteLength = 7 * UnsafeUtility.SizeOf<TElement>();
    1444.  
    1445.     if (requiredByteLength <= 64 - NativeIterator.FixedListPreliminaryBytes)
    1446.     {
    1447.       fixedList = new FixedList64Bytes<TElement> { t1, t2, t3, t4, t5, t6, t7 };
    1448.  
    1449.       return new NativeIterator<TElement>(fixedList);
    1450.     }
    1451.     else
    1452.     {
    1453.       var message = $"Size of fixed list is 64 (-{NativeIterator.FixedListPreliminaryBytes}) bytes but required is {requiredByteLength} bytes";
    1454.       Log.Error(message);
    1455.       throw new System.Data.DataException(message);
    1456.     }
    1457.   }
    1458.  
    1459.   /// <summary>
    1460.   /// Creates an iterator using the specified element based on an <see cref="FixedList64Bytes{T}" />.
    1461.   /// </summary>
    1462.   /// <param name="t1">Element.</param>
    1463.   /// <param name="t2">Element.</param>
    1464.   /// <param name="t3">Element.</param>
    1465.   /// <param name="t4">Element.</param>
    1466.   /// <param name="t5">Element.</param>
    1467.   /// <param name="t6">Element.</param>
    1468.   /// <param name="t7">Element.</param>
    1469.   /// <param name="t8">Element.</param>
    1470.   /// <param name="fixedList">The reference to the allocated array.</param>
    1471.   /// <typeparam name="TElement">The type of the element.</typeparam>
    1472.   /// <returns>Iterator for the specified elements.</returns>
    1473.   public static NativeIterator<TElement> CreateFixed64<TElement>(
    1474.     in TElement t1, in TElement t2, in TElement t3, in TElement t4, in TElement t5, in TElement t6, in TElement t7, in TElement t8, out FixedList64Bytes<TElement> fixedList)
    1475.     where TElement : unmanaged
    1476.   {
    1477.     var requiredByteLength = 8 * UnsafeUtility.SizeOf<TElement>();
    1478.  
    1479.     if (requiredByteLength <= 64 - NativeIterator.FixedListPreliminaryBytes)
    1480.     {
    1481.       fixedList = new FixedList64Bytes<TElement> { t1, t2, t3, t4, t5, t6, t7, t8 };
    1482.  
    1483.       return new NativeIterator<TElement>(fixedList);
    1484.     }
    1485.     else
    1486.     {
    1487.       var message = $"Size of fixed list is 64 (-{NativeIterator.FixedListPreliminaryBytes}) bytes but required is {requiredByteLength} bytes";
    1488.       Log.Error(message);
    1489.       throw new System.Data.DataException(message);
    1490.     }
    1491.   }
    1492. }