Skip to content

Commit d3be990

Browse files
Merge pull request #2 from ZoftWhere/feature/release-2.1.0
Release 2.1.0
2 parents d248b80 + b0bec16 commit d3be990

30 files changed

Lines changed: 953 additions & 209 deletions

.idea/codeStyles/Project.xml

Lines changed: 3 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/combinatoric.iml

Lines changed: 8 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

license.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2019 ZoftWhere
3+
Copyright (c) 2019-2020 ZoftWhere
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

main-github/release-notes/2.1.0.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
## Release Notes - Version 2.1.0
2+
3+
* Updated Maven build for manual JDK 8.
4+
* Updated Maven Surefire plugin to work with Java module.
5+
* Updated source code Javadoc.
6+
* Updated class access modifiers.
7+
* Updated copyright and license year(s).

main-java/app/zoftwhere/combinatoric/AbstractPermutation.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,20 +13,22 @@ abstract class AbstractPermutation<T> implements Permutation<T> {
1313

1414
private final int kSize;
1515

16-
private final List<T> list;
17-
1816
/**
19-
* User PermutationBuilder to initialize a new permutation.
17+
* Package-private constructor to initialize a new permutation.
2018
*/
21-
AbstractPermutation(int[] index, List<T> list, int kSize) {
19+
AbstractPermutation(int[] index, int kSize) {
2220
this.index = index;
2321
this.size = index.length;
24-
this.list = list;
2522
this.kSize = kSize;
2623
}
2724

2825
/**
2926
* Returns an immutable instance with the values in the clone.
27+
*
28+
* @param index index array
29+
* @param list list of elements
30+
* @param kSize count of permutation elements
31+
* @return immutable permutation instance.
3032
*/
3133
protected abstract Permutation<T> newInstance(int[] index, List<T> list, int kSize);
3234

main-java/app/zoftwhere/combinatoric/Generator.java

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,8 @@ public static Permutation<Void> newPermutation(int size) {
5252
/**
5353
* Creates an immutable void permutation.
5454
*
55-
* @param size the number of elements to hold.
55+
* @param size the number of elements to hold
56+
* @param kSize the number of elements for display
5657
* @return immutable void permutation
5758
*/
5859
public static Permutation<Void> newPermutation(int size, int kSize) {
@@ -71,7 +72,9 @@ public static Permutation<Void> newPermutation(int size, int kSize) {
7172
/**
7273
* Creates an immutable linked permutation.
7374
*
74-
* @param list the value elements
75+
* @param <T> the type
76+
* @param list the value elements
77+
* @param comparator the comparator
7578
* @return immutable basic permutation if no duplicates are detected, an N-Tuple otherwise
7679
* @throws NullPointerException if any of the list items are null
7780
*/
@@ -82,8 +85,10 @@ public static <T> Permutation<T> newPermutation(List<T> list, Comparator<T> comp
8285
/**
8386
* Creates an immutable k-permutation.
8487
*
85-
* @param list the value elements
86-
* @param kSize kSize value
88+
* @param <T> the type
89+
* @param list the value elements
90+
* @param comparator the comparator
91+
* @param kSize kSize value
8792
* @return immutable basic permutation if no duplicates are detected, an N-Tuple otherwise
8893
* @throws NullPointerException if any of the list items are null
8994
*/
@@ -125,6 +130,7 @@ public static <T> Permutation<T> newPermutation(List<T> list, Comparator<T> comp
125130
/**
126131
* Creates an immutable linked permutation.
127132
*
133+
* @param <T> the type
128134
* @param list the value elements
129135
* @return immutable basic permutation if no duplicates are detected, an N-Tuple otherwise
130136
* @throws NullPointerException if any of the list items are null
@@ -136,6 +142,7 @@ public static <T> Permutation<T> newPermutation(List<T> list) {
136142
/**
137143
* Creates an immutable linked permutation.
138144
*
145+
* @param <T> the type
139146
* @param list the value elements
140147
* @param kSize kSize value
141148
* @return immutable basic permutation if no duplicates are detected, an N-Tuple otherwise
@@ -180,6 +187,7 @@ public static <T> Permutation<T> newPermutation(List<T> list, int kSize) {
180187
/**
181188
* Creates an immutable linked permutation.
182189
*
190+
* @param <T> the type
183191
* @param list the value elements
184192
* @param withRepetitions flag to specify if duplicates should be ignored
185193
* @return immutable linked permutation
@@ -192,6 +200,7 @@ public static <T> Permutation<T> newPermutation(List<T> list, boolean withRepeti
192200
/**
193201
* Creates an immutable linked permutation.
194202
*
203+
* @param <T> the type
195204
* @param list the value elements
196205
* @param withRepetitions flag to specify if duplicates should be ignored
197206
* @param kSize kSize value
@@ -234,6 +243,7 @@ private static <T> int getGroupInsertIndex(final List<T> list, T item) {
234243
/**
235244
* Creates an empty permutation.
236245
*
246+
* @param <T> the type
237247
* @return an empty permutation
238248
*/
239249
static <T> Permutation<T> empty() {

main-java/app/zoftwhere/combinatoric/Permutation.java

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,39 @@
22

33
import java.util.List;
44

5+
/**
6+
* Permutation.
7+
*
8+
* @param <T> the type
9+
*/
510
public interface Permutation<T> {
611

12+
/**
13+
* Check if the permutation has any elements.
14+
*
15+
* @return true if the permutation has elements, false otherwise
16+
*/
717
boolean isPresent();
818

19+
/**
20+
* Check if the permutation is empty.
21+
*
22+
* @return true if the permutation is empty, false otherwise
23+
*/
924
boolean isEmpty();
1025

26+
/**
27+
* The element count in the selection set.
28+
*
29+
* @return element count in the selection set
30+
*/
1131
int size();
1232

33+
/**
34+
* The element count in the permutation.
35+
*
36+
* @return element count in the permutation
37+
*/
1338
int kSize();
1439

1540
/**
@@ -37,6 +62,7 @@ public interface Permutation<T> {
3762
/**
3863
* Progress to the next available permutation from the position provided.
3964
*
65+
* @param position the element to change
4066
* @return the next permutation if possible, an empty permutation otherwise
4167
*/
4268
Permutation<T> next(int position);

main-java/app/zoftwhere/combinatoric/PermutationBasic.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ class PermutationBasic<T> extends AbstractPermutation<T> {
1515

1616
private final int kSize;
1717

18-
public PermutationBasic(int[] index, List<T> list, int kSize) {
19-
super(index, list, kSize);
18+
PermutationBasic(int[] index, List<T> list, int kSize) {
19+
super(index, kSize);
2020
this.index = index;
2121
this.size = index.length;
2222
this.list = list;

main-java/app/zoftwhere/combinatoric/PermutationEmpty.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
class PermutationEmpty<T> extends AbstractPermutation<T> {
77

88
PermutationEmpty() {
9-
super(new int[0], null, 0);
9+
super(new int[0], 0);
1010
}
1111

1212
@Override
@@ -75,7 +75,7 @@ public Permutation<T> next(int position) {
7575
*/
7676
@Override
7777
public Permutation<T> progress(int position) {
78-
return newInstance(null, null, 0);
78+
return this;
7979
}
8080

8181
@Override

main-java/app/zoftwhere/combinatoric/PermutationNTuple.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class PermutationNTuple<T> extends PermutationBasic<T> {
1414

1515
private final int kSize;
1616

17-
public PermutationNTuple(int[] index, List<T> list, int kSize) {
17+
PermutationNTuple(int[] index, List<T> list, int kSize) {
1818
super(index, list, kSize);
1919
this.index = index;
2020
this.size = index.length;

0 commit comments

Comments
 (0)