コード例 #1
0
        public static void Add(ref DynamicBuffer <ExternalEntityRef> buffer, ExternalEntityRef entityref)
        {
            int i = FindInsertionPoint(ref buffer, entityref);

            buffer.Insert(i, entityref);
        }
コード例 #2
0
        private static unsafe int FindInsertionPoint(ref DynamicBuffer <ExternalEntityRef> buffer, ExternalEntityRef entityref)
        {
            int low  = 0;
            int high = buffer.Length;

            while (low != high)
            {
                int mid = (low + high) / 2;
                if (entityref < buffer[mid])
                {
                    high = mid;
                }
                else
                {
                    low = mid + 1;
                }
            }

            return(low);
        }