Maps "He's off the map!" -Stan (Mark Ruffalo)

Maps "He's off the map!" -Stan (Mark Ruffalo) Eternal Sunshine of the Spotless Mind 1 Other Data Structures Write a program to count the frequency of all the words in a file. Make a simplification: assume words are anything set off by whitespace Maps

2 Why So Slow Write a contains method for an array based list public boolean contains(E target) { CS 314 Maps 3 A Faster Way - Maps Also known as: table, search table, dictionary, associative array, or associative container

A data structure optimized for a very specific kind of search / access In a map we access by asking "give me the value associated with this key." Recall, in the ArrayList example we did not count the number of occurrences of each word CS 314 Maps 4 Keys and Values Dictionary Analogy:

The key in a dictionary is a word: foo The value in a dictionary is the definition: First on the standard list of metasyntactic variables used in syntax examples A key and its associated value form a pair that is stored in a map To retrieve a value the key for that value must be supplied A List can be viewed as a Map with integer keys CS 314 Maps 5

More on Keys and Values Keys must be unique, meaning a given key can only represent one value but one value may be represented by multiple keys like synonyms in the dictionary. Example: factor: n.See coefficient of X factor is a key associated with the same value (definition) as the key coefficient of X CS 314 Maps

6 The Map Interface in Java void clear() Removes all mappings from this map (optional operation). boolean containsKey(Object key) Returns true if this map contains a mapping for the specified key. boolean containsValue(Object value) Returns true if this map maps one or more keys to the specified value.

Set keySet() Returns a Set view of the keys contained in this map. CS 314 Maps 7 The Map Interface Continued V get(Object key) Returns the value to which this map maps the specified key. boolean isEmpty() Returns true if this map contains no key-value

mappings. V put(K key, V value) Associates the specified value with the specified key in this map CS 314 Maps 8 The Map Interface Continued V remove(Object key)

Removes the mapping for this key from this map if it is present int size() Returns the number of key-value mappings in this map. Collection values() Returns a collection view of the values contained in this map. CS 314 Maps 9

Other Uses? Maps 10

Recently Viewed Presentations

• Protonephridia Metanephredia of Earthworm Roles of the Kidney Filtration -- 180 liters/day of water, all NaCl, sugar, amino acids Absorption -- 178.5 liters reabsorbed with 95-99% of NaCl, all glucose, amino acids Secretion -- acids and bases, toxins, antibiotics Concentration...
• Supported by the latest groundbreaking research on the brain, Quiet Leadership provides, for the first time, a simple brain-based approach that will help busy leaders, executives, and managers improve their own and their colleagues' performance. Quiet Leadership: Six Steps to...
• VCAA and VTAC offer three options for accessing VCE results and the ATAR: internet, mail and app. ... Online test required for most undergraduate teaching courses in Victoria. Taken online at specific dates and times. Listed under essential requirements if...
• This functionality is used to calculate the LT/HT and Total Length of feeder (in meters) based upon Division/Town. 7.Manage Document. This Functionality is used to manage the Document associated with target layer within the GIS Map.
• Vestibule . Space between the cheeks (or lips) and the teeth. 24-2 The Oral Cavity. Gingivae (Gums) Ridges of oral mucosa. ... Manipulates materials inside mouth. Functions of the tongue . Mechanical processing by compression, abrasion, and distortion.
• Unbiasedness. Unbiasedness: The expected value (mean) of the statistic is exactly equal to the value of the parameter being estimated. The sample mean is an unbiased estimator of the population mean.
• Metric Conversions w/o Dimensional Analysis Just move the decimal!! Metric Conversions To change from a smaller unit to a larger unit, move the decimal point to the left. 4206 mm = _____ cm = 420.6 cm Try these….
• Purpose To compare the clinical results of Accommodative Kellan Tetraflex KH3500 (LensTec®) IOL vs. Diffractive Acri.Lisa (Acri.Tec®) multifocal IOL implantation Presbyopic IOLs Kellan Tetraflex KH3500 (LensTec®) Acri.Lisa (Acri.Tec®) Methods Group 1 : Kellan Tetraflex KH3500 (LensTec®) IOL was implanted in...