Created
June 23, 2011 15:33
-
-
Save dornatsky/1042777 to your computer and use it in GitHub Desktop.
Will run a for loop of an arbitrary nesting depth
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class ForLoop | |
{ | |
private int[] _indices; | |
private int[] _boundaries; | |
private Action<int[]> _action; | |
public ForLoop(int[] indices, int[] bondaries, Action<int[]> action) | |
{ | |
_indices = indices; | |
_boundaries = bondaries; | |
_action = action; | |
} | |
public void Run() | |
{ | |
for (int i = 0; i < _indices.Length; i++) | |
{ | |
int length = _boundaries[i]; | |
for (; _indices[i] < length; _indices[i]++) | |
{ | |
_action(_indices); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment