// ** keep this block in sync ** (end)

        int GetOrAddHeadIdIndex(int objectInstanceId)
        {
            if (!m_HeadIdIndices.TryGetValue(objectInstanceId, out var headIdIndex))
            {
                if (!m_FreeHeadIds.IsEmpty)
                {
                    int end = m_FreeHeadIds.Length - 1;
                    headIdIndex           = m_FreeHeadIds[end];
                    m_FreeHeadIds.Length -= 1;
                }
                else
                {
                    headIdIndex = m_HeadIdCount++;
                };
                m_HeadIdIndices.Add(objectInstanceId, headIdIndex);

                var headIdsCapacity = headIdIndex + 1;
                if (MultiList.CalcExpandCapacity(m_Entities.HeadIds.Length, ref headIdsCapacity))
                {
                    m_Entities.SetHeadIdsCapacity(headIdsCapacity);
                    m_LogEvents.SetHeadIdsCapacity(headIdsCapacity);
                }
            }

            return(headIdIndex);
        }
        int GetOrAddHybridHeadIdIndex(GameObject gameObject)
        {
            if (!m_NewHybridHeadIdIndices.TryGetValue(gameObject, out var headIdIndex))
            {
                headIdIndex = m_NewHybridHeadIdIndices.Count;
                m_NewHybridHeadIdIndices.Add(gameObject, headIdIndex);

                var headIdsCapacity = headIdIndex + 1;
                if (MultiList.CalcExpandCapacity(m_HybridTypes.HeadIds.Length, ref headIdsCapacity))
                {
                    m_HybridTypes.SetHeadIdsCapacity(headIdsCapacity);
                }
            }

            return(headIdIndex);
        }
 internal ConvertedEntitiesAccessor(NativeHashMap <int, int> headIndices,
                                    MultiList <Entity, MultiListNativeArrayData <Entity> > entities)
 {
     m_HeadIdIndices = headIndices;
     m_Entities      = entities;
 }
 // creates new head, returns false if already had one
 void AddHead <T, I>(int objectInstanceId, ref MultiList <T, I> store, in T data) where I : IMultiListDataImpl <T> =>