Mojo struct
Node
struct Node[ElementType: ExplicitlyCopyable & Movable]
A node in a linked list data structure.
Parameters
- ElementType (
ExplicitlyCopyable
&Movable
): The type of element stored in the node.
Fields
- value (
ElementType
): The value stored in this node. - prev (
UnsafePointer[Node[ElementType]]
): The previous node in the list. - next (
UnsafePointer[Node[ElementType]]
): The next node in the list.
Implemented traits
AnyType
,
Copyable
,
ExplicitlyCopyable
,
Movable
,
UnknownDestructibility
Aliases
__copyinit__is_trivial
alias __copyinit__is_trivial = False
__del__is_trivial
alias __del__is_trivial = get_witness(ElementType, stdlib::builtin::anytype::AnyType, __del__is_trivial)
__moveinit__is_trivial
alias __moveinit__is_trivial = get_witness(ElementType, stdlib::builtin::value::Movable, __moveinit__is_trivial)
Methods
__init__
__init__(out self, var value: ElementType, prev: Optional[UnsafePointer[Node[ElementType]]], next: Optional[UnsafePointer[Node[ElementType]]])
Initialize a new Node with the given value and optional prev/next pointers.
Args:
__copyinit__
__copyinit__(out self, existing: Self)
Creates a copy of the given node.
Args:
- existing (
Self
): The node to copy.
__str__
__str__[ElementType: ExplicitlyCopyable & Movable & Writable](self: Node[ElementType]) -> String
Convert this node's value to a string representation.
Parameters:
- ElementType (
ExplicitlyCopyable
&Movable
&Writable
): Used to conditionally enable this function ifElementType
isWritable
.
Returns:
String
: String representation of the node's value.
write_to
write_to[ElementType: ExplicitlyCopyable & Movable & Writable, W: Writer](self: Node[ElementType], mut writer: W)
Write this node's value to the given writer.
Parameters:
- ElementType (
ExplicitlyCopyable
&Movable
&Writable
): Used to conditionally enable this function ifElementType
isWritable
. - W (
Writer
): The type of writer to write the value to.
Args:
- writer (
W
): The writer to write the value to.
Was this page helpful?
Thank you! We'll create more content like this.
Thank you for helping us improve!