Example usage for java.util Spliterators spliteratorUnknownSize

List of usage examples for java.util Spliterators spliteratorUnknownSize

Introduction

In this page you can find the example usage for java.util Spliterators spliteratorUnknownSize.

Prototype

public static Spliterator.OfDouble spliteratorUnknownSize(PrimitiveIterator.OfDouble iterator,
        int characteristics) 

Source Link

Document

Creates a Spliterator.OfDouble using a given DoubleStream.DoubleIterator as the source of elements, with no initial size estimate.

Usage

From source file:eu.itesla_project.dymola.DymolaAdaptersMatParamsWriter.java

public DymolaAdaptersMatParamsWriter(HierarchicalINIConfiguration configuration) {
    if (configuration == null) {
        throw new RuntimeException("null config");
    }/*from  ww w .  j a v  a 2 s .c  om*/
    this.configuration = configuration;
    //this below will simply log parameters ..
    for (String section : configuration.getSections()) {
        SubnodeConfiguration node = configuration.getSection(section);
        List<String> paramsSummary = StreamSupport
                .stream(Spliterators.spliteratorUnknownSize(node.getKeys(), Spliterator.ORDERED), false)
                .map(p -> p + "=" + node.getString(p)).collect(Collectors.<String>toList());
        LOGGER.info("index {}: {}", section, paramsSummary);
    }
}

From source file:org.n52.iceland.config.json.AbstractJsonDao.java

protected Stream<Entry<String, JsonNode>> createEntryStream(JsonNode node) {
    return StreamSupport.stream(Spliterators.spliteratorUnknownSize(node.fields(), 0), true);
}

From source file:com.miovision.oss.awsbillingtools.parser.DetailedLineItemParser.java

@Override
public Stream<DetailedLineItem> parse(Reader reader) throws IOException {
    final CSVParser csvParser = CSV_FORMAT.parse(reader);
    try {//from  w  w  w.j  a  v a 2s . c om
        final Iterator<CSVRecord> iterator = csvParser.iterator();
        final List<String> tags = readTags(iterator);

        return StreamSupport.stream(Spliterators.spliteratorUnknownSize(iterator, Spliterator.ORDERED), false)
                .map(csvRecord -> createDetailedLineItem(csvRecord, tags)).onClose(() -> {
                    try {
                        csvParser.close();
                    } catch (IOException e) {
                        throw new RuntimeException(e);
                    }
                });
    } catch (Exception e) {
        csvParser.close();
        throw e;
    }
}

From source file:com.michaelwitbrock.jacksonstream.JsonArrayStreamDataSupplier.java

public Stream<T> getStream() {
    return StreamSupport.stream(Spliterators.spliteratorUnknownSize(this, 0), false);
}

From source file:com.steelbridgelabs.oss.neo4j.Neo4JTestGraphProvider.java

@Override
public Map<String, Object> getBaseConfiguration(String graphName, Class<?> test, String testMethodName,
        LoadGraphWith.GraphData graphData) {
    // build configuration
    Configuration configuration = Neo4JGraphConfigurationBuilder.connect("localhost", "neo4j", "123")
            .withName(graphName).withElementIdProvider(ElementIdProvider.class).build();
    // create property map from configuration
    Map<String, Object> map = StreamSupport
            .stream(Spliterators.spliteratorUnknownSize(configuration.getKeys(),
                    Spliterator.NONNULL | Spliterator.IMMUTABLE), false)
            .collect(Collectors.toMap(key -> key, configuration::getProperty));
    // append class name
    map.put(Graph.GRAPH, Neo4JGraph.class.getName());
    // return configuration map
    return map;//from  ww  w .j a  va 2  s .  c om
}

From source file:org.mskcc.shenkers.data.interval.GIntervalTreeMap.java

public Stream<Node<T>> streamOverlapNodes(String chr, int start, int end) {
    boolean parallel = false;
    int characteristics = 0;
    return StreamSupport.stream(
            Spliterators.spliteratorUnknownSize(queryNodes(chr, start, end), characteristics), parallel);
}

From source file:org.mskcc.shenkers.data.interval.GIntervalTreeMap.java

public Stream<Node<T>> streamOverlapNodes(String chr, int start, int end, Strand strand) {
    boolean parallel = false;
    int characteristics = 0;
    return StreamSupport.stream(
            Spliterators.spliteratorUnknownSize(queryNodes(chr, start, end, strand), characteristics),
            parallel);/*from   w  ww  . j av  a 2s .  c  o  m*/
}

From source file:org.apache.solr.client.solrj.io.eval.FindDelayEvaluator.java

@Override
public Object doWork(Object first, Object second) throws IOException {
    if (null == first) {
        throw new IOException(String.format(Locale.ROOT,
                "Invalid expression %s - null found for the first value", toExpression(constructingFactory)));
    }//from   w w w .  j  a  v  a  2  s . com
    if (null == second) {
        throw new IOException(String.format(Locale.ROOT,
                "Invalid expression %s - null found for the second value", toExpression(constructingFactory)));
    }
    if (!(first instanceof List<?>)) {
        throw new IOException(String.format(Locale.ROOT,
                "Invalid expression %s - found type %s for the first value, expecting a list of numbers",
                toExpression(constructingFactory), first.getClass().getSimpleName()));
    }
    if (!(second instanceof List<?>)) {
        throw new IOException(String.format(Locale.ROOT,
                "Invalid expression %s - found type %s for the second value, expecting a list of numbers",
                toExpression(constructingFactory), first.getClass().getSimpleName()));
    }

    // Get first and second lists as arrays, where second is in reverse order
    double[] firstArray = ((List) first).stream().mapToDouble(value -> ((BigDecimal) value).doubleValue())
            .toArray();
    double[] secondArray = StreamSupport
            .stream(Spliterators.spliteratorUnknownSize(
                    ((LinkedList) ((List) second).stream().collect(Collectors.toCollection(LinkedList::new)))
                            .descendingIterator(),
                    Spliterator.ORDERED), false)
            .mapToDouble(value -> ((BigDecimal) value).doubleValue()).toArray();

    double[] convolution = MathArrays.convolve(firstArray, secondArray);
    double maxValue = -Double.MAX_VALUE;
    double indexOfMaxValue = -1;

    for (int idx = 0; idx < convolution.length; ++idx) {
        double abs = Math.abs(convolution[idx]);
        if (abs > maxValue) {
            maxValue = abs;
            indexOfMaxValue = idx;
        }
    }

    return (indexOfMaxValue + 1) - secondArray.length;

}

From source file:org.mskcc.shenkers.data.interval.GIntervalTree.java

public Stream<Node> streamOverlapNodes(String chr, int start, int end) {
    boolean parallel = false;
    int characteristics = 0;
    return StreamSupport.stream(
            Spliterators.spliteratorUnknownSize(queryNodes(chr, start, end), characteristics), parallel);
}

From source file:org.mskcc.shenkers.data.interval.GIntervalTreeMap.java

public Stream<IntervalFeature<T>> streamOverlaps(String chr, int start, int end) {
    boolean parallel = false;
    int characteristics = 0;
    return StreamSupport.stream(Spliterators.spliteratorUnknownSize(query(chr, start, end), characteristics),
            parallel);/*from www  .  j a va  2s .  com*/
}