Jump to content

HashMap vs LinkedHashMap


Amrita

Recommended Posts

Small question regarding HashMap vs LinkedHashMap.

Implementation kadu practical example for LinkedHashmap in working environment kosam thinking.  Hashmap ki LinkedHashmap is almost same but linked hashmap uses doubly linked list and entries are in insertion order. In real world scenario i never had to use LinkedHashMap at least do not remember using it. Deniki use cheyachu in real world emanna example cheppagalara?

Thanks in advance.

Link to comment
Share on other sites

20 minutes ago, Amrita said:

Small question regarding HashMap vs LinkedHashMap.

Implementation kadu practical example for LinkedHashmap in working environment kosam thinking.  Hashmap ki LinkedHashmap is almost same but linked hashmap uses doubly linked list and entries are in insertion order. In real world scenario i never had to use LinkedHashMap at least do not remember using it. Deniki use cheyachu in real world emanna example cheppagalara?

Thanks in advance.

When you have a scenario where you need key value pair where you can’t use arraylist and preserve insertion order where you can’t use hashmap . Ee rendu chala rare ga needed nenu na jivitham lo once used when A stored proc is returning sorted rows my hashmap messed up the order I changed it to likedhashmap with 1 line change I understood the power of interface and linked datastructures idhi long long back when I moved from c programming to java 

Link to comment
Share on other sites

LRU cache is one example where it is used.

Any place where you want keys in order of insertion - you get data from database in some order and you need to display results in the same order but need to identify that data using keys. Shopping cart is a good example as you mentioned.  

 

Link to comment
Share on other sites

3 minutes ago, ennnna chata said:

When you have a scenario where you need key value pair where you can’t use arraylist and preserve insertion order where you can’t use hashmap . Ee rendu chala rare ga needed nenu na jivitham lo once used when A stored proc is returning sorted rows my hashmap messed up the order I changed it to likedhashmap with 1 line change I understood the power of interface and linked datastructures idhi long long back when I moved from c programming to java 

I guess this is one good example. Thanks dude.

Link to comment
Share on other sites

6 minutes ago, GLK said:

LRU cache is one example where it is used.

Any place where you want keys in order of insertion - you get data from database in some order and you need to display results in the same order but need to identify that data using keys. Shopping cart is a good example as you mentioned.  

 

 

11 minutes ago, ennnna chata said:

When you have a scenario where you need key value pair where you can’t use arraylist and preserve insertion order where you can’t use hashmap . Ee rendu chala rare ga needed nenu na jivitham lo once used when A stored proc is returning sorted rows my hashmap messed up the order I changed it to likedhashmap with 1 line change I understood the power of interface and linked datastructures idhi long long back when I moved from c programming to java 

Thanks. Just wondering what was the business requirement  that needed DB order to be maintained?  Mostly sorting aey use chestam kada sCo_^Y

Link to comment
Share on other sites

10 hours ago, Amrita said:

Small question regarding HashMap vs LinkedHashMap.

Implementation kadu practical example for LinkedHashmap in working environment kosam thinking.  Hashmap ki LinkedHashmap is almost same but linked hashmap uses doubly linked list and entries are in insertion order. In real world scenario i never had to use LinkedHashMap at least do not remember using it. Deniki use cheyachu in real world emanna example cheppagalara?

Thanks in advance.

I have used it for building game is preserve selection of order by customer on screen .based on that my answer is calculated on backend 

Link to comment
Share on other sites

14 hours ago, Amrita said:

 

Thanks. Just wondering what was the business requirement  that needed DB order to be maintained?  Mostly sorting aey use chestam kada sCo_^Y

Business req undakapovachu... Proc nundi sorted vasthe why again sorting in java where you can use linkedhashmap and preserve the order... 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...