Data structures

Table of contents

  1. Module container.deque — double-ended queues
  2. Module copylib — construction of deep copies

Module container.deque

Double-ended queues allow for appendage and removal of elements at the beginning and end in O(1) time complexity.

Deque
Data type of double-ended queues.
deque(), deque(a), a: List
Constructor of double-ended queues.

Type Deque, d: Deque

d.push(x)
Append an element to the end.
d.pop()
Remove the last element and return it. Raises an exception if empty.
d.shift(x)
Append an element to the beginning.
d.unshift()
Remove the first element and return it. Raises an exception if empty.

Module copylib

Functions that create deep copies of trees and dags.

deep_copy_tree(x)
Create a deep copy of x as a new tree.
deep_copy_dag(x)
Create a deep copy of x as a new directed acyclic graph.