[Python-checkins] python/dist/src/Doc/lib libcollections.tex, 1.5,
1.6
rhettinger at users.sourceforge.net
rhettinger at users.sourceforge.net
Mon Mar 1 18:16:23 EST 2004
Update of /cvsroot/python/python/dist/src/Doc/lib
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4871/doc/lib
Modified Files:
libcollections.tex
Log Message:
Replace left(), right(), and __reversed__() with the more general purpose
__getitem__() and __setitem__().
Simplifies the API, reduces the code size, adds flexibility, and makes
deques work with bisect.bisect(), random.shuffle(), and random.sample().
Index: libcollections.tex
===================================================================
RCS file: /cvsroot/python/python/dist/src/Doc/lib/libcollections.tex,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** libcollections.tex 29 Feb 2004 02:15:55 -0000 1.5
--- libcollections.tex 1 Mar 2004 23:16:21 -0000 1.6
***************
*** 55,63 ****
\end{methoddesc}
- \begin{methoddesc}{left}{}
- Return leftmost element from the deque.
- If no elements are present, raises a \exception{IndexError}.
- \end{methoddesc}
-
\begin{methoddesc}{pop}{}
Remove and return an element from the right side of the deque.
--- 55,58 ----
***************
*** 70,78 ****
\end{methoddesc}
- \begin{methoddesc}{right}{}
- Return the rightmost element from the deque.
- If no elements are present, raises a \exception{IndexError}.
- \end{methoddesc}
-
\begin{methoddesc}{rotate}{n}
Rotate the deque \var{n} steps to the right. If \var{n} is
--- 65,68 ----
***************
*** 82,87 ****
In addition to the above, deques support iteration, pickling, \samp{len(d)},
! \samp{reversed(d)}, \samp{copy.copy(d)}, \samp{copy.deepcopy(d)}, and
! membership testing with the \keyword{in} operator.
Example:
--- 72,78 ----
In addition to the above, deques support iteration, pickling, \samp{len(d)},
! \samp{reversed(d)}, \samp{copy.copy(d)}, \samp{copy.deepcopy(d)},
! membership testing with the \keyword{in} operator, and subscript references
! such as \samp{d[-1]}.
Example:
***************
*** 107,115 ****
>>> list(d) # list the contents of the deque
['g', 'h', 'i']
!
! >>> d.left() # peek at leftmost item
'g'
! >>> d.right() # peek at rightmost item
'i'
>>> list(reversed(d)) # list the contents of a deque in reverse
['i', 'h', 'g']
--- 98,106 ----
>>> list(d) # list the contents of the deque
['g', 'h', 'i']
! >>> d[0] # peek at leftmost item
'g'
! >>> d[-1] # peek at rightmost item
'i'
+
>>> list(reversed(d)) # list the contents of a deque in reverse
['i', 'h', 'g']
More information about the Python-checkins
mailing list