data_structures.stacks.stack_with_doubly_linked_list

Attributes

T

stack

Classes

Node

Stack

Module Contents

class data_structures.stacks.stack_with_doubly_linked_list.Node(data: T)

Bases: Generic[T]

data
next: Node[T] | None = None
prev: Node[T] | None = None
class data_structures.stacks.stack_with_doubly_linked_list.Stack

Bases: Generic[T]

>>> stack = Stack()
>>> stack.is_empty()
True
>>> stack.print_stack()
stack elements are:
>>> for i in range(4):
...     stack.push(i)
...
>>> stack.is_empty()
False
>>> stack.print_stack()
stack elements are:
3->2->1->0->
>>> stack.top()
3
>>> len(stack)
4
>>> stack.pop()
3
>>> stack.print_stack()
stack elements are:
2->1->0->
__len__() int
is_empty() bool
pop() T | None

pop the top element off the stack

print_stack() None
push(data: T) None

add a Node to the stack

top() T | None

return the top element of the stack

head: Node[T] | None = None
data_structures.stacks.stack_with_doubly_linked_list.T
data_structures.stacks.stack_with_doubly_linked_list.stack: Stack[int]