Chapter 17 The Map ADT - PowerPoint PPT Presentation

1 / 13
About This Presentation
Title:

Chapter 17 The Map ADT

Description:

Synonyms- search table, dictionary, associative array, associative container. Example of uses: Dictionary, Address Book, Lists, etc. How is works: ... – PowerPoint PPT presentation

Number of Views:61
Avg rating:3.0/5.0
Slides: 14
Provided by: wade6
Category:

less

Transcript and Presenter's Notes

Title: Chapter 17 The Map ADT


1
Chapter 17 The Map ADT
  • Presented by
  • Wade Apel

2
Contents
  • What are maps
  • How are they implemented
  • Compare JDS vs Java Implementations
  • Benefits
  • References

3
MAP
  • Definition To plan or delineate, especially in
    detail arrange
  • Synonyms- search table, dictionary, associative
    array, associative container
  • Example of uses Dictionary, Address Book,
    Lists, etc.

4
How is works
  • There are 2 main parts to a map
  • Key
  • Value

5
Interface (JDS)
  • Public interface Map extends Collection
  • public boolean containsKey (Object key)
  • public Object get(Object key)
  • public void removeKey (Object key)
  • public void set (Object key, Object value)

6
Javas Map Interface
  • Clear( )
  • containsKey(ObjectKey)
  • containsValue(Object value)
  • entrySet( )
  • equals(Object o)
  • get(Object key)
  • hashCode( )

7
Javas Map Interface (Continued)
  • isEmpty( )
  • keySet( )
  • put(Object key, Object value)
  • putAll(Map t)
  • remove(Object key)
  • size( )
  • values( )

8
Example
9
Timing Tests
10
Map Adapter
  • private class Association implements Comparable,
    Serializable
  • public Object key
  • public Object value
  • Association (Object k, Object v) key k
    value v
  • public int hashCode () return key.hashCode()
  • public boolean equals (Object test)
  • if (test instanceof Association)
  • Association pair (Association) test
  • return key.equals(pair.key)
  • return key.equals(test)
  • public int compareTo (Object testElement)
  • Association pair (Association) testElement
  • return test.compare(key, pair.key)

11
Uses
  • Mapjava.awt
  • java.awt.datatransfer 
  • java.awt.font 
  • java.awt.im 
  • java.security 
  • java.sql 
  • java.text 
  • java.util 
  • java.util.jar 
  • javax.swing 

12
Benifits
  • Easy of use
  • By extending the number of associations,
    searching large lists are fast

13
References
  • Sun Microsystems Java Documentation
  • http//java.sun.com/j2se/1.3/docs/api/java/util/M
    ap.html
  • Classic Data Structures in Java
  • by Timothy Budd
Write a Comment
User Comments (0)
About PowerShow.com