page242.html

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

HTML
49
字号
<HTML><HEAD><TITLE>Implementation</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="tex2html3988" HREF="page243.html"><IMG WIDTH=37 HEIGHT=24 ALIGN=BOTTOM ALT="next" SRC="../icons/next_motif.gif"></A> <A NAME="tex2html3986" HREF="page238.html"><IMG WIDTH=26 HEIGHT=24 ALIGN=BOTTOM ALT="up" SRC="../icons/up_motif.gif"></A> <A NAME="tex2html3980" HREF="page241.html"><IMG WIDTH=63 HEIGHT=24 ALIGN=BOTTOM ALT="previous" SRC="../icons/previous_motif.gif"></A>  <A NAME="tex2html3990" HREF="page611.html"><IMG WIDTH=43 HEIGHT=24 ALIGN=BOTTOM ALT="index" SRC="../icons/index_motif.gif"></A> <BR><HR><H2><A NAME="SECTION008640000000000000000">Implementation</A></H2><P>This section describes an implementation of a scatter tableusing open addressing with linear probing.Program&nbsp;<A HREF="page242.html#progopenScatterTablea"><IMG  ALIGN=BOTTOM ALT="gif" SRC="../icons/cross_ref_motif.gif"></A> introduces the <tt>OpenScatterTable</tt> class.The <tt>OpenScatterTable</tt> class extendsthe abstract <tt>HashTable</tt> classintroduced in Program&nbsp;<A HREF="page223.html#proghashTablea"><IMG  ALIGN=BOTTOM ALT="gif" SRC="../icons/cross_ref_motif.gif"></A>.The scatter table is implemented as an arrayof elements of the nested class <tt>Entry</tt>.Each <tt>Entry</tt> instance has two instance attributes--<tt>_obj</tt> and <tt>_state</tt>.The former is refers to an object.The latter represents the state of the entry which is either<tt>EMPTY</tt>, <tt>OCCUPIED</tt> or <tt>DELETED</tt>.<P><P><A NAME="13649">&#160;</A><A NAME="progopenScatterTablea">&#160;</A> <IMG WIDTH=575 HEIGHT=275 ALIGN=BOTTOM ALT="program13293" SRC="img1003.gif"  ><BR><STRONG>Program:</STRONG> <tt>OpenScatterTable.Entry</tt> class <tt>__init__</tt> method.<BR><P><P>Initially, all entries are empty.When an object recorded in an entry,the state of that entry is changed to <tt>OCCUPIED</tt>.The purpose of the third state, <tt>DELETED</tt>,will be discussed in conjunction with the <tt>withdraw</tt> method below.<P><BR> <HR><UL> <LI> <A NAME="tex2html3991" HREF="page243.html#SECTION008641000000000000000"><tt>__init__</tt>, <tt>__len__</tt> and <tt>purge</tt> Methods</A><LI> <A NAME="tex2html3992" HREF="page244.html#SECTION008642000000000000000">Inserting Items</A><LI> <A NAME="tex2html3993" HREF="page245.html#SECTION008643000000000000000">Finding Items</A><LI> <A NAME="tex2html3994" HREF="page246.html#SECTION008644000000000000000">Removing Items</A></UL><HR><A NAME="tex2html3988" HREF="page243.html"><IMG WIDTH=37 HEIGHT=24 ALIGN=BOTTOM ALT="next" SRC="../icons/next_motif.gif"></A> <A NAME="tex2html3986" HREF="page238.html"><IMG WIDTH=26 HEIGHT=24 ALIGN=BOTTOM ALT="up" SRC="../icons/up_motif.gif"></A> <A NAME="tex2html3980" HREF="page241.html"><IMG WIDTH=63 HEIGHT=24 ALIGN=BOTTOM ALT="previous" SRC="../icons/previous_motif.gif"></A>  <A NAME="tex2html3990" 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 + -
显示快捷键?