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

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

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

remove(2)<br />

E<br />

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

get(2)<br />

null<br />

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

isEmpty()<br />

false<br />

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

Maps <strong>in</strong> the java.util Package<br />

The <strong>Java</strong> package java.util <strong>in</strong>cludes an <strong>in</strong>terface for the map ADT, which is<br />

called java.util.Map. This <strong>in</strong>terface is def<strong>in</strong>ed so that an implement<strong>in</strong>g class<br />

enforces unique keys, <strong>and</strong> it <strong>in</strong>cludes all of the methods of the map ADT given<br />

above, except that it uses different method names <strong>in</strong> a couple of cases. The<br />

correspondences between the map ADT <strong>and</strong> the java.util. Map <strong>in</strong>terface are<br />

shown <strong>in</strong> Table 9.1.<br />

Table 9.1: Correspondences between methods of<br />

the map ADT <strong>and</strong> the methods of the java.util.Map<br />

<strong>in</strong>terface, which supports other methods as well.<br />

Map ADT Methods<br />

java.util.Map Methods<br />

size()<br />

size()<br />

isEmpty()<br />

isEmpty()<br />

get(k)<br />

520

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

Saved successfully!

Ooh no, something went wrong!