Convenient methods in old Iterable
Marcos Antonio
marcos_antonio_ps at hotmail.com
Fri Oct 19 04:21:02 PDT 2012
Thank you for the answer, Paul. What I meant was that I had code like this: Iterable<Employee> i = employees.filter(...); Now I called i.isEmpty() or i.count(). The code was converted to this: Stream<Employee> s = employees.stream().filter(...); What is the best way to know now if the stream is empty or its count? Thank you. Marcos > Subject: Re: Convenient methods in old Iterable
> From: paul.sandoz at oracle.com
> Date: Fri, 19 Oct 2012 13:00:44 +0200
> CC: lambda-dev at openjdk.java.net
> To: marcos_antonio_ps at hotmail.com
>
> On Oct 19, 2012, at 3:53 AM, Marcos Antonio <marcos_antonio_ps at hotmail.com> wrote:
> > Hello! The methods isEmpty() and count() in Iterable were very convenient to me.
>
> An Iterable may not know it's size, or the elements of the Iterable cannot be efficiently counted. See the Sized interface.
>
>
> > Now with Stream do I always need to convert the stream to a collection or an array (into() and toArray() methods) to get the same functionality or is there an easier way? Thank you.
> >
>
>
> You might be able to check if the Iterable is an instance of Sized.
>
> Paul.
More information about the lambda-dev
mailing list