/** * @return A {@link StochasticSupplier} that draws integer values from a * normal distribution. */ public StochasticSupplier<Integer> buildInteger() { integerChecks(); return roundDoubleToInt(buildDouble()); }
/** * @return A {@link StochasticSupplier} that draws long values from a normal * distribution. */ public StochasticSupplier<Long> buildLong() { integerChecks(); return roundDoubleToLong(buildDouble()); }
/** * @param time The time to check. * @return <code>true</code> when <code>time >= {@link #begin}</code>, * <code>false</code> otherwise. */ public boolean isAfterStart(long time) { return time >= begin(); }
/** * Creates a {@link StochasticSupplier} that produces uniformly distributed * {@link Long}s. * @param lower The (inclusive) lower bound of the uniform distribution. * @param upper The (inclusive) upper bound of the uniform distribution. * @return The supplier. */ public static StochasticSupplier<Long> uniformLong(int lower, int upper) { return intToLong(uniformInt(lower, upper)); }
/** * Sets the {@link StochasticSupplier} that will be used to generate the * frequency of the {@link IntensityFunction} that will be created by this * builder. Default value: 1. * @param f Must be positive. * @return This, as per the builder pattern. */ public SineIntensityBuilder frequency(StochasticSupplier<Double> f) { frequencySup = checked(f, POSITIVE); return this; }
double get(long i) { if (tw.isIn(i)) { return load; } return 0d; }
@Override public ParcelState getParcelState(Parcel parcel) { synchronized (this) { return parcelState.getKeys(parcel); } }
/** * Convert a {@link StochasticSupplier} of {@link Double} to a supplier of * {@link Integer}. * @param supplier The supplier to convert. * @return The converted supplier. */ public static StochasticSupplier<Integer> roundDoubleToInt( StochasticSupplier<Double> supplier) { return new DoubleToIntAdapter(supplier); }
@Override public Collection<Parcel> getParcels(ParcelState state) { synchronized (this) { return parcelState.get(state); } }
@Override public boolean canDeliver(TimeWindow tw, long time, long duration) { return tw.isAfterStart(time); } };
/** * Convert a {@link StochasticSupplier} of {@link Integer} to a supplier of * {@link Long}. * @param supplier The supplier to convert. * @return The converted supplier. */ public static StochasticSupplier<Long> intToLong( StochasticSupplier<Integer> supplier) { return new IntToLongAdapter(supplier); }
/** * @return Builder for constructing {@link StochasticSupplier}s that produce * normal (Gaussian) distributed numbers. */ public static Builder normal() { return new Builder(); }
/** * Convert a {@link StochasticSupplier} of {@link Double} to a supplier of * {@link Long}. * @param supplier The supplier to convert. * @return The converted supplier. */ public static StochasticSupplier<Long> roundDoubleToLong( StochasticSupplier<Double> supplier) { return new DoubleToLongAdapter(supplier); }
@Override public Collection<Parcel> getParcels(ParcelState... states) { synchronized (this) { return parcelState.getMultiple(states); } }
/** * Sets the {@link StochasticSupplier} that will be used to generate the * amplitude of the {@link IntensityFunction} that will be created by this * builder. Default value: 1. * @param a Must be positive. * @return This, as per the builder pattern. */ public SineIntensityBuilder amplitude(StochasticSupplier<Double> a) { amplitudeSup = checked(a, POSITIVE); return this; }
@Override public boolean canDeliver(TimeWindow tw, long time, long duration) { return tw.isIn(time); } },
/** * Sets the {@link StochasticSupplier} that will be used to generate the * phaseShift of the {@link IntensityFunction} that will be created by this * builder. Default value: 1/2. * @param s The phase shift. * @return This, as per the builder pattern. */ public SineIntensityBuilder phaseShift(StochasticSupplier<Double> s) { phaseShiftSup = checked(s, FINITE); return this; }