package org.psjava.util;

import org.psjava.ds.array.Array;
import org.psjava.ds.array.MutableArrayFromIterable;

public class SubSetIterable {

	public static <T> Iterable<Iterable<T>> create(final Iterable<T> superSet) {
		final Array<T> array = MutableArrayFromIterable.create(superSet);
		AssertStatus.assertTrue(array.size() <= 30, "too big set to iterate sub set");
		return ConvertedIterable.create(ZeroTo.get(1 << array.size()), new Converter<Integer, Iterable<T>>() {
			@Override
			public Iterable<T> convert(final Integer bits) {
				return ConvertedIterable.create(FilteredIterable.create(ZeroTo.get(array.size()), new Filter<Integer>() {
					@Override
					public boolean isAccepted(Integer index) {
						return IntBitUtil.get(bits, index);
					}
				}), new Converter<Integer, T>() {
					@Override
					public T convert(Integer index) {
						return array.get(index);
					}
				});
			}
		});
	}

	private SubSetIterable() {
	}
}

@@ -531,24 +531,101 @@
 ger bits) %7B%0A
+%09%09%09%09// Cannot get size of the sub st at this time. Because we use filter way%0A
 %09%09%09%09return C

add simple comment