.\" Automatically generated by Pod::Man 2.28 (Pod::Simple 3.28) .\" .\" 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 turned on, 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 .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "Slurm::Bitstr 3pm" .TH Slurm::Bitstr 3pm "2014-10-17" "perl v5.20.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" \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\->\fIsize()\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\->\fIffc()\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\->\fIffs()\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\->\fIfls()\fI;\fR .IX Subsection "$pos = $bitmap->fls();" .PP Find last bit set in \f(CW$bitmap\fR; .PP \fI\f(CI$bitmap\fI\->\fIfill_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\->\fInot()\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\->\fIcopy()\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\->\fIset_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\->\fIclear_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\->\fInset_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\->\fIfmt()\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 \fIfmt()\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\->\fIfmt_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 LSB\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 LSB\s0 .PP \fI\f(CI$str\fI = \f(CI$bitmap\fI\->\fIfmt_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 LSB\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 LSB\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 postion [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 \s-1SLURM.\s0 .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.