diff --git a/vavr/src/main/java/io/vavr/collection/BitSet.java b/vavr/src/main/java/io/vavr/collection/BitSet.java index ddcc4ee6d..d46b7cd54 100644 --- a/vavr/src/main/java/io/vavr/collection/BitSet.java +++ b/vavr/src/main/java/io/vavr/collection/BitSet.java @@ -139,14 +139,30 @@ static Collector, BitSet> collector() { return Builder.DEFAULT.collector(); } + /** + * Returns a BitSet containing no elements. + * + * @return an empty BitSet + */ static BitSet empty() { return Builder.DEFAULT.empty(); } + /** + * Returns a BitSet containing a single value. + * + * @param value A single value + * @return A BitSet containing the given value + */ static BitSet of(Integer value) { return Builder.DEFAULT.of(value); } + /** + * Creates a BitSet of int numbers starting from {@code from}, extending to {@code toExclusive - 1}. + * @param values int values + * @return A new BitSet of int values + */ static BitSet of(Integer... values) { return Builder.DEFAULT.of(values); } @@ -176,10 +192,20 @@ static BitSet fill(int n, Supplier s) { return Builder.DEFAULT.fill(n, s); } + /** + * Creates a BitSet of int numbers starting from {@code from}, extending to {@code toExclusive - 1}. + * @param values int values + * @return A new BitSet of int values + */ static BitSet ofAll(Iterable values) { return Builder.DEFAULT.ofAll(values); } + /** + * Creates a BitSet of int numbers starting from {@code from}, extending to {@code toExclusive - 1}. + * @param javaStream A java.util.stream.Stream of int values + * @return A new BitSet of int values + */ static BitSet ofAll(java.util.stream.Stream javaStream) { return Builder.DEFAULT.ofAll(javaStream); } @@ -267,10 +293,24 @@ static BitSet range(int from, int toExclusive) { return BitSet.ofAll(Iterator.range(from, toExclusive)); } + /** + * Creates a BitSet of char numbers starting from {@code from}, extending to {@code toExclusive - 1}. + * + * @param from the first number + * @param toExclusive the last number + 1 + * @return a range of char values as specified or the empty range if {@code from >= toExclusive} + */ static BitSet range(char from, char toExclusive) { return BitSet.withCharacters().ofAll(Iterator.range(from, toExclusive)); } + /** + * Creates a BitSet of long numbers starting from {@code from}, extending to {@code toExclusive - 1}. + * + * @param from the first number + * @param toExclusive the last number + 1 + * @return a range of long values as specified or the empty range if {@code from >= toExclusive} + */ static BitSet range(long from, long toExclusive) { return BitSet.withLongs().ofAll(Iterator.range(from, toExclusive)); } @@ -291,10 +331,32 @@ static BitSet rangeBy(int from, int toExclusive, int step) { return BitSet.ofAll(Iterator.rangeBy(from, toExclusive, step)); } + /** Creates a BitSet of char numbers starting from {@code from}, extending to {@code toExclusive - 1}, + * with {@code step}. + * + * @param from the first number + * @param toExclusive the last number + 1 + * @param step the step + * @return a range of char values as specified or the empty range if
+ * {@code from >= toInclusive} and {@code step > 0} or
+ * {@code from <= toInclusive} and {@code step < 0} + * @throws IllegalArgumentException if {@code step} is zero + */ static BitSet rangeBy(char from, char toExclusive, int step) { return BitSet.withCharacters().ofAll(Iterator.rangeBy(from, toExclusive, step)); } + /** Creates a BitSet of long numbers starting from {@code from}, extending to {@code toExclusive - 1}, + * with {@code step}. + * + * @param from the first number + * @param toExclusive the last number + 1 + * @param step the step + * @return a range of long values as specified or the empty range if
+ * {@code from >= toInclusive} and {@code step > 0} or
+ * {@code from <= toInclusive} and {@code step < 0} + * @throws IllegalArgumentException if {@code step} is zero + */ static BitSet rangeBy(long from, long toExclusive, long step) { return BitSet.withLongs().ofAll(Iterator.rangeBy(from, toExclusive, step)); } @@ -310,10 +372,24 @@ static BitSet rangeClosed(int from, int toInclusive) { return BitSet.ofAll(Iterator.rangeClosed(from, toInclusive)); } + /** + * Creates a BitSet of char numbers starting from {@code from}, extending to {@code toInclusive}. + * + * @param from the first number + * @param toInclusive the last number + * @return a range of char values as specified or the empty range if {@code from > toInclusive} + */ static BitSet rangeClosed(char from, char toInclusive) { return BitSet.withCharacters().ofAll(Iterator.rangeClosed(from, toInclusive)); } + /** + * Creates a BitSet of long numbers starting from {@code from}, extending to {@code toInclusive}. + * + * @param from the first number + * @param toInclusive the last number + * @return a range of long values as specified or the empty range if {@code from > toInclusive} + */ static BitSet rangeClosed(long from, long toInclusive) { return BitSet.withLongs().ofAll(Iterator.rangeClosed(from, toInclusive)); } @@ -334,10 +410,34 @@ static BitSet rangeClosedBy(int from, int toInclusive, int step) { return BitSet.ofAll(Iterator.rangeClosedBy(from, toInclusive, step)); } + /** + * Creates a BitSet of char numbers starting from {@code from}, extending to {@code toInclusive}, + * with {@code step}. + * + * @param from the first number + * @param toInclusive the last number + * @param step the step + * @return a range of char values as specified or the empty range if
+ * {@code from > toInclusive} and {@code step > 0} or
+ * {@code from < toInclusive} and {@code step < 0} + * @throws IllegalArgumentException if {@code step} is zero + */ static BitSet rangeClosedBy(char from, char toInclusive, int step) { return BitSet.withCharacters().ofAll(Iterator.rangeClosedBy(from, toInclusive, step)); } + /** + * Creates a BitSet of long numbers starting from {@code from}, extending to {@code toInclusive}, + * with {@code step}. + * + * @param from the first number + * @param toInclusive the last number + * @param step the step + * @return a range of long values as specified or the empty range if
+ * {@code from > toInclusive} and {@code step > 0} or
+ * {@code from < toInclusive} and {@code step < 0} + * @throws IllegalArgumentException if {@code step} is zero + */ static BitSet rangeClosedBy(long from, long toInclusive, long step) { return BitSet.withLongs().ofAll(Iterator.rangeClosedBy(from, toInclusive, step)); }