I need a HashSet implementation where the elements are a pair of Integers
eg. Set s = { {1,2} , {3,4} , {1,4}}
. Here the set s has 3 elements.
This kind of two key HashSet is needed in many situations like, I have a relation in my database where the candidate key is a combination of two columns.
Is there some library which already provides this?
If no such implementation is available, then rather then implementing the entire data structure from scratch, will it be easier (and efficient?) to extend the HashSet implementation in Java?
For this requirement I would create a data holder with the 2 integers as attributes and provide equals and hashcode implementations. Then put those objects in the Set.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With