BEPUutilities2.ResourceManagement.Allocator.GetLargestContiguousSize C# (CSharp) Метод

GetLargestContiguousSize() публичный Метод

Gets the size of the largest contiguous area and the total free space in the allocator. Not very efficient; runs in linear time for the number of allocations.
public GetLargestContiguousSize ( long &largestContiguous, long &totalFreeSpace ) : void
largestContiguous long Largest contiguous region in the allocator. The allocator can hold an allocation up to this size.
totalFreeSpace long Total free space in the allocator.
Результат void
        public void GetLargestContiguousSize(out long largestContiguous, out long totalFreeSpace)
        {
            if (allocations.Count == 0)
            {
                totalFreeSpace = memoryPoolSize;
                largestContiguous = memoryPoolSize;
                return;
            }
            largestContiguous = 0;
            totalFreeSpace = 0;
            for (int i = 0; i < allocations.Count; ++i)
            {
                Allocation nextAllocation;
                allocations.TryGetValue(allocations.Values[i].Next, out nextAllocation);
                var toNext = nextAllocation.Start - allocations.Values[i].End;
                if (toNext < 0)
                {
                    //The next allocation requires a wrap, so the actual contiguous area is only from our end to the end of the pool,
                    //and then a second region from 0 to the next allocation.
                    var adjacent = memoryPoolSize - allocations.Values[i].End;
                    var wrapped = nextAllocation.Start;
                    if (largestContiguous < adjacent)
                        largestContiguous = adjacent;
                    if (largestContiguous < wrapped)
                        largestContiguous = wrapped;
                    totalFreeSpace += adjacent + wrapped;
                }
                else
                {
                    if (largestContiguous < toNext)
                        largestContiguous = toNext;
                    totalFreeSpace += toNext;
                }
            }
        }