I have a hashset of objects, let’s call the hashset ‘myset’ and the objects ‘pair’.
Each object contains two further objects (first and second) and an int.
I’m adding unique pairs of objects to his hashset along with a value related to this pair.
I need to check, before adding a pair, that the reverse pair does not exist in the hashset.
Example: Pair 1 contains object apple, object banana and the value 5
I want to know if myset contains a Pair containing banana, apple and 5 (and if so, not add Pair 1 to it).
If I create a test pair into which I add {first: banana}, {second: apple} and 5 and check if myset contains the test pair, I get a result of false.
I presume the Contains() method of the HashSet object checks for some unique property of a pair object to see if it exists in the set?
What would be a sensible method of checking for the existence of a pair object matching the desciption of the test pair?