public function setRange(int $start, int $end) : void
    {
        if ($end < $start) {
            throw new InvalidArgumentException('End must be greater or equal to start');
        }

        if ($end === $start) {
            return;
        }

        --$end;

        $firstInt = $start >> 5;
        $lastInt = $end >> 5;

        for ($i = $firstInt; $i <= $lastInt; ++$i) {
            $firstBit = $i > $firstInt ? 0 : $start & 0x1f;
            $lastBit = $i < $lastInt ? 31 : $end & 0x1f;

            if (0 === $firstBit && 31 === $lastBit) {
                $mask = 0x7fffffff;
            } else {
                $mask = 0;

                for ($j = $firstBit; $j < $lastBit; ++$j) {
                    $mask |= 1 << $j;
                }
            }

            $this->bits[$i] = $this->bits[$i] | $mask;
        }
    }
public function setRange(int $start, int $end) : void
    {
        if ($end < $start) {
            throw new InvalidArgumentException('End must be greater or equal to start');
        }

        if ($end === $start) {
            return;
        }

        --$end;

        $firstInt = $start >> 5;
        $lastInt = $end >> 5;

        for ($i = $firstInt; $i <= $lastInt; ++$i) {
            $firstBit = $i > $firstInt ? 0 : $start & 0x1f;
            $lastBit = $i < $lastInt ? 31 : $end & 0x1f;

            if (0 === $firstBit && 31 === $lastBit) {
                $mask = 0x7fffffff;
            } else {
                $mask = 0;

                for ($j = $firstBit; $j < $lastBit; ++$j) {
                    $mask |= 1 << $j;
                }
            }

            $this->bits[$i] = $this->bits[$i] | $mask;
        }
    }
public function setRange ( int $ start , int $ end ) : void { if ( $ end < $ start ) { throw new InvalidArgumentException ( 'End must be greater or equal to start' ) ; } if ( $ end === $ start ) { return ; } -- $ end ; $ firstInt = $ start >> 5 ; $ lastInt = $ end >> 5 ; for ( $ i = $ firstInt ; $ i <= $ lastInt ; ++ $ i ) { $ firstBit = $ i > $ firstInt ? 0 : $ start & 0x1f ; $ lastBit = $ i < $ lastInt ? 31 : $ end & 0x1f ; if ( 0 === $ firstBit && 31 === $ lastBit ) { $ mask = 0x7fffffff ; } else { $ mask = 0 ; for ( $ j = $ firstBit ; $ j < $ lastBit ; ++ $ j ) { $ mask |= 1 << $ j ; } } $ this -> bits [ $ i ] = $ this -> bits [ $ i ] | $ mask ; } }
Sets a range of bits.

@throws InvalidArgumentException if end is smaller than start
Sets a range of bits .