Remove colour attributes from body and strip most of the font tags out
This commit is contained in:
parent
7e957c0bb4
commit
c1f88ddb41
362 changed files with 1632 additions and 1706 deletions
10
15-02.html
10
15-02.html
|
|
@ -24,7 +24,7 @@
|
|||
<!--CHAPTER=15//-->
|
||||
<!--PAGES=284-287//-->
|
||||
<!--UNASSIGNED1//-->
|
||||
<!--UNASSIGNED2//--></HEAD><BODY LINK=#0000FF ALINK=#000099 VLINK=#0000FF BGCOLOR=#FFFFFF>
|
||||
<!--UNASSIGNED2//--></HEAD><body>
|
||||
|
||||
<CENTER>
|
||||
<TABLE BORDER>
|
||||
|
|
@ -100,10 +100,10 @@ struct LinkNode *DeleteNodeAfter(struct LinkNode **HeadOfListPtr,
|
|||
<P>However, it is true that if you’re going to store a variety of types of structures in your linked lists, you should start each node with the <B>LinkNode</B> field. That way, the link pointer is in the same place in <I>every</I> structure, and the same linked list code can handle all of the structure types by casting them to the base link-node structure type. This is a less than elegant approach, but it works. C<SMALL>++</SMALL> can handle data mixing more cleanly than C, via derivation from a base link-node class.</P>
|
||||
<P>Note that Listings 15.1 and 15.3 have to specify the linked-list delete operation as “delete the <I>next</I> node,” rather than “delete this node,” because in order to relink it’s necessary to access the <B>NextNode</B> field of the node preceding the node to be deleted, and it’s impossible to backtrack in a singly linked list. For this reason, singly-linked list operations tend to work with the structure preceding the one of interest—and that makes the problem of having to special-case the head pointer all the more acute.</P>
|
||||
<P>Similar problems with the head pointer crop up when you’re inserting nodes, and in fact in all link manipulation code. It’s easy to end up working with either pointers to pointers or lots of special-case code, and while those approaches work, they’re inelegant and inefficient.</P>
|
||||
<H3><A NAME="Heading4"></A><FONT COLOR="#000077">Dummies and Sentinels</FONT></H3>
|
||||
<H3><A NAME="Heading4"></A>Dummies and Sentinels</H3>
|
||||
<P>A far better approach is to use a <I>dummy node</I> for the head of the list, as shown in Figure 15.2. I invented this one for myself the next time I encountered linked lists, while designing a seed fill function for MetaWindows, back during my tenure at Metagraphics Corp. But I could have learned it by spending five minutes with Sedgewick’s book.</P>
|
||||
<P><A NAME="Fig2"><!-- </A><A HREF="javascript:displayWindow('images/15-02.jpg',407,102 )"> --><IMG SRC="images/15-02.jpg"><BR><!-- </A>
|
||||
<BR><A HREF="javascript:displayWindow('images/15-02.jpg',407,102)"> --><FONT COLOR="#000077"><B>Figure 15.2</B></FONT></A> <I>Using a dummy head and tail node with a linked list.</I>
|
||||
<BR><A HREF="javascript:displayWindow('images/15-02.jpg',407,102)"> --><B>Figure 15.2</B></A> <I>Using a dummy head and tail node with a linked list.</I>
|
||||
</P>
|
||||
<TABLE WIDTH="100%">
|
||||
<TD ALIGN="LEFT" VALIGN="TOP" WIDTH="5%"><IMG SRC="images/i.jpg"><TD ALIGN="LEFT" VALIGN="TOP" WIDTH="95%"><SMALL><I>The next-node pointer of the head node, which points to the first real node, is the only part of the head node that’s actually used. This way the same code works on the head node as on the rest of the list, so there are no special cases.</I></SMALL>
|
||||
|
|
@ -139,7 +139,7 @@ struct LinkNode *FindNodeBeforeValueNotLess(
|
|||
<!-- END CODE //-->
|
||||
<P>Suppose, however, that we make the tail node a <I>sentinel</I> by giving it a value that is guaranteed to terminate the search, as shown in Figure 15.4. The list in Figure 15.4 has a sentinel with a value field of 32,767; since we’re working with integers, that’s the highest possible search value, and is guaranteed to satisfy any search that comes down the pike. The success or failure of the search can then be determined outside the loop, if necessary, by checking for the tail node’s special pointer—but the inside of the loop is streamlined to just one test, as shown in Listing 15.5. Not all linked lists lend themselves to sentinels, but the performance benefits are considerable for those lend themselves to sentinels, but the performance benefits are considerable for those that do.</P>
|
||||
<P><A NAME="Fig3"><!-- </A><A HREF="javascript:displayWindow('images/15-03.jpg',407,104 )"> --><IMG SRC="images/15-03.jpg"><BR><!-- </A>
|
||||
<BR><A HREF="javascript:displayWindow('images/15-03.jpg',407,104)"> --><FONT COLOR="#000077"><B>Figure 15.3</B></FONT></A> <I>Representing an empty list.</I>
|
||||
<BR><A HREF="javascript:displayWindow('images/15-03.jpg',407,104)"> --><B>Figure 15.3</B></A> <I>Representing an empty list.</I>
|
||||
<P><BR></P>
|
||||
<CENTER>
|
||||
<TABLE BORDER>
|
||||
|
|
@ -153,7 +153,7 @@ struct LinkNode *FindNodeBeforeValueNotLess(
|
|||
|
||||
<hr width="90%" size="1" noshade>
|
||||
<div align="center">
|
||||
<font face="Verdana,sans-serif" size="1">Graphics Programming Black Book © 2001 Michael Abrash</font>
|
||||
Graphics Programming Black Book © 2001 Michael Abrash
|
||||
</div>
|
||||
<!-- all of the reference materials (books) have the footer and subfoot reveresed -->
|
||||
<!-- reference_subfoot = footer -->
|
||||
|
|
|
|||
Loading…
Reference in a new issue