List of usage examples for java.util.stream DoubleStream builder
public static Builder builder()
From source file:Main.java
public static void main(String[] args) { DoubleStream.Builder b = DoubleStream.builder(); b.add(1.1).add(2.2).add(3.3).add(4.4); b.build().forEach(System.out::println); }
From source file:Main.java
public static void main(String[] args) { DoubleStream.Builder b = DoubleStream.builder(); b.accept(1.2);//from www . j a va 2 s .co m b.accept(1.2); b.accept(1.2); DoubleStream d = b.build(); d.forEach(System.out::println); }
From source file:Main.java
public static void main(String[] args) { DoubleStream.Builder b = DoubleStream.builder(); b.accept(1.1);/*ww w . ja va2 s .c o m*/ b.accept(2.2); b.accept(3.3); b.accept(4.4); b.build().forEach(System.out::println); }
From source file:org.jamocha.rating.fraj.RatingProvider.java
/** * dnrating (38)/*from ww w . j av a2s . co m*/ * * @param statisticsProvider * @param inputComponent * @param joinOrder * @param positiveExistentialComponents * @param negativeExistentialComponents * @param pathToPreNetworkComponents * @param xOverUX * @return */ private double joinSize(final StatisticsProvider statisticsProvider, final Set<PathFilterList> inputComponent, final List<Pair<List<Set<PathFilterList>>, List<PathFilter>>> joinOrder, final Set<Set<PathFilterList>> positiveExistentialComponents, final Set<Set<PathFilterList>> negativeExistentialComponents, final Map<Path, Set<PathFilterList>> pathToPreNetworkComponents, final double xOverUX) { final double[] jsfs = statisticsProvider.getAllJSFs(inputComponent, joinOrder, pathToPreNetworkComponents); // dnrating (35) final double sum; { final Builder values = DoubleStream.builder(); int i = 0; for (final Pair<List<Set<PathFilterList>>, List<PathFilter>> element : joinOrder) { assert i < jsfs.length; final List<Set<PathFilterList>> components = element.getLeft(); for (final Set<PathFilterList> component : components) { if (positiveExistentialComponents.contains(component)) { values.accept(statisticsProvider.getData(component).getRowCount() * (1 - jsfs[i])); } else if (negativeExistentialComponents.contains(component)) { values.accept(statisticsProvider.getData(component).getRowCount() * jsfs[i]); } } ++i; } sum = values.build().sum(); } final Builder sizes = DoubleStream.builder(); int i = 0; for (final Pair<List<Set<PathFilterList>>, List<PathFilter>> element : joinOrder) { final List<Set<PathFilterList>> components = element.getLeft(); final Iterator<Set<PathFilterList>> iterator = components.iterator(); final Set<PathFilterList> component = iterator.next(); if (positiveExistentialComponents.contains(component)) { sizes.accept(Math.pow(xOverUX, statisticsProvider.getData(component).getRowCount() * (1 - jsfs[i]) / sum)); } else if (negativeExistentialComponents.contains(component)) { sizes.accept( Math.pow(xOverUX, statisticsProvider.getData(component).getRowCount() * jsfs[i] / sum)); } else { sizes.accept(jsfs[i]); sizes.accept(statisticsProvider.getData(component).getRowCount()); while (iterator.hasNext()) { sizes.accept(statisticsProvider.getData(iterator.next()).getRowCount()); } } ++i; } return sizes.build().sum(); }
From source file:org.jamocha.rating.fraj.RatingProvider.java
private double costPosInsVarII(final StatisticsProvider statisticsProvider, final Set<PathFilterList> inputComponent, final List<Pair<List<Set<PathFilterList>>, List<PathFilter>>> joinOrder, final Set<Set<PathFilterList>> regularComponents, final Map<Path, Set<PathFilterList>> pathToPreNetworkComponents) { final double[] jsfs = statisticsProvider.getAllJSFs(inputComponent, joinOrder, pathToPreNetworkComponents); assert jsfs.length == joinOrder.size(); final Builder costs = DoubleStream.builder(); double size = 1.0; int i = 0;//w w w . j av a 2 s. c o m for (final Pair<List<Set<PathFilterList>>, List<PathFilter>> pair : joinOrder) { final List<Set<PathFilterList>> components = pair.getLeft(); final Set<PathFilterList> component = components.get(0); if (regularComponents.contains(component)) { if (component.size() > 1) { final int lastIndex = components.size() - 1; for (int ci = 0; ci < lastIndex; ++ci) { costs.accept( jc(statisticsProvider, 1.0, statisticsProvider.getData(components.get(ci)), size)); } costs.accept(jc(statisticsProvider, jsfs[i], statisticsProvider.getData(components.get(lastIndex)), size)); } else { costs.accept(jc(statisticsProvider, jsfs[i], statisticsProvider.getData(component), size)); } size *= statisticsProvider.getData(component).getRowCount() * jsfs[i]; } else { costs.accept(jc( statisticsProvider, statisticsProvider.getJSF(regularComponents, component, pair.getRight().get(0), pathToPreNetworkComponents), statisticsProvider.getData(component), size)); } ++i; } return costs.add(size).build().sum(); }
From source file:org.jamocha.rating.fraj.RatingProvider.java
private double costNegDelVarII(final StatisticsProvider statisticsProvider, final Set<PathFilterList> inputComponent, final List<Pair<List<Set<PathFilterList>>, List<PathFilter>>> joinOrder, final Map<Path, Set<PathFilterList>> pathToPreNetworkComponents) { final double[] jsfs = statisticsProvider.getAllJSFs(inputComponent, joinOrder, pathToPreNetworkComponents); assert jsfs.length == joinOrder.size(); final Builder costs = DoubleStream.builder(); double size = 1.0; int i = 0;//w ww. j ava 2s .co m for (final Pair<List<Set<PathFilterList>>, List<PathFilter>> pair : joinOrder) { final List<Set<PathFilterList>> components = pair.getLeft(); final Set<PathFilterList> component = components.get(0); if (component.size() > 1) { final int lastIndex = components.size() - 1; for (int ci = 0; ci < lastIndex; ++ci) { costs.accept(jc(statisticsProvider, 1.0, statisticsProvider.getData(components.get(ci)), size)); } costs.accept(jc(statisticsProvider, jsfs[i], statisticsProvider.getData(components.get(lastIndex)), size)); } else { costs.accept(jc(statisticsProvider, jsfs[i], statisticsProvider.getData(component), size)); } size *= statisticsProvider.getData(component).getRowCount() * jsfs[i]; ++i; } return costs.add(size).build().sum(); }