Memoize hash result for UidPair

The UidPair is an expensive type to calculate the hash for.  The interfaces of QHash and QSet require the hash value to be calculated redundantly, but we can avoid this by additionally storing the hash value in the stored object.