page105.html
来自「Data Structures And Algorithms With Obje」· HTML 代码 · 共 41 行
HTML
41 行
<HTML><HEAD><TITLE>append Method</TITLE></HEAD><BODY bgcolor="#FFFFFF"> <a href="../index.html" target="_top"><img src="../icons/usins.gif" alt="Logo" align=right></a><b>Data Structures and Algorithms with Object-Oriented Design Patterns in Python</b><br><A NAME="tex2html2423" HREF="page106.html"><IMG WIDTH=37 HEIGHT=24 ALIGN=BOTTOM ALT="next" SRC="../icons/next_motif.gif"></A> <A NAME="tex2html2421" HREF="page97.html"><IMG WIDTH=26 HEIGHT=24 ALIGN=BOTTOM ALT="up" SRC="../icons/up_motif.gif"></A> <A NAME="tex2html2415" HREF="page104.html"><IMG WIDTH=63 HEIGHT=24 ALIGN=BOTTOM ALT="previous" SRC="../icons/previous_motif.gif"></A> <A NAME="tex2html2425" HREF="page611.html"><IMG WIDTH=43 HEIGHT=24 ALIGN=BOTTOM ALT="index" SRC="../icons/index_motif.gif"></A> <BR><HR><H2><A NAME="SECTION004380000000000000000"><tt>append</tt> Method</A></H2><A NAME="secfdsappend"> </A><P>The <tt>append</tt> method,the definition of which is given in Program <A HREF="page105.html#proglinkedListg"><IMG ALIGN=BOTTOM ALT="gif" SRC="../icons/cross_ref_motif.gif"></A>,adds a new <tt>LinkedList.Element</tt> at the tail-end of the list.The appended element becomes the new tail of the list.<P><P><A NAME="4157"> </A><A NAME="proglinkedListg"> </A> <IMG WIDTH=575 HEIGHT=218 ALIGN=BOTTOM ALT="program3946" SRC="img634.gif" ><BR><STRONG>Program:</STRONG> <tt>LinkedList</tt> class <tt>append</tt> method.<BR><P><P>The <tt>append</tt> method first allocates a new <tt>LinkedList.Element</tt>.Its <tt>_datum</tt> instance attribute is initialized with the value to be appended, andthe <tt>_next</tt> instance attribute is set to <tt>None</tt>.If the list is initially empty,both <tt>_head</tt> and <tt>_tail</tt> refer to the new element.Otherwise, the new element is appended to the existing list,and the just <tt>_tail</tt> pointer is updated.<P>The running time analysis of the <tt>append</tt> methodis essentially the same as for <tt>prepend</tt>.I.e, the running time is <I>O</I>(1).<P><HR><A NAME="tex2html2423" HREF="page106.html"><IMG WIDTH=37 HEIGHT=24 ALIGN=BOTTOM ALT="next" SRC="../icons/next_motif.gif"></A> <A NAME="tex2html2421" HREF="page97.html"><IMG WIDTH=26 HEIGHT=24 ALIGN=BOTTOM ALT="up" SRC="../icons/up_motif.gif"></A> <A NAME="tex2html2415" HREF="page104.html"><IMG WIDTH=63 HEIGHT=24 ALIGN=BOTTOM ALT="previous" SRC="../icons/previous_motif.gif"></A> <A NAME="tex2html2425" HREF="page611.html"><IMG WIDTH=43 HEIGHT=24 ALIGN=BOTTOM ALT="index" SRC="../icons/index_motif.gif"></A> <P><ADDRESS><img src="../icons/bruno.gif" alt="Bruno" align=right><a href="../copyright.html">Copyright © 2003</a> by <a href="../signature.html">Bruno R. Preiss, P.Eng.</a> All rights reserved.</ADDRESS></BODY></HTML>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?