public static bool TryGetValue(this DictionaryGroup container, Type t, Composition composition, out GroupCore group) { var len = container.len; for (int i = 0; i < len; i++) { var instance = container.storage[i]; var instanceType = instance.GetType(); var instanceComposition = instance.composition; if (t != instanceType) { continue; } if (!instanceComposition.Equals(composition)) { continue; } group = instance; return(true); } group = default; return(false); }
internal void Add(int tagID, DictionaryGroup anotherGroupStorage) { if (len == groupStorage.Length - 1) { var l = len << 1; Array.Resize(ref groupStorage, l); Array.Resize(ref tagsID, l); } var pointer = len++; var indexLast = pointer; var index = pointer - 1; if (index >= 0) { if (tagID < tagsID[index]) { var startIndex = 0; var endIndex = indexLast; while (endIndex > startIndex) { var middleIndex = (endIndex + startIndex) / 2; var middleValue = tagsID[middleIndex]; if (middleValue == tagID) { pointer = middleIndex; break; } if (middleValue < tagID) { startIndex = middleIndex + 1; pointer = startIndex; } else { endIndex = middleIndex; pointer = endIndex; } } } } for (int i = indexLast; i >= pointer; i--) { tagsID[i + 1] = tagsID[i]; groupStorage[i + 1] = groupStorage[i]; } groupStorage[pointer] = anotherGroupStorage; tagsID[pointer] = tagID; }
public static bool Contain(this DictionaryGroup container, GroupCore groupCore) { var len = container.len; for (int i = 0; i < len; i++) { var groupAdded = container.storage[i]; if (groupAdded.Equals(groupCore)) { return(true); } } return(false); }
internal bool TryGetValue(int tagID, out DictionaryGroup groupOld) { var id = -1; for (int i = 0; i < len; i++) { if (tagsID[i] == tagID) { id = i; break; } id = -1; } if (id > -1) { groupOld = groupStorage[id]; return(true); } groupOld = default; return(false); }
public static GroupCore Add(this DictionaryGroup container, GroupCore group) { ref var len = ref container.len;