Struct indexing::Container [] [src]

pub struct Container<'id, Array> {
    // some fields omitted
}

A branded container, that allows access only to indices and ranges with the exact same brand in the 'id parameter.

Methods

impl<'id, Array, T> Container<'id, Array> where Array: Buffer<Target=[T]>
[src]

fn len(&self) -> usize

fn empty_range(&self) -> Range<'id>

Return the range [0, 0)

fn range(&self) -> Range<'id>

Return the full range of the Container.

fn vet(&self, index: usize) -> Result<Index<'id>, ()>

fn vet_range(&self, r: Range<usize>) -> Result<Range<'id>, ()>

fn split_at(&self, index: Index<'id>) -> (Range<'id>, Range<'id, NonEmpty>)

fn split_after(&self, index: Index<'id>) -> (Range<'id, NonEmpty>, Range<'id>)

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>)

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(&self, index: Index<'id>) -> Range<'id>

Return the range before (not including) the index itself

fn after(&self, index: Index<'id>) -> Range<'id>

Return the range after (not including) the index itself

fn forward(&self, index: &mut Index<'id>) -> bool

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

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>

Increment r, clamping to the end of the Container.

fn backward(&self, index: &mut Index<'id>) -> bool

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

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

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

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: BufferMut<Target=[T]>

Swap elements at i and j (they may be equal).

fn rotate1_up<R>(&mut self, r: R) where Array: BufferMut<Target=[T]>, 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: BufferMut<Target=[T]>, 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])()> where Array: BufferMut<Target=[T]>

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: BufferMut<Target=[T]>

Zip by raw pointer (will be indentical if ranges have same starting point)

Trait Implementations

impl<'id, T, Array> Index<Index<'id>> for Container<'id, Array> where Array: Buffer<Target=[T]>
[src]

&self[i] where i is an Index<'id>.

type Output = T

The returned type after indexing

fn index(&self, index: Index<'id>) -> &T

The method for the indexing (Foo[Bar]) operation

impl<'id, T, Array> IndexMut<Index<'id>> for Container<'id, Array> where Array: BufferMut<Target=[T]>
[src]

&mut self[i] where i is an Index<'id>.

fn index_mut(&mut self, index: Index<'id>) -> &mut T

The method for the indexing (Foo[Bar]) operation

impl<'id, T, Array, P> Index<Range<'id, P>> for Container<'id, Array> where Array: Buffer<Target=[T]>
[src]

&self[r] where r is a Range<'id>.

type Output = [T]

The returned type after indexing

fn index(&self, r: Range<'id, P>) -> &[T]

The method for the indexing (Foo[Bar]) operation

impl<'id, T, Array, P> IndexMut<Range<'id, P>> for Container<'id, Array> where Array: BufferMut<Target=[T]>
[src]

&mut self[r] where r is a Range<'id>.

fn index_mut(&mut self, r: Range<'id, P>) -> &mut [T]

The method for the indexing (Foo[Bar]) operation

impl<'id, T, Array> Index<RangeFrom<Index<'id>>> for Container<'id, Array> where Array: Buffer<Target=[T]>
[src]

&self[i..] where i is an Index<'id>.

type Output = [T]

The returned type after indexing

fn index(&self, r: RangeFrom<Index<'id>>) -> &[T]

The method for the indexing (Foo[Bar]) operation

impl<'id, T, Array> IndexMut<RangeFrom<Index<'id>>> for Container<'id, Array> where Array: BufferMut<Target=[T]>
[src]

&mut self[i..] where i is an Index<'id>.

fn index_mut(&mut self, r: RangeFrom<Index<'id>>) -> &mut [T]

The method for the indexing (Foo[Bar]) operation

impl<'id, T, Array> Index<RangeTo<Index<'id>>> for Container<'id, Array> where Array: Buffer<Target=[T]>
[src]

&self[..i] where i is an Index<'id>.

type Output = [T]

The returned type after indexing

fn index(&self, r: RangeTo<Index<'id>>) -> &[T]

The method for the indexing (Foo[Bar]) operation

impl<'id, T, Array> IndexMut<RangeTo<Index<'id>>> for Container<'id, Array> where Array: BufferMut<Target=[T]>
[src]

&mut self[..i] where i is an Index<'id>.

fn index_mut(&mut self, r: RangeTo<Index<'id>>) -> &mut [T]

The method for the indexing (Foo[Bar]) operation

impl<'id, T, Array> Index<RangeFull> for Container<'id, Array> where Array: Buffer<Target=[T]>
[src]

&self[..]

type Output = [T]

The returned type after indexing

fn index(&self, _: RangeFull) -> &[T]

The method for the indexing (Foo[Bar]) operation

impl<'id, T, Array> IndexMut<RangeFull> for Container<'id, Array> where Array: BufferMut<Target=[T]>
[src]

&mut self[..]

fn index_mut(&mut self, _: RangeFull) -> &mut [T]

The method for the indexing (Foo[Bar]) operation

impl<'id, 'a, T> Index<PIndex<'id, T>> for Container<'id, &'a mut [T]>
[src]

type Output = T

The returned type after indexing

fn index(&self, r: PIndex<'id, T>) -> &T

The method for the indexing (Foo[Bar]) operation

impl<'id, T, Array> Index<RangeTo<PIndex<'id, T>>> for Container<'id, Array> where Array: Buffer<Target=[T]>
[src]

type Output = [T]

The returned type after indexing

fn index(&self, r: RangeTo<PIndex<'id, T>>) -> &[T]

The method for the indexing (Foo[Bar]) operation