@Test
  public void flattenWithOptimisedArrays() {
    ArrayList<Integer> list = new ArrayList<Integer>(Interval.toReverseList(1, 105));

    ArrayList<Integer> result =
        ArrayListIterate.flatCollect(
            list, new CollectionWrappingFunction<Integer>(), new ArrayList<Integer>());
    Assert.assertEquals(105, result.get(0).intValue());
  }
  @Test
  public void flatCollect() {
    ArrayList<CollectionCreator> list = new ArrayList<CollectionCreator>();
    list.add(new CollectionCreator(1));
    list.add(new CollectionCreator(2));

    Function<CollectionCreator, Collection<Integer>> flatteningFunction =
        new Function<CollectionCreator, Collection<Integer>>() {
          public Collection<Integer> valueOf(CollectionCreator object) {
            return object.getCollection();
          }
        };
    List<Integer> results1 = ArrayListIterate.flatCollect(list, flatteningFunction);
    Verify.assertListsEqual(FastList.newListWith(1, 1, 2, 2), results1);

    MutableList<Integer> target1 = Lists.mutable.of();
    MutableList<Integer> results2 = ArrayListIterate.flatCollect(list, flatteningFunction, target1);
    Assert.assertSame(results2, target1);

    Verify.assertListsEqual(FastList.newListWith(1, 1, 2, 2), results2);
  }