| | | 1 | | namespace Itinero.Network.Tiles; |
| | | 2 | | |
| | | 3 | | internal static class ArrayBaseExtensions |
| | | 4 | | { |
| | | 5 | | /// <summary> |
| | | 6 | | /// Increase the native byte array size with a fixed step (but never more) to ensure the given position fits. |
| | | 7 | | /// </summary> |
| | | 8 | | /// <param name="array">The array.</param> |
| | | 9 | | /// <param name="position">The position.</param> |
| | | 10 | | /// <param name="step">The steps to add.</param> |
| | | 11 | | public static void EnsureMinimumSize(ref byte[] array, long position, long step = 16) |
| | 163283 | 12 | | { |
| | 295766 | 13 | | if (array.Length > position) return; |
| | 30800 | 14 | | var newSize = array.Length + step; |
| | 30800 | 15 | | while (newSize <= position) newSize += step; |
| | 30800 | 16 | | System.Array.Resize(ref array, (int)newSize); |
| | 163283 | 17 | | } |
| | | 18 | | |
| | | 19 | | /// <summary> |
| | | 20 | | /// Increase the native int array size with a fixed step (but never more) to ensure the given position fits. |
| | | 21 | | /// </summary> |
| | | 22 | | /// <param name="array">The array.</param> |
| | | 23 | | /// <param name="position">The position.</param> |
| | | 24 | | /// <param name="step">The steps to add.</param> |
| | | 25 | | public static void EnsureMinimumSize(ref int[] array, long position, long step = 16) |
| | 3 | 26 | | { |
| | 3 | 27 | | if (array.Length > position) return; |
| | 3 | 28 | | var newSize = array.Length + step; |
| | 5 | 29 | | while (newSize <= position) newSize += step; |
| | 3 | 30 | | System.Array.Resize(ref array, (int)newSize); |
| | 3 | 31 | | } |
| | | 32 | | |
| | | 33 | | /// <summary> |
| | | 34 | | /// Increase the native uint array size with a fixed step (but never more) to ensure the given position fits. |
| | | 35 | | /// </summary> |
| | | 36 | | /// <param name="array">The array.</param> |
| | | 37 | | /// <param name="position">The position.</param> |
| | | 38 | | /// <param name="step">The steps to add.</param> |
| | | 39 | | public static void EnsureMinimumSize(ref uint[] array, long position, long step = 16) |
| | 39197 | 40 | | { |
| | 75460 | 41 | | if (array.Length > position) return; |
| | 2934 | 42 | | var newSize = array.Length + step; |
| | 2934 | 43 | | while (newSize <= position) newSize += step; |
| | 2934 | 44 | | System.Array.Resize(ref array, (int)newSize); |
| | 39197 | 45 | | } |
| | | 46 | | |
| | | 47 | | /// <summary> |
| | | 48 | | /// Increase the native string array size with a fixed step (but never more) to ensure the given position fits. |
| | | 49 | | /// </summary> |
| | | 50 | | /// <param name="array">The array.</param> |
| | | 51 | | /// <param name="position">The position.</param> |
| | | 52 | | /// <param name="step">The steps to add.</param> |
| | | 53 | | public static void EnsureMinimumSize(ref string[] array, long position, long step = 16) |
| | 0 | 54 | | { |
| | 0 | 55 | | if (array.Length > position) return; |
| | 0 | 56 | | var newSize = array.Length + step; |
| | 0 | 57 | | while (newSize <= position) newSize += step; |
| | 0 | 58 | | System.Array.Resize(ref array, (int)newSize); |
| | 0 | 59 | | } |
| | | 60 | | } |