pub struct LList<T: Clone> { /* private fields */ }Expand description
This LList structure provides a simple interface for creating and manipulating cons cells in a linked lst fashion. It utilizes a bump allocator to allocate memory for cons cells avoiding the overhead of system memory allocation.
Implementations§
Source§impl<T: Clone> LList<T>
impl<T: Clone> LList<T>
Sourcepub fn cons<'a>(&self, content: T, cons_ref: &ConsRef<'a, T>) -> ConsRef<'a, T>
pub fn cons<'a>(&self, content: T, cons_ref: &ConsRef<'a, T>) -> ConsRef<'a, T>
Creates a new cons cell with the provided content and cdr reference.
This function allocates memory for a new cons cell using the internal bump allocator. It sets the car of the cons cell to the provided content and the cdr.
Arguments:
- content: The data to be stored in the car of the new cons cell.
- cons_ref: A reference to the cons cell that should be linked as the cdr.
Returns: A ConsRef representing the reference of newly created cons cell.
Sourcepub fn cons_ptr<'a>(
&self,
content_ptr: *mut T,
cons_ref: &ConsRef<'a, T>,
) -> ConsRef<'a, T>
pub fn cons_ptr<'a>( &self, content_ptr: *mut T, cons_ref: &ConsRef<'a, T>, ) -> ConsRef<'a, T>
Creates a new cons cell with a pointer to content and cdr reference.
Sourcepub fn nil(&self) -> ConsRef<'_, T>
pub fn nil(&self) -> ConsRef<'_, T>
Creates a ConsRef representing an empty list (nil).
This function returns a ConsRef with a null pointer indicating the end of the list.
Returns: A ConsRef representing an empty list