1Slurm::Bitstr(3)      User Contributed Perl Documentation     Slurm::Bitstr(3)
2
3
4

NAME

6       Slurm::Bitstr - Bitstring functions in libslurm
7

SYNOPSIS

9        use Slurm;
10
11        $bitmap = Slurm::Bitstr::alloc(32);
12        if ($bitmap->test(10)) {
13               print "bit 10 is set\n";
14        }
15

DESCRIPTION

17       The Slurm::Bitstr class is a wrapper of the bit string functions in
18       libslurm. This package is loaded and bootstrapped with package Slurm.
19

METHODS

21       $bitmap = Slurm::Bitstr::alloc($nbits);
22
23       Allocate a bitstring object with $nbits bits. An opaque bitstr object
24       is returned. This is a CLASS METHOD.
25
26       $bitmap->realloc($nbits);
27
28       Reallocate a bitstring(expand or contract size). $nbits is the number
29       of bits in the new bitstring.
30
31       $len = $bitmap->size();
32
33       Return the number of possible bits in a bitstring.
34
35       $cond = $bitmap->test($n);
36
37       Check if bit $n of $bitmap is set.
38
39       $bitmap->set($n);
40
41       Set bit $n of $bitmap.
42
43       $bitmap->clear($n);
44
45       Clear bit $n of $bitmap.
46
47       $bitmap->nset($start, $stop);
48
49       Set bits $start .. $stop in $bitmap.
50
51       $bitmap->nclear($start, $stop);
52
53       Clear bits $start .. $stop in $bitmap.
54
55       $pos = $bitmap->ffc();
56
57       Find first bit clear in $bitmap.
58
59       $pos = $bitmap->nffc($n)
60
61       Find the first $n contiguous bits clear in $bitmap.
62
63       $pos = $bitmap->noc($n, $seed);
64
65       Find $n contiguous bits clear in $bitmap starting at offset $seed.
66
67       $pos = $bitmap->nffs($n);
68
69       Find the first $n contiguous bits set in $bitmap.
70
71       $pos = $bitmap->ffs();
72
73       Find first bit set in $bitmap;
74
75       $pos = $bitmap->fls();
76
77       Find last bit set in $bitmap;
78
79       $bitmap->fill_gaps();
80
81       Set all bits of $bitmap between the first and last bits set(i.e. fill
82       in the gaps to make set bits contiguous).
83
84       $cond = $bitmap1->super_set($bitmap2);
85
86       Return 1 if all bits set in $bitmap1 are also set in $bitmap2, 0
87       otherwise.
88
89       $cond = $bitmap1->equal($bitmap2);
90
91       Return 1 if $bitmap1 and $bitmap2 are identical, 0 otherwise.
92
93       $bitmap1->and($bitmap2);
94
95       $bitmap1 &= $bitmap2.
96
97       $bitmap->not();
98
99       $bitmap = ~$bitmap.
100
101       $bitmap1->or($bitmap2);
102
103       $bitmap1 |= $bitmap2.
104
105       $new = $bitmap->copy();
106
107       Return a copy of the supplied bitmap.
108
109       $dest_bitmap->copybits($src_bitmap);
110
111       Copy all bits of $src_bitmap to $dest_bitmap.
112
113       $n = $bitmap->set_count();
114
115       Count the number of bits set in bitstring.
116
117       $n = $bitmap1->overlap($bitmap2);
118
119       Return number of bits set in $bitmap1 that are also set in $bitmap2, 0
120       if no overlap.
121
122       $n = $bitmap->clear_count();
123
124       Count the number of bits clear in bitstring.
125
126       $n = $bitmap->nset_max_count();
127
128       Return the count of the largest number of contiguous bits set in
129       $bitmap.
130
131       $sum = $bitmap->inst_and_set_count($int_array);
132
133       And $int_array and $bitmap and sum the elements corresponding to set
134       entries in $bitmap.
135
136       $new = $bitmap->rotate_copy($n, $nbits);
137
138       Return a copy of $bitmap rotated by $n bits. Number of bit in the new
139       bitmap is $nbits.
140
141       $bitmap->rotate($n);
142
143       Rotate $bitmap by $n bits.
144
145       $new = $bitmap->pick_cnt($nbits);
146
147       Build a bitmap containing the first $nbits of $bitmap which are set.
148
149       $str = $bitmap->fmt();
150
151       Convert $bitmap to range string format, e.g. 0-5,42
152
153       $rc = $bitmap->unfmt($str);
154
155       Convert range string format to bitmap.
156
157       $array = Slurm::Bitstr::bitfmt2int($str);
158
159       Convert $str describing bitmap (output from fmt(), e.g.
160       "0-30,45,50-60") into an array of integer (start/edn) pairs terminated
161       by -1 (e.g. "0, 30, 45, 45, 50, 60, -1").
162
163       $str = $bitmap->fmt_hexmask();
164
165       Given a bit string, allocate and return a string in the form of:
166           "0x0123ABC\0"
167              ^     ^
168              |     |
169             MSB   LSB
170
171       $rc = $bitmap->unfmt_hexmask($str);
172
173       Give a hex mask string "0x0123ABC\0", convert to a bit string.
174                                 ^     ^
175                                 |     |
176                                MSB   LSB
177
178       $str = $bitmap->fmt_binmask();
179
180       Given a bit string, allocate and return a binary string in the form of:
181                                   "0001010\0"
182                                    ^     ^
183                                    |     |
184                                   MSB   LSB
185
186       $rc = $bitmap->unfmt_binmask($str);
187
188       Give a bin mask string "0001010\0", convert to a bit string.
189                               ^     ^
190                               |     |
191                              MSB   LSB
192
193       $pos = $bitmap->get_bit_num($n);
194
195       Find position of the $n-th set bit(0 based, i.e., the first set bit is
196       the 0-th) in $bitmap. Returns -1 if there are less than $n bits set.
197
198       $n = $bitmap->get_pos_num($pos);
199
200       Find the number of bits set minus one in $bitmap between bit position
201       [0 .. $pos]. Returns -1 if no bits are set between [0 .. $pos].
202

SEE ALSO

204       Slurm
205

AUTHOR

207       This library is created by Hongjia Cao, <hjcao(AT)nudt.edu.cn> and
208       Danny Auble, <da(AT)llnl.gov>. It is distributed with Slurm.
209
211       This library is free software; you can redistribute it and/or modify it
212       under the same terms as Perl itself, either Perl version 5.8.4 or, at
213       your option, any later version of Perl 5 you may have available.
214
215
216
217perl v5.30.1                      2020-01-30                  Slurm::Bitstr(3)
Impressum