SeriesConcat { public static <T> Series<T> concat(Series<T>... concat) { int h = 0; for (Series<? extends T> s : concat) { h += s.size(); } T[] data = (T[]) new Object[h]; int offset = 0; for (Series<? extends T> s : concat) { int len = s.size(); s.copyTo(data, 0, offset, len); offset += len; } return new ArraySeries<>(data); }  static Series<T> concat(Series<T>... concat); static Series<T> concat(Iterable<Series<T>> concat); static IntSeries intConcat(IntSeries... concat); static IntSeries intConcat(Iterable<IntSeries> concat);  }
@Test public void testConcat_Array() { Series<String> s1 = Series.forData("m", "n"); Series<String> s2 = Series.forData("a", "b"); Series<String> s3 = Series.forData("d"); Series<String> c = SeriesConcat.concat(s1, s2, s3); new SeriesAsserts(c).expectData("m", "n", "a", "b", "d"); }
@Test public void testConcat_List() { Collection<Series<String>> ss = asList( Series.forData("m", "n"), Series.forData("a", "b"), Series.forData("d")); Series<String> c = SeriesConcat.concat(ss); new SeriesAsserts(c).expectData("m", "n", "a", "b", "d"); }