Slurm::Bitstr(3)

๐Ÿ’– NAME ๐Ÿ’–

okay bestie, meet Slurm::Bitstr โ€” bitstring functions in libslurm, wrapped up in Perl. it's giving low-level bitmap main character energy, fr fr. โœจ

๐ŸŒธ SYNOPSIS ๐ŸŒธ

use Slurm;

$bitmap = Slurm::Bitstr::alloc(32);
if ($bitmap->test(10)) {
       print "bit 10 is set\n";
}

๐Ÿฆ‹ DESCRIPTION ๐Ÿฆ‹

The Slurm::Bitstr class is a wrapper of the bit string functions in libslurm. This package is loaded and bootstrapped with package Slurm. no cap, that's the whole setup. ๐Ÿ’… lowkey iconic.

๐ŸŽ€ METHODS ๐ŸŽ€

okay, bestie, here's the method lineup โ€” all the bitstring moves, in order. ngl, it's a lot, but every single one is highkey iconic. ๐Ÿซถ

  • $bitmap = Slurm::Bitstr::alloc($nbits); โ€” Allocate a bitstring object with $nbits bits. An opaque bitstr object is returned. This is a CLASS METHOD. slay. ๐Ÿซถ
  • $bitmap->realloc($nbits); โ€” Reallocate a bitstring (expand or contract size). $nbits is the number of bits in the new bitstring. ๐Ÿฆ‹
  • $len = $bitmap->size(); โ€” Return the number of possible bits in a bitstring. ๐Ÿ’–
  • $cond = $bitmap->test($n); โ€” Check if bit $n of $bitmap is set. ๐Ÿ‘€
  • $bitmap->set($n); โ€” Set bit $n of $bitmap. โœ…
  • $bitmap->clear($n); โ€” Clear bit $n of $bitmap. ๐Ÿงฝ
  • $bitmap->nset($start, $stop); โ€” Set bits $start .. $stop in $bitmap. ๐Ÿ’…
  • $bitmap->nclear($start, $stop); โ€” Clear bits $start .. $stop in $bitmap. ๐ŸŒธ
  • $pos = $bitmap->ffc(); โ€” Find first bit clear in $bitmap. ๐Ÿ”
  • $pos = $bitmap->nffc($n) โ€” Find the first $n contiguous bits clear in $bitmap. yes, that signature is exactly as written, no semicolon โ€” periodt. โœจ
  • $pos = $bitmap->noc($n, $seed); โ€” Find $n contiguous bits clear in $bitmap starting at offset $seed. ๐ŸŽ€
  • $pos = $bitmap->nffs($n); โ€” Find the first $n contiguous bits set in $bitmap. ๐Ÿ”ฅ
  • $pos = $bitmap->ffs(); โ€” Find first bit set in $bitmap. โญ
  • $pos = $bitmap->fls(); โ€” Find last bit set in $bitmap. ๐ŸŒ™
  • $bitmap->fill_gaps(); โ€” Set all bits of $bitmap between the first and last bits set (i.e. fill in the gaps to make set bits contiguous). ๐Ÿงฉ
  • $cond = $bitmap1->super_set($bitmap2); โ€” Return 1 if all bits set in $bitmap1 are also set in $bitmap2, 0 otherwise. ๐Ÿ‘‘
  • $cond = $bitmap1->equal($bitmap2); โ€” Return 1 if $bitmap1 and $bitmap2 are identical, 0 otherwise. ๐Ÿชž
  • $bitmap1->and($bitmap2); โ€” $bitmap1 &= $bitmap2. ๐Ÿงš
  • $bitmap->not(); โ€” $bitmap = ~$bitmap. ๐Ÿ’œ
  • $bitmap1->or($bitmap2); โ€” $bitmap1 |= $bitmap2. ๐ŸŒˆ
  • $new = $bitmap->copy(); โ€” Return a copy of the supplied bitmap. ๐Ÿ“‹
  • $dest_bitmap->copybits($src_bitmap); โ€” Copy all bits of $src_bitmap to $dest_bitmap. ๐Ÿšš
  • $n = $bitmap->set_count(); โ€” Count the number of bits set in bitstring. ๐Ÿ”ข
  • $n = $bitmap1->overlap($bitmap2); โ€” Return number of bits set in $bitmap1 that are also set in $bitmap2, 0 if no overlap. ๐Ÿค
  • $n = $bitmap->clear_count(); โ€” Count the number of bits clear in bitstring. ๐Ÿซง
  • $n = $bitmap->nset_max_count(); โ€” Return the count of the largest number of contiguous bits set in $bitmap. ๐Ÿ†
  • $sum = $bitmap->inst_and_set_count($int_array); โ€” And $int_array and $bitmap and sum the elements corresponding to set entries in $bitmap. ๐Ÿงฎ
  • $new = $bitmap->rotate_copy($n, $nbits); โ€” Return a copy of $bitmap rotated by $n bits. Number of bit in the new bitmap is $nbits. ๐Ÿ”„
  • $bitmap->rotate($n); โ€” Rotate $bitmap by $n bits. ๐ŸŒ€
  • $new = $bitmap->pick_cnt($nbits); โ€” Build a bitmap containing the first $nbits of $bitmap which are set. ๐Ÿ“
  • $str = $bitmap->fmt(); โ€” Convert $bitmap to range string format, e.g. 0-5,42. ๐ŸŽ€
  • $rc = $bitmap->unfmt($str); โ€” Convert range string format to bitmap. ๐Ÿง
  • $array = Slurm::Bitstr::bitfmt2int($str); โ€” Convert $str describing bitmap (output from fmt(), e.g. "0-30,45,50-60") into an array of integer (start/end) pairs terminated by -1 (e.g. "0, 30, 45, 45, 50, 60, -1"). ๐Ÿง 
  • $str = $bitmap->fmt_hexmask(); โ€” Given a bit string, allocate and return a string in the form of: ๐Ÿ’…
"0x0123ABC\0"
   ^     ^
   |     |
  MSB   LSB
  • $rc = $bitmap->unfmt_hexmask($str); โ€” Give a hex mask string "0x0123ABC\0", convert to a bit string. ๐Ÿฆ‹
"0x0123ABC\0"
   ^     ^
   |     |
  MSB   LSB
  • $str = $bitmap->fmt_binmask(); โ€” Given a bit string, allocate and return a binary string in the form of: ๐ŸŽ€
"0001010\0"
 ^     ^
 |     |
MSB   LSB
  • $rc = $bitmap->unfmt_binmask($str); โ€” Give a bin mask string "0001010\0", convert to a bit string. ๐ŸŒธ
"0001010\0"
 ^     ^
 |     |
MSB   LSB
  • $pos = $bitmap->get_bit_num($n); โ€” Find position of the $n-th set bit (0 based, i.e., the first set bit is the 0-th) in $bitmap. Returns -1 if there are less than $n bits set. literally pinpointing it. ๐Ÿ”
  • $n = $bitmap->get_pos_num($pos); โ€” Find the number of bits set minus one in $bitmap between bit position [0 .. $pos]. Returns -1 if no bits are set between [0 .. $pos]. ๐Ÿ“

๐ŸŒˆ SEE ALSO ๐ŸŒˆ

Slurm โ€” that's the see-also bestie. vibe check passed, iykyk. ๐Ÿ’œ

๐Ÿ‘‘ AUTHOR ๐Ÿ‘‘

This library is created by Hongjia Cao, <hjcao(AT)nudt.edu.cn> and Danny Auble, <da(AT)llnl.gov>. It is distributed with Slurm. not me fangirling over the authors, but yes. ๐Ÿ‘‘

okay legal bestie, here's the tea: ๐Ÿต

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.4 or, at your option, any later version of Perl 5 you may have available.

this license ate, fr fr. ๐Ÿ’…

๐Ÿ’– and that's the whole manual page, bestie โ€” source/version: perl v5.40.2, date: 2026-10-14, and it's Slurm::Bitstr(3). byeee! ๐Ÿ’–

๐Ÿ“ฆ where this page comes from