public String toString()
    {
        checkInvariants();
        
        int numBits = (wordsInUse > 128) ? cardinality() : wordsInUse
                * BITS_PER_WORD;
        StringBuilder b = new StringBuilder(6 * numBits + 2);
        b.append('{');
        
        int i = nextSetBit(0);
        if (i != -1)
        {
            b.append(i);
            for (i = nextSetBit(i + 1); i >= 0; i = nextSetBit(i + 1))
            {
                int endOfRun = nextClearBit(i);
                do
                {
                    b.append(", ").append(i);
                }
                while (++i < endOfRun);
            }
        }
        
        b.append('}');
        return b.toString();
    }