private static void runUnifiedSetRetainAllFromSet(int shift) {
    MultiReaderUnifiedSet<CollidingInt> set = MultiReaderUnifiedSet.newSet();

    Set<CollidingInt> toRetain = new HashSet<CollidingInt>();

    int size = 100000;
    for (int i = 0; i < size; i++) {
      set.add(new CollidingInt(i, shift));
      if (i % 2 == 0) {
        toRetain.add(new CollidingInt(i, shift));
      }
    }
    Verify.assertSize(size, set);
    Assert.assertTrue(set.containsAll(toRetain));

    Assert.assertTrue(set.retainAll(toRetain));
    Assert.assertTrue(set.containsAll(toRetain));

    Assert.assertFalse(set.retainAll(toRetain)); // a second call should not modify the set

    Verify.assertSize(size / 2, set);

    for (int i = 0; i < size; i += 2) {
      Verify.assertContains(new CollidingInt(i, shift), set);
    }
  }