📄 page227.html
字号:
<HTML>
<HEAD>
<TITLE>Finding an Item</TITLE>
</HEAD>
<BODY bgcolor="#FFFFFF">
<img src="cover75.gif" tppabs="http://dictator.uwaterloo.ca/Bruno.Preiss/books/opus4/icons/cover75.gif" alt="Logo" align=right>
<b>Data Structures and Algorithms
with Object-Oriented Design Patterns in C++</b><br>
<A NAME="tex2html4721" HREF="page228.html" tppabs="http://dictator.uwaterloo.ca/Bruno.Preiss/books/opus4/html/page228.html"><IMG WIDTH=37 HEIGHT=24 ALIGN=BOTTOM ALT="next" SRC="next_motif.gif" tppabs="http://dictator.uwaterloo.ca/Bruno.Preiss/books/opus4/icons/next_motif.gif"></A> <A NAME="tex2html4719" HREF="page223.html" tppabs="http://dictator.uwaterloo.ca/Bruno.Preiss/books/opus4/html/page223.html"><IMG WIDTH=26 HEIGHT=24 ALIGN=BOTTOM ALT="up" SRC="up_motif.gif" tppabs="http://dictator.uwaterloo.ca/Bruno.Preiss/books/opus4/icons/up_motif.gif"></A> <A NAME="tex2html4715" HREF="page226.html" tppabs="http://dictator.uwaterloo.ca/Bruno.Preiss/books/opus4/html/page226.html"><IMG WIDTH=63 HEIGHT=24 ALIGN=BOTTOM ALT="previous" SRC="previous_motif.gif" tppabs="http://dictator.uwaterloo.ca/Bruno.Preiss/books/opus4/icons/previous_motif.gif"></A> <A NAME="tex2html4723" HREF="page9.html" tppabs="http://dictator.uwaterloo.ca/Bruno.Preiss/books/opus4/html/page9.html"><IMG WIDTH=65 HEIGHT=24 ALIGN=BOTTOM ALT="contents" SRC="contents_motif.gif" tppabs="http://dictator.uwaterloo.ca/Bruno.Preiss/books/opus4/icons/contents_motif.gif"></A> <A NAME="tex2html4724" HREF="page620.html" tppabs="http://dictator.uwaterloo.ca/Bruno.Preiss/books/opus4/html/page620.html"><IMG WIDTH=43 HEIGHT=24 ALIGN=BOTTOM ALT="index" SRC="index_motif.gif" tppabs="http://dictator.uwaterloo.ca/Bruno.Preiss/books/opus4/icons/index_motif.gif"></A> <BR><HR>
<H3><A NAME="SECTION009414000000000000000">Finding an Item</A></H3>
<P>
The definition of the <tt>Find</tt> member function
of the <tt>ChainedHashTable</tt> class
is given in Program <A HREF="page227.html#proghashtbl4c" tppabs="http://dictator.uwaterloo.ca/Bruno.Preiss/books/opus4/html/page227.html#proghashtbl4c"><IMG ALIGN=BOTTOM ALT="gif" SRC="cross_ref_motif.gif" tppabs="http://dictator.uwaterloo.ca/Bruno.Preiss/books/opus4/icons/cross_ref_motif.gif"></A>.
The <tt>Find</tt> function takes as its single argument
a reference to an <tt>Object</tt>.
The purpose of the <tt>Find</tt> operation is to return a reference
to an object which is compares equal to the specified object.
<P>
<P><A NAME="12080"> </A><A NAME="proghashtbl4c"> </A> <IMG WIDTH=575 HEIGHT=238 ALIGN=BOTTOM ALT="program11988" SRC="img982.gif" tppabs="http://dictator.uwaterloo.ca/Bruno.Preiss/books/opus4/html/img982.gif" ><BR>
<STRONG>Program:</STRONG> <tt>ChainedHashTable</tt> Class <tt>Find</tt> Member Function Definition<BR>
<P>
<P>
The <tt>Find</tt> function simply hashes its argument to select
the linked list in which it should be found.
Then, it traverses the linked list to locate the target object.
As for the <tt>Withdraw</tt> operation,
the worst case running time of the <tt>Find</tt> function
occurs when all the objects in the container have collided,
and the item that is being sought does not appear in the linked list.
In this case, the running time of the find operation
is <IMG WIDTH=251 HEIGHT=26 ALIGN=MIDDLE ALT="tex2html_wrap_inline62848" SRC="img983.gif" tppabs="http://dictator.uwaterloo.ca/Bruno.Preiss/books/opus4/html/img983.gif" >.
<P>
<HR><A NAME="tex2html4721" HREF="page228.html" tppabs="http://dictator.uwaterloo.ca/Bruno.Preiss/books/opus4/html/page228.html"><IMG WIDTH=37 HEIGHT=24 ALIGN=BOTTOM ALT="next" SRC="next_motif.gif" tppabs="http://dictator.uwaterloo.ca/Bruno.Preiss/books/opus4/icons/next_motif.gif"></A> <A NAME="tex2html4719" HREF="page223.html" tppabs="http://dictator.uwaterloo.ca/Bruno.Preiss/books/opus4/html/page223.html"><IMG WIDTH=26 HEIGHT=24 ALIGN=BOTTOM ALT="up" SRC="up_motif.gif" tppabs="http://dictator.uwaterloo.ca/Bruno.Preiss/books/opus4/icons/up_motif.gif"></A> <A NAME="tex2html4715" HREF="page226.html" tppabs="http://dictator.uwaterloo.ca/Bruno.Preiss/books/opus4/html/page226.html"><IMG WIDTH=63 HEIGHT=24 ALIGN=BOTTOM ALT="previous" SRC="previous_motif.gif" tppabs="http://dictator.uwaterloo.ca/Bruno.Preiss/books/opus4/icons/previous_motif.gif"></A> <A NAME="tex2html4723" HREF="page9.html" tppabs="http://dictator.uwaterloo.ca/Bruno.Preiss/books/opus4/html/page9.html"><IMG WIDTH=65 HEIGHT=24 ALIGN=BOTTOM ALT="contents" SRC="contents_motif.gif" tppabs="http://dictator.uwaterloo.ca/Bruno.Preiss/books/opus4/icons/contents_motif.gif"></A> <A NAME="tex2html4724" HREF="page620.html" tppabs="http://dictator.uwaterloo.ca/Bruno.Preiss/books/opus4/html/page620.html"><IMG WIDTH=43 HEIGHT=24 ALIGN=BOTTOM ALT="index" SRC="index_motif.gif" tppabs="http://dictator.uwaterloo.ca/Bruno.Preiss/books/opus4/icons/index_motif.gif"></A> <P><ADDRESS>
<img src="bruno.gif" tppabs="http://dictator.uwaterloo.ca/Bruno.Preiss/books/opus4/icons/bruno.gif" alt="Bruno" align=right>
<a href="javascript:if(confirm('http://dictator.uwaterloo.ca/Bruno.Preiss/books/opus4/copyright.html \n\nThis file was not retrieved by Teleport Pro, because it is addressed on a domain or path outside the boundaries set for its Starting Address. \n\nDo you want to open it from the server?'))window.location='http://dictator.uwaterloo.ca/Bruno.Preiss/books/opus4/copyright.html'" tppabs="http://dictator.uwaterloo.ca/Bruno.Preiss/books/opus4/copyright.html">Copyright © 1997</a> by <a href="javascript:if(confirm('http://dictator.uwaterloo.ca/Bruno.Preiss/books/opus4/signature.html \n\nThis file was not retrieved by Teleport Pro, because it is addressed on a domain or path outside the boundaries set for its Starting Address. \n\nDo you want to open it from the server?'))window.location='http://dictator.uwaterloo.ca/Bruno.Preiss/books/opus4/signature.html'" tppabs="http://dictator.uwaterloo.ca/Bruno.Preiss/books/opus4/signature.html">Bruno R. Preiss, P.Eng.</a> All rights reserved.
</ADDRESS>
</BODY>
</HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -