Exemplo n.º 1
0
 public bool IsSubsetOf(MultiSet <T> other)
 {
     foreach (T t in dict.Keys)
     {
         if (!other.dict.ContainsKey(t) || other.dict[t] < dict[t])
         {
             return(false);
         }
     }
     return(true);
 }
Exemplo n.º 2
0
 public bool IsDisjointFrom(MultiSet <T> other)
 {
     foreach (T t in dict.Keys)
     {
         if (other.dict.ContainsKey(t))
         {
             return(false);
         }
     }
     foreach (T t in other.dict.Keys)
     {
         if (dict.ContainsKey(t))
         {
             return(false);
         }
     }
     return(true);
 }
Exemplo n.º 3
0
        public MultiSet <T> Intersect(MultiSet <T> other)
        {
            if (dict.Count == 0)
            {
                return(this);
            }
            else if (other.dict.Count == 0)
            {
                return(other);
            }
            var r = new Dictionary <T, int>();

            foreach (T t in dict.Keys)
            {
                if (other.dict.ContainsKey(t))
                {
                    r.Add(t, other.dict[t] < dict[t] ? other.dict[t] : dict[t]);
                }
            }
            return(new MultiSet <T>(r));
        }
Exemplo n.º 4
0
 public bool IsProperSupersetOf(MultiSet <T> other)
 {
     return(other.IsProperSubsetOf(this));
 }
Exemplo n.º 5
0
 public bool IsProperSubsetOf(MultiSet <T> other)
 {
     return(!Equals(other) && IsSubsetOf(other));
 }
Exemplo n.º 6
0
 public bool Equals(MultiSet <T> other)
 {
     return(other.IsSubsetOf(this) && this.IsSubsetOf(other));
 }