1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
4 <title>List Updates</title>
5 <meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1">
6 <meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
9 <body bgcolor = "white">
11 <h1>List-Update Containers</h1>
14 This section describes policies for list updates. It is organized as follows:
18 <li> The <a href = "#general">General Terms</a> Subsection describes general
21 <li> The <a href = "#imp_pb_assoc">Implementation in <tt>pb_assoc</tt></a>
22 Subsection describes the implementation of these concepts in <tt>pb_assoc</tt>.
27 <h2><a name = "general">General Terms</a></h2>
30 Associative containers use some attributes of the keys of which they store: tree-based
31 containers use the ability to compare keys; hash-based containers use the ability to map
36 In the (rare) case where keys can only be checked for equivalence, these
37 types of containers cannot be used. In such a case, storing the entries in a list is a reasonable solution.
38 Clearly, the order of the elements within the list affects performance; ideally, frequently accessed elements
39 should be at the front of the list.
43 Many remarkable (online competitive
44 [<a href = "references.html#motwani95random">motwani95random</a>])
45 algorithms exist for reordering lists to reflect access prediction
46 [<a href = "references.html#andrew04mtf">andrew04mtf</a>]. Some of these algorithms require storing
47 metadata with each key, while others do not. Some of these algorithms require only the ability to
48 move an element to the front of the list, while others require the ability to interchange an element and
57 shows the counter algorithm. Each node contains both a key and a count metadata (shown in bold).
58 When an element is accessed (<i>e.g.</i> 6)
59 its count is incremented, as shown in
64 If the count reaches some predetermined value, say 10, as shown in
70 and the node is moved to the front of the list, as in
81 <img src = "lu_ops.jpg" width = "65%">
85 The counter algorithm.
90 <h2><a name = "imp_pb_assoc">Implementation in <tt>pb_assoc</tt></a></h2>
93 The <tt>pb_assoc</tt> library allows instantiating lists with policies
94 implementing any algorithm moving nodes to the front of the list (policies implementing
95 algorithms interchanging nodes are currently unsupported).
99 Associative containers based on lists are parameterized by a <tt>Update_Policy</tt> parameter.
100 This parameter defines the type of metadata each node contains, how to create the metadata, and how to
101 decide, using this metadata, whether to move a node to the front of the list.
102 A list-based associative container object derives (publicly) from its update policy.
106 An instantiation of <tt>Update_Policy</tt> must define internally <tt>update_metadata</tt> as the metadata
107 it requires. Internally, each node of the list contains, besides the usual key and data, an instance
108 of <tt><b>typename</b> Update_Policy::update_metadata</tt>.
112 An instantiation of <tt>Update_Policy</tt> must define internally two operators:
125 The first is called by the container object, when creating a new node, to create the node's metadata. The
126 second is called by the container object, when a node is accessed (<i>e.g.</i>, when a find operation's key
127 is equivalent to the key of the node), to determine whether to move the node to the front of the list.
131 Additionally, the library contains implementations of the move-to-front and counter policies. These
133 <a href="interface.html#policy_classes">Policy Classes</a>.