page103.html

来自「Data Structures And Algorithms With Obje」· HTML 代码 · 共 39 行

HTML
39
字号
<HTML><HEAD><TITLE>first and last Properties</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="tex2html2401" HREF="page104.html"><IMG WIDTH=37 HEIGHT=24 ALIGN=BOTTOM ALT="next" SRC="../icons/next_motif.gif"></A> <A NAME="tex2html2399" HREF="page97.html"><IMG WIDTH=26 HEIGHT=24 ALIGN=BOTTOM ALT="up" SRC="../icons/up_motif.gif"></A> <A NAME="tex2html2393" HREF="page102.html"><IMG WIDTH=63 HEIGHT=24 ALIGN=BOTTOM ALT="previous" SRC="../icons/previous_motif.gif"></A>  <A NAME="tex2html2403" HREF="page611.html"><IMG WIDTH=43 HEIGHT=24 ALIGN=BOTTOM ALT="index" SRC="../icons/index_motif.gif"></A> <BR><HR><H2><A NAME="SECTION004360000000000000000"><tt>first</tt> and <tt>last</tt> Properties</A></H2><P>Two more <tt>LinkedList</tt> properties are defined in Program&nbsp;<A HREF="page103.html#proglinkedListe"><IMG  ALIGN=BOTTOM ALT="gif" SRC="../icons/cross_ref_motif.gif"></A>.The <tt>first</tt> property provides an accessorthat returns the first list element.Similarly, the <tt>last</tt> property provides an accessorthat returns the last list element.The code for both methods is almost identical.In the event that the list is empty,a <tt>ContainerEmpty</tt><A NAME=3891>&#160;</A>exception<A NAME=3892>&#160;</A> is raised.<P><P><A NAME="4148">&#160;</A><A NAME="proglinkedListe">&#160;</A> <IMG WIDTH=575 HEIGHT=371 ALIGN=BOTTOM ALT="program3893" SRC="img632.gif"  ><BR><STRONG>Program:</STRONG> <tt>LinkedList</tt> class <tt>first</tt> and <tt>last</tt> properties.<BR><P><P>We will assume that in a bug-free program,neither the <tt>first</tt> nor the <tt>last</tt> property accessors willbe called for an empty list.In that case, the running time of each of these methods is constant.That is, <I>T</I>(<I>n</I>)=<I>O</I>(1).<P><HR><A NAME="tex2html2401" HREF="page104.html"><IMG WIDTH=37 HEIGHT=24 ALIGN=BOTTOM ALT="next" SRC="../icons/next_motif.gif"></A> <A NAME="tex2html2399" HREF="page97.html"><IMG WIDTH=26 HEIGHT=24 ALIGN=BOTTOM ALT="up" SRC="../icons/up_motif.gif"></A> <A NAME="tex2html2393" HREF="page102.html"><IMG WIDTH=63 HEIGHT=24 ALIGN=BOTTOM ALT="previous" SRC="../icons/previous_motif.gif"></A>  <A NAME="tex2html2403" 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 &#169; 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 + -
显示快捷键?