using lkfxdok.LKF;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace lkfxdok.unittests
{

    public class LKFMemoryLimitSettingsItem
    {
        public string Key { get; }
        public int Count { get; }
        public int MinKB { get; }

        internal LKFMemoryLimitSettingsItem(string key, int count, int minKB = 0)
        {
            Key = key;
            Count = count;
            MinKB = minKB;
        }
    }

    public class LKFMemoryLimitSettings
    {
        public int MinOccurrence { get; }
        public int Factor {  get; }

        internal LKFMemoryLimitSettings(int minOccurrence, int factor)
        {
            MinOccurrence = minOccurrence;
            Factor = factor;
        }

        public IEnumerable<LKFMemoryLimitSettingsItem> GetLimitItems (MemoryTracker tracker)
        {
            return tracker.Keys.Where(x => x.Value.AllocCount >= MinOccurrence).Select(x => new LKFMemoryLimitSettingsItem(x.Key, (x.Value.Count * Factor + 99) / 100));
        }

        public static LKFMemoryLimitSettings first = new LKFMemoryLimitSettings(1, 40);
        public static LKFMemoryLimitSettings second = new LKFMemoryLimitSettings(5, 60);
    }


    /*
     class MemoryDebugLimitSetting {
        let minOccurrence : Int
        let factor: Int
        
        init (minOccurrence: Int, factor: Int) {
            self.minOccurrence = minOccurrence
            self.factor = factor
        }
        
        var description: String {
            return "**minOccurrence=\(minOccurrence), factor=\(factor)"
        }
        
        static let first = MemoryDebugLimitSetting(minOccurrence: 1, factor: 40)
        static let second = MemoryDebugLimitSetting(minOccurrence: 5, factor: 60)
        static let third = MemoryDebugLimitSetting(minOccurrence: 20, factor: 75)
        static let forth = MemoryDebugLimitSetting(minOccurrence: 40, factor: 90)
    }

     */
}
