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); }
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); }
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)); }
public bool IsProperSupersetOf(MultiSet <T> other) { return(other.IsProperSubsetOf(this)); }
public bool IsProperSubsetOf(MultiSet <T> other) { return(!Equals(other) && IsSubsetOf(other)); }
public bool Equals(MultiSet <T> other) { return(other.IsSubsetOf(this) && this.IsSubsetOf(other)); }