#[repr(C)]pub struct ArrayLinkedList<const LEN: usize> {
array: [ArrayLinkNode; LEN],
head: Option<usize>,
tail: Option<usize>,
}Expand description
The list itself. Maintain a head and tail and the node array.
§Generic
The const LEN means the node count. It should be specified at the compile
time.
§Invariant
Both head and tail shall be None together or not be None
together.
See Also: ArrayLinkNode
Fields§
§array: [ArrayLinkNode; LEN]The array storing the linking field of each nodes.
head: Option<usize>The index of the first node. None means an empty node.
tail: Option<usize>The index of the last node. None means an empty node.
Implementations§
Source§impl<const LEN: usize> ArrayLinkedList<LEN>
impl<const LEN: usize> ArrayLinkedList<LEN>
Sourcepub fn insert_head(&mut self, item: usize)
pub fn insert_head(&mut self, item: usize)
Insert the index item node into the head.
Sourcepub fn pop_head(&mut self) -> Option<usize>
pub fn pop_head(&mut self) -> Option<usize>
Get the first node. And remove it from the list if the list is not empty.
Sourcepub fn insert_tail(&mut self, item: usize)
pub fn insert_tail(&mut self, item: usize)
Insert the index item node into the tail.