pub struct RangeExpr { /* private fields */ }Expand description
A range expression: a sorted set of non-overlapping integer ranges.
Implementations§
Source§impl RangeExpr
impl RangeExpr
Sourcepub fn with_contiguous(self, contiguous: bool) -> Self
pub fn with_contiguous(self, contiguous: bool) -> Self
Set contiguous display mode. When true, Display uses “{start}-{end}” format even for single values (e.g., “5-5”). Only meaningful for contiguous chunks.
Sourcepub fn from_values(values: Vec<i64>) -> Self
pub fn from_values(values: Vec<i64>) -> Self
Create a RangeExpr from a list of individual values.
Sourcepub fn from_ranges(ranges: Vec<IntRange>) -> Result<Self, ExpressionError>
pub fn from_ranges(ranges: Vec<IntRange>) -> Result<Self, ExpressionError>
Create from pre-built IntRanges. Sorts, merges adjacent ranges, and validates no overlaps.
Returns an error if the number of input ranges exceeds
MAX_RANGE_EXPR_CHUNKS.
Sourcepub fn contains(&self, value: i64) -> bool
pub fn contains(&self, value: i64) -> bool
Test membership via binary search on sub-range endpoints. O(log m).
Sourcepub fn get(&self, index: i64) -> Option<i64>
pub fn get(&self, index: i64) -> Option<i64>
Get element by index (supports negative indexing like Python).
Sourcepub fn cumulative_lengths(&self) -> &[usize]
pub fn cumulative_lengths(&self) -> &[usize]
Cumulative element counts per sub-range (for index mapping).
Sourcepub fn iter(&self) -> impl Iterator<Item = i64> + '_
pub fn iter(&self) -> impl Iterator<Item = i64> + '_
Iterate over all values in ascending order across all sub-ranges.
pub fn to_vec(&self) -> Vec<i64>
Sourcepub fn slice(
&self,
start: i64,
stop: i64,
step: i64,
) -> Result<RangeExpr, ExpressionError>
pub fn slice( &self, start: i64, stop: i64, step: i64, ) -> Result<RangeExpr, ExpressionError>
Slice this range expression with a positive step.
start, stop, step are already-normalized indices into the
flattened element sequence. step must be positive. Returns a new
RangeExpr without materializing any elements.
Runs in O(m) where m is the number of sub-ranges, regardless of how many elements are selected. Each sub-range’s intersection with the slice index sequence is computed as pure arithmetic.
For negative step (reverse slices), callers should use get() to
collect elements into a list, since RangeExpr cannot represent
descending sequences.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for RangeExpr
impl<'de> Deserialize<'de> for RangeExpr
Source§fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
impl Eq for RangeExpr
Auto Trait Implementations§
impl Freeze for RangeExpr
impl RefUnwindSafe for RangeExpr
impl Send for RangeExpr
impl Sync for RangeExpr
impl Unpin for RangeExpr
impl UnsafeUnpin for RangeExpr
impl UnwindSafe for RangeExpr
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> ToCompactString for Twhere
T: Display,
impl<T> ToCompactString for Twhere
T: Display,
Source§fn try_to_compact_string(&self) -> Result<CompactString, ToCompactStringError>
fn try_to_compact_string(&self) -> Result<CompactString, ToCompactStringError>
ToCompactString::to_compact_string() Read moreSource§fn to_compact_string(&self) -> CompactString
fn to_compact_string(&self) -> CompactString
CompactString. Read more