Does "set" mean the same thing in these two sentences?

He gave a final set to his hat.

The set of prime numbers is infinite.
different meanings