### Question:
AllocationCandidateIterator implements Iterator<AllocationCandidate> { public static <L, R> List<List<Pair<L, R>>> traverse(List<L> lefts, Set<R> rights) { Stack<Pair<L, R>> pairSet = new Stack<Pair<L, R>>(); List<List<Pair<L, R>>> pairSets = new ArrayList<List<Pair<L, R>>>(); traverse(lefts, rights, 0, pairSet, pairSets); return pairSets; } AllocationCandidateIterator(ObjectManager objectManager, List<CandidateHostInfo> hostInfos, List<Long> volumeIds); @Override boolean hasNext(); static List<List<Pair<L, R>>> traverse(List<L> lefts, Set<R> rights); static void traverse(List<L> lefts, Set<R> rights, int i, Stack<Pair<L, R>> pairSet, List<List<Pair<L, R>>> pairSets); @Override AllocationCandidate next(); @Override void remove();  }### Answer:
@Test public void test() { List<List<Pair<String, String>>> lists = AllocationCandidateIterator.traverse(Arrays.asList("a", "b", "c"), new LinkedHashSet<String>(Arrays.asList( "1", "2", "3", "4"))); if (print) { for (List<Pair<String, String>> pair : lists) { System.out.println(StringUtils.join(pair, ",")); } } assertEquals((long) Math.pow(4, 3), lists.size()); lists = AllocationCandidateIterator.traverse(Arrays.asList("a", "b"), new LinkedHashSet<String>(Arrays.asList("1", "2", "3"))); if (print) { for (List<Pair<String, String>> pair : lists) { System.out.println(StringUtils.join(pair, ",")); } } assertEquals((long) Math.pow(3, 2), lists.size()); }