Skip to content

Commit

Permalink
combinatorics: Break out logic to internal
Browse files Browse the repository at this point in the history
  • Loading branch information
minborg committed May 1, 2017
1 parent 1e85e5f commit ab63606
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 12 deletions.
Expand Up @@ -14,8 +14,9 @@
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.speedment.runtime.core.internal.util.testing;
package com.speedment.common.benchmark.internal;

import com.speedment.common.benchmark.Stopwatch;
import java.util.concurrent.TimeUnit;

import static java.util.concurrent.TimeUnit.*;
Expand All @@ -29,7 +30,7 @@ public final class StopwatchImpl implements Stopwatch {
private long start;
private long stop;

StopwatchImpl() {
public StopwatchImpl() {
reset();
}

Expand Down
Expand Up @@ -14,8 +14,9 @@
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.speedment.runtime.core.internal.util.testing;
package com.speedment.common.combinatorics.internal;

import com.speedment.common.combinatorics.*;
import java.util.*;
import java.util.function.Consumer;
import static java.util.stream.Collectors.toList;
Expand All @@ -26,7 +27,7 @@
*
* @author Per Minborg
*/
public final class Combination {
public final class CombinationUtil {

/**
* Creates and returns all possible combinations of the given elements.
Expand Down Expand Up @@ -70,7 +71,7 @@ public static <T> Stream<List<T>> of(final T... items) {
@SafeVarargs
@SuppressWarnings("varargs") // Creating a List from an array is safe
public static <T> Stream<List<T>> ofDistinct(final T... items) {
return of(items).filter(Combination::isDistinctElements);
return of(items).filter(CombinationUtil::isDistinctElements);
}

private static <T> boolean isDistinctElements(List<T> list) {
Expand All @@ -89,7 +90,7 @@ private static <T> void generateCombinations(List<T> s, int i, int k, List<T> bu
}
}

private Combination() {
private CombinationUtil() {
throw new UnsupportedOperationException();
}
}
Expand Up @@ -14,21 +14,20 @@
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.speedment.runtime.core.internal.util.testing;
package com.speedment.common.combinatorics.internal;

import com.speedment.common.combinatorics.*;
import java.util.*;
import java.util.stream.LongStream;
import java.util.stream.Stream;

import static com.speedment.runtime.core.util.StaticClassUtil.instanceNotAllowed;

/**
* General Permutation support from
* http://minborgsjavapot.blogspot.com/2015/07/java-8-master-permutations.html
*
* @author Per Minborg
*/
public class Permutations {
public final class PermutationUtil {

public static long factorial(final int n) {
if (n > 20 || n < 0) {
Expand Down Expand Up @@ -60,8 +59,8 @@ public static <T> Stream<Stream<T>> of(final T... items) {
.mapToObj(no -> permutation(no, itemList).stream());
}

private Permutations() {
instanceNotAllowed(getClass());
private PermutationUtil() {
throw new UnsupportedOperationException();
}

}

0 comments on commit ab63606

Please sign in to comment.