ArrayIterator
is handy (although I don't need the reset
functionality), but like the rest of the Commons Collections stuff, it doesn't use generics. I checked Google Collections, but I didn't see a close equivalent. Did I miss it? Is there another library of similar reputation and quality as the first two that provides such a thing? Thanks.
Description: The Apache Commons Collections is a project used to develop and maintain a collection of classes based on and inspired by the Java Development Kit (JDK) collection framework. This group of collections includes features such as: Bag interfaces for collections that have a number of copies of each object.
Simply put, the Apache CollectionUtils provides utility methods for common operations which cover a wide range of use cases and helps in avoiding writing boilerplate code. The library targets older JVM releases because currently, similar functionality is provided by the Java 8's Stream API.
MyObject res = CollectionUtils. find(myList, new Predicate<MyObject>() { @Override public boolean evaluate(MyObject o) { return o. getValue() >= 1 && o. getValue() <= 5; } });
CollectionUtils class of Apache Commons Collections library provides various utility methods for common operations covering wide range of use cases. It helps avoid writing boilerplate code. This library is very useful prior to jdk 8 as similar functionalities are now provided in Java 8's Stream API.
Arrays.asList(array).iterator()
Arrays.asList(array).subList(start, end).iterator()
These method calls are cheap -- they don't actually copy any data. The Arrays
class is in java.util
, of course.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With