COSI 12b Lecture Notes - Lecture 13: Associative Array, Iterator

54 views2 pages

Document Summary

A set is like a map from elements to booleans. A map associates a key with a value. Maps are also known as hash, dictionary, and associative array. Using the put method for an existing key will change that key s value. Hashmap is faster than treemap (o(1) vs. o(log n)). The comparable interface must be implemented for treemap to use a natural ordering. Maps are like a collection, though they do not actually implement the collections interface in. If a key does not exist, the get method returns null. The values and keyset methods return the values/keys which can be stored in a list or set. The iterator method cannot directly be used on a map; it must be used on the collection returned by the values or keyset methods. The enhanced for loop can also be used instead of the iterator method. To get a key for a given value, a new reverse map must be created.

Get access

Grade+
$40 USD/m
Billed monthly
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
10 Verified Answers
Class+
$30 USD/m
Billed monthly
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
7 Verified Answers

Related Documents

Related Questions