Hi, Guys.
I'm calculating the correlation coefficient between two HashMaps of Stock Prices keyed on Dates. However, the Dates do not always line up perfectly. So, I need to line-up the two HashMaps by their Keys.

Thus far, I'm creating two ArrayLists of the Dates, doing retainAll between them and then copying over the HashMaps using only the matching Dates.
This probably less than ideal.
If someone has a more efficient way, please let me know.
Help me out, Daniweb.

Recommended Answers

All 2 Replies

Maybe just loop through the keys of one of the Maps, deleting all the entries that don't have a corresponding key in the second Map?

Simplest way's the best I guess.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.