示例#1
0
        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);
        }
示例#2
0
        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;
        }
示例#3
0
        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);
        }
示例#4
0
        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);
        }
示例#5
0
 public static GroupCore Add(this DictionaryGroup container, GroupCore group)
 {
     ref var len     = ref container.len;