Returns an IntSet that contains all ints from the given Set that is mutable. Updates to the original Set or
the returned IntSet are not reflected in the other.
@param mutableSet set to copy from
@return IntSet with the values set
184814
public static IntSet mutableCopyFrom(Set<Integer> mutableSet) {
      if (mutableSet instanceof SingletonIntSet) {
         return mutableSet(((SingletonIntSet) mutableSet).value);
      }
      return new SmallIntSet(mutableSet);
   }
305158
public static <T> PowerSet<T> getPowerSet(Set<T> hashSet) {
		Validate.notNull(hashSet);
		if (hashSet.isEmpty())
			throw new IllegalArgumentException("set size 0");
		HashList<T> hashList = new HashList<>(hashSet);
		PowerSet<T> result = new PowerSet<>(hashList.size());
		for (int i = 0; i < Math.pow(2, hashList.size()); i++) {
			int setSize = Integer.bitCount(i);
			HashSet<T> newList = new HashSet<>(setSize);
			result.get(setSize).add(newList);
			for (int j = 0; j < hashList.size(); j++) {
				if ((i & (1 << j)) != 0) {
					newList.add(hashList.get(j));
				}
			}
		}
		return result;
	}
852115
public static <T> Set<T> keyset(Set<T> set, KeyExtractor<T> keyExtractor) {
        Set<T> keyset = new HashSet<T>();
        for(T item : set) {
            keyset.add(keyExtractor.extractKey(item));
        }
        return keyset;
    }
372310
public static final <T> Set<Set<T>> powerSet(Set<T> set)
    {
        Set<Set<T>> powerSet = new HashSet<>();
        powerSet.add(Collections.EMPTY_SET);
        powerSet(powerSet, set);
        return powerSet;
    }
1180476
public static <T> Set<T> union(Collection<Set<T>> sets) {
		Set<T> result = new HashSet<>();
		if (sets.isEmpty()) {
			return result;
		}
		Iterator<Set<T>> iter = sets.iterator();
		result.addAll(iter.next());

		if (sets.size() == 1) {
			return result;
		}

		while (iter.hasNext()) {
			result.addAll(iter.next());
		}
		return result;
	}
478084
@SuppressWarnings("unchecked")
    @NonNull
    public static <T> Set<T> unmodifiableNonNullSet(@Nullable Set<T> set) {
        return set == null || set.isEmpty()
                ? (Set<T>) emptySet()
                : Collections.unmodifiableSet(set);
    }
42261
@Inline(value="$2.$3unmodifiableSet($1)", imported=Collections.class)
	public static <T> Set<T> unmodifiableView(Set<? extends T> set) {
		return Collections.unmodifiableSet(set);
	}
522324
private FastSet convert(IntSet c)
  {
    if (c instanceof FastSet) {
      return (FastSet) c;
    }
    if (c == null) {
      return new FastSet();
    }

    FastSet res = new FastSet();
    IntIterator itr = c.iterator();
    while (itr.hasNext()) {
      res.add(itr.next());
    }
    return res;
  }
184873
public static final <K,V> MapSet<K,V> unmodifiableMapSet(MapSet<K,V> set)
    {
        return new UnmodifiableMapSet(set);
    }
630930
@Override
    public Set<java.util.Map.Entry<K, V>> entrySet() {
        final Set<Entry<K, V>> localSet = this.localMap.entrySet();

        if (isReadyOnly())
            return Collections.unmodifiableSet(localSet);

        return localSet;
    }
203197
public Set<T> internAll(Set<T> s) {
    Set<T> result = Generics.newHashSet();
    for (T o : s) {
      result.add(intern(o));
    }
    return result;
  }
94620
@Override
    public <O extends Comparable> Set<O> transform(Set<O> set) {
        return checkNotNull(set);
    }
370
public SortedSet<T> firstSubset(SortedSet<T> set) {
        if (this.rootNodes.isEmpty() || set == null || set.isEmpty()) {
            return null;
        }
        return firstSubset(set, this.rootNodes);
    }
152516
public Set<E> getSubSet(int k) {
        int from = -1;
        //TODO: very bad. Bounds should be memorized
        for (int x = 0; x < values.size(); x++) {
            int cIdx = index.get(values.get(x).id());
            if (cIdx == k && from == -1) {
                from = x;
            }
            if (from >= 0 && cIdx > k) {
                return new ElementSubSet<>(this, k, from, x);
            }
        }
        if (from >= 0) {
            return new ElementSubSet<>(this, k, from, values.size());
        }
        return Collections.emptySet();
    }
1161265
public static <T> Set<T> iterableToSet(Iterable<T> iterable) {
        if (iterable == null) {
            return Collections.emptySet();
        }
        if (iterable instanceof Set) {
            return (Set<T>) iterable;
        }
        Iterator<T> i = iterable.iterator();
        if (i.hasNext()) {
            Set<T> list = new HashSet<>();
            while (i.hasNext()) {
                list.add(i.next());
            }
            return list;
        }
        return Collections.emptySet();
    }
550711
public static <T> Set<T> getSet(Collection<T> collection) {
    Set<T> set = new LinkedHashSet<T>();
    set.addAll(collection);

    return set;
  }
369390
@Override
    public Set<K> keySet() {
        try {
            lockAllSegments();
            Set<K> set = new HashSet<>();
            for (LinkedHashMapSegment<K, V> seg : segments) {
                set.addAll(seg.keySet());
            }
            return set;
        } finally {
            unlockAllSegments();
        }
    }