public Set<Role> getProperSubRoles() { return SetUtils.difference( subRoles, superRoles ); }
BaseUnionDatatype(ATermAppl name, Datatype[] members) { super(name); this.members = SetUtils.create(members); }
public Set<Node> getMerged() { if ( merged == null ) return SetUtils.emptySet(); return merged; }
/** * @param functionalSuper The functionalSuper to set. */ public void addFunctionalSuper(Role r) { for( Role fs : functionalSupers ) { if( fs.isSubRoleOf( r ) ) { functionalSupers = SetUtils.remove( fs, functionalSupers ); break; } else if( r.isSubRoleOf( fs ) ) { return; } } functionalSupers = SetUtils.add( r, functionalSupers ); }
/** * Adds the given object to the set but saves memory space * by allocating only the required amount for small sets. The * idea is to use the specialized empty set and singleton set * implementations (which are immutable) for the sets of size * 0 and 1. If the set is empty a new singleton set is created, * if set has one element we create a new set with two elements, * otherwise we simply add the element to the given set.This * technique is most useful if the expected set size is 0 or 1. * * @param o * @param set * @return */ public static <T> Set<T> add( T o, Set<T> set ) { int size = set.size(); if( size == 0 ) set = singleton( o ); else if( size == 1 ) { T existing = set.iterator().next(); if( !existing.equals( o ) ) set = binary( existing, o ); } else set.add( o ); return set; }
/** * Create a new DependencySet and all the elements of <code>this</code> * and <code>ds</code>. * * @param ds * @param doExplanation * @return */ public DependencySet union(DependencySet ds, boolean doExplanation) { IntSet newDepends = depends.union( ds.depends ); Set<ATermAppl> newExplain; if( doExplanation ) { newExplain = SetUtils.union( explain, ds.explain ); } else { newExplain = SetUtils.emptySet(); } return new DependencySet( branch, newDepends, newExplain ); }
public AtomicDatatype intersection(AtomicDatatype dt) { if(getPrimitiveType().equals(dt.getPrimitiveType()) && dt instanceof BaseAtomicDatatype) { BaseAtomicDatatype other = (BaseAtomicDatatype) dt; if(values == null) { if(negated) return this; else return other; } else if(other.values == null) { if(other.negated) return other; else return this; } else if(negated) { if(other.negated) return derive(SetUtils.union(values, other.values), true); else return derive(SetUtils.difference(other.values, values), false); } else if(other.negated) return derive(SetUtils.difference(values, other.values), false); else return derive(SetUtils.intersection(values, other.values), false); } return null; }
private boolean checkDisjointProperties(Set<Role> roles1, Set<Role> roles2) { Set<Role> allDisjoints = new HashSet<Role>(); for( Role role : roles1 ) { allDisjoints.addAll( role.getDisjointRoles() ); } return SetUtils.intersects( allDisjoints, roles2 ); }
public RestrictedDatatype<ATermAppl> intersect(RestrictedDatatype<?> other, boolean negated) { if( other instanceof RestrictedTextDatatype ) { RestrictedTextDatatype that = (RestrictedTextDatatype) other; return new RestrictedTextDatatype(dt, SetUtils.union(this.patterns, that.patterns), this.allowLang && that.allowLang, SetUtils.union(this.excludedValues, that.excludedValues)); } else { throw new IllegalArgumentException(); } }
public void addSuperRole(Role r, DependencySet ds) { superRoles = SetUtils.add( r, superRoles ); explainSup.put(r.getName(), ds); }
public Set<Role> getEquivalentProperties() { return SetUtils.intersection( subRoles, superRoles ); }
public void removeSubRole(Role r) { subRoles = SetUtils.remove( r, subRoles ); }
public boolean isDirectlyBlockedBy(BlockingContext cxt) { Individual parentBlocked = cxt.blocked.getParent(); Individual parentBlocker = cxt.blocker.getParent(); if( SetUtils.equals( cxt.blocked.getTypes(), cxt.blocker.getTypes() ) && SetUtils.equals( parentBlocked.getTypes(), parentBlocker.getTypes() ) ) { if( SetUtils.equals( cxt.getIncomingRoles(), BlockingContext.getIncomingRoles( cxt.blocker ) ) ) return true; } return false; } }
private boolean checkDisjointProperties(Set<Role> roles1, Set<Role> roles2) { Set<Role> allDisjoints = new HashSet<Role>(); for( Role role : roles1 ) { allDisjoints.addAll( role.getDisjointRoles() ); } return SetUtils.intersects( allDisjoints, roles2 ); }
/** * Create a new DependencySet and all the elements of <code>this</code> * and <code>ds</code>. * * @param ds * @param doExplanation * @return */ public DependencySet union(DependencySet ds, boolean doExplanation) { IntSet newDepends = depends.union( ds.depends ); Set<ATermAppl> newExplain; if( doExplanation ) { newExplain = SetUtils.union( explain, ds.explain ); } else { newExplain = SetUtils.emptySet(); } return new DependencySet( branch, newDepends, newExplain ); }
public RestrictedDatatype<ATermAppl> intersect(RestrictedDatatype<?> other, boolean negated) { if( other instanceof RestrictedTextDatatype ) { RestrictedTextDatatype that = (RestrictedTextDatatype) other; return new RestrictedTextDatatype(dt, SetUtils.union(this.patterns, that.patterns), this.allowLang && that.allowLang, SetUtils.union(this.excludedValues, that.excludedValues)); } else { throw new IllegalArgumentException(); } }
/** * @param functionalSuper The functionalSuper to set. */ public void addFunctionalSuper(Role r) { for( Role fs : functionalSupers ) { if( fs.isSubRoleOf( r ) ) { functionalSupers = SetUtils.remove( fs, functionalSupers ); break; } else if( r.isSubRoleOf( fs ) ) { return; } } functionalSupers = SetUtils.add( r, functionalSupers ); }
/** * Adds the given object to the set but saves memory space * by allocating only the required amount for small sets. The * idea is to use the specialized empty set and singleton set * implementations (which are immutable) for the sets of size * 0 and 1. If the set is empty a new singleton set is created, * if set has one element we create a new set with two elements, * otherwise we simply add the element to the given set.This * technique is most useful if the expected set size is 0 or 1. * * @param o * @param set * @return */ public static <T> Set<T> add( T o, Set<T> set ) { int size = set.size(); if( size == 0 ) set = singleton( o ); else if( size == 1 ) { T existing = set.iterator().next(); if( !existing.equals( o ) ) set = binary( existing, o ); } else set.add( o ); return set; }