public static int getExtractedIntValue ( @ Nonnull final BitSet aBS ) { ValueEnforcer . notNull ( aBS , "BitSet" ) ; final int nMax = aBS . length ( ) ; ValueEnforcer . isTrue ( nMax <= CGlobal . BITS_PER_INT , ( ) -> "Can extract only up to " + CGlobal . BITS_PER_INT + " bits" ) ; int ret = 0 ; for ( int i = nMax - 1 ; i >= 0 ; -- i ) { ret <<= 1 ; if ( aBS . get ( i ) ) ret += CGlobal . BIT_SET ; } return ret ; }
Extract the int representation of the passed bit set . To avoid loss of data the bit set may not have more than 32 bits .