Hadn't used Commons Collections until recently, as Tom recently blogged about Closure Time for Java.
It includes Predicates for equals, and and others.
Related: Functional programming in the Java language and Commons Primitives package (another implementation of primitive collections).
3 comments:
Bah! .Net 2.0 has this functionality baked into the framework. Check out the documentation on the generic List class. It provides an Exists, Find, FindAll, FindIndex, FindLast, FindLastIndex, ForEach, FindAll and RemoveAll method which take a delegate (method pointer) of type 'bool Predicate<T>' (basically, any method taking the generic type of the List and returning a boolean).
No reliance on dodgy Apache Commons libraries required!
I have to say I agree that Microsoft has done quite a lot of good stuff in .NET 2. I especially like the fact that they changed the VM so that you can test drive the type of List, Map, etc - it's not implemented with erasure like in Java. This means at runtime in Java you don't know what type something is. That really sucks.
Oh and I think trove4j is a lot better anyway.
Post a Comment