Ejemplo n.º 1
0
 /// <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);
     }
 }
Ejemplo n.º 2
0
        /// <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);
        }
Ejemplo n.º 3
0
 /// <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 / φ));