예제 #1
0
 protected virtual void ValidValues_ItemsRemoved(object sender, CollectionItemsChangedEventArgs <T> e)
 {
     if ((Value != null) && !validValues.Contains(Value))
     {
         Value = null;
     }
 }
 private bool IsSubsetOf(ItemSet <T> set1, ItemSet <T> set2)
 {
     for (int i = 0; i < set1.Count; ++i)
     {
         if (!set2.Contains(set1[i]))
         {
             return(false);
         }
     }
     return(true);
 }
예제 #3
0
        protected ItemSets <T> FindMaxPatterns(ItemSets <T> fis)
        {
            for (int i = fis.Count - 1; i >= 0; i--)
            {
                ItemSet <T> itemset  = fis[i];
                bool        isSubSet = false;
                for (int j = 0; j < fis.Count; j++)
                {
                    if (i == j)
                    {
                        continue;
                    }
                    isSubSet = true;

                    ItemSet <T> itemset2 = fis[j];
                    if (itemset.Count > itemset2.Count)
                    {
                        isSubSet = false;
                        break;
                    }

                    for (int k = 0; k < itemset.Count; ++k)
                    {
                        if (!itemset2.Contains(itemset[k]))
                        {
                            isSubSet = false;
                            break;
                        }
                    }

                    if (!isSubSet)
                    {
                        break;
                    }
                }

                if (isSubSet)
                {
                    fis.RemoveAt(i);
                }
            }
            return(fis);
        }
예제 #4
0
    public Item GetSample(Item item)
    {
        if (!samples.Contains(item))
        {
            Item sample;

            if (item.IsFungible())
            {
                sample          = item.Copy();
                sample.Quantity = 1;

                sample.transform.SetParent(transform);
            }
            else
            {
                sample = item;
            }

            samples.Add(sample);
        }

        return(samples.Get(item));
    }