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

namespace TwoMbit
{
    class Recent
    {
        string[] recentList;
        int maxSize = 0;

        public Recent(Settings[] recents)
        {
            maxSize = recents.Count();
            recentList = new string[maxSize];
            clear();
            int idx = 0;
            foreach(Settings recent in recents) {
                if (recent.str_data == "") continue;
                recentList[idx++] = recent.str_data;
            }
        }

        public bool add(string recent)
        {
            for (int i = 0; i < maxSize; i++) {
                if (recentList[i] == recent) return false;
            }

            for (int i = maxSize-1; i > 0; i--) {
                recentList[i] = recentList[i - 1];
            }
            recentList[0] = recent;
            return true;
        }

        public void clear()
        {
            for (int i = 0; i < maxSize; i++) {
                recentList[i] = "";
            }
        }

        public string[] getList()
        {
            return recentList;
        }

    }
}
