@Override public LongStream events() throws IOException { DataInputStream input = new DataInputStream(new BufferedInputStream(readFiles())); LongStream stream = StreamSupport.longStream(Spliterators.spliteratorUnknownSize( new TraceIterator(input), Spliterator.ORDERED), /* parallel */ false); return stream.onClose(() -> Closeables.closeQuietly(input)); }
public static LongStream toLongStream(PrimitiveLongIterator it) { PrimitiveIterator.OfLong iterator = new PrimitiveIterator.OfLong() { @Override public boolean hasNext() { return it.hasNext(); } @Override public long nextLong() { return it.next(); } }; return StreamSupport.longStream(Spliterators.spliteratorUnknownSize( iterator, Spliterator.ORDERED | Spliterator.IMMUTABLE | Spliterator.NONNULL), false); }
@Override default LongStream mapToLong(ToLongFunction<? super T> fn){ Spliterator<T> split = this.spliterator(); return (split instanceof Spliterator.OfLong)? StreamSupport.longStream((Spliterator.OfLong)split,false) : StreamSupport.stream(split,false).mapToLong(fn); }
@Override default LongStream mapToLong(ToLongFunction<? super T> fn){ Spliterator<T> split = this.spliterator(); return (split instanceof Spliterator.OfLong)? StreamSupport.longStream((Spliterator.OfLong)split,false) : StreamSupport.stream(split,false).mapToLong(fn); }
/** * Generates a LongStream that traverses long-valued values of a scala.collection.immutable.HashMap. * <p> * Both sequential and parallel operations will be efficient. * * @param coll The immutable.HashMap to traverse * @return A LongStream view of the collection which, by default, executes sequentially. */ public static LongStream longStreamValues(scala.collection.immutable.HashMap<? super Object, Long> coll) { return StreamSupport.longStream(new StepsLongImmHashMapValue(coll, 0, coll.size()), false); }
/** * Generates a LongStream that traverses long-valued keys of a scala.collection.immutable.HashMap. * <p> * Both sequential and parallel operations will be efficient. * * @param coll The immutable.HashMap to traverse * @return A LongStream view of the collection which, by default, executes sequentially. */ public static LongStream longStreamKeys(scala.collection.immutable.HashMap<Long, ? super Object> coll) { return StreamSupport.longStream(new StepsLongImmHashMapKey(coll, 0, coll.size()), false); }
/** * Generates a LongStream that traverses a scala.collection.mutable.HashSet of Longs. * <p> * Both sequential and parallel operations will be efficient. * * @param coll The mutable.HashSet to traverse * @return A LongStream view of the collection which, by default, executes sequentially. */ public static LongStream longStream(scala.collection.mutable.HashSet<Long> coll) { Object[] tbl = CollectionInternals.getTable(coll); return StreamSupport.longStream(new StepsLongFlatHashTable(tbl, 0, tbl.length), false); }
/** * Generates a LongStream that traverses an IndexedSeq of Longs. * <p> * Both sequential and parallel operations will be efficient. * * @param coll The IndexedSeq to traverse * @return A LongStream view of the collection which, by default, executes sequentially. */ public static LongStream longStream(scala.collection.IndexedSeq<Long> coll) { return StreamSupport.longStream(new StepsLongIndexedSeq(coll, 0, coll.length()), false); }
/** * Generates a LongStream that traverses long-valued values of a scala.collection.immutable.HashMap. * <p> * Both sequential and parallel operations will be efficient. * * @param coll The immutable.HashMap to traverse * @return A LongStream view of the collection which, by default, executes sequentially. */ public static LongStream longStreamValues(scala.collection.immutable.HashMap<? super Object, Long> coll) { return StreamSupport.longStream(new StepsLongImmHashMapValue(coll, 0, coll.size()), false); }
/** * Generates a LongStream that traverses long-valued keys of a scala.collection.mutable.HashMap. * <p> * Both sequential and parallel operations will be efficient. * * @param coll The mutable.HashMap to traverse * @return A LongStream view of the collection which, by default, executes sequentially. */ public static LongStream longStreamKeys(scala.collection.mutable.HashMap<Long, ?> coll) { scala.collection.mutable.HashEntry[] tbl = CollectionInternals.getTable(coll); return StreamSupport.longStream(new StepsLongHashTableKey(tbl, 0, tbl.length), false); }
/** * Generates a LongStream that traverses long-valued values of a scala.collection.mutable.HashMap. * <p> * Both sequential and parallel operations will be efficient. * * @param coll The mutable.HashMap to traverse * @return A LongStream view of the collection which, by default, executes sequentially. */ public static LongStream longStreamValues(scala.collection.mutable.HashMap<? super Object, Long> coll) { scala.collection.mutable.HashEntry[] tbl = CollectionInternals.getTable(coll); return StreamSupport.longStream(new StepsLongDefaultHashTableValue(tbl, 0, tbl.length), false); }
/** * Generates a LongStream that traverses long-valued values of a scala.collection.immutable.HashMap. * <p> * Both sequential and parallel operations will be efficient. * * @param coll The immutable.HashMap to traverse * @return A LongStream view of the collection which, by default, executes sequentially. */ public static LongStream longStreamValues(scala.collection.immutable.HashMap<? super Object, Long> coll) { return StreamSupport.longStream(new StepsLongImmHashMapValue(coll, 0, coll.size()), false); }
/** * Generates a LongStream that traverses long-valued keys of a scala.collection.immutable.HashMap. * <p> * Both sequential and parallel operations will be efficient. * * @param coll The immutable.HashMap to traverse * @return A LongStream view of the collection which, by default, executes sequentially. */ public static LongStream longStreamKeys(scala.collection.immutable.HashMap<Long, ? super Object> coll) { return StreamSupport.longStream(new StepsLongImmHashMapKey(coll, 0, coll.size()), false); }
/** * Generates a LongStream that traverses an IndexedSeq of Longs. * <p> * Both sequential and parallel operations will be efficient. * * @param coll The IndexedSeq to traverse * @return A LongStream view of the collection which, by default, executes sequentially. */ public static LongStream longStream(scala.collection.IndexedSeq<Long> coll) { return StreamSupport.longStream(new StepsLongIndexedSeq(coll, 0, coll.length()), false); }
/** * Generates a LongStream that traverses long-valued keys of a scala.collection.immutable.HashMap. * <p> * Both sequential and parallel operations will be efficient. * * @param coll The immutable.HashMap to traverse * @return A LongStream view of the collection which, by default, executes sequentially. */ public static LongStream longStreamKeys(scala.collection.immutable.HashMap<Long, ? super Object> coll) { return StreamSupport.longStream(new StepsLongImmHashMapKey(coll, 0, coll.size()), false); }
/** * Generates a LongStream that traverses long-valued values of a scala.collection.mutable.HashMap. * <p> * Both sequential and parallel operations will be efficient. * * @param coll The mutable.HashMap to traverse * @return A LongStream view of the collection which, by default, executes sequentially. */ public static LongStream longStreamValues(scala.collection.mutable.HashMap<? super Object, Long> coll) { scala.collection.mutable.HashEntry[] tbl = CollectionInternals.getTable(coll); return StreamSupport.longStream(new StepsLongDefaultHashTableValue(tbl, 0, tbl.length), false); }
/** * Generates a LongStream that traverses a scala.collection.mutable.HashSet of Longs. * <p> * Both sequential and parallel operations will be efficient. * * @param coll The mutable.HashSet to traverse * @return A LongStream view of the collection which, by default, executes sequentially. */ public static LongStream longStream(scala.collection.mutable.HashSet<Long> coll) { Object[] tbl = CollectionInternals.getTable(coll); return StreamSupport.longStream(new StepsLongFlatHashTable(tbl, 0, tbl.length), false); }
/** * Generates a LongStream that traverses an IndexedSeq of Longs. * <p> * Both sequential and parallel operations will be efficient. * * @param coll The IndexedSeq to traverse * @return A LongStream view of the collection which, by default, executes sequentially. */ public static LongStream longStream(scala.collection.IndexedSeq<Long> coll) { return StreamSupport.longStream(new StepsLongIndexedSeq(coll, 0, coll.length()), false); }
/** * Generates a LongStream that traverses a scala.collection.mutable.HashSet of Longs. * <p> * Both sequential and parallel operations will be efficient. * * @param coll The mutable.HashSet to traverse * @return A LongStream view of the collection which, by default, executes sequentially. */ public static LongStream longStream(scala.collection.mutable.HashSet<Long> coll) { Object[] tbl = CollectionInternals.getTable(coll); return StreamSupport.longStream(new StepsLongFlatHashTable(tbl, 0, tbl.length), false); }
public void testLongToArray() { Cache<Long, String> cache = getCache(0); int range = 10; // First populate the cache with a bunch of values LongStream.range(0, range).boxed().forEach(i -> cache.put(i, i + "-value")); assertEquals(range, cache.size()); CacheSet<Map.Entry<Long, String>> entrySet = cache.entrySet(); long[] array = createStream(entrySet).mapToLong(toLong).toArray(); assertEquals(cache.size(), array.length); Spliterator.OfLong spliterator = Spliterators.spliterator(array, Spliterator.DISTINCT); StreamSupport.longStream(spliterator, true).forEach(e -> assertTrue(cache.containsKey(e))); }