Struct indexing::container::Container
[−]
[src]
pub struct Container<'id, Array, Mode = ()> { /* fields omitted */ }
A branded container, that allows access only to indices and ranges with
the exact same brand in the 'id
parameter.
The elements in the underlying data structure are accessible partly through special purpose methods, and through indexing/slicing.
The Container
can be indexed like self[i]
where i
is a trusted
dereferenceable index
or range, and equivalently using &self[i..]
or &self[..i]
where
i
is a trusted index. Indexing like this uses no runtime bounds checking
at all, and it statically guaranteed to be in bounds.
The container can also be sliced for its complete range: &self[..]
.
Methods
impl<'id, Array, T, Mode> Container<'id, Array, Mode> where
Array: Trustworthy<Item = T>,
[src]
Array: Trustworthy<Item = T>,
fn len(&self) -> usize
[src]
fn only_index(self) -> Container<'id, Array, OnlyIndex>
[src]
Convert the container into an only-indexing container.
The container no longer allows pointer access. This unlocks some features.
fn empty_range(&self) -> Range<'id>
[src]
Return the range [0, 0)
fn range(&self) -> Range<'id>
[src]
Return the full range of the Container.
fn vet(&self, index: usize) -> Result<Index<'id>, IndexingError>
[src]
Vet the absolute index
.
fn vet_range(&self, r: Range<usize>) -> Result<Range<'id>, IndexingError>
[src]
Vet the range r
.
fn split_at<P>(&self, index: Index<'id, P>) -> (Range<'id>, Range<'id, P>)
[src]
fn split_after(&self, index: Index<'id>) -> (Range<'id, NonEmpty>, Range<'id>)
[src]
Split in two ranges, where the first includes the index
and the second
starts with the following index.
fn split_around<P>(&self, r: Range<'id, P>) -> (Range<'id>, Range<'id>)
[src]
Split around the Range r
: Return ranges corresponding to 0..r.start
and r.end..
.
So that input r
and return values (s, t)
cover the whole container
in the order s
, r
, t
.
fn before<P>(&self, index: Index<'id, P>) -> Range<'id>
[src]
Return the range before (not including) the index itself
fn after(&self, index: Index<'id>) -> Range<'id>
[src]
Return the range after (not including) the index itself
fn range_of<P, R>(&self, r: R) -> Range<'id> where
R: OnePointRange<Index<'id, P>>,
[src]
R: OnePointRange<Index<'id, P>>,
fn forward(&self, index: &mut Index<'id>) -> bool
[src]
Increment index
, if doing so would still be in bounds.
Return true
if the index was incremented.
fn forward_by(&self, index: &mut Index<'id>, offset: usize) -> bool
[src]
Increment index
, if doing so would still be in bounds.
Return true
if the index was incremented.
fn forward_range_by<P>(&self, r: Range<'id, P>, offset: usize) -> Range<'id>
[src]
Increment r
, clamping to the end of the Container.
fn backward(&self, index: &mut Index<'id>) -> bool
[src]
Decrement index
, if doing so would still be in bounds.
Return true
if the index was decremented.
fn scan_from<'b, F>(&'b self, index: Index<'id>, f: F) -> Range<'id, NonEmpty> where
F: FnMut(&'b T) -> bool,
T: 'b,
Array: Contiguous<Item = T>,
[src]
F: FnMut(&'b T) -> bool,
T: 'b,
Array: Contiguous<Item = T>,
Examine the elements after index
in order from lower indices towards higher.
While the closure returns true
, continue scan and include the scanned
element in the range.
Result always includes index
in the range
fn scan_from_rev<'b, F>(
&'b self,
index: Index<'id>,
f: F
) -> Range<'id, NonEmpty> where
F: FnMut(&'b T) -> bool,
T: 'b,
Array: Contiguous<Item = T>,
[src]
&'b self,
index: Index<'id>,
f: F
) -> Range<'id, NonEmpty> where
F: FnMut(&'b T) -> bool,
T: 'b,
Array: Contiguous<Item = T>,
Examine the elements before index
in order from higher indices towards lower.
While the closure returns true
, continue scan and include the scanned
element in the range.
Result always includes index
in the range.
fn scan_range<'b, F, P>(
&'b self,
range: Range<'id, P>,
f: F
) -> (Range<'id>, Range<'id>) where
F: FnMut(&'b T) -> bool,
T: 'b,
Array: Contiguous<Item = T>,
[src]
&'b self,
range: Range<'id, P>,
f: F
) -> (Range<'id>, Range<'id>) where
F: FnMut(&'b T) -> bool,
T: 'b,
Array: Contiguous<Item = T>,
Examine the elements range
in order from lower indices towards higher.
While the closure returns true
, continue scan and include the scanned
element in the range.
fn swap(&mut self, i: Index<'id>, j: Index<'id>) where
Array: GetUncheckedMut,
[src]
Array: GetUncheckedMut,
Swap elements at i
and j
(they may be equal).
fn rotate1_up<R>(&mut self, r: R) where
Array: Contiguous + GetUncheckedMut,
R: IntoCheckedRange<'id>,
[src]
Array: Contiguous + GetUncheckedMut,
R: IntoCheckedRange<'id>,
Rotate elements in the range r
by one step to the right (towards higher indices)
fn rotate1_down<R>(&mut self, r: R) where
Array: Contiguous + GetUncheckedMut,
R: IntoCheckedRange<'id>,
[src]
Array: Contiguous + GetUncheckedMut,
R: IntoCheckedRange<'id>,
Rotate elements in the range r
by one step to the left (towards lower indices)
fn index_twice<P, Q>(
&mut self,
r: Range<'id, P>,
s: Range<'id, Q>
) -> Result<(&mut [T], &mut [T]), IndexingError> where
Array: ContiguousMut,
[src]
&mut self,
r: Range<'id, P>,
s: Range<'id, Q>
) -> Result<(&mut [T], &mut [T]), IndexingError> where
Array: ContiguousMut,
Index by two nonoverlapping ranges, where r
is before s
.
fn zip_mut_raw<P, Q, F>(&mut self, r: Range<'id, P>, s: Range<'id, Q>, f: F) where
F: FnMut(*mut T, *mut T),
Array: GetUncheckedMut,
[src]
F: FnMut(*mut T, *mut T),
Array: GetUncheckedMut,
Zip by raw pointer (will be indentical if ranges have same starting point)
impl<'id, Array, T> Container<'id, Array, OnlyIndex> where
Array: Pushable<Item = T>,
[src]
Array: Pushable<Item = T>,
Methods specific to only index mode
fn push(&mut self, element: T) -> Index<'id>
[src]
Add one element to the underlying storage, and return its index.
All outstanding indices remain valid, only the length of the container is now larger.
fn insert<Q>(&mut self, index: Index<'id, Q>, element: T)
[src]
Insert one element in the underlying storage at index
.
All outstanding indices remain valid (in bounds), but elements have shifted.
impl<'id, T, Array> Container<'id, Array> where
Array: Contiguous<Item = T>,
[src]
Array: Contiguous<Item = T>,
fn pointer_range(&self) -> PRange<'id, T>
[src]
fn pointer_slice(&self) -> PSlice<'id, T>
[src]
fn pointer_range_of<P, R>(&self, r: R) -> PRange<'id, T> where
R: OnePointRange<PIndex<'id, T, P>>,
[src]
R: OnePointRange<PIndex<'id, T, P>>,
fn nonempty_range<P, Q>(
&self,
a: PIndex<'id, T, P>,
b: PIndex<'id, T, Q>
) -> Result<PRange<'id, T, NonEmpty>, IndexingError>
[src]
&self,
a: PIndex<'id, T, P>,
b: PIndex<'id, T, Q>
) -> Result<PRange<'id, T, NonEmpty>, IndexingError>
fn distance_to<P>(&self, ptr: PIndex<'id, T, P>) -> usize
[src]
Return the distance (in number of elements) from the start of the container to the pointer.
fn scan_tail_<P, F>(&self, index: PIndex<'id, T, P>, f: F) -> PRange<'id, T, P> where
F: FnMut(&T) -> bool,
[src]
F: FnMut(&T) -> bool,
Examine the elements before index
in order from higher indices towards lower.
While the closure returns true
, continue scan and include the scanned
element in the range.
Result always includes index
in the range
fn scan_pointer_range<'b, F, P>(
&'b self,
range: PRange<'id, T, P>,
f: F
) -> (PRange<'id, T>, PRange<'id, T>) where
F: FnMut(&'b T) -> bool,
T: 'b,
[src]
&'b self,
range: PRange<'id, T, P>,
f: F
) -> (PRange<'id, T>, PRange<'id, T>) where
F: FnMut(&'b T) -> bool,
T: 'b,
Examine the elements range
in order from lower towards higher.
While the closure returns true
, continue scan and include the scanned
element in the range.
fn split_at_pointer<P>(
&self,
index: PIndex<'id, T, P>
) -> (PRange<'id, T>, PRange<'id, T, P>)
[src]
&self,
index: PIndex<'id, T, P>
) -> (PRange<'id, T>, PRange<'id, T, P>)
fn scan_pointer_range_rev<'b, F, P>(
&'b self,
range: PRange<'id, T, P>,
f: F
) -> (PRange<'id, T>, PRange<'id, T>) where
F: FnMut(&'b T) -> bool,
T: 'b,
[src]
&'b self,
range: PRange<'id, T, P>,
f: F
) -> (PRange<'id, T>, PRange<'id, T>) where
F: FnMut(&'b T) -> bool,
T: 'b,
Examine the elements range
in order from higher towards lower
While the closure returns true
, continue scan and include the scanned
element in the range.
impl<'id, T, Array> Container<'id, Array> where
Array: Contiguous<Item = T>,
[src]
Array: Contiguous<Item = T>,
fn split_container_at_pointer<P, F, Out>(
&mut self,
index: PIndex<'id, T, P>,
f: F
) -> Out where
F: for<'id1, 'id2> FnOnce(Container<'id1, &mut [T]>, PRange<'id1, T>, Container<'id2, &mut [T]>, PRange<'id2, T, P>) -> Out,
[src]
&mut self,
index: PIndex<'id, T, P>,
f: F
) -> Out where
F: for<'id1, 'id2> FnOnce(Container<'id1, &mut [T]>, PRange<'id1, T>, Container<'id2, &mut [T]>, PRange<'id2, T, P>) -> Out,
impl<'id, T, Array> Container<'id, Array> where
Array: ContiguousMut<Item = T>,
[src]
Array: ContiguousMut<Item = T>,
fn rotate1_prange(&mut self, r: PRange<'id, T, NonEmpty>)
[src]
Rotate elements in the range by one step to the right (towards higher indices)
fn swap_ptr(&mut self, i: PIndex<'id, T>, j: PIndex<'id, T>)
[src]
Swap elements at i
and j
(they may be equal).
Trait Implementations
impl<'id, Array, Mode> Debug for Container<'id, Array, Mode> where
Array: Debug,
[src]
Array: Debug,
impl<'id, Array, Mode> Clone for Container<'id, Array, Mode> where
Array: Clone,
[src]
Array: Clone,
fn clone(&self) -> Self
[src]
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl<'id, Array, M> Index<Index<'id>> for Container<'id, Array, M> where
Array: GetUnchecked,
[src]
Array: GetUnchecked,
&self[i]
where i
is an Index<'id>
.
type Output = Array::Item
The returned type after indexing.
fn index(&self, index: Index<'id>) -> &Self::Output
[src]
Performs the indexing (container[index]
) operation.
impl<'id, Array, M> IndexMut<Index<'id>> for Container<'id, Array, M> where
Array: GetUncheckedMut,
[src]
Array: GetUncheckedMut,
&mut self[i]
where i
is an Index<'id>
.
fn index_mut(&mut self, index: Index<'id>) -> &mut Self::Output
[src]
Performs the mutable indexing (container[index]
) operation.
impl<'id, T, Array, P, M> Index<Range<'id, P>> for Container<'id, Array, M> where
Array: Contiguous<Item = T>,
[src]
Array: Contiguous<Item = T>,
&self[r]
where r
is a Range<'id>
.
type Output = [T]
The returned type after indexing.
fn index(&self, r: Range<'id, P>) -> &Self::Output
[src]
Performs the indexing (container[index]
) operation.
impl<'id, Array, P, M> IndexMut<Range<'id, P>> for Container<'id, Array, M> where
Array: ContiguousMut,
[src]
Array: ContiguousMut,
&mut self[r]
where r
is a Range<'id>
.
fn index_mut(&mut self, r: Range<'id, P>) -> &mut Self::Output
[src]
Performs the mutable indexing (container[index]
) operation.
impl<'id, T, P, Array, M> Index<RangeFrom<Index<'id, P>>> for Container<'id, Array, M> where
Array: Contiguous<Item = T>,
[src]
Array: Contiguous<Item = T>,
&self[i..]
where i
is an Index<'id, P>
which may be an edge index.
type Output = [T]
The returned type after indexing.
fn index(&self, r: RangeFrom<Index<'id, P>>) -> &[T]
[src]
Performs the indexing (container[index]
) operation.
impl<'id, T, P, Array, M> IndexMut<RangeFrom<Index<'id, P>>> for Container<'id, Array, M> where
Array: ContiguousMut<Item = T>,
[src]
Array: ContiguousMut<Item = T>,
&mut self[i..]
where i
is an Index<'id, P>
which may be an edge index.
fn index_mut(&mut self, r: RangeFrom<Index<'id, P>>) -> &mut [T]
[src]
Performs the mutable indexing (container[index]
) operation.
impl<'id, T, P, Array, M> Index<RangeTo<Index<'id, P>>> for Container<'id, Array, M> where
Array: Contiguous<Item = T>,
[src]
Array: Contiguous<Item = T>,
&self[..i]
where i
is an Index<'id, P>
, which may be an edge index.
type Output = [T]
The returned type after indexing.
fn index(&self, r: RangeTo<Index<'id, P>>) -> &[T]
[src]
Performs the indexing (container[index]
) operation.
impl<'id, T, P, Array, M> IndexMut<RangeTo<Index<'id, P>>> for Container<'id, Array, M> where
Array: ContiguousMut<Item = T>,
[src]
Array: ContiguousMut<Item = T>,
&mut self[..i]
where i
is an Index<'id, P>
, which may be an edge index.
fn index_mut(&mut self, r: RangeTo<Index<'id, P>>) -> &mut [T]
[src]
Performs the mutable indexing (container[index]
) operation.
impl<'id, T, Array, M> Index<RangeFull> for Container<'id, Array, M> where
Array: Contiguous<Item = T>,
[src]
Array: Contiguous<Item = T>,
&self[..]
type Output = [T]
The returned type after indexing.
fn index(&self, _: RangeFull) -> &[T]
[src]
Performs the indexing (container[index]
) operation.
impl<'id, T, Array> IndexMut<RangeFull> for Container<'id, Array> where
Array: ContiguousMut<Item = T>,
[src]
Array: ContiguousMut<Item = T>,
&mut self[..]
fn index_mut(&mut self, _: RangeFull) -> &mut [T]
[src]
Performs the mutable indexing (container[index]
) operation.
impl<'id, 'a, Array, T: 'a> ContainerRef<'id> for &'a Container<'id, Array> where
Array: Contiguous<Item = T>,
[src]
Array: Contiguous<Item = T>,
impl<'id, 'a, Array, T: 'a> ContainerRef<'id> for &'a mut Container<'id, Array> where
Array: ContiguousMut<Item = T>,
[src]
Array: ContiguousMut<Item = T>,
impl<'id, T, Array, P> Index<PRange<'id, T, P>> for Container<'id, Array> where
Array: Contiguous<Item = T>,
[src]
Array: Contiguous<Item = T>,
&self[r]
where r
is a PRange<'id>
.
type Output = [T]
The returned type after indexing.
fn index(&self, r: PRange<'id, T, P>) -> &[T]
[src]
Performs the indexing (container[index]
) operation.
impl<'id, T, Array, P> IndexMut<PRange<'id, T, P>> for Container<'id, Array> where
Array: ContiguousMut<Item = T>,
[src]
Array: ContiguousMut<Item = T>,
&mut self[r]
where r
is a Range<'id>
.
fn index_mut(&mut self, r: PRange<'id, T, P>) -> &mut [T]
[src]
Performs the mutable indexing (container[index]
) operation.
impl<'id, 'a, T, Array> Index<PIndex<'id, T>> for Container<'id, Array> where
Array: Contiguous<Item = T>,
[src]
Array: Contiguous<Item = T>,
type Output = T
The returned type after indexing.
fn index(&self, r: PIndex<'id, T>) -> &T
[src]
Performs the indexing (container[index]
) operation.
impl<'id, T, P, Array> Index<RangeTo<PIndex<'id, T, P>>> for Container<'id, Array> where
Array: Contiguous<Item = T>,
[src]
Array: Contiguous<Item = T>,
type Output = [T]
The returned type after indexing.
fn index(&self, r: RangeTo<PIndex<'id, T, P>>) -> &[T]
[src]
Performs the indexing (container[index]
) operation.
impl<'id, T, P, Array> IndexMut<RangeTo<PIndex<'id, T, P>>> for Container<'id, Array> where
Array: ContiguousMut<Item = T>,
[src]
Array: ContiguousMut<Item = T>,
fn index_mut(&mut self, r: RangeTo<PIndex<'id, T, P>>) -> &mut [T]
[src]
Performs the mutable indexing (container[index]
) operation.
impl<'id, T, P, Array> Index<RangeFrom<PIndex<'id, T, P>>> for Container<'id, Array> where
Array: Contiguous<Item = T>,
[src]
Array: Contiguous<Item = T>,
type Output = [T]
The returned type after indexing.
fn index(&self, r: RangeFrom<PIndex<'id, T, P>>) -> &[T]
[src]
Performs the indexing (container[index]
) operation.
impl<'id, T, P, Array> IndexMut<RangeFrom<PIndex<'id, T, P>>> for Container<'id, Array> where
Array: ContiguousMut<Item = T>,
[src]
Array: ContiguousMut<Item = T>,