Class SubsetsIterator<T>
java.lang.Object
com.amalgamasimulation.core.combinatorics.SubsetsIterator<T>
- Type Parameters:
T
- the type of elements in the input lists and the subsets produced by this iterator
An iterator over all possible subsets of the provided list of elements. Each
subset is represented as a list of elements, and the list includes all
subsets ranging from the empty set to the full set of the input list. This
class provides an iterative approach to generating and traversing each
subset, without generating all of them in memory upfront.
For example, if the input list is [1, 2]
, the result would include
[]
, [1]
, [2]
, and [1, 2]
.
Returned list is ordered, order of elements is always the same for the same input. Order of elements in every returned subset is the same as in the original list.
- Author:
- Andrey Malykhanov
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionSubsetsIterator
(List<? extends T> elements) Creates a new instance of an iterator over all possible subsets of the provided list of elements -
Method Summary
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.util.Iterator
forEachRemaining, remove
-
Constructor Details
-
SubsetsIterator
Creates a new instance of an iterator over all possible subsets of the provided list of elements- Parameters:
elements
- list of elements- See Also:
-
-
Method Details