23.11.2014 Views

Data Structures and Algorithms in Java[1].pdf - Fulvio Frisone

Data Structures and Algorithms in Java[1].pdf - Fulvio Frisone

Data Structures and Algorithms in Java[1].pdf - Fulvio Frisone

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

f<strong>in</strong>dAll(2)<br />

{(2,C), (2,E)}<br />

{(5,A), (7,B), (2,C), (8,D), (2,E)}<br />

size()<br />

5<br />

{(5,A), (7,B), (2,C), (8,D), (2,E)}<br />

remove(f<strong>in</strong>d(5))<br />

(5,A)<br />

{(7,B), (2,C), (8,D), (2,E)}<br />

f<strong>in</strong>d(5)<br />

null<br />

{(7,B), (2,C), (8,D), (2,E)<br />

9.3.1 List-Based Dictionaries <strong>and</strong> Audit Trails<br />

A simple way of realiz<strong>in</strong>g a dictionary uses an unordered list to store the key-value<br />

entries. Such an implementation is often called a log file or audit trail. The primary<br />

applications of audit trails are situations where we wish to archive structured data.<br />

For example, many operat<strong>in</strong>g systems store log files of log<strong>in</strong> requests they process.<br />

The typical scenario is that there are many <strong>in</strong>sertions <strong>in</strong>to the dictionary but few<br />

searches. For example, search<strong>in</strong>g such an operat<strong>in</strong>g system log file typically occurs<br />

only after someth<strong>in</strong>g goes wrong. Thus, a list-based dictionary supports simple <strong>and</strong><br />

fast <strong>in</strong>sertions, possibly at the expense of search time, by stor<strong>in</strong>g entries of a<br />

dictionary <strong>in</strong> arbitrary order. (See Figure 9.6.)<br />

Figure 9.6: Realization of a dictionary D by means<br />

of a log file. We show only the keys <strong>in</strong> this dictionary, so<br />

as to highlight its unordered list implementation.<br />

547

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!