) and marked these APIs "stable" (as opposed to the rest of the APIs of Guava which are marked "tentative"). I've also integrated further improvements to these APIs ... and added a bunch of new stuff!
Don't be too tempted by the new stuff, as it is marked "tentative" and is still subject to change. You may prefer to still stick with the "stable" APIs (currently, just those that used to be part of google collections).
Confused yet? Please ask any questions.
com.google.common.collect:
* ComparisonChain - the best way to implement a lazy chained comparison
statement ever!
public int compareTo(Foo that) {
return ComparisonChain.start()
.compare(this.aString, that.aString)
.compare(this.anInt, that.anInt)
.compare(this.anEnum, that.anEnum, Ordering.nullsLast())
.result();
}
See
javadoc for more explanation.
* ImmutableCollection.asList() - every ImmutableCollection can be viewed as a
List now, cheaply! In fact, it's a *magical* List, because its contains()
method is as fast as the contains() method of the immutable collection that
spawned it - etc.
* Itera*s.consumingItera*(Itera*) - an iterator/iterable which automatically
removes elements as they are returned.
* Itera*s.indexOf(Itera*, Predicate) - returns the index of the first element
satisfying a predicate.
* Itera*s.removeIf(Itera*, Predicate) - removes each element that satisfies a
predicate.
* Multisets.intersection() - a multiplicity-aware intersection view of two
multisets; for example [a x 2, b x 3] intersected with [b x 2, c x 4] is
[b x 2]. The count of every element is the smaller of its count in each of
the given multisets.
* Ordering.arbitrary() - an Ordering (Comparator) for those cases where you
have no logical way to order the items at all -- see
javadoc for details.
* Ordering.lexicographical() - an Ordering (Comparator) for iterables, which
compares elements pairwise until the first nonzero result is found
("dictionary order").
* Sets.cartesianProduct() - returns the cartesian product of the given sets, in
a very memory-friendly way.
------------------------------------------