DoublesScheduleGenerator { public static double[] combineSets(final double[] set1, final double[] set2) { final int n1 = set1.length; final int n2 = set2.length; final int n = n1 + n2; final double[] set = new double[n]; System.arraycopy(set1, 0, set, 0, n1); System.arraycopy(set2, 0, set, n1, n2); Arrays.sort(set); final double[] temp = new double[n]; temp[0] = set[0]; int pos = 0; for (int i = 1; i < n; i++) { if (different(temp[pos], set[i])) { temp[++pos] = set[i]; } } final int resLength = pos + 1; if (resLength == n) { return temp; } final double[] res = new double[resLength]; System.arraycopy(temp, 0, res, 0, resLength); return res; }  static double[] getIntegrationsPoints(final double start, final double end, final ISDACompliantYieldCurve yieldCurve, final ISDACompliantCreditCurve creditCurve); static double[] getIntegrationsPoints(final double start, final double end, final double[] setA, final double[] setB); static double[] combineSets(final double[] set1, final double[] set2); static double[] truncateSetInclusive(final double lower, final double upper, final double[] set); static double[] truncateSetExclusive(final double lower, final double upper, final double[] set); static double[] leftTruncate(final double lower, final double[] set);  }
@Test public void combineSetsTest() { final double[] setA0 = new double[] {-2., -1., 0., 2. }; final double[] setB0 = new double[] {-1., -0., 2.1 }; final double[] exp0 = new double[] {-2., -1., 0., 2., 2.1 }; final double[] res0 = DoublesScheduleGenerator.combineSets(setA0, setB0); assertTrue(equalArrays(res0, exp0)); final double[] setA1 = new double[] {-2., 0., 2. }; final double[] setB1 = new double[] {-1., 2.1 }; final double[] exp1 = new double[] {-2., -1., 0., 2., 2.1 }; final double[] res1 = DoublesScheduleGenerator.combineSets(setA1, setB1); assertTrue(equalArrays(res1, exp1)); }