page118.html

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

HTML
54
字号
<HTML><HEAD><TITLE>Containers</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="tex2html2573" HREF="page119.html"><IMG WIDTH=37 HEIGHT=24 ALIGN=BOTTOM ALT="next" SRC="../icons/next_motif.gif"></A> <A NAME="tex2html2571" HREF="page113.html"><IMG WIDTH=26 HEIGHT=24 ALIGN=BOTTOM ALT="up" SRC="../icons/up_motif.gif"></A> <A NAME="tex2html2565" HREF="page117.html"><IMG WIDTH=63 HEIGHT=24 ALIGN=BOTTOM ALT="previous" SRC="../icons/previous_motif.gif"></A>  <A NAME="tex2html2575" HREF="page611.html"><IMG WIDTH=43 HEIGHT=24 ALIGN=BOTTOM ALT="index" SRC="../icons/index_motif.gif"></A> <BR><HR><H2><A NAME="SECTION005230000000000000000">Containers</A></H2><A NAME="secadtscontainers">&#160;</A><P>A container is an object that contains within it other objects.Many of the data structures presentedin this book can be viewed as containers.For this reason, we develop a common abstract base classthat is extended by the various data structure classes.<P>The <tt>Container</tt> base class is definedin Program&nbsp;<A HREF="page119.html#progcontainera"><IMG  ALIGN=BOTTOM ALT="gif" SRC="../icons/cross_ref_motif.gif"></A> to Program&nbsp;<A HREF="page125.html#progcontainerd"><IMG  ALIGN=BOTTOM ALT="gif" SRC="../icons/cross_ref_motif.gif"></A>.The <tt>Container</tt> class defines the concrete methods<tt>__init__</tt>,<tt>getCount</tt>,<tt>getIsEmpty</tt>,<tt>getIsFull</tt>,<tt>accept</tt> andthe abstract methods<tt>purge</tt> and<tt>__iter__</tt>and the properties<tt>count</tt>,<tt>isFull</tt> and<tt>isEmpty</tt>.<P>Conspicuous by their absence are methods for putting objects into a containerand for taking them out again.These methods have been omitted from the <tt>Container</tt> class,because the precise nature of these methods depends on the typeof container implemented.<P><BR> <HR><UL> <LI> <A NAME="tex2html2576" HREF="page119.html#SECTION005231000000000000000"><tt>Container</tt> <tt>__init__</tt>, hookiterand <tt>purge</tt> methods</A><LI> <A NAME="tex2html2577" HREF="page120.html#SECTION005232000000000000000"><tt>Container</tt> Properties</A></UL><HR><A NAME="tex2html2573" HREF="page119.html"><IMG WIDTH=37 HEIGHT=24 ALIGN=BOTTOM ALT="next" SRC="../icons/next_motif.gif"></A> <A NAME="tex2html2571" HREF="page113.html"><IMG WIDTH=26 HEIGHT=24 ALIGN=BOTTOM ALT="up" SRC="../icons/up_motif.gif"></A> <A NAME="tex2html2565" HREF="page117.html"><IMG WIDTH=63 HEIGHT=24 ALIGN=BOTTOM ALT="previous" SRC="../icons/previous_motif.gif"></A>  <A NAME="tex2html2575" 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 + -
显示快捷键?