summaryrefslogtreecommitdiff
path: root/docs/library
diff options
context:
space:
mode:
authorDamien George <damien@micropython.org>2024-03-18 22:42:33 +1100
committerDamien George <damien@micropython.org>2024-03-19 10:09:11 +1100
commitd92dff881ca99281893b1d77eee4bf2eca25d0c8 (patch)
treef2a92efadee4129d62e20b3537db01a0a7180222 /docs/library
parentc9016b4979a718c7a66b2145e00fbdabfa2dc509 (diff)
docs/library/collections: Update deque docs to describe new features.
Signed-off-by: Damien George <damien@micropython.org>
Diffstat (limited to 'docs/library')
-rw-r--r--docs/library/collections.rst31
1 files changed, 26 insertions, 5 deletions
diff --git a/docs/library/collections.rst b/docs/library/collections.rst
index 6cf2c096f..6a23e456c 100644
--- a/docs/library/collections.rst
+++ b/docs/library/collections.rst
@@ -18,7 +18,9 @@ Classes
appends and pops from either side of the deque. New deques are created
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
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.
- As well as supporting `bool` and `len`, deque objects have the following
- methods:
+ Deque objects support `bool`, `len`, iteration and subscript load and store.
+ They also have the following methods:
.. method:: deque.append(x)
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()
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)