Skip to main content

Mojo struct

Node

struct Node[ElementType: Copyable & ImplicitlyDestructible]

A node in a linked list data structure.

Parameters

Fields

  • value (ElementType): The value stored in this node.

Implemented traits

AnyType, Copyable, ImplicitlyDestructible, Movable

Methods

__init__

__init__(out self, var value: ElementType, prev: Optional[Optional[NonNullUnsafePointer[NoneType, MutExternalOrigin]]], next: Optional[Optional[NonNullUnsafePointer[NoneType, MutExternalOrigin]]])

Initialize a new Node with the given value and optional prev/next pointers.

Args:

  • value (ElementType): The value to store in this node.
  • prev (Optional): Optional pointer to the previous node.
  • next (Optional): Optional pointer to the next node.

write_to

write_to[_ElementType: Copyable & ImplicitlyDestructible & Writable](self: Node[_ElementType], mut writer: T)

Write this node's value to the given writer.

Parameters:

Args:

  • writer (T): The writer to write the value to.

Was this page helpful?