@Override
  @Test
  public void toArray() {
    super.toArray();

    int size = COLLISIONS.size();
    for (int i = 1; i < size; i++) {
      MutableSet<Integer> set =
          UnifiedSetWithHashingStrategy.newSet(INTEGER_HASHING_STRATEGY, SIZE)
              .withAll(COLLISIONS.subList(0, i));
      Object[] objects = set.toArray();
      Assert.assertEquals(set, UnifiedSet.newSetWith(objects));
    }

    MutableSet<Integer> deepChain =
        UnifiedSetWithHashingStrategy.newSetWith(
            INTEGER_HASHING_STRATEGY,
            COLLISION_1,
            COLLISION_2,
            COLLISION_3,
            COLLISION_4,
            COLLISION_5,
            COLLISION_6);
    Assert.assertArrayEquals(
        new Integer[] {
          COLLISION_1, COLLISION_2, COLLISION_3, COLLISION_4, COLLISION_5, COLLISION_6
        },
        deepChain.toArray());

    MutableSet<Integer> minimumChain =
        UnifiedSetWithHashingStrategy.newSetWith(
            INTEGER_HASHING_STRATEGY, COLLISION_1, COLLISION_2);
    minimumChain.remove(COLLISION_2);
    Assert.assertArrayEquals(new Integer[] {COLLISION_1}, minimumChain.toArray());

    MutableSet<Integer> set =
        UnifiedSetWithHashingStrategy.newSetWith(
            INTEGER_HASHING_STRATEGY, COLLISION_1, COLLISION_2, COLLISION_3, COLLISION_4);
    Integer[] target = {
      Integer.valueOf(1),
      Integer.valueOf(1),
      Integer.valueOf(1),
      Integer.valueOf(1),
      Integer.valueOf(1),
      Integer.valueOf(1)
    };
    Integer[] actual = set.toArray(target);
    ArrayIterate.sort(actual, actual.length, Comparators.safeNullsHigh(Integer::compareTo));
    Assert.assertArrayEquals(
        new Integer[] {COLLISION_1, 1, COLLISION_2, COLLISION_3, COLLISION_4, null}, actual);
  }
 @Test
 public void testUnifiedSetKeySetToArrayDest() {
   MutableSet<Integer> set = MultiReaderUnifiedSet.newSetWith(1, 2, 3, 4);
   // deliberately to small to force the method to allocate one of the correct size
   Integer[] dest = new Integer[2];
   Integer[] result = set.toArray(dest);
   Verify.assertSize(4, result);
   Arrays.sort(result);
   Assert.assertArrayEquals(new Integer[] {1, 2, 3, 4}, result);
 }