Struct swiss_army_knife::bit_set::BitSet [−][src]
#[repr(transparent)]pub struct BitSet<BSA: BitSetAware>(_, _);
Expand description
Represents a BitSet suitable for use with various Linux /sys
files and NUMA syscalls.
Internally uses usize
to match what Linux uses.
Implementations
Creates a new empty bit set (all bits are initially zero) of the maximum possible size.
Creates an empty new instance of the same capacity as this one.
Creates a new empty bit set (all bits are initially zero).
Panics if size_in_words
exceeds that needed to represent BSA::LinuxMaximum
.
pub fn parse_linux_list_string(
linux_list_string: &[u8]
) -> Result<BitSet<BSA>, ListParseError>
pub fn parse_linux_list_string(
linux_list_string: &[u8]
) -> Result<BitSet<BSA>, ListParseError>
Parses a Linux list string used for cpu sets, core masks and NUMA nodes such as “2,4-31,32-63” and “1,2,10-20,100-2000:2/25” (see https://www.kernel.org/doc/html/latest/admin-guide/kernel-parameters.html for an awful description of this mad syntax).
Returns a BitSet with the zero-based indices found in the string. For example, “2,4-31,32-63” would return a set with all values between 0 to 63 except 0, 1 and 3.
linux_list_string
does not have a terminating line feed (LF).
Removes the highest values from the set.
pub fn iterate<'a>(&'a self) -> BitSetIterator<'a, BSA>ⓘNotable traits for BitSetIterator<'a, BSA>
impl<'a, BSA: BitSetAware> Iterator for BitSetIterator<'a, BSA> type Item = BSA;
pub fn iterate<'a>(&'a self) -> BitSetIterator<'a, BSA>ⓘNotable traits for BitSetIterator<'a, BSA>
impl<'a, BSA: BitSetAware> Iterator for BitSetIterator<'a, BSA> type Item = BSA;
Iterate.
pub fn iterate_infinitely<'a>(&'a self) -> InfiniteBitSetIterator<'a, BSA>ⓘNotable traits for InfiniteBitSetIterator<'a, BSA>
impl<'a, BSA: BitSetAware> Iterator for InfiniteBitSetIterator<'a, BSA> type Item = BSA;
pub fn iterate_infinitely<'a>(&'a self) -> InfiniteBitSetIterator<'a, BSA>ⓘNotable traits for InfiniteBitSetIterator<'a, BSA>
impl<'a, BSA: BitSetAware> Iterator for InfiniteBitSetIterator<'a, BSA> type Item = BSA;
Iterate infinitely.
pub fn iterate_including_empty<'a>(
&'a self
) -> BitSetIncludingEmptyIterator<'a, BSA>ⓘNotable traits for BitSetIncludingEmptyIterator<'a, BSA>
impl<'a, BSA: BitSetAware> Iterator for BitSetIncludingEmptyIterator<'a, BSA> type Item = Option<BSA>;
pub fn iterate_including_empty<'a>(
&'a self
) -> BitSetIncludingEmptyIterator<'a, BSA>ⓘNotable traits for BitSetIncludingEmptyIterator<'a, BSA>
impl<'a, BSA: BitSetAware> Iterator for BitSetIncludingEmptyIterator<'a, BSA> type Item = Option<BSA>;
Iterate.
Capacity assuming one byte per HyperThread represented.
Suitable for use as the size of a Vec
, say, which will hold HyperThread items, one per HyperThread.
Are no bits set?
This operation is a little expensive, but less expensive than self.len()
.
Are all bits set?
This operation is a little expensive, but less expensive than self.len()
.
Is this longer than maximum_length
?
More efficient than calling self.len() <= maximum_length
.
Is this longer than maximum_length
?
More efficient than calling self.len() > maximum_length
.
Number of bits set.
This operation is relatively expensive.
For an emptiness check, prefer self.is_empty()
which is slightly less expensive.
Number of bits set if all bits are set.
Adds, without checking capacity.
Removes top bits that are zero and tries to shrink underlying storage.
Use only if intending to store a BitSet in memory for a long time.
Keeps only bits in both sets.
If sets are of different lengths, the missing bits are assumed to be zero.
Removes bits in other
.
Trait Implementations
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
This method returns an ordering between self
and other
values if one exists. Read more
This method tests less than (for self
and other
) and is used by the <
operator. Read more
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
Auto Trait Implementations
impl<BSA> RefUnwindSafe for BitSet<BSA> where
BSA: RefUnwindSafe,
impl<BSA> UnwindSafe for BitSet<BSA> where
BSA: UnwindSafe,
Blanket Implementations
Mutably borrows from an owned value. Read more
impl<T> CallHasher for T where
T: Hash,
impl<T> CallHasher for T where
T: Hash,