﻿using System.Collections.Generic;

namespace Trigon
{
    /// <summary>
    /// Provides extension methods for common types.
    /// </summary>
    public static partial class Extensions
    {
        /// <summary>
        /// Discards the specified number of items from the top of the stack.
        /// </summary>
        /// <typeparam name="T">The type of the stack item.</typeparam>
        /// <param name="stack">The stack.</param>
        /// <param name="count">The number of items to discard from the top of the stack.</param>
        public static void Discard<T>(this Stack<T> stack, int count)
        {
            for (; count > 0 && stack.Count > 0; count--)
            {
                stack.Pop();
            }
        }
    }
}
