File tree Expand file tree Collapse file tree 2 files changed +0
-40
lines changed
main/java/io/github/abductcows/bitarray
test/kotlin/io/github/abductcows/bitarray Expand file tree Collapse file tree 2 files changed +0
-40
lines changed Original file line number Diff line number Diff line change @@ -532,30 +532,6 @@ private int longsRequiredForNBits(int nBits) {
532
532
BitArray specific methods
533
533
*/
534
534
535
- /**
536
- * Calculates the parity of {@link Boolean#TRUE ones} in the array
537
- *
538
- * @return 0 or 1 if there is an even or odd number of {@link Boolean#TRUE ones} respectively
539
- */
540
- public int sumMod2 () {
541
- if (isEmpty ()) return 0 ;
542
- int sumMod2 = 0 ;
543
- int limit = longsRequiredForNBits (size ()) - 1 ;
544
-
545
- sumMod2 += Long .bitCount (Arrays .stream (data )
546
- .limit (limit )
547
- .reduce (0L , (i , j ) -> i ^ j ));
548
-
549
- int remainingBitsIndex = limit * BITS_PER_LONG ;
550
- for (int i = remainingBitsIndex ; i < elements ; i ++) {
551
- if (get (i )) {
552
- sumMod2 ++;
553
- }
554
- }
555
-
556
- return sumMod2 % 2 ;
557
- }
558
-
559
535
/**
560
536
* Counts the number of {@code true} elements in the array
561
537
*
Original file line number Diff line number Diff line change @@ -191,22 +191,6 @@ internal class BitArrayTest {
191
191
@DisplayName(" New Method Tests" )
192
192
@TestInstance(TestInstance .Lifecycle .PER_CLASS )
193
193
internal inner class NewMethodTests {
194
- @ParameterizedTest(name = " {0} elements" )
195
- @MethodSource(" io.github.abductcows.bitarray.TestUtils#testCaseBooleans" )
196
- @DisplayName(" sumMod2 is equivalent to parity of 1s in the array" )
197
- fun `sumMod2 should be equivalent to the parity of 1s in the array` (elementsToAdd : List <Boolean >) {
198
- // given
199
- bitArray.addAll(elementsToAdd)
200
-
201
- // when
202
- val sumMod2 = bitArray.sumMod2()
203
- val expectedSumMod2 = bitArray.count { it == true } % 2
204
-
205
- // then
206
- printDetails(elementsToAdd.size, expectedSumMod2, sumMod2)
207
- assertThat(sumMod2).isEqualTo(expectedSumMod2)
208
- }
209
-
210
194
@ParameterizedTest(name = " {0} elements" )
211
195
@MethodSource(" io.github.abductcows.bitarray.TestUtils#testCaseBooleans" )
212
196
@DisplayName(" countOnes is equivalent to the number of true elements in the array" )
You can’t perform that action at this time.
0 commit comments