Fetch the binary representation of a mask

@param int $mask A mask from a CIDR
@return string
767877
private function getBinaryMask($mask) {
        // Prefix the string
        $hexMask = str_repeat('f', $mask / 4);

        // Add the remainder
        switch ($mask % 4) {
            case 1:
                $hexMask .= '8';
                break;
            case 2:
                $hexMask .= 'c';
                break;
            case 3:
                $hexMask .= 'e';
                break;
        }

        // Pad with 0 to 32 in length
        $hexMask = str_pad($hexMask, 32, '0');

        // Pack into binary string
        return hex2bin($hexMask);
    }
1046951
def _match_mask(mask, ctype):
    

    # Handle the simple cases first
    if '*' not in mask:
        return ctype == mask
    elif mask == '*/*':
        return True
    elif not mask.endswith('/*'):
        return False

    mask_major = mask[:-2]
    ctype_major = ctype.split('/', 1)[0]
    return ctype_major == mask_major
193799
def get_mask(self, m):
        """"""
        mask = torch.ones((m, m, m, self.k_lf, self.k_lf, self.k_lf)).byte()
        for i, j, k in product(range(m), repeat=3):
            if len(set((i, j, k))) < 3:
                mask[i, j, k, :, :, :] = 0
        return mask
414992
public static function getSetBits(int $mask): array
    {
        $bits = [];
        $scan = 1;
        while ($mask >= $scan) {
            if ($mask & $scan) {
                $bits[] = $scan;
            }
            $scan <<= 1;
        }
        return $bits;
    }
714336
protected function getEventQueueDeferred($mask)
    {
        if (!isset($this->queues[$mask])) {
            $this->queues[$mask] = new Deferred;
        }
        return $this->queues[$mask];
    }
651300
def get_interleave_mask():
    

    nodemask = nodemask_t()
    bitmask = libnuma.numa_get_interleave_mask()
    libnuma.copy_bitmask_to_nodemask(bitmask, byref(nodemask))
    libnuma.numa_bitmask_free(bitmask)

    return numa_nodemask_to_set(nodemask)
996018
private void calculate(String mask) {
        Matcher matcher = cidrPattern.matcher(mask);

        if (matcher.matches()) {
            matchAddress(matcher);

            /* Create a binary netmask from the number of bits specification /x */
            rangeCheck(Integer.parseInt(matcher.group(5)), 0, NBITS);
        } else {
            throw new IllegalArgumentException("Could not parse [" + mask + "]");
        }
    }
309320
def normalize_mask(mask)
      mask = mask.dup
      mask.gsub!(/\*{2,}/, '*')
      parts = []
      remainder = nil

      if mask !~ /!/ && mask =~ /@/
        remainder = mask
        parts[0] = '*'
      else
        parts[0], remainder = mask.split(/!/, 2)
      end

      if remainder
        remainder.gsub!(/!/, '')
        parts[1..2] = remainder.split(/@/, 2)
      end
      parts[2].gsub!(/@/, '') if parts[2]

      (1..2).each { |i| parts[i] ||= '*' }
      return parts[0] + "!" + parts[1] + "@" + parts[2]
    end
857357
protected function fromInotifyMask($mask)
    {
        $mask &= ~IN_ISDIR;
        $event = 0;
        switch ($mask) {
            case (IN_MODIFY):
            case (IN_ATTRIB):
                $event =  FilesystemEvent::MODIFY;
                break;
            case (IN_CREATE):
                $event =  FilesystemEvent::CREATE;
                break;
            case (IN_DELETE):
            case (IN_IGNORED):
                $event =  FilesystemEvent::DELETE;
        }

        return $this->supportsEvent($event) ? $event : false;
    }
279910
public function trim(string $mask = null): self
    {
        return new self(
            $mask === null ? \trim((string) $this) : \trim((string) $this, $mask),
            $this->encoding
        );
    }
1209397
public static function getMSB(int $mask): int
    {
        $scan = 1;
        $msb = 0;
        while ($mask >= $scan) {
            $msb++;
            $scan <<= 1;
            if ($mask < $scan) {
                break;
            }
        }
        return $msb;
    }
834967
protected function getMask(/*# int */ $length = 32)/*# : int */
    {
        $bin = substr(str_repeat('1', $length) . str_repeat('0', 32), 0, 32);
        return ip2long(long2ip(bindec($bin)));
    }
605978
private static function getBitmask(): int
    {
        $enumType = static::class;

        if (!isset(self::$masks[$enumType])) {
            $mask = 0;
            foreach (static::values() as $flag) {
                if ($flag < 1 || ($flag > 1 && ($flag % 2) !== 0)) {
                    throw new LogicException(sprintf(
                        'Possible value %s of the enumeration "%s" is not a bit flag.',
                        json_encode($flag),
                        static::class
                    ));
                }
                $mask |= $flag;
            }
            self::$masks[$enumType] = $mask;
        }

        return self::$masks[$enumType];
    }
1049268
public function decodeMask($mask, ResourceType $type)
    {
        $decoders = $this->maskRepo->findBy(array('resourceType' => $type));
        $perms = array();

        foreach ($decoders as $decoder) {
            $perms[$decoder->getName()] = ($mask & $decoder->getValue()) ? true: false;
        }

        return $perms;
    }
484896
public function withMask(IPAddressInterface $mask): IPAddressInterface
    {
        $octets = $this->getParts();
        $maskOctets = $mask->getParts();

        for ($i = 0; $i < 4; $i++) {
            $octets[$i] = $octets[$i] & $maskOctets[$i];
        }

        return new self($octets);
    }
740663
public function get_mask_xor($base_id)
    {
        $this->load_rights_bas();
        if (!$this->has_access_to_base($base_id)) {
            return false;
        }

        return $this->_rights_bas[$base_id]['mask_xor'];
    }
209355
public function modifyMask($mask): self
    {
        if (is_array($mask)) {
            $this->attributes['mask'] = json_encode($mask);
        }

        return $this;
    }