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.

emove<br />

O(1)<br />

O(1)<br />

O(logn)<br />

replaceKey<br />

O(1)<br />

O(n)<br />

O(logn)<br />

replaceValue<br />

O(1)<br />

O(1)<br />

O(1)<br />

8.4.3 Implement<strong>in</strong>g an Adaptable Priority Queue<br />

In Code Fragment 8.17 <strong>and</strong> 8.18, we show the <strong>Java</strong> implementation of an adaptable<br />

priority queue based on a sorted list. This implementation is obta<strong>in</strong>ed by extend<strong>in</strong>g<br />

class SortedListPriorityQueue shown <strong>in</strong> Code Fragment 8.6. In particular,<br />

Code Fragment 8.18 shows how to realize a location-aware entry <strong>in</strong> <strong>Java</strong> by<br />

extend<strong>in</strong>g a regular entry.<br />

Code Fragment 8.17: <strong>Java</strong> implementation of an<br />

adaptable priority queue by means of a sorted list<br />

stor<strong>in</strong>g location-aware entries. Class<br />

SortedListAdaptablePriori tyQueue extends<br />

class SortedListPriorityQueue (Code Fragment<br />

8.6) <strong>and</strong> imple ments <strong>in</strong>terface<br />

AdaptablePriorityQueue. (Cont<strong>in</strong>ues <strong>in</strong> Code<br />

Fragment 8.18.)<br />

500

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

Saved successfully!

Ooh no, something went wrong!