So today I needed to do something seemingly simple, compare two Sets. This functionality isn’t built into the Java class library, so rather than write my own I thought I would check out the Commons Collections. Sure enough, the functionality exists but when I downloaded the package, I was shocked to discover that the archive was over 4 megs and the JAR file you’re supposed to include in your own project is 547 kilobytes. That’s a lot of overhead to compare two collections, I’m writing my own method to take care of the problem.

Update: this method is trivial to write. For some reason I had thought that some iteratiion was needed, but of course all you need to do is compare the sizes of the two sets and then use the containsAll() method that’s built into the Set interface.