public BitSet toBitSet() {
        BitSet resultSet = new BitSet();
        int ordinal = this.nextSetBit(0);
        while(ordinal!=-1) {
            resultSet.set(ordinal);
            ordinal = this.nextSetBit(ordinal + 1);
        }
        return resultSet;
    }
@Test
    public void testToBitSet() {
        BitSet bSet = new BitSet();
        ThreadSafeBitSet tsbSet = new ThreadSafeBitSet();
        int[] ordinals = new int[] { 1, 5, 10 };

        // init
        for (int ordinal : ordinals) {
            bSet.set(ordinal);
            tsbSet.set(ordinal);
        }

        // validate content
        for (int ordinal : ordinals) {
            Assert.assertEquals(bSet.get(ordinal), tsbSet.get(ordinal));
        }
        Assert.assertEquals(bSet.cardinality(), tsbSet.cardinality());

        // compare toBitSet
        BitSet bSet2 = tsbSet.toBitSet();
        Assert.assertEquals(bSet, bSet2);

        // compare toString
        Assert.assertEquals(bSet.toString(), bSet.toString());
    }