docs/library/collections: Update deque docs to describe new features.
Signed-off-by: Damien George <damien@micropython.org>
This commit is contained in:
parent
c9016b4979
commit
d92dff881c
@ -18,7 +18,9 @@ Classes
|
|||||||
appends and pops from either side of the deque. New deques are created
|
appends and pops from either side of the deque. New deques are created
|
||||||
using the following arguments:
|
using the following arguments:
|
||||||
|
|
||||||
- *iterable* must be the empty tuple, and the new deque is created empty.
|
- *iterable* is an iterable used to populate the deque when it is
|
||||||
|
created. It can be an empty tuple or list to create a deque that
|
||||||
|
is initially empty.
|
||||||
|
|
||||||
- *maxlen* must be specified and the deque will be bounded to this
|
- *maxlen* must be specified and the deque will be bounded to this
|
||||||
maximum length. Once the deque is full, any new items added will
|
maximum length. Once the deque is full, any new items added will
|
||||||
@ -26,18 +28,37 @@ Classes
|
|||||||
|
|
||||||
- The optional *flags* can be 1 to check for overflow when adding items.
|
- The optional *flags* can be 1 to check for overflow when adding items.
|
||||||
|
|
||||||
As well as supporting `bool` and `len`, deque objects have the following
|
Deque objects support `bool`, `len`, iteration and subscript load and store.
|
||||||
methods:
|
They also have the following methods:
|
||||||
|
|
||||||
.. method:: deque.append(x)
|
.. method:: deque.append(x)
|
||||||
|
|
||||||
Add *x* to the right side of the deque.
|
Add *x* to the right side of the deque.
|
||||||
Raises IndexError if overflow checking is enabled and there is no more room left.
|
Raises ``IndexError`` if overflow checking is enabled and there is
|
||||||
|
no more room in the queue.
|
||||||
|
|
||||||
|
.. method:: deque.appendleft(x)
|
||||||
|
|
||||||
|
Add *x* to the left side of the deque.
|
||||||
|
Raises ``IndexError`` if overflow checking is enabled and there is
|
||||||
|
no more room in the queue.
|
||||||
|
|
||||||
|
.. method:: deque.pop()
|
||||||
|
|
||||||
|
Remove and return an item from the right side of the deque.
|
||||||
|
Raises ``IndexError`` if no items are present.
|
||||||
|
|
||||||
.. method:: deque.popleft()
|
.. method:: deque.popleft()
|
||||||
|
|
||||||
Remove and return an item from the left side of the deque.
|
Remove and return an item from the left side of the deque.
|
||||||
Raises IndexError if no items are present.
|
Raises ``IndexError`` if no items are present.
|
||||||
|
|
||||||
|
.. method:: deque.extend(iterable)
|
||||||
|
|
||||||
|
Extend the deque by appending all the items from *iterable* to
|
||||||
|
the right of the deque.
|
||||||
|
Raises ``IndexError`` if overflow checking is enabled and there is
|
||||||
|
no more room in the deque.
|
||||||
|
|
||||||
.. function:: namedtuple(name, fields)
|
.. function:: namedtuple(name, fields)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user