@Test public void testIntersection() throws Exception { long[] objectsInList1 = { 10, 20, 40, 50, 60, 70, 80, 100 }; long[] objectsInList2 = { 0, 30, 50, 70, 90, 100 }; long[] intersection = { 50, 70, 100 }; for (ObjectSet set : fixedSets) for (long object : objectsInList2) set.add(object); for (ObjectSet set2 : fixedSets) { for (ObjectSet set : changeableSets) { set.clear(); for (long object : objectsInList1) set.add(object); set.intersection(set2); assertEquals(intersection.length, set.size()); for (long object : intersection) assertTrue(set.contains(object)); } } }
public boolean intersection(ObjectSet otherSet) { if (stripeWidth != otherSet.stripeWidth || firstObjectNo != otherSet.firstObjectNo) throw new IllegalArgumentException( "The sets are not compatible. They must have the same stripe width and first object number."); int previousLength = objects.cardinality(); objects.and(otherSet.objects); return (objects.cardinality() != previousLength) ? true : false; }
ObjectSet implements /*Serializable,*/ Iterable<Long> { public boolean intersection(ObjectSet otherSet) { if (stripeWidth != otherSet.stripeWidth || firstObjectNo != otherSet.firstObjectNo) throw new IllegalArgumentException( "The sets are not compatible. They must have the same stripe width and first object number."); int previousLength = objects.cardinality(); objects.and(otherSet.objects); return (objects.cardinality() != previousLength) ? true : false; } }
ObjectSet implements /*Serializable,*/ Iterable<Long> { public boolean intersection(ObjectSet otherSet) { if (stripeWidth != otherSet.stripeWidth || firstObjectNo != otherSet.firstObjectNo) throw new IllegalArgumentException( "The sets are not compatible. They must have the same stripe width and first object number."); int previousLength = objects.cardinality(); objects.and(otherSet.objects); return (objects.cardinality() != previousLength) ? true : false; } ObjectSet();  ObjectSet(int initialSize);  ObjectSet(int stripeWidth, int firstObjectNo);  ObjectSet(int stripeWidth, int firstObjectNo, int initialSize);  ObjectSet(int stripeWidth, int firstObjectNo, byte[] serializedBitSet);  ObjectSet(ObjectSet objectSet); }
ObjectSet implements /*Serializable,*/ Iterable<Long> { public boolean intersection(ObjectSet otherSet) { if (stripeWidth != otherSet.stripeWidth || firstObjectNo != otherSet.firstObjectNo) throw new IllegalArgumentException( "The sets are not compatible. They must have the same stripe width and first object number."); int previousLength = objects.cardinality(); objects.and(otherSet.objects); return (objects.cardinality() != previousLength) ? true : false; } ObjectSet();  ObjectSet(int initialSize);  ObjectSet(int stripeWidth, int firstObjectNo);  ObjectSet(int stripeWidth, int firstObjectNo, int initialSize);  ObjectSet(int stripeWidth, int firstObjectNo, byte[] serializedBitSet);  ObjectSet(ObjectSet objectSet); boolean add(Long object); boolean contains(Long object); Long getFirst(); Long getRandom(); Iterator<Long> iterator(); boolean remove(Long object); boolean isEmpty(); int size(); void clear(); boolean equals(Object obj); boolean intersection(ObjectSet otherSet); boolean union(ObjectSet otherSet); boolean complement(int lastObject); @Override String toString(); @Override ObjectSet clone(); int getStripeWidth(); int getFirstObjectNo(); byte[] getSerializedBitSet(); }
ObjectSet implements /*Serializable,*/ Iterable<Long> { public boolean intersection(ObjectSet otherSet) { if (stripeWidth != otherSet.stripeWidth || firstObjectNo != otherSet.firstObjectNo) throw new IllegalArgumentException( "The sets are not compatible. They must have the same stripe width and first object number."); int previousLength = objects.cardinality(); objects.and(otherSet.objects); return (objects.cardinality() != previousLength) ? true : false; } ObjectSet();  ObjectSet(int initialSize);  ObjectSet(int stripeWidth, int firstObjectNo);  ObjectSet(int stripeWidth, int firstObjectNo, int initialSize);  ObjectSet(int stripeWidth, int firstObjectNo, byte[] serializedBitSet);  ObjectSet(ObjectSet objectSet); boolean add(Long object); boolean contains(Long object); Long getFirst(); Long getRandom(); Iterator<Long> iterator(); boolean remove(Long object); boolean isEmpty(); int size(); void clear(); boolean equals(Object obj); boolean intersection(ObjectSet otherSet); boolean union(ObjectSet otherSet); boolean complement(int lastObject); @Override String toString(); @Override ObjectSet clone(); int getStripeWidth(); int getFirstObjectNo(); byte[] getSerializedBitSet(); static final int DEFAULT_INITIAL_SIZE; }