List of usage examples for com.google.common.collect ImmutableSortedSet headSet
public ImmutableSortedSet<E> headSet(E toElement)
From source file:com.facebook.buck.io.file.PathListing.java
private static ImmutableSortedSet<Path> subSet(ImmutableSortedSet<Path> paths, FilterMode filterMode, int limitIndex) { // This doesn't copy the contents of the ImmutableSortedSet. We use it // as a simple way to get O(1) access to the set's contents, as otherwise // we would have to iterate to find the Nth element. ImmutableList<Path> pathsList = paths.asList(); boolean fullSet = limitIndex == paths.size(); switch (filterMode) { case INCLUDE: // Make sure we don't call pathsList.get(pathsList.size()). if (!fullSet) { paths = paths.headSet(pathsList.get(limitIndex)); }/* w w w . j a v a 2s. c o m*/ break; case EXCLUDE: if (fullSet) { // Make sure we don't call pathsList.get(pathsList.size()). paths = ImmutableSortedSet.of(); } else { paths = paths.tailSet(pathsList.get(limitIndex)); } break; } return paths; }