org.matheclipse.combinatoric
Class RosenIterator
- java.lang.Object
-
- org.matheclipse.combinatoric.RosenIterator
-
- All Implemented Interfaces:
- java.util.Iterator<int[]>
- Direct Known Subclasses:
- RosenNumberPartitionIterator
public class RosenIterator extends java.lang.Object implements java.util.Iterator<int[]>An iterator that generates combinations of
nelements,C(n), in lexicographic order, based on Rosen's algorithm.- See Also:
- "Kenneth H. Rosen, Discrete Mathematics and Its Applications, 2nd edition (NY: McGraw-Hill, 1991), pp. 284-286"
-
-
Nested Class Summary
Nested Classes Modifier and Type Class and Description static classRosenIterator.Factory
-
Constructor Summary
Constructors Constructor and Description RosenIterator(int n, int k)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method and Description static longcount(int n, int k)Computes the number of unique combinations ofnelements takenkat a time, which can be computed as:n! / k! (n - k)!booleanhasNext()int[]next()voidremove()voidreset()
-
-
-
Constructor Detail
-
RosenIterator
public RosenIterator(int n, int k)- Parameters:
n- the number of elementsk- taken k at a time
-
-
Method Detail
-
reset
public void reset()
-
count
public static long count(int n, int k)Computes the number of unique combinations ofnelements takenkat a time, which can be computed as:n! / k! (n - k)!- Parameters:
n- the number of elementsk- subset/sample size- Returns:
- the number of combinations of
nelements takenkat a time
-
hasNext
public final boolean hasNext()
- Specified by:
hasNextin interfacejava.util.Iterator<int[]>- See Also:
Iterator.hasNext()
-
next
public int[] next()
- Specified by:
nextin interfacejava.util.Iterator<int[]>- See Also:
Iterator.next()
-
remove
public void remove()
- Specified by:
removein interfacejava.util.Iterator<int[]>
-
-
DMelt 3.0 © DataMelt by jWork.ORG