// Copyright © 2017-2018 Atomic Software, LLC. All Rights Reserved.
// See LICENSE.md for full license information.

using System.Collections.Generic;
using System.Linq;

namespace Atom.Core.Collections
{
    public class List<T> : System.Collections.Generic.List<T>
    {
        public new int Count { get; private set; }

        public new void Add(T value)
        {
            base.Add(value);
            Count++;
        }

        public new bool Remove(T value)
        {
            if (!base.Remove(value))
            {
                return false;
            }

            Count--;
            return true;
        }

        public new void AddRange(IEnumerable<T> collection)
        {
            var array = collection.ToArray();

            base.AddRange(array);
            Count += array.Length;
        }

        public new void Clear()
        {
            base.Clear();
            Count = 0;
        }
    }
}
