Skip to content

Commit d92dff8

Browse files
committed
docs/library/collections: Update deque docs to describe new features.
Signed-off-by: Damien George <damien@micropython.org>
1 parent c9016b4 commit d92dff8

1 file changed

Lines changed: 26 additions & 5 deletions

File tree

docs/library/collections.rst

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,26 +18,47 @@ Classes
1818
appends and pops from either side of the deque. New deques are created
1919
using the following arguments:
2020

21-
- *iterable* must be the empty tuple, and the new deque is created empty.
21+
- *iterable* is an iterable used to populate the deque when it is
22+
created. It can be an empty tuple or list to create a deque that
23+
is initially empty.
2224

2325
- *maxlen* must be specified and the deque will be bounded to this
2426
maximum length. Once the deque is full, any new items added will
2527
discard items from the opposite end.
2628

2729
- The optional *flags* can be 1 to check for overflow when adding items.
2830

29-
As well as supporting `bool` and `len`, deque objects have the following
30-
methods:
31+
Deque objects support `bool`, `len`, iteration and subscript load and store.
32+
They also have the following methods:
3133

3234
.. method:: deque.append(x)
3335

3436
Add *x* to the right side of the deque.
35-
Raises IndexError if overflow checking is enabled and there is no more room left.
37+
Raises ``IndexError`` if overflow checking is enabled and there is
38+
no more room in the queue.
39+
40+
.. method:: deque.appendleft(x)
41+
42+
Add *x* to the left side of the deque.
43+
Raises ``IndexError`` if overflow checking is enabled and there is
44+
no more room in the queue.
45+
46+
.. method:: deque.pop()
47+
48+
Remove and return an item from the right side of the deque.
49+
Raises ``IndexError`` if no items are present.
3650

3751
.. method:: deque.popleft()
3852

3953
Remove and return an item from the left side of the deque.
40-
Raises IndexError if no items are present.
54+
Raises ``IndexError`` if no items are present.
55+
56+
.. method:: deque.extend(iterable)
57+
58+
Extend the deque by appending all the items from *iterable* to
59+
the right of the deque.
60+
Raises ``IndexError`` if overflow checking is enabled and there is
61+
no more room in the deque.
4162

4263
.. function:: namedtuple(name, fields)
4364

0 commit comments

Comments
 (0)