Can we have Collection.containsAny(Collection<?>)
Lukas Eder
lukas.eder at gmail.com
Wed Mar 20 01:33:51 PDT 2013
- Previous message: Fwd: hg: lambda/lambda/jdk: Eliminate Collector.Of{Int,Long,Double}; make {Int,Long,Double}Statistics top-level classes; add .statistics() methods to {Int,Long,DOuble}Stream; add Collectors.to{ILD}Statistics(mapper); add Collectors.reduce(mapper, reducer); eliminate Collectors.mapper forms; more efficient implementation of {ILD}Stream.average
- Next message: hg: lambda/lambda/jdk: Eliminate Collector.Of{Int,Long,Double}; make {Int,Long,Double}Statistics top-level classes; add .statistics() methods to {Int,Long,DOuble}Stream; add Collectors.to{ILD}Statistics(mapper); add Collectors.reduce(mapper, reducer); eliminate Collectors.mapper forms; more efficient implementation of {ILD}Stream.average
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Hello,
We already have a method to check if *all* elements of Collection A
are contained in Collection B:
boolean all = B.containsAll(A);
I often find myself trying to see if *any* element in Collection A is
contained in Collection B. I think this would be a low-hanging fruit
to add to the Collection interface as a default method:
boolean any = B.containsAny(A);
With
default boolean containsAny(Collection<?> c) {
for (Object e : c)
if (contains(e))
return true;
return false;
}
Also, are there any plans of adding default implementations for other
Collection methods, e.g.
// Promoted from AbstractCollection
default boolean containsAll(Collection<?> c) {
for (Object e : c)
if (!contains(e))
return false;
return true;
}
Or is there some subtle backwards-compatibility issue that I'm missing?
Cheers
Lukas
- Previous message: Fwd: hg: lambda/lambda/jdk: Eliminate Collector.Of{Int,Long,Double}; make {Int,Long,Double}Statistics top-level classes; add .statistics() methods to {Int,Long,DOuble}Stream; add Collectors.to{ILD}Statistics(mapper); add Collectors.reduce(mapper, reducer); eliminate Collectors.mapper forms; more efficient implementation of {ILD}Stream.average
- Next message: hg: lambda/lambda/jdk: Eliminate Collector.Of{Int,Long,Double}; make {Int,Long,Double}Statistics top-level classes; add .statistics() methods to {Int,Long,DOuble}Stream; add Collectors.to{ILD}Statistics(mapper); add Collectors.reduce(mapper, reducer); eliminate Collectors.mapper forms; more efficient implementation of {ILD}Stream.average
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the lambda-libs-spec-observers
mailing list