page129.html
来自「wqeqwvrw rkjqhwrjwq jkhrjqwhrwq jkhrwq」· HTML 代码 · 共 72 行
HTML
72 行
<HTML>
<HEAD>
<TITLE>Projects</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="tex2html3496" HREF="page130.html" tppabs="http://dictator.uwaterloo.ca/Bruno.Preiss/books/opus4/html/page130.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="tex2html3494" HREF="page107.html" tppabs="http://dictator.uwaterloo.ca/Bruno.Preiss/books/opus4/html/page107.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="tex2html3490" HREF="page128.html" tppabs="http://dictator.uwaterloo.ca/Bruno.Preiss/books/opus4/html/page128.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="tex2html3498" 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="tex2html3499" 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>
<H1><A NAME="SECTION006400000000000000000">Projects</A></H1>
<P>
<OL><LI> <A NAME="projectadtscompare"> </A>
Design and implement suitable <tt>Compare</tt> functions
for the C++ built-in types
<tt>int</tt>, <tt>char</tt>, <tt>double</tt> and <tt>string</tt>
so that they may be wrapped using the <tt>Wrapper<T></tt> class
declared in Program <A HREF="page115.html#progwrapper1h" tppabs="http://dictator.uwaterloo.ca/Bruno.Preiss/books/opus4/html/page115.html#progwrapper1h"><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>.<LI>
Using <em>visitors</em>,
devise implementations for the <tt>IsMember</tt> and <tt>Find</tt>
member functions of the <tt>SearchableContainer</tt> class
declared in Program <A HREF="page127.html#progsrchconth" tppabs="http://dictator.uwaterloo.ca/Bruno.Preiss/books/opus4/html/page127.html#progsrchconth"><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>.<LI>
Using <em>iterators</em>,
devise implementations for the <tt>IsMember</tt> and <tt>Find</tt>
member functions of the <tt>SearchableContainer</tt> class
declared in Program <A HREF="page127.html#progsrchconth" tppabs="http://dictator.uwaterloo.ca/Bruno.Preiss/books/opus4/html/page127.html#progsrchconth"><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>.<LI>
Devise a scheme using visitors
whereby all of the objects contained in one
searchable container can be removed from it
and transfered to another container.<LI> <A NAME="projectadtsbag"> </A>
A <em>bag</em><A NAME=5411> </A> is a simple container
that can hold a collection of objects.
Design and implement a concrete class called <tt>Bag</tt>
derived from the <tt>SearchableContainer</tt> class
declared in Program <A HREF="page127.html#progsrchconth" tppabs="http://dictator.uwaterloo.ca/Bruno.Preiss/books/opus4/html/page127.html#progsrchconth"><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>.
Use the <tt>Array<T></tt> class given in Chapter <A HREF="page79.html#chapfds" tppabs="http://dictator.uwaterloo.ca/Bruno.Preiss/books/opus4/html/page79.html#chapfds"><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>
to keep track of the contents of the bag.<LI>
Repeat Project <A HREF="page129.html#projectadtsbag" tppabs="http://dictator.uwaterloo.ca/Bruno.Preiss/books/opus4/html/page129.html#projectadtsbag"><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>,
this time using the <tt>LinkedList<T></tt> class given in Chapter <A HREF="page79.html#chapfds" tppabs="http://dictator.uwaterloo.ca/Bruno.Preiss/books/opus4/html/page79.html#chapfds"><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>.<LI>
Ownership is all or nothing--a container owns all the object it contains or none of them.
However, sometimes it is useful for an association
to be the owner of the key
but not of the associated value.
Design and implement a class called <tt>Assoc</tt>
which has this characteristic.
Derive the class <tt>Assoc</tt> from the class <tt>Association</tt>
given in Program <A HREF="page125.html#progassoch" tppabs="http://dictator.uwaterloo.ca/Bruno.Preiss/books/opus4/html/page125.html#progassoch"><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>.<LI>
The <em>Java</em><A NAME=5425> </A> programming language provides
the notion of an <em>enumeration</em><A NAME=5427> </A> as the means to
iterate through the objects in a container.
In C++ we can define enumerations like this:
<PRE>class Enumeration
{
public:
virtual bool hasMoreElements () const = 0;
virtual Object& nextElement () = 0;
};</PRE>
Given an enumeration <tt>e</tt> for some container <tt>c</tt>,
the contents of <tt>c</tt> can be printed like this:
<PRE>while (e.hasMoreElements ())
cout << e.nextElement () << endl;</PRE>
Devise a wrapper class to encapsulate an iterator
and provide the functionality of an enumeration.
</OL>
<P>
<HR><A NAME="tex2html3496" HREF="page130.html" tppabs="http://dictator.uwaterloo.ca/Bruno.Preiss/books/opus4/html/page130.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="tex2html3494" HREF="page107.html" tppabs="http://dictator.uwaterloo.ca/Bruno.Preiss/books/opus4/html/page107.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="tex2html3490" HREF="page128.html" tppabs="http://dictator.uwaterloo.ca/Bruno.Preiss/books/opus4/html/page128.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="tex2html3498" 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="tex2html3499" 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 + =
减小字号Ctrl + -
显示快捷键?