.\" -*- mode: troff; coding: utf-8 -*- .\" Automatically generated by Pod::Man 5.01 (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 .. .\" \*(C` and \*(C' are quotes in nroff, nothing in troff, for use with C<>. .ie n \{\ . ds C` "" . ds C' "" 'br\} .el\{\ . 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 2024-02-25 "perl v5.38.2" "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" \fR\f(CI$bitmap\fR\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 \fBCLASS METHOD\fR. .PP \fR\f(CI$bitmap\fR\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 \fR\f(CI$len\fR\fI = \fR\f(CI$bitmap\fR\fI\->\fR\f(BIsize()\fR\fI;\fR .IX Subsection "$len = $bitmap->size();" .PP Return the number of possible bits in a bitstring. .PP \fR\f(CI$cond\fR\fI = \fR\f(CI$bitmap\fR\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 \fR\f(CI$bitmap\fR\fI\->set($n);\fR .IX Subsection "$bitmap->set($n);" .PP Set bit \f(CW$n\fR of \f(CW$bitmap\fR. .PP \fR\f(CI$bitmap\fR\fI\->clear($n);\fR .IX Subsection "$bitmap->clear($n);" .PP Clear bit \f(CW$n\fR of \f(CW$bitmap\fR. .PP \fR\f(CI$bitmap\fR\fI\->nset($start, \fR\f(CI$stop\fR\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 \fR\f(CI$bitmap\fR\fI\->nclear($start, \fR\f(CI$stop\fR\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 \fR\f(CI$pos\fR\fI = \fR\f(CI$bitmap\fR\fI\->\fR\f(BIffc()\fR\fI;\fR .IX Subsection "$pos = $bitmap->ffc();" .PP Find first bit clear in \f(CW$bitmap\fR. .PP \fR\f(CI$pos\fR\fI = \fR\f(CI$bitmap\fR\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 \fR\f(CI$pos\fR\fI = \fR\f(CI$bitmap\fR\fI\->noc($n, \fR\f(CI$seed\fR\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 \fR\f(CI$pos\fR\fI = \fR\f(CI$bitmap\fR\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 \fR\f(CI$pos\fR\fI = \fR\f(CI$bitmap\fR\fI\->\fR\f(BIffs()\fR\fI;\fR .IX Subsection "$pos = $bitmap->ffs();" .PP Find first bit set in \f(CW$bitmap\fR; .PP \fR\f(CI$pos\fR\fI = \fR\f(CI$bitmap\fR\fI\->\fR\f(BIfls()\fR\fI;\fR .IX Subsection "$pos = $bitmap->fls();" .PP Find last bit set in \f(CW$bitmap\fR; .PP \fR\f(CI$bitmap\fR\fI\->\fR\f(BIfill_gaps()\fR\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 \fR\f(CI$cond\fR\fI = \fR\f(CI$bitmap1\fR\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 \fR\f(CI$cond\fR\fI = \fR\f(CI$bitmap1\fR\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 \fR\f(CI$bitmap1\fR\fI\->and($bitmap2);\fR .IX Subsection "$bitmap1->and($bitmap2);" .PP \&\f(CW$bitmap1\fR &= \f(CW$bitmap2\fR. .PP \fR\f(CI$bitmap\fR\fI\->\fR\f(BInot()\fR\fI;\fR .IX Subsection "$bitmap->not();" .PP \&\f(CW$bitmap\fR = ~$bitmap. .PP \fR\f(CI$bitmap1\fR\fI\->or($bitmap2);\fR .IX Subsection "$bitmap1->or($bitmap2);" .PP \&\f(CW$bitmap1\fR |= \f(CW$bitmap2\fR. .PP \fR\f(CI$new\fR\fI = \fR\f(CI$bitmap\fR\fI\->\fR\f(BIcopy()\fR\fI;\fR .IX Subsection "$new = $bitmap->copy();" .PP Return a copy of the supplied bitmap. .PP \fR\f(CI$dest_bitmap\fR\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 \fR\f(CI$n\fR\fI = \fR\f(CI$bitmap\fR\fI\->\fR\f(BIset_count()\fR\fI;\fR .IX Subsection "$n = $bitmap->set_count();" .PP Count the number of bits set in bitstring. .PP \fR\f(CI$n\fR\fI = \fR\f(CI$bitmap1\fR\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 \fR\f(CI$n\fR\fI = \fR\f(CI$bitmap\fR\fI\->\fR\f(BIclear_count()\fR\fI;\fR .IX Subsection "$n = $bitmap->clear_count();" .PP Count the number of bits clear in bitstring. .PP \fR\f(CI$n\fR\fI = \fR\f(CI$bitmap\fR\fI\->\fR\f(BInset_max_count()\fR\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 \fR\f(CI$sum\fR\fI = \fR\f(CI$bitmap\fR\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 \fR\f(CI$new\fR\fI = \fR\f(CI$bitmap\fR\fI\->rotate_copy($n, \fR\f(CI$nbits\fR\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 \fR\f(CI$bitmap\fR\fI\->rotate($n);\fR .IX Subsection "$bitmap->rotate($n);" .PP Rotate \f(CW$bitmap\fR by \f(CW$n\fR bits. .PP \fR\f(CI$new\fR\fI = \fR\f(CI$bitmap\fR\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 \fR\f(CI$str\fR\fI = \fR\f(CI$bitmap\fR\fI\->\fR\f(BIfmt()\fR\fI;\fR .IX Subsection "$str = $bitmap->fmt();" .PP Convert \f(CW$bitmap\fR to range string format, e.g. 0\-5,42 .PP \fR\f(CI$rc\fR\fI = \fR\f(CI$bitmap\fR\fI\->unfmt($str);\fR .IX Subsection "$rc = $bitmap->unfmt($str);" .PP Convert range string format to bitmap. .PP \fR\f(CI$array\fR\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. "0\-30,45,50\-60") into an array of integer (start/edn) pairs terminated by \-1 (e.g. "0, 30, 45, 45, 50, 60, \-1"). .PP \fR\f(CI$str\fR\fI = \fR\f(CI$bitmap\fR\fI\->\fR\f(BIfmt_hexmask()\fR\fI;\fR .IX Subsection "$str = $bitmap->fmt_hexmask();" .PP Given a bit string, allocate and return a string in the form of: "0x0123ABC\e0" ^ ^ | | MSB LSB .PP \fR\f(CI$rc\fR\fI = \fR\f(CI$bitmap\fR\fI\->unfmt_hexmask($str);\fR .IX Subsection "$rc = $bitmap->unfmt_hexmask($str);" .PP Give a hex mask string "0x0123ABC\e0", convert to a bit string. ^ ^ | | MSB LSB .PP \fR\f(CI$str\fR\fI = \fR\f(CI$bitmap\fR\fI\->\fR\f(BIfmt_binmask()\fR\fI;\fR .IX Subsection "$str = $bitmap->fmt_binmask();" .PP Given a bit string, allocate and return a binary string in the form of: "0001010\e0" ^ ^ | | MSB LSB .PP \fR\f(CI$rc\fR\fI = \fR\f(CI$bitmap\fR\fI\->unfmt_binmask($str);\fR .IX Subsection "$rc = $bitmap->unfmt_binmask($str);" .PP Give a bin mask string "0001010\e0", convert to a bit string. ^ ^ | | MSB LSB .PP \fR\f(CI$pos\fR\fI = \fR\f(CI$bitmap\fR\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 \fR\f(CI$n\fR\fI = \fR\f(CI$bitmap\fR\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.