code: public static <T> Set<T> toSet(Collection<T> self) {
          Set<T> answer = new HashSet<T>(self.size());
          answer.addAll(self);
          return answer;
      }
docs: Convert a Collection to a Set. Always returns a new Set
  even if the Collection is already a Set.
  <p>
  Example usage:
  <pre class="groovyTestCase">
  def result = [1, 2, 2, 2, 3].toSet()
  assert result instanceof Set
  assert result == [1, 2, 3] as Set
  </pre>
  
  @param self a collection
  @return a Set
  @since 1.8.0