/** * <p>Answer a list of lists, which is a partition of the given * input list of resources. The equivalence relation is the predicate p. * So, two resources <code>a</code> and <code>b</code> * will be in the same partition iff * {@code (a p b) && (b p a)}.</p> * @param <T> * @param l A list of resources * @param p An equivalence predicate * @return A list of lists which are the partitions of <code>l</code> * under <code>p</code> */ public static <T extends Resource> List<List<T>> partition( List<T> l, Property p ) { // first copy the input so we can mess with it List<T> source = new ArrayList<>(); source.addAll( l ); List<List<T>> parts = new ArrayList<>(); while (!source.isEmpty()) { // each step through the loop we pick a random element, and // create a list of that element and all its equivalent values T seed = source.remove( 0 ); List<T> part = removeEquiv( source, p, seed ); part.add( seed ); // add to the partition list parts.add( part ); } return parts; }
/** * <p>Answer a list of lists, which is a partition of the given * input list of resources. The equivalence relation is the predicate p. * So, two resources <code>a</code> and <code>b</code> * will be in the same partition iff * {@code (a p b) && (b p a)}.</p> * @param <T> * @param l A list of resources * @param p An equivalence predicate * @return A list of lists which are the partitions of <code>l</code> * under <code>p</code> */ public static <T extends Resource> List<List<T>> partition( List<T> l, Property p ) { // first copy the input so we can mess with it List<T> source = new ArrayList<>(); source.addAll( l ); List<List<T>> parts = new ArrayList<>(); while (!source.isEmpty()) { // each step through the loop we pick a random element, and // create a list of that element and all its equivalent values T seed = source.remove( 0 ); List<T> part = removeEquiv( source, p, seed ); part.add( seed ); // add to the partition list parts.add( part ); } return parts; }
ResourceUtils.removeEquiv( s, orderRel, this ); boolean withheld = s.remove( this );
ResourceUtils.removeEquiv( s, orderRel, this ); boolean withheld = s.remove( this );
assertNull( out ); out = ResourceUtils.removeEquiv( in, RDFS.subClassOf, a ); assertEquals( out, ab ); out = ResourceUtils.removeEquiv( in, RDFS.subClassOf, e );
assertNull( out ); out = ResourceUtils.removeEquiv( in, RDFS.subClassOf, a ); assertEquals( out, ab ); out = ResourceUtils.removeEquiv( in, RDFS.subClassOf, e );