Java Reference
In-Depth Information
private K key;
private V value;
private Node next;
The generic types K and V are defined by the outer class. In addition to constructors, the class Node
would contain the methods getKey , getValue , setValue , getNextNode , and setNextNode . Since
changing the search key is not necessary and, in fact, could destroy the order of a sorted dictionary,
no setKey method is provided.
FIGURE 20-6
Three possible ways to use linked nodes to represent the entries in a
dictionary: (a) a chain of nodes that each reference an entry object;
(b) parallel chains of search keys and values; (c) a chain of nodes that each
reference a search key and a value
(a)
Instance of Node
firstNode
Instance of Entry
Search key
Value
(b)
firstNodeSK
Search key
firstNodeV
Va l u e
(c)
Instance of a revised Node
firstNode
Search key
Value
Search WWH ::




Custom Search