Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from copy import copy
- class Queue:
- def __init__(self, *values):
- self.q = list(values)
- def __str__(self):
- q = ' -> '.join(map(str, self.q))
- return f'[{q}]'
- def __next__(self):
- n = self.q[1:]
- return Queue(*n)
- def __eq__(self, other):
- return self.q[:] == other.q[:]
- def __add__(self, other):
- return copy(Queue(*(self.q + other.q)))
- def __rshift__(self, other):
- n = self.q[other:]
- return Queue(*n)
- def __iadd__(self, other):
- return Queue(*(self.q + other.q))
- def extend(self, queue):
- self.q.extend(queue.q)
- def append(self, *values):
- self.q += list(values)
- def copy(self):
- return Queue(*self.q)
- def pop(self):
- return self.q.pop(0)
- def next(self):
- n = self.q[1:]
- return Queue(*n)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement