The usual java.util.Set implementations use data structures that are optimized for containment checks.