module splitend_node¶
Class SENode¶
Used to make inwardly directed bush-like graphs.
designed so multiple splitends can safely share the same data
nodes always contain data
data node
SENode[D]make up end-to-root singularly linked lists- two nodes compare as equal if
both their previous Nodes are the same
their data compare as equal
- a root node is a node whose previous node is itself
root nodes mark the bottom of splitend stacks
- more than one node can point to the same proceeding node
forming bush like graphs
- class pythonic_fp.splitends.splitend_node.SENode(data: D, prev: ~typing.Self | _Sentinel = Sentinel(''_split_end_node_private_str''))¶
- Parameters:
data – Nodes always contain data of type
D.prev – Link to previous node. Points to
selfif a root node.
- both() tuple[D, Self]¶
Peak at data and previous node, if a root then data and self.
- Returns:
tuple of type tuple[D, SENode[D]]
- data() D¶
Peak at data.
- Returns:
The data stored in the
SENode.
- fold(f: Callable[[D, D], D]) D¶
- fold(f: Callable[[T, D], T], init: T) T
Fold data across linked nodes with a function..
- Parameters:
f – Folding function, first argument is for accumulated value.`
init – Optional initial starting value for the fold.
- Returns:
Reduced value folded from end to root in natural LIFO order.
- prev() Self¶
Peak at previous node.
- Returns:
The previous node stored in the
SENode.
- push(data: D) Self¶
Create a new
SENode[D].- Parameters:
data – Data for new node to contain.
- Returns:
New
SENodewhose previous node is the current node.