i have set, divide smaller sets of size x. guava has similar lists - lists.partition. couldn't find related sets. there libraries can me in doing this? if not, what's best way break set smaller sets?
edit: currently, i'm doing follows:
int x = 10; set<string> stringset = createhashset(); (list<string> partition : iterables.partition(stringset, x) { dosomething(new hashset<>(partition)); }
i'm using iterables.partition. there should better ways it, doesn't involve converting set list, , set.
set<integer> input = /*defined elsewhere*/; int x = 10; list<set<integer>> output = new arraylist<>(); set<integer> currset = null; (integer value : input) { if (currset == null || currset.size() == x) output.add(currset = new hashset<>()); currset.add(value); }
result is, intends , purposes, random. undefined elements of input set going set of output, , within output set, values in arbitrary order.
Comments
Post a Comment