All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.link_intersystems.graph.tree.Iterators Maven / Gradle / Ivy

Go to download

There is a newer version: 1.9.7
Show newest version
package com.link_intersystems.graph.tree;

import java.util.Iterator;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import java.util.stream.StreamSupport;

/**
 * @author René Link {@literal }
 */
public class Iterators {


    public static  Stream toStream(Iterator iterator) {
        Iterable iterable = () -> iterator;
        return toStream(iterable);
    }

    public static  Stream toStream(Iterable iterable) {
        return StreamSupport.stream(iterable.spliterator(), false);
    }


    public static  List toList(Iterable iterable) {
        return toList(iterable.iterator());
    }

    public static  List toList(Iterator iterator) {
        return toStream(iterator).collect(Collectors.toList());
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy