Change bold code snippets to inline code blocks
This commit is contained in:
parent
f658bfbb40
commit
3c76d884ef
185 changed files with 1772 additions and 1772 deletions
12
15-01.md
12
15-01.md
|
|
@ -126,23 +126,23 @@ The basic concept of a linked list—the one I came up with for that *DDJ*
|
|||
column—is straightforward, as shown in Figure 15.1. A head pointer
|
||||
points to the first node in the list, which points to the next node,
|
||||
which points to the next, and so on, until the last node in the list is
|
||||
reached (typically denoted by a **NULL** next-node pointer).
|
||||
reached (typically denoted by a `NULL` next-node pointer).
|
||||
Conceptually, nothing could be simpler. From an implementation
|
||||
perspective, however, there are serious flaws with this model.
|
||||
|
||||
The fundamental problem is that the model of Figure 15.1 unnecessarily
|
||||
complicates link manipulation. In order to delete a node, for example,
|
||||
you must change the preceding node's **NextNode** pointer to point to
|
||||
you must change the preceding node's `NextNode` pointer to point to
|
||||
the following node, as shown in Listing 15.1. (Listing 15.2 is the
|
||||
header file LLIST.H, which is **\#include**d by all the linked list
|
||||
header file LLIST.H, which is `#include`d by all the linked list
|
||||
listings in this chapter.) Easy enough—unless the preceding node happens
|
||||
to be the head pointer, which doesn't *have* a **NextNode** field,
|
||||
to be the head pointer, which doesn't *have* a `NextNode` field,
|
||||
because it's not a node, so Listing 15.1 won't work. Cumbersome special
|
||||
code and extra information (a pointer to the head of the list) are
|
||||
required to handle the head-pointer case, as shown in Listing 15.3.
|
||||
(I'll grant you that if you make the next-node pointer the first field
|
||||
in the **LinkNode** structure, at offset 0, then you could successfully
|
||||
point to the head pointer and pretend it was a **LinkNode**
|
||||
in the `LinkNode` structure, at offset 0, then you could successfully
|
||||
point to the head pointer and pretend it was a `LinkNode`
|
||||
structure—but that's an ugly and potentially dangerous trick, and we'll
|
||||
see a better approach next.)
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue