Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

org.pokersource.enum
Class NestedLoopEnumeration  view NestedLoopEnumeration download NestedLoopEnumeration.java

java.lang.Object
  extended byorg.pokersource.enum.NestedLoopEnumeration
All Implemented Interfaces:
java.util.Enumeration

public class NestedLoopEnumeration
extends java.lang.Object
implements java.util.Enumeration

An iterator that steps through an abritrary number of nested loops, each starting at zero and ending at its own upper limit. Useful when the number of nested loops is known only at runtime. Example: if the limits are set to {2, 3, 2}, then the iterator will return the following values:

        {0, 0, 0}
        {0, 0, 1}
        {0, 1, 0}
        {0, 1, 1}
        {0, 2, 0}
        {0, 2, 1}
        {1, 0, 0}
        {1, 0, 1}
        {1, 1, 0}
        {1, 1, 1}
        {1, 2, 0}
        {1, 2, 1}


Field Summary
private  int[] elem
           
private  int[] limits
           
private  int[] next
           
 
Constructor Summary
NestedLoopEnumeration(int[] limits)
          Initializes a nested loop iterator with limits.length dimensions.
 
Method Summary
 boolean hasMoreElements()
          Tests whether there are elements remaining in the enumeration.
 java.lang.Object nextElement()
          Return an integer array listing the next loop indices for each dimension.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

next

private int[] next

elem

private int[] elem

limits

private int[] limits
Constructor Detail

NestedLoopEnumeration

public NestedLoopEnumeration(int[] limits)
Initializes a nested loop iterator with limits.length dimensions.

Method Detail

hasMoreElements

public boolean hasMoreElements()
Description copied from interface: java.util.Enumeration
Tests whether there are elements remaining in the enumeration.

Specified by:
hasMoreElements in interface java.util.Enumeration

nextElement

public java.lang.Object nextElement()
Return an integer array listing the next loop indices for each dimension.

Specified by:
nextElement in interface java.util.Enumeration