Struct indexing::Range
[−]
[src]
pub struct Range<'id, Proof = Unknown> { /* fields omitted */ }
A branded range.
Range<'id>
only indexes the container instantiated with the exact same
particular lifetime for the parameter 'id
at its inception from
the indices()
constructor.
The Range
may carry a proof of nonemptiness (type parameter Proof
),
which enables further methods.
The range is delimited by a start index and an end index. Some methods
will use offsets relative the the start of a range, others will use
“absolute indices” which are offsets relative to the base Container
itself.
Methods
impl<'id, P> Range<'id, P>
[src]
fn len(&self) -> usize
[src]
Return the length of the range.
fn is_empty(&self) -> bool
[src]
Return true
if the range is empty.
fn nonempty(&self) -> Result<Range<'id, NonEmpty>, IndexingError>
[src]
Try to create a proof that the Range is nonempty; return
a Result
where the Ok
branch carries a non-empty Range.
fn start(&self) -> usize
[src]
Return the start index.
fn end(&self) -> usize
[src]
Return the end index.
fn split_in_half(self) -> (Range<'id>, Range<'id, P>)
[src]
Split the range in half, with the upper middle index landing in the
latter half. Proof of length P
transfers to the latter half.
fn split_at(&self, index: usize) -> (Range<'id>, Range<'id>, bool)
[src]
Split to length index
; if past the end, return false and clamp to the end
index
is a relative index.
fn contains(&self, abs_index: usize) -> Option<Index<'id>>
[src]
abs_index
is an absolute index
fn subdivide(&self, n: usize) -> Subdivide<'id>
[src]
Return an iterator that divides the range in n
parts, in as
even length chunks as possible.
fn join<Q>(
&self,
other: Range<'id, Q>
) -> Result<Range<'id, <(P, Q) as ProofAdd>::Sum>, IndexingError> where
(P, Q): ProofAdd,
[src]
&self,
other: Range<'id, Q>
) -> Result<Range<'id, <(P, Q) as ProofAdd>::Sum>, IndexingError> where
(P, Q): ProofAdd,
Join together two adjacent ranges (they must be exactly touching, and in left to right order).
fn join_cover<Q>(
&self,
other: Range<'id, Q>
) -> Range<'id, <(P, Q) as ProofAdd>::Sum> where
(P, Q): ProofAdd,
[src]
&self,
other: Range<'id, Q>
) -> Range<'id, <(P, Q) as ProofAdd>::Sum> where
(P, Q): ProofAdd,
Extend the range to the end of other
, including any space in between
fn join_cover_both<Q>(
&self,
other: Range<'id, Q>
) -> Range<'id, <(P, Q) as ProofAdd>::Sum> where
(P, Q): ProofAdd,
[src]
&self,
other: Range<'id, Q>
) -> Range<'id, <(P, Q) as ProofAdd>::Sum> where
(P, Q): ProofAdd,
Extend the range to start and end of other
, including any space in between
fn as_range(&self) -> Range<usize>
[src]
fn frontiers(&self) -> (Range<'id>, Range<'id>)
[src]
Return two empty ranges, at the front and the back of the range respectively
fn forward_by(&self, index: &mut Index<'id>, offset: usize) -> bool
[src]
Increment index
, if doing so would still be before the end of the range
Return true
if the index was incremented.
fn forward_range_by<Q>(&self, r: Range<'id, Q>, offset: usize) -> Range<'id>
[src]
Increment r
, clamping to the end of self
.
fn no_proof(&self) -> Range<'id>
[src]
impl<'id, P> Range<'id, P>
[src]
fn first(&self) -> Index<'id, P>
[src]
Return the first index in the range (The index is accessible if the range
is NonEmpty
).
fn upper_middle(&self) -> Index<'id, P>
[src]
Return the middle index, rounding up.
Produces mid
where mid = start + len / 2
.
fn past_the_end(self) -> Index<'id, Unknown>
[src]
Return the index past the end of the range.
impl<'id> Range<'id, NonEmpty>
[src]
fn lower_middle(&self) -> Index<'id>
[src]
Return the middle index, rounding down.
Produces mid
where mid = start + (len - 1)/ 2
.
fn last(&self) -> Index<'id>
[src]
fn tail(self) -> Range<'id>
[src]
fn init(&self) -> Range<'id>
[src]
fn advance_(&self) -> Result<Range<'id, NonEmpty>, IndexingError>
[src]
fn advance(&mut self) -> bool
[src]
Increase the range's start, if the result is still a non-empty range.
Return true
if stepped successfully, false
if the range would be empty.
fn advance_by(&mut self, offset: usize) -> bool
[src]
Increase the range's start, if the result is still a non-empty range.
Return true
if stepped successfully, false
if the range would be empty.
fn advance_back(&mut self) -> bool
[src]
Decrease the range's end, if the result is still a non-empty range.
Return true
if stepped successfully, false
if the range would be empty.
Trait Implementations
impl<'id, P, Q> PartialEq<Range<'id, Q>> for Range<'id, P>
[src]
fn eq(&self, other: &Range<'id, Q>) -> bool
[src]
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
This method tests for !=
.
impl<'id, P> Eq for Range<'id, P>
[src]
impl<'id, P> Hash for Range<'id, P>
[src]
fn hash<H: Hasher>(&self, h: &mut H)
[src]
Feeds this value into the given [Hasher
]. Read more
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
Feeds a slice of this type into the given [Hasher
]. Read more
impl<'id, P> Debug for Range<'id, P>
[src]
impl<'id> IntoCheckedRange<'id> for Range<'id>
[src]
impl<'id> IntoCheckedRange<'id> for Range<'id, NonEmpty>
[src]
impl<'id, P> IntoIterator for Range<'id, P>
[src]
type Item = Index<'id>
The type of the elements being iterated over.
type IntoIter = RangeIter<'id>
Which kind of iterator are we turning this into?
fn into_iter(self) -> RangeIter<'id>
[src]
Creates an iterator from a value. Read more
impl<'id, P> Provable for Range<'id, P>
[src]
type Proof = P
type WithoutProof = Range<'id, Unknown>
fn no_proof(self) -> Self::WithoutProof
[src]
Return a copy of self with the proof parameter set to Unknown
.