Mentions légales du service

Skip to content
Snippets Groups Projects
Commit 58544f7f authored by Jérôme Euzenat's avatar Jérôme Euzenat
Browse files

- added entails( DisjunctiveRelation ) across disjunctive relations

parent 8a8f1d64
No related branches found
No related tags found
No related merge requests found
......@@ -121,6 +121,24 @@ public abstract class BitSetDisjunctiveRelation<T extends BaseRelation> extends
return relset.isEmpty();
}
public boolean entails( BitSetDisjunctiveRelation<T> dr ) {
if ( dr == this ) return true;
if ( dr == null ) return false;
// This does allocate but is certainly faster and simpler
BitSet bs = (BitSet)relset.clone();
bs.andNot( ((BitSetDisjunctiveRelation<?>)dr).getRelations() );
return bs.isEmpty();
/*
// This does not allocate but is certainly slower
BitSet bs = ((BitSetDisjunctiveRelation<?>)dr).getRelations();
int size = relset.size(); // is it correct?
for( int i=0; i < size; i++ ) {
if ( bs.get(i) && !relset.get(i) ) return false;
}
return true;
*/
}
/** This is kept for displayig more correctly the result **/
public void write( PrintWriter writer ) {
Iterator<T> brit = iterator();
......
......@@ -45,5 +45,7 @@ public interface DisjunctiveRelation<T extends BaseRelation> extends Relation, I
public boolean isEmpty();
//public boolean entails( DisjunctiveRelation<T> dr );
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment