typed_data_structures package¶
Classes¶
Heap¶
- class typed_data_structures.Heap.Heap(items: Optional[Iterable[typed_data_structures.Heap.T]] = None, key: Callable[[typed_data_structures.Heap.T], Any] = <function Heap.<lambda>>)¶
Bases:
Generic
[typed_data_structures.Heap.T
],Collection
[typed_data_structures.Heap.T
]A heap (aka priority queue) data structure.
- Args:
Generic (T): The type of the elements in the heap.
- peek() typed_data_structures.Heap.T ¶
Get the first item from the heap without extracting it.
- Returns:
T: The first item in the heap.
- Raises:
IndexError: If the heap is empty.
- pop() typed_data_structures.Heap.T ¶
Extrace an item from the heap.
- Returns:
T: The item extracted from the heap.
- Raises:
IndexError: If there are no more items in the heap.
- push(item: typed_data_structures.Heap.T, key: Optional[Any] = None)¶
Insert a new item into the heap.
- Args:
item (T): The item to insert. key (Any, optional): Override the key returned by the key function provided in the constructor.
Queue¶
- class typed_data_structures.Queue.Queue(items: Iterable[typed_data_structures.Queue.T] = ())¶
Bases:
Generic
[typed_data_structures.Queue.T
],Container
[typed_data_structures.Queue.T
],Reversible
[typed_data_structures.Queue.T
]A collection of items which can be accessed in a FIFO order.
- Args:
Generic (T): The type of the items stored in the queue.
- pop() typed_data_structures.Queue.T ¶
Pop an item from the front of the queue.
- Returns:
T: The frontmost item that was removed from the queue.
- Raises:
IndexError: If the queue was empty.
- push(value: typed_data_structures.Queue.T)¶
Push an item to the back of the queue.
- Args:
value (T): The item to push to the back of the queue.
Stack¶
- class typed_data_structures.Stack.Stack(items: Iterable[typed_data_structures.Stack.T] = ())¶
Bases:
Generic
[typed_data_structures.Stack.T
],Reversible
[typed_data_structures.Stack.T
],Collection
[typed_data_structures.Stack.T
]A collection of items which can be accessed in a LIFO order.
- Args:
Generic (T): The type of the items stored in the stack.
- pop() typed_data_structures.Stack.T ¶
Pop an item from the top of the stack.
- Returns:
T: The topmost item that was removed from the stack.
- Raises:
IndexError: If the stack was empty.
- push(value: typed_data_structures.Stack.T)¶
Push an item onto the stack.
- Args:
value (T): The item to push onto the stack.