Trait std::iter::RandomAccessIteratorExperimental [-]  [+] [src]

pub trait RandomAccessIterator<A>: Iterator<A> {
    fn indexable(&self) -> uint;
    fn idx(&mut self, index: uint) -> Option<A>;
}

An object implementing random access indexing by uint

A RandomAccessIterator should be either infinite or a DoubleEndedIterator. Calling next() or next_back() on a RandomAccessIterator reduces the indexable range accordingly. That is, it.idx(1) will become it.idx(0) after it.next() is called.

Required Methods

fn indexable(&self) -> uint

Return the number of indexable elements. At most std::uint::MAX elements are indexable, even if the iterator represents a longer range.

fn idx(&mut self, index: uint) -> Option<A>

Return an element at an index, or None if the index is out of bounds

Implementors