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
impl ParamIndices
Sourcepub fn to_bitset(&self) -> BitSet
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.
Sourcepub fn empty() -> ParamIndices
pub fn empty() -> ParamIndices
Creates a ParamIndices representing a constant value (no parameters).
§Returns
A ParamIndices representing an empty set of parameter indices.
Sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Checks if the ParamIndices is empty (contains no parameters).
§Returns
true if the ParamIndices is empty, false otherwise.
Sourcepub fn is_consecutive(&self) -> bool
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.
Sourcepub fn num_params(&self) -> usize
pub fn num_params(&self) -> usize
Returns the number of parameters represented by the ParamIndices.
§Returns
The number of parameters.
Sourcepub fn start(&self) -> usize
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.
Sourcepub fn union(&self, other: &ParamIndices) -> ParamIndices
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 otherParamIndicesto concatenate with.
§Returns
A new ParamIndices representing the concatenation of the two input ParamIndices.
Sourcepub fn intersect(&self, other: &ParamIndices) -> ParamIndices
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 otherParamIndicesto intersect with.
§Returns
A new ParamIndices representing the intersection of the two input ParamIndices.
Sourcepub fn sort(&mut self) -> &mut Self
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.
Sourcepub fn iter<'a>(&'a self) -> ParamIndicesIter<'a>
pub fn iter<'a>(&'a self) -> ParamIndicesIter<'a>
Creates an iterator over the parameter indices.
§Returns
A ParamIndicesIter that yields the parameter indices.
Trait Implementations§
Source§impl Clone for ParamIndices
impl Clone for ParamIndices
Source§fn clone(&self) -> ParamIndices
fn clone(&self) -> ParamIndices
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more