| 1222 | private final transient CartesianList<E> delegate; |
| 1223 | |
| 1224 | static <E> Set<List<E>> create(List<? extends Set<? extends E>> sets) { |
| 1225 | ImmutableList.Builder<ImmutableSet<E>> axesBuilder = new ImmutableList.Builder<ImmutableSet<E>>(sets.size()); |
| 1226 | for (Set<? extends E> set : sets) { |
| 1227 | ImmutableSet<E> copy = ImmutableSet.copyOf(set); |
| 1228 | if (copy.isEmpty()) { |
| 1229 | return ImmutableSet.of(); |
| 1230 | } |
| 1231 | axesBuilder.add(copy); |
| 1232 | } |
| 1233 | final ImmutableList<ImmutableSet<E>> axes = axesBuilder.build(); |
| 1234 | ImmutableList<List<E>> listAxes = new ImmutableList<List<E>>() { |
| 1235 | @Override |
| 1236 | public int size() { |
| 1237 | return axes.size(); |
| 1238 | } |
| 1239 | |
| 1240 | @Override |
| 1241 | public List<E> get(int index) { |
| 1242 | return axes.get(index).asList(); |
| 1243 | } |
| 1244 | |
| 1245 | @Override |
| 1246 | boolean isPartialView() { |
| 1247 | return true; |
| 1248 | } |
| 1249 | }; |
| 1250 | return new CartesianSet<E>(axes, new CartesianList<E>(listAxes)); |
| 1251 | } |
| 1252 | |
| 1253 | private CartesianSet(ImmutableList<ImmutableSet<E>> axes, CartesianList<E> delegate) { |
| 1254 | this.axes = axes; |