//------------------------------------------------------------------------- public virtual void test_negate() { ObjDoublePredicate <string> fn1 = (a, b) => b > 3; ObjDoublePredicate <string> negate = fn1.negate(); assertEquals(fn1.test("a", 2.3d), false); assertEquals(fn1.test("a", 3.2d), true); assertEquals(negate.test("a", 2.3d), true); assertEquals(negate.test("a", 3.2d), false); }
//------------------------------------------------------------------------- public virtual void test_or() { ObjDoublePredicate <string> fn1 = (a, b) => b > 3; ObjDoublePredicate <string> fn2 = (a, b) => a.length() > 3; ObjDoublePredicate <string> or = fn1.or(fn2); assertEquals(fn1.test("a", 2.3d), false); assertEquals(fn1.test("a", 3.2d), true); assertEquals(fn2.test("a", 3.2d), false); assertEquals(fn2.test("abcd", 3.2d), true); assertEquals(or.test("a", 2.3d), false); assertEquals(or.test("a", 3.2d), true); assertEquals(or.test("abcd", 2.3d), true); assertEquals(or.test("abcd", 3.2d), true); }
public LocalDateDoubleTimeSeries filter(ObjDoublePredicate <LocalDate> predicate) { ArgChecker.notNull(predicate, "predicate"); // build up result in arrays keeping track of count of retained dates LocalDate[] resDates = new LocalDate[size()]; double[] resValues = new double[size()]; int resCount = 0; for (int i = 0; i < size(); i++) { if (predicate.test(dates_Renamed[i], values_Renamed[i])) { resDates[resCount] = dates_Renamed[i]; resValues[resCount] = values_Renamed[i]; resCount++; } } return(createUnsafe(Arrays.copyOf(resDates, resCount), Arrays.copyOf(resValues, resCount))); }