@@ -14,33 +14,58 @@ hold/accumulate various objects.
1414Classes
1515-------
1616
17- .. class :: deque(iterable, maxlen[, flags ])
17+ .. class :: deque(iterable, maxlen[, flag ])
1818
19- Deques (double-ended queues ) are a list-like container that support O(1)
20- appends and pops from either side of the deque. New deques are created
21- using the following arguments:
19+ Deques (pronounced "deck" and short for " double-ended queue" ) are fixed length
20+ list-like containers that support O(1) appends and pops from either side of the
21+ deque. New deques are created using the following arguments:
2222
23- - *iterable * must be the empty tuple, and the new deque is created empty.
23+ - *iterable * must be specified as an empty or non-empty iterable.
24+ If the iterable is empty, the new deque is created empty. If the
25+ iterable is not empty, the new deque is created with the items
26+ from the iterable.
2427
2528 - *maxlen * must be specified and the deque will be bounded to this
2629 maximum length. Once the deque is full, any new items added will
2730 discard items from the opposite end.
2831
29- - The optional *flags * can be 1 to check for overflow when adding items.
32+ - *flag * is optional and can be set to 1 to check for overflow when
33+ adding items. If the deque is full and overflow checking is enabled,
34+ an IndexError will be raised when adding items.
3035
31- As well as supporting ``bool `` and ``len ``, deque objects have the following
32- methods:
36+ Deque objects have the following methods:
3337
3438 .. method :: deque.append(x)
3539
3640 Add *x * to the right side of the deque.
3741 Raises IndexError if overflow checking is enabled and there is no more room left.
3842
43+ .. method :: deque.appendleft(x)
44+
45+ Add *x * to the left side of the deque.
46+ Raises IndexError if overflow checking is enabled and there is no more room left.
47+
48+ .. method :: deque.pop()
49+
50+ Remove and return an item from the right side of the deque.
51+ Raises IndexError if no items are present.
52+
3953 .. method :: deque.popleft()
4054
4155 Remove and return an item from the left side of the deque.
4256 Raises IndexError if no items are present.
4357
58+ .. method :: deque.extend(iterable)
59+
60+ Extend the right side of the deque by appending items from the *iterable * argument.
61+ Raises IndexError if overflow checking is enabled and there is no more room left
62+ for all of the items in *iterable *.
63+
64+ In addition to the above, deques support iteration, ``bool ``, ``len(d) ``, ``reversed(d) ``,
65+ membership testing with the ``in `` operator, and subscript references like ``d[0] ``.
66+ Note: Indexed access is O(1) at both ends but slows to O(n) in the middle of the deque,
67+ so for fast random access use a ``list `` instead.
68+
4469.. function :: namedtuple(name, fields)
4570
4671 This is factory function to create a new namedtuple type with a specific
0 commit comments