I have a set, which I would like to divide into smaller sets of size x. Guava has something similar for lists - Lists.partition. But I couldn't find anything related to Sets. Are there any libraries which can help me in doing this? If not, what's the best way to break a set into smaller sets?
Edit: Currently, I'm doing it as follows:
int x = 10;
Set<String> stringSet = createHashSet();
for (List<String> partition : Iterables.partition(stringSet, x) {
doSomething(new HashSet<>(partition));
}
I'm using this Iterables.partition. There should be better ways to do it, which doesn't involve converting set to a list, and then back to a set.