1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
use num_traits::one;

use crate::LinkedList;
use crate::Num;

pub trait RelativeLinkedList<T: Num>: LinkedList<T> {
    fn get_first(&self, head: T) -> T;
    fn get_last(&self, head: T) -> T;
    fn get_size(&self, head: T) -> T;

    fn set_first(&mut self, head: T, element: T);
    fn set_last(&mut self, head: T, element: T);
    fn set_size(&mut self, head: T, size: T);

    fn inc_size(&mut self, head: T) {
        self.set_size(head, self.get_size(head) + one())
    }
    fn dec_size(&mut self, head: T) {
        self.set_size(head, self.get_size(head) - one())
    }
}