package edu.neu.ccs.pyramid.dataset;

import java.io.Serializable;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
import java.util.stream.Collectors;

/**
 * Created by chengli on 9/27/14.
 */
public class MultiLabel implements Serializable{
    private static final long serialVersionUID = 2L;
    private Set<Integer> labels;


    public MultiLabel() {
        this.labels = new HashSet<>();
    }

    public MultiLabel addLabel(int k){
        this.labels.add(k);
        return this;
    }

    public boolean matchClass(int k){
        return labels.contains(k);
    }

    public Set<Integer> getMatchedLabels(){
        return labels;
    }


    @Override
    public String toString() {
        return labels.stream().sorted().collect(Collectors.toList()).toString();
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        MultiLabel that = (MultiLabel) o;

        if (!labels.equals(that.labels)) return false;

        return true;
    }

    @Override
    public int hashCode() {
        return labels.hashCode();
    }
}

@@ -674,92 +674,1165 @@
  %7D%0A%0A
-%0A    @Override%0A    public String toString() %7B%0A        return labels.stream().sorted(
+    public static Set%3CInteger%3E union(MultiLabel multiLabel1, MultiLabel multiLabel2)%7B%0A        Set%3CInteger%3E union = new HashSet%3C%3E();%0A        union.addAll(multiLabel1.getMatchedLabels());%0A        union.addAll(multiLabel2.getMatchedLabels());%0A        return union;%0A    %7D%0A%0A    public static Set%3CInteger%3E intersection(MultiLabel multiLabel1, MultiLabel multiLabel2)%7B%0A        Set%3CInteger%3E intersection = new HashSet%3C%3E();%0A        intersection.addAll(multiLabel1.getMatchedLabels());%0A        intersection.retainAll(multiLabel2.getMatchedLabels());%0A        return intersection;%0A    %7D%0A%0A%0A    public static Set%3CInteger%3E symmetricDifference(MultiLabel multiLabel1, MultiLabel multiLabel2)%7B%0A        Set%3CInteger%3E union = union(multiLabel1,multiLabel2);%0A        Set%3CInteger%3E itersection = intersection(multiLabel1,multiLabel2);%0A        union.removeAll(itersection);%0A        return union;%0A    %7D%0A%0A    @Override%0A    public String toString() %7B%0A        return labels.stream().sorted().collect(Collectors.toList()).toString();%0A    %7D%0A%0A    public String toStringWithExtLabels(LabelTranslator labelTranslator)%7B%0A        return labels.stream().sorted().map(labelTranslator::toExtLabel
 ).co

add more methods