public bool Remove(K entity) { int index = contents.IndexOf <K>(entity); if (index >= 0) { contents.RemoveAtSwapBack <K>(index); return(true); } return(false); }
public void IndexOfTest() { var arr = UnsafeList.Allocate <int>(10); for (int i = 1; i <= 10; i++) { UnsafeList.Add(arr, i); } var index = UnsafeList.IndexOf(arr, 5); Assert.AreEqual(4, index); }
internal void AddUnmanagedSystemToUpdateList(SystemHandleUntyped sysHandle) { CheckCreated(); if (-1 != UnmanagedSystemIndex(sysHandle)) { int index = m_UnmanagedSystemsToRemove.IndexOf(sysHandle); if (-1 != index) { m_UnmanagedSystemsToRemove.RemoveAt(index); } return; } m_UnmanagedSystemsToUpdate.Add(sysHandle); m_systemSortDirty = true; }
public static bool AddWriterTypeIndex(int typeIndex, ref UnsafeList reading, ref UnsafeList writing) { if (writing.Contains(typeIndex)) { return(false); } var readingIndex = reading.IndexOf(typeIndex); if (readingIndex != -1) { reading.RemoveAtSwapBack <int>(readingIndex); } writing.Add(typeIndex); return(true); }
public static bool Add(ComponentType type, ref UnsafeList reading, ref UnsafeList writing) { if (!type.RequiresJobDependency) { return(false); } // If any other dependency is added the Entity type dependency is removed to avoid the overhead of having all jobs // depend on this. if ((reading.m_size == 1) && reading.Contains(TypeManager.GetTypeIndex <Entity>())) { reading.m_size = 0; } if (type.AccessModeType == ComponentType.AccessMode.ReadOnly) { if (reading.Contains(type.TypeIndex)) { return(false); } if (writing.Contains(type.TypeIndex)) { return(false); } reading.Add(type.TypeIndex); return(true); } else { if (writing.Contains(type.TypeIndex)) { return(false); } var readingIndex = reading.IndexOf(type.TypeIndex); if (readingIndex != -1) { reading.RemoveAtSwapBack <int>(readingIndex); } writing.Add(type.TypeIndex); return(true); } }
private void RemovePending() { if (m_systemsToRemove.Count > 0) { foreach (var sys in m_systemsToRemove) { m_systemsToUpdate.Remove(sys); } m_systemsToRemove.Clear(); } for (int i = 0; i < m_UnmanagedSystemsToRemove.Length; ++i) { var sysHandle = m_UnmanagedSystemsToRemove[i]; m_UnmanagedSystemsToUpdate.RemoveAt(m_UnmanagedSystemsToUpdate.IndexOf(sysHandle)); } m_UnmanagedSystemsToRemove.Clear(); }
internal void AddUnmanagedSystemToUpdateList(SystemHandleUntyped sysHandle) { CheckCreated(); if (-1 != UnmanagedSystemIndex(sysHandle)) { int index = m_UnmanagedSystemsToRemove.IndexOf(sysHandle); if (-1 != index) { m_UnmanagedSystemsToRemove.RemoveAt(index); } return; } if (UseLegacySortOrder) { throw new InvalidOperationException("ISystemBase systems are not compatible with legacy sort order. Set UseLegacySortOrder to false to use ISystemBase systems."); } m_UnmanagedSystemsToUpdate.Add(sysHandle); m_systemSortDirty = true; }
public void UnsafeListIndexOf() { int num = UnsafeList.IndexOf <long>(uList, COUNT / 3 * 2); }