Exemplo n.º 1
0
        //"Grammer","XXX",23,4
        public List <ITEM> FindTopSim(ref ITEMS Items, List <string> Keys, List <string> Vals, int?ExcludedID, int TopX)
        {
            List <ITEM>   Res     = new List <ITEM>();
            List <SimRes> ResTemp = new List <SimRes>();

            if (Keys.Count == 0 || Items.Internal.Count == 0 || Keys.Count != Vals.Count || TopX <= 0)
            {
                return(Res);
            }

            foreach (ITEM Item in Items.Internal)
            {
                if (ExcludedID != null && ExcludedID == Item.UniqueID)
                {
                    continue;
                }
                ResTemp.Add(new SimRes()
                {
                    Sim = Sim(Item, Keys, Vals), ID = Item.UniqueID,
                });
            }
            ResTemp.Sort(SortList);
            int j = 0;

            for (int i = 0; i < TopX; i++)
            {
                if (Vals[0] != Items.Internal[Items.GetIndexByID(ResTemp[j].ID)].MainBody[Keys[0]])
                {
                    Res.Add(Items.Internal[Items.GetIndexByID(ResTemp[j].ID)]);
                }
                else
                {
                    i--;
                }
                j++;
            }

            return(Res);
        }