ParamIndices

Enum ParamIndices 

Source
pub enum ParamIndices {
    Joint(usize, usize),
    Disjoint(Vec<usize>),
}
Expand description

A data structure representing indices of parameters (e.g. for a function). There are optimized methods for consecutive and disjoint parameters.

Variants§

§

Joint(usize, usize)

The index of the first parameter (consecutive parameters)

§

Disjoint(Vec<usize>)

The index of each parameter (disjoint parameters)

Implementations§

Source§

impl ParamIndices

Source

pub fn to_bitset(&self) -> BitSet

Converts the ParamIndices to a BitSet.

This function creates a BitSet where each bit corresponds to a parameter index. If a parameter index is present in the ParamIndices, the corresponding bit in the BitSet is set to 1.

§Returns

A BitSet representing the parameter indices.

Source

pub fn empty() -> ParamIndices

Creates a ParamIndices representing a constant value (no parameters).

§Returns

A ParamIndices representing an empty set of parameter indices.

Source

pub fn is_empty(&self) -> bool

Checks if the ParamIndices is empty (contains no parameters).

§Returns

true if the ParamIndices is empty, false otherwise.

Source

pub fn is_consecutive(&self) -> bool

Checks if the ParamIndices represents a consecutive range of parameters.

§Returns

true if the ParamIndices is consecutive, false otherwise.

Source

pub fn num_params(&self) -> usize

Returns the number of parameters represented by the ParamIndices.

§Returns

The number of parameters.

Source

pub fn start(&self) -> usize

Returns the starting index of the parameters.

For ParamIndices::Joint, this is the index of the first parameter in the consecutive range. For ParamIndices::Disjoint, this is the index of the first parameter in the vector, or 0 if the vector is empty.

§Returns

The starting index of the parameters.

Source

pub fn union(&self, other: &ParamIndices) -> ParamIndices

Concatenates two ParamIndices into a single ParamIndices.

This function combines the parameter indices from two ParamIndices instances. If the two ParamIndices represent overlapping ranges, they are merged into a single ParamIndices::Joint if possible. Otherwise, the parameter indices are combined into a ParamIndices::Disjoint.

§Arguments
  • other - The other ParamIndices to concatenate with.
§Returns

A new ParamIndices representing the concatenation of the two input ParamIndices.

Source

pub fn intersect(&self, other: &ParamIndices) -> ParamIndices

Computes the intersection of two ParamIndices.

This function returns a new ParamIndices containing only the parameter indices that are present in both input ParamIndices. The result is always a ParamIndices::Disjoint.

§Arguments
  • other - The other ParamIndices to intersect with.
§Returns

A new ParamIndices representing the intersection of the two input ParamIndices.

Source

pub fn sort(&mut self) -> &mut Self

Sorts the indices.

If the ParamIndices is Joint, this method does nothing.

§Returns

A mutable reference to self for chaining.

Source

pub fn sorted(&self) -> Self

Returns a new ParamIndices with the indices sorted.

Source

pub fn iter<'a>(&'a self) -> ParamIndicesIter<'a>

Creates an iterator over the parameter indices.

§Returns

A ParamIndicesIter that yields the parameter indices.

Source

pub fn contains(&self, index: usize) -> bool

Checks if the ParamIndices contains the given index.

§Arguments
  • index - The index to check.
§Returns

true if the ParamIndices contains the index, false otherwise.

Source

pub fn to_vec(self) -> Vec<usize>

Convert the indices to a vector

Source

pub fn as_vec(&self) -> Vec<usize>

Convert the indices to a vector without consuming the indices object.

Source

pub fn len(&self) -> usize

Returns the number of indices tracked by this object; alias for num_params()

Trait Implementations§

Source§

impl Clone for ParamIndices

Source§

fn clone(&self) -> ParamIndices

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for ParamIndices

Source§

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

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

impl<T: AsRef<[usize]>> From<T> for ParamIndices

Source§

fn from(indices: T) -> Self

Converts to this type from the input type.
Source§

impl Hash for ParamIndices

Source§

fn hash<H: Hasher>(&self, state: &mut H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl<'a> IntoIterator for &'a ParamIndices

Source§

type Item = usize

The type of the elements being iterated over.
Source§

type IntoIter = ParamIndicesIter<'a>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
Source§

impl PartialEq for ParamIndices

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · 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 Eq for ParamIndices

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> ByRef<T> for T

Source§

fn by_ref(&self) -> &T

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> DistributionExt for T
where T: ?Sized,

Source§

fn rand<T>(&self, rng: &mut (impl Rng + ?Sized)) -> T
where Self: Distribution<T>,

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, 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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V