/// <summary> /// Grows the collection by a computed factor. /// </summary> /// <param name="collection">This collection.</param> public static void Grow(this IResize collection) { if (collection.Capacity >= 8) { collection.Resize((Int32)(collection.Capacity * φ)); } else { collection.Resize(13); } }
/// <summary> /// Grows the collection by a computed factor, to at least a specified <paramref name="minimum"/>. /// </summary> /// <param name="collection">This collection.</param> /// <param name="minimum">The minimum allowed size.</param> public static void Grow(this IResize collection, nint minimum) { Double size = collection.Capacity; while (size < minimum) { size += 4.0; size *= φ; } collection.Resize((Int32)size); }
/// <summary> /// Shrinks the collection by a computed factor. /// </summary> /// <param name="collection">This collection.</param> public static void Shrink(this IResize collection) => collection.Resize((Int32)(collection.Capacity / φ));