[][src]Trait toodee::TooDeeOps

pub trait TooDeeOps<T>: Index<usize, Output = [T]> + Index<Coordinate, Output = T> {
    fn num_cols(&self) -> usize;
fn num_rows(&self) -> usize;
fn bounds(&self) -> (Coordinate, Coordinate);
fn view(&self, start: Coordinate, end: Coordinate) -> TooDeeView<T>;
fn rows(&self) -> Rows<T>;
fn col(&self, col: usize) -> Col<T>; fn size(&self) -> (usize, usize) { ... }
fn is_empty(&self) -> bool { ... }
fn cells(&self) -> Cells<T> { ... } }

Defines operations common to both TooDee and TooDeeView. Default implementations are provided where possible/practical.

Required methods

fn num_cols(&self) -> usize

The number of columns in the area represented by this object.

fn num_rows(&self) -> usize

The number of rows in the area represented by this object.

fn bounds(&self) -> (Coordinate, Coordinate)

Returns the bounds of the object's area within the original TooDee area (views are not nested for now).

fn view(&self, start: Coordinate, end: Coordinate) -> TooDeeView<T>

Returns a view (or subset) of the current area based on the coordinates provided.

fn rows(&self) -> Rows<T>

Returns an iterator of slices, where each slice represents the entire row of the object's area.

fn col(&self, col: usize) -> Col<T>

Returns an iterator over a single column

Loading content...

Provided methods

fn size(&self) -> (usize, usize)

Returns the size/dimensions of the current object.

fn is_empty(&self) -> bool

Returns true if the array contains no elements.

fn cells(&self) -> Cells<T>

Returns an iterator that traverses all cells within the area.

Loading content...

Implementors

impl<'a, T> TooDeeOps<T> for TooDeeView<'a, T>[src]

impl<'a, T> TooDeeOps<T> for TooDeeViewMut<'a, T>[src]

impl<T> TooDeeOps<T> for TooDee<T>[src]

fn num_cols(&self) -> usize[src]

Examples

use toodee::{TooDee,TooDeeOps,TooDeeOpsMut};
let toodee : TooDee<u32> = TooDee::new(10, 5);
assert_eq!(toodee.num_cols(), 10);

fn num_rows(&self) -> usize[src]

Examples

use toodee::{TooDee,TooDeeOps,TooDeeOpsMut};
let toodee : TooDee<u32> = TooDee::new(10, 5);
assert_eq!(toodee.num_rows(), 5);

fn bounds(&self) -> (Coordinate, Coordinate)[src]

Examples

use toodee::{TooDee,TooDeeOps};
let toodee : TooDee<u32> = TooDee::new(10, 5);
assert_eq!(toodee.bounds(), ((0, 0), (10, 5)));

fn view(&self, start: Coordinate, end: Coordinate) -> TooDeeView<T>[src]

Examples

use toodee::{TooDee,TooDeeOps};
let toodee : TooDee<u32> = TooDee::new(10, 5);
let view = toodee.view((1,2), (8,4));
assert_eq!(view.num_cols(), 7);
assert_eq!(view.num_rows(), 2);

fn rows(&self) -> Rows<T>[src]

Examples

use toodee::{TooDee,TooDeeOps,TooDeeOpsMut};
let mut toodee : TooDee<u32> = TooDee::new(10, 5);
let mut rows = toodee.rows();
assert_eq!(rows.len(), 5);
let r0 = rows.next().unwrap();
assert_eq!(r0.len(), 10);

fn col(&self, col: usize) -> Col<T>[src]

Examples

use toodee::{TooDee,TooDeeOps,TooDeeOpsMut};
let mut toodee : TooDee<u32> = TooDee::new(10, 5);
let mut col = toodee.col(8);
assert_eq!(col.len(), 5);
Loading content...