• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Factors to be considered for creating custom hashmap

 
Ranch Hand
Posts: 35
Eclipse IDE Firefox Browser Windows XP
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
For the application, we are planning for creating custom hashmap class.

So will you please help us to consider the factors for creating custom hashmap.
 
Bartender
Posts: 1558
5
Eclipse IDE Java Linux
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Kiran,

Can you please be clearer about what is behavioral difference between in built HashMap and custom HashMap you are planning to build?

What problem are you facing while using current implementation of HashMap (i.e. what is the reason behind creating custom HashMap)?
 
Marshal
Posts: 79180
377
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Not a “beginning” question. Moving thread.
 
Sheriff
Posts: 3837
66
Netbeans IDE Oracle Firefox Browser
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Kiran Yadav wrote:So will you please help us to consider the factors for creating custom hashmap.


The immediately obvious factors are:

1) No added benefit (the JDK's implementation is about as good as it gets, if you need highly concurrent implementation, you can use the ConcurrentHashMap).

2) More overall work which will never pay back, possible need to maintain the new code.

3) Possibility of bugs (JDK's implementations were tested by millions of users and are virtually bug-free).

I don't want to sound harsh, but in my opinion you need very very very serious reason to reimplement a hashmap in a real-world application. All the factors I can think of favor the JDK's HashMap heavily.
 
Bartender
Posts: 6109
6
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Kiran Yadav wrote:For the application, we are planning for creating custom hashmap class.

So will you please help us to consider the factors for creating custom hashmap.



If you're creating this for a real application, then only you know the factors to consider, since only you know your requirements.

If you're doing this as an academic exercise, then the factors are whatever you decide to pick to make it interesting: insertion performance, lookup performance, memory usage, scalability, complexity, thread-safety, ... etc. ...
 
Kiran Yadav
Ranch Hand
Posts: 35
Eclipse IDE Firefox Browser Windows XP
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you so much everyone for your inputs. This will surely help me to create custom hashmap for real application.
 
Campbell Ritchie
Marshal
Posts: 79180
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You’re welcome (on behalf of the others who posted). But I still think it would have been better for us to have explained how not to create this custom map.
 
Jeff Verdegan
Bartender
Posts: 6109
6
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Kiran Yadav wrote:Thank you so much everyone for your inputs. This will surely help me to create custom hashmap for real application.



But why do you think you need to? In what way does java.util.HashMap not suit your needs?
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic