Alec Muffett
10/30/2020, 7:12 AMSequenceInputStream()
takes a Java Enumeration
as an argument, but at the moment I only have a `List<InputStream>`; there's a workaround for this described at https://www.pushing-pixels.org/2018/08/15/converting-list-to-enumeration-in-kotlin.html to provide a List<T>.toEnumeration()
method, but I am wondering if there's something more elegant?Vampire
10/30/2020, 10:03 AMVector
instances:
inList.reduce { left, right -> SequenceInputStream(left, right) }
Another way would be
SequenceInputStream(Vector(inList).elements())
Alec Muffett
10/30/2020, 4:12 PMAlec Muffett
10/30/2020, 4:14 PMVampire
10/30/2020, 4:34 PMasEnumeration()
method?
Maybenanodeath
10/30/2020, 9:10 PMprivate operator fun InputStream.plus(inputStream: InputStream): InputStream = SequenceInputStream(this, inputStream)
might be what you wantVampire
10/31/2020, 10:46 AMinList.sum()
, but it is basically the same as my reduce call and thus will create n-1 new Vector
instances.nanodeath
11/02/2020, 4:30 PMVector
instances thoughVampire
11/02/2020, 5:17 PMSequenceInputStream
constructor you are calling 😉nanodeath
11/02/2020, 5:18 PMnanodeath
11/02/2020, 5:29 PMnanodeath
11/02/2020, 5:29 PMVampire
11/02/2020, 6:06 PMVampire
11/02/2020, 6:06 PMVampire
11/02/2020, 6:07 PMnanodeath
11/02/2020, 6:27 PMVampire
11/02/2020, 6:36 PMSequenceInputStream
is simply very old and pre-collections framework.
I wonder they didn't add a collections variant.nanodeath
11/02/2020, 6:38 PMVampire
11/02/2020, 6:44 PMnanodeath
11/02/2020, 6:46 PM