To compare two hashmaps



Keywords: to compare two hashmaps
Description: I am writing an application for my company. I am wanting to compare inventory authorized to that of inventory on-hand. First, I have constructed a HashMap, HashMap authorized, containing

I am writing an application for my company. I am wanting to compare inventory authorized to that of inventory on-hand. First, I have constructed a HashMap, HashMap authorized, containing serial-numbers(keys)and authorized quantities(values). Next, I am querying a database and obtaining a ResultSet object that contains serial numbers. I am wanting to take this ResultSet and make a HashMap, HashMap on_hand, containing the same serial numbers but with the quantities that are present.

Once I have these two HashMaps, I am wanting to compare the values(authorized vs. on-hand) for each serial number in the HashMap.

You can load both HashMaps, then iterate through the entries in one, and try to get() the entry for the same key in the other table. An example may be found in my first post in this thread. Note also that you don't necessarily have to wait for the second HashMap to be complete - since you're already looping through ResultSets, you could start your comparison as you build the second HashMap, by checking the values you read from the second ResultSet against the first HashMap. In fact, if the only reason you build the HashMaps is to generate the comparison, you may not even need to build the second HashMap at all.

Also: if you need to check for inventory that is authorized but not on-hand, you will need to loop through the authorized HashMap or ResultSet and check it against the on-hand HashMap. If you need to check for inventory that is on-hand but not authorized. you will need to loop through the on-hand HashMap or ResultSet and check it against the authorized HashMap. If you need to do both, you will have to build both HashMaps and loop through each.






Photogallery To compare two hashmaps:


Project Tungsten: Bringing Spark Closer to Bare Metal | Databricks ...


Drools: User forum - MOVED - Is it possible to compare the hashmap ...


How Much JUnit Test Code is Needed for a Minimal HashMap ...


Drools: User forum - MOVED - Is it possible to compare the hashmap ...


Monkey X - Hashmap and Hashset


How to Create and Destroy Java Memory Leaks | AppNeta Blogs


24-collections-framework- ...


Tweaking Your Android Performance: ParseArray v. Hashmap - DZone ...


CIS 35A: Introduction to Java Programming


Talk:kd-tree - RoboWiki


Java Data Structures Interview Questions


OpenJDK and HashMap . Safely Teaching an Old Dog New (Off-Heap ...


Writing Fast, Memory-Efficient JavaScript  Smashing Magazine


Collections - Learning Java, 4th Edition


ILIC Dejan - MSc: Secure Business Computation by using Garbled Circui


OCAJP java 7 Primera Version


OpenJDK and HashMap . Safely Teaching an Old Dog New (Off-Heap ...


Understand Initial Capacity and Load Factor in hashmap hashtable ...


Java By Patel


Presentation "Data Structures and Algorithms Course slides ...