Struct tsil_cev::Cursor[][src]

pub struct Cursor<'t, T: 't> { /* fields omitted */ }

Implementations

impl<'t, T: 't> Cursor<'t, T>[src]

pub fn is_none(&self) -> bool[src]

Returns true if cursor pointing on some element.

use tsil_cev::TsilCev;

let mut tc = TsilCev::from(vec![0, 1, 2, 3, 4]);
let mut cursor = tc.cursor_front();

assert_eq!(cursor.is_none(), false);

cursor.move_prev();
assert_eq!(cursor.is_none(), true);

pub fn current(&self) -> Option<&T>[src]

Returns a reference to the element that the cursor is currently pointing or None if cursor empty.

use tsil_cev::TsilCev;

let tc = TsilCev::from(vec![0, 1, 2, 3, 4]);
let cursor = tc.cursor_front();

assert_eq!(cursor.current(), Some(&0));

pub unsafe fn current_unchecked(&self) -> &T[src]

Returns a reference to the element that the cursor is currently pointing and not check if cursor empty.

use tsil_cev::TsilCev;

let tc = TsilCev::from(vec![0, 1, 2, 3, 4]);
let cursor = tc.cursor_front();

assert_eq!(unsafe { cursor.current_unchecked() }, &0);

Safety

This function safe if current not None.

pub fn move_to_start(&mut self) -> &mut Self[src]

Move cursor to front (start) TsilCev.

use tsil_cev::TsilCev;

let tc = TsilCev::from(vec![0, 1, 2, 3, 4]);
let mut cursor = tc.cursor_idx_tsil(3);

assert_eq!(cursor.current(), Some(&3));
cursor.move_to_start();
assert_eq!(cursor.current(), Some(&0));

pub fn move_to_end(&mut self) -> &mut Self[src]

Move cursor to back (end) TsilCev.

use tsil_cev::TsilCev;

let tc = TsilCev::from(vec![0, 1, 2, 3, 4]);
let mut cursor = tc.cursor_idx_tsil(3);

assert_eq!(cursor.current(), Some(&3));
cursor.move_to_end();
assert_eq!(cursor.current(), Some(&4));

pub fn move_next(&mut self) -> &mut Self[src]

Move cursor to next TsilCev element in LinkedList order.

use tsil_cev::TsilCev;

let mut tc = TsilCev::new();
tc.push_back(3);
tc.push_back(4);
tc.push_front(2);
tc.push_front(1);
tc.push_front(0);
let mut cursor = tc.cursor_front();

assert_eq!(cursor.current(), Some(&0));
cursor.move_next();
assert_eq!(cursor.current(), Some(&1));
cursor.move_next();
assert_eq!(cursor.current(), Some(&2));

pub fn move_prev(&mut self) -> &mut Self[src]

Move cursor to prev TsilCev element in LinkedList order.

use tsil_cev::TsilCev;

let mut tc = TsilCev::new();
tc.push_back(3);
tc.push_back(4);
tc.push_front(2);
tc.push_front(1);
tc.push_front(0);
let mut cursor = tc.cursor_back();

assert_eq!(cursor.current(), Some(&4));
cursor.move_prev();
assert_eq!(cursor.current(), Some(&3));
cursor.move_prev();
assert_eq!(cursor.current(), Some(&2));

pub fn move_next_cycle(&mut self) -> &mut Self[src]

Move cursor to next TsilCev element in LinkedList order. If the cursor is empty or back (end) element in TsilCev then this will move to the front (start) element.

use tsil_cev::TsilCev;

let mut tc = TsilCev::from(vec![0, 1, 2, 3, 4]);
let mut cursor = tc.cursor_back();

assert_eq!(cursor.current(), Some(&4));
cursor.move_next_cycle();
assert_eq!(cursor.current(), Some(&0));
cursor.move_next_cycle();
assert_eq!(cursor.current(), Some(&1));

pub fn move_prev_cycle(&mut self) -> &mut Self[src]

Move cursor to prev TsilCev element in LinkedList order. If the cursor is empty or front (start) element in TsilCev then this will move to the back (end) element.

use tsil_cev::TsilCev;

let mut tc = TsilCev::from(vec![0, 1, 2, 3, 4]);
let mut cursor = tc.cursor_front();

assert_eq!(cursor.current(), Some(&0));
cursor.move_prev_cycle();
assert_eq!(cursor.current(), Some(&4));
cursor.move_prev_cycle();
assert_eq!(cursor.current(), Some(&3));

pub unsafe fn move_next_unchecked(&mut self) -> &mut Self[src]

Move cursor to next TsilCev element in LinkedList order not check if cursor is empty.

use tsil_cev::TsilCev;

let mut tc = TsilCev::new();
tc.push_back(3);
tc.push_back(4);
tc.push_front(2);
tc.push_front(1);
tc.push_front(0);
let mut cursor = tc.cursor_front();

assert_eq!(cursor.current(), Some(&0));
unsafe { cursor.move_next_unchecked() };
assert_eq!(cursor.current(), Some(&1));
unsafe { cursor.move_next_unchecked() };
assert_eq!(cursor.current(), Some(&2));

Safety

This function safe if current not None.

pub unsafe fn move_prev_unchecked(&mut self) -> &mut Self[src]

Move cursor to prev TsilCev element in LinkedList order not check if cursor is empty.

use tsil_cev::TsilCev;

let mut tc = TsilCev::new();
tc.push_back(3);
tc.push_back(4);
tc.push_front(2);
tc.push_front(1);
tc.push_front(0);
let mut cursor = tc.cursor_back();

assert_eq!(cursor.current(), Some(&4));
unsafe { cursor.move_prev_unchecked() };
assert_eq!(cursor.current(), Some(&3));
unsafe { cursor.move_prev_unchecked() };
assert_eq!(cursor.current(), Some(&2));

Safety

This function safe if current not None.

pub fn move_next_length(&mut self, mut len: usize) -> &mut Self[src]

Move cursor to next TsilCev elements with lengths in LinkedList order.

use tsil_cev::TsilCev;

let mut tc = TsilCev::new();
tc.push_back(3);
tc.push_back(4);
tc.push_front(2);
tc.push_front(1);
tc.push_front(0);
let mut cursor = tc.cursor_front();

assert_eq!(cursor.current(), Some(&0));
cursor.move_next_length(1);
assert_eq!(cursor.current(), Some(&1));
cursor.move_next_length(3);
assert_eq!(cursor.current(), Some(&4));

pub fn move_prev_length(&mut self, mut len: usize) -> &mut Self[src]

Move cursor to prev TsilCev element with lenght in LinkedList order.

use tsil_cev::TsilCev;

let mut tc = TsilCev::new();
tc.push_back(3);
tc.push_back(4);
tc.push_front(2);
tc.push_front(1);
tc.push_front(0);
let mut cursor = tc.cursor_back();

assert_eq!(cursor.current(), Some(&4));
cursor.move_prev_length(1);
assert_eq!(cursor.current(), Some(&3));
cursor.move_prev_length(3);
assert_eq!(cursor.current(), Some(&0));

pub fn peek_next(&self) -> Option<&T>[src]

Returns a reference to the next element or None if cursor empty or next element not exist.

use tsil_cev::TsilCev;

let tc = TsilCev::from(vec![0, 1, 2, 3, 4]);

assert_eq!(tc.cursor_front().peek_next(), Some(&1));
assert_eq!(tc.cursor_back().peek_next(), None);

pub fn peek_prev(&self) -> Option<&T>[src]

Returns a reference to the prev element or None if cursor empty or prev element not exist.

use tsil_cev::TsilCev;

let tc = TsilCev::from(vec![0, 1, 2, 3, 4]);

assert_eq!(tc.cursor_front().peek_prev(), None);
assert_eq!(tc.cursor_back().peek_prev(), Some(&3));

pub fn peek_next_cycle(&self) -> Option<&T>[src]

Returns a reference to the next element or None if TsilCev empty. If the cursor is empty or back (end) element in TsilCev then this will return the front (start) element.

use tsil_cev::TsilCev;

let tc = TsilCev::from(vec![0, 1, 2, 3, 4]);

assert_eq!(tc.cursor_back().peek_next_cycle(), Some(&0));
assert_eq!(tc.cursor_back().peek_next(), None);

pub fn peek_prev_cycle(&self) -> Option<&T>[src]

Returns a reference to the prev element or None if TsilCev empty. If the cursor is empty or back (end) element in TsilCev then this will return the front (start) element.

use tsil_cev::TsilCev;

let tc = TsilCev::from(vec![0, 1, 2, 3, 4]);

assert_eq!(tc.cursor_front().peek_prev_cycle(), Some(&4));
assert_eq!(tc.cursor_front().peek_prev(), None);

pub fn finish(&mut self) -> Self[src]

Finish combination chain with cursor.

use tsil_cev::TsilCev;

let tc = TsilCev::from(vec![0, 1, 2, 3, 4]);

let mut cursor = tc.cursor_front().move_next_length(3).finish();
assert_eq!(cursor.current(), Some(&3));
cursor.move_next();
assert_eq!(cursor.current(), Some(&4));

Trait Implementations

impl<'t, T: Clone + 't> Clone for Cursor<'t, T>[src]

Auto Trait Implementations

impl<'t, T> Send for Cursor<'t, T> where
    T: Sync
[src]

impl<'t, T> Sync for Cursor<'t, T> where
    T: Sync
[src]

impl<'t, T> Unpin for Cursor<'t, T>[src]

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.