3 ms·
For people getting into Java 8, jOOL is a great, small library with a "Seq" class that fills in the gaps missing in j.u.stream.Stream: https://github.com/jOOQ/
by stephen 11y ago
For people getting into Java 8, jOOL is a great, small library with a "Seq" class that fills in the gaps missing in j.u.stream.Stream:
https://github.com/jOOQ/jOOL https://github.com/jOOQ/jOOL
E.g. if you're coming from groovy/Scala and wonder "why doesn't Stream have this method?", Seq probably either already has it, or the maintainer will be open to adding it for you.
So, use jOOL. It's great.
That said, I still cringe that we have to do "someCollection.stream()..." (or use fill-ins like jOOL) at all, because these methods aren't on j.u.List/etc. itself...
My naive impression is that the JDK designers fixated on making streams support parallelization (because fancy!), and so made some compromises on the API, when in reality 98% of collections are small/not parallel, and I assert a non-parallel, more complete API (e.g. more default methods directly on j.u.List/j.u.Iterable themselves) would have been a net-win to most programmers.
And the parallelized version could be a separate library/jar/something.
- mkobit 11y agoThat library has some fun/interesting generics declarations like this one (https://github.com/jOOQ/jOOL/blob/master/src/main/java/org/jooq/lambda/Seq.java#L4301-L4303 https://github.com/jOOQ/jOOL/blob/master/src/main/java/org/j...) > static <T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16> Seq<Tuple16<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16>> crossJoin(...
- arjie 11y agoSort of like http://www.scala-lang.org/api/current/index.html#scala.Tuple22 http://www.scala-lang.org/api/current/index.html#scala.Tuple...
- masklinn 11y agoPretty much all languages with generics will have that kind of declarations, the only question is how many type parameters they'll go up to. In C# Action goes up to 16[0] while Rust's tuple go to 12[1] and GHC goes to 62[2] (intending 100, but a comment notes declaration of a 63-wide tuple constructor segfaults) [0] https://msdn.microsoft.com/en-us/library/dd402872(v=vs.110).aspx https://msdn.microsoft.com/en-us/library/dd402872(v=vs.110).... [1] https://github.com/rust-lang/rust/blob/master/src/libcore/tuple.rs#L238 https://github.com/rust-lang/rust/blob/master/src/libcore/tu... [2] https://downloads.haskell.org/~ghc/7.2.2/docs/html/libraries/ghc-prim-0.2.0.0/src/GHC-Tuple.html https://downloads.haskell.org/~ghc/7.2.2/docs/html/libraries...