做这样的事情
public Multime<T> Difference(Multime<T> list)
{
Multime<T> diff = new Multime<T>();
for (int i = 0; i < list.Multisets.Count() - 1; i++)
{
foreach (T el in list.multiSets[i].Multimea)
{
if (!(list.multiSets[i + 1].Multimea.Exists(element => EqualityComparer<T>.Default.Equals(element, el))))
diff.Multimea.Add(el);
}
list.multiSets[i + 1] = diff;
if (i < list.multiSets.Count() - 1)
diff.Multimea.RemoveAll(item => EqualityComparer<T>.Default.Equals(item, item));
}
...
在也diff.Multimea.RemoveAll(item => EqualityComparer<T>.Default.Equals(item, item));
被list.multiSets[i + 1]
清除之后。我该如何解决这个问题,这样他们就不会以这种方式连接,我不想list.multiSets[i + 1]
被清除。
public Multime<T> this[int index]
{
get { return this.multiSets[index]; }
set { this.multiSets[index] = value; }
}
如果有帮助,这是索引器:)