Skip to content

Commit 6ac2978

Browse files
Kajetan FuchsbergerKajetan Fuchsberger
Kajetan Fuchsberger
authored and
Kajetan Fuchsberger
committed
new position factory methods
1 parent 435fd7d commit 6ac2978

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/java/org/tensorics/core/tensor/Positions.java

+11
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@
3333
import java.util.function.Function;
3434
import java.util.stream.Collectors;
3535

36+
import org.mockito.internal.util.collections.Iterables;
37+
3638
import com.google.common.base.MoreObjects;
3739
import com.google.common.base.Objects;
3840
import com.google.common.base.Preconditions;
@@ -384,6 +386,15 @@ public static Set<Position> cartesianProduct(Iterable<Set<?>> coordinateSets) {
384386
return cartesianProduct.stream().map(l -> Position.of(new HashSet<>(l))).collect(toSet());
385387
}
386388

389+
public static <T> Set<Position> from(Collection<T> coordinates) {
390+
return coordinates.stream().map(t -> Position.of(t)).collect(toSet());
391+
}
392+
393+
public static <T> Set<Position> from(T ... coordinates) {
394+
return from(ImmutableSet.copyOf(coordinates));
395+
}
396+
397+
387398
/**
388399
* Returns a position which contains the coordinates which are contained in the left position but not in the right
389400
* position. The right position might also contain coordinates not contained in the left position, which are simply

0 commit comments

Comments
 (0)