.\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.43) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "Slurm::Bitstr 3pm" .TH Slurm::Bitstr 3pm "2023-12-25" "perl v5.36.0" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" Slurm::Bitstr \- Bitstring functions in libslurm .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& use Slurm; \& \& $bitmap = Slurm::Bitstr::alloc(32); \& if ($bitmap\->test(10)) { \& print "bit 10 is set\en"; \& } .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" The Slurm::Bitstr class is a wrapper of the bit string functions in libslurm. This package is loaded and bootstrapped with package Slurm. .SH "METHODS" .IX Header "METHODS" \fI\f(CI$bitmap\fI = Slurm::Bitstr::alloc($nbits);\fR .IX Subsection "$bitmap = Slurm::Bitstr::alloc($nbits);" .PP Allocate a bitstring object with \f(CW$nbits\fR bits. An opaque bitstr object is returned. This is a \fB\s-1CLASS METHOD\s0\fR. .PP \fI\f(CI$bitmap\fI\->realloc($nbits);\fR .IX Subsection "$bitmap->realloc($nbits);" .PP Reallocate a bitstring(expand or contract size). \f(CW$nbits\fR is the number of bits in the new bitstring. .PP \fI\f(CI$len\fI = \f(CI$bitmap\fI\->\f(BIsize()\fI;\fR .IX Subsection "$len = $bitmap->size();" .PP Return the number of possible bits in a bitstring. .PP \fI\f(CI$cond\fI = \f(CI$bitmap\fI\->test($n);\fR .IX Subsection "$cond = $bitmap->test($n);" .PP Check if bit \f(CW$n\fR of \f(CW$bitmap\fR is set. .PP \fI\f(CI$bitmap\fI\->set($n);\fR .IX Subsection "$bitmap->set($n);" .PP Set bit \f(CW$n\fR of \f(CW$bitmap\fR. .PP \fI\f(CI$bitmap\fI\->clear($n);\fR .IX Subsection "$bitmap->clear($n);" .PP Clear bit \f(CW$n\fR of \f(CW$bitmap\fR. .PP \fI\f(CI$bitmap\fI\->nset($start, \f(CI$stop\fI);\fR .IX Subsection "$bitmap->nset($start, $stop);" .PP Set bits \f(CW$start\fR .. \f(CW$stop\fR in \f(CW$bitmap\fR. .PP \fI\f(CI$bitmap\fI\->nclear($start, \f(CI$stop\fI);\fR .IX Subsection "$bitmap->nclear($start, $stop);" .PP Clear bits \f(CW$start\fR .. \f(CW$stop\fR in \f(CW$bitmap\fR. .PP \fI\f(CI$pos\fI = \f(CI$bitmap\fI\->\f(BIffc()\fI;\fR .IX Subsection "$pos = $bitmap->ffc();" .PP Find first bit clear in \f(CW$bitmap\fR. .PP \fI\f(CI$pos\fI = \f(CI$bitmap\fI\->nffc($n)\fR .IX Subsection "$pos = $bitmap->nffc($n)" .PP Find the first \f(CW$n\fR contiguous bits clear in \f(CW$bitmap\fR. .PP \fI\f(CI$pos\fI = \f(CI$bitmap\fI\->noc($n, \f(CI$seed\fI);\fR .IX Subsection "$pos = $bitmap->noc($n, $seed);" .PP Find \f(CW$n\fR contiguous bits clear in \f(CW$bitmap\fR starting at offset \f(CW$seed\fR. .PP \fI\f(CI$pos\fI = \f(CI$bitmap\fI\->nffs($n);\fR .IX Subsection "$pos = $bitmap->nffs($n);" .PP Find the first \f(CW$n\fR contiguous bits set in \f(CW$bitmap\fR. .PP \fI\f(CI$pos\fI = \f(CI$bitmap\fI\->\f(BIffs()\fI;\fR .IX Subsection "$pos = $bitmap->ffs();" .PP Find first bit set in \f(CW$bitmap\fR; .PP \fI\f(CI$pos\fI = \f(CI$bitmap\fI\->\f(BIfls()\fI;\fR .IX Subsection "$pos = $bitmap->fls();" .PP Find last bit set in \f(CW$bitmap\fR; .PP \fI\f(CI$bitmap\fI\->\f(BIfill_gaps()\fI;\fR .IX Subsection "$bitmap->fill_gaps();" .PP Set all bits of \f(CW$bitmap\fR between the first and last bits set(i.e. fill in the gaps to make set bits contiguous). .PP \fI\f(CI$cond\fI = \f(CI$bitmap1\fI\->super_set($bitmap2);\fR .IX Subsection "$cond = $bitmap1->super_set($bitmap2);" .PP Return 1 if all bits set in \f(CW$bitmap1\fR are also set in \f(CW$bitmap2\fR, 0 otherwise. .PP \fI\f(CI$cond\fI = \f(CI$bitmap1\fI\->equal($bitmap2);\fR .IX Subsection "$cond = $bitmap1->equal($bitmap2);" .PP Return 1 if \f(CW$bitmap1\fR and \f(CW$bitmap2\fR are identical, 0 otherwise. .PP \fI\f(CI$bitmap1\fI\->and($bitmap2);\fR .IX Subsection "$bitmap1->and($bitmap2);" .PP \&\f(CW$bitmap1\fR &= \f(CW$bitmap2\fR. .PP \fI\f(CI$bitmap\fI\->\f(BInot()\fI;\fR .IX Subsection "$bitmap->not();" .PP \&\f(CW$bitmap\fR = ~$bitmap. .PP \fI\f(CI$bitmap1\fI\->or($bitmap2);\fR .IX Subsection "$bitmap1->or($bitmap2);" .PP \&\f(CW$bitmap1\fR |= \f(CW$bitmap2\fR. .PP \fI\f(CI$new\fI = \f(CI$bitmap\fI\->\f(BIcopy()\fI;\fR .IX Subsection "$new = $bitmap->copy();" .PP Return a copy of the supplied bitmap. .PP \fI\f(CI$dest_bitmap\fI\->copybits($src_bitmap);\fR .IX Subsection "$dest_bitmap->copybits($src_bitmap);" .PP Copy all bits of \f(CW$src_bitmap\fR to \f(CW$dest_bitmap\fR. .PP \fI\f(CI$n\fI = \f(CI$bitmap\fI\->\f(BIset_count()\fI;\fR .IX Subsection "$n = $bitmap->set_count();" .PP Count the number of bits set in bitstring. .PP \fI\f(CI$n\fI = \f(CI$bitmap1\fI\->overlap($bitmap2);\fR .IX Subsection "$n = $bitmap1->overlap($bitmap2);" .PP Return number of bits set in \f(CW$bitmap1\fR that are also set in \f(CW$bitmap2\fR, 0 if no overlap. .PP \fI\f(CI$n\fI = \f(CI$bitmap\fI\->\f(BIclear_count()\fI;\fR .IX Subsection "$n = $bitmap->clear_count();" .PP Count the number of bits clear in bitstring. .PP \fI\f(CI$n\fI = \f(CI$bitmap\fI\->\f(BInset_max_count()\fI;\fR .IX Subsection "$n = $bitmap->nset_max_count();" .PP Return the count of the largest number of contiguous bits set in \f(CW$bitmap\fR. .PP \fI\f(CI$sum\fI = \f(CI$bitmap\fI\->inst_and_set_count($int_array);\fR .IX Subsection "$sum = $bitmap->inst_and_set_count($int_array);" .PP And \f(CW$int_array\fR and \f(CW$bitmap\fR and sum the elements corresponding to set entries in \f(CW$bitmap\fR. .PP \fI\f(CI$new\fI = \f(CI$bitmap\fI\->rotate_copy($n, \f(CI$nbits\fI);\fR .IX Subsection "$new = $bitmap->rotate_copy($n, $nbits);" .PP Return a copy of \f(CW$bitmap\fR rotated by \f(CW$n\fR bits. Number of bit in the new bitmap is \f(CW$nbits\fR. .PP \fI\f(CI$bitmap\fI\->rotate($n);\fR .IX Subsection "$bitmap->rotate($n);" .PP Rotate \f(CW$bitmap\fR by \f(CW$n\fR bits. .PP \fI\f(CI$new\fI = \f(CI$bitmap\fI\->pick_cnt($nbits);\fR .IX Subsection "$new = $bitmap->pick_cnt($nbits);" .PP Build a bitmap containing the first \f(CW$nbits\fR of \f(CW$bitmap\fR which are set. .PP \fI\f(CI$str\fI = \f(CI$bitmap\fI\->\f(BIfmt()\fI;\fR .IX Subsection "$str = $bitmap->fmt();" .PP Convert \f(CW$bitmap\fR to range string format, e.g. 0\-5,42 .PP \fI\f(CI$rc\fI = \f(CI$bitmap\fI\->unfmt($str);\fR .IX Subsection "$rc = $bitmap->unfmt($str);" .PP Convert range string format to bitmap. .PP \fI\f(CI$array\fI = Slurm::Bitstr::bitfmt2int($str);\fR .IX Subsection "$array = Slurm::Bitstr::bitfmt2int($str);" .PP Convert \f(CW$str\fR describing bitmap (output from \fBfmt()\fR, e.g. \*(L"0\-30,45,50\-60\*(R") into an array of integer (start/edn) pairs terminated by \-1 (e.g. \*(L"0, 30, 45, 45, 50, 60, \-1\*(R"). .PP \fI\f(CI$str\fI = \f(CI$bitmap\fI\->\f(BIfmt_hexmask()\fI;\fR .IX Subsection "$str = $bitmap->fmt_hexmask();" .PP Given a bit string, allocate and return a string in the form of: \*(L"0x0123ABC\e0\*(R" ^ ^ | | \s-1MSB\s0 \s-1LSB\s0 .PP \fI\f(CI$rc\fI = \f(CI$bitmap\fI\->unfmt_hexmask($str);\fR .IX Subsection "$rc = $bitmap->unfmt_hexmask($str);" .PP Give a hex mask string \*(L"0x0123ABC\e0\*(R", convert to a bit string. ^ ^ | | \s-1MSB\s0 \s-1LSB\s0 .PP \fI\f(CI$str\fI = \f(CI$bitmap\fI\->\f(BIfmt_binmask()\fI;\fR .IX Subsection "$str = $bitmap->fmt_binmask();" .PP Given a bit string, allocate and return a binary string in the form of: \*(L"0001010\e0\*(R" ^ ^ | | \s-1MSB\s0 \s-1LSB\s0 .PP \fI\f(CI$rc\fI = \f(CI$bitmap\fI\->unfmt_binmask($str);\fR .IX Subsection "$rc = $bitmap->unfmt_binmask($str);" .PP Give a bin mask string \*(L"0001010\e0\*(R", convert to a bit string. ^ ^ | | \s-1MSB\s0 \s-1LSB\s0 .PP \fI\f(CI$pos\fI = \f(CI$bitmap\fI\->get_bit_num($n);\fR .IX Subsection "$pos = $bitmap->get_bit_num($n);" .PP Find position of the \f(CW$n\fR\-th set bit(0 based, i.e., the first set bit is the 0\-th) in \f(CW$bitmap\fR. Returns \-1 if there are less than \f(CW$n\fR bits set. .PP \fI\f(CI$n\fI = \f(CI$bitmap\fI\->get_pos_num($pos);\fR .IX Subsection "$n = $bitmap->get_pos_num($pos);" .PP Find the number of bits set minus one in \f(CW$bitmap\fR between bit position [0 .. \f(CW$pos\fR]. Returns \-1 if no bits are set between [0 .. \f(CW$pos\fR]. .SH "SEE ALSO" .IX Header "SEE ALSO" Slurm .SH "AUTHOR" .IX Header "AUTHOR" This library is created by Hongjia Cao, and Danny Auble, . It is distributed with Slurm. .SH "COPYRIGHT AND LICENSE" .IX Header "COPYRIGHT AND LICENSE" 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.