• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • Devaka Cooray
Saloon Keepers:
  • Ganesh Patekar
  • Tim Moores
  • Carey Brown
  • Stephan van Hulst
  • salvin francis
Bartenders:
  • Ron McLeod
  • Frits Walraven
  • Pete Letkeman

Linked List and Linked Hash Map  RSS feed

 
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

K&B says that Linked list is efficient if frequent insertions are required because elements are not shifted as in array. On the other hand says that LinkedHashMap can be slightly slower than hashmap when i comes to adding,removing or finding entries.

I am unable to understand this? As both LinkedList and LinkedHashMap implemented as doubly linked list then why LinkedHashMap is slow when it comes to frequent additions.

-Ashu
 
Sheriff
Posts: 9613
37
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well LinkedList is faster than ArrayList in terms of insertion and deletion. This is because ArrayList maintains indexed list of elements which is ordered according to insertion order.

LinkedHashSet is slower than HashSet in terms of insertion and deletion as HashSet is extremely fast as it doesn't maintain any index or ordering.

So actually LinkedList and LinkedHashSet are equally efficient. It's just that ArrayList is slow in insertion and deletion and HashSet is extremely efficient in terms of Insertion and deletion.
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!