This preview shows page 1. Sign up to view the full content.
Unformatted text preview: Additional Methods of the Adaptable Priority Queue ADT
remove(e): Remove from P and return entry e.
replaceKey(e,k): Replace with k and return the old key;
an error condition occurs if k is invalid (that is, k cannot
be compared with other keys).
replaceValue(e,x): Replace with x and return the old
value. CSE 2011
Prof. J. Elder - 66 - Last Updated: 1/7/10 10:14 AM Locating Entries
In order to implement the operations remove(k),
replaceKey(e), and replaceValue(k), we need fast ways
of locating an entry e in a priority queue.
We can always just search the entire data structure to
find an entry e, but there are better ways for locating
entries. CSE 2011
Prof. J. Elder - 67 - Last Updated: 1/7/10 10:14 AM Location-Aware Entries
A locator-aware entry identifies and tracks the
location of its (key, value) object within a data
structure CSE 2011
Prof. J. Elder - 68 - Last Updated: 1/7/10 10:14 AM Maps
A map models a searchable collection of key-value
The main operations of a map are for searching,
inserting, and deleting items
Multiple entries with the same key are not allowed
student-record database CSE 2011
Prof. J. Elder - 69 - Last Updated: 1/7/10 10:14 AM The Map ADT
Map ADT methods:
get(k): if the map M has an entry with key k, return its associated
value; else, return null
put(k, v): insert entry (k, v) into the map M; if key k is not already
in M, then return null; else, return old value associated with k
remove(k): if the map M has an entry with key k, remove it from
M and return its associated value; else, return null
keys(): return an iterator of the keys in M
values(): return an iterator of the values in M
entries(): returns an iterator of the entries in M CSE 2011
Prof. J. Elder - 70 - Last Updated: 1/7/10 10:14 AM ...
View Full Document
This note was uploaded on 02/14/2012 for the course CSE 2011Z taught by Professor Elder during the Fall '11 term at York University.
- Fall '11
- Data Structures