在两个结果之间制作比较器

时间:2016-11-25 00:56:21

标签: java data-structures hashmap set

比较两个数据结构的值。基本上我想比较我的字符串格式的输出结果和三个哈希映射的值。

一个数据结构包含三个哈希图:

<Key, Set<SuperClass>>
<key, Set<SubClass>>
<key,Set<EquivalentClass>> datatype. 

其他数据结构是一个包含三个集合和一个元素的类,并以String格式提供结果

{SuperClassSet, SubClassClassSet, EquivalentClassSet and keyElement}.

情况是两个数据结构中的Key是相同的。我必须比较DataImplementation Class中key的Set值和Hashmaps中key的Set Values。因为两者必须包含相同的setValues。如果发生,我还想打印结果值的差异。我试图开始这样的事情,但没有得到如何开始:

Public void testing(DataImplementationClass FinalGraphList)
{
For(DataImplementationClass owlElement: FinalGraphList){
    if(owlelement.getSuccessor() equals hashmap.get(OwlElement).getSuccessor()){ 
        iterate all successors element of DataImplementationClass in HashMap Successor Set
    }
    Else{
        System.out.println(owlelement+ "Do something");
    }

    if(owlelement.getPredecessor() equals hashmap.get(OwlElement).getPredecessor()){ 
        iterate all Predecessor elements of DataImplementationClass in HashMap Predecessor Set
    }
    Else{
        System.out.println(owlelement+ "Need to check");
    }

    if(owlelement.getEquEquivalent() of DataImplementationClass in HashMap EquivalentSet()){
        iterate all Equivalent element of DataImplementationClass in HashMap EquivalentSet
    }
    Else{
        System.out.println(owlelement+ "Need to check");
    }
    }   
}

DataImplementation Class和HashMap的实际代码:

//Three hashmap used to compare the result of class DataimplementationClass
static HashMap<OWLClass, Set<OWLClass>> subClassSet = new HashMap<OWLClass, Set<OWLClass>>();
static HashMap<OWLClass, Set<OWLClass>> superClassSet = new HashMap<OWLClass, Set<OWLClass>>();
static HashMap<OWLClass, Set<OWLClass>> equiClassMap = new HashMap<OWLClass, Set<OWLClass>>();


// Final Output Data implementation class use for final graph data structure

package MainOWLFiles;
import org.semanticweb.owlapi.model.OWLClass;
import java.util.HashSet;
import java.util.Set;

public class DataImplementationCls {

public Set<OWLClass> predcessorElements;
public Set<OWLClass> successorElements;
public OWLClass element;
public Set<OWLClass> isEquivalentList;


public Set<OWLClass> getIsEquivalentList() {
    return isEquivalentList;
}

public void setIsEquivalentList(Set<OWLClass> isEquivalentList) {
    this.isEquivalentList = isEquivalentList;
}

public DataImplementationCls(OWLClass element) {
    this.element = element;
    predcessorElements = new HashSet<OWLClass>();
    successorElements = new HashSet<OWLClass>();
    this.isEquivalentList = new HashSet();

}

public Set<OWLClass> getPredcessorElements() {
    return predcessorElements;
}

public void setPredcessorElements(Set<OWLClass> predcessorElements) {
    this.predcessorElements = predcessorElements;
}

public Set<OWLClass> getSuccessorElements() {
    return successorElements;
}

public void setSuccessorElements(Set<OWLClass> successorElements) {
    this.successorElements = successorElements;
}

public OWLClass getElement() {
    return element;
}

public void setElement(OWLClass element) {
    this.element = element;
}

@Override
public String toString() {
    return "DataImplementationCls [predcessorElements=" + predcessorElements + ", "
            + "successorElements=" + successorElements + ", "
            + "element=" + element + ", "
            + "isEquivalent=" + isEquivalentList + ""
            + "]";
}

}

0 个答案:

没有答案