Nodes

class data_structures.linked_list.Node(value: Any, next_: Optional[data_structures.linked_list.Node] = None)

The most simple Node class, only contains value and next properties, and there is no any security mechanism for node properties modification

Any enhanced Node class should inherit this class

Parameters
  • value (Any) –

  • next (Optional[Node]) –

abstract classmethod after_node(value: Any, node: data_structures.linked_list.Node) → data_structures.linked_list.Node

Create a node with the given value, and after the given node

Parameters
  • value (Any) – The value that the node contains

  • node (Node) – The node which next points to this node

Returns

The node created

Return type

Node

class data_structures.linked_list.nodes.SinglyNode(value: Any, next_: Optional[data_structures.linked_list.Node] = None)

The most simple SinglyNode class, only contains value and next properties, and there is no any security mechanism for node properties modification

Any enhanced SinglyNode class should inherit this class

Parameters
  • value (Any) –

  • next (Optional[Node]) –

classmethod after_node(value: Any, node: data_structures.linked_list.nodes.SinglyNode) → data_structures.linked_list.nodes.SinglyNode

Create a node with the given value, and after the given node

Parameters
  • value (Any) – The value that the node contains

  • node (SinglyNode) – The node which next points to this node

Returns

The node created

Return type

SinglyNode

class data_structures.linked_list.nodes.SecureSinglyNode(value: Any, next_: Optional[data_structures.linked_list.nodes.SecureSinglyNode] = None, frozen: bool = True)

A node with secure mechanism - when it is frozen, the value and next cannot be changed

Initial a node with secure mechanism, and as default the node is frozen to change after initialized

Parameters
  • value (Any) –

  • next (Optional[Node]) –

  • frozen (bool) –

classmethod after_node(value: Any, node: data_structures.linked_list.nodes.SecureSinglyNode, frozen: bool = True) → data_structures.linked_list.nodes.SecureSinglyNode

Create a node with the given value, and after the given node

Parameters
  • value (Any) – The value that the node contains

  • node (SinglyNode) – The node which next points to this node

  • frozen (bool) –

Returns

The node created

Return type

SinglyNode

freeze() → None

Freeze this node - the value and next cannot be changed

Returns

Return type

None

unfreeze() → None

Unfreeze this node - the value and next can be changed

Returns

Return type

None

property next
Returns

Return type

Optional[SecureSinglyNode]

property value
Returns

Return type

Any

class data_structures.linked_list.nodes.DoublyNode(value: Any, previous: Optional[data_structures.linked_list.nodes.DoublyNode] = None, next_: Optional[data_structures.linked_list.nodes.DoublyNode] = None)

The most simple DoublyNode class, only contains value and next properties, and there is no any security mechanism for node properties modification

Any enhanced DoublyNode class should inherit this class

Create a node with the given value, previous and next nodes

Parameters
classmethod after_node(value: Any, node: data_structures.linked_list.nodes.DoublyNode) → data_structures.linked_list.nodes.DoublyNode

Create a node with the given value, and after the given node

Parameters
  • value (Any) – The value that the node contains

  • node (DoublyNode) – The node which next points to this node

Returns

The node created

Return type

DoublyNode