SlideShare a Scribd company logo
Map Collections and
Custom Collection
Classes
Chapter 14
14
Maps
An object that maps a key to a value
Key maps to one value
A map cannot have duplicate keys
Often used to associate a short key
with a longer value
Example: Dictionary
Example: Employee database using
employee ID number
14
Concrete Map Implementations
TreeMap orders the keys.
HashMap stores the keys in a hash table.
HashMap class is generally preferred for
its efficiency (speed) unless sorted keys
are needed.
14
Retrieving Values by Key
Use the keys collection to retrieve the keys
in a map.
Iterator keyIterator =
myMap.keySet().iterator();
Keys collection holds “key” objects.
Must cast key values to the appropriate type
Integer key =
(Integer)keyIterator.next();
Retrieves the next key from keyIterator
(collection of keys) then casts it to an Integer
and assigns it to the variable key
14
Custom Collection Classes
Custom collections allow you to define
the data storage method.
Good way to understand how other
collection classes work
Think through issues involved in writing
good generic classes
14
Linked List
A linked list is a type of collection, similar to
a train.
Each object or node is linked to the next object
in the collection.
Singly linked list
Each node knows the node following it
Can only be iterated in one direction
Doubly linked list
Each node knows the node preceding it and the node
following it
Can be iterated in both directions
14
Linked List Hierarchy
Head node points to next node in list
Internal node “carries” an object (the value
being stored) and points to next node in list
Tail node signals end of the list

More Related Content

What's hot

Data structure lecture 2
Data structure lecture 2Data structure lecture 2
Data structure lecture 2
Abbott
 
Array
ArrayArray
Group p1
Group p1Group p1
Group p1
IIUM
 
Introduction to data structure
Introduction to data structureIntroduction to data structure
Introduction to data structure
adeel hamid
 
Presentation on array
Presentation on array Presentation on array
Presentation on array
topu93
 
Array Of Pointers
Array Of PointersArray Of Pointers
Array Of Pointers
Sharad Dubey
 
Data structures
Data structuresData structures
Concepts of Arrays
Concepts of ArraysConcepts of Arrays
Concepts of Arrays
Yashh Pandya
 
Arrays In C Language
Arrays In C LanguageArrays In C Language
Arrays In C Language
Surbhi Yadav
 
Pointer to array and structure
Pointer to array and structurePointer to array and structure
Pointer to array and structure
sangrampatil81
 
Sets
SetsSets
Two Dimentional Array
Two Dimentional ArrayTwo Dimentional Array
Two Dimentional Array
Sonya Akter Rupa
 
Chapter 13
Chapter 13Chapter 13
Chapter 13
Graham Royce
 
Introduction to data_structure
Introduction to data_structureIntroduction to data_structure
Introduction to data_structure
Ashim Lamichhane
 
Arrays introduction- JAVA
Arrays introduction- JAVAArrays introduction- JAVA
Arrays introduction- JAVA
Hamna_sheikh
 
Array
ArrayArray
Chapter 12
Chapter 12Chapter 12
Chapter 12
Graham Royce
 
Data Structure Basics
Data Structure BasicsData Structure Basics
Data Structure Basics
Shakila Mahjabin
 
Chapter 8: tree data structure
Chapter 8:  tree data structureChapter 8:  tree data structure
Chapter 8: tree data structure
Mahmoud Alfarra
 
Data Structure & Algorithms | Computer Science
Data Structure & Algorithms | Computer ScienceData Structure & Algorithms | Computer Science
Data Structure & Algorithms | Computer Science
Transweb Global Inc
 

What's hot (20)

Data structure lecture 2
Data structure lecture 2Data structure lecture 2
Data structure lecture 2
 
Array
ArrayArray
Array
 
Group p1
Group p1Group p1
Group p1
 
Introduction to data structure
Introduction to data structureIntroduction to data structure
Introduction to data structure
 
Presentation on array
Presentation on array Presentation on array
Presentation on array
 
Array Of Pointers
Array Of PointersArray Of Pointers
Array Of Pointers
 
Data structures
Data structuresData structures
Data structures
 
Concepts of Arrays
Concepts of ArraysConcepts of Arrays
Concepts of Arrays
 
Arrays In C Language
Arrays In C LanguageArrays In C Language
Arrays In C Language
 
Pointer to array and structure
Pointer to array and structurePointer to array and structure
Pointer to array and structure
 
Sets
SetsSets
Sets
 
Two Dimentional Array
Two Dimentional ArrayTwo Dimentional Array
Two Dimentional Array
 
Chapter 13
Chapter 13Chapter 13
Chapter 13
 
Introduction to data_structure
Introduction to data_structureIntroduction to data_structure
Introduction to data_structure
 
Arrays introduction- JAVA
Arrays introduction- JAVAArrays introduction- JAVA
Arrays introduction- JAVA
 
Array
ArrayArray
Array
 
Chapter 12
Chapter 12Chapter 12
Chapter 12
 
Data Structure Basics
Data Structure BasicsData Structure Basics
Data Structure Basics
 
Chapter 8: tree data structure
Chapter 8:  tree data structureChapter 8:  tree data structure
Chapter 8: tree data structure
 
Data Structure & Algorithms | Computer Science
Data Structure & Algorithms | Computer ScienceData Structure & Algorithms | Computer Science
Data Structure & Algorithms | Computer Science
 

Viewers also liked

Chapter 18
Chapter 18Chapter 18
Chapter 18
Graham Royce
 
Enterprise Skills
Enterprise SkillsEnterprise Skills
Enterprise Skills
Graham Royce
 
Chapter 17
Chapter 17Chapter 17
Chapter 17
Graham Royce
 
Chapter 16
Chapter 16Chapter 16
Chapter 16
Graham Royce
 
Chapter 15
Chapter 15Chapter 15
Chapter 15
Graham Royce
 
Key enterprise skills
Key enterprise skillsKey enterprise skills
Key enterprise skills
Zone Glyndwr University
 
Chapter 11
Chapter 11Chapter 11
Chapter 11
Graham Royce
 

Viewers also liked (7)

Chapter 18
Chapter 18Chapter 18
Chapter 18
 
Enterprise Skills
Enterprise SkillsEnterprise Skills
Enterprise Skills
 
Chapter 17
Chapter 17Chapter 17
Chapter 17
 
Chapter 16
Chapter 16Chapter 16
Chapter 16
 
Chapter 15
Chapter 15Chapter 15
Chapter 15
 
Key enterprise skills
Key enterprise skillsKey enterprise skills
Key enterprise skills
 
Chapter 11
Chapter 11Chapter 11
Chapter 11
 

Similar to Chapter 14

Lecture notesmap
Lecture notesmapLecture notesmap
Lecture notesmap
Vasanti Dutta
 
Hashing
HashingHashing
Hashing
kurubameena1
 
hashing.pdf
hashing.pdfhashing.pdf
hashing.pdf
Yuvraj919347
 
Hashing Technique In Data Structures
Hashing Technique In Data StructuresHashing Technique In Data Structures
Hashing Technique In Data Structures
SHAKOOR AB
 
Data Structures Design Notes.pdf
Data Structures Design Notes.pdfData Structures Design Notes.pdf
Data Structures Design Notes.pdf
AmuthachenthiruK
 
Hashing data
Hashing dataHashing data
Hashing data
umair khan
 
Data structure.pptx
Data structure.pptxData structure.pptx
Data structure.pptx
SajalFayyaz
 
Sienna 9 hashing
Sienna 9 hashingSienna 9 hashing
Sienna 9 hashing
chidabdu
 
Generics collections
Generics collectionsGenerics collections
Generics collections
Yaswanth Babu Gummadivelli
 
oop lecture framework,list,maps,collection
oop lecture framework,list,maps,collectionoop lecture framework,list,maps,collection
oop lecture framework,list,maps,collection
ssuseredfbe9
 
Week 11.pptx
Week 11.pptxWeek 11.pptx
Week 11.pptx
CruiseCH
 
An important part of electrical engineering is PCB design. One impor.pdf
An important part of electrical engineering is PCB design. One impor.pdfAn important part of electrical engineering is PCB design. One impor.pdf
An important part of electrical engineering is PCB design. One impor.pdf
ARORACOCKERY2111
 
Chap09
Chap09Chap09
Chap09
Terry Yoast
 
Python - Data Collection
Python - Data CollectionPython - Data Collection
Python - Data Collection
JoseTanJr
 
Generics Collections
Generics CollectionsGenerics Collections
Generics Collections
phanleson
 
Recurrence Relation
Recurrence RelationRecurrence Relation
Recurrence Relation
NilaNila16
 
LJ_JAVA_FS_Collection.pptx
LJ_JAVA_FS_Collection.pptxLJ_JAVA_FS_Collection.pptx
LJ_JAVA_FS_Collection.pptx
Raneez2
 
Array and Pointers
Array and PointersArray and Pointers
Array and Pointers
Prof Ansari
 
Generic collection types in PLSQL
Generic collection types in PLSQLGeneric collection types in PLSQL
Generic collection types in PLSQL
Arnold Reuser
 
Collection in Java
Collection in JavaCollection in Java
Collection in Java
Home
 

Similar to Chapter 14 (20)

Lecture notesmap
Lecture notesmapLecture notesmap
Lecture notesmap
 
Hashing
HashingHashing
Hashing
 
hashing.pdf
hashing.pdfhashing.pdf
hashing.pdf
 
Hashing Technique In Data Structures
Hashing Technique In Data StructuresHashing Technique In Data Structures
Hashing Technique In Data Structures
 
Data Structures Design Notes.pdf
Data Structures Design Notes.pdfData Structures Design Notes.pdf
Data Structures Design Notes.pdf
 
Hashing data
Hashing dataHashing data
Hashing data
 
Data structure.pptx
Data structure.pptxData structure.pptx
Data structure.pptx
 
Sienna 9 hashing
Sienna 9 hashingSienna 9 hashing
Sienna 9 hashing
 
Generics collections
Generics collectionsGenerics collections
Generics collections
 
oop lecture framework,list,maps,collection
oop lecture framework,list,maps,collectionoop lecture framework,list,maps,collection
oop lecture framework,list,maps,collection
 
Week 11.pptx
Week 11.pptxWeek 11.pptx
Week 11.pptx
 
An important part of electrical engineering is PCB design. One impor.pdf
An important part of electrical engineering is PCB design. One impor.pdfAn important part of electrical engineering is PCB design. One impor.pdf
An important part of electrical engineering is PCB design. One impor.pdf
 
Chap09
Chap09Chap09
Chap09
 
Python - Data Collection
Python - Data CollectionPython - Data Collection
Python - Data Collection
 
Generics Collections
Generics CollectionsGenerics Collections
Generics Collections
 
Recurrence Relation
Recurrence RelationRecurrence Relation
Recurrence Relation
 
LJ_JAVA_FS_Collection.pptx
LJ_JAVA_FS_Collection.pptxLJ_JAVA_FS_Collection.pptx
LJ_JAVA_FS_Collection.pptx
 
Array and Pointers
Array and PointersArray and Pointers
Array and Pointers
 
Generic collection types in PLSQL
Generic collection types in PLSQLGeneric collection types in PLSQL
Generic collection types in PLSQL
 
Collection in Java
Collection in JavaCollection in Java
Collection in Java
 

More from Graham Royce

Chapter 10
Chapter 10Chapter 10
Chapter 10
Graham Royce
 
Chapter 09
Chapter 09Chapter 09
Chapter 09
Graham Royce
 
Chapter 08
Chapter 08Chapter 08
Chapter 08
Graham Royce
 
Chapter 07
Chapter 07Chapter 07
Chapter 07
Graham Royce
 
Chapter 06
Chapter 06Chapter 06
Chapter 06
Graham Royce
 
Chapter 05
Chapter 05Chapter 05
Chapter 05
Graham Royce
 
Chapter 04
Chapter 04Chapter 04
Chapter 04
Graham Royce
 
Chapter 03
Chapter 03Chapter 03
Chapter 03
Graham Royce
 
Chapter 02
Chapter 02Chapter 02
Chapter 02
Graham Royce
 
Chapter 01
Chapter 01Chapter 01
Chapter 01
Graham Royce
 
13 java in oracle
13 java in oracle13 java in oracle
13 java in oracle
Graham Royce
 
Java tut1 Coderdojo Cahersiveen
Java tut1 Coderdojo CahersiveenJava tut1 Coderdojo Cahersiveen
Java tut1 Coderdojo Cahersiveen
Graham Royce
 
My 3 min pitch pack
My 3 min pitch packMy 3 min pitch pack
My 3 min pitch pack
Graham Royce
 
Things to do
Things to doThings to do
Things to do
Graham Royce
 
House in order
House in orderHouse in order
House in order
Graham Royce
 
Blank 10 all you need
Blank 10 all you needBlank 10 all you need
Blank 10 all you need
Graham Royce
 
Goals
GoalsGoals
Idea's1 only
Idea's1 onlyIdea's1 only
Idea's1 only
Graham Royce
 
New frontiers motivation
New frontiers motivationNew frontiers motivation
New frontiers motivation
Graham Royce
 
The only slides you need
The only slides you needThe only slides you need
The only slides you need
Graham Royce
 

More from Graham Royce (20)

Chapter 10
Chapter 10Chapter 10
Chapter 10
 
Chapter 09
Chapter 09Chapter 09
Chapter 09
 
Chapter 08
Chapter 08Chapter 08
Chapter 08
 
Chapter 07
Chapter 07Chapter 07
Chapter 07
 
Chapter 06
Chapter 06Chapter 06
Chapter 06
 
Chapter 05
Chapter 05Chapter 05
Chapter 05
 
Chapter 04
Chapter 04Chapter 04
Chapter 04
 
Chapter 03
Chapter 03Chapter 03
Chapter 03
 
Chapter 02
Chapter 02Chapter 02
Chapter 02
 
Chapter 01
Chapter 01Chapter 01
Chapter 01
 
13 java in oracle
13 java in oracle13 java in oracle
13 java in oracle
 
Java tut1 Coderdojo Cahersiveen
Java tut1 Coderdojo CahersiveenJava tut1 Coderdojo Cahersiveen
Java tut1 Coderdojo Cahersiveen
 
My 3 min pitch pack
My 3 min pitch packMy 3 min pitch pack
My 3 min pitch pack
 
Things to do
Things to doThings to do
Things to do
 
House in order
House in orderHouse in order
House in order
 
Blank 10 all you need
Blank 10 all you needBlank 10 all you need
Blank 10 all you need
 
Goals
GoalsGoals
Goals
 
Idea's1 only
Idea's1 onlyIdea's1 only
Idea's1 only
 
New frontiers motivation
New frontiers motivationNew frontiers motivation
New frontiers motivation
 
The only slides you need
The only slides you needThe only slides you need
The only slides you need
 

Recently uploaded

How To Change Your Name On American Airlines Aadvantage.pptx
How To Change Your Name On American Airlines Aadvantage.pptxHow To Change Your Name On American Airlines Aadvantage.pptx
How To Change Your Name On American Airlines Aadvantage.pptx
edqour001namechange
 
Explore Architectural Wonders and Vibrant Culture With Naples Tours
Explore Architectural Wonders and Vibrant Culture With Naples ToursExplore Architectural Wonders and Vibrant Culture With Naples Tours
Explore Architectural Wonders and Vibrant Culture With Naples Tours
Naples Tours
 
bangalore metro routes, stations, timings
bangalore metro routes, stations, timingsbangalore metro routes, stations, timings
bangalore metro routes, stations, timings
narinav14
 
What Outdoor Adventures Await Young Adults in Montreal's Surrounding Nature
What Outdoor Adventures Await Young Adults in Montreal's Surrounding NatureWhat Outdoor Adventures Await Young Adults in Montreal's Surrounding Nature
What Outdoor Adventures Await Young Adults in Montreal's Surrounding Nature
Spade & Palacio Tours
 
Discover the Magic of Ibiza An Unforgettable Boat Trip
Discover the Magic of Ibiza An Unforgettable Boat TripDiscover the Magic of Ibiza An Unforgettable Boat Trip
Discover the Magic of Ibiza An Unforgettable Boat Trip
White Island Charter
 
Un viaje a Buenos Aires y sus alrededores
Un viaje a Buenos Aires y sus alrededoresUn viaje a Buenos Aires y sus alrededores
Un viaje a Buenos Aires y sus alrededores
Judy Hochberg
 
How Do I Plan a Kilimanjaro Climb? 7 Essential Tips Revealed.pdf
How Do I Plan a Kilimanjaro Climb? 7 Essential Tips Revealed.pdfHow Do I Plan a Kilimanjaro Climb? 7 Essential Tips Revealed.pdf
How Do I Plan a Kilimanjaro Climb? 7 Essential Tips Revealed.pdf
Eastafrica Travelcompany
 
Educational Tour Operators - Edutour.pdf
Educational Tour Operators - Edutour.pdfEducational Tour Operators - Edutour.pdf
Educational Tour Operators - Edutour.pdf
Edu tour
 
How To Change A Name On American Airlines Ticket.pptx
How To Change A Name On American Airlines Ticket.pptxHow To Change A Name On American Airlines Ticket.pptx
How To Change A Name On American Airlines Ticket.pptx
edqour001namechange
 
Exploring the Majesty of Nepal: An Unforgettable Tour Experience
Exploring the Majesty of Nepal: An Unforgettable Tour ExperienceExploring the Majesty of Nepal: An Unforgettable Tour Experience
Exploring the Majesty of Nepal: An Unforgettable Tour Experience
Welcome Nepal Treks and Tours
 
Ready for Cold Weather Rafting Here's What to Wear to Stay Comfortable!
Ready for Cold Weather Rafting Here's What to Wear to Stay Comfortable!Ready for Cold Weather Rafting Here's What to Wear to Stay Comfortable!
Ready for Cold Weather Rafting Here's What to Wear to Stay Comfortable!
River Recreation - Washington Whitewater Rafting
 
Understanding Bus Hire ServicesIN MELBOURNE .pptx
Understanding Bus Hire ServicesIN MELBOURNE .pptxUnderstanding Bus Hire ServicesIN MELBOURNE .pptx
Understanding Bus Hire ServicesIN MELBOURNE .pptx
MELBOURNEBUSHIRE
 
在线办理(BU毕业证书)波士顿大学毕业证录取通知书一模一样
在线办理(BU毕业证书)波士顿大学毕业证录取通知书一模一样在线办理(BU毕业证书)波士顿大学毕业证录取通知书一模一样
在线办理(BU毕业证书)波士顿大学毕业证录取通知书一模一样
v6ldcxuq
 
5-Day Nathdwara Tour Itinerary: From Temples to Traditional Markets
5-Day Nathdwara Tour Itinerary: From Temples to Traditional Markets5-Day Nathdwara Tour Itinerary: From Temples to Traditional Markets
5-Day Nathdwara Tour Itinerary: From Temples to Traditional Markets
Parag Goswami
 
Golden Gate Bridge: Magnificent Architecture in San Francisco | CIO Women Mag...
Golden Gate Bridge: Magnificent Architecture in San Francisco | CIO Women Mag...Golden Gate Bridge: Magnificent Architecture in San Francisco | CIO Women Mag...
Golden Gate Bridge: Magnificent Architecture in San Francisco | CIO Women Mag...
CIOWomenMagazine
 
The Ultimate Travel Guide to Hawaii Island Hopping in 2024
The Ultimate Travel Guide to Hawaii Island Hopping in 2024The Ultimate Travel Guide to Hawaii Island Hopping in 2024
The Ultimate Travel Guide to Hawaii Island Hopping in 2024
adventuressabifn
 
Excursions in Tahiti Island Adventure
Excursions in Tahiti Island AdventureExcursions in Tahiti Island Adventure
Excursions in Tahiti Island Adventure
Unique Tahiti
 
What Challenges Await Beginners in Snowshoeing
What Challenges Await Beginners in SnowshoeingWhat Challenges Await Beginners in Snowshoeing
What Challenges Await Beginners in Snowshoeing
Snowshoe Tahoe
 
一比一原版(UST毕业证)圣托马斯大学毕业证如何办理
一比一原版(UST毕业证)圣托马斯大学毕业证如何办理一比一原版(UST毕业证)圣托马斯大学毕业证如何办理
一比一原版(UST毕业证)圣托马斯大学毕业证如何办理
yfuwd
 
Un viaje a Argentina updated xxxxxxxxxxx
Un viaje a Argentina updated xxxxxxxxxxxUn viaje a Argentina updated xxxxxxxxxxx
Un viaje a Argentina updated xxxxxxxxxxx
Judy Hochberg
 

Recently uploaded (20)

How To Change Your Name On American Airlines Aadvantage.pptx
How To Change Your Name On American Airlines Aadvantage.pptxHow To Change Your Name On American Airlines Aadvantage.pptx
How To Change Your Name On American Airlines Aadvantage.pptx
 
Explore Architectural Wonders and Vibrant Culture With Naples Tours
Explore Architectural Wonders and Vibrant Culture With Naples ToursExplore Architectural Wonders and Vibrant Culture With Naples Tours
Explore Architectural Wonders and Vibrant Culture With Naples Tours
 
bangalore metro routes, stations, timings
bangalore metro routes, stations, timingsbangalore metro routes, stations, timings
bangalore metro routes, stations, timings
 
What Outdoor Adventures Await Young Adults in Montreal's Surrounding Nature
What Outdoor Adventures Await Young Adults in Montreal's Surrounding NatureWhat Outdoor Adventures Await Young Adults in Montreal's Surrounding Nature
What Outdoor Adventures Await Young Adults in Montreal's Surrounding Nature
 
Discover the Magic of Ibiza An Unforgettable Boat Trip
Discover the Magic of Ibiza An Unforgettable Boat TripDiscover the Magic of Ibiza An Unforgettable Boat Trip
Discover the Magic of Ibiza An Unforgettable Boat Trip
 
Un viaje a Buenos Aires y sus alrededores
Un viaje a Buenos Aires y sus alrededoresUn viaje a Buenos Aires y sus alrededores
Un viaje a Buenos Aires y sus alrededores
 
How Do I Plan a Kilimanjaro Climb? 7 Essential Tips Revealed.pdf
How Do I Plan a Kilimanjaro Climb? 7 Essential Tips Revealed.pdfHow Do I Plan a Kilimanjaro Climb? 7 Essential Tips Revealed.pdf
How Do I Plan a Kilimanjaro Climb? 7 Essential Tips Revealed.pdf
 
Educational Tour Operators - Edutour.pdf
Educational Tour Operators - Edutour.pdfEducational Tour Operators - Edutour.pdf
Educational Tour Operators - Edutour.pdf
 
How To Change A Name On American Airlines Ticket.pptx
How To Change A Name On American Airlines Ticket.pptxHow To Change A Name On American Airlines Ticket.pptx
How To Change A Name On American Airlines Ticket.pptx
 
Exploring the Majesty of Nepal: An Unforgettable Tour Experience
Exploring the Majesty of Nepal: An Unforgettable Tour ExperienceExploring the Majesty of Nepal: An Unforgettable Tour Experience
Exploring the Majesty of Nepal: An Unforgettable Tour Experience
 
Ready for Cold Weather Rafting Here's What to Wear to Stay Comfortable!
Ready for Cold Weather Rafting Here's What to Wear to Stay Comfortable!Ready for Cold Weather Rafting Here's What to Wear to Stay Comfortable!
Ready for Cold Weather Rafting Here's What to Wear to Stay Comfortable!
 
Understanding Bus Hire ServicesIN MELBOURNE .pptx
Understanding Bus Hire ServicesIN MELBOURNE .pptxUnderstanding Bus Hire ServicesIN MELBOURNE .pptx
Understanding Bus Hire ServicesIN MELBOURNE .pptx
 
在线办理(BU毕业证书)波士顿大学毕业证录取通知书一模一样
在线办理(BU毕业证书)波士顿大学毕业证录取通知书一模一样在线办理(BU毕业证书)波士顿大学毕业证录取通知书一模一样
在线办理(BU毕业证书)波士顿大学毕业证录取通知书一模一样
 
5-Day Nathdwara Tour Itinerary: From Temples to Traditional Markets
5-Day Nathdwara Tour Itinerary: From Temples to Traditional Markets5-Day Nathdwara Tour Itinerary: From Temples to Traditional Markets
5-Day Nathdwara Tour Itinerary: From Temples to Traditional Markets
 
Golden Gate Bridge: Magnificent Architecture in San Francisco | CIO Women Mag...
Golden Gate Bridge: Magnificent Architecture in San Francisco | CIO Women Mag...Golden Gate Bridge: Magnificent Architecture in San Francisco | CIO Women Mag...
Golden Gate Bridge: Magnificent Architecture in San Francisco | CIO Women Mag...
 
The Ultimate Travel Guide to Hawaii Island Hopping in 2024
The Ultimate Travel Guide to Hawaii Island Hopping in 2024The Ultimate Travel Guide to Hawaii Island Hopping in 2024
The Ultimate Travel Guide to Hawaii Island Hopping in 2024
 
Excursions in Tahiti Island Adventure
Excursions in Tahiti Island AdventureExcursions in Tahiti Island Adventure
Excursions in Tahiti Island Adventure
 
What Challenges Await Beginners in Snowshoeing
What Challenges Await Beginners in SnowshoeingWhat Challenges Await Beginners in Snowshoeing
What Challenges Await Beginners in Snowshoeing
 
一比一原版(UST毕业证)圣托马斯大学毕业证如何办理
一比一原版(UST毕业证)圣托马斯大学毕业证如何办理一比一原版(UST毕业证)圣托马斯大学毕业证如何办理
一比一原版(UST毕业证)圣托马斯大学毕业证如何办理
 
Un viaje a Argentina updated xxxxxxxxxxx
Un viaje a Argentina updated xxxxxxxxxxxUn viaje a Argentina updated xxxxxxxxxxx
Un viaje a Argentina updated xxxxxxxxxxx
 

Chapter 14

  • 1. Map Collections and Custom Collection Classes Chapter 14
  • 2. 14 Maps An object that maps a key to a value Key maps to one value A map cannot have duplicate keys Often used to associate a short key with a longer value Example: Dictionary Example: Employee database using employee ID number
  • 3. 14 Concrete Map Implementations TreeMap orders the keys. HashMap stores the keys in a hash table. HashMap class is generally preferred for its efficiency (speed) unless sorted keys are needed.
  • 4. 14 Retrieving Values by Key Use the keys collection to retrieve the keys in a map. Iterator keyIterator = myMap.keySet().iterator(); Keys collection holds “key” objects. Must cast key values to the appropriate type Integer key = (Integer)keyIterator.next(); Retrieves the next key from keyIterator (collection of keys) then casts it to an Integer and assigns it to the variable key
  • 5. 14 Custom Collection Classes Custom collections allow you to define the data storage method. Good way to understand how other collection classes work Think through issues involved in writing good generic classes
  • 6. 14 Linked List A linked list is a type of collection, similar to a train. Each object or node is linked to the next object in the collection. Singly linked list Each node knows the node following it Can only be iterated in one direction Doubly linked list Each node knows the node preceding it and the node following it Can be iterated in both directions
  • 7. 14 Linked List Hierarchy Head node points to next node in list Internal node “carries” an object (the value being stored) and points to next node in list Tail node signals end of the list