Only if you have two of them <a,b> and <b,a>.
The trick here is that a lot of times b is an object and you are going to have to come up with a hash function and equality function for your object.
You may also want to consider using TrieMaps instead since they are much more memory efficient. See: NFTAnvil IC network tests report