@Test public void testCompressedSize() { Assert.assertEquals(1, ps.compressedSize(fromString("1111"))); Assert.assertEquals(1, ps.compressedSize(fromString("1111 1111"))); Assert.assertEquals(1, ps.compressedSize(fromString("1111 1111 1111 1111"))); Assert.assertEquals( 3, ps.compressedSize( fromString( "0000 0000 0000 0000 0000 0000 0000 0000 1111 1111 1111 1111 1111 1111 1111 0000"))); Assert.assertEquals( 1, ps.compressedSize( fromString( "0000 0000 0000 0000 0000 0000 0000 0000 1111 1111 1111 1111 1111 1111 1111 1111 0000"))); Assert.assertEquals( 2, ps.compressedSize( fromString( "0000 0000 0000 0000 1111 1111 1111 1111 1111 1111 1111 1111 1111 1111 1111 1111 0000"))); Assert.assertEquals( 3, ps.compressedSize(fromString("1111 1111 1111 1111 1111 1111 1111 0000"))); Assert.assertEquals(1, ps.compressedSize(fromString("1111 1111 0000"))); Assert.assertEquals(3, ps.compressedSize(fromString("0001 1111 1111 0000"))); Assert.assertEquals( 3, ps.compressedSize(fromString("0001 1111 1111 1111"))); Assert.assertEquals(2, ps.compressedSize(fromString("0000 1111 1111 1111 0000"))); Assert.assertEquals(4, ps.compressedSize(fromString("1101 0111"))); Assert.assertEquals(3, ps.compressedSize(fromString("1111 1110"))); Assert.assertEquals(4, ps.compressedSize(fromString("0111 0111"))); Assert.assertEquals(0, ps.compressedSize(fromString("0000 0000"))); Assert.assertEquals(2, ps.compressedSize(fromString("1111 1111 1111"))); }
int compressedSize(BitSet sigs) { if (sigs.length() == params.signingNodeCount) { return 1; } int firstOneAt = -1; int sigCt = 0; int pos = -1; boolean compressing = false; boolean wasCompressing = false; while (++pos <= sigs.length() + 1) { if (!sigs.get(pos)) { compressing = false; sigCt -= mergeRanges(firstOneAt, pos); firstOneAt = -1; } else if (compressing) { if ((pos + 1) % 2 == 0) { compressing = false; wasCompressing = true; } } else { sigCt++; if (pos % 2 == 0) { compressing = true; if (!wasCompressing) { firstOneAt = pos; } else { wasCompressing = false; } } } } return sigCt; }
P2PHandel implements Protocol { int compressedSize(BitSet sigs) { if (sigs.length() == params.signingNodeCount) { return 1; } int firstOneAt = -1; int sigCt = 0; int pos = -1; boolean compressing = false; boolean wasCompressing = false; while (++pos <= sigs.length() + 1) { if (!sigs.get(pos)) { compressing = false; sigCt -= mergeRanges(firstOneAt, pos); firstOneAt = -1; } else if (compressing) { if ((pos + 1) % 2 == 0) { compressing = false; wasCompressing = true; } } else { sigCt++; if (pos % 2 == 0) { compressing = true; if (!wasCompressing) { firstOneAt = pos; } else { wasCompressing = false; } } } } return sigCt; } }
P2PHandel implements Protocol { int compressedSize(BitSet sigs) { if (sigs.length() == params.signingNodeCount) { return 1; } int firstOneAt = -1; int sigCt = 0; int pos = -1; boolean compressing = false; boolean wasCompressing = false; while (++pos <= sigs.length() + 1) { if (!sigs.get(pos)) { compressing = false; sigCt -= mergeRanges(firstOneAt, pos); firstOneAt = -1; } else if (compressing) { if ((pos + 1) % 2 == 0) { compressing = false; wasCompressing = true; } } else { sigCt++; if (pos % 2 == 0) { compressing = true; if (!wasCompressing) { firstOneAt = pos; } else { wasCompressing = false; } } } } return sigCt; } P2PHandel(P2PHandelParameters params); }
P2PHandel implements Protocol { int compressedSize(BitSet sigs) { if (sigs.length() == params.signingNodeCount) { return 1; } int firstOneAt = -1; int sigCt = 0; int pos = -1; boolean compressing = false; boolean wasCompressing = false; while (++pos <= sigs.length() + 1) { if (!sigs.get(pos)) { compressing = false; sigCt -= mergeRanges(firstOneAt, pos); firstOneAt = -1; } else if (compressing) { if ((pos + 1) % 2 == 0) { compressing = false; wasCompressing = true; } } else { sigCt++; if (pos % 2 == 0) { compressing = true; if (!wasCompressing) { firstOneAt = pos; } else { wasCompressing = false; } } } } return sigCt; } P2PHandel(P2PHandelParameters params); @Override void init(); @Override Network<P2PHandelNode> network(); @Override P2PHandel copy(); }
P2PHandel implements Protocol { int compressedSize(BitSet sigs) { if (sigs.length() == params.signingNodeCount) { return 1; } int firstOneAt = -1; int sigCt = 0; int pos = -1; boolean compressing = false; boolean wasCompressing = false; while (++pos <= sigs.length() + 1) { if (!sigs.get(pos)) { compressing = false; sigCt -= mergeRanges(firstOneAt, pos); firstOneAt = -1; } else if (compressing) { if ((pos + 1) % 2 == 0) { compressing = false; wasCompressing = true; } } else { sigCt++; if (pos % 2 == 0) { compressing = true; if (!wasCompressing) { firstOneAt = pos; } else { wasCompressing = false; } } } } return sigCt; } P2PHandel(P2PHandelParameters params); @Override void init(); @Override Network<P2PHandelNode> network(); @Override P2PHandel copy();  }