Skip to main content

igraph_bitset_t

Struct igraph_bitset_t 

Source
pub struct igraph_bitset_t { /* private fields */ }

Implementations§

Source§

impl igraph_bitset_t

Source

pub fn new(len: usize) -> Self

Creates a bitset of len bits, all zero (igraph_bitset_init).

Source

pub fn from_bools(bits: &[bool]) -> Self

Creates a bitset from a slice of booleans (bits[i] is bit i).

Source

pub fn from_ones(len: usize, ones: impl IntoIterator<Item = usize>) -> Self

Creates a bitset of len bits where exactly the listed positions are set.

§Panics

If a position is >= len.

Source

pub fn len(&self) -> usize

Number of bits (igraph_bitset_size).

Source

pub fn is_empty(&self) -> bool

Whether the bitset has no bits at all (not whether all bits are zero: see none).

Source

pub fn capacity(&self) -> usize

Number of bits that fit in the allocated storage (igraph_bitset_capacity).

Source

pub fn reserve(&mut self, capacity: usize)

Reserves storage for at least capacity bits in total (igraph_bitset_reserve).

Source

pub fn resize(&mut self, len: usize)

Changes the number of bits; new bits are zero (igraph_bitset_resize).

Source

pub fn get(&self, i: usize) -> bool

The value of bit i (IGRAPH_BIT_TEST).

§Panics

If i >= len.

Source

pub fn set(&mut self, i: usize, value: bool)

Sets bit i to value (IGRAPH_BIT_SET / IGRAPH_BIT_CLEAR).

§Panics

If i >= len.

Source

pub fn toggle(&mut self, i: usize) -> bool

Flips bit i and returns its new value.

§Panics

If i >= len.

Source

pub fn insert(&mut self, i: usize) -> bool

Sets bit i and returns whether it was not set before (like HashSet::insert).

§Panics

If i >= len.

Source

pub fn push(&mut self, value: bool)

Appends a bit at the end, growing the bitset by one.

Source

pub fn count_ones(&self) -> usize

Number of set bits (the population count) (igraph_bitset_popcount).

Source

pub fn count_zeros(&self) -> usize

Number of zero bits.

Source

pub fn leading_zeros(&self) -> usize

Number of zeros before the first one, starting from the most significant bit (len if all zero) (igraph_bitset_countl_zero).

Source

pub fn leading_ones(&self) -> usize

Number of ones before the first zero, starting from the most significant bit (igraph_bitset_countl_one).

Source

pub fn trailing_zeros(&self) -> usize

Number of zeros before the first one, starting from bit 0 (len if all zero); i.e. the index of the first set bit (igraph_bitset_countr_zero).

Source

pub fn trailing_ones(&self) -> usize

Number of ones before the first zero, starting from bit 0 (igraph_bitset_countr_one).

Source

pub fn all(&self) -> bool

Whether all bits are one (true for an empty bitset) (igraph_bitset_is_all_one).

Source

pub fn any(&self) -> bool

Whether some bit is one (igraph_bitset_is_any_one).

Source

pub fn none(&self) -> bool

Whether all bits are zero (true for an empty bitset) (igraph_bitset_is_all_zero).

Source

pub fn not_all(&self) -> bool

Whether some bit is zero (igraph_bitset_is_any_zero).

Source

pub fn fill(&mut self, value: bool)

Sets every bit to value (igraph_bitset_fill).

Source

pub fn clear(&mut self)

Sets every bit to zero, keeping the length (igraph_bitset_null).

Source

pub fn iter(&self) -> impl Iterator<Item = bool> + '_

Iterates over all the bits, from bit 0.

Source

pub fn iter_ones(&self) -> impl Iterator<Item = usize> + '_

Iterates over the positions of the set bits, in increasing order, skipping whole zero words.

Source

pub fn to_vec(&self) -> Vec<bool>

The bits as a Vec<bool>.

Source

pub fn and(&self, other: &Self) -> Self

Bitwise AND (igraph_bitset_and).

§Panics

If the lengths differ.

Source

pub fn or(&self, other: &Self) -> Self

Bitwise OR (igraph_bitset_or).

§Panics

If the lengths differ.

Source

pub fn xor(&self, other: &Self) -> Self

Bitwise XOR (igraph_bitset_xor).

§Panics

If the lengths differ.

Source

pub fn complement(&self) -> Self

Bitwise complement (igraph_bitset_not).

Source

pub fn update(&mut self, other: &Self)

Replaces the content with a copy of other, reusing the storage when possible (igraph_bitset_update).

Trait Implementations§

Source§

impl BitAnd for &igraph_bitset_t

Source§

fn bitand(self, rhs: Self) -> igraph_bitset_t

§Panics

If the lengths differ.

Source§

type Output = igraph_bitset_t

The resulting type after applying the & operator.
Source§

impl BitAndAssign<&igraph_bitset_t> for igraph_bitset_t

Source§

fn bitand_assign(&mut self, rhs: &igraph_bitset_t)

§Panics

If the lengths differ.

Source§

impl BitOr for &igraph_bitset_t

Source§

fn bitor(self, rhs: Self) -> igraph_bitset_t

§Panics

If the lengths differ.

Source§

type Output = igraph_bitset_t

The resulting type after applying the | operator.
Source§

impl BitOrAssign<&igraph_bitset_t> for igraph_bitset_t

Source§

fn bitor_assign(&mut self, rhs: &igraph_bitset_t)

§Panics

If the lengths differ.

Source§

impl BitXor for &igraph_bitset_t

Source§

fn bitxor(self, rhs: Self) -> igraph_bitset_t

§Panics

If the lengths differ.

Source§

type Output = igraph_bitset_t

The resulting type after applying the ^ operator.
Source§

impl BitXorAssign<&igraph_bitset_t> for igraph_bitset_t

Source§

fn bitxor_assign(&mut self, rhs: &igraph_bitset_t)

§Panics

If the lengths differ.

Source§

impl Clone for igraph_bitset_t

Source§

fn clone(&self) -> Self

Deep copy with igraph_bitset_init_copy.

1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for igraph_bitset_t

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for igraph_bitset_t

Source§

fn default() -> Self

An empty bitset.

Source§

impl Display for igraph_bitset_t

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Writes the bits as 0/1 characters, most significant (highest index) first, like igraph_bitset_print.

Source§

impl Drop for igraph_bitset_t

Source§

fn drop(&mut self)

Frees the storage with igraph_bitset_destroy.

Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more
Source§

impl Eq for igraph_bitset_t

Source§

impl Extend<igraph_bitset_t> for igraph_bitset_list_t

Source§

fn extend<I: IntoIterator<Item = igraph_bitset_t>>(&mut self, iter: I)

Extends a collection with the contents of an iterator. Read more
Source§

fn extend_one(&mut self, item: A)

🔬This is a nightly-only experimental API. (extend_one)
Extends a collection with exactly one element.
Source§

fn extend_reserve(&mut self, additional: usize)

🔬This is a nightly-only experimental API. (extend_one)
Reserves capacity in a collection for the given number of additional elements. Read more
Source§

impl From<&[bool]> for igraph_bitset_t

Source§

fn from(bits: &[bool]) -> Self

Converts to this type from the input type.
Source§

impl From<&igraph_bitset_t> for Vec<bool>

Source§

fn from(b: &igraph_bitset_t) -> Self

Converts to this type from the input type.
Source§

impl FromIterator<bool> for igraph_bitset_t

Source§

fn from_iter<I: IntoIterator<Item = bool>>(iter: I) -> Self

Creates a value from an iterator. Read more
Source§

impl FromIterator<igraph_bitset_t> for igraph_bitset_list_t

Source§

fn from_iter<I: IntoIterator<Item = igraph_bitset_t>>(iter: I) -> Self

Creates a value from an iterator. Read more
Source§

impl Not for &igraph_bitset_t

Source§

type Output = igraph_bitset_t

The resulting type after applying the ! operator.
Source§

fn not(self) -> igraph_bitset_t

Performs the unary ! operation. Read more
Source§

impl PartialEq for igraph_bitset_t

Source§

fn eq(&self, other: &Self) -> bool

Two bitsets are equal when they have the same length and bits (the unused padding bits of the last word are ignored).

1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Send for igraph_bitset_t

Source§

impl Sync for igraph_bitset_t

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.