For a project I'm working on, I need a way to calculate a unique integer representation of a data structure with type [(int, int)]
, i. e. a collection of (nonnegative) integer pairs. The requirement is that while the ordering within the pair matters, the collection itself is order-insensitive. After some searching, I've come believe that a suitable solution would be to encode each pair using the Cantor pairing function and xor
the results.
The range will be fairly small, say 1-700 for the first integer in the pair, 1-10 for the second one and the list will contain around 5-15 of these pairs.
If you believe there's a better solution, let me know, but an answer "yes, this will work" would be terrific as well :)